From bd7d5997abc52721563f83adbab39d93582bce0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=91=E5=B9=B4=E6=A2=A6=E4=B8=8E=E7=A0=96?= <2847127106@qq.com> Date: Tue, 3 Sep 2024 23:37:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BB=BB=E5=8A=A1=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E4=BF=AE=E6=94=B9=E6=9C=AA=E4=BF=9D=E5=AD=98=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/quest/node/Home.vue | 63 ++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 9 deletions(-) diff --git a/src/views/quest/node/Home.vue b/src/views/quest/node/Home.vue index 23e0ccf..123771a 100644 --- a/src/views/quest/node/Home.vue +++ b/src/views/quest/node/Home.vue @@ -128,15 +128,24 @@ export default { top: r.node.top, left: r.node.left }) + this.checkData.nodeList.push({ + id: r.node.id, + type: r.node.type, + typeName: r.node.typeName, + nodeName: r.node.nodeName, + top: r.node.top, + left: r.node.left + }) // 连线添加 if (r.line) { r.line.forEach(v => { this.data.lineList.push({ from: v.from, - to: v.to, - label: "连线名称", - id: GenNonDuplicateID(8), - Remark: "" + to: v.to + }); + this.checkData.lineList.push({ + from: v.from, + to: v.to }); }) } @@ -145,8 +154,8 @@ export default { this.nodeHandle() // 连线去重 this.data.lineList = this.lineHandle(this.data.lineList) + this.checkData.lineList = this.lineHandle(this.data.lineList) }) - this.flag = true }, // 节点批量处理-初始化 nodeHandle() { @@ -200,18 +209,53 @@ export default { // 3. 激活接口将参数传递到后端 batch(nodeData,this.$route.query.taskCode).then(res => { this.$message.success(res.msg) - this.flag = true }) console.log(nodeData) }, + // 返回校验 returnBack() { - if (this.flag){ + const newNodeList = this.data.nodeList + const oldNodeList = this.checkData.nodeList + const newLineList = this.data.lineList + const oldLineList = this.checkData.lineList + // this.$router.push({path: '/quest/task'}) + if (this.checkNodeList(newNodeList,oldNodeList) && this.checkLineList(newLineList,oldLineList)){ this.$router.push({path: '/quest/task'}) }else{ this.checkReturn() } - }, + // 节点校验 + checkNodeList(newNodeList, oldNodeList) { + let newLen = newNodeList.length + let oldLen = oldNodeList.length + if (newLen !== oldLen) return false; + for (let i = 0; i < newLen; i++) { + if (newNodeList[i].id === oldNodeList[i].id && + newNodeList[i].nodeName === oldNodeList[i].nodeName && + newNodeList[i].type === oldNodeList[i].type && + newNodeList[i].left === oldNodeList[i].left && + newNodeList[i].top === oldNodeList[i].top){ + continue; + } + return false; + } + return true; + }, + checkLineList(newLineList,oldLineList) { + let newLen = newLineList.length + let oldLen = oldLineList.length + if (newLen !== oldLen) return false; + for (let i = 0; i < newLen; i++) { + if (newLineList[i].from === oldLineList[i].from && + newLineList[i].to === oldLineList[i].to){ + continue; + } + return false; + } + return true; + }, + // 未保存 返回按钮 checkReturn() { this.$confirm('更改未保存,是否保存?', '未保存提示', { confirmButtonText: '保存', @@ -219,13 +263,14 @@ export default { type: 'warning' }).then(() => { this.save() + this.$router.push({path: '/quest/task'}) }).catch(() => { this.$message({ type: 'success', message: '返回成功' }); + this.$router.push({path: '/quest/task'}) }); - this.$router.push({path: '/quest/task'}) }, // 修改状态更新 checkFlag(){