|
@@ -5,7 +5,8 @@
|
|
|
</div>
|
|
</div>
|
|
|
<div class="app-listing__form">
|
|
<div class="app-listing__form">
|
|
|
<h4 class="block-title">订单挂牌</h4>
|
|
<h4 class="block-title">订单挂牌</h4>
|
|
|
- <el-form ref="formRef" size="small" label-width="50px" label-position="left" :model="formData">
|
|
|
|
|
|
|
+ <el-form ref="formRef" size="small" label-width="50px" label-position="left" :model="formData"
|
|
|
|
|
+ :rules="formRules">
|
|
|
<el-form-item prop="GoodsID" label="商品">
|
|
<el-form-item prop="GoodsID" label="商品">
|
|
|
<el-select placeholder="请选择" v-model="goodsStore.goodsId">
|
|
<el-select placeholder="请选择" v-model="goodsStore.goodsId">
|
|
|
<el-option :label="item.goodsname" :value="item.goodsid"
|
|
<el-option :label="item.goodsname" :value="item.goodsid"
|
|
@@ -20,25 +21,31 @@
|
|
|
</el-radio-group>
|
|
</el-radio-group>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
<el-form-item prop="OrderPrice" label="价格">
|
|
<el-form-item prop="OrderPrice" label="价格">
|
|
|
- <el-input-number placeholder="请输入" :step="priceStep" v-model="formData.OrderPrice" />
|
|
|
|
|
|
|
+ <el-input-number placeholder="请输入" :min="0" :step="priceStep" :precision="quote?.decimalplace"
|
|
|
|
|
+ v-model="formData.OrderPrice" />
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
<el-form-item prop="OrderQty" label="数量">
|
|
<el-form-item prop="OrderQty" label="数量">
|
|
|
- <el-input-number placeholder="请输入" :step="qtyStep" v-model="orderQty" />
|
|
|
|
|
|
|
+ <el-input-number placeholder="请输入" :min="agreeunit" :step="qtyStep" v-model="orderQty" />
|
|
|
|
|
+ <el-radio-group v-model="qtyStep" @change="onRadioChange">
|
|
|
|
|
+ <el-radio-button v-for="(value, index) in qtyStepList" :key="index" :label="value" />
|
|
|
|
|
+ </el-radio-group>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
</el-form>
|
|
</el-form>
|
|
|
<div class="block-btnbar">
|
|
<div class="block-btnbar">
|
|
|
<template v-if="formData.BuyOrSell === BuyOrSell.Buy">
|
|
<template v-if="formData.BuyOrSell === BuyOrSell.Buy">
|
|
|
- <el-button type="primary" size="small" @click="onSubmit(EBuildType.BUILDTYPE_OPEN)">订立买入</el-button>
|
|
|
|
|
- <el-button type="primary" size="small" :disabled="(sellQty === 0) || (orderQty > sellQty)"
|
|
|
|
|
- @click="onSubmit(EBuildType.BUILDTYPE_CLOSE)">
|
|
|
|
|
|
|
+ <el-button type="primary" size="small" :loading="loading"
|
|
|
|
|
+ @click="onSubmit(EBuildType.BUILDTYPE_OPEN)">订立买入</el-button>
|
|
|
|
|
+ <el-button type="primary" size="small" :loading="loading"
|
|
|
|
|
+ :disabled="(sellQty === 0) || (orderQty > sellQty)" @click="onSubmit(EBuildType.BUILDTYPE_CLOSE)">
|
|
|
<span>转让买入</span>
|
|
<span>转让买入</span>
|
|
|
<span v-if="sellQty">(≤{{ sellQty }})</span>
|
|
<span v-if="sellQty">(≤{{ sellQty }})</span>
|
|
|
</el-button>
|
|
</el-button>
|
|
|
</template>
|
|
</template>
|
|
|
<template v-if="formData.BuyOrSell === BuyOrSell.Sell">
|
|
<template v-if="formData.BuyOrSell === BuyOrSell.Sell">
|
|
|
- <el-button type="primary" size="small" @click="onSubmit(EBuildType.BUILDTYPE_OPEN)">订立卖出</el-button>
|
|
|
|
|
- <el-button type="primary" size="small" :disabled="(buyQty === 0) || (orderQty > buyQty)"
|
|
|
|
|
- @click="onSubmit(EBuildType.BUILDTYPE_CLOSE)">
|
|
|
|
|
|
|
+ <el-button type="primary" size="small" :loading="loading"
|
|
|
|
|
+ @click="onSubmit(EBuildType.BUILDTYPE_OPEN)">订立卖出</el-button>
|
|
|
|
|
+ <el-button type="primary" size="small" :loading="loading"
|
|
|
|
|
+ :disabled="(buyQty === 0) || (orderQty > buyQty)" @click="onSubmit(EBuildType.BUILDTYPE_CLOSE)">
|
|
|
<span>转让卖出</span>
|
|
<span>转让卖出</span>
|
|
|
<span v-if="buyQty">(≤{{ buyQty }})</span>
|
|
<span v-if="buyQty">(≤{{ buyQty }})</span>
|
|
|
</el-button>
|
|
</el-button>
|
|
@@ -50,7 +57,7 @@
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
import { shallowRef, computed, watch } from 'vue'
|
|
import { shallowRef, computed, watch } from 'vue'
|
|
|
-import { ElMessage } from 'element-plus'
|
|
|
|
|
|
|
+import { ElMessage, ElMessageBox, FormInstance, FormRules } from 'element-plus'
|
|
|
import { EPriceMode, EListingSelectType, EDelistingType, EBuildType, EValidType, EOrderOperateType } from '@/constants/client'
|
|
import { EPriceMode, EListingSelectType, EDelistingType, EBuildType, EValidType, EOrderOperateType } from '@/constants/client'
|
|
|
import { BuyOrSell, getBuyOrSellList } from '@/constants/order'
|
|
import { BuyOrSell, getBuyOrSellList } from '@/constants/order'
|
|
|
import { useRequest } from '@/hooks/request'
|
|
import { useRequest } from '@/hooks/request'
|
|
@@ -62,7 +69,8 @@ import Forex from '@pc/components/modules/quote/forex/index.vue'
|
|
|
|
|
|
|
|
const goodsStore = useGoodsStore()
|
|
const goodsStore = useGoodsStore()
|
|
|
const futuresStore = useFuturesStore()
|
|
const futuresStore = useFuturesStore()
|
|
|
-const { formData, formSubmit } = useOrder()
|
|
|
|
|
|
|
+const { formData, loading, formSubmit } = useOrder()
|
|
|
|
|
+const formRef = shallowRef<FormInstance>()
|
|
|
const orderQty = shallowRef(1) // 数量
|
|
const orderQty = shallowRef(1) // 数量
|
|
|
const qtyStep = shallowRef(1) // 数量步长
|
|
const qtyStep = shallowRef(1) // 数量步长
|
|
|
|
|
|
|
@@ -73,7 +81,7 @@ const { dataList: positionList, run: getTradePosition } = useRequest(queryTradeP
|
|
|
},
|
|
},
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-// 商品行情
|
|
|
|
|
|
|
+// 商品盘面
|
|
|
const quote = computed(() => futuresStore.getQuoteInfo(goodsStore.goodsCode).value)
|
|
const quote = computed(() => futuresStore.getQuoteInfo(goodsStore.goodsCode).value)
|
|
|
|
|
|
|
|
// 合约乘数
|
|
// 合约乘数
|
|
@@ -92,11 +100,8 @@ const priceStep = computed(() => {
|
|
|
const qtyStepList = computed(() => {
|
|
const qtyStepList = computed(() => {
|
|
|
return [
|
|
return [
|
|
|
agreeunit.value * 1,
|
|
agreeunit.value * 1,
|
|
|
- agreeunit.value * 5,
|
|
|
|
|
agreeunit.value * 10,
|
|
agreeunit.value * 10,
|
|
|
- agreeunit.value * 20,
|
|
|
|
|
- agreeunit.value * 30,
|
|
|
|
|
- agreeunit.value * 50,
|
|
|
|
|
|
|
+ agreeunit.value * 100,
|
|
|
]
|
|
]
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -118,25 +123,55 @@ const sellQty = computed(() => {
|
|
|
return 0
|
|
return 0
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+const formRules: FormRules = {
|
|
|
|
|
+ OrderPrice: [{ required: true, message: '请输入价格' }],
|
|
|
|
|
+ OrderQty: [{
|
|
|
|
|
+ required: true,
|
|
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
|
|
+ if (orderQty.value) {
|
|
|
|
|
+ if (orderQty.value % agreeunit.value === 0) {
|
|
|
|
|
+ callback()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ callback(new Error('只能输入合约乘数的整数倍'))
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ callback(new Error('请输入摘牌数量'))
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }],
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const onRadioChange = (value: number) => {
|
|
|
|
|
+ orderQty.value = value
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// 提交挂牌
|
|
// 提交挂牌
|
|
|
const onSubmit = (buildType: number) => {
|
|
const onSubmit = (buildType: number) => {
|
|
|
- const { marketid = 0, goodsid = 0 } = quote.value ?? {}
|
|
|
|
|
- /// 获取对应的市场ID
|
|
|
|
|
- formData.MarketID = marketid
|
|
|
|
|
- formData.PriceMode = EPriceMode.PRICEMODE_LIMIT
|
|
|
|
|
- formData.GoodsID = goodsid
|
|
|
|
|
- formData.ListingSelectType = EListingSelectType.LISTINGSELECTTYPE_DELISTINGTHENLISTING
|
|
|
|
|
- formData.DelistingType = EDelistingType.DELISTINGTYPE_PRICE
|
|
|
|
|
- formData.BuildType = EBuildType.BUILDTYPE_OPEN
|
|
|
|
|
- formData.TimevalidType = EValidType.VALIDTYPE_DR
|
|
|
|
|
- formData.OperateType = EOrderOperateType.ORDEROPERATETYPE_NORMAL
|
|
|
|
|
- formData.BuildType = buildType
|
|
|
|
|
- formData.OrderQty = orderQty.value / agreeunit.value // 数量÷合约乘数
|
|
|
|
|
-
|
|
|
|
|
- formSubmit().then(() => {
|
|
|
|
|
- ElMessage.success('提交成功')
|
|
|
|
|
- }).catch((err) => {
|
|
|
|
|
- ElMessage.error('提交失败:' + err)
|
|
|
|
|
|
|
+ formRef.value?.validate((valid) => {
|
|
|
|
|
+ if (valid) {
|
|
|
|
|
+ ElMessageBox.confirm(
|
|
|
|
|
+ '是否立即挂牌?',
|
|
|
|
|
+ '提示'
|
|
|
|
|
+ ).then(() => {
|
|
|
|
|
+ const { marketid = 0, goodsid = 0 } = quote.value ?? {}
|
|
|
|
|
+ /// 获取对应的市场ID
|
|
|
|
|
+ formData.MarketID = marketid
|
|
|
|
|
+ formData.PriceMode = EPriceMode.PRICEMODE_LIMIT
|
|
|
|
|
+ formData.GoodsID = goodsid
|
|
|
|
|
+ formData.ListingSelectType = EListingSelectType.LISTINGSELECTTYPE_DELISTINGTHENLISTING
|
|
|
|
|
+ formData.DelistingType = EDelistingType.DELISTINGTYPE_PRICE
|
|
|
|
|
+ formData.TimevalidType = EValidType.VALIDTYPE_DR
|
|
|
|
|
+ formData.OperateType = EOrderOperateType.ORDEROPERATETYPE_NORMAL
|
|
|
|
|
+ formData.BuildType = buildType
|
|
|
|
|
+ formData.OrderQty = orderQty.value / agreeunit.value // 数量÷合约乘数
|
|
|
|
|
+
|
|
|
|
|
+ formSubmit().then(() => {
|
|
|
|
|
+ ElMessage.success('提交成功')
|
|
|
|
|
+ }).catch((err) => {
|
|
|
|
|
+ ElMessage.error('提交失败:' + err)
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|