li.shaoyi преди 2 години
родител
ревизия
611efe048f

+ 2 - 3
src/hooks/echarts/candlestick/options.ts

@@ -1,6 +1,5 @@
 import { reactive, watch } from 'vue'
 import { ECOption } from '@/components/base/echarts/core'
-import { timerInterceptor } from '@/utils/timer'
 import { ChartCycleType } from '@/constants/chart'
 import { useGlobalStore } from '@/stores'
 import { EchartsDataset, EchartsOptions, Colors } from './types'
@@ -349,7 +348,7 @@ export function useOptions(dataset: EchartsDataset) {
     }
 
     // 动态更新数据
-    const updateOptions = timerInterceptor.setThrottle(() => {
+    const updateOptions = () => {
         const { candlestick, macd, vol, kdj, cci } = dataset;
 
         options.candlestick = {
@@ -389,7 +388,7 @@ export function useOptions(dataset: EchartsDataset) {
                 source: cci.source,
             },
         }
-    }, 50)
+    }
 
     // 监听主题变化
     watch(appTheme, () => {

+ 2 - 3
src/hooks/echarts/timeline/options.ts

@@ -1,5 +1,4 @@
 import { reactive, watch } from 'vue'
-import { timerInterceptor } from '@/utils/timer'
 import { useGlobalStore } from '@/stores'
 import { echarts } from '@/components/base/echarts/core'
 import { EchartsDataset, EchartsOptions, Colors } from './types'
@@ -216,7 +215,7 @@ export function useOptions(dataset: EchartsDataset) {
     }
 
     // 动态更新数据
-    const updateOptions = timerInterceptor.setThrottle(() => {
+    const updateOptions = () => {
         const { colors } = options;
         const { timeline, yestclose } = dataset;
 
@@ -243,7 +242,7 @@ export function useOptions(dataset: EchartsDataset) {
                 },
             ],
         }
-    }, 50)
+    }
 
     // 监听主题变化
     watch(appTheme, () => {

+ 50 - 94
src/packages/mobile/views/order/position/components/transfer/listing/Index.vue

@@ -5,45 +5,51 @@
             <template #header>
                 <app-navbar title="转让" @back="closed" />
             </template>
-            <component :is="Price" v-bind="{ goodsCode }" />
-            <component :is="Forex" v-bind="{ goodsCode, showMore: false }" @price-click="onPriceClick" />
-            <Form ref="formRef" class="g-form__container" @submit="onSubmit">
+            <Form ref="formRef" :label-width="100" class="g-form__container" @submit="onSubmit">
                 <CellGroup inset>
-                    <Field name="OrderPrice" :rules="formRules.OrderPrice" label="价格">
+                    <Field label="商品代码/名称">
                         <template #input>
-                            <Stepper v-model="formData.OrderPrice" theme="round" button-size="22" :min="0"
-                                :auto-fixed="false" :decimal-length="quote?.decimalplace" :step="priceStep" />
+                            <span>{{ selectedRow.goodscode }}/{{ selectedRow.goodsname }}</span>
                         </template>
                     </Field>
-                    <Field name="OrderQty" :rules="formRules.OrderQty" label="数量">
+                    <Field label="预售价">
                         <template #input>
-                            <div class="goods-listing__stepper">
-                                <Stepper v-model="formData.OrderQty" theme="round" button-size="22" :min="0" :step="qtyStep"
-                                    integer />
-                                <RadioGroup v-model="qtyStep" direction="horizontal" @change="onRadioChange">
-                                    <Radio v-for="(value, index) in qtyStepList" :key="index" :name="value">{{ value }}
-                                    </Radio>
-                                </RadioGroup>
-                            </div>
+                            <span>{{ selectedRow.presaleprice }}</span>
                         </template>
                     </Field>
-                    <Field label="可用资金">
+                    <Field label="可用量">
                         <template #input>
-                            <span>{{ accountStore.currentAccount.avaiableMoney?.toFixed(2) }}</span>
+                            <span>{{ enableqty }}</span>
+                        </template>
+                    </Field>
+                    <Field label="涨停">
+                        <template #input>
+                            <span>{{ handleNumberValue(quote?.limitup) }}</span>
+                        </template>
+                    </Field>
+                    <Field label="跌停">
+                        <template #input>
+                            <span>{{ handleNumberValue(quote?.limitdown) }}</span>
+                        </template>
+                    </Field>
+                    <Field name="OrderPrice" :rules="formRules.OrderPrice" label="转让价">
+                        <template #input>
+                            <Stepper v-model="formData.OrderPrice" theme="round" :min="quote?.limitdown"
+                                :max="quote?.limitup" :step="Math.pow(10, -selectedRow.decimalplace)"
+                                :decimal-length="selectedRow.decimalplace" :auto-fixed="false" button-size="22" />
+                        </template>
+                    </Field>
+                    <Field name="OrderQty" :rules="formRules.OrderQty" label="转让数量">
+                        <template #input>
+                            <Stepper v-model="formData.OrderQty" theme="round" :max="enableqty" button-size="22"
+                                :auto-fixed="false" integer />
                         </template>
                     </Field>
                 </CellGroup>
             </Form>
             <template #footer>
                 <div class="g-form__footer">
-                    <Button block square type="danger" @click="formRef?.submit"
-                        v-if="buyOrSell === BuyOrSell.Buy">订立买入</Button>
-                    <Button block square type="primary"
-                        :disabled="!formData.OrderQty || !enableqty || (formData.OrderQty > enableqty)"
-                        @click="formRef?.submit" v-if="buyOrSell === BuyOrSell.Sell">
-                        <span>转让卖出</span>
-                        <span v-if="enableqty">(≤{{ enableqty }})</span>
-                    </Button>
+                    <Button block square type="danger" @click="formRef?.submit">提交</Button>
                 </div>
             </template>
         </app-view>
@@ -51,63 +57,29 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, defineAsyncComponent, computed, onMounted } from 'vue'
-import { CellGroup, Form, Field, Stepper, Button, FieldRule, FormInstance, RadioGroup, Radio } from 'vant'
+import { shallowRef, PropType, computed, onMounted } from 'vue'
+import { CellGroup, Form, Field, Stepper, Button, FieldRule, FormInstance } from 'vant'
 import { fullloading, dialog } from '@/utils/vant'
-import { useRequest } from '@/hooks/request'
-import { queryMineTradePositionExs } from '@/services/api/transfer'
+import { handleNumberValue } from '@/filters'
 import { useOrder } from '@/business/trade'
-import { useAccountStore, useFuturesStore } from '@/stores'
+import { useFuturesStore } from '@/stores'
 import AppModal from '@/components/base/modal/index.vue'
 import { BuyOrSell } from '@/constants/order'
 import { EPriceMode, EValidType, EListingSelectType, EBuildType } from '@/constants/client'
 
-const Price = defineAsyncComponent(() => import('../../../../../../components/modules/quote/price/index.vue'))
-const Forex = defineAsyncComponent(() => import('../../../../../../components/modules/quote/forex/index.vue'))
-
 const props = defineProps({
-    goodsCode: {
-        type: String,
+    selectedRow: {
+        type: Object as PropType<Model.MineTradePositionExsRsp>,
         required: true
     },
-    buyOrSell: {
-        type: Number,
-        required: true
-    }
 })
 
 const { formData, formSubmit } = useOrder()
-const accountStore = useAccountStore()
-const futuresStore = useFuturesStore()
+const { getGoodsQuote } = useFuturesStore()
 const formRef = shallowRef<FormInstance>()
 const refresh = shallowRef(false) // 是否刷新父组件数据
 const showModal = shallowRef(true)
-const quote = futuresStore.getGoodsQuote(props.goodsCode)
-const qtyStepList = [1, 5, 10, 20, 30, 50] // 数量步长列表
-const qtyStep = shallowRef(qtyStepList[0]) // 数量步长
-
-// 获取转让持仓
-const { dataList: positionList, run: getMineTradePositionExs } = useRequest(queryMineTradePositionExs, {
-    manual: true,
-    params: {
-        goodsid: quote.value?.goodsid,
-    },
-    onSuccess: (res) => {
-        const [firstItem] = res.data
-        if (firstItem) {
-            formData.OrderPrice = firstItem.presaleprice
-        }
-    }
-})
-
-// 价格步长
-const priceStep = computed(() => {
-    const { quoteminunit = 0, decimalplace = 0 } = quote.value ?? {}
-    if (quoteminunit) {
-        return quoteminunit * Math.pow(10, decimalplace * -1)
-    }
-    return 1
-})
+const quote = getGoodsQuote(props.selectedRow.goodscode)
 
 // 表单验证规则
 const formRules: { [key in keyof Proto.OrderReq]?: FieldRule[] } = {
@@ -126,29 +98,24 @@ const formRules: { [key in keyof Proto.OrderReq]?: FieldRule[] } = {
 }
 
 // 可用数量
-const enableqty = computed(() => {
-    const [firstItem] = positionList.value
-    return firstItem ? firstItem.buycurpositionqty - firstItem.buyfrozenqty : 0
-})
+const enableqty = computed(() => props.selectedRow.buycurpositionqty - props.selectedRow.buyfrozenqty)
 
-const onPriceClick = (buyorsell: BuyOrSell, value: number) => {
-    formData.OrderPrice = value
-}
-
-const onRadioChange = (value: number) => {
-    formData.OrderQty = value
+// 关闭弹窗
+const closed = (isRefresh = false) => {
+    refresh.value = isRefresh
+    showModal.value = false
 }
 
 // 提交挂牌
 const onSubmit = () => {
-    const { marketid = 0, goodsid = 0 } = quote.value ?? {}
-    formData.MarketID = marketid
+    const { goodsid } = props.selectedRow
     formData.GoodsID = goodsid
-    formData.BuyOrSell = props.buyOrSell
+    formData.MarketID = 49201
+    formData.BuyOrSell = BuyOrSell.Sell
     formData.TimevalidType = EValidType.VALIDTYPE_YZ
     formData.PriceMode = EPriceMode.PRICEMODE_LIMIT
-    formData.ListingSelectType = EListingSelectType.LISTINGSELECTTYPE_DELISTINGTHENLISTING
-    formData.BuildType = props.buyOrSell === BuyOrSell.Sell ? EBuildType.BUILDTYPE_CLOSE : EBuildType.BUILDTYPE_OPEN
+    formData.ListingSelectType = EListingSelectType.LISTINGSELECTTYPE_LISTING
+    formData.BuildType = EBuildType.BUILDTYPE_CLOSE
 
     fullloading((hideLoading) => {
         formSubmit().then(() => {
@@ -161,20 +128,9 @@ const onSubmit = () => {
 }
 
 onMounted(() => {
-    const { last = 0, presettle = 0 } = quote.value ?? {}
-    formData.OrderPrice = last || presettle
-
-    if (props.buyOrSell === BuyOrSell.Sell) {
-        getMineTradePositionExs()
-    }
+    formData.OrderPrice = props.selectedRow.presaleprice
 })
 
-// 关闭弹窗
-const closed = (isRefresh = false) => {
-    refresh.value = isRefresh
-    showModal.value = false
-}
-
 // 暴露组件属性给父组件调用
 defineExpose({
     closed,

+ 1 - 1
src/packages/mobile/views/transfer/detail2/index.vue

@@ -38,7 +38,7 @@ const Chart = defineAsyncComponent(() => import('../../../components/modules/quo
 const Forex = defineAsyncComponent(() => import('../../../components/modules/quote/forex/index.vue'))
 
 const componentMap = new Map<string, unknown>([
-    ['listing', defineAsyncComponent(() => import('../../../views/order/position/components/transfer/listing/Index.vue'))], // 挂牌
+    ['listing', defineAsyncComponent(() => import('../listing/Index.vue'))], // 挂牌
 ])
 
 const { router, getQueryStringToNumber } = useNavigation()

+ 182 - 0
src/packages/mobile/views/transfer/listing/Index.vue

@@ -0,0 +1,182 @@
+<!-- 定金转让-挂牌 -->
+<template>
+    <app-modal direction="right" height="100%" v-model:show="showModal" :refresh="refresh">
+        <app-view class="g-form">
+            <template #header>
+                <app-navbar title="转让" @back="closed" />
+            </template>
+            <component :is="Price" v-bind="{ goodsCode }" />
+            <component :is="Forex" v-bind="{ goodsCode, showMore: false }" @price-click="onPriceClick" />
+            <Form ref="formRef" class="g-form__container" @submit="onSubmit">
+                <CellGroup inset>
+                    <Field name="OrderPrice" :rules="formRules.OrderPrice" label="价格">
+                        <template #input>
+                            <Stepper v-model="formData.OrderPrice" theme="round" button-size="22" :min="0"
+                                :auto-fixed="false" :decimal-length="quote?.decimalplace" :step="priceStep" />
+                        </template>
+                    </Field>
+                    <Field name="OrderQty" :rules="formRules.OrderQty" label="数量">
+                        <template #input>
+                            <div class="goods-listing__stepper">
+                                <Stepper v-model="formData.OrderQty" theme="round" button-size="22" :min="0" :step="qtyStep"
+                                    integer />
+                                <RadioGroup v-model="qtyStep" direction="horizontal" @change="onRadioChange">
+                                    <Radio v-for="(value, index) in qtyStepList" :key="index" :name="value">{{ value }}
+                                    </Radio>
+                                </RadioGroup>
+                            </div>
+                        </template>
+                    </Field>
+                    <Field label="可用资金">
+                        <template #input>
+                            <span>{{ accountStore.currentAccount.avaiableMoney?.toFixed(2) }}</span>
+                        </template>
+                    </Field>
+                </CellGroup>
+            </Form>
+            <template #footer>
+                <div class="g-form__footer">
+                    <Button block square type="danger" @click="formRef?.submit"
+                        v-if="buyOrSell === BuyOrSell.Buy">订立买入</Button>
+                    <Button block square type="primary"
+                        :disabled="!formData.OrderQty || !enableqty || (formData.OrderQty > enableqty)"
+                        @click="formRef?.submit" v-if="buyOrSell === BuyOrSell.Sell">
+                        <span>转让卖出</span>
+                        <span v-if="enableqty">(≤{{ enableqty }})</span>
+                    </Button>
+                </div>
+            </template>
+        </app-view>
+    </app-modal>
+</template>
+
+<script lang="ts" setup>
+import { shallowRef, defineAsyncComponent, computed, onMounted } from 'vue'
+import { CellGroup, Form, Field, Stepper, Button, FieldRule, FormInstance, RadioGroup, Radio } from 'vant'
+import { fullloading, dialog } from '@/utils/vant'
+import { useRequest } from '@/hooks/request'
+import { queryMineTradePositionExs } from '@/services/api/transfer'
+import { useOrder } from '@/business/trade'
+import { useAccountStore, useFuturesStore } from '@/stores'
+import AppModal from '@/components/base/modal/index.vue'
+import { BuyOrSell } from '@/constants/order'
+import { EPriceMode, EValidType, EListingSelectType, EBuildType } from '@/constants/client'
+
+const Price = defineAsyncComponent(() => import('../../../components/modules/quote/price/index.vue'))
+const Forex = defineAsyncComponent(() => import('../../../components/modules/quote/forex/index.vue'))
+
+const props = defineProps({
+    goodsCode: {
+        type: String,
+        required: true
+    },
+    buyOrSell: {
+        type: Number,
+        required: true
+    }
+})
+
+const { formData, formSubmit } = useOrder()
+const accountStore = useAccountStore()
+const futuresStore = useFuturesStore()
+const formRef = shallowRef<FormInstance>()
+const refresh = shallowRef(false) // 是否刷新父组件数据
+const showModal = shallowRef(true)
+const quote = futuresStore.getGoodsQuote(props.goodsCode)
+const qtyStepList = [1, 5, 10, 20, 30, 50] // 数量步长列表
+const qtyStep = shallowRef(qtyStepList[0]) // 数量步长
+
+// 获取转让持仓
+const { dataList: positionList, run: getMineTradePositionExs } = useRequest(queryMineTradePositionExs, {
+    manual: true,
+    params: {
+        goodsid: quote.value?.goodsid,
+    },
+    onSuccess: (res) => {
+        const [firstItem] = res.data
+        if (firstItem) {
+            formData.OrderPrice = firstItem.presaleprice
+        }
+    }
+})
+
+// 价格步长
+const priceStep = computed(() => {
+    const { quoteminunit = 0, decimalplace = 0 } = quote.value ?? {}
+    if (quoteminunit) {
+        return quoteminunit * Math.pow(10, decimalplace * -1)
+    }
+    return 1
+})
+
+// 表单验证规则
+const formRules: { [key in keyof Proto.OrderReq]?: FieldRule[] } = {
+    OrderPrice: [{
+        message: '请输入价格',
+        validator: () => {
+            return !!formData.OrderPrice
+        }
+    }],
+    OrderQty: [{
+        message: '请输入数量',
+        validator: () => {
+            return !!formData.OrderQty
+        }
+    }],
+}
+
+// 可用数量
+const enableqty = computed(() => {
+    const [firstItem] = positionList.value
+    return firstItem ? firstItem.buycurpositionqty - firstItem.buyfrozenqty : 0
+})
+
+const onPriceClick = (buyorsell: BuyOrSell, value: number) => {
+    formData.OrderPrice = value
+}
+
+const onRadioChange = (value: number) => {
+    formData.OrderQty = value
+}
+
+// 提交挂牌
+const onSubmit = () => {
+    const { marketid = 0, goodsid = 0 } = quote.value ?? {}
+    formData.MarketID = marketid
+    formData.GoodsID = goodsid
+    formData.BuyOrSell = props.buyOrSell
+    formData.TimevalidType = EValidType.VALIDTYPE_YZ
+    formData.PriceMode = EPriceMode.PRICEMODE_LIMIT
+    formData.ListingSelectType = EListingSelectType.LISTINGSELECTTYPE_DELISTINGTHENLISTING
+    formData.BuildType = props.buyOrSell === BuyOrSell.Sell ? EBuildType.BUILDTYPE_CLOSE : EBuildType.BUILDTYPE_OPEN
+
+    fullloading((hideLoading) => {
+        formSubmit().then(() => {
+            hideLoading()
+            dialog('提交成功').then(() => closed(true))
+        }).catch((err) => {
+            hideLoading(err, 'fail')
+        })
+    })
+}
+
+onMounted(() => {
+    const { last = 0, presettle = 0 } = quote.value ?? {}
+    formData.OrderPrice = last || presettle
+
+    if (props.buyOrSell === BuyOrSell.Sell) {
+        getMineTradePositionExs()
+    }
+})
+
+// 关闭弹窗
+const closed = (isRefresh = false) => {
+    refresh.value = isRefresh
+    showModal.value = false
+}
+
+// 暴露组件属性给父组件调用
+defineExpose({
+    closed,
+})
+</script>