|
|
@@ -3,54 +3,52 @@
|
|
|
<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 class="order-detail__container g-form__container">
|
|
|
- <CellGroup title="持仓信息">
|
|
|
+ <Form ref="formRef" class="g-form__container" @submit="onCloseSumit">
|
|
|
+ <CellGroup title="持仓信息" inset>
|
|
|
<Cell title="商品代码/名称" :value="`${selectedRow.goodscode}/${selectedRow.goodsname}`" />
|
|
|
<Cell title="持仓方向" :value="getBuyOrSellName(selectedRow.buyorsell)" />
|
|
|
<Cell title="持仓金额" :value="formatDecimal(selectedRow.curholderamount)" />
|
|
|
- <Cell title="持仓数量" :value="formatDecimal(selectedRow.curpositionqty)" />
|
|
|
- <Cell title="冻结数量" :value="formatDecimal(selectedRow.frozenqty)" />
|
|
|
- <Cell title="可用数量" :value="formatDecimal(selectedRow.enableqty)" />
|
|
|
+ <Cell title="持仓数量" :value="selectedRow.curpositionqty" />
|
|
|
+ <Cell title="冻结数量" :value="selectedRow.frozenqty" />
|
|
|
+ <Cell title="可用数量" :value="selectedRow.enableqty" />
|
|
|
<Cell title="持仓均价" :value="formatDecimal(selectedRow.averageprice)" />
|
|
|
<Cell title="参考损益">
|
|
|
<template #value>
|
|
|
- <span :class="handlePriceColor(closepl, 0.0)">{{ formatDecimal(closepl) }}</span>
|
|
|
+ <span :class="selectedRow.closeplColor">{{ formatDecimal(selectedRow.closepl) }}</span>
|
|
|
</template>
|
|
|
</Cell>
|
|
|
</CellGroup>
|
|
|
- <CellGroup title="转让信息">
|
|
|
+ <CellGroup title="转让信息" inset>
|
|
|
<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="转让价格">
|
|
|
- <template #input>
|
|
|
- <Stepper v-model="formData.OrderPrice" theme="round" button-size="22" :min="0"
|
|
|
- :decimal-length="selectedRow.decimalplace" :auto-fixed="false" />
|
|
|
- </template>
|
|
|
- </Field>
|
|
|
- <Field name="OrderQty" :rules="formRules.OrderQty" label="转让数量">
|
|
|
- <template #input>
|
|
|
- <Stepper v-model="formData.OrderQty" theme="round" button-size="22" :min="0"
|
|
|
- :max="selectedRow.enableqty" :auto-fixed="false" integer />
|
|
|
- </template>
|
|
|
- </Field>
|
|
|
- </Form>
|
|
|
+ <Field name="OrderPrice" :rules="formRules.OrderPrice" label="转让价格">
|
|
|
+ <template #input>
|
|
|
+ <Stepper v-model="formData.OrderPrice" theme="round" button-size="22" :min="0"
|
|
|
+ :decimal-length="selectedRow.decimalplace" :auto-fixed="false" />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ <Field name="OrderQty" :rules="formRules.OrderQty" label="转让数量">
|
|
|
+ <template #input>
|
|
|
+ <Stepper v-model="formData.OrderQty" theme="round" button-size="22" :min="0"
|
|
|
+ :max="selectedRow.enableqty" :auto-fixed="false" integer />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
</CellGroup>
|
|
|
- </div>
|
|
|
+ </Form>
|
|
|
<template #footer>
|
|
|
- <Button block square type="danger" @click="onCloseSumit">转让</Button>
|
|
|
+ <Button block square type="danger" @click="formRef?.submit">转让</Button>
|
|
|
</template>
|
|
|
</app-view>
|
|
|
</app-modal>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { shallowRef, PropType, onMounted, computed } from 'vue'
|
|
|
+import { shallowRef, PropType, onMounted } from 'vue'
|
|
|
import AppModal from '@/components/base/modal/index.vue'
|
|
|
-import { CellGroup, Cell, Button, FieldRule, Form, Field, Stepper } from 'vant'
|
|
|
+import { CellGroup, Cell, Button, FieldRule, Form, Field, Stepper, FormInstance } from 'vant'
|
|
|
import { getBuyOrSellName, BuyOrSell } from '@/constants/order'
|
|
|
-import { formatDecimal, handleNumberValue, handlePriceColor } from '@/filters'
|
|
|
+import { formatDecimal, handleNumberValue } from '@/filters'
|
|
|
import { useOrder } from '@/business/trade'
|
|
|
import { dialog, fullloading } from '@/utils/vant'
|
|
|
import { useFuturesStore } from '@/stores'
|
|
|
@@ -58,27 +56,24 @@ import { EBuildType, EDelistingType, EListingSelectType, EOrderOperateType, EPri
|
|
|
|
|
|
const props = defineProps({
|
|
|
selectedRow: {
|
|
|
- type: Object as PropType<Model.TradePositionRsp>,
|
|
|
+ type: Object as PropType<Model.TradePositionRsp & {
|
|
|
+ closepl: number; // 浮动盈亏
|
|
|
+ closeplColor: string; // 浮动盈亏颜色
|
|
|
+ }>,
|
|
|
required: true,
|
|
|
}
|
|
|
})
|
|
|
|
|
|
const futuresStore = useFuturesStore()
|
|
|
const quote = futuresStore.getGoodsQuote(props.selectedRow.goodscode)
|
|
|
+const formRef = shallowRef<FormInstance>()
|
|
|
const showModal = shallowRef(true)
|
|
|
// 是否刷新父组件数据
|
|
|
const refresh = shallowRef(false)
|
|
|
const { formSubmit, formData } = useOrder()
|
|
|
|
|
|
-// 损益
|
|
|
-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.OrderReq]?: FieldRule[] } = {
|
|
|
+const formRules: { [key: string]: FieldRule[] } = {
|
|
|
OrderPrice: [{
|
|
|
message: '请输入转让价格',
|
|
|
validator: () => {
|
|
|
@@ -115,7 +110,7 @@ const onCloseSumit = () => {
|
|
|
/// loding....
|
|
|
fullloading((hideLoading) => {
|
|
|
formSubmit().then(() => {
|
|
|
- hideLoading('转让成功')
|
|
|
+ hideLoading('转让成功', 'success')
|
|
|
closed(true)
|
|
|
}).catch((err) => {
|
|
|
hideLoading(err, 'fail')
|