增加任务流程修改未保存校验

master
面包骑士 2024-09-03 23:37:29 +08:00
parent 75ab3073b4
commit bd7d5997ab
1 changed files with 54 additions and 9 deletions

View File

@ -128,15 +128,24 @@ export default {
top: r.node.top, top: r.node.top,
left: r.node.left 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) { if (r.line) {
r.line.forEach(v => { r.line.forEach(v => {
this.data.lineList.push({ this.data.lineList.push({
from: v.from, from: v.from,
to: v.to, to: v.to
label: "连线名称", });
id: GenNonDuplicateID(8), this.checkData.lineList.push({
Remark: "" from: v.from,
to: v.to
}); });
}) })
} }
@ -145,8 +154,8 @@ export default {
this.nodeHandle() this.nodeHandle()
// 线 // 线
this.data.lineList = this.lineHandle(this.data.lineList) this.data.lineList = this.lineHandle(this.data.lineList)
this.checkData.lineList = this.lineHandle(this.data.lineList)
}) })
this.flag = true
}, },
// - // -
nodeHandle() { nodeHandle() {
@ -200,18 +209,53 @@ export default {
// 3. // 3.
batch(nodeData,this.$route.query.taskCode).then(res => { batch(nodeData,this.$route.query.taskCode).then(res => {
this.$message.success(res.msg) this.$message.success(res.msg)
this.flag = true
}) })
console.log(nodeData) console.log(nodeData)
}, },
//
returnBack() { 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'}) this.$router.push({path: '/quest/task'})
}else{ }else{
this.checkReturn() 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() { checkReturn() {
this.$confirm('更改未保存,是否保存?', '未保存提示', { this.$confirm('更改未保存,是否保存?', '未保存提示', {
confirmButtonText: '保存', confirmButtonText: '保存',
@ -219,13 +263,14 @@ export default {
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.save() this.save()
this.$router.push({path: '/quest/task'})
}).catch(() => { }).catch(() => {
this.$message({ this.$message({
type: 'success', type: 'success',
message: '返回成功' message: '返回成功'
}); });
});
this.$router.push({path: '/quest/task'}) this.$router.push({path: '/quest/task'})
});
}, },
// //
checkFlag(){ checkFlag(){