From 8825ed2f8e0c2aabae9cd151e09f2a07384b4e80 Mon Sep 17 00:00:00 2001 From: lijisanxiong <1518062161@qq.com> Date: Fri, 17 Jan 2025 20:16:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=20=E9=83=A8=E4=BB=B6=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=97=A0=E6=95=B0=E6=8D=AE=E7=BB=98=E5=88=B6=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 ++++ src/control/calendar/calendar.tsx | 19 +++++++++++++++++-- src/control/chart/chart.tsx | 19 +++++++++++++++++-- src/control/data-view/data-view.tsx | 19 +++++++++++++++++-- src/control/gantt/gantt.tsx | 14 +++++++++++++- src/control/grid/grid/grid.tsx | 14 +++++++++++++- src/control/kanban/kanban.tsx | 19 +++++++++++++++++-- src/control/list/list.tsx | 17 +++++++++++++++-- src/control/tree-grid-ex/tree-grid-ex.tsx | 19 +++++++++++++++++-- src/control/tree-grid/tree-grid.tsx | 19 +++++++++++++++++-- 10 files changed, 147 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d79a87644..383c37ee1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ ## [Unreleased] +### Added + +- 部件支持无数据绘制器 + ## [0.7.38-alpha.51] - 2025-01-16 ### Added diff --git a/src/control/calendar/calendar.tsx b/src/control/calendar/calendar.tsx index 6ac2d5d1c..23f86a57a 100644 --- a/src/control/calendar/calendar.tsx +++ b/src/control/calendar/calendar.tsx @@ -1,5 +1,10 @@ /* eslint-disable no-nested-ternary */ -import { useControlController, useNamespace } from '@ibiz-template/vue3-util'; +import { + hasEmptyPanelRenderer, + IBizCustomRender, + useControlController, + useNamespace, +} from '@ibiz-template/vue3-util'; import { defineComponent, PropType, ref, VNode, watch } from 'vue'; import { ILayoutPanel, ISysCalendar, ISysCalendarItem } from '@ibiz/model-core'; import { @@ -483,13 +488,23 @@ export const CalendarControl = defineComponent({ const renderNoData = (): VNode | false => { // 未加载不显示无数据 const { isLoaded } = this.c.state; + const noDataSlots: IParams = {}; + if (hasEmptyPanelRenderer(this.c)) { + Object.assign(noDataSlots, { + customRender: () => ( + + ), + }); + } return ( isLoaded && ( + > + {noDataSlots} + ) ); }; diff --git a/src/control/chart/chart.tsx b/src/control/chart/chart.tsx index 768d155a8..fb8e91ab2 100644 --- a/src/control/chart/chart.tsx +++ b/src/control/chart/chart.tsx @@ -1,4 +1,9 @@ -import { useControlController, useNamespace } from '@ibiz-template/vue3-util'; +import { + hasEmptyPanelRenderer, + IBizCustomRender, + useControlController, + useNamespace, +} from '@ibiz-template/vue3-util'; import { defineComponent, nextTick, @@ -216,12 +221,22 @@ const ChartControl = defineComponent({ const renderNoData = () => { if (c.state.items.length === 0) { + const noDataSlots: IParams = {}; + if (hasEmptyPanelRenderer(c)) { + Object.assign(noDataSlots, { + customRender: () => ( + + ), + }); + } return ( + > + {noDataSlots} + ); } }; diff --git a/src/control/data-view/data-view.tsx b/src/control/data-view/data-view.tsx index 66783f353..d4da7aec2 100644 --- a/src/control/data-view/data-view.tsx +++ b/src/control/data-view/data-view.tsx @@ -1,5 +1,10 @@ /* eslint-disable no-nested-ternary */ -import { useControlController, useNamespace } from '@ibiz-template/vue3-util'; +import { + hasEmptyPanelRenderer, + IBizCustomRender, + useControlController, + useNamespace, +} from '@ibiz-template/vue3-util'; import { computed, defineComponent, PropType, ref, VNode, watch } from 'vue'; import { IDEDataView, @@ -452,13 +457,23 @@ export const DataViewControl = defineComponent({ if (!isLoaded) { return; } + const noDataSlots: IParams = {}; + if (hasEmptyPanelRenderer(c)) { + Object.assign(noDataSlots, { + customRender: () => ( + + ), + }); + } return ( + > + {noDataSlots} + ); }; diff --git a/src/control/gantt/gantt.tsx b/src/control/gantt/gantt.tsx index 08d8c940a..88e7a754e 100644 --- a/src/control/gantt/gantt.tsx +++ b/src/control/gantt/gantt.tsx @@ -6,6 +6,8 @@ import { useNamespace, useUIStore, IBizControlShell, + hasEmptyPanelRenderer, + IBizCustomRender, } from '@ibiz-template/vue3-util'; import { computed, @@ -515,12 +517,22 @@ export const GanttControl = defineComponent({ const renderNoData = (): VNode | false => { // 未加载不显示无数据 const { isLoaded } = c.state; + const noDataSlots: IParams = {}; + if (hasEmptyPanelRenderer(c)) { + Object.assign(noDataSlots, { + customRender: () => ( + + ), + }); + } return ( isLoaded && ( + > + {noDataSlots} + ) ); }; diff --git a/src/control/grid/grid/grid.tsx b/src/control/grid/grid/grid.tsx index 1bea1ef5e..9ce44ff75 100644 --- a/src/control/grid/grid/grid.tsx +++ b/src/control/grid/grid/grid.tsx @@ -3,6 +3,8 @@ import { useUIStore, useNamespace, useControlController, + hasEmptyPanelRenderer, + IBizCustomRender, } from '@ibiz-template/vue3-util'; import { defineComponent, @@ -220,12 +222,22 @@ export const GridControl = defineComponent({ > ); } + const noDataSlots: IParams = {}; + if (hasEmptyPanelRenderer(c)) { + Object.assign(noDataSlots, { + customRender: () => ( + + ), + }); + } return ( + > + {noDataSlots} + ); } // 给null 表格会绘制默认的无数据 diff --git a/src/control/kanban/kanban.tsx b/src/control/kanban/kanban.tsx index 11a2a1826..90e0db937 100644 --- a/src/control/kanban/kanban.tsx +++ b/src/control/kanban/kanban.tsx @@ -1,5 +1,10 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import { useControlController, useNamespace } from '@ibiz-template/vue3-util'; +import { + hasEmptyPanelRenderer, + IBizCustomRender, + useControlController, + useNamespace, +} from '@ibiz-template/vue3-util'; import { computed, defineComponent, @@ -319,11 +324,21 @@ export const KanbanControl = defineComponent({ if (!c.state.isLoaded) { return; } + const noDataSlots: IParams = {}; + if (hasEmptyPanelRenderer(c)) { + Object.assign(noDataSlots, { + customRender: () => ( + + ), + }); + } return ( + > + {noDataSlots} + ); }; diff --git a/src/control/list/list.tsx b/src/control/list/list.tsx index fbaa4620a..939f776fd 100644 --- a/src/control/list/list.tsx +++ b/src/control/list/list.tsx @@ -1,5 +1,10 @@ /* eslint-disable no-nested-ternary */ -import { useControlController, useNamespace } from '@ibiz-template/vue3-util'; +import { + hasEmptyPanelRenderer, + IBizCustomRender, + useControlController, + useNamespace, +} from '@ibiz-template/vue3-util'; import { defineComponent, PropType, computed, VNode, ref, watch } from 'vue'; import { IDEList, ILayoutPanel, IUIActionGroupDetail } from '@ibiz/model-core'; import { isNil } from 'lodash-es'; @@ -388,6 +393,14 @@ export const ListControl = defineComponent({ if (!isLoaded) { return; } + const noDataSlots: IParams = { default: () => renderQuickToolBar() }; + if (hasEmptyPanelRenderer(c)) { + Object.assign(noDataSlots, { + customRender: () => ( + + ), + }); + } return ( isLoaded && ( - {renderQuickToolBar()} + {noDataSlots} ) ); diff --git a/src/control/tree-grid-ex/tree-grid-ex.tsx b/src/control/tree-grid-ex/tree-grid-ex.tsx index e27d74aaf..190fdcbc9 100644 --- a/src/control/tree-grid-ex/tree-grid-ex.tsx +++ b/src/control/tree-grid-ex/tree-grid-ex.tsx @@ -1,4 +1,9 @@ -import { useControlController, useNamespace } from '@ibiz-template/vue3-util'; +import { + hasEmptyPanelRenderer, + IBizCustomRender, + useControlController, + useNamespace, +} from '@ibiz-template/vue3-util'; import { computed, defineComponent, @@ -40,12 +45,22 @@ export const TreeGridExControl = defineComponent({ const renderNoData = (): VNode | false => { // 未加载不显示无数据 const { isLoaded } = c.state; + const noDataSlots: IParams = {}; + if (hasEmptyPanelRenderer(c)) { + Object.assign(noDataSlots, { + customRender: () => ( + + ), + }); + } return ( isLoaded && ( + > + {noDataSlots} + ) ); }; diff --git a/src/control/tree-grid/tree-grid.tsx b/src/control/tree-grid/tree-grid.tsx index 076fb3a57..717daeed9 100644 --- a/src/control/tree-grid/tree-grid.tsx +++ b/src/control/tree-grid/tree-grid.tsx @@ -1,4 +1,9 @@ -import { useControlController, useNamespace } from '@ibiz-template/vue3-util'; +import { + hasEmptyPanelRenderer, + IBizCustomRender, + useControlController, + useNamespace, +} from '@ibiz-template/vue3-util'; import { defineComponent, PropType, @@ -86,11 +91,21 @@ export const TreeGridControl = defineComponent({ > ); } + const noDataSlots: IParams = {}; + if (hasEmptyPanelRenderer(c)) { + Object.assign(noDataSlots, { + customRender: () => ( + + ), + }); + } return ( + > + {noDataSlots} + ); } return null; -- Gitee