Преглед изворни кода

修复组成搜索不到以及下拉没反应

张田田 пре 8 месеци
родитељ
комит
2e104ce13b
1 измењених фајлова са 33 додато и 17 уклоњено
  1. 33 17
      src/service/AddItems.vue

+ 33 - 17
src/service/AddItems.vue

@@ -247,6 +247,7 @@ function doSubmit() {
       message.error('请选择计价规则');
       return;
     }
+    // console.log(form.pricingType, 'form.pricingType==>', form);
     // 计价规则相关字段校验
     if (form.pricingType === '0') {
       const { unitPrice, pricingUnit, convertDose, convertUnit } = form.cpFixedPricingRule || {};
@@ -255,15 +256,20 @@ function doSubmit() {
         message.error('请将单价、计价单位、相当于、使用单位全部填写');
         return;
       }
+      form.cpDynamicPricingRule = undefined;
     } else if (form.pricingType === '1') {
       const rule1 = form.cpDynamicPricingRule[0] || {};
       const rule2 = form.cpDynamicPricingRule[1] || {};
       const allFilled1 = rule1.min && typeof rule1.priceType !== 'undefined' && rule1.price;
       const allFilled2 = rule2.max && typeof rule2.priceType !== 'undefined' && rule2.price;
+      rule1.max = 0;
+      rule2.min = 0;
       if (!(allFilled1 && allFilled2)) {
         message.error('请将按穴位/经络/部位的所有计价字段全部填写');
         return;
       }
+      // 按穴位模式:清空一口价数据
+      form.cpFixedPricingRule = undefined;
     }
     // 供应商
     if (form.addType === 'itemsList' && checkedList.value.includes('1')) {
@@ -295,6 +301,10 @@ function doSubmit() {
         message.error('单价、计价单位、相当于、使用单位要么全部填写,要么全部为空');
         return;
       }
+      // 一口价模式:清空按穴位数据
+      if (allFilled) {
+        form.cpDynamicPricingRule = undefined;
+      }
     } else if (form.pricingType === '1') {
       const rule1 = form.cpDynamicPricingRule[0] || {};
       const rule2 = form.cpDynamicPricingRule[1] || {};
@@ -306,6 +316,10 @@ function doSubmit() {
         message.error('按穴位/经络/部位的所有计价字段要么全部填写,要么全部为空');
         return;
       }
+      // 按穴位模式:清空一口价数据
+      if (allFilled1 && allFilled2) {
+        form.cpFixedPricingRule = undefined;
+      }
     }
   }
   // 调理方案项目相关必填
@@ -643,15 +657,24 @@ function handleVideoChange(info: any) {
 watch(
   () => form.pricingType,
   (val) => {
-    if (val === '0' && !form.cpFixedPricingRule) {
-      form.cpFixedPricingRule = {
-        unitPrice: '',
-        pricingUnit: '',
-        convertDose: '',
-        convertUnit: '',
-      };
-    } else {
-      form.cpFixedPricingRule = null;
+    if (val === '0') {
+      // 一口价模式:确保 cpFixedPricingRule 存在
+      if (!form.cpFixedPricingRule) {
+        form.cpFixedPricingRule = {
+          unitPrice: '',
+          pricingUnit: '',
+          convertDose: '',
+          convertUnit: '',
+        };
+      }
+    } else if (val === '1') {
+      // 按穴位模式:确保 cpDynamicPricingRule 存在
+      if (!form.cpDynamicPricingRule) {
+        form.cpDynamicPricingRule = [
+          { min: '', max: '', priceType: '', price: '' },
+          { min: '', max: '', priceType: '', price: '' },
+        ];
+      }
     }
   }
 );
@@ -766,14 +789,7 @@ function handleDerivation() {
 
         <span style="margin-left: 32px">相当于</span>
         <a-input v-model:value="form.cpFixedPricingRule.convertDose" placeholder="请输入" style="width: 100px; margin-left: 8px" />
-        <vxe-select
-          v-model="form.cpFixedPricingRule.convertUnit"
-          :options="unitOptions"
-          placeholder="请选择"
-          clearable
-          transfer
-          style="width: 100px; margin-left: 8px"
-        />
+        <vxe-select v-model="form.cpFixedPricingRule.convertUnit" :options="unitOptions" placeholder="请选择" clearable transfer style="width: 100px; margin-left: 8px" />
 
         <span style="color: #aaa; margin-left: 8px">(使用单位)</span>
       </div>