Handy_Cao 1 년 전
부모
커밋
28babdc704
1개의 변경된 파일60개의 추가작업 그리고 8개의 파일을 삭제
  1. 60 8
      src/packages/pc/views/footer/pricing/position/components/transfer/index.vue

+ 60 - 8
src/packages/pc/views/footer/pricing/position/components/transfer/index.vue

@@ -28,6 +28,20 @@
                     {{ formatDecimal(position.closepl, position.decimalplace) }}
                 </span>
             </el-form-item>
+            <el-form-item prop="PriceMode" :label="t('quote.pricing.pricemode')">
+                <el-radio-group v-model="formData.PriceMode">
+                    <el-radio v-for="(item, index) in getPricemode2List()" :key="index" :label="item.value">
+                        {{ item.label }}
+                    </el-radio>
+                </el-radio-group>
+            </el-form-item>
+            <el-form-item prop="MarketMaxSub" :label="t('quote.pricing.marketmaxsub')" v-if="formData.PriceMode === PriceMode.Market">
+                <el-input-number ref="priceRef" :placeholder="t('common.pleaseenter')" :min="0" :max="999" v-model="formData.MarketMaxSub" />
+            </el-form-item>
+            <el-form-item prop="OrderPrice" :label="t('position.transfer.transferprice')" v-if="formData.PriceMode === PriceMode.Limit">
+                <el-input-number :placeholder="t('position.transfer.tips3')" v-model="formData.OrderPrice" :step="decimalvalue"
+                    :precision="decimalplace" />
+            </el-form-item>
             <el-form-item prop="OrderQty" :label="t('position.transfer.transferqty')">
                 <div class="g-qty-group">
                     <el-input-number :placeholder="t('position.transfer.tips4')" v-model="formData.OrderQty" :precision="0"
@@ -40,10 +54,6 @@
                     </el-radio-group>
                 </div>
             </el-form-item>
-            <el-form-item prop="OrderPrice" :label="t('position.transfer.transferprice')">
-                <el-input-number :placeholder="t('position.transfer.tips3')" v-model="formData.OrderPrice" :step="decimalvalue"
-                    :precision="decimalplace" />
-            </el-form-item>
         </el-form> 
         <template #footer>
             <el-button type="info" @click="onCancel(false)">{{ t('operation.cancel') }}</el-button>
@@ -53,12 +63,12 @@
 </template>
 
 <script lang="ts" setup>
-import { ref, PropType, onMounted } from 'vue'
+import { ref, PropType, onMounted, computed } from 'vue'
 import { ElMessage, FormInstance, FormRules } from 'element-plus'
 import { useOrder } from '@/business/trade'
 import { formatDecimal, parsePercent } from '@/filters'
-import { getBuyOrSellName, BuyOrSell } from '@/constants/order'
-import { useFuturesStore, i18n } from '@/stores'
+import { getBuyOrSellName, BuyOrSell, getPricemode2List, PriceMode } from '@/constants/order'
+import { useFuturesStore, i18n, useSettingStore } from '@/stores'
 import { EBuildType, EDelistingType, EListingSelectType, EOrderOperateType, EPriceMode, EValidType } from '@/constants/client'
 import AppDrawer from '@pc/components/base/drawer/index.vue'
 
@@ -73,6 +83,10 @@ const props = defineProps({
 })
 
 const futuresStore = useFuturesStore()
+const settingStore = useSettingStore()
+
+// 价格类型
+const orderPriceType = computed(() => settingStore.getSettingValue('orderPriceType'))
 const quote = futuresStore.getGoodsQuote(props.position.goodscode)
 const { decimalplace = 0 } = quote.value ?? {}
 const quoteminunit = quote.value?.quoteminunit ?? 1
@@ -92,6 +106,16 @@ const formRules: FormRules = {
             return !!formData.OrderPrice
         }
     }],
+    MarketMaxSub: [{
+        type: 'number',
+        validator: (rule, value, callback) => {
+            if (value) {
+                callback()
+            } else {
+                callback(new Error(t('quote.pricing.tips3')))
+            }
+        }
+    }],
     OrderQty: [{
         message: t('position.transfer.tips4'),
         validator: () => {
@@ -105,6 +129,31 @@ const onCancel = (isRefresh = false) => {
     refresh.value = isRefresh
 }
 
+const getOrderPrice = () => {
+    const { last, bid, ask, presettle = 0 } = quote.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
+    }
+}
+
+const marketPrice = computed(() => {
+    const { ask = 0, bid = 0 } = quote.value ?? {}
+    return formData.BuyOrSell === BuyOrSell.Buy ? ask : bid
+})
+
 const onCloseSumit = () => {
     formRef.value?.validate((valid) => {
         if (valid) {
@@ -112,7 +161,7 @@ const onCloseSumit = () => {
             /// 市场ID
             formData.Header = { GoodsID: goodsid }
             formData.MarketID = marketid
-            formData.PriceMode = EPriceMode.PRICEMODE_LIMIT
+            if (formData.PriceMode === PriceMode.Market) { formData.OrderPrice = marketPrice.value }
             formData.BuyOrSell = buyorsell === BuyOrSell.Buy ? BuyOrSell.Sell : BuyOrSell.Buy
             formData.GoodsID = goodsid
             formData.ListingSelectType = EListingSelectType.LISTINGSELECTTYPE_DELISTINGTHENLISTING
@@ -147,6 +196,9 @@ onMounted(() => {
         default:
             formData.OrderPrice = last || presettle
     }
+    formData.OrderPrice = getOrderPrice()
     formData.OrderQty = props.position.enableqty
+    formData.PriceMode = PriceMode.Market
+    formData.MarketMaxSub = 100.0
 })
 </script>