Переглянути джерело

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

zhujindu 11 місяців тому
батько
коміт
f004f975e4
3 змінених файлів з 32 додано та 134 видалено
  1. 3 21
      src/mixin/clew.js
  2. 20 1
      src/views/clew/clewent.vue
  3. 9 112
      src/views/clew/complaintDetail/index.vue

+ 3 - 21
src/mixin/clew.js

@@ -1,4 +1,3 @@
-import { insertCustomerClueAnswerKs } from '@/api/complaintDetail';
 export const clewMixins = {
   data() {
     return {};
@@ -7,15 +6,12 @@ export const clewMixins = {
   created() {},
   mounted() {},
   methods: {
-    purchaseSubmit() {
+    purchaseSubmit(callback) {
       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;
@@ -23,16 +19,7 @@ export const clewMixins = {
       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);
-          }
-        });
+        callback && callback(params);
       } else {
         this.$toast(this.requiredMessage);
       }
@@ -63,7 +50,7 @@ export const clewMixins = {
                 customerClueItemList.push(
                   ...this.deepClone(customerClueOptionList[i].customerClueItemList, 0)
                 );
-                if (customerClueOptionList[i].customerClueItemList[0]) {
+                if (customerClueOptionList[i].customerClueItemList.length) {
                   this.filterOption(customerClueOptionList[i].customerClueItemList, params);
                 }
               }
@@ -132,11 +119,6 @@ export const clewMixins = {
             } else {
               optionList[i].answerValue = this.filterBGData(tableData);
             }
-            // if (optionList[i].searchValue) {
-            //   this.requiredFlag = false;
-            //   this.requiredMessage = optionList[i].remark;
-            //   return;
-            // }
           }
         }
       }

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

@@ -865,7 +865,26 @@ export default {
     onLoad() {},
     onSubmit() {
       if (this.infoData.cid == '5') {
-        this.purchaseSubmit();
+        this.purchaseSubmit((data) => {
+          var form = {
+            isClose: this.isClose,
+            followUpResult: this.followUpResult,
+            customerClueItemList: data.customerClueItemList,
+          };
+          this.toastLoading(0, '加载中...', true);
+          insertCustomerClueAnswer(form).then((res) => {
+            this.toastLoading().clear();
+            if (res.code == 200) {
+              if (this.$route.query.token != undefined) {
+                window.location.replace(window.location.origin + '/mobile/clew');
+              } else {
+                this.$router.go(-1);
+              }
+            } else {
+              this.$toast(res.msg);
+            }
+          });
+        });
       } else {
         for (var c = 0; c < this.collectionAnswerlisd.length; c++) {
           for (var b = 0; b < this.collectionItemList.length; b++) {

+ 9 - 112
src/views/clew/complaintDetail/index.vue

@@ -188,9 +188,11 @@ import radioGroup from './radioGroup';
 import followUpHistory from './followUpHistory';
 import { getDictOption } from '@/api/index';
 import { updateCustomerClueDept, getDeptInfo } from '@/api/clew';
+import { clewMixins } from '@/mixin/clew.js';
 
 export default {
   name: 'complaintDetail',
+  mixins: [clewMixins],
   components: {
     infoDetail,
     complaintLog,
@@ -299,27 +301,13 @@ export default {
       });
     },
     onSubmit() {
-      // 没有选择跟进记录
-      // if (!this.taskGather[0].searchValue) {
-      //   this.$toast('请选择跟进结果');
-      //   return;
-      // }
-      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.purchaseSubmit((data) => {
         this.toastLoading(0, '加载中...', true);
+        let params = {
+          customerClueItemList: data.customerClueItemList,
+          customerClassify: this.customerClassify,
+          customerSubClassify: this.customerSubClassify,
+        };
         insertCustomerClueAnswerKs(params).then((res) => {
           this.toastLoading().clear();
           if (res.code == 200) {
@@ -329,98 +317,7 @@ export default {
             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;
-            }
-          }
-        }
-      }
+      });
     },
     // 校验错误返回信息
     onFailed(errorInfo) {