|
|
@@ -1,115 +1,91 @@
|
|
|
<!-- 交易市场-订单交易 -->
|
|
|
<template>
|
|
|
- <app-table :data="tableList" v-model:columns="tableColumns" :loading="loading" @row-click="onRowClick" showIndex>
|
|
|
+ <app-table :data="marketGoodsList" v-model:columns="tableColumns" @row-click="onRowClick" showIndex>
|
|
|
<!-- 规格 -->
|
|
|
<template #spec="{ row }">
|
|
|
{{ handleNumberValue(row.agreeunit, getGoodsUnitName(row.goodunitid)) }}
|
|
|
</template>
|
|
|
+ <!-- 买价 -->
|
|
|
+ <template #bid="{ row }">
|
|
|
+ <span :class="row.bidColor">{{ handleNumberValue(formatDecimal(row.bid, row.decimalplace)) }}</span>
|
|
|
+ </template>
|
|
|
+ <!-- 买量 -->
|
|
|
+ <template #bidvolume="{ row }">
|
|
|
+ <span :class="row.bidvolumeColor">{{ handleNumberValue(row.bidvolume) }}</span>
|
|
|
+ </template>
|
|
|
<!-- 卖价 -->
|
|
|
<template #ask="{ row }">
|
|
|
- <span :class="row.askColor">{{ row.ask }}</span>
|
|
|
+ <span :class="row.askColor">{{ handleNumberValue(formatDecimal(row.ask, row.decimalplace)) }}</span>
|
|
|
</template>
|
|
|
- <!-- 买价 -->
|
|
|
- <template #bid="{ row }">
|
|
|
- <span :class="row.bidColor">{{ row.bid }}</span>
|
|
|
+ <!-- 卖量 -->
|
|
|
+ <template #askvolume="{ row }">
|
|
|
+ <span :class="row.askvolumeColor">{{ handleNumberValue(row.askvolume) }}</span>
|
|
|
</template>
|
|
|
<!-- 当前价 -->
|
|
|
<template #last="{ row }">
|
|
|
- <span :class="row.lastColor">{{ row.last }}</span>
|
|
|
+ <span :class="row.lastColor">{{ handleNumberValue(formatDecimal(row.last, row.decimalplace)) }}</span>
|
|
|
</template>
|
|
|
<!-- 涨跌 -->
|
|
|
<template #rise="{ row }">
|
|
|
- <span :class="row.lastColor">{{ row.rise }}</span>
|
|
|
+ <span :class="row.lastColor">{{ formatDecimal(row.rise, row.decimalplace) }}</span>
|
|
|
</template>
|
|
|
<!-- 涨跌幅 -->
|
|
|
<template #change="{ row }">
|
|
|
- <span :class="row.lastColor">{{ row.change }}</span>
|
|
|
+ <span :class="row.lastColor">{{ parsePercent(row.change) }}</span>
|
|
|
</template>
|
|
|
<!-- 开盘 -->
|
|
|
<template #opened="{ row }">
|
|
|
- <span :class="row.openedColor">{{ row.opened }}</span>
|
|
|
+ <span :class="row.openedColor">{{ handleNumberValue(formatDecimal(row.opened, row.decimalplace)) }}</span>
|
|
|
</template>
|
|
|
<!-- 最低 -->
|
|
|
<template #lowest="{ row }">
|
|
|
- <span :class="row.lowestColor">{{ row.lowest }}</span>
|
|
|
+ <span :class="row.lowestColor">{{ handleNumberValue(formatDecimal(row.lowest, row.decimalplace)) }}</span>
|
|
|
</template>
|
|
|
<!-- 最高 -->
|
|
|
<template #highest="{ row }">
|
|
|
- <span :class="row.highestColor">{{ row.highest }}</span>
|
|
|
+ <span :class="row.highestColor">{{ handleNumberValue(formatDecimal(row.highest, row.decimalplace)) }}</span>
|
|
|
+ </template>
|
|
|
+ <!-- 振幅 -->
|
|
|
+ <template #amplitude="{ value }">
|
|
|
+ <span>{{ parsePercent(value) }}</span>
|
|
|
+ </template>
|
|
|
+ <!-- 涨停 -->
|
|
|
+ <template #limitup="{ value }">
|
|
|
+ <span class="g-price-up">{{ handleNumberValue(value) }}</span>
|
|
|
+ </template>
|
|
|
+ <!-- 跌停 -->
|
|
|
+ <template #limitdown="{ value }">
|
|
|
+ <span class="g-price-down">{{ handleNumberValue(value) }}</span>
|
|
|
+ </template>
|
|
|
+ <template #footer>
|
|
|
+ <component ref="componentRef" v-bind="{ goodsId: selectedGoodsId }" :is="componentMap.get(componentId)"
|
|
|
+ @closed="closeComponent" v-if="componentId" />
|
|
|
</template>
|
|
|
</app-table>
|
|
|
- <component ref="componentRef" v-bind="{ goodsId }" :is="componentMap.get(componentId)" @closed="closeComponent"
|
|
|
- v-if="componentId" />
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { shallowRef, computed, onMounted, onUnmounted, defineAsyncComponent } from 'vue'
|
|
|
-import { parsePercent, handleNumberValue } from '@/filters'
|
|
|
+import { shallowRef, onMounted, onUnmounted, defineAsyncComponent } from 'vue'
|
|
|
+import { parsePercent, handleNumberValue, formatDecimal } from '@/filters'
|
|
|
import { useComponent } from '@/hooks/component'
|
|
|
import { getGoodsUnitName } from '@/constants/unit'
|
|
|
-import { useFuturesStore, useGoodsStore } from '@/stores'
|
|
|
+import { useFuturesStore } from '@/stores'
|
|
|
import quoteSocket from '@/services/websocket/quote'
|
|
|
import AppTable from '@pc/components/base/table/index.vue'
|
|
|
|
|
|
const componentMap = new Map<string, unknown>([
|
|
|
- ['detail', defineAsyncComponent(() => import('./detail/index.vue'))], // 详情
|
|
|
+ ['detail', defineAsyncComponent(() => import('@pc/components/modules/goods-detail/index.vue'))], // 详情
|
|
|
])
|
|
|
|
|
|
const props = defineProps({
|
|
|
code: String
|
|
|
})
|
|
|
|
|
|
-const marketIds = (()=>{
|
|
|
- switch (props.code) {
|
|
|
- case 'market_trade_goods_50101':
|
|
|
- return '50101'
|
|
|
- case 'market_trade_goods_50102':
|
|
|
- return '50102'
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
-})()
|
|
|
-
|
|
|
-const futuresStore = useFuturesStore()
|
|
|
-const goodsStore = useGoodsStore()
|
|
|
const subscribe = quoteSocket.createSubscribe()
|
|
|
+const { setMarketId, $toRefs } = useFuturesStore()
|
|
|
+const { marketGoodsList, selectedGoodsId } = $toRefs()
|
|
|
|
|
|
-const { loading, goodsId, quoteGoodsList } = goodsStore.$toRefs()
|
|
|
-const { componentRef, componentId, openComponent, closeComponent } = useComponent(() => goodsStore.getQuoteGoodsList({
|
|
|
- marketids: marketIds
|
|
|
-}), false)
|
|
|
-
|
|
|
-const tableList = computed(() => {
|
|
|
- return quoteGoodsList.value.map((item) => {
|
|
|
- const quote = futuresStore.getGoodsQuote(item.goodscode)
|
|
|
- const { bid, bidColor, bidvolume, ask, askColor, askvolume, goodunitid, agreeunit, limitdown, limitup, lastColor, openedColor, lowestColor, highestColor, last, presettle, rise, change, amplitude, highest, lowest, opened, decimalplace } = quote.value ?? {}
|
|
|
- return {
|
|
|
- ...item,
|
|
|
- lastColor,
|
|
|
- openedColor,
|
|
|
- lowestColor,
|
|
|
- highestColor,
|
|
|
- askColor,
|
|
|
- bidColor,
|
|
|
- bid: handleNumberValue(bid?.toFixed(decimalplace)),
|
|
|
- bidvolume: handleNumberValue(bidvolume),
|
|
|
- ask: handleNumberValue(ask?.toFixed(decimalplace)),
|
|
|
- askvolume: handleNumberValue(askvolume),
|
|
|
- last: handleNumberValue(last?.toFixed(decimalplace)),
|
|
|
- rise: rise?.toFixed(item.decimalplace),
|
|
|
- change: parsePercent(change),
|
|
|
- opened: handleNumberValue(opened?.toFixed(decimalplace)),
|
|
|
- presettle: handleNumberValue(presettle?.toFixed(decimalplace)),
|
|
|
- lowest: handleNumberValue(lowest?.toFixed(decimalplace)),
|
|
|
- highest: handleNumberValue(highest?.toFixed(decimalplace)),
|
|
|
- amplitude: parsePercent(amplitude),
|
|
|
- limitdown: handleNumberValue(limitdown?.toFixed(decimalplace)),
|
|
|
- limitup: handleNumberValue(limitup?.toFixed(decimalplace)),
|
|
|
- agreeunit,
|
|
|
- goodunitid
|
|
|
- }
|
|
|
- })
|
|
|
-})
|
|
|
+const { componentRef, componentId, openComponent, closeComponent } = useComponent(() => true, false)
|
|
|
|
|
|
const tableColumns = shallowRef<Model.TableColumn[]>([
|
|
|
{ prop: 'goodscode', label: '代码' },
|
|
|
@@ -127,20 +103,27 @@ const tableColumns = shallowRef<Model.TableColumn[]>([
|
|
|
{ prop: 'highest', label: '最高' },
|
|
|
{ prop: 'lowest', label: '最低' },
|
|
|
{ prop: 'amplitude', label: '振幅' },
|
|
|
- { prop: 'limitup', label: '涨停价', className: 'g-price-up' },
|
|
|
- { prop: 'limitdown', label: '跌停价', className: 'g-price-down' },
|
|
|
+ { prop: 'limitup', label: '涨停价' },
|
|
|
+ { prop: 'limitdown', label: '跌停价' },
|
|
|
])
|
|
|
|
|
|
-const onRowClick = (row: Model.OrderQuoteRsp) => {
|
|
|
- goodsId.value = row.goodsid
|
|
|
+const onRowClick = (row: Model.GoodsQuote) => {
|
|
|
+ selectedGoodsId.value = row.goodsid
|
|
|
openComponent('detail')
|
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
|
- goodsStore.getQuoteGoodsList({ marketids: marketIds }).then(() => {
|
|
|
- const goodsCodes = goodsStore.quoteGoodsList.map((e) => e.goodscode)
|
|
|
- subscribe.start(...goodsCodes)
|
|
|
- })
|
|
|
+ switch (props.code) {
|
|
|
+ case 'market_trade_goods_50101':
|
|
|
+ setMarketId(50101)
|
|
|
+ break
|
|
|
+ case 'market_trade_goods_50102':
|
|
|
+ setMarketId(50102)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ const goodsCodes = marketGoodsList.value.map((e) => e.goodscode)
|
|
|
+ subscribe.start(...goodsCodes)
|
|
|
})
|
|
|
+
|
|
|
onUnmounted(() => subscribe.stop())
|
|
|
</script>
|