Browse Source

fix: 懒加载无效

main
刘凯 1 year ago
parent
commit
4d7f07dd33
  1. 30
      src/views/system/dept/index.vue
  2. 30
      src/views/system/role/index.vue

30
src/views/system/dept/index.vue

@ -8,7 +8,7 @@ import { useModal } from '@/components/Modal'
import { IconEnum } from '@/enums/appEnum' import { IconEnum } from '@/enums/appEnum'
import { BasicTable, TableAction, useTable } from '@/components/Table' import { BasicTable, TableAction, useTable } from '@/components/Table'
import { deleteDept, lazyGetDeptList } from '@/api/system/dept' 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' import { usePermission } from '@/hooks/web/usePermission'
defineOptions({ name: 'SystemDept' }) defineOptions({ name: 'SystemDept' })
@ -19,21 +19,23 @@ const [registerModal, { openModal }] = useModal<Department>()
const { hasPermission } = usePermission() 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<Department>({ const [register, { reload }] = useTable<Department>({
async api(params) { api: lazyGetDeptListWrap,
try {
const list = await lazyGetDeptList(params)
return list.map(item => ({
...item,
children: item.hasChildren ? [] : undefined,
}))
}
catch {
return []
}
},
load(record) { load(record) {
return lazyGetDeptList({ parentId: record.id }) return lazyGetDeptListWrap({ parentId: record.id })
}, },
columns, columns,
formConfig: { formConfig: {

30
src/views/system/role/index.vue

@ -7,7 +7,7 @@ import { useMessage } from '@/hooks/web/useMessage'
import { useModal } from '@/components/Modal' import { useModal } from '@/components/Modal'
import { BasicTable, TableAction, useTable } from '@/components/Table' import { BasicTable, TableAction, useTable } from '@/components/Table'
import { deleteRole, lazyGetRoleList } from '@/api/system/role' 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' import { usePermission } from '@/hooks/web/usePermission'
defineOptions({ name: 'SystemRole' }) defineOptions({ name: 'SystemRole' })
@ -18,21 +18,23 @@ const [registerMenuModal, { openModal: openMenuModal }] = useModal<string>()
const { hasPermission } = usePermission() 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<Role>({ const [registerTable, { reload }] = useTable<Role>({
async api(params) { api: lazyGetRoleListWrap,
try {
const list = await lazyGetRoleList(params)
return list.map(item => ({
...item,
children: item.hasChildren ? [] : undefined,
}))
}
catch {
return []
}
},
load(record) { load(record) {
return lazyGetRoleList({ parentId: record.id }) return lazyGetRoleListWrap({ parentId: record.id })
}, },
columns, columns,
formConfig: { formConfig: {

Loading…
Cancel
Save