From 39dc39f72b6fd21a08dd2959907b756063c296e5 Mon Sep 17 00:00:00 2001 From: rubyliu Date: Sun, 13 Aug 2023 22:50:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A1=A8=E6=A0=BC=E7=A9=BA=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/pure/ms-table/base-table.vue | 5 ++++ .../components/pure/ms-table/locale/zh-CN.ts | 4 +++ frontend/src/components/pure/ms-table/type.ts | 6 ++++ .../src/components/pure/ms-table/useTable.ts | 28 +++++++++++++------ .../components/systemOrganization.vue | 14 ++++++---- 5 files changed, 44 insertions(+), 13 deletions(-) diff --git a/frontend/src/components/pure/ms-table/base-table.vue b/frontend/src/components/pure/ms-table/base-table.vue index 638efa19a7..54bdd3b9cf 100644 --- a/frontend/src/components/pure/ms-table/base-table.vue +++ b/frontend/src/components/pure/ms-table/base-table.vue @@ -79,6 +79,11 @@ +
{ + propsRes.value.tableErrorStatus = status; + }; + /** * 分页设置 * @param current //当前页数 @@ -120,9 +130,7 @@ export default function useTableProps( const setPagination = ({ current, total }: SetPaginationPrams) => { if (propsRes.value.msPagination && typeof propsRes.value.msPagination === 'object') { propsRes.value.msPagination.current = current; - if (total) { - propsRes.value.msPagination.total = total; - } + propsRes.value.msPagination.total = total || 0; } }; @@ -171,14 +179,18 @@ export default function useTableProps( } return item; }); + if (data.total === 0) { + setTableErrorStatus('empty'); + } else { + setTableErrorStatus(false); + } setPagination({ current: data.current, total: data.total }); return data; } catch (err) { - // eslint-disable-next-line no-console - // TODO 表格异常放到solt的empty - console.log(err); + setTableErrorStatus('error'); } finally { setLoading(false); + if (propsRes.value.debug) console.info(propsRes.value); } }; diff --git a/frontend/src/views/setting/system/organizationAndProject/components/systemOrganization.vue b/frontend/src/views/setting/system/organizationAndProject/components/systemOrganization.vue index 9c1e50e5b6..f8096a2862 100644 --- a/frontend/src/views/setting/system/organizationAndProject/components/systemOrganization.vue +++ b/frontend/src/views/setting/system/organizationAndProject/components/systemOrganization.vue @@ -29,7 +29,7 @@ import useTable from '@/components/pure/ms-table/useTable'; import MsBaseTable from '@/components/pure/ms-table/base-table.vue'; import { useTableStore } from '@/store'; - import { ref, reactive, watchEffect } from 'vue'; + import { ref, reactive, watchEffect, watch } from 'vue'; import type { ActionsItem } from '@/components/pure/ms-table-more-action/types'; import { postOrgTable } from '@/api/modules/setting/system/organizationAndProject'; import { TableKeyEnum } from '@/enums/tableEnum'; @@ -172,20 +172,24 @@ scroll: { y: 'auto', x: '1300px' }, selectable: false, noDisable: false, + debug: true, size: 'default', }); const fetchData = async () => { + setKeyword(props.keyword); await loadList(); }; const handleAddUserModalCancel = () => { userVisible.value = false; }; - watchEffect(() => { - setKeyword(props.keyword); - fetchData(); - }); + watch( + () => props.keyword, + () => { + fetchData(); + } + );