diff --git a/CHANGELOG.md b/CHANGELOG.md index c9a91da70f9cf8c29db439d317ab0f3c9d94e2d3..9dd61c11c591ccb32d23c660aee8b3c1d0cd28f7 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 9cc09d2b44713d8542699fc35691c141bdfca0ab..cfda8738815f9d9c9febd51926b4a4833d82f29b 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 421e035d017896db85cff8a3c09a6ba2be2c92d2..b827d62ac606d54d8b0b081f1d42685b8bbba61d 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 2a6d12cb4d68274e3bf9d8fd2b81b3385eeefe06..02aad15673a5181d8752fabcae9c652b16607034 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 092967cb8806d6ced23a5e08c13c531a37ae5d5f..7220ef467498b5bf292b0167f76f803231561d81 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 0968c0348d47ed9af78371dd7f9a27af317c17d2..127ea59eeb542af92ed72ce00788a25826a0e998 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();