|
|
@@ -0,0 +1,114 @@
|
|
|
+<!-- 我的订单- 订单持仓 - 平仓 -->
|
|
|
+<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>
|
|
|
+ <div v-if="props" class="order-detail__container g-form__container">
|
|
|
+ <CellGroup title="持仓信息">
|
|
|
+ <Cell title="商品代码/名称" :value="selectedRow.goodscode + '/' + selectedRow.goodsname" />
|
|
|
+ <Cell title="持仓方向" :value="getBuyOrSellName(selectedRow.buyorsell)" />
|
|
|
+ <Cell title="持仓金额" :value="formatDecimal(selectedRow.holderamount)" />
|
|
|
+ <Cell title="持仓数量" :value="formatDecimal(selectedRow.curpositionqty)" />
|
|
|
+ <Cell title="冻结数量" :value="formatDecimal(selectedRow.frozenqty)" />
|
|
|
+ <Cell title="可用数量" :value="formatDecimal(selectedRow.enableqty)" />
|
|
|
+ <Cell title="持仓均价" :value="formatDecimal(selectedRow.averageprice)" />
|
|
|
+ <Cell title="参考损益" :value="'--'" />
|
|
|
+ </CellGroup>
|
|
|
+ <CellGroup title="平仓信息">
|
|
|
+ <Cell title="当前价" :value="'--'" />
|
|
|
+ <Form class="goods-close__form" ref="formRef" @submit="onCloseSumit" v-if="props">
|
|
|
+ <Field name="OrderQty" :rules="formRules.OrderQty" label="平仓数量">
|
|
|
+ <template #input>
|
|
|
+ <Stepper v-model="formData.OrderQty" input-width="100" theme="round" button-size="22" :min="0" :step="0.01" :max="selectedRow.enableqty" :auto-fixed="false" />
|
|
|
+ </template>
|
|
|
+ </Field>
|
|
|
+ </Form>
|
|
|
+ </CellGroup>
|
|
|
+ </div>
|
|
|
+ <template #footer>
|
|
|
+ <Button type="primary" block round @click="onCloseSumit">平仓</Button>
|
|
|
+ </template>
|
|
|
+ </app-view>
|
|
|
+ </app-modal>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script lang="ts" setup>
|
|
|
+import { shallowRef, PropType } 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 { formatDecimal } from '@/filters'
|
|
|
+import { useOrder } from '@/business/trade'
|
|
|
+import { dialog, fullloading } from '@/utils/vant'
|
|
|
+import { EBuildType, EDelistingType, EListingSelectType, EOrderOperateType, EPriceMode, EValidType } from '@/constants/client'
|
|
|
+
|
|
|
+const showModal = shallowRef(true)
|
|
|
+// 是否刷新父组件数据
|
|
|
+const refresh = shallowRef(false)
|
|
|
+const { formSubmit, formData } = useOrder()
|
|
|
+
|
|
|
+const props = defineProps({
|
|
|
+ selectedRow: {
|
|
|
+ type: Object as PropType<Model.TradePositionRsp>,
|
|
|
+ required: true,
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+// 表单验证规则
|
|
|
+const formRules: { [key in keyof Proto.OrderReq]?: FieldRule[] } = {
|
|
|
+ OrderQty: [{
|
|
|
+ message: '请输入平仓数量',
|
|
|
+ validator: () => {
|
|
|
+ return !!formData.OrderQty
|
|
|
+ }
|
|
|
+ }],
|
|
|
+}
|
|
|
+
|
|
|
+const onCloseSumit = () => {
|
|
|
+ dialog({
|
|
|
+ message: '确认要撤销吗?',
|
|
|
+ showCancelButton: true,
|
|
|
+ }).then(() => {
|
|
|
+
|
|
|
+ const { marketid, goodsid, buyorsell, averageprice} = props.selectedRow
|
|
|
+ /// 市场ID
|
|
|
+ formData.Header = { MarketID: marketid, GoodsID: goodsid }
|
|
|
+ formData.MarketID = marketid
|
|
|
+ formData.PriceMode = EPriceMode.PRICEMODE_LIMIT
|
|
|
+ formData.OrderPrice = averageprice
|
|
|
+ formData.BuyOrSell = buyorsell === 0 ? 1 : 0,
|
|
|
+ formData.GoodsID = goodsid
|
|
|
+ formData.ListingSelectType = EListingSelectType.LISTINGSELECTTYPE_DELISTING
|
|
|
+ formData.DelistingType = EDelistingType.DELISTINGTYPE_PRICE
|
|
|
+ formData.BuildType = EBuildType.BUILDTYPE_CLOSE
|
|
|
+ formData.ValidType = EValidType.VALIDTYPE_DR
|
|
|
+ formData.OperateType = EOrderOperateType.ORDEROPERATETYPE_NORMAL
|
|
|
+ formData.TriggerType = 0
|
|
|
+ formData.ServiceTime = ""
|
|
|
+ formData.ValidTime = ""
|
|
|
+
|
|
|
+ /// loding....
|
|
|
+ fullloading((hideLoading) => {
|
|
|
+ formSubmit().then(() => {
|
|
|
+ hideLoading('平仓成功')
|
|
|
+ closed(true)
|
|
|
+ }).catch((err) => {
|
|
|
+ hideLoading(err, 'fail')
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// 关闭弹窗
|
|
|
+const closed = (isRefresh = false) => {
|
|
|
+ refresh.value = isRefresh
|
|
|
+ showModal.value = false
|
|
|
+}
|
|
|
+
|
|
|
+// 暴露组件属性给父组件调用
|
|
|
+defineExpose({
|
|
|
+ closed,
|
|
|
+})
|
|
|
+</script>
|