diff --git a/src/api/platform/system/controller/region.ts b/src/api/platform/system/controller/region.ts index 17e7946..d77c627 100644 --- a/src/api/platform/system/controller/region.ts +++ b/src/api/platform/system/controller/region.ts @@ -16,16 +16,13 @@ enum Api { del = '/system_proxy/system/region/remove' } -export const listRegion = (params?: Partial) => { - 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) => defHttp.get({ url: Api.list, params }); -export const addRegion = (params:Partial) => defHttp.post({ url: Api.add,data:params }); +export const lazyListRegion = (params?: Partial) => defHttp.get({ url: Api.lazyList, params }); -export const editRegion = (params:Partial) => defHttp.put({ url: Api.edit,data:params }); +export const addRegion = (params:Partial) => defHttp.post({ url: Api.add, data: params }); + +export const editRegion = (params:Partial) => defHttp.put({ url: Api.edit, data: params }); export const getRegion = (id: string) => defHttp.get>({ url: `${Api.get}/${id}` }); diff --git a/src/views/system/region/RegionModal.vue b/src/views/system/region/RegionModal.vue index 9f9bd55..db7142f 100644 --- a/src/views/system/region/RegionModal.vue +++ b/src/views/system/region/RegionModal.vue @@ -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({ @@ -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; }); }); diff --git a/src/views/system/region/index.vue b/src/views/system/region/index.vue index 9d3df9a..5a568b6 100644 --- a/src/views/system/region/index.vue +++ b/src/views/system/region/index.vue @@ -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: { @@ -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));