From f352c4d941e2a32ca4f4960c88cdd6eecc202a01 Mon Sep 17 00:00:00 2001 From: xingyu Date: Tue, 3 Jan 2023 11:21:27 +0800 Subject: [PATCH] =?UTF-8?q?reactor:=20=E9=87=8D=E6=9E=84=20XTable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/XTable/src/XTable.vue | 93 +++++++++++-------- .../src/components/XTable/src/type.ts | 1 + .../src/views/infra/apiAccessLog/index.vue | 11 +-- .../src/views/infra/apiErrorLog/index.vue | 17 ++-- .../src/views/infra/codegen/index.vue | 14 ++- .../src/views/infra/config/index.vue | 16 ++-- .../views/infra/dataSourceConfig/index.vue | 14 ++- .../src/views/infra/fileConfig/index.vue | 16 ++-- .../src/views/infra/fileList/index.vue | 14 ++- .../src/views/infra/job/JobLog.vue | 12 +-- .../src/views/infra/job/index.vue | 20 ++-- .../src/views/pay/app/index.vue | 16 ++-- .../src/views/pay/merchant/index.vue | 16 ++-- .../src/views/pay/order/index.vue | 12 +-- .../src/views/pay/refund/index.vue | 12 +-- .../src/views/system/dept/index.vue | 12 +-- .../src/views/system/errorCode/index.vue | 14 ++- .../src/views/system/loginlog/index.vue | 12 +-- .../src/views/system/menu/index.vue | 12 +-- .../src/views/system/notice/index.vue | 14 ++- .../src/views/system/oauth2/client/index.vue | 14 ++- .../src/views/system/oauth2/token/index.vue | 12 +-- .../src/views/system/operatelog/index.vue | 12 +-- .../src/views/system/post/index.vue | 16 ++-- .../src/views/system/role/index.vue | 14 ++- .../src/views/system/sensitiveWord/index.vue | 27 +++--- .../src/views/system/sms/smsChannel/index.vue | 14 ++- .../src/views/system/sms/smsLog/index.vue | 12 +-- .../views/system/sms/smsTemplate/index.vue | 14 ++- .../src/views/system/tenant/index.vue | 16 ++-- .../src/views/system/tenantPackage/index.vue | 14 ++- .../src/views/system/user/index.vue | 22 ++--- 32 files changed, 250 insertions(+), 285 deletions(-) diff --git a/yudao-ui-admin-vue3/src/components/XTable/src/XTable.vue b/yudao-ui-admin-vue3/src/components/XTable/src/XTable.vue index 3fbf70a44..72d83d6fe 100644 --- a/yudao-ui-admin-vue3/src/components/XTable/src/XTable.vue +++ b/yudao-ui-admin-vue3/src/components/XTable/src/XTable.vue @@ -118,45 +118,64 @@ const getColumnsConfig = (options: XTableProps) => { // 动态请求 const getProxyConfig = (options: XTableProps) => { - const { getListApi, proxyConfig, data } = options + const { getListApi, proxyConfig, data, isList } = options if (proxyConfig || data) return - if (getListApi && isFunction(getListApi)) { - options.proxyConfig = { - seq: true, // 启用动态序号代理(分页之后索引自动计算为当前页的起始序号) - form: proxyForm, // 启用表单代理,当点击表单提交按钮时会自动触发 reload 行为 - props: { result: 'list', total: 'total' }, - ajax: { - query: async ({ page, form }) => { - let queryParams: any = Object.assign({}, JSON.parse(JSON.stringify(form))) - if (options.params) { - queryParams = Object.assign(queryParams, options.params) - } - if (!options?.treeConfig) { - queryParams.pageSize = page.pageSize - queryParams.pageNo = page.currentPage - } - return new Promise(async (resolve) => { - resolve(await getListApi(queryParams)) - }) - }, - delete: ({ body }) => { - return new Promise(async (resolve) => { - if (options.deleteApi) { - resolve(await options.deleteApi(JSON.stringify(body))) - } else { - Promise.reject('未设置deleteApi') + if (getListApi && isFunction(getListApi) && !isList) { + if (!isList) { + options.proxyConfig = { + seq: true, // 启用动态序号代理(分页之后索引自动计算为当前页的起始序号) + form: proxyForm, // 启用表单代理,当点击表单提交按钮时会自动触发 reload 行为 + props: { result: 'list', total: 'total' }, + ajax: { + query: async ({ page, form }) => { + let queryParams: any = Object.assign({}, JSON.parse(JSON.stringify(form))) + if (options.params) { + queryParams = Object.assign(queryParams, options.params) } - }) - }, - queryAll: ({ form }) => { - const queryParams = Object.assign({}, JSON.parse(JSON.stringify(form))) - return new Promise(async (resolve) => { - if (options.getAllListApi) { - resolve(await options.getAllListApi(queryParams)) - } else { + if (!options?.treeConfig) { + queryParams.pageSize = page.pageSize + queryParams.pageNo = page.currentPage + } + return new Promise(async (resolve) => { resolve(await getListApi(queryParams)) + }) + }, + delete: ({ body }) => { + return new Promise(async (resolve) => { + if (options.deleteApi) { + resolve(await options.deleteApi(JSON.stringify(body))) + } else { + Promise.reject('未设置deleteApi') + } + }) + }, + queryAll: ({ form }) => { + const queryParams = Object.assign({}, JSON.parse(JSON.stringify(form))) + return new Promise(async (resolve) => { + if (options.getAllListApi) { + resolve(await options.getAllListApi(queryParams)) + } else { + resolve(await getListApi(queryParams)) + } + }) + } + } + } + } else { + options.proxyConfig = { + seq: true, // 启用动态序号代理(分页之后索引自动计算为当前页的起始序号) + form: true, // 启用表单代理,当点击表单提交按钮时会自动触发 reload 行为 + props: { result: 'data' }, + ajax: { + query: ({ form }) => { + let queryParams: any = Object.assign({}, JSON.parse(JSON.stringify(form))) + if (options?.params) { + queryParams = Object.assign(queryParams, options.params) } - }) + return new Promise(async (resolve) => { + resolve(await getListApi(queryParams)) + }) + } } } } @@ -232,14 +251,14 @@ const getPageConfig = (options: XTableProps) => { // tool bar const getToolBarConfig = (options: XTableProps) => { - const { toolBar, toolbarConfig } = options + const { toolBar, toolbarConfig, topActionSlots } = options if (toolbarConfig) return if (toolBar) { if (!isBoolean(toolBar)) { options.toolbarConfig = toolBar return } - } else { + } else if (!topActionSlots) { options.toolbarConfig = { slots: { buttons: 'toolbar_buttons' } } diff --git a/yudao-ui-admin-vue3/src/components/XTable/src/type.ts b/yudao-ui-admin-vue3/src/components/XTable/src/type.ts index c4ad2eb6b..7abf911f7 100644 --- a/yudao-ui-admin-vue3/src/components/XTable/src/type.ts +++ b/yudao-ui-admin-vue3/src/components/XTable/src/type.ts @@ -6,6 +6,7 @@ export type XTableProps = VxeGridProps & { height?: number // 高度 默认730 topActionSlots?: boolean // 是否开启表格内顶部操作栏插槽 treeConfig?: VxeTablePropTypes.TreeConfig // 树形表单配置 + isList?: boolean // 是否不带分页的list getListApi?: Function getAllListApi?: Function deleteApi?: Function diff --git a/yudao-ui-admin-vue3/src/views/infra/apiAccessLog/index.vue b/yudao-ui-admin-vue3/src/views/infra/apiAccessLog/index.vue index ae1aba8a1..14cf656aa 100644 --- a/yudao-ui-admin-vue3/src/views/infra/apiAccessLog/index.vue +++ b/yudao-ui-admin-vue3/src/views/infra/apiAccessLog/index.vue @@ -1,7 +1,7 @@ - + @@ -38,15 +38,14 @@ diff --git a/yudao-ui-admin-vue3/src/views/infra/config/index.vue b/yudao-ui-admin-vue3/src/views/infra/config/index.vue index 50a067fcb..8749568b2 100644 --- a/yudao-ui-admin-vue3/src/views/infra/config/index.vue +++ b/yudao-ui-admin-vue3/src/views/infra/config/index.vue @@ -1,7 +1,7 @@