|
|
|
@ -186,8 +186,6 @@ export default {
|
|
|
|
name: "Template",
|
|
|
|
name: "Template",
|
|
|
|
data() {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
detail: {},
|
|
|
|
|
|
|
|
items: [],
|
|
|
|
|
|
|
|
// 遮罩层
|
|
|
|
// 遮罩层
|
|
|
|
loading: true,
|
|
|
|
loading: true,
|
|
|
|
// 选中数组
|
|
|
|
// 选中数组
|
|
|
|
@ -295,9 +293,7 @@ export default {
|
|
|
|
this.reset()
|
|
|
|
this.reset()
|
|
|
|
const id = row.id || this.ids
|
|
|
|
const id = row.id || this.ids
|
|
|
|
getTemplate(id).then(response => {
|
|
|
|
getTemplate(id).then(response => {
|
|
|
|
this.form = {...response.data};
|
|
|
|
this.form = response.data
|
|
|
|
this.detail = {...response.data};
|
|
|
|
|
|
|
|
this.items = [...response.data.items];
|
|
|
|
|
|
|
|
this.open = true
|
|
|
|
this.open = true
|
|
|
|
this.title = "修改考核模板"
|
|
|
|
this.title = "修改考核模板"
|
|
|
|
})
|
|
|
|
})
|
|
|
|
@ -308,20 +304,11 @@ export default {
|
|
|
|
if (valid) {
|
|
|
|
if (valid) {
|
|
|
|
if(this.form.items.length>0){
|
|
|
|
if(this.form.items.length>0){
|
|
|
|
if (this.form.id != null) {
|
|
|
|
if (this.form.id != null) {
|
|
|
|
let ids = this.items.map(item => item.id).sort((a, b) => a - b);;
|
|
|
|
|
|
|
|
let ids1 = this.form.items.map(item => item.id).sort((a, b) => a - b);;
|
|
|
|
|
|
|
|
console.log(ids,ids1, this.arraysEqual(ids,ids1));
|
|
|
|
|
|
|
|
if(!(this.detail.temName === this.form.temName && this.detail.remark === this.form.remark && this.arraysEqual(ids,ids1))){
|
|
|
|
|
|
|
|
updateTemplate(this.form).then(response => {
|
|
|
|
updateTemplate(this.form).then(response => {
|
|
|
|
this.$modal.msgSuccess("修改成功")
|
|
|
|
this.$modal.msgSuccess("修改成功")
|
|
|
|
this.open = false
|
|
|
|
this.open = false
|
|
|
|
this.getList()
|
|
|
|
this.getList()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}else {
|
|
|
|
|
|
|
|
this.$alert(`数据未发生变化,如不需要修改,请直接点击取消按钮!`, `提示`, {
|
|
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
addTemplate(this.form).then(response => {
|
|
|
|
addTemplate(this.form).then(response => {
|
|
|
|
this.$modal.msgSuccess("新增成功")
|
|
|
|
this.$modal.msgSuccess("新增成功")
|
|
|
|
@ -429,9 +416,6 @@ export default {
|
|
|
|
delKhitemList(row,index){
|
|
|
|
delKhitemList(row,index){
|
|
|
|
this.form.items.splice(index,1)
|
|
|
|
this.form.items.splice(index,1)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
arraysEqual(a, b) {
|
|
|
|
|
|
|
|
return JSON.stringify(a.sort()) === JSON.stringify(b.sort());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|