Handy_Cao 2 years ago
parent
commit
b2b573b85c

+ 13 - 9
src/packages/pc/views/footer/goods/position/index.vue

@@ -6,12 +6,14 @@
             {{ getBuyOrSellName(value) }}
         </template>
         <!-- 最新价 -->
-        <template #last="{ row }">
-            {{ last(row.goodsCode) }}
+        <template #lastprice="{ row }">
+            <span :class="lastColor(row)">
+                {{ lastprice(row) }}
+            </span>
         </template>
         <!-- 浮动盈亏-->
         <template #closepl="{ row }">
-            <span :class="lastColor(row.goodscode)">{{ closepl(row).toFixed(2) }}</span>
+            <span :class="handlePriceColor(closepl(row), 0.0)">{{ closepl(row).toFixed(2) }}</span>
         </template>
          <!-- 展开行 -->
          <template #expand>
@@ -34,15 +36,17 @@ import { useComposeTable } from '@pc/components/base/table'
 import { queryTradePosition } from '@/services/api/order'
 import { useFuturesStore } from '@/stores'
 import AppTable from '@pc/components/base/table/index.vue'
+import { handlePriceColor } from '@/filters'
 
 const futuresStore = useFuturesStore()
 
-const last = (goodsCode: string) => {
-    return futuresStore.getQuotePrice(goodsCode)
+const lastprice = (item: Model.TradePositionRsp) => {
+    const { last = 0 } = futuresStore.getQuoteInfo(item.goodscode).value ?? {}
+    return last
 }
 
-const lastColor = (goodsCode: string) => {
-    return futuresStore.getQuoteInfo(goodsCode).value?.lastColor
+const lastColor = (item: Model.TradePositionRsp) => {
+    return futuresStore.getQuoteInfo(item.goodscode).value?.lastColor
 }
 
 /// 计算参考损益
@@ -71,7 +75,7 @@ const { loading, dataList, run } = useRequest(queryTradePosition, {
     },
 })
 
-const { rowKey, expandKeys, selectedRow, rowClick } = useComposeTable<Model.TradePositionRsp>({ rowKey: 'accountid' })
+const { rowKey, expandKeys, selectedRow, rowClick } = useComposeTable<Model.TradePositionRsp>({ rowKey: 'goodsid' })
 
 const tableColumns = shallowRef<Model.TableColumn[]>([
     { prop: 'goodsname', label: '订单合约' },
@@ -80,7 +84,7 @@ const tableColumns = shallowRef<Model.TableColumn[]>([
     { prop: 'enableqty', label: '可用数量' },
     { prop: 'frozenqty', label: '冻结数量' },
     { prop: 'averageprice', label: '均价' },
-    { prop: 'last', label: '现价' },
+    { prop: 'lastprice', label: '现价' },
     { prop: 'curholderamount', label: '持仓金额' },
     { prop: 'usedmargin', label: '占用保证金' },
     { prop: 'closepl', label: '浮动盈亏' },

+ 1 - 0
src/packages/pc/views/market/trade/goods/index.vue

@@ -61,6 +61,7 @@ const tableList = computed(() => {
     return quoteGoodsList.value.map((item) => {
         const quote = futuresStore.getQuoteInfo(item.goodscode)
         const { bid, bidColor, bidvolume, ask, askColor, askvolume, limitdown, limitup, lastColor, openedColor, lowestColor, highestColor, last, presettle, rise, change, amplitude, highest, lowest, opened, decimalplace } = quote.value ?? {}
+        // console.log(item.goodscode, last)
         return {
             ...item,
             lastColor,