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) } }) } function getExternalId(index: number) { return externalexchangeList.value[index].autoid } return { index, loading, tabList, tableList, hanldeQuoteData } }