|
|
@@ -0,0 +1,147 @@
|
|
|
+<!-- 商品订单-持仓明细-转让 -->
|
|
|
+<template>
|
|
|
+ <app-drawer title="转让" :width="800" v-model:show="show" :loading="loading" :refresh="refresh">
|
|
|
+ <el-form ref="formRef" class="el-form--horizontal" label-width="120px" label-position="left" :model="formData"
|
|
|
+ :rules="formRules">
|
|
|
+ <el-form-item label="商品代码/名称">
|
|
|
+ <span>{{ selectedRow.goodscode }}/{{ selectedRow.goodsname }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="持仓方向">
|
|
|
+ <span>{{ getBuyOrSellName(selectedRow.buyorsell) }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="持仓金额">
|
|
|
+ <span>{{ formatDecimal(selectedRow.holderamount) }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="持仓数量">
|
|
|
+ <span>{{ selectedRow.holderqty }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="持仓价">
|
|
|
+ <span>{{ formatDecimal(selectedRow.holderprice, selectedRow.decimalplace) }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="参考损益">
|
|
|
+ <span :class="handlePriceColor(closepl)">{{ formatDecimal(closepl) }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="OrderQty" label="转让数量">
|
|
|
+ <div class="g-qty-group">
|
|
|
+ <el-input-number placeholder="请输入数量" v-model="formData.OrderQty" :precision="0"
|
|
|
+ :max="selectedRow.holderqty" :min="0" />
|
|
|
+ <el-radio-group size="small" v-model="qtyStep" @change="onRadioChange">
|
|
|
+ <el-radio v-for="(value, index) in qtyStepList" :key="index" :label="value" border
|
|
|
+ style="width: 25%;">
|
|
|
+ {{ parsePercent(value, 0) }}
|
|
|
+ </el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </div>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="OrderPrice" label="转让价格">
|
|
|
+ <el-input-number placeholder="请输入价格" v-model="formData.OrderPrice"
|
|
|
+ :decimal-length="selectedRow.decimalplace" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <el-button type="info" @click="onCancel(false)">取消</el-button>
|
|
|
+ <el-button type="primary" @click="onCloseSumit">提交</el-button>
|
|
|
+ </template>
|
|
|
+ </app-drawer>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script lang="ts" setup>
|
|
|
+import { ref, PropType, computed, onMounted } from 'vue'
|
|
|
+import { ElMessage, FormInstance, FormRules } from 'element-plus'
|
|
|
+import { useOrder } from '@/business/trade'
|
|
|
+import { formatDecimal, handlePriceColor, parsePercent } from '@/filters'
|
|
|
+import { getBuyOrSellName, BuyOrSell } from '@/constants/order'
|
|
|
+import { useFuturesStore } from '@/stores'
|
|
|
+import { EBuildType, EDelistingType, EListingSelectType, EOrderOperateType, EPriceMode, EValidType } from '@/constants/client'
|
|
|
+import AppDrawer from '@pc/components/base/drawer/index.vue'
|
|
|
+
|
|
|
+const props = defineProps({
|
|
|
+ selectedRow: {
|
|
|
+ type: Object as PropType<Model.TradeHolderDetailRsp>,
|
|
|
+ required: true
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+const futuresStore = useFuturesStore()
|
|
|
+const quote = futuresStore.getGoodsQuote(props.selectedRow.goodscode)
|
|
|
+// 损益
|
|
|
+const closepl = computed(() => {
|
|
|
+ const { last = 0 } = quote.value ?? {}
|
|
|
+ const { holderqty, holderamount, agreeunit, buyorsell } = props.selectedRow
|
|
|
+ return (last * holderqty * agreeunit - holderamount) * (buyorsell === BuyOrSell.Buy ? 1 : -1)
|
|
|
+})
|
|
|
+
|
|
|
+const { formSubmit, formData, loading } = useOrder()
|
|
|
+const show = ref(true)
|
|
|
+const refresh = ref(false)
|
|
|
+const formRef = ref<FormInstance>()
|
|
|
+const qtyStepList = [0.25, 0.5, 0.75, 1] // 数量步长列表
|
|
|
+const qtyStep = ref<number>() // 数量步长
|
|
|
+
|
|
|
+const formRules: FormRules = {
|
|
|
+ OrderPrice: [{
|
|
|
+ message: '请输入转让价格',
|
|
|
+ validator: () => {
|
|
|
+ return !!formData.OrderPrice
|
|
|
+ }
|
|
|
+ }],
|
|
|
+ OrderQty: [{
|
|
|
+ message: '请输入转让数量',
|
|
|
+ validator: () => {
|
|
|
+ return !!formData.OrderQty
|
|
|
+ }
|
|
|
+ }],
|
|
|
+}
|
|
|
+
|
|
|
+const onCancel = (isRefresh = false) => {
|
|
|
+ show.value = false
|
|
|
+ refresh.value = isRefresh
|
|
|
+}
|
|
|
+
|
|
|
+const onCloseSumit = () => {
|
|
|
+ formRef.value?.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ const { marketid, goodsid, buyorsell, tradeid } = props.selectedRow
|
|
|
+ /// 市场ID
|
|
|
+ formData.Header = { GoodsID: goodsid }
|
|
|
+ formData.MarketID = marketid
|
|
|
+ formData.PriceMode = EPriceMode.PRICEMODE_LIMIT
|
|
|
+ formData.BuyOrSell = buyorsell === BuyOrSell.Buy ? BuyOrSell.Sell : BuyOrSell.Buy
|
|
|
+ formData.GoodsID = goodsid
|
|
|
+ formData.ListingSelectType = EListingSelectType.LISTINGSELECTTYPE_DELISTINGTHENLISTING
|
|
|
+ formData.DelistingType = EDelistingType.DELISTINGTYPE_PRICE
|
|
|
+ formData.BuildType = EBuildType.BUILDTYPE_CLOSE
|
|
|
+ formData.TimevalidType = EValidType.VALIDTYPE_DR
|
|
|
+ formData.OperateType = EOrderOperateType.ORDEROPERATETYPE_NORMAL
|
|
|
+ formData.RelatedID = tradeid
|
|
|
+
|
|
|
+ formSubmit().then(() => {
|
|
|
+ ElMessage.success('挂牌成功')
|
|
|
+ onCancel(true)
|
|
|
+ }).catch((err) => {
|
|
|
+ ElMessage.error('挂牌失败:' + err)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const onRadioChange = (value: number) => {
|
|
|
+ const { holderqty, freezeqty } = props.selectedRow
|
|
|
+ formData.OrderQty = Math.trunc((holderqty-freezeqty) * value) || 1
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ const { bid, ask, presettle = 0 } = quote.value ?? {}
|
|
|
+ switch (props.selectedRow.buyorsell) {
|
|
|
+ case BuyOrSell.Buy:
|
|
|
+ formData.OrderPrice = ask || presettle
|
|
|
+ break
|
|
|
+ case BuyOrSell.Sell:
|
|
|
+ formData.OrderPrice = bid || presettle
|
|
|
+ break
|
|
|
+ default:
|
|
|
+ formData.OrderPrice = presettle
|
|
|
+ }
|
|
|
+ formData.OrderQty = props.selectedRow.holderqty
|
|
|
+})
|
|
|
+</script>
|