From 4ed7815c103bc92db81d2bd6e7362ff4255e07db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=BF=E5=B0=8F=E5=A4=A9?= <1638245306@qq.com> Date: Mon, 20 Mar 2023 09:47:46 +0800 Subject: [PATCH] =?UTF-8?q?chore(=E5=9C=B0=E5=8C=BA=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=F0=9F=9A=B8=20=E5=9C=B0=E5=8C=BA=E7=AE=A1=E7=90=86=E6=94=B9?= =?UTF-8?q?=E6=A0=91=E5=BD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/views/system/areas/api.ts | 2 +- web/src/views/system/areas/crud.tsx | 77 +++++++++++++++++------------ 2 files changed, 47 insertions(+), 32 deletions(-) diff --git a/web/src/views/system/areas/api.ts b/web/src/views/system/areas/api.ts index dc94c6a..be49d95 100644 --- a/web/src/views/system/areas/api.ts +++ b/web/src/views/system/areas/api.ts @@ -6,7 +6,7 @@ export function GetList(query: PageQuery) { return request({ url: apiPrefix, method: 'get', - data: query, + params: query, }); } export function GetObj(id: InfoReq) { diff --git a/web/src/views/system/areas/crud.tsx b/web/src/views/system/areas/crud.tsx index bdf9ec4..b8f36ad 100644 --- a/web/src/views/system/areas/crud.tsx +++ b/web/src/views/system/areas/crud.tsx @@ -20,6 +20,18 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp const addRequest = async ({ form }: AddReq) => { return await api.AddObj(form); }; + + /** + * 懒加载 + * @param row + * @returns {Promise} + */ + const loadContentMethod = (tree: any, treeNode: any, resolve: any) => { + api.GetList({ pcode: tree.code }).then((res: any) => { + resolve(res.data); + }); + }; + return { crudOptions: { request: { @@ -28,47 +40,50 @@ export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExp editRequest, delRequest, }, + pagination: { + show: false, + }, + table: { + rowKey: 'id', + lazy: true, + load: loadContentMethod, + treeProps: { children: 'children', hasChildren: 'hasChild' }, + }, columns: { _index: { title: '序号', form: { show: false }, column: { - //type: 'index', + type: 'index', align: 'center', width: '70px', columnSetDisabled: true, //禁止在列设置中选择 - formatter: (context) => { - //计算序号,你可以自定义计算规则,此处为翻页累加 - let index = context.index ?? 1; - let pagination = crudExpose.crudBinding.value.pagination; - return ((pagination.currentPage ?? 1) - 1) * pagination.pageSize + index + 1; - }, - }, - }, - pcode: { - title: '父级地区', - show: false, - search: { - show: true, - }, - type: 'dict-tree', - form: { - component: { - showAllLevels: false, // 仅显示最后一级 - props: { - elProps: { - clearable: true, - showAllLevels: false, // 仅显示最后一级 - props: { - checkStrictly: true, // 可以不需要选到最后一级 - emitPath: false, - clearable: true, - }, - }, - }, - }, }, }, + // pcode: { + // title: '父级地区', + // show: false, + // search: { + // show: true, + // }, + // type: 'dict-tree', + // form: { + // component: { + // showAllLevels: false, // 仅显示最后一级 + // props: { + // elProps: { + // clearable: true, + // showAllLevels: false, // 仅显示最后一级 + // props: { + // checkStrictly: true, // 可以不需要选到最后一级 + // emitPath: false, + // clearable: true, + // }, + // }, + // }, + // }, + // }, + // }, name: { title: '名称', search: {