import wangeditor from "../components/wangEditor.vue"; import question from "../components/question.vue"; import message from "../components/message.vue"; import scripts from "../components/script.vue"; import propaganda from "../components/propaganda.vue"; import officialAccount from "../components/officialAccount.vue"; import miniProgram from "../components/miniProgram.vue"; import { getAgencytype } from "@/api/system/agency"; import { selectTaskTypeList, taskPartitionList, taskStatusDictList, specialDiseaseNode, triggerCondition, selectSpecialDisease, updateRouteCheckStatus, list, triggerConditionList, getList, } from "@/api/system/specialDiseaseNode"; import Cookies from "js-cookie"; export default { components: { wangeditor, question, propaganda, message, scripts, officialAccount, miniProgram, }, name: "specialDiseaseNode", data() { return { value: 1, ConditionValue: [], dictDataType: "", openlist: { suitRange: "", routeId: "", triggerConditionList: [], }, open: false, show3: false, activeNames: ["1"], routeform: { routeCheckStatus: null, routeCheckRemark: "", }, optionslist: [], // 包含 optionstriggerConditionOperator: [], // 将这部分选项的 optionslistS: [], optionslistSname: [], // 诊断 optionsname: [], routeName: "", updata: [], updatalists: [], updatalist: [], // triggerConditionList: [{}], form: { specialDiseaseNodeId: "", nodeContent: "", templateId: "", templateName: "", taskType: "", taskTypeName: "", taskSubdivision: "", taskSubdivisionName: "", taskStatus: "", secondClassifyDescribe: "", executionTime: "", appletPushSign: "0", officialPushSign: "0", messagePushSign: "0", taskSubdivisiontemplateType: "", }, itemindex: 0, listindex: 0, totalNumber: 0, agreeNumber: 0, value: "", input: "", //任务类型 selectTaskTypeList: [], //任务状态 taskStatusDictList: [], //任务细分 taskPartitionList: [], routeId: "", options: [], lists: [], dialogVisible: false, parentDictCodelist: [], parentDictCode: "", itemlist: { specialDiseaseRouteId: "", // suitRange: "", routeName: "", specialDiseaseNodeList: [], }, updataname: "", rules: { routeCheckStatus: [ { required: true, message: "请选择节点审核状态", trigger: "change" }, ], }, }; }, created() { if (this.$route.query) { this.$set(this.form, "specialDiseaseNodeId", this.$route.query.id); this.$set(this.openlist, "suitRange", this.$route.query.suitRange); this.openlist.routeId = this.$route.query.id; this.itemlist.routeName = this.$route.query.routeName } this.taskinfo(); this.infolistname(); this.infolists(); this.infolistoptionslistS(); this.infolistMESSAGE(); this.infolistword(); // this.optiononditionOperator(); this.optiononditionOperators(); }, beforeDestroy() { }, watch: { "form.phoneMessageRemind": { handler(newValue, oldValue) { if (newValue == "NOT_SEND_MESSAGE") { this.form.phoneMessageTemplateId = ""; this.form.phoneMessageTemplateName = ""; } }, deep: true, }, // "openlist.triggerConditionList": { // handler(newValue, oldValue) { // // console.log(newValue,'newValue') // newValue.forEach(e=>{ // console.log(e,'e') // }) // // if (newValue == "NOT_SEND_MESSAGE") { // // this.form.phoneMessageTemplateId = ""; // // this.form.phoneMessageTemplateName = ""; // // } // }, // deep: true, // }, }, mounted() { // this.form = this.lists[0].list[0]; }, methods: { // 短信提醒 infolistword() { var dictType = "text_message_remind"; getAgencytype(dictType).then((res) => { this.optionslist = res.data; // this.taskinfo(); }); }, // 重播次数 infolistMESSAGE() { var dictType = "redial_times"; getAgencytype(dictType).then((res) => { this.optionslistSname = res.data; this.taskinfo(); }); }, // 弹框确定 upload() { const loading = this.$loading({ lock: true, text: "Loading", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", }); this.openlist.triggerConditionList.forEach((e) => { e.routeId = this.$route.query.id; e.routeName = this.$route.query.routeName; delete e.optionstriggerConditionOperator }); delete this.openlist.triggerConditionList.optionstriggerConditionOperator loading.close(); console.log(this.openlist.triggerConditionList, 'this.openlist.triggerConditionList') // return; triggerCondition(this.openlist).then((res) => { if (res.code == 200) { this.$notify({ type: "success", title: "提示", message: "修改触发条件成功", }); this.itemlist.routeName = res.data; } this.infolist(); // this.handlelist(); this.openfalse(); }); }, // 关闭弹框 openfalse() { this.openlist.triggerConditionList = [ { routeId: "", routeName: "", triggerConditionName: "", triggerConditionOperator: "", triggerConditionValue: "", triggerConditionOperatorName: "", dictDataType: "STRING", triggerLogic: "AND", triggerLogicName: "", }, ]; this.open = false; this.resetForm("openlist"); }, // 批量新增添加属性 addtriggerCondition() { this.idd++; var obj = { routeId: "", routeName: "", triggerConditionName: "", triggerConditionOperator: "", triggerConditionValue: "", triggerConditionOperatorName: "", dictDataType: "STRING", triggerLogic: "AND", triggerLogicName: "", }; if (this.openlist.triggerConditionList.length == 3) { this.$message.error("至多仅支持两种属性"); } else { this.openlist.triggerConditionList.push(obj); } }, // 删除属性 delitemlistname(index, item) { this.openlist.triggerConditionList.splice(index, 1); }, //取消 handleClose() { this.dialogVisible = false; this.routeform = { routeCheckStatus: "", routeCheckRemark: "", }; this.resetForm("routeform"); }, //审核 auditing() { this.$refs["routeform"].validate((valid) => { if (valid) { const loading = this.$loading({ lock: true, text: "审核中", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", }); if (!this.form.routeNodeDay) { this.$message.error("请输入节点时间段天数"); return loading.close(); } if (!this.form.routeNodeName) { this.$message.error("请选择节点时间段"); return loading.close(); } if (!this.form.taskType) { this.$message.error("请选择任务类型"); return loading.close(); } if (!this.form.taskSubdivision) { this.$message.error("请选择任务细分"); return loading.close(); } if (!this.form.taskStatus) { this.$message.error("请选择任务状态"); return loading.close(); } updateRouteCheckStatus({ routeCheckStatus: this.routeform.routeCheckStatus, id: this.form.specialDiseaseNodeId, routeCheckRemark: this.routeform.routeCheckRemark, routeCheckPerson: JSON.parse(localStorage.getItem("user")).nickName, }).then((res) => { loading.close(); if (res.data == 1) { this.info(); this.handleClose(); this.$modal.msgSuccess("审核成功!"); } }); } }); }, // 保存触发条件 addlistname() { this.show3 = !this.show3; }, // 适用范围 changeoptions(e) { this.parentDictCode = this.options.find( (el) => el.dictValue == e )?.dictCode; this.changelisy(); }, changelisy() { list(this.parentDictCode).then((res) => { this.parentDictCodelist = res.rows; }); }, // 回显 info() { const loading = this.$loading({ lock: true, text: "数据加载中", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", }); this.lists = []; if (this.$route.query) { this.$set(this.updata, "suitRange", this.$route.query.suitRange); this.parentDictCode = this.options.find( (el) => el.dictValue == this.updata.suitRange )?.dictCode; setTimeout(() => { this.changelisy(); }, 1000); this.itemlist.specialDiseaseRouteId = this.$route.query.id; selectSpecialDisease(this.$route.query.id).then((res) => { loading.close(); this.agreeNumber = res.data.agreeNumber; this.totalNumber = res.data.totalNumber; res.data.specialDiseaseNodeList.forEach((e) => { if (e.messagePushSign) { e.messagePushSign = "" + e.messagePushSign; } if (e.officialPushSign) { e.officialPushSign = "" + e.officialPushSign; } if (e.appletPushSign) { e.appletPushSign = "" + e.appletPushSign; } if (e.phonePushSign) { e.phonePushSign = "" + e.phonePushSign; } }); this.lists = this.handleData( res.data.specialDiseaseNodeList, "routeNodeDay", "routeNodeName" ); this.form = this.lists[0].list[0]; if (this.form.taskType) { this.changeTaskType(this.form.taskType, this.form.taskSubdivision); } }); } else { loading.close(); this.lists.push({ routeNodeName: "", routeNodeDay: "", list: [ { nodeContent: "

", templateId: "", templateName: "", taskType: "", taskSubdivision: "", taskSubdivisionName: "", taskStatus: "", secondClassifyDescribe: "", executionTime: "", appletPushSign: "0", officialPushSign: "0", messagePushSign: "0", messagePreview: "", officialRemindContent: "", taskSubdivisiontemplateType: "", appletRemindContent: "", appletPromptDescription: "", }, ], }); this.form = this.lists[0].list[0]; } }, handleData(list, key, keytwo) { //得到数据的主键列表 let keysArr = list.map((item) => { return { routeNodeDay: item[key], routeNodeName: item[keytwo], }; }); let array = keysArr.filter( (item, index, arr) => index === arr.findIndex( (ite) => ite.routeNodeDay == item.routeNodeDay && ite.routeNodeName == item.routeNodeName ) ); let keys = [...new Set(array)]; let newList = keys.map((item) => { return { //这里写新的 数据结构 如下是整体复制 routeNodeDay: item[key], routeNodeName: item[keytwo], list: list.filter( (i) => i[key] == item[key] && i[keytwo] == item[keytwo] ), }; }); return newList; }, // 且或 infolistoptionslistS() { var dictType = "trigger_logic"; getAgencytype(dictType).then((res) => { this.optionslistS = res.data; }); }, // 诊断 optiononditionOperators() { var dictType = "trigger_condition_name"; getAgencytype(dictType).then((res) => { this.optionsname = res.data; }); }, // 包含 optiononditionOperator() { var dictType = "trigger_condition_operator"; getAgencytype(dictType).then((res) => { // console.log(res, 'redsssssssss') this.openlist.triggerConditionList.optionstriggerConditionOperator = res.data; }); }, // 包含 changetriggerLogic(e, index) { // this.openlist.triggerConditionList[index].triggerConditionOperatorName = // this.openlist.triggerConditionList[index].optionstriggerConditionOperator.find( // (el) => el.dictValue == e // ).dictLabel; this.openlist.triggerConditionList[index].triggerConditionValue = null; }, // 诊断 changetriggerConditionName(e, index) { var dictType = e; getAgencytype(dictType).then((res) => { this.ConditionValue = res.data; }); this.openlist.triggerConditionList[index].triggerConditionName = this.optionsname.find((el) => el.dictValue == e).dictLabel; this.openlist.triggerConditionList[index].triggerConditionValue = null; this.openlist.triggerConditionList[index].triggerConditionOperator = null this.dictDataType = this.optionsname.find( (el) => el.dictValue == e ).dictDataType; this.handlelist(index) this.openlist.triggerConditionList[index].dictDataType = this.optionsname.find((el) => el.dictValue == e).dictDataType; }, // 包含或等号接口 handlelist(index) { var dictType = "trigger_condition_operator"; // this.openlist.triggerConditionList[index].optionstriggerConditionOperator=[] getList(dictType, this.dictDataType).then((res) => { this.$set(this.openlist.triggerConditionList[index], 'optionstriggerConditionOperator', res.data) console.log(this.openlist.triggerConditionList[index].optionstriggerConditionOperator, 'this.openlist') this.$forceUpdate(); }); }, // 且或 changetriggerLogicsname(e, index) { this.openlist.triggerConditionList[index].triggerLogic = e; this.openlist.triggerConditionList[index].triggerLogicName = this.optionslistS.find((el) => el.dictValue == e).dictLabel; }, // 适用范围 infolists() { var dictType = "suit_range"; getAgencytype(dictType).then((res) => { this.options = res.data; }); this.infolist(); }, // 展示触发条件 infolist() { this.routeId = this.$route.query.id; triggerConditionList(this.routeId).then((res) => { this.openlist.triggerConditionList = res.data; res.data.forEach((p) => { this.optiononditionOperators(); p.dictDataType = this.optionsname.find( (el) => el.dictValue == p.triggerConditionCode )?.dictDataType; var dictType = p.triggerConditionCode; getAgencytype(dictType).then((res) => { this.ConditionValue = res.data; this.optiononditionOperator(); }); }); if (res.data.length == 1) { // 回显一条时 this.updata = res.data[0]; this.updata.triggerConditionOperatorName = this.optionstriggerConditionOperator.find( (el) => el.dictValue == this.updata.triggerConditionOperator )?.dictLabel; this.updatalist = []; } else { // 回显两条或者三条 this.updata = res.data[0]; this.updata.triggerConditionOperatorName = this.optionstriggerConditionOperator.find( (el) => el.dictValue == this.updata.triggerConditionOperator )?.dictLabel; res.data.splice(0, 1); this.updatalist = res.data; this.updatalist.forEach((e) => { e.triggerConditionOperatorName = this.optionstriggerConditionOperator.find( (el) => el.dictValue == e.triggerConditionOperator )?.dictLabel; }); } if (this.open == true) { this.$set(this.openlist, "suitRange", this.$route.query.suitRange); } else { this.$set(this.updata, "suitRange", this.openlist.suitRange); } }); }, // 编辑接口回显 infolistname() { this.routeId = this.$route.query.id; triggerConditionList(this.routeId).then((res) => { this.openlist.triggerConditionList = res.data; this.openlist.triggerConditionList.forEach((o) => { this.optiononditionOperators(); o.dictDataType = this.optionsname.find( (el) => el.dictValue == o.triggerConditionCode )?.dictDataType; var dictType = "trigger_condition_operator"; getList(dictType, o.dictDataType).then((res) => { this.$set(o, 'optionstriggerConditionOperator', res.data) this.$forceUpdate() }); var dictType = o.triggerConditionCode; getAgencytype(dictType).then((res) => { this.ConditionValue = res.data; }); }); this.$set(this.updata, "suitRange", this.openlist.suitRange); }); }, // 编辑 edit() { this.open = true; this.infolistname(); // this.openfalse(); }, //wangeditor传值 onNodeContent(item) { if (item.nodeContent) { this.form.nodeContent = item.nodeContent; var abc = new RegExp("
", "g"); var bbb = this.form.nodeContent.replace(abc, ""); this.form.nodeContent = bbb; } }, //小程序传值 miniProgramtemplate(item) { this.form.appletTemplateId = item.templateId; this.form.appletTemplateName = item.templateName; this.form.appletRemindContent = item.templateContent; }, // 话术 messageontemplateword(item) { this.form.phoneTemplateId = item.templateId; this.form.phoneTemplateName = item.templateName; console.log(this.form.phoneTemplateId, ' this.form.phoneTemplateId') // this.form.messagePreview = item.templateContent; }, //短信传值 messageontemplate(item) { this.form.messageTemplateId = item.templateId; this.form.messageTemplateName = item.templateName; this.form.messagePreview = item.templateContent; }, // 短信 messageontemplateMESSAGE(item) { this.form.phoneMessageTemplateId = item.templateId; this.form.phoneMessageTemplateName = item.templateName; this.form.messagePreview = item.templateContent; }, //公众号传值 officialAccountontemplate(item) { this.form.officialTemplateId = item.templateId; this.form.officialTemplateName = item.templateName; this.form.officialRemindContent = item.templateContent; }, // 暂存 TemporaryStorage() { if ( this.form.taskSubdivisiontemplateType != "QUESTIONNAIRE" && this.form.taskSubdivisiontemplateType != "PROPAGANDA" && this.form.taskSubdivisiontemplateType != 'SCRIPT' ) { this.$refs.wangeditor.emit(); } this.$confirm( "确认暂存时将过滤掉部分内容未填写完成的子节点,是否确认暂存?", "提示", { confirmButtonText: "确认", cancelButtonText: "取消", } ).then(() => { const loading = this.$loading({ lock: true, text: "暂存中", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", }); this.itemlist.specialDiseaseNodeList = []; this.lists.forEach((e) => { e.list.length > 0 ? e.list.forEach((el) => { el.routeNodeDay = e.routeNodeDay; el.routeNodeName = e.routeNodeName; this.itemlist.specialDiseaseNodeList.push(el); }) : ""; }); // this.updata.specialDiseaseNodeList = // this.updata.specialDiseaseNodeList.filter( // (e) => // !e.routeNodeDay && // !e.routeNodeName && // !e.taskType && // !e.taskSubdivision && // !e.taskStatus // ); console.log(this.itemlist, 'itemlist') // return specialDiseaseNode(this.itemlist).then((res) => { this.info(); loading.close(); this.$modal.msgSuccess("暂存成功!"); }); setTimeout(() => { loading.close(); }, 3000); }); }, //问卷传值 questionontemplate(item) { this.form.templateId = item.templateId; this.form.templateName = item.templateName; }, //宣教传值 propagandaontemplate(item) { this.form.templateId = item.templateId; this.form.templateName = item.templateName; }, bottomclickevent(uitem, index, uindex) { if ( this.form.taskSubdivisiontemplateType != "QUESTIONNAIRE" && this.form.taskSubdivisiontemplateType != "PROPAGANDA" && this.form.taskSubdivisiontemplateType != 'SCRIPT' ) { this.$refs.wangeditor.emit(); } setTimeout(() => { this.form = uitem; this.taskPartitionList = []; if (this.form.taskType) { this.changeTaskType(this.form.taskType, this.form.taskSubdivision); } this.listindex = index; this.itemindex = uindex; }, 300); }, handleStep() { this.active = 2; }, //任务类型 任务状态 taskinfo() { selectTaskTypeList().then((res) => { this.selectTaskTypeList = res.data; this.info(); }); }, //任务类型 changeTaskType(code, taskSubdivision) { let id = this.selectTaskTypeList?.find((e) => e.taskTypeCode == code)?.id; this.form.taskTypeName = this.selectTaskTypeList?.find( (e) => e.taskTypeCode == code )?.taskTypeName; taskPartitionList(id).then((res) => { this.taskPartitionList = res.data; this.form.taskSubdivision = ""; this.form.taskSubdivisionName = ""; this.form.taskSubdivisiontemplateType = ""; this.taskStatusDictList = []; if (taskSubdivision) { this.form.taskSubdivision = taskSubdivision; this.changetaskSubdivision(taskSubdivision, 1); } }); }, //点击任务细分 changetaskSubdivision(code, type) { this.form.taskSubdivisionName = this.taskPartitionList?.find( (e) => e.taskPartitionCode == code )?.taskPartitionName; let id = this.taskPartitionList?.find( (e) => e.taskPartitionCode == code )?.id; this.form.secondClassifyDescribe = this.taskPartitionList?.find( (e) => e.taskPartitionCode == code )?.secondClassifyDescribe; this.form.executionTime = this.taskPartitionList?.find( (e) => e.taskPartitionCode == code )?.executionTime; taskStatusDictList(id).then((res) => { this.taskStatusDictList = res.data; }); this.taskPartitionList.forEach((el) => { if (code == el.taskPartitionCode) { this.form.executionTime = el.executionTime; this.form.taskSubdivisiontemplateType = el.templateType; if ( this.form.taskSubdivisiontemplateType == "SCRIPT" || this.form.taskSubdivisiontemplateType == "PROPAGANDA" || this.form.taskSubdivisiontemplateType == "QUESTIONNAIRE" ) { this.form.nodeContent = `

`; } if (!type) { this.form.templateId = ""; this.form.templateName = ""; } } }); }, // 添加管理路径节点 addlist() { list(this.parentDictCode).then((res) => { // this.parentDictCodelist = res.rows; res.rows.forEach((e) => { this.lists.forEach((el) => { el.routeNodeName = e.dictLabel; }); }); }); this.lists.push({ routeNodeName: "", routeNodeDay: "", list: [ { nodeContent: "

", templateId: "", templateName: "", taskType: "", officialRemindContent: "", taskSubdivision: "", taskSubdivisionName: "", appletRemindContent: "", appletPromptDescription: "", taskStatus: "", secondClassifyDescribe: "", executionTime: "", appletPushSign: "0", officialPushSign: "0", messagePushSign: "0", messagePreview: "", taskSubdivisiontemplateType: "", }, ], }); // }, }, // 添加节点 additem(item) { item.list.push({ nodeContent: "

", templateId: "", templateName: "", taskType: "", officialRemindContent: "", taskSubdivision: "", taskSubdivisionName: "", appletRemindContent: "", appletPromptDescription: "", taskStatus: "", secondClassifyDescribe: "", executionTime: "", appletPushSign: "0", officialPushSign: "0", messagePushSign: "0", messagePreview: "", taskSubdivisiontemplateType: "", }); }, // 删除节点 delitemh(item, index) { item.list.splice(this.itemindex, 1); if (item.list.length == 0) { this.lists.splice(index, 1); } }, }, }; //