diff --git a/src/views/system/role/RoleMenuModal.vue b/src/views/system/role/RoleMenuModal.vue index 83fc3248..7aa4c1e5 100644 --- a/src/views/system/role/RoleMenuModal.vue +++ b/src/views/system/role/RoleMenuModal.vue @@ -32,8 +32,8 @@ const { t } = useI18n() const { createMessage } = useMessage() const emit = defineEmits(['success', 'register']) const treeData = ref([]) -const menuKeys = ref<(string | number)[]>([]) -const menuHalfKeys = ref<(string | number)[]>([]) +const menuKeys = ref([]) +const menuHalfKeys = ref([]) const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({ labelWidth: 120, @@ -54,28 +54,19 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data const res = await getRole(data.record.id) const menuRes = await listRoleMenus(data.record.id) - res.roleId = data.record.id res.menuIds = menuRes menuKeys.value = res.menuIds setFieldsValue({ ...res }) }) -function menuCheck(checkedKeys, e) { - menuKeys.value = checkedKeys as (string | number)[] - menuHalfKeys.value = e.halfCheckedKeys as (string | number)[] -} - -function menuReset() { - menuKeys.value = [] - menuHalfKeys.value = [] -} - async function handleSubmit() { try { const values = await validate() - values.menuIds = menuKeys.value.concat(menuHalfKeys.value) setModalProps({ confirmLoading: true }) - await assignRoleMenu(values) + await assignRoleMenu({ + roleId: values.id, + menuIds: menuKeys.value.concat(menuHalfKeys.value) + }) closeModal() emit('success') } finally { @@ -83,4 +74,14 @@ async function handleSubmit() { setModalProps({ confirmLoading: false }) } } + +function menuReset() { + menuKeys.value = [] + menuHalfKeys.value = [] +} + +function menuCheck(checkedKeys, e) { + menuKeys.value = checkedKeys.checked as number[] + menuHalfKeys.value = e.halfCheckedKeys as number[] +} diff --git a/src/views/system/role/role.data.ts b/src/views/system/role/role.data.ts index abf75ee4..9e245150 100644 --- a/src/views/system/role/role.data.ts +++ b/src/views/system/role/role.data.ts @@ -123,7 +123,7 @@ export const formSchema: FormSchema[] = [ export const menuScopeFormSchema: FormSchema[] = [ { label: '角色编号', - field: 'roleId', + field: 'id', show: false, component: 'Input' }, diff --git a/src/views/system/tenantPackage/TenantPackageModal.vue b/src/views/system/tenantPackage/TenantPackageModal.vue index fac4766a..69ce1455 100644 --- a/src/views/system/tenantPackage/TenantPackageModal.vue +++ b/src/views/system/tenantPackage/TenantPackageModal.vue @@ -55,22 +55,11 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data if (unref(isUpdate)) { const res = await getTenantPackage(data.record.id) - res.menuIds.checked = res.menuIds menuKeys.value = res.menuIds setFieldsValue({ ...res }) } }) -function menuCheck(checkedKeys, e) { - menuKeys.value = checkedKeys as (string | number)[] - menuHalfKeys.value = e.halfCheckedKeys as (string | number)[] -} - -function menuReset() { - menuKeys.value = [] - menuHalfKeys.value = [] -} - async function handleSubmit() { try { const values = await validate() @@ -88,4 +77,14 @@ async function handleSubmit() { setModalProps({ confirmLoading: false }) } } + +function menuReset() { + menuKeys.value = [] + menuHalfKeys.value = [] +} + +function menuCheck(checkedKeys, e) { + menuKeys.value = checkedKeys as (string | number)[] + menuHalfKeys.value = e.halfCheckedKeys as (string | number)[] +}