Browse Source

#I24D3P后台-系统管理-部门管理,编辑最上级部门,提示“上级部门不能为空”

master
xuwenbo 4 years ago
parent
commit
5aaae5a3ab
  1. 77
      src/views/system/dept/index.vue

77
src/views/system/dept/index.vue

@ -113,23 +113,83 @@ export default {
} }
}, },
methods: { methods: {
getDeptDatas(tree, treeNode, resolve) {
const params = { pid: tree.id }
setTimeout(() => {
crudDept.getDepts(params).then(res => {
resolve(res.content)
})
}, 100)
},
// //
[CRUD.HOOK.afterToCU](crud, form) { [CRUD.HOOK.afterToCU](crud, form) {
if (form.pid !== null) {
form.isTop = '0'
} else if (form.id !== null) {
form.isTop = '1'
}
form.enabled = `${form.enabled}` form.enabled = `${form.enabled}`
// if (form.id != null) {
this.getSupDepts(form.id)
} else {
this.getDepts()
}
},
getSupDepts(id) {
crudDept.getDeptSuperior(id).then(res => {
const date = res.content
this.buildDepts(date)
this.depts = date
})
},
buildDepts(depts) {
depts.forEach(data => {
if (data.children) {
this.buildDepts(data.children)
}
if (data.hasChildren && !data.children) {
data.children = null
}
})
},
getDepts() {
crudDept.getDepts({ enabled: true }).then(res => { crudDept.getDepts({ enabled: true }).then(res => {
this.depts = res.content this.depts = res.content.map(function(obj) {
if (obj.hasChildren) {
obj.children = null
}
return obj
})
}) })
}, },
//
loadDepts({ action, parentNode, callback }) {
if (action === LOAD_CHILDREN_OPTIONS) {
crudDept.getDepts({ enabled: true, pid: parentNode.id }).then(res => {
parentNode.children = res.content.map(function(obj) {
if (obj.hasChildren) {
obj.children = null
}
return obj
})
setTimeout(() => {
callback()
}, 100)
})
}
},
// //
[CRUD.HOOK.afterValidateCU]() { [CRUD.HOOK.afterValidateCU]() {
if (!this.form.pid) { if (this.form.pid !== null && this.form.pid === this.form.id) {
this.$message({ this.$message({
message: '上级部门不能为空', message: '上级部门不能为空',
type: 'warning' type: 'warning'
}) })
return false return false
} }
if (this.form.isTop === '1') {
this.form.pid = null
}
return true return true
}, },
// //
@ -156,5 +216,14 @@ export default {
} }
</script> </script>
<style scoped> <style rel="stylesheet/scss" lang="scss" scoped>
::v-deep .vue-treeselect__control,::v-deep .vue-treeselect__placeholder,::v-deep .vue-treeselect__single-value {
height: 30px;
line-height: 30px;
}
</style>
<style rel="stylesheet/scss" lang="scss" scoped>
::v-deep .el-input-number .el-input__inner {
text-align: left;
}
</style> </style>

Loading…
Cancel
Save