Procházet zdrojové kódy

Merge branch 'master' of http://47.101.159.18:3000/Muchinfo/MTP20_WEB_GLOBAL

li.shaoyi před 2 roky
rodič
revize
1209bd1fb1

+ 10 - 10
src/packages/mobile/views/order/position/components/goods/close/Index.vue

@@ -1,9 +1,9 @@
-<!-- 我的持仓- 订单持仓 - 平仓 -->
+<!-- 我的持仓- 订单持仓 - 转让 -->
 <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" />
+                <app-navbar title="订单持仓 - 转让" @back="closed" />
             </template>
             <div v-if="props" class="order-detail__container g-form__container">
                 <CellGroup title="持仓信息">
@@ -20,16 +20,16 @@
                         </template>
                     </Cell>
                 </CellGroup>
-                <CellGroup title="平仓信息">
+                <CellGroup title="转让信息">
                     <Cell title="当前价" :value="handleNumberValue(quote?.last)" />
                     <Form class="goods-close__form" ref="formRef" @submit="onCloseSumit" v-if="props">
-                        <Field name="OrderPrice" :rules="formRules.OrderPrice" label="平仓价格">
+                        <Field name="OrderPrice" :rules="formRules.OrderPrice" label="转让价格">
                             <template #input>
                                 <Stepper v-model="formData.OrderPrice" input-width="100" theme="round" button-size="22"
                                     :min="0" :decimal-length="selectedRow.decimalplace" :auto-fixed="false" />
                             </template>
                         </Field>
-                        <Field name="OrderQty" :rules="formRules.OrderQty" label="平仓数量">
+                        <Field name="OrderQty" :rules="formRules.OrderQty" label="转让数量">
                             <template #input>
                                 <Stepper v-model="formData.OrderQty" input-width="100" theme="round" button-size="22"
                                     :min="0" :max="selectedRow.enableqty" :auto-fixed="false" integer />
@@ -39,7 +39,7 @@
                 </CellGroup>
             </div>
             <template #footer>
-                <Button type="primary" block round @click="onCloseSumit">平仓</Button>
+                <Button type="primary" block round @click="onCloseSumit">转让</Button>
             </template>
         </app-view>
     </app-modal>
@@ -80,13 +80,13 @@ const closepl = computed(() => {
 // 表单验证规则
 const formRules: { [key in keyof Proto.OrderReq]?: FieldRule[] } = {
     OrderPrice: [{
-        message: '请输入平仓价格',
+        message: '请输入转让价格',
         validator: () => {
             return !!formData.OrderPrice
         }
     }],
     OrderQty: [{
-        message: '请输入平仓数量',
+        message: '请输入转让数量',
         validator: () => {
             return !!formData.OrderQty
         }
@@ -95,7 +95,7 @@ const formRules: { [key in keyof Proto.OrderReq]?: FieldRule[] } = {
 
 const onCloseSumit = () => {
     dialog({
-        message: '确认要平仓吗?',
+        message: '确认要转让吗?',
         showCancelButton: true,
     }).then(() => {
 
@@ -115,7 +115,7 @@ const onCloseSumit = () => {
         /// loding....
         fullloading((hideLoading) => {
             formSubmit().then(() => {
-                hideLoading('平仓成功')
+                hideLoading('转让成功')
                 closed(true)
             }).catch((err) => {
                 hideLoading(err, 'fail')

+ 31 - 14
src/packages/mobile/views/order/position/components/goods/delivery/Index.vue

@@ -14,17 +14,21 @@
                     <Cell title="冻结数量" :value="formatDecimal(selectedRow.frozenqty)" />
                     <Cell title="可用数量" :value="formatDecimal(selectedRow.enableqty)" />
                     <Cell title="持仓均价" :value="formatDecimal(selectedRow.averageprice)" />
-                    <Cell title="参考损益" :value="'--'" />
+                    <Cell title="参考损益">
+                        <template #value>
+                            <span :class="closepl ? 'g-up-color' : 'g-down-color'">{{ formatDecimal(closepl) }}</span>
+                        </template>
+                    </Cell>
                 </CellGroup>
                 <CellGroup title="交收信息">
-                    <Cell title="交收对手方" :value="'--'" />
+                    <Cell title="交收对手方" :value="selectedRow.matchname" />
                     <Form class="goods-close__form" ref="formRef" @submit="onDeliverySumit" v-if="props">
-                        <Field name="DeliveryLot" :rules="formRules.DeliveryLot" label="交收数量">
+                        <Field name="DeliveryLot" type="digit" :rules="formRules.DeliveryLot" label="交收数量">
                             <template #input>
                                 <Stepper v-model="formData.DeliveryLot" input-width="100" theme="round" button-size="22" :min="0" :max="selectedRow.enableqty" :auto-fixed="false" integer />
                             </template>
                         </Field>
-                        <Field name="DeliveryInfo" v-model="formData.DeliveryInfo" :rules="formRules.DeliveryInfo" label="交收信息" placeholder="请输入交收信息">
+                        <Field name="DeliveryInfo" v-model="formData.DeliveryInfo" type="textarea" autosize clearable :rules="formRules.DeliveryInfo" maxlength="50" label="交收信息" placeholder="请输入交收信息">
                         </Field>
                     </Form>
                 </CellGroup>
@@ -37,18 +41,14 @@
 </template>
 
 <script lang="ts" setup>
-import { shallowRef, PropType } from 'vue'
+import { shallowRef, PropType, computed } from 'vue'
 import AppModal from '@/components/base/modal/index.vue'
 import { CellGroup, Cell, Button, FieldRule, Form, Field, Stepper} from 'vant'
-import { getBuyOrSellName } from '@/constants/order'
+import { getBuyOrSellName, BuyOrSell } from '@/constants/order'
 import { formatDecimal } from '@/filters'
 import { useOfflineDelivery } from '@/business/trade'
 import { dialog, fullloading } from '@/utils/vant'
-
-const showModal = shallowRef(true)
-// 是否刷新父组件数据
-const refresh = shallowRef(false)
-const { formSubmit, formData } = useOfflineDelivery()
+import { useFuturesStore } from '@/stores'
 
 const props = defineProps({
     selectedRow: {
@@ -57,15 +57,33 @@ const props = defineProps({
     }
 })
 
+const showModal = shallowRef(true)
+// 是否刷新父组件数据
+const refresh = shallowRef(false)
+const { formSubmit, formData } = useOfflineDelivery()
+const futuresStore = useFuturesStore()
+const quote = futuresStore.getQuoteInfo(props.selectedRow.goodscode)
+
+/// 计算参考损益
+const closepl = computed(() => {
+    const { last = 0 } = quote.value ?? {}
+    const { curpositionqty, curholderamount, agreeunit, buyorsell } = props.selectedRow
+    return (last * curpositionqty * agreeunit - curholderamount) * (buyorsell === BuyOrSell.Buy ? 1 : -1)
+})
+
 // 表单验证规则
 const formRules: { [key in keyof Proto.OfflineDeliveryReq]?: FieldRule[] } = {
     DeliveryLot: [{
         message: '请输入交收数量',
-        validator: () => {
-            return !!formData.DeliveryLot
+        validator: (val) => {
+            if (val <= props.selectedRow.enableqty) {
+                return true
+            }
+            return '超过可用交收数量'
         }
     }],
     DeliveryInfo: [{
+        required: true,
         message: '请输入交收信息',
         validator: () => {
             return !!formData.DeliveryInfo
@@ -84,7 +102,6 @@ const onDeliverySumit = () => {
         formData.GoodsCode = goodscode
         formData.GoodsID = goodsid
         formData.BuyOrSell = buyorsell
-	
         /// loding....
         fullloading((hideLoading) => {
             formSubmit().then(() => {

+ 28 - 5
src/packages/mobile/views/order/position/components/goods/list/Index.vue

@@ -7,14 +7,16 @@
                 <div class="g-order-list__titlebar">
                     <div class="left">
                         <h4>{{ item.goodscode }}/{{ item.goodsname }}</h4>
-                        <span>--</span>
                     </div>
                     <div class="right">
-                        <span>{{ getBuyOrSellName(item.buyorsell) }}</span>
+                        <span :class="!item.buyorsell ? 'g-up-color' : 'g-down-color'">{{ getBuyOrSellName(item.buyorsell) }}</span>
                     </div>
                 </div>
                 <div class="g-order-list__content">
                     <ul>
+                        <li :class="lastColor(item.goodscode)">{{ last(item.goodscode) }}</li>
+                    </ul>
+                    <ul>
                         <li>
                             <span>持有数量:</span>
                             <span>{{ formatDecimal(item.curpositionqty) }}</span>
@@ -35,10 +37,14 @@
                             <span>可用数量:</span>
                             <span>{{ formatDecimal(item.enableqty) }}</span>
                         </li>
+                        <li>
+                            <span>参考损益:</span>
+                            <span :class="closepl(item) ? 'g-up-color' : 'g-down-color'">{{ closepl(item) }}</span>
+                        </li>
                     </ul>
                 </div>
                 <div class="g-order-list__btnbar">
-                    <Button size="small" @click="showComponent('close', item)" round>平仓</Button>
+                    <Button size="small" v-if="item.enableqty != 0" @click="showComponent('close', item)" round>平仓</Button>
                     <Button size="small" v-if="userStore.userType === 5" @click="showComponent('delivery', item)"
                         round>交收</Button>
                 </div>
@@ -56,9 +62,9 @@ import { useComponent } from '@/hooks/component'
 import { useRequest } from '@/hooks/request'
 import { queryTradePosition } from '@/services/api/order'
 import AppPullRefresh from '@mobile/components/base/pull-refresh/index.vue'
-import { getBuyOrSellName } from '@/constants/order'
+import { getBuyOrSellName, BuyOrSell} from '@/constants/order'
 import { formatDecimal, handleNumberValue } from '@/filters'
-import { useUserStore } from '@/stores'
+import { useUserStore, useFuturesStore } from '@/stores'
 
 const componentMap = new Map<string, unknown>([
     ['close', defineAsyncComponent(() => import('../close/Index.vue'))],
@@ -66,11 +72,28 @@ const componentMap = new Map<string, unknown>([
 ])
 
 const userStore = useUserStore()
+const futuresStore = useFuturesStore()
+
 const dataList = shallowRef<Model.TradePositionRsp[]>([])
 const selectedRow = shallowRef<Model.TradePositionRsp>()
 const error = shallowRef(false)
 const pullRefreshRef = shallowRef()
 
+const last = (goodsCode: string) => {
+    return futuresStore.getQuotePrice(goodsCode)
+} 
+
+const lastColor = (goodsCode: string) => {
+    return futuresStore.getQuoteInfo(goodsCode).value?.lastColor
+} 
+
+/// 计算参考损益
+const closepl = (item: Model.TradePositionRsp) => {
+    const { last = 0 } = futuresStore.getQuoteInfo(item.goodscode).value ?? {}
+    const { curpositionqty, curholderamount, agreeunit, buyorsell } = item
+    return (last * curpositionqty * agreeunit - curholderamount) * (buyorsell === BuyOrSell.Buy ? 1 : -1)
+}
+
 const { componentRef, componentId, openComponent, closeComponent } = useComponent(() => {
     pullRefreshRef.value?.refresh()
 })

+ 23 - 3
src/packages/mobile/views/order/position/components/swap/list/Index.vue

@@ -7,7 +7,6 @@
                 <div class="g-order-list__titlebar">
                     <div class="left">
                         <h4>{{ item.goodscode }}/{{ item.goodsname }}</h4>
-                        <span>--</span>
                     </div>
                     <div class="right">
                         <span>{{ getBuyOrSellName(item.buyorsell) }}</span>
@@ -15,6 +14,9 @@
                 </div>
                 <div class="g-order-list__content">
                     <ul>
+                        <li :class="lastColor(item.goodscode)">{{ last(item.goodscode) }}</li>
+                    </ul>
+                    <ul>
                         <li>
                             <span>持有数量:</span>
                             <span>{{ item.curpositionqty }}</span>
@@ -37,7 +39,7 @@
                         </li>
                         <li>
                             <span>参考损益:</span>
-                            <span>--</span>
+                            <span :class="closepl(item) ? 'g-up-color' : 'g-down-color'">{{ closepl(item) }}</span>
                         </li>
                     </ul>
                 </div>
@@ -58,18 +60,36 @@ import { useComponent } from '@/hooks/component'
 import { useRequest } from '@/hooks/request'
 import { queryTradePosition } from '@/services/api/order'
 import AppPullRefresh from '@mobile/components/base/pull-refresh/index.vue'
-import { getBuyOrSellName } from '@/constants/order'
+import { getBuyOrSellName, BuyOrSell } from '@/constants/order'
 import { formatDecimal, handleNumberValue } from '@/filters'
+import { useFuturesStore } from '@/stores'
 
 const componentMap = new Map<string, unknown>([
     ['close', defineAsyncComponent(() => import('../close/Index.vue'))],
 ])
 
+const futuresStore = useFuturesStore()
+
 const dataList = shallowRef<Model.TradePositionRsp[]>([])
 const selectedRow = shallowRef<Model.TradePositionRsp>()
 const error = shallowRef(false)
 const pullRefreshRef = shallowRef()
 
+const last = (goodsCode: string) => {
+    return futuresStore.getQuotePrice(goodsCode)
+} 
+
+const lastColor = (goodsCode: string) => {
+    return futuresStore.getQuoteInfo(goodsCode).value?.lastColor
+} 
+
+/// 计算参考损益
+const closepl = (item: Model.TradePositionRsp) => {
+    const { last = 0 } = futuresStore.getQuoteInfo(item.goodscode).value ?? {}
+    const { curpositionqty, curholderamount, agreeunit, buyorsell } = item
+    return (last * curpositionqty * agreeunit - curholderamount) * (buyorsell === BuyOrSell.Buy ? 1 : -1)
+}
+
 const { componentRef, componentId, openComponent, closeComponent } = useComponent(() => {
     pullRefreshRef.value?.refresh()
 })

+ 2 - 0
src/types/model/order.d.ts

@@ -967,6 +967,8 @@ declare namespace Model {
         lastprice: number
         /// 市值
         marketamount: number
+        /// 对手方名称
+        matchname: string
         /// 所属市场ID
         marketid: number
         /// 开仓申请数量(用于比较最大持仓数量)