|
|
@@ -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" :disabled="orderPriceType === 3" v-model="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,28 +116,8 @@ const sellQty = computed(() => getOrderQty(BuyOrSell.Sell, selectedGoodsId.value
|
|
|
// 价格类型
|
|
|
const orderPriceType = computed(() => settingStore.getSettingValue('orderPriceType'))
|
|
|
|
|
|
-// 订单价格
|
|
|
-const orderPrice = computed({
|
|
|
- get: () => {
|
|
|
- const { last, bid, ask, presettle = 0 } = selectedGoods.value ?? {}
|
|
|
- // 1=现价,2=对手价,3=实时价
|
|
|
- switch (orderPriceType.value) {
|
|
|
- case 2:
|
|
|
- if (formData.BuyOrSell === BuyOrSell.Buy) {
|
|
|
- return ask || last || presettle
|
|
|
- } else {
|
|
|
- return bid || last || presettle
|
|
|
- }
|
|
|
- case 3:
|
|
|
- return last || presettle
|
|
|
- default:
|
|
|
- return formData.OrderPrice
|
|
|
- }
|
|
|
- },
|
|
|
- set: (val) => {
|
|
|
- formData.OrderPrice = val
|
|
|
- }
|
|
|
-})
|
|
|
+// 是否禁用价格输入
|
|
|
+const isDisabled = computed(() => [3, 4].includes(orderPriceType.value))
|
|
|
|
|
|
const formRules: FormRules = {
|
|
|
OrderPrice: [{
|
|
|
@@ -185,7 +165,7 @@ const onRadioChange = (value: number) => {
|
|
|
|
|
|
const onPriceClick = (buyorsell: BuyOrSell, value: number) => {
|
|
|
formData.BuyOrSell = buyorsell === BuyOrSell.Sell ? BuyOrSell.Buy : BuyOrSell.Sell
|
|
|
- if (orderPriceType.value === 3) {
|
|
|
+ if (isDisabled.value) {
|
|
|
qtyInputFocus()
|
|
|
} else {
|
|
|
formData.OrderPrice = value
|
|
|
@@ -218,7 +198,7 @@ const onSubmit = (buildType: number) => {
|
|
|
ElMessage.error('挂牌失败:' + err)
|
|
|
}).finally(() => {
|
|
|
const focusType = settingStore.getSettingValue('orderFocusType')
|
|
|
- if (focusType === 2 || orderPriceType.value === 3) {
|
|
|
+ if (focusType === 2 || isDisabled.value) {
|
|
|
qtyInputFocus()
|
|
|
} else {
|
|
|
priceInputFocus()
|
|
|
@@ -229,14 +209,40 @@ const onSubmit = (buildType: number) => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-const goodsChange = () => {
|
|
|
- const { last = 0, presettle = 0 } = selectedGoods.value ?? {}
|
|
|
- formData.OrderPrice = last || presettle
|
|
|
- formData.OrderQty = qtyStep.value
|
|
|
+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, () => goodsChange())
|
|
|
-onMounted(() => goodsChange())
|
|
|
+watch([() => selectedGoodsId, () => orderPriceType.value], () => {
|
|
|
+ formData.OrderPrice = getOrderPrice()
|
|
|
+})
|
|
|
+
|
|
|
+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
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<style lang="less">
|