From 4d7f07dd33e0c1ea5cde5cde1ad6340be80692e2 Mon Sep 17 00:00:00 2001 From: K <1175047471@qq.com> Date: Wed, 20 Mar 2024 10:36:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=87=92=E5=8A=A0=E8=BD=BD=E6=97=A0?= =?UTF-8?q?=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/dept/index.vue | 30 ++++++++++++++++-------------- src/views/system/role/index.vue | 30 ++++++++++++++++-------------- 2 files changed, 32 insertions(+), 28 deletions(-) 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: {