|
|
@@ -0,0 +1,162 @@
|
|
|
+<!-- 掉期市场 - 买卖大厅 - 摘牌 -->
|
|
|
+<template>
|
|
|
+ <app-drawer title="摘牌" v-model:show="show" :width="800" :loading="loading" :refresh="refresh">
|
|
|
+ <el-form ref="formRef" class="el-form--horizontal" label-width="100px" :model="formData" :rules="formRules">
|
|
|
+ <el-form-item label="交易账户">
|
|
|
+ <span>{{ accountStore.currentAccountId }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="挂牌方">
|
|
|
+ <span>{{ selectedRow.username }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="价格类型" prop="PriceMove">
|
|
|
+ <el-radio-group v-model="priceMove">
|
|
|
+ <el-radio :label="2">固定价</el-radio>
|
|
|
+ <el-radio v-if="userStore.userType != 5" :label="3">浮动价</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="当前价格" v-if="priceMove === 2">
|
|
|
+ <span>{{ formatDecimal(selectedRow.orderprice) }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="浮动价格" v-if="priceMove === 3">
|
|
|
+ <span>{{ '******' }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item v-if="priceMove === 2" prop="OrderPrice" label="摘牌价格">
|
|
|
+ <el-input-number placeholder="请输入" :min="0" :precision="2" v-model="formData.OrderPrice" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item v-if="priceMove === 3" prop="MarketMaxSub" label="点差">
|
|
|
+ <el-input-number placeholder="请输入" :min="0" :precision="2" v-model="formData.MarketMaxSub" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="OrderQty" label="摘牌数量">
|
|
|
+ <div class="g-qty-group">
|
|
|
+ <el-input-number placeholder="请输入" :min="0" :max="selectedRow.orderqty" :precision="0" :step="qtyStep"
|
|
|
+ v-model="formData.OrderQty" />
|
|
|
+ <el-radio-group size="small" v-model="qtyStep" @change="onRadioChange">
|
|
|
+ <el-radio v-for="(value, index) in qtyStepList" :key="index" :label="value" border />
|
|
|
+ </el-radio-group>
|
|
|
+ </div>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="可摘数量">
|
|
|
+ <span>{{ selectedRow.orderqty }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="参考价格" v-if="priceMove === 2">
|
|
|
+ <span :class="quote?.lastColor">{{ quote?.last ?? 0.0 }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="估算价格" v-if="priceMove === 3">
|
|
|
+ <span>0.0</span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="挂牌金额" v-if="priceMove === 2">
|
|
|
+ <span>{{ amount.toFixed(2) }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="估算金额" v-if="priceMove === 3">
|
|
|
+ <span>{{ amount.toFixed(2) }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="履约保证金">
|
|
|
+ <span>{{ permargin.toFixed(2) }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="可用资金">
|
|
|
+ <span>{{ accountStore.currentAccount.avaiableMoney?.toFixed(2) }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <el-button type="info" @click="onCancel(false)">取消</el-button>
|
|
|
+ <el-button type="danger" :disabled="!formData.OrderQty || formData.OrderQty > selectedRow.orderqty"
|
|
|
+ @click="onSubmit(EBuildType.BUILDTYPE_OPEN)">{{ selectedRow.buyorsell === 0 ? '卖出' : '买入' }}</el-button>
|
|
|
+ </template>
|
|
|
+ </app-drawer>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script lang="ts" setup>
|
|
|
+import { shallowRef, PropType, computed } from 'vue'
|
|
|
+import { ElMessage, FormInstance, FormRules, ElMessageBox } from 'element-plus'
|
|
|
+import { formatDecimal, handleRequestBigNumber } from '@/filters'
|
|
|
+import { EBuildType, EDelistingType, EListingSelectType, EOrderOperateType, EPriceMode, EValidType } from '@/constants/client'
|
|
|
+import { BuyOrSell } from '@/constants/order'
|
|
|
+import { useOrder } from '@/business/trade'
|
|
|
+import { usePosition } from '@/business/position'
|
|
|
+import { useFuturesStore, useAccountStore, useUserStore } from '@/stores'
|
|
|
+import AppDrawer from '@pc/components/base/drawer/index.vue'
|
|
|
+
|
|
|
+const props = defineProps({
|
|
|
+ selectedRow: {
|
|
|
+ type: Object as PropType<Model.TjmdTradeOrderDetailRsp>,
|
|
|
+ required: true
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+const accountStore = useAccountStore()
|
|
|
+const userStore = useUserStore()
|
|
|
+
|
|
|
+/// 价格类型
|
|
|
+const priceMove = shallowRef(EPriceMode.PRICEMODE_LIMIT)
|
|
|
+/// 挂牌金额
|
|
|
+const amount = shallowRef(0.0)
|
|
|
+/// 履约保证金
|
|
|
+const permargin = shallowRef(0.0)
|
|
|
+
|
|
|
+const { formData, formSubmit, loading } = useOrder()
|
|
|
+const futuresStore = useFuturesStore()
|
|
|
+const show = shallowRef(true)
|
|
|
+const refresh = shallowRef(false)
|
|
|
+const formRef = shallowRef<FormInstance>()
|
|
|
+const qtyStepList = [1, 5, 10, 20, 30, 50] // 数量步长列表
|
|
|
+const qtyStep = shallowRef(qtyStepList[0]) // 数量步长
|
|
|
+
|
|
|
+// 商品盘面
|
|
|
+const quote = futuresStore.getGoodsQuote(props.selectedRow.goodsid)
|
|
|
+
|
|
|
+const formRules: FormRules = {
|
|
|
+ OrderQty: [{
|
|
|
+ required: true,
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
+ if (value) {
|
|
|
+ callback()
|
|
|
+ } else {
|
|
|
+ callback(new Error('请输入摘牌数量'))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }],
|
|
|
+}
|
|
|
+
|
|
|
+const onRadioChange = (value: number) => {
|
|
|
+ formData.OrderQty = value
|
|
|
+}
|
|
|
+
|
|
|
+const onCancel = (isRefresh = false) => {
|
|
|
+ show.value = false
|
|
|
+ refresh.value = isRefresh
|
|
|
+}
|
|
|
+
|
|
|
+const onSubmit = (buildType: number) => {
|
|
|
+ formRef.value?.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ ElMessageBox.confirm(
|
|
|
+ '*若存在价格匹配的反方向委托订单,系统将会自动撤销。',
|
|
|
+ '是否立即摘牌?'
|
|
|
+ ).then(() => {
|
|
|
+ const { goodsid, orderid, orderprice, buyorsell } = props.selectedRow
|
|
|
+ const { marketid = 0 } = quote.value ?? {}
|
|
|
+
|
|
|
+ /// 获取对应的市场ID
|
|
|
+ formData.MarketID = marketid
|
|
|
+ formData.PriceMode = EPriceMode.PRICEMODE_LIMIT
|
|
|
+ formData.RelatedID = handleRequestBigNumber(orderid)
|
|
|
+ formData.OrderPrice = orderprice
|
|
|
+ formData.BuyOrSell = buyorsell === BuyOrSell.Buy ? BuyOrSell.Sell : BuyOrSell.Buy
|
|
|
+ formData.GoodsID = goodsid
|
|
|
+ formData.ListingSelectType = EListingSelectType.LISTINGSELECTTYPE_DELISTING
|
|
|
+ formData.DelistingType = EDelistingType.DELISTINGTYPE_SELECTED
|
|
|
+ formData.BuildType = buildType
|
|
|
+ formData.TimevalidType = EValidType.VALIDTYPE_DR
|
|
|
+ formData.OperateType = EOrderOperateType.ORDEROPERATETYPE_NORMAL
|
|
|
+
|
|
|
+ formSubmit().then(() => {
|
|
|
+ ElMessage.success('提交成功')
|
|
|
+ onCancel(true)
|
|
|
+ }).catch((err) => {
|
|
|
+ ElMessage.error('提交失败:' + err)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+</script>
|