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