import { TabList } from '@/common/components/description/interface'; import { initData } from '@/common/methods'; import APP from '@/services'; import { getQuoteDayInfoByCode } from '@/services/bus/goods'; import { Ermcp3GoodsGroup, Goods } from '@/services/go/ermcp/goodsInfo/interface'; import { QueryQuoteDayRsp } from '@/services/go/quote/interface'; import { Externalexchange } from '@/services/go/useInfo/interface'; import { ref } from 'vue'; export function getColumnsList() { const columns = [ { title: '序号', key: 'index', width: 80 }, { title: '代码', key: 'goodscode' }, { title: '名称', key: 'goodsname' }, { title: '买价', key: 'bid' }, { title: '买量', key: 'bidvolume' }, { title: '卖价', key: 'ask' }, { title: '卖量', key: 'askvolume' }, { title: '当前价', key: 'last' }, { title: '涨跌', key: 'change' }, // 最新价 - 昨结价 { title: '幅度', key: 'amplitude' }, // (最新价 - 昨结价) / 100 % { title: '开盘', key: 'opened' }, { title: '最高', key: 'highest' }, { title: '最低', key: 'lowest' }, { title: '结算', key: 'settle' }, { title: '昨结算', key: 'presettle' }, // { title: '振幅', key: 'vibration' }, // (最高价 - 最低价 ) / 最新价 * 100 % // { title: '总量', key: 'totalvolume' }, // { title: '现量', key: 'lastvolume' }, // { title: '持仓量', key: 'holdvolume' }, // { title: '日增', key: 'holdincrement' }, // { title: '金额', key: 'totalturnover' }, ]; return columns.map(el => { return { dataIndex: el.key, width: 100, align: 'center', slots: { customRender: el.key, }, ...el } }) } // 外部交易所 export const useExternalexchange = () => { const loading = ref(false) const index = ref('0'); // 外部交易所 数据 const externalexchangeList = ref([]) const tabList = ref([]) // 盘面数据 const tableList = ref([ ]) // 获取 商品数据 const useGoodsList = (exchareaid: number) => { const goodsList = APP.get('Goods') as Goods[]; const goodsGroups = APP.get('goodsgroups') as Ermcp3GoodsGroup[] // 商品组 const selectedGoodsGroups = goodsGroups.filter(e => e.exexchangeid === exchareaid).map(el => el.goodsgroupid) return goodsList.filter(e => { return e.goodsstatus === 3 && selectedGoodsGroups.includes(e.goodsgroupid) }) } initData(() => { externalexchangeList.value = APP.get('externalexchange') const list = externalexchangeList.value.map((e: Externalexchange) => { return { lable: e.exexchangename, code: e.exexchangecode }; }) as TabList[] tabList.value = list if (list.length) { hanldeQuoteData(0) } }) function hanldeQuoteData(index: number) { const id = getExternalId(index) // 找到 交易所 下的商品列表 const goodsList = useGoodsList(id) // 找到 盘面数据 getQuoteData(goodsList) } function getQuoteData(goodsList: Goods[]) { tableList.value.length = 0 // 找到盘面数据 goodsList.forEach(el => { const quote = getQuoteDayInfoByCode(el.goodscode); if (quote) { tableList.value.push(quote) } else { tableList.value.push({ ask: 0, ask1number: 0, ask2: 0, ask3: 0, ask4: 0, ask5: 0, ask6: 0, ask7: 0, ask8: 0, ask9: 0, askorderid: 0, askorderid2: 0, askorderid3: 0, askorderid4: 0, askorderid5: 0, askordervolume: 0, askordervolume1number: 0, askordervolume2: 0, askordervolume3: 0, askordervolume4: 0, askordervolume5: 0, askordervolume6: 0, askordervolume7: 0, askordervolume8: 0, askordervolume9: 0, askqueueinfo: '', askvolume: 0, askvolume1number: 0, askvolume2: 0, askvolume3: 0, askvolume4: 0, askvolume5: 0, askvolume6: 0, askvolume7: 0, askvolume8: 0, askvolume9: 0, averageprice: 0, bid: 0, bid1number: 0, bid2: 0, bid3: 0, bid4: 0, bid5: 0, bid6: 0, bid7: 0, bid8: 0, bid9: 0, bidorderid: 0, bidorderid2: 0, bidorderid3: 0, bidorderid4: 0, bidorderid5: 0, bidordervolume: 0, bidordervolume1number: 0, bidordervolume2: 0, bidordervolume3: 0, bidordervolume4: 0, bidordervolume5: 0, bidordervolume6: 0, bidordervolume7: 0, bidordervolume8: 0, bidordervolume9: 0, bidqueueinfo: '', bidvolume: 0, bidvolume1number: 0, bidvolume2: 0, bidvolume3: 0, bidvolume4: 0, bidvolume5: 0, bidvolume6: 0, bidvolume7: 0, bidvolume8: 0, bidvolume9: 0, calloptionpremiums: 0, calloptionpremiums2: 0, calloptionpremiums3: 0, calloptionpremiums4: 0, calloptionpremiums5: 0, cleartime: 0, exchangecode: 0, exchangedate: 0, goodscode: '', refgoodscode: '', grepmarketprice: 0, highest: 0, holdincrement: 0, holdvolume: 0, iep: 0, iev: 0, inventory: 0, iscleared: 0, issettled: 0, last: 0, lastlot: 0, lasttime: '', lastturnover: 0, lastvolume: 0, limitdown: 0, limitup: 0, lowest: 0, nontotalholdervolume: 0, nontotallot: 0, nontotalturnover: 0, nontotalvolume: 0, opened: 0, opentime: '', orderid: 0, preclose: 0, preholdvolume: 0, presettle: 0, publictradetype: '', putoptionpremiums: 0, putoptionpremiums2: 0, putoptionpremiums3: 0, putoptionpremiums4: 0, putoptionpremiums5: 0, settle: 0, strikeprice: 0, totalaskvolume: 0, totalbidvolume: 0, totallot: 0, totalturnover: 0, totalvolume: 0, utclasttime: '', }) } }) } function getExternalId(index: number) { return externalexchangeList.value[index].autoid } return { index, loading, tabList, tableList, hanldeQuoteData } }