Przeglądaj źródła

协议调度bug

@dongkboy 3 miesięcy temu
rodzic
commit
a977bbe5f2
1 zmienionych plików z 28 dodań i 8 usunięć
  1. 28 8
      src/views/quoteConfig/dispatch/components/rule.vue

+ 28 - 8
src/views/quoteConfig/dispatch/components/rule.vue

@@ -12,7 +12,7 @@
               <div class="condition-row">
                 <!-- 1. 条件类型选择框 -->
                 <el-select v-model="domain.attrCode" placeholder="选择条件" style="width: 341px"
-                  @change="handleConditionChange(domain)" clearable>
+                  @change="(val) => handleConditionChange(domain, val)" clearable>
                   <el-option v-for="item in dispatchList" :key="item.attrCode" :label="item.attrName"
                     :value="item.attrCode" />
                 </el-select>
@@ -39,7 +39,7 @@
                 </el-select>
 
                 <!-- 单选下拉 -->
-                <el-select v-model="domain.max" placeholder="选择值" style="width: 341px" multiple
+                <el-select v-model="domain.minArray" placeholder="选择值" style="width: 341px" multiple
                   v-if="getConditionType(domain.attrCode) === 'select'" :disabled="!domain.operator" clearable>
                   <el-option v-for="item in getOptions(domain.attrCode)" :key="item.code" :label="item.name"
                     :value="item.code" />
@@ -208,6 +208,7 @@ const cascaderProps = { multiple: true, checkStrictly: true };
 interface ConditionRow {
   key: number;
   min: any;
+  attrType: string;
   operator: string;
   attrCode: string;
   max: any;
@@ -256,6 +257,7 @@ const formData = ref<{
       groupKey: Date.now(),
       actions: [
         {
+          attrType: "",
           attrCode: "",
           key: Date.now(),
           min: "",
@@ -466,16 +468,19 @@ const getConditionType = (conditionValue: string) => {
 };
 
 // 条件切换时的处理
-const handleConditionChange = (domain: ConditionRow) => {
+const handleConditionChange = (domain: ConditionRow, val: string) => {
+  console.log(domain, val)
+  const target = dispatchList.value.find((item: any) => item.attrCode == val)
   domain.max = null;
   domain.operator = "";
+  domain.attrType = target?.attrType || "input";
 };
 
 // 运算符切换时重置值
 const handleOperatorChange = (domain: ConditionRow) => {
   const attrType = getConditionType(domain.attrCode);
   // 重置对应类型的值
-  if (["checkbox", "inputTag"].includes(attrType)) {
+  if (["checkbox", "inputTag", "select"].includes(attrType)) {
     domain.minArray = [];
   } else {
     domain.min = null;
@@ -488,6 +493,7 @@ const handleAddRow = (groupIndex: number) => {
   formData.value.conditionGroups[groupIndex].actions.push({
     key: Date.now(),
     min: "",
+    attrType: "",
     attrCode: "",
     operator: "",
     max: null,
@@ -509,6 +515,7 @@ const handleAddGroup = () => {
       {
         key: Date.now(),
         min: "",
+        attrType: "",
         attrCode: "",
         operator: "",
         max: null,
@@ -614,10 +621,17 @@ const submit = async () => {
     })
     return
   }
-
+  // 处理多选框额外传值
+  const allActions = formData.value.conditionGroups.flatMap((group) => group.actions);
+  allActions.map((item) => {
+    if (["checkbox", "inputTag", "select"].includes(item.attrType)) {
+      item.min = item.minArray.join(',');
+    }
+    return item
+  })
   const submitData = {
     companyId: props.companyId + "",
-    attrLinks: formData.value.conditionGroups.flatMap((group) => group.actions),
+    attrLinks: allActions,
     actions,
     ...(dispatchId.value && { dispatchId: dispatchId.value }), // 编辑时携带ID
   };
@@ -715,6 +729,7 @@ onMounted(async () => {
       if (rawGroup.length > 0) {
         group.actions = rawGroup.map((rawRow: any, rowIdx: number) => ({
           key: rawRow.id || `row_${groupIdx}_${rowIdx}_${Date.now()}`,
+          attrType: rawRow.attrType || "",
           attrCode: rawRow.attrCode || "",
           operator: rawRow.operator || "",
           min: rawRow.min !== undefined ? rawRow.min : null,
@@ -726,6 +741,7 @@ onMounted(async () => {
         // 组内无数据时,兜底1行
         group.actions.push({
           key: Date.now(),
+          attrType: "",
           attrCode: "",
           operator: "",
           min: null,
@@ -745,6 +761,7 @@ onMounted(async () => {
         actions: [
           {
             key: Date.now(),
+            attrType: "",
             attrCode: "",
             operator: "",
             min: null,
@@ -779,6 +796,7 @@ onMounted(async () => {
         rawGroup.forEach((rawRow: any, rowIdx: number) => {
           group.actions.push({
             key: rawRow.id || `row_${groupIdx}_${rowIdx}_${Date.now()}`,
+            attrType: rawRow.attrType || "",
             attrCode: rawRow.attrCode || "",
             operator: rawRow.operator || "",
             min: rawRow.min !== undefined ? rawRow.min : null,
@@ -792,6 +810,7 @@ onMounted(async () => {
         if (group.actions.length === 0) {
           group.actions.push({
             key: Date.now(),
+            attrType: "",
             attrCode: "",
             operator: "",
             min: null,
@@ -841,6 +860,7 @@ onMounted(async () => {
           actions: [
             {
               key: Date.now(),
+              attrType: "",
               attrCode: "",
               operator: "",
               min: null,
@@ -872,13 +892,13 @@ const regionLicenseNumber = (value: string) => {
         })
         return val;
       })
-      if(value == '14'){
+      if (value == '14') {
         const licenseNoItem = dispatchList.value.find((item: any) => item.attrCode == 'LicenseNo');
         if (licenseNoItem) {
           licenseNoItem.dictLabal = data;
         }
       }
-      if(value == '0'){
+      if (value == '0') {
         const licenseAreaItem = dispatchList.value.find((item: any) => item.attrCode == 'LicenseArea');
         if (licenseAreaItem) {
           licenseAreaItem.dictLabal = data;