Commit 718f3a0e31ddf27fb00e4cb4e045bc1850a208ab
1 parent
c3fe5dc0
debug role permission
Showing
1 changed file
with
11 additions
and
9 deletions
src/views/role/permission.vue
| @@ -18,7 +18,6 @@ let form = reactive({ | @@ -18,7 +18,6 @@ let form = reactive({ | ||
| 18 | }, | 18 | }, |
| 19 | loading: false, | 19 | loading: false, |
| 20 | permissions: [], | 20 | permissions: [], |
| 21 | - defaultPermissions: [], | ||
| 22 | collections: [], | 21 | collections: [], |
| 23 | }); | 22 | }); |
| 24 | const ruleFormRef = ref<InstanceType<typeof ElForm>>(); | 23 | const ruleFormRef = ref<InstanceType<typeof ElForm>>(); |
| @@ -28,7 +27,6 @@ const addTreeTest = ref<InstanceType<typeof ElTree>>(); | @@ -28,7 +27,6 @@ const addTreeTest = ref<InstanceType<typeof ElTree>>(); | ||
| 28 | */ | 27 | */ |
| 29 | const resetForm = (formEl: InstanceType<typeof ElForm> | undefined) => { | 28 | const resetForm = (formEl: InstanceType<typeof ElForm> | undefined) => { |
| 30 | if (!formEl) return; | 29 | if (!formEl) return; |
| 31 | - form.defaultPermissions = []; | ||
| 32 | addTreeTest.value!.setCheckedNodes([]); | 30 | addTreeTest.value!.setCheckedNodes([]); |
| 33 | formEl.resetFields(); | 31 | formEl.resetFields(); |
| 34 | }; | 32 | }; |
| @@ -36,7 +34,7 @@ const resetForm = (formEl: InstanceType<typeof ElForm> | undefined) => { | @@ -36,7 +34,7 @@ const resetForm = (formEl: InstanceType<typeof ElForm> | undefined) => { | ||
| 36 | * 表单提交 | 34 | * 表单提交 |
| 37 | */ | 35 | */ |
| 38 | const submitForm = (formEl: InstanceType<typeof ElForm> | undefined) => { | 36 | const submitForm = (formEl: InstanceType<typeof ElForm> | undefined) => { |
| 39 | - form.loading = true | 37 | + form.loading = true; |
| 40 | if (!formEl) return; | 38 | if (!formEl) return; |
| 41 | formEl.validate((valid) => { | 39 | formEl.validate((valid) => { |
| 42 | if (valid) { | 40 | if (valid) { |
| @@ -49,12 +47,13 @@ const submitForm = (formEl: InstanceType<typeof ElForm> | undefined) => { | @@ -49,12 +47,13 @@ const submitForm = (formEl: InstanceType<typeof ElForm> | undefined) => { | ||
| 49 | }) | 47 | }) |
| 50 | .catch((error) => { | 48 | .catch((error) => { |
| 51 | console.log(error); | 49 | console.log(error); |
| 52 | - }).finally (() => { | ||
| 53 | - form.loading = false | ||
| 54 | }) | 50 | }) |
| 51 | + .finally(() => { | ||
| 52 | + form.loading = false; | ||
| 53 | + }); | ||
| 55 | } else { | 54 | } else { |
| 56 | globalProperties.$message.error("请检查表单格式"); | 55 | globalProperties.$message.error("请检查表单格式"); |
| 57 | - form.loading = false | 56 | + form.loading = false; |
| 58 | return false; | 57 | return false; |
| 59 | } | 58 | } |
| 60 | }); | 59 | }); |
| @@ -67,7 +66,7 @@ const getPermissions = async (roleId = useRoute().query.roleId) => { | @@ -67,7 +66,7 @@ const getPermissions = async (roleId = useRoute().query.roleId) => { | ||
| 67 | try { | 66 | try { |
| 68 | let res = await rolePermission({ roleId: roleId }); | 67 | let res = await rolePermission({ roleId: roleId }); |
| 69 | form.permissions = res?.data?.data; | 68 | form.permissions = res?.data?.data; |
| 70 | - form.defaultPermissions = getCheckedPermissions(res?.data?.data); | 69 | + form.data.permissionIds = getCheckedPermissions(res?.data?.data); |
| 71 | } catch (e) { | 70 | } catch (e) { |
| 72 | console.log(e); | 71 | console.log(e); |
| 73 | } | 72 | } |
| @@ -146,7 +145,7 @@ onMounted(() => { | @@ -146,7 +145,7 @@ onMounted(() => { | ||
| 146 | :data="form.permissions" | 145 | :data="form.permissions" |
| 147 | :props="defaultProps" | 146 | :props="defaultProps" |
| 148 | :check-strictly="true" | 147 | :check-strictly="true" |
| 149 | - :default-checked-keys="form.defaultPermissions" | 148 | + :default-checked-keys="form.data.permissionIds" |
| 150 | node-key="id" | 149 | node-key="id" |
| 151 | ref="addTreeTest" | 150 | ref="addTreeTest" |
| 152 | show-checkbox | 151 | show-checkbox |
| @@ -154,7 +153,10 @@ onMounted(() => { | @@ -154,7 +153,10 @@ onMounted(() => { | ||
| 154 | /> | 153 | /> |
| 155 | </el-form-item> | 154 | </el-form-item> |
| 156 | <el-form-item style="width: 100%"> | 155 | <el-form-item style="width: 100%"> |
| 157 | - <el-button type="primary" @click.prevent="submitForm(ruleFormRef)" :loading="form.loading" | 156 | + <el-button |
| 157 | + type="primary" | ||
| 158 | + @click.prevent="submitForm(ruleFormRef)" | ||
| 159 | + :loading="form.loading" | ||
| 158 | >提交</el-button | 160 | >提交</el-button |
| 159 | > | 161 | > |
| 160 | <el-button type="info" @click="resetForm(ruleFormRef)" | 162 | <el-button type="info" @click="resetForm(ruleFormRef)" |