소스 검색

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

zhujindu 11 달 전
부모
커밋
7b2050365a
3개의 변경된 파일189개의 추가작업 그리고 37개의 파일을 삭제
  1. 173 1
      src/mixin/clew.js
  2. 1 32
      src/views/clew/clewent.vue
  3. 15 4
      src/views/clew/complaintDetail/radioGroup.vue

+ 173 - 1
src/mixin/clew.js

@@ -1,3 +1,4 @@
+import { insertCustomerClueAnswerKs } from '@/api/complaintDetail';
 export const clewMixins = {
   data() {
     return {};
@@ -5,5 +6,176 @@ export const clewMixins = {
   computed: {},
   created() {},
   mounted() {},
-  methods: {},
+  methods: {
+    purchaseSubmit() {
+      this.requiredFlag = true;
+      let customerClueItemList = [];
+      // 每一个层级都是一道题的题目,子级就是题,被选中和填写的题要带上题目一块上传(题的同级也要上传)
+      // 第一级题目下的题默认都要上传
+      let params = {
+        customerClueItemList: [],
+        customerClassify: this.customerClassify,
+        customerSubClassify: this.customerSubClassify,
+      };
+      params.customerClueItemList.push(...this.deepClone(this.taskGather, 0));
+      // let optionList = this.taskGather[0].customerClueOptionList;
+      this.filterOption(this.taskGather, params);
+      console.log(JSON.stringify(params));
+      // 必填验证
+      if (this.requiredFlag) {
+        this.toastLoading(0, '加载中...', true);
+        insertCustomerClueAnswerKs(params).then((res) => {
+          this.toastLoading().clear();
+          if (res.code == 200) {
+            this.$toast(res.msg);
+            window.location.replace(window.location.origin + '/mobile/clew');
+          } else {
+            this.$toast(res.msg);
+          }
+        });
+      } else {
+        this.$toast(this.requiredMessage);
+      }
+    },
+    filterOption(optionList, params) {
+      for (let val = 0; val < optionList.length; val++) {
+        if (
+          optionList[val].isMust == '0' &&
+          optionList[val].searchValue == null &&
+          optionList[val].answerType == 'dx'
+        ) {
+          // 题目必填校验
+          this.requiredFlag = false;
+          this.requiredMessage = '请选择' + optionList[val].customerClueName;
+          return;
+        } else if (optionList[val].isMust == '0' && optionList[val].searchValue) {
+          // 子级题校验
+          let customerClueOptionList = optionList[val].customerClueOptionList;
+          for (let i = 0; i < customerClueOptionList.length; i++) {
+            // 选中的题目Y:选中,N:未选中
+            if (customerClueOptionList[i].value == 'Y') {
+              if (customerClueOptionList[i].customerClueItemList) {
+                // 必填校验
+                this.isRequiredFlag(customerClueOptionList[i].customerClueItemList);
+                // 赋值选中题
+                let customerClueItemList =
+                  params.customerClueItemList[val].customerClueOptionList[i].customerClueItemList;
+                customerClueItemList.push(
+                  ...this.deepClone(customerClueOptionList[i].customerClueItemList, 0)
+                );
+                if (customerClueOptionList[i].customerClueItemList[0]) {
+                  this.filterOption(customerClueOptionList[i].customerClueItemList, params);
+                }
+              }
+            }
+          }
+        }
+      }
+    },
+    // 深拷贝指定拷贝层级
+    deepClone(obj, num) {
+      // 检查是否为对象或数组
+      if (obj === null || typeof obj !== 'object') {
+        return obj; // 基本类型直接返回
+      }
+      // 创建一个数组或对象
+      const copy = Array.isArray(obj) ? [] : {};
+      // 遍历对象的每个属性
+      for (const key in obj) {
+        if (obj.hasOwnProperty(key) && num < 2) {
+          // 递归调用深拷贝
+          if (key == 'customerClueOptionList' || key == 'customerClueItemList') {
+            num = num + 1;
+          }
+          copy[key] = this.deepClone(obj[key], num);
+        }
+      }
+      return copy;
+    },
+    isRequiredFlag(optionList) {
+      // console.log(optionList);
+      for (let i = 0; i < optionList.length; i++) {
+        // 是否必填
+        if (optionList[i].isMust == 0) {
+          // 输入框
+          if (optionList[i].answerType == 'wb' || optionList[i].answerType == 'sz') {
+            if (!optionList[i].answerValue) {
+              // 必填类型
+              this.requiredFlag = false;
+              this.requiredMessage = optionList[i].remark;
+              return;
+            } else {
+              // 条件校验
+              if (optionList[i].minTextLength) {
+                // 输入内容长度校验
+                if (optionList[i].answerValue.length < optionList[i].minTextLength) {
+                  this.requiredFlag = false;
+                  this.requiredMessage = optionList[i].remark;
+                  return;
+                }
+              }
+            }
+          } else if (optionList[i].answerType == 'zp') {
+            // 照片
+            if (!optionList[i].fileInfoList || !optionList[i].fileInfoList.length) {
+              this.requiredFlag = false;
+              this.requiredMessage = optionList[i].remark;
+              return;
+            }
+          } else if (optionList[i].answerType == 'bg') {
+            // 表格
+            let tableData = optionList[i].tableData;
+            if (!this.filterBGData(tableData)) {
+              this.requiredFlag = false;
+              this.requiredMessage = '请填写' + optionList[i].customerClueName;
+              return;
+            } else {
+              optionList[i].answerValue = this.filterBGData(tableData);
+            }
+            // if (optionList[i].searchValue) {
+            //   this.requiredFlag = false;
+            //   this.requiredMessage = optionList[i].remark;
+            //   return;
+            // }
+          }
+        }
+      }
+    },
+    filterBGData(tableData) {
+      let data = null;
+      const isValid = tableData.data.some((row) => {
+        if (Object.values(row).every((value) => value.trim() !== '')) {
+          data = row;
+        }
+      });
+
+      //   const hasContent = Object.values(row).some(value => value.trim() !== '');
+      //   if (hasContent) {
+      //     for (const key in row) {
+      //       if (row[key].trim() === '') {
+      //         this.$set(row, key, ''); // 确保其他输入框也被标记为需要填写
+      //       }
+      //     }
+      //   }
+      return data;
+      //   let title = remarkData.title;
+      //   let len = title.length;
+      //   let data = remarkData.data;
+      //   let isFlag = false;
+      //   data.forEach((val) => {
+      //     for (let i = 0; i < len; i++) {
+      //       let num = 0;
+      //       if (val[title[i].prop]) {
+      //         num = num + 1;
+      //       }
+      //       if (num == len) {
+      //         isFlag = true;
+      //       } else if (num == 2) {
+      //         this.requiredFlag = false;
+      //         this.requiredMessage = '请将' + val.typeName + '填写完整';
+      //       }
+      //     }
+      //   });
+    },
+  },
 };

+ 1 - 32
src/views/clew/clewent.vue

@@ -449,7 +449,6 @@ import {
   updateCustomerClueDept,
   getCustomerClueAnswerById,
 } from '@/api/clew';
-import { insertCustomerClueAnswerKs } from '@/api/complaintDetail';
 import { ImagePreview } from 'vant';
 import clewentDetails from './clewentDetails';
 import radioGroup from './complaintDetail/radioGroup';
@@ -864,38 +863,8 @@ export default {
       return val.slice(0, 4) + '-' + val.slice(4, 6) + '-' + val.slice(6, 8);
     },
     onLoad() {},
-    purchaseSubmit() {
-      this.requiredFlag = true;
-      let customerClueItemList = [];
-      // 每一个层级都是一道题的题目,子级就是题,被选中和填写的题要带上题目一块上传(题的同级也要上传)
-      // 第一级题目下的题默认都要上传
-      let params = {
-        customerClueItemList: [],
-        customerClassify: this.customerClassify,
-        customerSubClassify: this.customerSubClassify,
-      };
-      params.customerClueItemList.push(...this.deepClone(this.taskGather, 0));
-      // let optionList = this.taskGather[0].customerClueOptionList;
-      this.filterOption(this.taskGather, params);
-      console.log(JSON.stringify(params));
-      // 必填验证
-      if (this.requiredFlag) {
-        this.toastLoading(0, '加载中...', true);
-        insertCustomerClueAnswerKs(params).then((res) => {
-          this.toastLoading().clear();
-          if (res.code == 200) {
-            this.$toast(res.msg);
-            window.location.replace(window.location.origin + '/mobile/clew');
-          } else {
-            this.$toast(res.msg);
-          }
-        });
-      } else {
-        this.$toast(this.requiredMessage);
-      }
-    },
     onSubmit() {
-      if (this.infoDatacid == '5') {
+      if (this.infoData.cid == '5') {
         this.purchaseSubmit();
       } else {
         for (var c = 0; c < this.collectionAnswerlisd.length; c++) {

+ 15 - 4
src/views/clew/complaintDetail/radioGroup.vue

@@ -96,11 +96,9 @@
           <span class="van-f-red" v-if="val.isMust == 0">*</span>
           {{ val.customerClueName }}
         </div>
-        <el-table
-          :data="JSON.parse(val.remark).data"
-          style="width: 100%; position: relative; left: -10px">
+        <el-table :data="val.tableData.data" style="width: 100%; position: relative; left: -10px">
           <el-table-column
-            v-for="(item, index) in JSON.parse(val.remark).title"
+            v-for="(item, index) in val.tableData.title"
             :prop="item.prop"
             :label="item.label"
             align="center">
@@ -145,6 +143,19 @@ export default {
   data() {
     return {};
   },
+  watch: {
+    clueOptionList: {
+      handler(val) {
+        val.forEach((item) => {
+          if (item.answerType == 'bg') {
+            this.$set(item, 'tableData', JSON.parse(item.remark));
+            // this.$forceUpdate();
+          }
+        });
+      },
+      immediate: true,
+    },
+  },
   created() {
     // console.log(this.clueOptionList);
   },