|
@@ -1,3 +1,4 @@
|
|
|
|
|
+import { insertCustomerClueAnswerKs } from '@/api/complaintDetail';
|
|
|
export const clewMixins = {
|
|
export const clewMixins = {
|
|
|
data() {
|
|
data() {
|
|
|
return {};
|
|
return {};
|
|
@@ -5,5 +6,176 @@ export const clewMixins = {
|
|
|
computed: {},
|
|
computed: {},
|
|
|
created() {},
|
|
created() {},
|
|
|
mounted() {},
|
|
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 + '填写完整';
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // });
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
};
|
|
};
|