setup.ts 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. import { TabList } from '@/common/components/description/interface';
  2. import { initData } from '@/common/methods';
  3. import APP from '@/services';
  4. import { getQuoteDayInfoByCode } from '@/services/bus/goods';
  5. import { Ermcp3GoodsGroup, Goods } from '@/services/go/ermcp/goodsInfo/interface';
  6. import { QueryQuoteDayRsp } from '@/services/go/quote/interface';
  7. import { Externalexchange } from '@/services/go/useInfo/interface';
  8. import { ref } from 'vue';
  9. export function getColumnsList() {
  10. const columns = [
  11. { title: '序号', key: 'index', width: 80 },
  12. { title: '代码', key: 'goodscode' },
  13. { title: '名称', key: 'goodsname' },
  14. { title: '买价', key: 'bid' },
  15. { title: '买量', key: 'bidvolume' },
  16. { title: '卖价', key: 'ask' },
  17. { title: '卖量', key: 'askvolume' },
  18. { title: '当前价', key: 'last' },
  19. { title: '涨跌', key: 'change' }, // 最新价 - 昨结价
  20. { title: '幅度', key: 'amplitude' }, // (最新价 - 昨结价) / 100 %
  21. { title: '开盘', key: 'opened' },
  22. { title: '最高', key: 'highest' },
  23. { title: '最低', key: 'lowest' },
  24. { title: '结算', key: 'settle' },
  25. { title: '昨结算', key: 'presettle' },
  26. // { title: '振幅', key: 'vibration' }, // (最高价 - 最低价 ) / 最新价 * 100 %
  27. // { title: '总量', key: 'totalvolume' },
  28. // { title: '现量', key: 'lastvolume' },
  29. // { title: '持仓量', key: 'holdvolume' },
  30. // { title: '日增', key: 'holdincrement' },
  31. // { title: '金额', key: 'totalturnover' },
  32. ];
  33. return columns.map(el => {
  34. return { dataIndex: el.key, width: 100, align: 'center', slots: { customRender: el.key, }, ...el }
  35. })
  36. }
  37. // 外部交易所
  38. export const useExternalexchange = () => {
  39. const loading = ref<boolean>(false)
  40. const index = ref<string>('0');
  41. // 外部交易所 数据
  42. const externalexchangeList = ref<Externalexchange[]>([])
  43. const tabList = ref<TabList[]>([])
  44. // 盘面数据
  45. const tableList = ref<QueryQuoteDayRsp[]>([
  46. ])
  47. // 获取 商品数据
  48. const useGoodsList = (exchareaid: number) => {
  49. const goodsList = APP.get('Goods') as Goods[];
  50. const goodsGroups = APP.get('goodsgroups') as Ermcp3GoodsGroup[]
  51. // 商品组
  52. const selectedGoodsGroups = goodsGroups.filter(e => e.exexchangeid === exchareaid).map(el => el.goodsgroupid)
  53. return goodsList.filter(e => {
  54. return e.goodsstatus === 3 && selectedGoodsGroups.includes(e.goodsgroupid)
  55. })
  56. }
  57. initData(() => {
  58. externalexchangeList.value = APP.get('externalexchange')
  59. const list = externalexchangeList.value.map((e: Externalexchange) => {
  60. return { lable: e.exexchangename, code: e.exexchangecode };
  61. }) as TabList[]
  62. tabList.value = list
  63. if (list.length) {
  64. hanldeQuoteData(0)
  65. }
  66. })
  67. function hanldeQuoteData(index: number) {
  68. const id = getExternalId(index)
  69. // 找到 交易所 下的商品列表
  70. const goodsList = useGoodsList(id)
  71. // 找到 盘面数据
  72. getQuoteData(goodsList)
  73. }
  74. function getQuoteData(goodsList: Goods[]) {
  75. tableList.value.length = 0
  76. // 找到盘面数据
  77. goodsList.forEach(el => {
  78. const quote = getQuoteDayInfoByCode(el.goodscode);
  79. if (quote) {
  80. tableList.value.push(quote)
  81. } else {
  82. tableList.value.push({
  83. ask: 0,
  84. ask1number: 0,
  85. ask2: 0,
  86. ask3: 0,
  87. ask4: 0,
  88. ask5: 0,
  89. ask6: 0,
  90. ask7: 0,
  91. ask8: 0,
  92. ask9: 0,
  93. askorderid: 0,
  94. askorderid2: 0,
  95. askorderid3: 0,
  96. askorderid4: 0,
  97. askorderid5: 0,
  98. askordervolume: 0,
  99. askordervolume1number: 0,
  100. askordervolume2: 0,
  101. askordervolume3: 0,
  102. askordervolume4: 0,
  103. askordervolume5: 0,
  104. askordervolume6: 0,
  105. askordervolume7: 0,
  106. askordervolume8: 0,
  107. askordervolume9: 0,
  108. askqueueinfo: '',
  109. askvolume: 0,
  110. askvolume1number: 0,
  111. askvolume2: 0,
  112. askvolume3: 0,
  113. askvolume4: 0,
  114. askvolume5: 0,
  115. askvolume6: 0,
  116. askvolume7: 0,
  117. askvolume8: 0,
  118. askvolume9: 0,
  119. averageprice: 0,
  120. bid: 0,
  121. bid1number: 0,
  122. bid2: 0,
  123. bid3: 0,
  124. bid4: 0,
  125. bid5: 0,
  126. bid6: 0,
  127. bid7: 0,
  128. bid8: 0,
  129. bid9: 0,
  130. bidorderid: 0,
  131. bidorderid2: 0,
  132. bidorderid3: 0,
  133. bidorderid4: 0,
  134. bidorderid5: 0,
  135. bidordervolume: 0,
  136. bidordervolume1number: 0,
  137. bidordervolume2: 0,
  138. bidordervolume3: 0,
  139. bidordervolume4: 0,
  140. bidordervolume5: 0,
  141. bidordervolume6: 0,
  142. bidordervolume7: 0,
  143. bidordervolume8: 0,
  144. bidordervolume9: 0,
  145. bidqueueinfo: '',
  146. bidvolume: 0,
  147. bidvolume1number: 0,
  148. bidvolume2: 0,
  149. bidvolume3: 0,
  150. bidvolume4: 0,
  151. bidvolume5: 0,
  152. bidvolume6: 0,
  153. bidvolume7: 0,
  154. bidvolume8: 0,
  155. bidvolume9: 0,
  156. calloptionpremiums: 0,
  157. calloptionpremiums2: 0,
  158. calloptionpremiums3: 0,
  159. calloptionpremiums4: 0,
  160. calloptionpremiums5: 0,
  161. cleartime: 0,
  162. exchangecode: 0,
  163. exchangedate: 0,
  164. goodscode: '',
  165. refgoodscode: '',
  166. grepmarketprice: 0,
  167. highest: 0,
  168. holdincrement: 0,
  169. holdvolume: 0,
  170. iep: 0,
  171. iev: 0,
  172. inventory: 0,
  173. iscleared: 0,
  174. issettled: 0,
  175. last: 0,
  176. lastlot: 0,
  177. lasttime: '',
  178. lastturnover: 0,
  179. lastvolume: 0,
  180. limitdown: 0,
  181. limitup: 0,
  182. lowest: 0,
  183. nontotalholdervolume: 0,
  184. nontotallot: 0,
  185. nontotalturnover: 0,
  186. nontotalvolume: 0,
  187. opened: 0,
  188. opentime: '',
  189. orderid: 0,
  190. preclose: 0,
  191. preholdvolume: 0,
  192. presettle: 0,
  193. publictradetype: '',
  194. putoptionpremiums: 0,
  195. putoptionpremiums2: 0,
  196. putoptionpremiums3: 0,
  197. putoptionpremiums4: 0,
  198. putoptionpremiums5: 0,
  199. settle: 0,
  200. strikeprice: 0,
  201. totalaskvolume: 0,
  202. totalbidvolume: 0,
  203. totallot: 0,
  204. totalturnover: 0,
  205. totalvolume: 0,
  206. utclasttime: '',
  207. })
  208. }
  209. })
  210. }
  211. function getExternalId(index: number) {
  212. return externalexchangeList.value[index].autoid
  213. }
  214. return { index, loading, tabList, tableList, hanldeQuoteData }
  215. }