index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <!--期货-->
  3. <div class="topTableHeight">
  4. <a-table :columns="getColumnsList()" :class="['srcollYTable', isBottom ? 'condSecondTabTable' : 'condSecondTabTableNoBottom', tableList.length ? 'noPlaceHolder' : 'hasPlaceHolder']" :scroll="{ x: '100%', y: isBottom ? 'calc(100vh- 443px)' : 'calc(100vh - 196px)' }" :pagination="false" :loading="loading" :customRow="Rowclick" rowKey="key" :data-source="tableList">
  5. <template #totalturnover="{ text }">
  6. <span>{{changeUnit(text)}}</span>
  7. </template>
  8. <!-- 涨跌 -->
  9. <template #change="{ record }">
  10. <span>{{quoteChange(record, record.decimalplace)}}</span>
  11. </template>
  12. <!-- 幅度 -->
  13. <template #amplitude="{ record }">
  14. <span>{{quoteAmplitude(record, record.decimalplace)}}</span>
  15. </template>
  16. <!-- 振幅 -->
  17. <template #vibration="{ record }">
  18. <span>{{quoteAmplituOfVibration(record, record.decimalplace)}}</span>
  19. </template>
  20. <template #index="{ index }">
  21. <span>{{index + 1}}</span>
  22. </template>
  23. <!-- 买价 -->
  24. <template #bid="{ text, record }">
  25. <span :class="handleQuotePriceColor(text, record.presettle)">{{text}}</span>
  26. </template>
  27. <!-- 卖价 -->
  28. <template #ask="{ text, record }">
  29. <span :class="handleQuotePriceColor(text, record.presettle)">{{text}}</span>
  30. </template>
  31. <!-- 最新价 -->
  32. <template #last="{ text, record }">
  33. <span :class="handleQuotePriceColor(text, record.presettle)">{{text}}</span>
  34. </template>
  35. <!-- 最低价 -->
  36. <template #lowest="{ text, record }">
  37. <span :class="handleQuotePriceColor(text, record.presettle)">{{text}}</span>
  38. </template>
  39. <!-- 最高价 -->
  40. <template #highest="{ text, record }">
  41. <span :class="handleQuotePriceColor(text, record.presettle)">{{text}}</span>
  42. </template>
  43. </a-table>
  44. <ThridMenu :list="tabList" :selectedKey="index" @selectMenu="changeTab" />
  45. <!-- 右键 -->
  46. <contextMenu :contextMenu="contextMenu" @cancel="closeContext" :list="buttons"></contextMenu>
  47. <component :is="componentId" v-if="componentId" :selectedRow="selectedRow" @cancel="closeComponent"></component>
  48. </div>
  49. </template>
  50. <script lang="ts">
  51. import { TabList } from '@/common/components/description/interface';
  52. import ThridMenu from '@/common/components/thirdMenu/index.vue';
  53. import { getShowBottomValue } from '@/common/config/constrolBottom';
  54. import { handleModalComponent } from '@/common/setup/asyncComponent';
  55. import { handleQuotePriceColor, handleSubcriteOnDemandQuote, quoteAmplitude, quoteAmplituOfVibration, quoteChange } from '@/common/setup/table/tableQuote';
  56. import { QueryQuoteDayRsp } from '@/services/go/quote/interface';
  57. import { ref } from 'vue';
  58. import { getColumnsList, useExternalexchange } from './setup';
  59. import { getTableButton } from '@/common/setup/table/button';
  60. import { contextMenu, defineAsyncComponent, defineComponent } from '@/common/export/commonTable';
  61. import { handleContextMenu } from '@/common/components/contextMenu/setup';
  62. import { TableEventCB } from '@/common/setup/table/interface';
  63. import { getTableEvent } from '@/common/export/table';
  64. import { ContextMenuTemp } from '@/common/components/contextMenu/interface';
  65. import { BtnListType } from '@/common/components/btnList/interface';
  66. export default defineComponent({
  67. name: 'spot_trade_order_transaction_swap',
  68. components: {
  69. ThridMenu,
  70. contextMenu,
  71. trade: defineAsyncComponent(() => import('./compoments/futures-trade/index.vue')),
  72. },
  73. setup() {
  74. const isBottom = getShowBottomValue();
  75. const selectedRow = ref<QueryQuoteDayRsp>();
  76. const buttons = getTableButton();
  77. console.log('buttons', buttons);
  78. const { index, loading, tabList, tableList, hanldeQuoteData } = useExternalexchange();
  79. // 行情按需订阅
  80. let stopSubcribe = handleSubcriteOnDemandQuote<QueryQuoteDayRsp>(tableList);
  81. function changeTab(index: number, current: TabList) {
  82. hanldeQuoteData(index);
  83. console.log(index, current);
  84. // 停止上次订阅
  85. stopSubcribe();
  86. // 重新发起订阅
  87. stopSubcribe = handleSubcriteOnDemandQuote<QueryQuoteDayRsp>(tableList);
  88. }
  89. // 右键逻辑
  90. const { contextMenu, closeContext: closeContextAction } = handleContextMenu();
  91. // 右键回调函数
  92. const eventsCB: TableEventCB = {
  93. contextmenuCB: (record: QueryQuoteDayRsp, value: ContextMenuTemp) => {
  94. // 控制打开右键
  95. contextMenu.value = value;
  96. },
  97. };
  98. // 表格事件
  99. const { Rowclick } = getTableEvent<QueryQuoteDayRsp>(eventsCB);
  100. // 控制异步组件
  101. const { componentId, closeComponent, openComponent } = handleModalComponent(() => {}, selectedRow);
  102. // 关闭右键
  103. function closeContext(value: BtnListType | null) {
  104. // 打开对应的弹窗组件
  105. if (value) openComponent(value, selectedRow.value);
  106. // 关闭右键
  107. closeContextAction();
  108. }
  109. return {
  110. index,
  111. loading,
  112. tabList,
  113. changeTab,
  114. tableList,
  115. isBottom,
  116. handleQuotePriceColor,
  117. quoteChange,
  118. quoteAmplitude,
  119. quoteAmplituOfVibration,
  120. getColumnsList,
  121. buttons,
  122. contextMenu,
  123. closeContext,
  124. Rowclick,
  125. componentId,
  126. closeComponent,
  127. selectedRow,
  128. };
  129. },
  130. });
  131. </script>
  132. <style lang="less">
  133. .noData {
  134. .position(absolute, 28px, 0, 0, 0);
  135. }
  136. .filter-custom-table {
  137. display: inline-flex;
  138. padding-top: 4px;
  139. height: 34px;
  140. .conditionSelect:first-child {
  141. margin-right: 10px;
  142. }
  143. .btnDeafault.ant-btn,
  144. .operBtn.ant-btn {
  145. height: 26px !important;
  146. line-height: 26px !important;
  147. }
  148. .ant-select-single:not(.ant-select-customize-input) + .ant-select-single:not(.ant-select-customize-input),
  149. .ant-select + .ant-space.ant-space-vertical {
  150. margin-left: 10px;
  151. }
  152. .ant-select-single:not(.ant-select-customize-input) {
  153. height: 26px;
  154. line-height: 26px !important;
  155. .ant-select-selector {
  156. height: 26px;
  157. border-color: @m-grey46 !important;
  158. background: @m-grey47;
  159. .rounded-corners(3px);
  160. .ant-select-selection-item {
  161. line-height: 26px;
  162. }
  163. .ant-select-selection-search {
  164. height: 26px;
  165. .ant-select-selection-search-input {
  166. height: 26px;
  167. line-height: 27px !important;
  168. }
  169. }
  170. .ant-select-selection-placeholder {
  171. line-height: 26px;
  172. }
  173. }
  174. }
  175. .allDatePicker.ant-calendar-picker {
  176. height: 26px !important;
  177. border: 1px solid @m-grey46 !important;
  178. .ant-calendar-picker-input.ant-input {
  179. height: 26px;
  180. line-height: 26px;
  181. &::placeholder {
  182. color: @m-grey10 !important;
  183. }
  184. }
  185. }
  186. .conditionSelect + .conditionSelect {
  187. margin-left: 10px;
  188. }
  189. }
  190. </style>