Browse Source

家装客资

zhujindu 1 year ago
parent
commit
4e38f56009

+ 131 - 49
src/views/week/assignAwait/JZfollowUp.vue

@@ -9,7 +9,7 @@
     <div class="lineGrey"></div>
     <div class="lineGrey"></div>
     <!-- 客资详情 -->
-    <assignAwaitDetail :infoData="infoData">
+    <assignAwaitDetail :infoData="infoData" v-if="infoData">
       <div class="info">
         跟进状态:
         <span v-if="infoData.isClose == 1">跟进完成</span>
@@ -29,10 +29,10 @@
       </van-button>
     </assignAwaitDetail>
     <!-- 历史跟进记录 -->
-    <p style="margin: 0 16px 8px; color: #888" v-if="infoData.userCustomerClueList">
+    <p style="margin: 0 16px 8px; color: #888" v-if="infoData && infoData.userCustomerClueList">
       该客资历史跟进记录
     </p>
-    <van-cell-group inset class="cardclewContentCell">
+    <van-cell-group inset class="cardclewContentCell" v-if="infoData">
       <div style="border-radius: 6px; overflow: hidden">
         <van-cell
           is-link
@@ -49,12 +49,12 @@
       </div>
     </van-cell-group>
     <!-- 跟进任务填写 -->
-    <div class="assign">
+    <div class="assign" v-if="infoData && infoData.isClose != 1">
       <div class="followUp required">跟进结果</div>
       <div class="taskGather" v-if="taskGather && taskGather">
         <radioGroup :clueOptionList="taskGather"></radioGroup>
       </div>
-      <div v-if="infoData.isClose != 1" class="tc" style="padding: 0 16px">
+      <div class="tc" style="padding: 0 16px">
         <van-button class="submitBtn" block type="info" color="#0057ba" @click="onSubmit">
           提交
         </van-button>
@@ -63,6 +63,7 @@
     <!-- 转交下属 -->
     <van-popup v-model="showPicker" position="bottom">
       <van-picker
+        title="转交下属"
         show-toolbar
         value-key="nickName"
         :columns="assignTypeData"
@@ -77,7 +78,7 @@
       cancel-button-text="关闭"
       :show-confirm-button="false"
       class="dialogz">
-      <followUpHistory :historyId="historyId"></followUpHistory>
+      <followUpHistory :historyId="historyId" :showView="showView"></followUpHistory>
     </van-dialog>
   </div>
 </template>
@@ -111,7 +112,7 @@ export default {
   data() {
     return {
       id: '',
-      infoData: {},
+      infoData: null,
       collectionItemList: [],
       title: '',
       postName: '',
@@ -120,6 +121,8 @@ export default {
       taskGather: null, //跟进任务集合
       showView: false,
       historyId: '',
+      requiredFlag: true, //问题必填检验
+      requiredMessage: '', //必填提示信息
     };
   },
   watch: {},
@@ -127,14 +130,15 @@ export default {
     this.id = this.$route.query.id;
     this.postName = localStorage.getItem('postName');
     this.getCustomerClueInfoById();
-    this.getSelectCustomerClueInfoById();
   },
   methods: {
     getCustomerClueInfoById() {
+      this.toastLoading(0, '加载中...', true);
       this.id = this.$route.query.id;
       this.collectionAnswerlisd = [];
       this.collectionItemList = [];
       getCustomerClueInfoById({ customerClueInfoId: this.id }).then((response) => {
+        this.toastLoading().clear();
         if (response.code == 200) {
           this.infoData = response.data;
           this.title = response.data.name;
@@ -148,8 +152,12 @@ export default {
             this.infoData.customerClueStatus == 0 &&
             this.postName &&
             this.postName == '区域家装销售负责人'
-          )
+          ) {
             this.getSelectSubUserList();
+          }
+          if (this.infoData.isClose != 1) {
+            this.getSelectCustomerClueInfoById();
+          }
         } else {
           this.$toast(res.msg);
         }
@@ -159,7 +167,10 @@ export default {
       selectCustomerClueInfoById({ customerClueInfoId: this.id }).then((res) => {
         if (res.code == 200) {
           // res.data.customerClue.searchValue.customerClueItemList
-          this.taskGather = res.data.customerClue.customerClueItemList;
+          if (res.data.customerClue) {
+            res.data.customerClue.customerClueItemList[0].customerClueInfoId = this.id;
+            this.taskGather = res.data.customerClue.customerClueItemList;
+          }
         } else {
           this.$toast(res.msg);
         }
@@ -175,17 +186,26 @@ export default {
       });
     },
     confirm(value) {
-      allocationSubCustomer({
-        userId: value.userId, //	string	用户ID
-        customerClueInfoId: this.id, //	string	客资主键ID
-      }).then((res) => {
-        if (res.code == 200) {
-          this.$toast(res.msg);
-          this.onClickLeft();
-        } else {
-          this.$toast(res.msg);
-        }
-      });
+      this.$dialog
+        .confirm({
+          title: '提示',
+          message: '一旦转交出去,则无法再查看,请确认!',
+        })
+        .then(() => {
+          this.toastLoading(0, '加载中...', true);
+          allocationSubCustomer({
+            userId: value.userId, //	string	用户ID
+            customerClueInfoId: this.id, //	string	客资主键ID
+          }).then((res) => {
+            this.toastLoading().clear();
+            if (res.code == 200) {
+              this.$toast(res.msg);
+              this.onClickLeft();
+            } else {
+              this.$toast(res.msg);
+            }
+          });
+        });
     },
     // 查看历史跟进记录
     viewFn(val) {
@@ -199,38 +219,79 @@ export default {
         this.$toast('请选择跟进结果');
         return;
       }
+      this.requiredFlag = true;
       let customerClueItemList = [];
       // 每一个层级都是一道题的题目,子级就是题,被选中和填写的题要带上题目一块上传(题的同级也要上传)
       // 第一级题目下的题默认都要上传
-      this.copyData(this.taskGather);
-      // 过滤最外层题目
-      let topOptionList = this.taskGather[0].customerClueOptionList.find(
-        (val) => val.customerClueOptionId == this.taskGather[0].searchValue
-      );
-      // console.log(topOptionList);
-      // insertFollowCustomerClueAnswer({ customerClueItemList: [this.taskGather] }).then((res) => {
-      //   if (res.code == 200) {
-      //     this.$toast(res.msg);
-      //   } else {
-      //     this.$toast(res.msg);
-      //   }
-      // });
+      let params = { customerClueItemList: [] };
+      params.customerClueItemList.push(...this.deepClone(this.taskGather, 0));
+      let optionList = this.taskGather[0].customerClueOptionList;
+      this.filterOption(optionList, params);
+      // 必填验证
+      if (this.requiredFlag) {
+        this.toastLoading(0, '加载中...', true);
+        insertFollowCustomerClueAnswer(params).then((res) => {
+          this.toastLoading().clear();
+          if (res.code == 200) {
+            this.$toast(res.msg);
+            this.onClickLeft();
+          } else {
+            this.$toast(res.msg);
+          }
+        });
+      } else {
+        this.$toast(this.requiredMessage);
+      }
+    },
+    filterOption(optionList, params) {
+      let copy = null;
+      for (let i = 0; i < optionList.length; i++) {
+        if (optionList[i].value == 'Y') {
+          if (optionList[i].customerClueItemList) {
+            // 必填校验
+            this.isRequiredFlag(optionList[i].customerClueItemList[0]);
+            params.customerClueItemList.push(
+              ...this.deepClone(optionList[i].customerClueItemList, 0)
+            );
+            if (
+              optionList[i].customerClueItemList[0] &&
+              optionList[i].customerClueItemList[0].customerClueOptionList.length
+            ) {
+              this.filterOption(
+                optionList[i].customerClueItemList[0].customerClueOptionList,
+                params
+              );
+            }
+          }
+        }
+      }
     },
-    copyData(data) {
-      for (let i = 0; i < data.length; i++) {
-        console.log(data[i]);
-        // numbersCopy = [];
-        // const target = Array.isArray(source) ? [] : {};
-        // for (const key in data[0]) {
-        //   if (Object.prototype.hasOwnProperty.call(data[0], key)) {
-        //     if (typeof data[0][key] === 'object' && data[0][key] !== null) {
-        //       target[key] = deepClone(data[0][key]);
-        //     } else {
-        //       target[key] = data[0][key];
-        //     }
-        //   }
-        // }
-        // return target;
+    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) {
+      // 必填类型
+      if (optionList.answerType == 'wb' && optionList.isMust == 0) {
+        if (!optionList.answerValue) {
+          this.requiredFlag = false;
+          this.requiredMessage = optionList.remark;
+        }
       }
     },
     // 校验错误返回信息
@@ -245,6 +306,16 @@ export default {
 </script>
 <style scoped lang="scss">
 .assignPage {
+  .assign {
+    margin: 16px;
+    background-color: #fff;
+    padding-bottom: 20px;
+    .followUp {
+      padding: 16px;
+      font-size: 14px;
+      font-weight: 600;
+    }
+  }
 }
 </style>
 <style lang="scss">
@@ -264,5 +335,16 @@ export default {
     margin-top: -33px;
     border-radius: 5px;
   }
+  .dialogz {
+    width: 100%;
+    display: flex;
+    flex-direction: column;
+    overflow: hidden;
+    height: 72vh;
+    .van-dialog__content {
+      flex: 1;
+      overflow-y: auto;
+    }
+  }
 }
 </style>

+ 15 - 238
src/views/week/assignAwait/followUpHistory.vue

@@ -115,13 +115,20 @@
   </div>
 </template>
 <script>
+import deleteUploadImg from '@/components/deleteUploadImg2';
+import deleteUploadImgv from '@/components/deleteUploadImg';
 import { getCustomerClueAnswerById } from '@/api/clew';
 export default {
+  components: { deleteUploadImg, deleteUploadImgv },
   props: {
     historyId: {
       type: [String, Number],
       default: '',
     },
+    showView: {
+      type: Boolean,
+      default: '',
+    },
   },
   data() {
     return {
@@ -129,248 +136,18 @@ export default {
       viewTextShow: false,
     };
   },
-  activated() {
-    debugger;
-    this.getFollowUpHistory();
+  watch: {
+    showView: {
+      handler(val) {
+        if (val) this.getFollowUpHistory();
+      },
+      immediate: true,
+    },
   },
   methods: {
     getFollowUpHistory(val) {
-      this.customItemList = {
-        customerClueItemList: [
-          {
-            searchValue: null,
-            createBy: 'admin',
-            createTime: '2024-11-04 10:32:28',
-            updateBy: '',
-            updateTime: null,
-            remark: '',
-            params: {},
-            pageSize: null,
-            pageNum: null,
-            customerClueItemId: 326,
-            customerClueId: 68,
-            customerClueInfoId: 102,
-            customerClueName: '跟进结果',
-            itemOptionParentId: null,
-            isMust: '0',
-            answerType: 'dx',
-            answerValue: null,
-            sort: 1,
-            delFlag: null,
-            fileIdList: null,
-            customerClueOptionList: [
-              {
-                searchValue: null,
-                createBy: 'admin',
-                createTime: '2024-11-14 15:51:45',
-                updateBy: '',
-                updateTime: null,
-                remark: null,
-                params: {},
-                pageSize: null,
-                pageNum: null,
-                customerClueOptionId: 438,
-                customerClueItemId: 326,
-                customerClueOption: '信息不真实',
-                value: 'Y',
-                checked: false,
-                customerClueItemList: null,
-              },
-              {
-                searchValue: null,
-                createBy: 'admin',
-                createTime: '2024-11-14 15:51:45',
-                updateBy: '',
-                updateTime: null,
-                remark: null,
-                params: {},
-                pageSize: null,
-                pageNum: null,
-                customerClueOptionId: 439,
-                customerClueItemId: 326,
-                customerClueOption: '新装企想合作',
-                value: 'N',
-                checked: false,
-                customerClueItemList: null,
-              },
-              {
-                searchValue: null,
-                createBy: 'admin',
-                createTime: '2024-11-14 15:51:45',
-                updateBy: '',
-                updateTime: null,
-                remark: null,
-                params: {},
-                pageSize: null,
-                pageNum: null,
-                customerClueOptionId: 440,
-                customerClueItemId: 326,
-                customerClueOption: '装企或工作室要服务',
-                value: 'N',
-                checked: false,
-                customerClueItemList: null,
-              },
-              {
-                searchValue: null,
-                createBy: 'admin',
-                createTime: '2024-11-14 15:51:46',
-                updateBy: '',
-                updateTime: null,
-                remark: null,
-                params: {},
-                pageSize: null,
-                pageNum: null,
-                customerClueOptionId: 441,
-                customerClueItemId: 326,
-                customerClueOption: '装企或工作室要一批货',
-                value: 'N',
-                checked: false,
-                customerClueItemList: null,
-              },
-            ],
-            fileInfoList: null,
-            del: true,
-          },
-          {
-            searchValue: null,
-            createBy: 'admin',
-            createTime: '2024-11-14 15:51:46',
-            updateBy: '',
-            updateTime: null,
-            remark: '',
-            params: {},
-            pageSize: null,
-            pageNum: null,
-            customerClueItemId: 327,
-            customerClueId: 68,
-            customerClueInfoId: null,
-            customerClueName: '信息不真实',
-            itemOptionParentId: 438,
-            isMust: '0',
-            answerType: 'dx',
-            answerValue: null,
-            sort: 2,
-            delFlag: null,
-            fileIdList: null,
-            customerClueOptionList: [
-              {
-                searchValue: null,
-                createBy: 'admin',
-                createTime: '2024-11-14 15:51:46',
-                updateBy: '',
-                updateTime: null,
-                remark: null,
-                params: {},
-                pageSize: null,
-                pageNum: null,
-                customerClueOptionId: 442,
-                customerClueItemId: 327,
-                customerClueOption: '号码不存在',
-                value: 'N',
-                checked: false,
-                customerClueItemList: null,
-              },
-              {
-                searchValue: null,
-                createBy: 'admin',
-                createTime: '2024-11-14 15:51:46',
-                updateBy: '',
-                updateTime: null,
-                remark: null,
-                params: {},
-                pageSize: null,
-                pageNum: null,
-                customerClueOptionId: 443,
-                customerClueItemId: 327,
-                customerClueOption: '公司不存在',
-                value: 'N',
-                checked: false,
-                customerClueItemList: null,
-              },
-              {
-                searchValue: null,
-                createBy: 'admin',
-                createTime: '2024-11-14 15:51:46',
-                updateBy: '',
-                updateTime: null,
-                remark: null,
-                params: {},
-                pageSize: null,
-                pageNum: null,
-                customerClueOptionId: 444,
-                customerClueItemId: 327,
-                customerClueOption: '城市有误',
-                value: 'N',
-                checked: false,
-                customerClueItemList: null,
-              },
-              {
-                searchValue: null,
-                createBy: 'admin',
-                createTime: '2024-11-14 15:51:46',
-                updateBy: '',
-                updateTime: null,
-                remark: null,
-                params: {},
-                pageSize: null,
-                pageNum: null,
-                customerClueOptionId: 445,
-                customerClueItemId: 327,
-                customerClueOption: '不接电话',
-                value: 'N',
-                checked: false,
-                customerClueItemList: null,
-              },
-              {
-                searchValue: null,
-                createBy: 'admin',
-                createTime: '2024-11-14 15:51:46',
-                updateBy: '',
-                updateTime: null,
-                remark: null,
-                params: {},
-                pageSize: null,
-                pageNum: null,
-                customerClueOptionId: 446,
-                customerClueItemId: 327,
-                customerClueOption: '其他',
-                value: 'Y',
-                checked: false,
-                customerClueItemList: null,
-              },
-            ],
-            fileInfoList: null,
-            del: true,
-          },
-          {
-            searchValue: null,
-            createBy: 'admin',
-            createTime: '2024-11-14 15:51:46',
-            updateBy: '',
-            updateTime: null,
-            remark: '请输入其他原因',
-            params: {},
-            pageSize: null,
-            pageNum: null,
-            customerClueItemId: 328,
-            customerClueId: 68,
-            customerClueInfoId: null,
-            customerClueName: '请输入原因',
-            itemOptionParentId: 446,
-            isMust: '0',
-            answerType: 'wb',
-            answerValue: '这个信息有误,以上原因都不是',
-            sort: 3,
-            delFlag: null,
-            fileIdList: null,
-            customerClueOptionList: [],
-            fileInfoList: null,
-            del: true,
-          },
-        ],
-      };
       this.toastLoading(0, '加载中...', true);
-      getCustomerClueAnswerById({ userCustomerClueId: val }).then((res) => {
+      getCustomerClueAnswerById({ userCustomerClueId: this.historyId }).then((res) => {
         this.toastLoading().clear();
         this.customItemList = res.data.customerClue.customerClueItemList;
         for (var pl = 0; pl < this.customItemList[1].customerClueOptionList.length; pl++) {

+ 1 - 1
src/views/week/assignAwait/radioGroup.vue

@@ -19,7 +19,7 @@
           <span class="van-f-red" v-if="clueOptionList[0].isMust == 0">*</span>
           {{ clueOptionList[0].customerClueName }}
           <van-field
-            v-model="clueOptionList[0].searchValue"
+            v-model="clueOptionList[0].answerValue"
             :placeholder="clueOptionList[0].customerClueName" />
         </template>
       </template>