Quellcode durchsuchen

客资任务跟踪题目填写添加表格选项

zhujindu vor 11 Monaten
Ursprung
Commit
fa85013beb
1 geänderte Dateien mit 17 neuen und 21 gelöschten Zeilen
  1. 17 21
      src/mixin/clew.js

+ 17 - 21
src/mixin/clew.js

@@ -17,7 +17,6 @@ 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);
@@ -116,44 +115,41 @@ export const clewMixins = {
             // 表格
             let tableData = optionList[i].tableData;
             let filterBGData = this.filterBGData(tableData);
-            if (!filterBGData) {
-              // this.requiredFlag = false;
-              // this.requiredMessage = '请填写' + optionList[i].customerClueName;
-              return;
-            } else {
+            if (filterBGData.hasAllFilledRow && filterBGData.filledRow == '') {
               optionList[i].answerValue = JSON.stringify(tableData);
+            } else {
+              this.requiredFlag = false;
+              this.requiredMessage =
+                filterBGData.filledRow != ''
+                  ? filterBGData.filledRow
+                  : '请填写' + optionList[i].customerClueName;
+              return;
             }
           }
         }
       }
     },
     filterBGData(tableData) {
-      let hasAllFilledRow = false;
+      // 如果一行中有一个输入框输入了内容,其他输入框没有内容,就弹框提示当前行其它输入框也要填写,
+      // 整个表格必须有一行所有输入框都输入了内容
+      let hasAllFilledRow = false; // 是否有整行都填写
+      let filledRow = ''; // 有内容行
       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() !== ''
-        );
+        const allFilled = Object.values(row).every((cell, index) => {
+          return cell.trim() !== '';
+        });
         if (hasContent && !allFilled) {
-          alert(`第 ${rowIndex + 1} 行的其他输入框也要填写`);
-          this.requiredFlag = false;
-          this.requiredMessage = `第 ${rowIndex + 1} 行的其他输入框也要填写`;
+          filledRow = `${row.typeName}请填写完整`;
           return;
         }
         if (allFilled) {
           hasAllFilledRow = true;
         }
       });
-      if (!hasAllFilledRow) {
-        alert('整个表格必须有一行所有输入框都输入了内容');
-        this.requiredFlag = false;
-        this.requiredMessage = '整个表格必须有一行所有输入框都输入了内容';
-        return false;
-      } else {
-        return true;
-      }
+      return { hasAllFilledRow, filledRow };
       // let data = [];
       // const isValid = tableData.data.some((row) => {
       //   if (Object.values(row).every((value) => value.trim() !== '')) {