编辑禁用上级选项

This commit is contained in:
13218645326 2023-12-21 20:44:28 +08:00
parent 4990efa585
commit 5c50ce4706
1 changed files with 7 additions and 30 deletions

View File

@ -61,7 +61,7 @@
<el-row>
<el-col :span="24">
<el-form-item label="上级" prop="currentId">
<el-cascader v-model="form.currentId" :options="deptOptions"
<el-cascader v-model="form.currentId" :options="deptOptions" :disabled="isEdit"
:props="{ expandTrigger: 'hover', label: 'label', value: 'id', checkStrictly: true }"
@change="handleNodeClick"> </el-cascader>
</el-form-item>
@ -170,23 +170,19 @@ export default {
}
]
},
isEdit:false
};
},
created() {
this.getList();
// this.initApiGetPartTree()
},
methods: {
/** 查询部门列表 */
getList() {
// this.loading = true;
listPartType(this.queryParams).then(response => {
console.log("response", response)
this.deptList = this.handleTree(response.data, "paId");
// this.deptList = response.data
this.loading = false;
}).catch(err => {
console.log("err", err)
@ -235,11 +231,9 @@ export default {
/** 新增按钮操作 */
handleAdd() {
this.reset();
// if (row != undefined) {
// this.form.currentId = row.paId;
// }
this.open = true;
this.title = "添加";
this.isEdit = false
this.initApiGetPartTree()
},
@ -247,7 +241,6 @@ export default {
toggleExpandAll() {
this.refreshTable = false;
this.isExpandAll = !this.isExpandAll;
console.log("isExpandAll", this.isExpandAll)
this.$nextTick(() => {
this.refreshTable = true;
});
@ -255,23 +248,20 @@ export default {
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
// getDept(row.paId).then(response => {
// this.form = row;
this.open = true;
this.title = "修改部门";
this.isEdit = true
this.initGetPartType(row)
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
console.log("ressearchTreeform", this.form)
if (this.form.paId != undefined) {
delete this.form.currentId
updatePartTypeById(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
@ -287,22 +277,16 @@ export default {
async initApiGetPartTree() {
try {
const res = await apiGetPartTree()
console.log("res--apiGetPartTree", res)
this.deptOptions = res.data
} catch (error) {
}
},
handleNodeClick(ev) {
console.log("scurrentIdcurrentIdcurrentId", ev)
const res = this.searchTree(this.deptOptions,this.form.currentId&&this.form.currentId.length > 0 ? this.form.currentId.slice(-1)[0] : {})
console.log("ressearchTreeres", res)
if(res){
const res = this.searchTree(this.deptOptions, this.form.currentId && this.form.currentId.length > 0 ? this.form.currentId.slice(-1)[0] : {})
if (res) {
this.form.parentId = res.id
this.form.level = Number(res.level) + 1
}
},
/** 删除按钮操作 */
handleDelete(row) {
@ -346,20 +330,13 @@ export default {
}
},
handleRowClick(ev) {
console.log("handleRowClick", ev)
this.form.currentId = row.parentId;
}
,
async initGetPartType(row) {
console.log("rowgetPartType",row)
// const res = await getPartType(row.paId)
const currentItem = this.getAllParentArr(this.deptList, row.parentId, 'parentId', 'children')
console.log("currcurrentItemetn", currentItem)
this.form = JSON.parse(JSON.stringify(row))
this.form = JSON.parse(JSON.stringify(row))
this.form.currentId = currentItem && currentItem.reverse().map(ele => ele.paId)
console.log
// this.form = res.data
this.initApiGetPartTree()
}
}