fix: BUG修改
This commit is contained in:
parent
f651ba04c1
commit
77de79e60c
@ -132,6 +132,13 @@ const rules = reactive<FormRules>({
|
||||
message: "请输入角色顺序",
|
||||
trigger: "blur"
|
||||
}
|
||||
],
|
||||
sn: [
|
||||
{
|
||||
required: true,
|
||||
message: "请选择指定类型",
|
||||
trigger: "blur"
|
||||
}
|
||||
]
|
||||
});
|
||||
const treeRef = ref(null);
|
||||
@ -249,9 +256,21 @@ const transfrom = (arr: Array<any>) => {
|
||||
|
||||
const confirm = async () => {
|
||||
const checked = treeRef.value.getCheckedNodes();
|
||||
await editRolePermissions(transfrom(checked));
|
||||
drawerVisible.value = false;
|
||||
datas.length = 0;
|
||||
const halfChecked = treeRef.value.getHalfCheckedNodes();
|
||||
const checkedArr = transfrom(checked);
|
||||
const halfCheckedArr = transfrom(halfChecked);
|
||||
const concatArr: any = checkedArr.concat(halfCheckedArr);
|
||||
if (!concatArr.length) {
|
||||
ElMessage.error("请选择");
|
||||
} else {
|
||||
await editRolePermissions(concatArr);
|
||||
drawerVisible.value = false;
|
||||
datas.length = 0;
|
||||
}
|
||||
// const checked = treeRef.value.getCheckedNodes();
|
||||
// await editRolePermissions(transfrom(checked));
|
||||
// drawerVisible.value = false;
|
||||
// datas.length = 0;
|
||||
};
|
||||
|
||||
// 如果你想在请求之前对当前请求参数做一些操作,可以自定义如下函数:params 为当前所有的请求参数(包括分页),最后返回请求列表接口
|
||||
@ -302,9 +321,27 @@ const handleEditItem = async (row: any) => {
|
||||
const res = await getTreeByIdList({ roleId: row.roleId });
|
||||
// 打开弹窗时调用上面的接口勾选
|
||||
nextTick(() => {
|
||||
treeRef.value.setCheckedKeys(res.result.map(item => item.authorityId));
|
||||
// treeRef.value.setCheckedKeys(res.result.map(item => item.authorityId));
|
||||
treeRef.value.setCheckedKeys(getRelativeKeys(res.result));
|
||||
});
|
||||
};
|
||||
// 根据条件获取需要选中的节点keys
|
||||
const getRelativeKeys = (arr: any) => {
|
||||
let keysArr = [] as any;
|
||||
arr.map(item => {
|
||||
if (item.type == 0 && item.children == 0) {
|
||||
keysArr.push(item.authorityId);
|
||||
}
|
||||
if (item.type == 1 && item.children == 0) {
|
||||
keysArr.push(item.authorityId);
|
||||
}
|
||||
if (item.type != 0 && item.type != 1 && !item.children) {
|
||||
keysArr.push(item.authorityId);
|
||||
}
|
||||
});
|
||||
return keysArr;
|
||||
};
|
||||
|
||||
const saveItem = async (formEl: FormInstance | undefined, form: any) => {
|
||||
// 标记表单校验
|
||||
if (!formEl) return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user