li.shaoyi 1 yıl önce
ebeveyn
işleme
85a9dd402f

+ 44 - 29
src/packages/mobile/views/pricing/trade/v2/Index.vue

@@ -2,7 +2,8 @@
     <app-view class="pricing-trade">
         <template #header>
             <app-navbar>
-                <app-select v-model="goodsCode" :options="goodsList" :optionProps="{ label: 'goodscode', value: 'goodscode' }" @confirm="onConfirm" >
+                <app-select v-model="goodsCode" :options="goodsList"
+                    :optionProps="{ label: 'goodscode', value: 'goodscode' }" @confirm="onConfirm">
                     {{ quote ? `${quote.goodscode}` : $t('quote.pricing.title') }}
                     <Icon name="arrow-down" size="16" style="padding-left: 5px;" />
                 </app-select>
@@ -57,36 +58,40 @@
                             </RadioGroup>
                         </div>
                     </template>
-                </Field> 
+                </Field>
                 <!-- 限价 -->
-                <Field name="OrderPrice" :rules="formRules.OrderPrice" :label="$t('quote.pricing.price')" v-if="formData.PriceMode === PriceMode.Limit">
+                <Field name="OrderPrice" :rules="formRules.OrderPrice" :label="$t('quote.pricing.price')"
+                    v-if="formData.PriceMode === PriceMode.Limit">
                     <template #input>
                         <Stepper v-model="formData.OrderPrice" theme="round" button-size="22" :min="0"
                             :auto-fixed="false" :decimal-length="decimalplace" :step="decimalvalue" />
                     </template>
                 </Field>
                 <!-- 限价 -->
-                <Field name="OrderPrice" :rules="formRules.OrderPrice" :label="$t('quote.pricing.price')" v-if="formData.PriceMode === PriceMode.Limit">
+                <Field name="OrderPrice" :rules="formRules.OrderPrice" :label="$t('quote.pricing.price')"
+                    v-if="formData.PriceMode === PriceMode.Limit">
                     <template #input>
                         <Stepper v-model="formData.OrderPrice" theme="round" button-size="22" :min="0"
                             :auto-fixed="false" :decimal-length="decimalplace" :step="decimalvalue" />
                     </template>
                 </Field>
-                <Field v-if="quote?.trademode != 10" name="Receive" :label="$t('performance.address')" type="textarea" autosize
-                        v-model="formData.AddrInfo" :rules="formRules.AddrInfo" :placeholder="$t('performance.pleaseentertheaddress')" right-icon="add-o"
-                        @click-right-icon="showContact = true" />
+                <Field v-if="quote?.trademode != 10" name="Receive" :label="$t('performance.address')" type="textarea"
+                    autosize v-model="formData.AddrInfo" :rules="formRules.AddrInfo"
+                    :placeholder="$t('performance.pleaseentertheaddress')" right-icon="add-o"
+                    @click-right-icon="showContact = true" />
             </CellGroup>
-        </Form> 
+        </Form>
         <app-contact v-model:show="showContact" @change="contactChange" />
         <div class="g-form__footer" v-if="quote?.trademode != 53">
             <template v-if="formData.BuyOrSell === BuyOrSell.Buy">
                 <Button type="danger" block square :disabled="!formData.OrderQty"
-                    @click="onBeforeSubmit(BuildType.Open)" v-if="!quote?.iscannotbuy">{{ $t('operation.order') }}</Button>
+                    @click="onBeforeSubmit(BuildType.Open)" v-if="!quote?.iscannotbuy">{{ $t('operation.order')
+                    }}</Button>
             </template>
             <template v-if="formData.BuyOrSell === BuyOrSell.Sell">
                 <Button type="danger" block square :disabled="!formData.OrderQty"
-                    @click="onBeforeSubmit(BuildType.Open)"
-                    v-if="!isTrademode16 && !quote?.iscannotsell">{{ $t('operation.order') }}</Button>
+                    @click="onBeforeSubmit(BuildType.Open)" v-if="!isTrademode16 && !quote?.iscannotsell">{{
+                        $t('operation.order') }}</Button>
             </template>
         </div>
         <div class="g-form__footer" v-else>
@@ -95,30 +100,32 @@
                     @click="onBeforeSubmit(BuildType.Open)" v-if="!quote?.iscannotbuy">立即购买</Button>
             </template>
         </div>
-        <Tabs class="van-tabs--list" v-model:active="active" >
+        <Tabs class="van-tabs--list" v-model:active="active">
             <template v-for="(item, index) in components.filter(e => e.show === true)" :key="index">
                 <Tab :title="item.title" :name="item.name">
-                    <component :is="item.component" v-bind="{ goodsCode, goodsid, fromTrade, pictureurl }" @callBack="itemBack"/>
+                    <component :is="item.component" v-bind="{ goodsCode, goodsid, fromTrade, pictureurl }"
+                        @callBack="itemBack" />
                 </Tab>
             </template>
         </Tabs>
         <template #footer>
-            <component ref="componentRef" :is="componentMap.get(componentId)" v-bind="{ goodsCode, goodsid, selectedRow }"
-            @closed="closeComponent" v-if="componentId" />
-        </template> 
+            <component ref="componentRef" :is="componentMap.get(componentId)"
+                v-bind="{ goodsCode, goodsid, selectedRow }" @closed="closeComponent" v-if="componentId" />
+        </template>
     </app-view>
 </template>
 
 <script lang="ts" setup>
 import { useFuturesStore, useUserStore, i18n } from '@/stores'
 import { useNavigation } from '@mobile/router/navigation'
-import { shallowRef, onMounted, computed, defineAsyncComponent } from 'vue'
+import { shallowRef, onMounted, onUnmounted, computed, defineAsyncComponent } from 'vue'
 import { Form, Field, Button, FieldRule, FormInstance, Radio, RadioGroup, CellGroup, Icon, Tab, Tabs } from 'vant'
 import { useOrder } from '@/business/trade'
 import { BuyOrSell, BuildType, PriceMode } from '@/constants/order'
 import { useComponent } from '@/hooks/component'
 import { fullloading, dialog } from '@/utils/vant'
 import { formatDecimal, handleNumberValue } from '@/filters'
+import quoteSocket from '@/services/websocket/quote'
 import Stepper from '@mobile/components/base/stepper/index.vue'
 import eventBus from '@/services/bus'
 import AppSelect from '@mobile/components/base/select/index.vue'
@@ -126,9 +133,9 @@ import AppContact from '@mobile/components/modules/contact/index.vue'
 
 const { getQueryString, getQueryStringToNumber } = useNavigation()
 const { global: { t } } = i18n
+const subscribe = quoteSocket.createSubscribe()
 const futuresStore = useFuturesStore()
 
-
 const buyOrSell = getQueryStringToNumber('buyOrSell')
 const buildType = getQueryStringToNumber('buildType')
 const orderQty = getQueryStringToNumber('orderQty')
@@ -145,12 +152,12 @@ const goodsid = shallowRef(getQueryStringToNumber('goodsid') ?? goodsList.value[
 const decimalplace = computed(() => {
     const { decimalplace = 0.0 } = futuresStore.getGoodsQuote(goodsCode.value).value ?? {}
     return decimalplace
-}) 
+})
 // 小数位以及步进值
 const decimalvalue = computed(() => {
     const { quoteminunit = 1.0, decimalplace = 0.0 } = futuresStore.getGoodsQuote(goodsCode.value).value ?? {}
-    return Math.pow(10.0, -decimalplace)*(quoteminunit == 0 ? 1 : quoteminunit)
-}) 
+    return Math.pow(10.0, -decimalplace) * (quoteminunit == 0 ? 1 : quoteminunit)
+})
 const isTrademode16 = computed(() => quote.value?.trademode === 16)
 const { getSystemParamValue } = useUserStore()
 const system_1012 = getSystemParamValue('1012') ?? '1'
@@ -165,19 +172,22 @@ const { formData, formSubmit } = useOrder()
 const formRef = shallowRef<FormInstance>()
 // 数量步长列表
 const qtyStepList = computed(() => {
-    const system_1009 = Number(getSystemParamValue('1009')) ?? 1
-    return [1*system_1009, 5*system_1009, 10*system_1009, 20*system_1009, 30*system_1009, 50*system_1009]
-}) 
+    const result = [1, 5, 10, 20, 30, 50]
+    const system_1009 = getSystemParamValue('1009') ?? '1'
+    return result.map((value) => +system_1009 * value)
+})
 const qtyStep = shallowRef(qtyStepList.value[0]) // 数量步长
 const fromTrade = true
 
 // 持仓汇总
-const position = shallowRef<Model.TradePositionRsp[]>([]) 
+const position = shallowRef<Model.TradePositionRsp[]>([])
 
 const onConfirm = (() => {
     selectedRow.value = undefined
     quote.value = futuresStore.getGoodsQuote(goodsCode.value).value
     goodsid.value = quote.value?.goodsid ?? 0
+
+    subscribe.start(goodsCode.value)
 })
 
 // 点击返回
@@ -218,7 +228,7 @@ const components = [
     //     show: true
     // }
 ]
-    
+
 const componentMap = new Map<string, unknown>([
     ['detail', defineAsyncComponent(() => import('../components/detail/Index.vue'))],
     ['transfer', defineAsyncComponent(() => import('@mobile/views/order/position/components/pricing/detail2/components/transfer/Index.vue'))]
@@ -323,7 +333,7 @@ const onRadioChange = (value: number) => {
     formData.OrderQty = value
 }
 
- onMounted(() => {
+onMounted(() => {
     quote.value = futuresStore.getGoodsQuote(goodsCode.value).value
     formData.BuyOrSell = BuyOrSell.Buy
     formData.BuildType = BuildType.Open
@@ -335,13 +345,18 @@ const onRadioChange = (value: number) => {
     formData.OrderQty = qtyStep.value
 
     /// 如果是从头寸点进来的
-    if ( buildType === BuildType.Close) {
+    if (buildType === BuildType.Close) {
         formData.OrderQty = orderQty
         formData.BuyOrSell = buyOrSell
         formData.BuildType = buildType
     }
- })
 
+    subscribe.start(goodsCode.value)
+})
+
+onUnmounted(() => {
+    subscribe.stop()
+})
 </script>
 
 <style lang="less">

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

@@ -24,6 +24,7 @@ const componentMap = new Map<string, unknown>([
     ['tradeModel_46', defineAsyncComponent(() => import('./swap/index.vue'))], // 掉期市场
     ['tradeModel_99', defineAsyncComponent(() => import('./market/index.vue'))], // 参考行情
     ['tradeModel_10', defineAsyncComponent(() => import('./pricing/v2/index.vue'))], // 挂牌点价
+    ['tradeModel_53', defineAsyncComponent(() => import('./pricing/v2/index.vue'))], // 点价商城
 ])
 
 const futuresStore = useFuturesStore()

+ 6 - 9
src/packages/tss/views/home/main/index.vue

@@ -83,18 +83,15 @@ const onRefresh = () => {
 }
 
 const getGoodsList = () => {
-  const list = futuresStore.quotationList.filter((e) => e.marketid === 53201)
-  goodsList.value = list.map((e) => ({ ...e }))
+  futuresStore.onDataCompleted(() => {
+    const list = futuresStore.quotationList.filter((e) => e.marketid === 53201)
+    goodsList.value = list.map((e) => ({ ...e }))
+  })
 }
 
-futuresStore.onDataCompleted(() => {
-  getGoodsList()
-})
+onActivated(() => getGoodsList())
 
-onMounted(() => {
-  onRefresh()
-  onActivated(() => getGoodsList())
-})
+onMounted(() => onRefresh())
 </script>
 
 <style lang="less">

+ 6 - 10
src/packages/tss/views/product/list/index.vue

@@ -9,7 +9,7 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, onMounted, computed, onActivated } from 'vue'
+import { shallowRef, computed, onActivated } from 'vue'
 import { Empty } from 'vant'
 import { useNavigation } from '@mobile/router/navigation'
 import { useUserStore, useFuturesStore } from '@/stores'
@@ -28,15 +28,11 @@ const groupInfo = computed(() => {
 })
 
 const getGoodsList = () => {
-    const list = futuresStore.quotationList.filter((e) => e.goodsgroupid === groupId)
-    dataList.value = list.map((e) => ({ ...e }))
+    futuresStore.onDataCompleted(() => {
+        const list = futuresStore.quotationList.filter((e) => e.goodsgroupid === groupId)
+        dataList.value = list.map((e) => ({ ...e }))
+    })
 }
 
-futuresStore.onDataCompleted(() => {
-    getGoodsList()
-})
-
-onMounted(() => {
-    onActivated(() => getGoodsList())
-})
+onActivated(() => getGoodsList())
 </script>