zhujindu 11 ماه پیش
والد
کامیت
cdd8beead4
1فایلهای تغییر یافته به همراه36 افزوده شده و 8 حذف شده
  1. 36 8
      src/mixin/clew.js

+ 36 - 8
src/mixin/clew.js

@@ -17,6 +17,7 @@ export const clewMixins = {
       params.customerClueItemList.push(...this.deepClone(this.taskGather, 0));
       this.filterOption(this.taskGather, params);
       console.log(JSON.stringify(params));
+      debugger;
       // 必填验证
       if (this.requiredFlag) {
         callback && callback(params);
@@ -114,9 +115,10 @@ export const clewMixins = {
           } else if (optionList[i].answerType == 'bg') {
             // 表格
             let tableData = optionList[i].tableData;
-            if (!this.filterBGData(tableData).length) {
-              this.requiredFlag = false;
-              this.requiredMessage = '请填写' + optionList[i].customerClueName;
+            let filterBGData = this.filterBGData(tableData);
+            if (!filterBGData) {
+              // this.requiredFlag = false;
+              // this.requiredMessage = '请填写' + optionList[i].customerClueName;
               return;
             } else {
               optionList[i].answerValue = JSON.stringify(tableData);
@@ -126,13 +128,39 @@ export const clewMixins = {
       }
     },
     filterBGData(tableData) {
-      let data = [];
-      const isValid = tableData.data.some((row) => {
-        if (Object.values(row).every((value) => value.trim() !== '')) {
-          data.push(row);
+      let hasAllFilledRow = false;
+      tableData.data.forEach((row, rowIndex) => {
+        const hasContent = Object.values(row).some(
+          (cell, index) => index !== 0 && cell.trim() !== ''
+        );
+        const allFilled = Object.values(row).every(
+          (cell, index) => index !== 0 || cell.trim() !== ''
+        );
+        if (hasContent && !allFilled) {
+          alert(`第 ${rowIndex + 1} 行的其他输入框也要填写`);
+          this.requiredFlag = false;
+          this.requiredMessage = `第 ${rowIndex + 1} 行的其他输入框也要填写`;
+          return;
+        }
+        if (allFilled) {
+          hasAllFilledRow = true;
         }
       });
-      return data;
+      if (!hasAllFilledRow) {
+        alert('整个表格必须有一行所有输入框都输入了内容');
+        this.requiredFlag = false;
+        this.requiredMessage = '整个表格必须有一行所有输入框都输入了内容';
+        return false;
+      } else {
+        return true;
+      }
+      // let data = [];
+      // const isValid = tableData.data.some((row) => {
+      //   if (Object.values(row).every((value) => value.trim() !== '')) {
+      //     data.push(row);
+      //   }
+      // });
+      // return data;
     },
   },
 };