From dc3e70b3f6f3b9c98b07049cbb852a57791b075b Mon Sep 17 00:00:00 2001 From: ShineKOT <1917095344@qq.com> Date: Mon, 15 Apr 2024 19:54:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=20=E6=96=B0=E5=A2=9E=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=89=93=E5=BC=80=E8=A7=86=E5=9B=BE=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E8=B0=83=E6=95=B4=E8=A1=A8=E6=A0=BC=E5=88=97?= =?UTF-8?q?=EF=BC=8C=E8=A1=A8=E5=8D=95=E9=A1=B9=E6=8F=92=E6=A7=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 5 +++++ src/control/form/form/form.tsx | 18 ++++++---------- src/control/grid/grid/grid.tsx | 24 +++++++++++++++------ src/control/tree-grid-ex/tree-grid-ex.tsx | 7 ++++++ src/control/tree-grid/tree-grid.tsx | 26 ++++++++++++++++------- src/view-engine/index-view.engine.ts | 18 ++++++++++++++++ 6 files changed, 72 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9a91da70..9dd61c11c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,12 @@ 并且此项目遵循 [Semantic Versioning](https://semver.org/lang/zh-CN/). ## [Unreleased] +### Added + +- 新增首页视图逻辑默认打开视图(无应用菜单) +### Changed +- 表单项,表格列,树表格列,树表格增强列插槽 ## [0.7.1] - 2024-04-14 ### Added diff --git a/src/control/form/form/form.tsx b/src/control/form/form/form.tsx index 9cc09d2b4..cfda87388 100644 --- a/src/control/form/form/form.tsx +++ b/src/control/form/form/form.tsx @@ -70,19 +70,12 @@ export const FormControl = defineComponent({ } const detailId = detail.id!; - // 表单成员组件的props - const detailProps: IData = { - modelData: detail, - controller: c.details[detailId], - key: detail.id, - attrs: renderAttrs(detail), - }; - // 有插槽走插槽 if (slots[detailId]) { return renderSlot(slots, detailId, { - ...slotProps, - ...detailProps, + model: detail, + data: c.state.data, + value: c.state.data[detailId], }); } @@ -118,7 +111,10 @@ export const FormControl = defineComponent({ return h( component, { - ...detailProps, + modelData: detail, + controller: c.details[detailId], + key: detail.id, + attrs: renderAttrs(detail), }, childSlots, ); diff --git a/src/control/grid/grid/grid.tsx b/src/control/grid/grid/grid.tsx index 421e035d0..b827d62ac 100644 --- a/src/control/grid/grid/grid.tsx +++ b/src/control/grid/grid/grid.tsx @@ -10,6 +10,7 @@ import { PropType, resolveComponent, VNode, + renderSlot, VNodeArrayChildren, } from 'vue'; import { IDEGrid, IDEGridColumn, IDEGridGroupColumn } from '@ibiz/model-core'; @@ -160,7 +161,7 @@ export const GridControl = defineComponent({ data: { type: Array, required: false }, loadDefault: { type: Boolean, default: true }, }, - setup(props) { + setup(props, { slots }) { const c = useControlController( (...args) => new GridController(...args), ); @@ -244,6 +245,19 @@ export const GridControl = defineComponent({ ); }; + // 绘制表格列 + const renderTableColumn = ( + model: IDEGridColumn, + index: number, + ): VNode | null => { + if (slots[model.id!]) { + return renderSlot(slots, model.id!, { + model, + data: c.state.items, + }); + } + return renderChildColumn(c, model, renderColumns.value, index); + }; onUnmounted(() => { zIndex.decrement(); @@ -255,6 +269,7 @@ export const GridControl = defineComponent({ tableRef, tableData, renderColumns, + renderTableColumn, onDbRowClick, onRowClick, onSelectionChange, @@ -323,12 +338,7 @@ export const GridControl = defineComponent({ > ), this.renderColumns.map((model, index) => { - return renderChildColumn( - this.c, - model, - this.renderColumns, - index, - ); + return this.renderTableColumn(model, index); }), ]; }, diff --git a/src/control/tree-grid-ex/tree-grid-ex.tsx b/src/control/tree-grid-ex/tree-grid-ex.tsx index 2a6d12cb4..02aad1567 100644 --- a/src/control/tree-grid-ex/tree-grid-ex.tsx +++ b/src/control/tree-grid-ex/tree-grid-ex.tsx @@ -7,6 +7,7 @@ import { ref, resolveComponent, VNode, + renderSlot, VNodeArrayChildren, watchEffect, } from 'vue'; @@ -227,6 +228,12 @@ export const TreeGridExControl = defineComponent({ model: IDETreeColumn, index: number, ): VNode | null => { + if (this.$slots[model.id!]) { + return renderSlot(this.$slots, model.id!, { + model, + data: this.c.state.items, + }); + } const { codeName: columnName, width } = model; const columnC = this.c.columns[columnName!]; const columnState = this.c.state.columnStates.find( diff --git a/src/control/tree-grid/tree-grid.tsx b/src/control/tree-grid/tree-grid.tsx index 092967cb8..7220ef467 100644 --- a/src/control/tree-grid/tree-grid.tsx +++ b/src/control/tree-grid/tree-grid.tsx @@ -4,9 +4,10 @@ import { defineComponent, PropType, VNode, + renderSlot, VNodeArrayChildren, } from 'vue'; -import { IDETreeGrid } from '@ibiz/model-core'; +import { IDEGridColumn, IDETreeGrid } from '@ibiz/model-core'; import { ControlVO, IControlProvider, @@ -44,7 +45,7 @@ export const TreeGridControl = defineComponent({ data: { type: Array, required: false }, loadDefault: { type: Boolean, default: true }, }, - setup(props) { + setup(props, { slots }) { const c = useControlController( (...args) => new TreeGridController(...args), ); @@ -174,6 +175,19 @@ export const TreeGridControl = defineComponent({ ); }; + const renderColumn = ( + model: IDEGridColumn, + index: number, + ): VNode | null => { + if (slots[model.id!]) { + return renderSlot(slots, model.id!, { + model, + data: c.state.items, + }); + } + return renderChildColumn(c, model, renderColumns.value, index); + }; + return { c, ns, @@ -182,6 +196,7 @@ export const TreeGridControl = defineComponent({ treeGirdData, tableData, renderColumns, + renderColumn, defaultSort, onDbRowClick, onRowClick, @@ -252,12 +267,7 @@ export const TreeGridControl = defineComponent({ ), state.isCreated && this.renderColumns.map((model, index) => { - return renderChildColumn( - this.c, - model, - this.renderColumns, - index, - ); + return this.renderColumn(model, index); }), ]; }, diff --git a/src/view-engine/index-view.engine.ts b/src/view-engine/index-view.engine.ts index 0968c0348..127ea59ee 100644 --- a/src/view-engine/index-view.engine.ts +++ b/src/view-engine/index-view.engine.ts @@ -5,6 +5,7 @@ import { IViewEvent, IAppMenuController, ViewCallTag, + OpenAppViewCommand, } from '@ibiz-template/runtime'; import { IAppIndexView } from '@ibiz/model-core'; @@ -51,6 +52,23 @@ export class IndexViewEngine extends ViewEngineBase { async onMounted(): Promise { await super.onMounted(); + + // 判断是否存在首页菜单模型 + if (!this.isExistAndInLayout('appmenu')) { + // 没有则跳转默认视图 + const { model, context, params } = this.view; + const { defAppViewId } = model; + if (defAppViewId) { + // 打开视图 + ibiz.commands.execute( + OpenAppViewCommand.TAG, + defAppViewId, + context, + params, + ); + } + } + // 屏幕宽度小于1200时折叠 if (window.innerWidth <= 1200) { this.toggleCollapse(); -- Gitee