li.shaoyi 1 éve
szülő
commit
758609b7f1

+ 2 - 3
src/business/login/index.ts

@@ -2,7 +2,7 @@ import { shallowRef, reactive } from 'vue'
 import { v4 } from 'uuid'
 import { timerTask } from '@/utils/timer'
 import { wsLogin, httpLogin, queryLoginId } from '@/services/api/account'
-import { useGlobalStore, useLoginStore, useEnumStore, useErrorInfoStore, useUserStore, useFuturesStore, useAccountStore, useNoticeStore } from '@/stores'
+import { useGlobalStore, useLoginStore, useEnumStore, useErrorInfoStore, useUserStore, useFuturesStore, useAccountStore } from '@/stores'
 import service from '@/services'
 import quoteSocket from '@/services/websocket/quote'
 import tradeSocket from '@/services/websocket/trade'
@@ -25,7 +25,6 @@ export function useLogin(persist = false) {
     const userStore = useUserStore()
     const accountStore = useAccountStore()
     const futuresStore = useFuturesStore()
-    const noticeStore = useNoticeStore()
 
     const { logining, token } = loginStore.$toRefs()
 
@@ -51,7 +50,6 @@ export function useLogin(persist = false) {
             accountStore.getAccountList(),
         ])
         futuresStore.getGoodsList()
-        noticeStore.getNoticeList()
         checkTokenLoop()
 
         if (globalStore.getSystemInfo('tradeChannel') === 'http') {
@@ -164,6 +162,7 @@ export function useLogin(persist = false) {
             await loadBaseData()
             if (token.value) {
                 await loadUserData()
+                eventBus.$emit('LoginNotify') // 登录成功通知
             } else if (autoLogin && loginStore.getAutoLoginData()) {
                 await userLogin(true)
             }

+ 0 - 82
src/business/order/index.ts

@@ -1,82 +0,0 @@
-import { ref, computed } from 'vue'
-import { BuyOrSell } from '@/constants/order'
-import { querySBYJMyOrders } from '@/services/api/order'
-import { useFuturesStore } from '@/stores'
-
-/**
- * 水贝亿爵订单业务
- * @param selectedRow 
- * @returns 
- */
-export const useSBYJOrder = (selectedRow?: Model.SBYJMyOrderRsp) => {
-    const futuresStore = useFuturesStore()
-    const loading = ref(false)
-    const error = ref(false)
-    const orderList = ref<Model.SBYJMyOrderRsp[]>([])
-
-    const orderComputedList = computed(() => {
-        orderList.value.forEach((e) => {
-            e.tHDetailEx.depositRate = calcDepositRate(e)
-            e.tHDetailEx.floatPL = floatpl(e)
-        })
-        return orderList.value
-    })
-
-    // 订单详情
-    const detail = computed(() => {
-        if (selectedRow) {
-            selectedRow.depositRate = calcDepositRate(selectedRow)
-            selectedRow.tHDetailEx.floatPL = floatpl(selectedRow)
-        }
-        return selectedRow
-    }) 
-
-    const floatpl = ({ tHDetailEx }: Model.SBYJMyOrderRsp) => {
-        const quote = futuresStore.getGoodsQuote(tHDetailEx.goodsID)
-        const { ask = 0, bid = 0, agreeunit = 0 } = quote.value ?? {}
-        const price = tHDetailEx.buyOrSell === BuyOrSell.Buy ? bid : ask // 根据方向取买卖价
-        // 计算浮动盈亏 (价格 * 手数 * 合约乘数 - 持仓金额) * 方向标识
-        const float = price ? price * tHDetailEx.holderQty * agreeunit - tHDetailEx.holderAmount : 0
-        return float * (tHDetailEx.buyOrSell === BuyOrSell.Buy ? 1 : -1)
-    }
-
-    // 计算定金率
-    const calcDepositRate = ({ tHDetailEx }: Model.SBYJMyOrderRsp) => {
-        const quote = futuresStore.getGoodsQuote(tHDetailEx.goodsID)
-        const { ask = 0, bid = 0, agreeunit = 0 } = quote.value ?? {}
-        const price = tHDetailEx.buyOrSell === BuyOrSell.Buy ? bid : ask // 根据方向取买卖价
-
-        // 计算浮动盈亏 (价格 * 手数 * 合约乘数 - 持仓金额) * 方向标识
-        const float = price ? price * tHDetailEx.holderQty * agreeunit - tHDetailEx.holderAmount : 0
-        const floatpl = float * (tHDetailEx.buyOrSell === BuyOrSell.Buy ? 1 : -1)
-        // 计算定金率 (已付定金 + 补充定金 +盈亏 - 已计滞纳金) / 已付定金
-        const depositRate = (tHDetailEx.payedDeposit + tHDetailEx.restockDeposit + floatpl - tHDetailEx.callAteFee) / tHDetailEx.payedDeposit
-        return depositRate
-    }
-
-    // 获取订单列表
-    const getSBYJMyOrders = async (params?: Model.SBYJMyOrderReq) => {
-        loading.value = true
-        try {
-            const res = await querySBYJMyOrders({
-                data: {
-                    ...params
-                }
-            })
-            orderList.value = res.data
-        } catch {
-            error.value = true
-        } finally {
-            loading.value = false
-        }
-    }
-
-    return {
-        loading,
-        error,
-        orderList,
-        orderComputedList,
-        detail,
-        getSBYJMyOrders
-    }
-}

+ 1 - 12
src/business/position/index.ts

@@ -1,7 +1,6 @@
-import { onMounted, onUnmounted, computed } from 'vue'
+import { computed } from 'vue'
 import { BuyOrSell } from '@/constants/order'
 import { usePositionStore } from '@/stores'
-import quoteSocket from '@/services/websocket/quote'
 
 /**
  * 持仓业务
@@ -10,7 +9,6 @@ import quoteSocket from '@/services/websocket/quote'
  */
 export const usePosition = (...tradeMode: number[]) => {
     const store = usePositionStore()
-    const subscribe = quoteSocket.createSubscribe()
     const { positionComputedList, loading } = store.$toRefs()
 
     const positionList = computed(() => positionComputedList.value.filter((e) => tradeMode.length ? tradeMode.includes(e.trademode) : true))
@@ -21,15 +19,6 @@ export const usePosition = (...tradeMode: number[]) => {
         return item?.enableqty ?? 0
     }
 
-    onMounted(() => {
-        store.getTradePosition().then(() => {
-            const goodsCodes = positionList.value.map((e) => e.refgoodscode || e.goodscode)
-            subscribe.start(...goodsCodes)
-        })
-    })
-
-    onUnmounted(() => subscribe.stop())
-
     return {
         loading,
         positionList,

+ 2 - 8
src/packages/gcszt/views/mine/Index.vue

@@ -131,21 +131,20 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, onMounted, onActivated, computed } from 'vue'
+import { shallowRef, onActivated, computed } from 'vue'
 import { Cell, CellGroup, Button, Icon } from 'vant'
 import { fullloading, dialog } from '@/utils/vant'
 import { parsePercent } from '@/filters'
 import { useNavigation } from '@mobile/router/navigation'
 import { AuthStatus } from '@/constants/account'
 import { queryBankAccountSign } from '@/services/api/bank'
-import { useLoginStore, useAccountStore, useUserStore, usePositionStore } from '@/stores'
+import { useLoginStore, useAccountStore, useUserStore } from '@/stores'
 import eventBus from '@/services/bus'
 import Iconfont from '@/components/base/iconfont/index.vue'
 
 const { router, routerTo } = useNavigation()
 const loginStore = useLoginStore()
 const userStore = useUserStore()
-const positionStore = usePositionStore()
 const accountStore = useAccountStore()
 const { currentAccount } = accountStore.$toRefs()
 
@@ -207,11 +206,6 @@ onActivated(() => {
     }
     accountStore.getAccountList()
 })
-
-onMounted(() => {
-    // 请求持仓列表,待优化---可用资金计算可能需要订阅行情
-    positionStore.getTradePosition()
-})
 </script>
 
 <style lang="less">

+ 2 - 8
src/packages/gstj/views/mine/Index.vue

@@ -137,21 +137,20 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, onMounted, onActivated, computed } from 'vue'
+import { shallowRef, onActivated, computed } from 'vue'
 import { Cell, CellGroup, Button, Icon } from 'vant'
 import { parsePercent } from '@/filters'
 import { fullloading, dialog } from '@/utils/vant'
 import { useNavigation } from '@mobile/router/navigation'
 import { AuthStatus } from '@/constants/account'
 import { queryBankAccountSign } from '@/services/api/bank'
-import { useLoginStore, useAccountStore, useUserStore, usePositionStore } from '@/stores'
+import { useLoginStore, useAccountStore, useUserStore } from '@/stores'
 import eventBus from '@/services/bus'
 import Iconfont from '@/components/base/iconfont/index.vue'
 
 const { router, routerTo } = useNavigation()
 const loginStore = useLoginStore()
 const userStore = useUserStore()
-const positionStore = usePositionStore()
 const accountStore = useAccountStore()
 const { currentAccount } = accountStore.$toRefs()
 
@@ -213,11 +212,6 @@ onActivated(() => {
     }
     accountStore.getAccountList()
 })
-
-onMounted(() => {
-    // 请求持仓列表,待优化---可用资金计算可能需要订阅行情
-    positionStore.getTradePosition()
-})
 </script>
 
 <style lang="less">

+ 2 - 8
src/packages/mobile/views/mine/Index.vue

@@ -142,21 +142,20 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, onMounted, onActivated, computed } from 'vue'
+import { shallowRef, onActivated, computed } from 'vue'
 import { Cell, CellGroup, Button, Icon } from 'vant'
 import { fullloading, dialog } from '@/utils/vant'
 import { parsePercent } from '@/filters'
 import { useNavigation } from '@mobile/router/navigation'
 import { AuthStatus } from '@/constants/account'
 import { queryBankAccountSign } from '@/services/api/bank'
-import { useLoginStore, useAccountStore, useUserStore, usePositionStore } from '@/stores'
+import { useLoginStore, useAccountStore, useUserStore } from '@/stores'
 import eventBus from '@/services/bus'
 import Iconfont from '@/components/base/iconfont/index.vue'
 
 const { router, routerTo } = useNavigation()
 const loginStore = useLoginStore()
 const userStore = useUserStore()
-const positionStore = usePositionStore()
 const accountStore = useAccountStore()
 const { currentAccount } = accountStore.$toRefs()
 
@@ -218,11 +217,6 @@ onActivated(() => {
     }
     accountStore.getAccountList()
 })
-
-onMounted(() => {
-    // 请求持仓列表,待优化---可用资金计算可能需要订阅行情
-    positionStore.getTradePosition()
-})
 </script>
 
 <style lang="less">

+ 2 - 8
src/packages/qdhs/views/mine/Index.vue

@@ -134,21 +134,20 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, onMounted, onActivated, computed } from 'vue'
+import { shallowRef, onActivated, computed } from 'vue'
 import { Cell, CellGroup, Button, Icon } from 'vant'
 import { fullloading, dialog } from '@/utils/vant'
 import { parsePercent } from '@/filters'
 import { useNavigation } from '@mobile/router/navigation'
 import { AuthStatus } from '@/constants/account'
 import { queryBankAccountSign } from '@/services/api/bank'
-import { useLoginStore, useAccountStore, useUserStore, usePositionStore } from '@/stores'
+import { useLoginStore, useAccountStore, useUserStore } from '@/stores'
 import eventBus from '@/services/bus'
 import Iconfont from '@/components/base/iconfont/index.vue'
 
 const { router, routerTo } = useNavigation()
 const loginStore = useLoginStore()
 const userStore = useUserStore()
-const positionStore = usePositionStore()
 const accountStore = useAccountStore()
 const { currentAccount } = accountStore.$toRefs()
 
@@ -210,11 +209,6 @@ onActivated(() => {
     }
     accountStore.getAccountList()
 })
-
-onMounted(() => {
-    // 请求持仓列表,待优化---可用资金计算可能需要订阅行情
-    positionStore.getTradePosition()
-})
 </script>
 
 <style lang="less">

+ 2 - 8
src/packages/qxst/views/mine/Index.vue

@@ -131,21 +131,20 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, onMounted, onActivated, computed } from 'vue'
+import { shallowRef, onActivated, computed } from 'vue'
 import { Cell, CellGroup, Button, Icon } from 'vant'
 import { fullloading, dialog } from '@/utils/vant'
 import { parsePercent } from '@/filters'
 import { useNavigation } from '@mobile/router/navigation'
 import { AuthStatus } from '@/constants/account'
 import { queryBankAccountSign } from '@/services/api/bank'
-import { useLoginStore, useAccountStore, useUserStore, usePositionStore } from '@/stores'
+import { useLoginStore, useAccountStore, useUserStore } from '@/stores'
 import eventBus from '@/services/bus'
 import Iconfont from '@/components/base/iconfont/index.vue'
 
 const { router, routerTo } = useNavigation()
 const loginStore = useLoginStore()
 const userStore = useUserStore()
-const positionStore = usePositionStore()
 const accountStore = useAccountStore()
 const { currentAccount } = accountStore.$toRefs()
 
@@ -207,11 +206,6 @@ onActivated(() => {
     }
     accountStore.getAccountList()
 })
-
-onMounted(() => {
-    // 请求持仓列表,待优化---可用资金计算可能需要订阅行情
-    positionStore.getTradePosition()
-})
 </script>
 
 <style lang="less">

+ 11 - 19
src/packages/sbyj/views/market/detail/index.vue

@@ -38,7 +38,7 @@
         </div>
         <div class="market-detail__list">
             <div class="g-order-list">
-                <div class="g-order-list__box" v-for="(item, index) in orderComputedList" :key="index">
+                <div class="g-order-list__box" v-for="(item, index) in orderList" :key="index">
                     <div class="g-order-list__titlebar">
                         <div class="left">
                             <h4 :class="item.tHDetailEx.buyOrSell === BuyOrSell.Buy ? 'g-price-up' : 'g-price-down'">
@@ -77,7 +77,9 @@
                             </li>
                             <li>
                                 <span>浮动权益</span>
-                                <span :class="handlePriceColor(item.tHDetailEx.floatPL)">{{ item.tHDetailEx.floatPL }}</span>
+                                <span :class="handlePriceColor(item.tHDetailEx.floatPL)">
+                                    {{ formatDecimal(item.tHDetailEx.floatPL) }}
+                                </span>
                             </li>
                             <li>
                                 <span>已补定金</span>
@@ -122,21 +124,20 @@ import { useOrder } from '@/business/trade'
 import { shallowRef, onMounted, onUnmounted, computed, onActivated, defineAsyncComponent } from 'vue'
 import { Form, Field, Stepper, Button, FieldRule, FormInstance, Radio, RadioGroup, showToast } from 'vant'
 import { useNavigation } from '@mobile/router/navigation'
-import { useFuturesStore, useUserStore } from '@/stores'
+import { useFuturesStore, useUserStore, useSBYJOrderStore } from '@/stores'
 import { getGoodsUnitName } from '@/constants/unit'
 import { formatDecimal, parsePercent, handleNumberValue, handlePriceColor } from '@/filters'
 import { useComponent } from '@/hooks/component'
 import { fullloading, dialog } from '@/utils/vant'
 import { EPriceMode, EValidType, EOrderOperateType, EBuildType } from '@/constants/client'
 import { BuyOrSell } from '@/constants/order'
-import { useSBYJOrder } from '@/business/order'
 import quoteSocket from '@/services/websocket/quote'
-import eventBus from '@/services/bus'
 import { queryMdUserSwapProtocol } from '@/services/api/swap'
 import { getUserId } from '@/services/methods/user'
 
 const { getQueryString } = useNavigation()
 const { formData, formSubmit } = useOrder()
+const { getSBYJMyOrders, getOrderByGoodsId } = useSBYJOrderStore()
 const futuresStore = useFuturesStore()
 const userStore = useUserStore()
 const formRef = shallowRef<FormInstance>()
@@ -156,8 +157,9 @@ const componentMap = new Map<string, unknown>([
     ['closeholder', defineAsyncComponent(() => import('../../order/list/components/close-holder/index.vue'))], // 转让
 ])
 
-const { getSBYJMyOrders, orderComputedList } = useSBYJOrder()
-const { componentRef, componentId, openComponent, closeComponent } = useComponent(() => getOrderList())
+const { componentRef, componentId, openComponent, closeComponent } = useComponent(() => getSBYJMyOrders())
+
+const orderList = computed(() => getOrderByGoodsId(quote.value?.goodsid))
 
 // 合约乘数
 const agreeunit = computed(() => quote.value?.agreeunit ?? 0)
@@ -178,12 +180,6 @@ const qtyStepList = computed(() => {
     ]
 })
 
-const getOrderList = () => {
-    getSBYJMyOrders({
-        goodsId: quote.value?.goodsid
-    })
-}
-
 const commit = (buyOrSell: BuyOrSell) => {
     /// 这里要去判断是否已经实名认证
     if (userStore.hasAuth) {
@@ -221,7 +217,7 @@ const onSubmit = () => {
             formSubmit().then(() => {
                 hideLoading('提交成功。', 'success')
                 // 刷新订单列表
-                getOrderList()
+                getSBYJMyOrders()
             }).catch((err) => {
                 hideLoading(err, 'fail')
             })
@@ -250,9 +246,6 @@ const showComponent = (componentName: string, row: Model.SBYJMyOrderRsp) => {
     openComponent(componentName)
 }
 
-// 接收委托单成交通知
-const orderDealedNtf = eventBus.$on('OrderDealedNtf', () => getOrderList())
-
 onActivated(() => {
     /// 查询是否已签署合同
     queryMdUserSwapProtocol({
@@ -268,12 +261,11 @@ onMounted(() => {
     subscribe.start(goodscode)
     orderQty.value = agreeunit.value
     qtyStep.value = qtyStepList.value[0]
-    getOrderList()
+    getSBYJMyOrders()
 })
 
 onUnmounted(() => {
     subscribe.stop()
-    orderDealedNtf.cancel()
 })
 </script>
 

+ 10 - 7
src/packages/sbyj/views/mine/index.vue

@@ -43,7 +43,9 @@
                         </li>
                         <li>
                             <span>浮动权益</span>
-                            <span>{{ currentAccount.profitLoss?.toFixed(2) }}</span>
+                            <span :class="handlePriceColor(currentAccount.profitLoss ?? 0)">
+                                {{ currentAccount.profitLoss?.toFixed(2) }}
+                            </span>
                         </li>
                     </ul>
                     <!-- <ul>
@@ -110,7 +112,8 @@
                         <Iconfont icon="g-icon-sign">签约账户</Iconfont>
                     </template>
                 </Cell>
-                <Cell is-link :to="{ name: 'account-protocol', query: { memberUserId: getMemberUserId()} }" v-if="userStore.userType != 2 && authStatus === AuthStatus.Certified">
+                <Cell is-link :to="{ name: 'account-protocol', query: { memberUserId: getMemberUserId() } }"
+                    v-if="userStore.userType != 2 && authStatus === AuthStatus.Certified">
                     <template #title>
                         <Iconfont icon="g-icon-order--line">合同签署</Iconfont>
                     </template>
@@ -157,7 +160,7 @@
 import { shallowRef, onActivated, computed } from 'vue'
 import { Cell, CellGroup, Button, Icon } from 'vant'
 import { fullloading, dialog } from '@/utils/vant'
-import { parsePercent } from '@/filters'
+import { handlePriceColor } from '@/filters'
 import { useNavigation } from '@mobile/router/navigation'
 import { AuthStatus } from '@/constants/account'
 import { queryBankAccountSign } from '@/services/api/bank'
@@ -173,7 +176,7 @@ const userStore = useUserStore()
 const accountStore = useAccountStore()
 const { currentAccount } = accountStore.$toRefs()
 /// 判断是否能签约
-const canBankSign = shallowRef(false) 
+const canBankSign = shallowRef(false)
 const headerRef = shallowRef<HTMLDivElement>()
 const authStatus = computed(() => userStore.userAccount.hasauth) // 实名认证状态
 
@@ -192,7 +195,7 @@ const doInOutMoney = (tab: string) => {
                 showCancelButton: true,
                 confirmButtonText: '去签署合同'
             }).then(() => {
-                router.push({ name: 'account-protocol', query: { memberUserId: getMemberUserId()} })
+                router.push({ name: 'account-protocol', query: { memberUserId: getMemberUserId() } })
             })
             return
         }
@@ -247,7 +250,7 @@ onActivated(() => {
     /// 机构不需要签合同
     if (userStore.userInfo.usertype === 2) {
         canBankSign.value = true
-        return 
+        return
     }
 
     /// 查询数据
@@ -257,7 +260,7 @@ onActivated(() => {
         }
     }).then((res) => {
         /// 判断是否能签约
-        canBankSign.value = res.data.some(e => e.protocolstatus === 4 )
+        canBankSign.value = res.data.some(e => e.protocolstatus === 4)
     })
 })
 </script>

+ 2 - 2
src/packages/sbyj/views/order/close/index.vue

@@ -39,7 +39,7 @@
                             </li>
                             <li>
                                 <span>终止结余</span>
-                                <span>{{ formatDecimal(item.closepl) }}</span>
+                                <span :class="handlePriceColor(item.closepl)">{{ formatDecimal(item.closepl) }}</span>
                             </li>
                         </ul>
                     </div>
@@ -51,7 +51,7 @@
 
 <script lang="ts" setup>
 import { shallowRef } from 'vue'
-import { formatDecimal,formatDate } from '@/filters'
+import { formatDecimal, formatDate, handlePriceColor } from '@/filters'
 import { BuyOrSell } from '@/constants/order'
 import { useRequest } from '@/hooks/request'
 import { queryTradeCloseDetails } from '@/services/api/order'

+ 21 - 22
src/packages/sbyj/views/order/detail/index.vue

@@ -5,40 +5,39 @@
             <template #header>
                 <app-navbar title="订单详情" @back="closed" />
             </template>
-            <div class="order-detail__container g-form__container" v-if="detail">
+            <div class="order-detail__container g-form__container">
                 <CellGroup inset>
-                    <Cell :title="detail.tHDetailEx.buyOrSell === BuyOrSell.Buy ? '买料订单' : '卖料订单'"
-                        :value="detail.tHDetailEx.tradeID" />
-                    <Cell title="商品代码/名称" :value="detail.goodsCode + '/' + detail.goodsName" />
+                    <Cell :title="detail.buyOrSell === BuyOrSell.Buy ? '买料订单' : '卖料订单'" :value="detail.tradeID" />
+                    <Cell title="商品代码/名称" :value="selectedRow.goodsCode + '/' + selectedRow.goodsName" />
                     <Cell title="订单重量"
-                        :value="(detail.tHDetailEx.openQty * detail.agreeUnit) + getGoodsUnitName(detail.goodsUnitID)" />
+                        :value="(detail.openQty * selectedRow.agreeUnit) + getGoodsUnitName(selectedRow.goodsUnitID)" />
                     <Cell title="可用数量"
-                        :value="((detail.tHDetailEx.holderQty - detail.tHDetailEx.freezeQty) * detail.agreeUnit) + getGoodsUnitName(detail.goodsUnitID)" />
-                    <Cell title="订单价格" :value="detail.tHDetailEx.holderPrice" />
-                    <Cell title="订单金额" :value="detail.tHDetailEx.tradeAmount" />
+                        :value="((detail.holderQty - detail.freezeQty) * selectedRow.agreeUnit) + getGoodsUnitName(selectedRow.goodsUnitID)" />
+                    <Cell title="订单价格" :value="detail.holderPrice" />
+                    <Cell title="订单金额" :value="detail.tradeAmount" />
                     <Cell title="浮动权益">
                         <template #value>
-                            <span :class="handlePriceColor(detail.tHDetailEx.floatPL)">
-                                {{ detail.tHDetailEx.floatPL }}
+                            <span :class="handlePriceColor(detail.floatPL)">
+                                {{ detail.floatPL }}
                             </span>
                         </template>
                     </Cell>
-                    <Cell title="已付定金" :value="detail.tHDetailEx.payedDeposit" />
-                    <Cell title="已补定金" :value="detail.tHDetailEx.restockDeposit" />
-                    <Cell title="订单天数" :value="detail.tHDetailEx.holdDays" />
-                    <Cell title="滞纳金" :value="detail.tHDetailEx.callAteFee" />
+                    <Cell title="已付定金" :value="detail.payedDeposit" />
+                    <Cell title="已补定金" :value="detail.restockDeposit" />
+                    <Cell title="订单天数" :value="detail.holdDays" />
+                    <Cell title="滞纳金" :value="detail.callAteFee" />
                     <Cell title="定金率">
                         <template #value>
-                            <span :class="detail.tHDetailEx.depositRate <= detail.tHDetailEx.promptDepositRate ? 'g-price-up' : ''">
-                                {{ parsePercent(detail.tHDetailEx.depositRate) }}
+                            <span :class="detail.depositRate <= detail.promptDepositRate ? 'g-price-up' : ''">
+                                {{ parsePercent(detail.depositRate) }}
                             </span>
                         </template>
                     </Cell>
                     <Cell title="冻结重量"
-                        :value="(detail.tHDetailEx.freezeQty * detail.agreeUnit) + getGoodsUnitName(detail.goodsUnitID)" />
+                        :value="(detail.freezeQty * selectedRow.agreeUnit) + getGoodsUnitName(selectedRow.goodsUnitID)" />
                     <Cell title="交料重量"
-                        :value="(detail.tHDetailEx.deliveryQty * detail.agreeUnit) + getGoodsUnitName(detail.goodsUnitID)" />
-                    <Cell title="订单时间" :value="detail.tHDetailEx.tradeTime" />
+                        :value="(detail.deliveryQty * selectedRow.agreeUnit) + getGoodsUnitName(selectedRow.goodsUnitID)" />
+                    <Cell title="订单时间" :value="detail.tradeTime" />
                 </CellGroup>
             </div>
         </app-view>
@@ -46,12 +45,11 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, PropType } from 'vue'
+import { shallowRef, PropType, computed } from 'vue'
 import { CellGroup, Cell } from 'vant'
 import { parsePercent, handlePriceColor } from '@/filters'
 import { BuyOrSell } from '@/constants/order'
 import AppModal from '@/components/base/modal/index.vue'
-import { useSBYJOrder } from '@/business/order'
 import { getGoodsUnitName } from '@/constants/unit'
 
 const props = defineProps({
@@ -61,10 +59,11 @@ const props = defineProps({
     }
 })
 
-const { detail } = useSBYJOrder(props.selectedRow)
 const showModal = shallowRef(true)
 const refresh = shallowRef(false) // 是否刷新父组件数据
 
+const detail = computed(() => props.selectedRow.tHDetailEx)
+
 // 关闭弹窗
 const closed = (isRefresh = false) => {
     refresh.value = isRefresh

+ 6 - 3
src/packages/sbyj/views/order/list/index.vue

@@ -51,7 +51,9 @@
                             </li>
                             <li>
                                 <span>浮动权益</span>
-                                <span :class="handlePriceColor(item.tHDetailEx.floatPL)">{{ item.tHDetailEx.floatPL }}</span>
+                                <span :class="handlePriceColor(item.tHDetailEx.floatPL)">
+                                    {{ formatDecimal(item.tHDetailEx.floatPL) }}
+                                </span>
                             </li>
                             <li>
                                 <span>已补定金</span>
@@ -91,7 +93,7 @@ import { formatDecimal, parsePercent, handleNumberValue, handlePriceColor } from
 import { getGoodsUnitName } from '@/constants/unit'
 import { useComponent } from '@/hooks/component'
 import { Button } from 'vant'
-import { useSBYJOrder } from '@/business/order'
+import { useSBYJOrderStore } from '@/stores'
 import AppPullRefresh from '@mobile/components/base/pull-refresh/index.vue'
 
 const componentMap = new Map<string, unknown>([
@@ -101,7 +103,8 @@ const componentMap = new Map<string, unknown>([
     ['closeholder', defineAsyncComponent(() => import('./components/close-holder/index.vue'))], // 转让
 ])
 
-const { getSBYJMyOrders, orderComputedList, loading, error } = useSBYJOrder()
+const { getSBYJMyOrders, $toRefs } = useSBYJOrderStore()
+const { orderComputedList, loading, error } = $toRefs()
 const selectedRow = shallowRef<Model.SBYJMyOrderRsp>()
 
 const { componentRef, componentId, openComponent, closeComponent } = useComponent(() => getSBYJMyOrders())

+ 2 - 8
src/packages/tc/views/mine/Index.vue

@@ -137,21 +137,20 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, onMounted, onActivated, computed } from 'vue'
+import { shallowRef, onActivated, computed } from 'vue'
 import { Cell, CellGroup, Button, Icon } from 'vant'
 import { fullloading, dialog } from '@/utils/vant'
 import { parsePercent } from '@/filters'
 import { useNavigation } from '@mobile/router/navigation'
 import { AuthStatus } from '@/constants/account'
 import { queryBankAccountSign } from '@/services/api/bank'
-import { useLoginStore, useAccountStore, useUserStore, usePositionStore } from '@/stores'
+import { useLoginStore, useAccountStore, useUserStore } from '@/stores'
 import eventBus from '@/services/bus'
 import Iconfont from '@/components/base/iconfont/index.vue'
 
 const { router, routerTo } = useNavigation()
 const loginStore = useLoginStore()
 const userStore = useUserStore()
-const positionStore = usePositionStore()
 const accountStore = useAccountStore()
 const { currentAccount } = accountStore.$toRefs()
 
@@ -213,11 +212,6 @@ onActivated(() => {
     }
     accountStore.getAccountList()
 })
-
-onMounted(() => {
-    // 请求持仓列表,待优化---可用资金计算可能需要订阅行情
-    positionStore.getTradePosition()
-})
 </script>
 
 <style lang="less">

+ 10 - 15
src/packages/tjmd/views/mine/Index.vue

@@ -98,7 +98,8 @@
                         <Iconfont icon="g-icon-sign">签约账户</Iconfont>
                     </template>
                 </Cell>
-                <Cell is-link :to="{ name: 'account-protocol', query: { memberUserId: getMemberUserId()} }" v-if="userStore.userType != 2 && authStatus === AuthStatus.Certified">
+                <Cell is-link :to="{ name: 'account-protocol', query: { memberUserId: getMemberUserId() } }"
+                    v-if="userStore.userType != 2 && authStatus === AuthStatus.Certified">
                     <template #title>
                         <Iconfont icon="g-icon-order--line">合同签署</Iconfont>
                     </template>
@@ -142,14 +143,14 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, onMounted, onActivated, computed } from 'vue'
+import { shallowRef, onActivated, computed } from 'vue'
 import { Cell, CellGroup, Button, Icon } from 'vant'
 import { parsePercent } from '@/filters'
 import { fullloading, dialog } from '@/utils/vant'
 import { useNavigation } from '@mobile/router/navigation'
 import { AuthStatus } from '@/constants/account'
 import { queryBankAccountSign } from '@/services/api/bank'
-import { useLoginStore, useAccountStore, useUserStore, usePositionStore } from '@/stores'
+import { useLoginStore, useAccountStore, useUserStore } from '@/stores'
 import eventBus from '@/services/bus'
 import Iconfont from '@/components/base/iconfont/index.vue'
 import { getMemberUserId } from '@/services/methods/user'
@@ -158,11 +159,10 @@ import { queryMdUserSwapProtocol } from '@/services/api/swap'
 const { router, routerTo } = useNavigation()
 const loginStore = useLoginStore()
 const userStore = useUserStore()
-const positionStore = usePositionStore()
 const accountStore = useAccountStore()
 const { currentAccount } = accountStore.$toRefs()
 /// 判断是否能签约
-const canBankSign = shallowRef(false) 
+const canBankSign = shallowRef(false)
 const headerRef = shallowRef<HTMLDivElement>()
 const authStatus = computed(() => userStore.userAccount.hasauth) // 实名认证状态
 
@@ -181,11 +181,11 @@ const doInOutMoney = (tab: string) => {
                 showCancelButton: true,
                 confirmButtonText: '去签署合同'
             }).then(() => {
-                router.push({ name: 'account-protocol', query: { memberUserId: getMemberUserId()} })
+                router.push({ name: 'account-protocol', query: { memberUserId: getMemberUserId() } })
             })
             return
         }
-  
+
         // 判断是否已签约
         fullloading((hideLoading) => {
             queryBankAccountSign().then((res) => {
@@ -237,9 +237,9 @@ onActivated(() => {
     /// 机构不需要签合同
     if (userStore.userInfo.usertype === 2) {
         canBankSign.value = true
-        return 
+        return
     }
-    
+
     /// 查询数据
     queryMdUserSwapProtocol({
         data: {
@@ -247,14 +247,9 @@ onActivated(() => {
         }
     }).then((res) => {
         /// 判断是否能签约
-        canBankSign.value = res.data.some(e => e.protocolstatus === 4 )
+        canBankSign.value = res.data.some(e => e.protocolstatus === 4)
     })
 })
-
-onMounted(() => {
-    // 请求持仓列表,待优化---可用资金计算可能需要订阅行情
-    positionStore.getTradePosition()
-})
 </script>
 
 <style lang="less">

+ 8 - 13
src/packages/zrwyt/views/mine/Index.vue

@@ -101,7 +101,8 @@
                         <Iconfont icon="g-icon-sign">银行签约</Iconfont>
                     </template>
                 </Cell>
-                <Cell is-link :to="{ name: 'account-protocol', query: { memberUserId: getMemberUserId()} }" v-if="userStore.userType != 2 && authStatus === AuthStatus.Certified">
+                <Cell is-link :to="{ name: 'account-protocol', query: { memberUserId: getMemberUserId() } }"
+                    v-if="userStore.userType != 2 && authStatus === AuthStatus.Certified">
                     <template #title>
                         <Iconfont icon="g-icon-order--line">入市协议</Iconfont>
                     </template>
@@ -145,14 +146,14 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, onMounted, onActivated, computed } from 'vue'
+import { shallowRef, onActivated, computed } from 'vue'
 import { Cell, CellGroup, Button, Icon } from 'vant'
 import { parsePercent } from '@/filters'
 import { fullloading, dialog } from '@/utils/vant'
 import { useNavigation } from '@mobile/router/navigation'
 import { AuthStatus } from '@/constants/account'
 import { queryBankAccountSign } from '@/services/api/bank'
-import { useLoginStore, useAccountStore, useUserStore, usePositionStore } from '@/stores'
+import { useLoginStore, useAccountStore, useUserStore } from '@/stores'
 import eventBus from '@/services/bus'
 import Iconfont from '@/components/base/iconfont/index.vue'
 import { getMemberUserId } from '@/services/methods/user'
@@ -161,11 +162,10 @@ import { queryUsereSignRecords } from '@/services/api/account'
 const { router, routerTo } = useNavigation()
 const loginStore = useLoginStore()
 const userStore = useUserStore()
-const positionStore = usePositionStore()
 const accountStore = useAccountStore()
 const { currentAccount } = accountStore.$toRefs()
 /// 判断是否能签约
-const hasSignContract = shallowRef(false) 
+const hasSignContract = shallowRef(false)
 const headerRef = shallowRef<HTMLDivElement>()
 const authStatus = computed(() => userStore.userAccount.hasauth) // 实名认证状态
 
@@ -245,9 +245,9 @@ onActivated(() => {
     /// 机构不需要签合同
     if (userStore.userInfo.usertype === 2) {
         hasSignContract.value = true
-        return 
+        return
     }
-    
+
     /// 查询数据
     queryUsereSignRecords({
         data: {
@@ -257,14 +257,9 @@ onActivated(() => {
         }
     }).then((res) => {
         /// 判断是否能签约
-        hasSignContract.value = res.data.some(e => e.recordstatus === 3 )
+        hasSignContract.value = res.data.some(e => e.recordstatus === 3)
     })
 })
-
-onMounted(() => {
-    // 请求持仓列表,待优化---可用资金计算可能需要订阅行情
-    positionStore.getTradePosition()
-})
 </script>
 
 <style lang="less">

+ 1 - 1
src/services/websocket/quote.ts

@@ -86,7 +86,7 @@ export default new (class {
                 }
             })
         })
-    }, 200)
+    }, 300)
 
     /**
      * 创建行情订阅

+ 1 - 1
src/stores/index.ts

@@ -8,5 +8,5 @@ export { useFuturesStore } from './modules/futures'
 //export { i18n, useLanguageStore } from './modules/language'
 export { useErrorInfoStore } from './modules/errorInfo'
 export { useNoticeStore } from './modules/notice'
-export { usePositionStore } from './modules/position'
+export { usePositionStore, useSBYJOrderStore } from './modules/position'
 export { useSettingStore } from './modules/setting'

+ 10 - 2
src/stores/modules/account.ts

@@ -3,7 +3,7 @@ import { queryTaAccounts, getTodayAccountConfigInfo } from '@/services/api/accou
 import { defineStore } from '../store'
 import { useLoginStore } from './login'
 import { useUserStore } from './user'
-import { usePositionStore } from './position'
+import { usePositionStore, useSBYJOrderStore } from './position'
 import eventBus from '@/services/bus'
 
 /**
@@ -14,6 +14,7 @@ export const useAccountStore = defineStore(() => {
     const loginStore = useLoginStore()
     const userStore = useUserStore()
     const positionStore = usePositionStore()
+    const sbyjOrderStore = useSBYJOrderStore()
 
     const state = reactive<{
         loading: boolean;
@@ -44,9 +45,16 @@ export const useAccountStore = defineStore(() => {
         state.accountList.forEach((item) => {
             // 账号持仓列表
             const positionList = positionStore.positionComputedList.filter((e) => e.accountid === item.accountid)
+            // 计算浮动盈亏
+            const profitLoss1 = positionList.reduce((pre, cur) => cur.tradeproperty === 1 ? pre += cur.closepl : pre, 0)
 
+            // 水贝亿爵订单列表
+            const orderList = sbyjOrderStore.orderComputedList.filter((e) => e.tHDetailEx.accountID === item.accountid)
             // 计算浮动盈亏
-            const profitLoss = positionList.reduce((pre, cur) => cur.tradeproperty === 1 ? pre += cur.closepl : pre, 0)
+            const profitLoss2 = orderList.reduce((pre, cur) => pre += cur.tHDetailEx.floatPL, 0)
+
+            // 计算总浮动盈亏
+            const profitLoss = profitLoss1 + profitLoss2
 
             // 计算市值(所有权)
             const marketValue = positionList.reduce((pre, cur) => cur.tradeproperty === 2 ? pre += cur.marketValue : pre, 0)

+ 12 - 0
src/stores/modules/notice.ts

@@ -2,6 +2,7 @@ import { reactive, toRefs, computed } from 'vue'
 import { timerTask } from '@/utils/timer'
 import { queryNotice, postNoticeReaded } from '@/services/api/common'
 import { defineStore } from '../store'
+import eventBus from '@/services/bus'
 
 /**
  * 系统通知存储对象
@@ -47,6 +48,17 @@ export const useNoticeStore = defineStore(() => {
         }
     }
 
+    // 接收登入请求数据
+    eventBus.$on('LoginNotify', () => {
+        getNoticeList()
+    })
+
+    // 接收登出通知清空数据
+    eventBus.$on('LogoutNotify', () => {
+        timerTask.clearTimeout('systemNotice')
+        state.noticeList = []
+    })
+
     return {
         ...toRefs(state),
         unreadList,

+ 43 - 1
src/stores/modules/position.ts

@@ -5,12 +5,15 @@ import { queryTradePosition, querySBYJMyOrders } from '@/services/api/order'
 import { useFuturesStore } from './futures'
 import { defineStore } from '../store'
 import eventBus from '@/services/bus'
+import quoteSocket from '@/services/websocket/quote'
 
 /**
  * 持仓存储对象
  */
 export const usePositionStore = defineStore(() => {
     const futuresStore = useFuturesStore()
+    const subscribe = quoteSocket.createSubscribe()
+
     const state = reactive({
         loading: false,
         positionList: <Model.TradePositionRsp[]>[], // 持仓汇总列表
@@ -19,10 +22,12 @@ export const usePositionStore = defineStore(() => {
     // 获取持仓汇总列表
     const getTradePosition = async () => {
         if (!state.loading) {
+            subscribe.stop()
             try {
                 state.loading = true
                 const res = await queryTradePosition()
                 state.positionList = res.data
+                subscribe.start(...res.data.map((e) => e.goodscode))
             } finally {
                 state.loading = false
             }
@@ -69,18 +74,32 @@ export const usePositionStore = defineStore(() => {
     // 接收头寸变化通知
     const posChangedNtf = eventBus.$on('PosChangedNtf', () => getTradePosition())
 
+    // 接收登入请求数据
+    eventBus.$on('LoginNotify', () => {
+        getTradePosition()
+    })
+
     // 接收登出通知清空数据
+    eventBus.$on('LogoutNotify', () => {
+        state.positionList = []
+    })
 
     return {
         ...toRefs(state),
         getTradePosition,
         positionComputedList,
         posChangedNtf,
+        subscribe
     }
 })
 
+/**
+ * 订单存储对象
+ */
 export const useSBYJOrderStore = defineStore(() => {
     const futuresStore = useFuturesStore()
+    const subscribe = quoteSocket.createSubscribe()
+
     const state = reactive({
         loading: false,
         error: false,
@@ -102,7 +121,8 @@ export const useSBYJOrderStore = defineStore(() => {
         const price = tHDetailEx.buyOrSell === BuyOrSell.Buy ? bid : ask // 根据方向取买卖价
         // 计算浮动盈亏 (价格 * 手数 * 合约乘数 - 持仓金额) * 方向标识
         const float = price ? price * tHDetailEx.holderQty * agreeunit - tHDetailEx.holderAmount : 0
-        return float * (tHDetailEx.buyOrSell === BuyOrSell.Buy ? 1 : -1)
+        const result = float * (tHDetailEx.buyOrSell === BuyOrSell.Buy ? 1 : -1)
+        return round(result, quote.value?.decimalplace)
     }
 
     // 计算定金率
@@ -122,11 +142,13 @@ export const useSBYJOrderStore = defineStore(() => {
     // 获取订单列表
     const getSBYJMyOrders = async () => {
         if (!state.loading) {
+            subscribe.stop()
             try {
                 state.error = false
                 state.loading = true
                 const res = await querySBYJMyOrders()
                 state.orderList = res.data
+                subscribe.start(...res.data.map((e) => e.goodsCode))
             } catch {
                 state.error = true
             } finally {
@@ -135,9 +157,29 @@ export const useSBYJOrderStore = defineStore(() => {
         }
     }
 
+    const getOrderByGoodsId = (goodsId = 0) => {
+        return orderComputedList.value.filter((e) => e.tHDetailEx.goodsID === goodsId)
+    }
+
+    // 接收委托单成交通知
+    const orderDealedNtf = eventBus.$on('OrderDealedNtf', () => getSBYJMyOrders())
+
+    // 接收登入请求数据
+    eventBus.$on('LoginNotify', () => {
+        getSBYJMyOrders()
+    })
+
+    // 接收登出通知清空数据
+    eventBus.$on('LogoutNotify', () => {
+        state.orderList = []
+    })
+
     return {
         ...toRefs(state),
         orderComputedList,
         getSBYJMyOrders,
+        getOrderByGoodsId,
+        orderDealedNtf,
+        subscribe
     }
 })