|
|
@@ -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="selectedGoodsId" filterable>
|
|
|
+ <el-select placeholder="请选择" v-model="selectedGoodsId" filterable @change="onGoodsChange">
|
|
|
<el-option :label="item.goodsname" :value="item.goodsid" v-for="(item, index) in marketGoodsList"
|
|
|
:key="index" />
|
|
|
</el-select>
|
|
|
@@ -22,7 +22,7 @@
|
|
|
<el-form-item prop="OrderPrice" label="价格">
|
|
|
<div class="el-form-item--col">
|
|
|
<el-input-number ref="priceRef" placeholder="请输入" :min="0" :step="priceStep"
|
|
|
- :precision="selectedGoods?.decimalplace" v-model="formData.OrderPrice"
|
|
|
+ :precision="selectedGoods?.decimalplace" :disabled="isDisabled" v-model="formData.OrderPrice"
|
|
|
@keyup.enter="qtyInputFocus" />
|
|
|
<div v-if="selectedGoods">
|
|
|
<div class="row-price g-price-up">
|
|
|
@@ -116,6 +116,12 @@ const priceStep = computed(() => {
|
|
|
return 1
|
|
|
})
|
|
|
|
|
|
+// 价格类型
|
|
|
+const orderPriceType = computed(() => settingStore.getSettingValue('orderPriceType'))
|
|
|
+
|
|
|
+// 是否禁用价格输入
|
|
|
+const isDisabled = computed(() => [3, 4].includes(orderPriceType.value))
|
|
|
+
|
|
|
const formRules: FormRules = {
|
|
|
OrderPrice: [{
|
|
|
required: true,
|
|
|
@@ -134,7 +140,7 @@ const formRules: FormRules = {
|
|
|
if (value) {
|
|
|
callback()
|
|
|
} else {
|
|
|
- callback(new Error('请输入挂牌数量'))
|
|
|
+ callback(new Error('请输入数量'))
|
|
|
}
|
|
|
}
|
|
|
}],
|
|
|
@@ -162,8 +168,12 @@ const onRadioChange = (value: number) => {
|
|
|
|
|
|
const onPriceClick = (buyorsell: BuyOrSell, value: number) => {
|
|
|
formData.BuyOrSell = buyorsell === BuyOrSell.Sell ? BuyOrSell.Buy : BuyOrSell.Sell
|
|
|
- formData.OrderPrice = value
|
|
|
- priceInputFocus()
|
|
|
+ if (isDisabled.value) {
|
|
|
+ qtyInputFocus()
|
|
|
+ } else {
|
|
|
+ formData.OrderPrice = value
|
|
|
+ priceInputFocus()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 提交挂牌
|
|
|
@@ -192,10 +202,10 @@ const onSubmit = () => {
|
|
|
ElMessage.error('挂牌失败:' + err)
|
|
|
}).finally(() => {
|
|
|
const focusType = settingStore.getSettingValue('orderFocusType')
|
|
|
- if (focusType === 1) {
|
|
|
- priceInputFocus()
|
|
|
- } else {
|
|
|
+ if (focusType === 2 || isDisabled.value) {
|
|
|
qtyInputFocus()
|
|
|
+ } else {
|
|
|
+ priceInputFocus()
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
@@ -203,11 +213,7 @@ const onSubmit = () => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-const goodsChange = () => {
|
|
|
- const { last = 0, presettle = 0 } = selectedGoods.value ?? {}
|
|
|
- formData.OrderPrice = last || presettle
|
|
|
- formData.OrderQty = qtyStep.value
|
|
|
-
|
|
|
+const onGoodsChange = () => {
|
|
|
if (selectedGoodsId.value) {
|
|
|
getMineTradePositionExs({
|
|
|
goodsid: selectedGoodsId.value
|
|
|
@@ -215,9 +221,41 @@ const goodsChange = () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-watch(selectedGoodsId, () => goodsChange())
|
|
|
+const getOrderPrice = () => {
|
|
|
+ const { last, bid, ask, presettle = 0 } = selectedGoods.value ?? {}
|
|
|
+ const price = last || presettle
|
|
|
+ // 1=现价,2=对手价,3=实时价,4=实时对手价
|
|
|
+ switch (orderPriceType.value) {
|
|
|
+ case 1:
|
|
|
+ case 3:
|
|
|
+ return price
|
|
|
+ case 2:
|
|
|
+ case 4:
|
|
|
+ if (formData.BuyOrSell === BuyOrSell.Buy) {
|
|
|
+ return ask || price
|
|
|
+ } else {
|
|
|
+ return bid || price
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+watch([selectedGoodsId, orderPriceType], () => {
|
|
|
+ formData.OrderPrice = getOrderPrice()
|
|
|
+})
|
|
|
|
|
|
-onMounted(() => goodsChange())
|
|
|
+watch([() => formData.BuyOrSell, () => selectedGoods.value?.last, () => selectedGoods.value?.bid, () => selectedGoods.value?.ask], () => {
|
|
|
+ if (isDisabled.value) {
|
|
|
+ formData.OrderPrice = getOrderPrice()
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ formData.OrderPrice = getOrderPrice()
|
|
|
+ formData.OrderQty = qtyStep.value
|
|
|
+ onGoodsChange()
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<style lang="less">
|