diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue index 5ebf588a..2fbee31d 100644 --- a/src/views/system/dept/index.vue +++ b/src/views/system/dept/index.vue @@ -8,7 +8,7 @@ import { useModal } from '@/components/Modal' import { IconEnum } from '@/enums/appEnum' import { BasicTable, TableAction, useTable } from '@/components/Table' import { deleteDept, lazyGetDeptList } from '@/api/system/dept' -import type { Department } from '@/api/system/dept/types' +import type { Department, LazyGetDeptListParams } from '@/api/system/dept/types' import { usePermission } from '@/hooks/web/usePermission' defineOptions({ name: 'SystemDept' }) @@ -19,21 +19,23 @@ const [registerModal, { openModal }] = useModal() const { hasPermission } = usePermission() +async function lazyGetDeptListWrap(params: LazyGetDeptListParams) { + try { + const list = await lazyGetDeptList(params) + return list.map(item => ({ + ...item, + children: item.hasChildren ? [] : undefined, + })) + } + catch { + return [] + } +} + const [register, { reload }] = useTable({ - async api(params) { - try { - const list = await lazyGetDeptList(params) - return list.map(item => ({ - ...item, - children: item.hasChildren ? [] : undefined, - })) - } - catch { - return [] - } - }, + api: lazyGetDeptListWrap, load(record) { - return lazyGetDeptList({ parentId: record.id }) + return lazyGetDeptListWrap({ parentId: record.id }) }, columns, formConfig: { diff --git a/src/views/system/role/index.vue b/src/views/system/role/index.vue index b07b980f..5625e37c 100644 --- a/src/views/system/role/index.vue +++ b/src/views/system/role/index.vue @@ -7,7 +7,7 @@ import { useMessage } from '@/hooks/web/useMessage' import { useModal } from '@/components/Modal' import { BasicTable, TableAction, useTable } from '@/components/Table' import { deleteRole, lazyGetRoleList } from '@/api/system/role' -import type { Role } from '@/api/system/role/types' +import type { GetRoleListParams, Role } from '@/api/system/role/types' import { usePermission } from '@/hooks/web/usePermission' defineOptions({ name: 'SystemRole' }) @@ -18,21 +18,23 @@ const [registerMenuModal, { openModal: openMenuModal }] = useModal() const { hasPermission } = usePermission() +async function lazyGetRoleListWrap(params: GetRoleListParams) { + try { + const list = await lazyGetRoleList(params) + return list.map(item => ({ + ...item, + children: item.hasChildren ? [] : undefined, + })) + } + catch { + return [] + } +} + const [registerTable, { reload }] = useTable({ - async api(params) { - try { - const list = await lazyGetRoleList(params) - return list.map(item => ({ - ...item, - children: item.hasChildren ? [] : undefined, - })) - } - catch { - return [] - } - }, + api: lazyGetRoleListWrap, load(record) { - return lazyGetRoleList({ parentId: record.id }) + return lazyGetRoleListWrap({ parentId: record.id }) }, columns, formConfig: {