|
|
@@ -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(() => {
|