Skip to content

Commit

Permalink
🧑‍💻🐳 chore: optimization lazy list
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxiang committed Feb 23, 2023
1 parent 9e925d5 commit 42c96b1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
13 changes: 5 additions & 8 deletions src/api/platform/system/controller/region.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@ enum Api {
del = '/system_proxy/system/region/remove'
}

export const listRegion = (params?: Partial<RegionParams>) => {
let url = Api.lazyList;
// todo: 待优化
if (params?.name || params?.code || params?.beginTime || params?.endTime) url = Api.list;
return defHttp.get({ url: url, params });
};
export const listRegion = (params?: Partial<RegionParams>) => defHttp.get({ url: Api.list, params });

export const addRegion = (params:Partial<Region>) => defHttp.post({ url: Api.add,data:params });
export const lazyListRegion = (params?: Partial<RegionParams>) => defHttp.get({ url: Api.lazyList, params });

export const editRegion = (params:Partial<Region>) => defHttp.put({ url: Api.edit,data:params });
export const addRegion = (params:Partial<Region>) => defHttp.post({ url: Api.add, data: params });

export const editRegion = (params:Partial<Region>) => defHttp.put({ url: Api.edit, data: params });

export const getRegion = (id: string) => defHttp.get<ResultVo<Region>>({ url: `${Api.get}/${id}` });

Expand Down
10 changes: 5 additions & 5 deletions src/views/system/region/RegionModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { BasicForm, useForm } from '/@/components/Form';
import { regionFormSchema } from './region.data';
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal';
import { listRegion, addRegion, editRegion, getRegion } from '/@/api/platform/system/controller/region';
import { lazyListRegion, addRegion, editRegion, getRegion } from '/@/api/platform/system/controller/region';
/** 通用变量统一声明区域 */
const state = reactive({
Expand Down Expand Up @@ -52,11 +52,11 @@
},
loadData: (treeNode: any) => {
const { id } = treeNode.dataRef;
return listRegion({ parentId: id }).then(res => {
return lazyListRegion({ parentId: id }).then(res => {
treeNode.dataRef.children = (res || [])?.map(item => {
if(item.hasOwnProperty('children')) {
item.isLeaf = false;
} else item.isLeaf = true;
item.hasOwnProperty('children')
? (item.isLeaf = false)
: (item.isLeaf = true);
return item;
});
});
Expand Down
8 changes: 4 additions & 4 deletions src/views/system/region/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@
import { useModal } from '/@/components/Modal';
import RegionModal from './RegionModal.vue';
import { columns, searchFormSchema } from './region.data';
import { delRegion, listRegion } from '/@/api/platform/system/controller/region';
import { delRegion, lazyListRegion } from '/@/api/platform/system/controller/region';
import { useMessage } from '/@/hooks/web/useMessage';
/** 通用变量统一声明区域 */
const { createMessage } = useMessage();
const [registerModal, { openModal }] = useModal();
const [registerTable, { reload, getDataSource, setLoading, collapseAll }] = useTable({
const [registerTable, { reload, setLoading, collapseAll }] = useTable({
title: '区域列表',
api: listRegion,
api: lazyListRegion,
rowKey: 'id',
columns,
formConfig: {
Expand Down Expand Up @@ -86,7 +86,7 @@
function onExpandClick(expanded, info) {
if (expanded) {
setLoading(true);
listRegion({ parentId: info.id }).then(res => {
lazyListRegion({ parentId: info.id }).then(res => {
info.children = res;
setLoading(false);
}).catch(() => setLoading(false));
Expand Down

0 comments on commit 42c96b1

Please sign in to comment.