|
|
@@ -7,7 +7,7 @@
|
|
|
<h4 class="header-title">订单挂牌</h4>
|
|
|
<el-form ref="formRef" class="el-form--vertical" label-width="60px" :model="formData" :rules="formRules">
|
|
|
<el-form-item prop="GoodsID" label="商品">
|
|
|
- <el-select placeholder="请选择" v-model="goodsStore.goodsId">
|
|
|
+ <el-select placeholder="请选择" v-model="goodsStore.goodsId" @change="getTradePosition">
|
|
|
<el-option :label="item.goodsname" :value="item.goodsid"
|
|
|
v-for="(item, index) in goodsStore.quoteGoodsList" :key="index" />
|
|
|
</el-select>
|
|
|
@@ -24,32 +24,31 @@
|
|
|
v-model="formData.OrderPrice" />
|
|
|
</el-form-item>
|
|
|
<el-form-item prop="OrderQty" label="数量">
|
|
|
- <div class="el-form-item--col">
|
|
|
- <div class="g-qty-group">
|
|
|
- <el-input-number placeholder="请输入" :min="agreeunit" :step="qtyStep" v-model="orderQty" />
|
|
|
- <el-radio-group size="small" v-model="qtyStep" @change="onRadioChange"
|
|
|
- v-if="qtyStepList.length">
|
|
|
- <el-radio v-for="(value, index) in qtyStepList" :key="index" :label="value" border />
|
|
|
- </el-radio-group>
|
|
|
- </div>
|
|
|
- <span>{{ getGoodsUnitName(quote?.goodunitid) }}</span>
|
|
|
+ <div class="g-qty-group">
|
|
|
+ <el-input-number placeholder="请输入" :min="0" :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>
|
|
|
<div class="footer-btnbar">
|
|
|
<template v-if="formData.BuyOrSell === BuyOrSell.Buy">
|
|
|
- <el-button type="primary" :loading="loading" :disabled="!goodsStore.goodsId"
|
|
|
+ <el-button type="primary" :loading="loading" :disabled="!goodsStore.goodsId || !formData.OrderQty"
|
|
|
@click="onSubmit(EBuildType.BUILDTYPE_OPEN)">订立买入</el-button>
|
|
|
- <el-button type="primary" :loading="loading" :disabled="(sellQty === 0) || (orderQty > sellQty)"
|
|
|
+ <el-button type="primary" :loading="loading"
|
|
|
+ :disabled="!formData.OrderQty || !sellQty || (formData.OrderQty > sellQty)"
|
|
|
@click="onSubmit(EBuildType.BUILDTYPE_CLOSE)">
|
|
|
<span>转让买入</span>
|
|
|
<span v-if="sellQty">(≤{{ sellQty }})</span>
|
|
|
</el-button>
|
|
|
</template>
|
|
|
<template v-if="formData.BuyOrSell === BuyOrSell.Sell">
|
|
|
- <el-button type="primary" :loading="loading" :disabled="!goodsStore.goodsId"
|
|
|
+ <el-button type="primary" :loading="loading" :disabled="!goodsStore.goodsId || !formData.OrderQty"
|
|
|
@click="onSubmit(EBuildType.BUILDTYPE_OPEN)">订立卖出</el-button>
|
|
|
- <el-button type="primary" :loading="loading" :disabled="(buyQty === 0) || (orderQty > buyQty)"
|
|
|
+ <el-button type="primary" :loading="loading"
|
|
|
+ :disabled="!formData.OrderQty || !buyQty || (formData.OrderQty > buyQty)"
|
|
|
@click="onSubmit(EBuildType.BUILDTYPE_CLOSE)">
|
|
|
<span>转让卖出</span>
|
|
|
<span v-if="buyQty">(≤{{ buyQty }})</span>
|
|
|
@@ -65,7 +64,6 @@ import { shallowRef, computed, watch } from 'vue'
|
|
|
import { ElMessage, ElMessageBox, FormInstance, FormRules } from 'element-plus'
|
|
|
import { EPriceMode, EListingSelectType, EDelistingType, EBuildType, EValidType, EOrderOperateType } from '@/constants/client'
|
|
|
import { BuyOrSell, getBuyOrSellList } from '@/constants/order'
|
|
|
-import { getGoodsUnitName } from '@/constants/unit'
|
|
|
import { useRequest } from '@/hooks/request'
|
|
|
import { queryTradePosition } from '@/services/api/order'
|
|
|
import { useOrder } from '@/business/trade'
|
|
|
@@ -77,8 +75,8 @@ const goodsStore = useGoodsStore()
|
|
|
const futuresStore = useFuturesStore()
|
|
|
const { formData, loading, formSubmit } = useOrder()
|
|
|
const formRef = shallowRef<FormInstance>()
|
|
|
-const orderQty = shallowRef(1) // 数量
|
|
|
-const qtyStep = shallowRef(1) // 数量步长
|
|
|
+const qtyStepList = [1, 10, 100] // 数量步长列表
|
|
|
+const qtyStep = shallowRef(qtyStepList[0]) // 数量步长
|
|
|
|
|
|
// 持仓列表
|
|
|
const { dataList: positionList, run: getTradePosition } = useRequest(queryTradePosition, {
|
|
|
@@ -90,9 +88,6 @@ const { dataList: positionList, run: getTradePosition } = useRequest(queryTradeP
|
|
|
// 商品盘面
|
|
|
const quote = computed(() => futuresStore.getQuoteInfo(goodsStore.goodsCode).value)
|
|
|
|
|
|
-// 合约乘数
|
|
|
-const agreeunit = computed(() => quote.value?.agreeunit ?? 0)
|
|
|
-
|
|
|
// 价格步长
|
|
|
const priceStep = computed(() => {
|
|
|
const { quoteminunit = 0, decimalplace = 0 } = quote.value ?? {}
|
|
|
@@ -102,34 +97,16 @@ const priceStep = computed(() => {
|
|
|
return 1
|
|
|
})
|
|
|
|
|
|
-// 数量步长列表
|
|
|
-const qtyStepList = computed(() => {
|
|
|
- if (agreeunit.value) {
|
|
|
- return [
|
|
|
- agreeunit.value * 1,
|
|
|
- agreeunit.value * 10,
|
|
|
- agreeunit.value * 100,
|
|
|
- ]
|
|
|
- }
|
|
|
- return []
|
|
|
-})
|
|
|
-
|
|
|
// 买方向持仓数量
|
|
|
const buyQty = computed(() => {
|
|
|
const item = positionList.value.find((e) => e.goodscode === goodsStore.goodsCode && e.buyorsell === BuyOrSell.Buy)
|
|
|
- if (item) {
|
|
|
- return item.enableqty * agreeunit.value
|
|
|
- }
|
|
|
- return 0
|
|
|
+ return item?.enableqty ?? 0
|
|
|
})
|
|
|
|
|
|
// 卖方向持仓数量
|
|
|
const sellQty = computed(() => {
|
|
|
const item = positionList.value.find((e) => e.goodscode === goodsStore.goodsCode && e.buyorsell === BuyOrSell.Sell)
|
|
|
- if (item) {
|
|
|
- return item.enableqty * agreeunit.value
|
|
|
- }
|
|
|
- return 0
|
|
|
+ return item?.enableqty ?? 0
|
|
|
})
|
|
|
|
|
|
const formRules: FormRules = {
|
|
|
@@ -147,21 +124,17 @@ const formRules: FormRules = {
|
|
|
OrderQty: [{
|
|
|
required: true,
|
|
|
validator: (rule, value, callback) => {
|
|
|
- if (orderQty.value) {
|
|
|
- if (orderQty.value % agreeunit.value === 0) {
|
|
|
- callback()
|
|
|
- } else {
|
|
|
- callback(new Error('只能输入合约乘数的整数倍'))
|
|
|
- }
|
|
|
+ if (value) {
|
|
|
+ callback()
|
|
|
} else {
|
|
|
- callback(new Error('请输入摘牌数量'))
|
|
|
+ callback(new Error('请输入挂牌数量'))
|
|
|
}
|
|
|
}
|
|
|
}],
|
|
|
}
|
|
|
|
|
|
const onRadioChange = (value: number) => {
|
|
|
- orderQty.value = value
|
|
|
+ formData.OrderQty = value
|
|
|
}
|
|
|
|
|
|
const onBuyClick = (price: number) => {
|
|
|
@@ -192,12 +165,11 @@ const onSubmit = (buildType: number) => {
|
|
|
formData.TimevalidType = EValidType.VALIDTYPE_DR
|
|
|
formData.OperateType = EOrderOperateType.ORDEROPERATETYPE_NORMAL
|
|
|
formData.BuildType = buildType
|
|
|
- formData.OrderQty = orderQty.value / agreeunit.value // 数量÷合约乘数
|
|
|
|
|
|
formSubmit().then(() => {
|
|
|
- ElMessage.success('提交成功')
|
|
|
+ ElMessage.success('挂牌成功')
|
|
|
}).catch((err) => {
|
|
|
- ElMessage.error('提交失败:' + err)
|
|
|
+ ElMessage.error('挂牌失败:' + err)
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
@@ -205,10 +177,9 @@ const onSubmit = (buildType: number) => {
|
|
|
}
|
|
|
|
|
|
watch(() => goodsStore.goodsId, () => {
|
|
|
- const { last = 0, agreeunit = 0, presettle = 0 } = quote.value ?? {}
|
|
|
+ const { last = 0, presettle = 0 } = quote.value ?? {}
|
|
|
formData.OrderPrice = last || presettle
|
|
|
- orderQty.value = agreeunit
|
|
|
- qtyStep.value = qtyStepList.value[0]
|
|
|
+ formData.OrderQty = qtyStep.value
|
|
|
}, {
|
|
|
immediate: true
|
|
|
})
|