huangbin 4 anos atrás
pai
commit
c535db82d3

+ 16 - 4
src/views/order/spot_warran/components/spot_warrant_spot_details/components/listing/index.vue

@@ -90,13 +90,16 @@
           <a-row :gutter="24"
                  v-if="formState.WRPriceType === 2">
             <a-col :span="24">
-              <a-form-item label="行情商品">
+              <a-form-item label="行情商品"
+                           name="goodsid">
                 <!-- <a-select class="inlineFormSelect"
                           style="width: 135px"
                           placeholder="请择交易所">
                 </a-select> -->
                 <a-select class="inlineFormSelect ml5"
+                          @change="groupsChange"
                           style="width: 135px"
+                          v-model:value="formState.goodsgroupid"
                           placeholder="请选择商品">
                   <a-select-option v-for="item in goodsGroup"
                                    :value="item.goodsgroupid"
@@ -106,7 +109,14 @@
                 </a-select>
                 <a-select class="inlineFormSelect ml5"
                           style="width: 135px"
-                          placeholder="请选择合约"></a-select>
+                          v-model:value="formState.goodsid"
+                          placeholder="请选择合约">
+                  <a-select-option v-for="item in goodsList"
+                                   :value="item.goodsid"
+                                   :key="item.goodsid">
+                    {{item.goodsname}}
+                  </a-select-option>
+                </a-select>
               </a-form-item>
             </a-col>
           </a-row>
@@ -140,7 +150,7 @@ import { v4 as uuidv4 } from 'uuid';
 import moment from 'moment';
 import { ModalEnum } from '@/common/constants/modalNameEnum';
 import { _closeModal } from '@/common/setup/modal/modal';
-import { handlePasswordForm } from './setup';
+import { handleGoods, handlePasswordForm } from './setup';
 import { validateAction } from '@/common/setup/form';
 import { ListingForm } from './interface';
 import { getMarketRunByTradeMode } from '@/services/bus/market';
@@ -164,7 +174,7 @@ export default defineComponent({
         const { rules, formState, formRef } = handlePasswordForm(props.selectedRow);
         const data = props.selectedRow;
         const loading = ref<boolean>(false);
-        const goodsGroup = getGoodsGroupsByTradeMode(TradeMode.quote99);
+        const { goodsGroup, goodsList, groupsChange } = handleGoods();
         function submit() {
             const marketInfo = getMarketRunByTradeMode(17);
             if (marketInfo) {
@@ -227,6 +237,8 @@ export default defineComponent({
             formState,
             formRef,
             goodsGroup,
+            goodsList,
+            groupsChange,
         };
     },
 });

+ 2 - 0
src/views/order/spot_warran/components/spot_warrant_spot_details/components/listing/interface.ts

@@ -3,4 +3,6 @@ export interface ListingForm {
     FixedPrice: number, // 固定价格
     OrderQty: number,
     PriceMove: number,// 升贴水(浮动价时填写)
+    goodsgroupid: number | undefined,
+    goodsid: number | undefined,
 }

+ 27 - 1
src/views/order/spot_warran/components/spot_warrant_spot_details/components/listing/setup.ts

@@ -1,4 +1,9 @@
+import { TradeMode } from '@/common/constants/enumCommon';
+import { validateCommon } from '@/common/setup/validate';
+import { getGoodsGroupsByTradeMode, getGoodsList } from '@/services/bus/goods';
+import { Goods } from "@/services/go/ermcp/goodsInfo/interface";
 import { WrHoldLB } from "@/services/go/wrtrade/interface";
+import { RuleObject } from 'ant-design-vue/lib/form/interface';
 import { reactive, ref, UnwrapRef } from "vue";
 import { ListingForm } from "./interface";
 
@@ -9,12 +14,33 @@ export function handlePasswordForm(data: WrHoldLB) {
         FixedPrice: 0,
         OrderQty: 0,
         PriceMove: 1,
+        goodsgroupid: undefined,
+        goodsid: undefined,
     })
+    const v_group = async (rule: RuleObject, value: number) => {
+        if (formState.goodsgroupid) {
+            return validateCommon(value, '请选择合约');
+        } else {
+            return Promise.reject('请选择商品')
+        }
+    };
     const rules = {
         FixedPrice: [{ required: true, message: '请输入挂牌价格', trigger: 'blur', type: 'number', min: 1, }],
         OrderQty: [{ required: true, message: '请输入挂牌数量', trigger: 'blur', type: 'number', min: 1, ma: data.enableqty }],
-        // comfirePassword: [{ required: true, validator: validatePassword, trigger: 'blur' }],
+        PriceMove: [{ required: true, message: '请输入升贴水', trigger: 'blur', type: 'number', }],
+        goodsid: [{ required: true, validator: v_group }],
 
     }
     return { rules, formState, formRef }
 }
+
+
+export function handleGoods() {
+    const goodsGroup = getGoodsGroupsByTradeMode(TradeMode.quote99);
+    const allGoods = getGoodsList()
+    const goodsList = ref<Goods[]>([])
+    function groupsChange(id: number) {
+        goodsList.value = allGoods.filter(e => e.goodsgroupid === id)
+    }
+    return { goodsGroup, goodsList, groupsChange }
+}