From 8cdd3f3c40cbf65107ad22461ab27d7873cdea05 Mon Sep 17 00:00:00 2001 From: Cano1997 <1978141412@qq.com> Date: Wed, 11 Jun 2025 16:31:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A7=86=E5=9B=BE=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BB=8E=E5=B8=83=E5=B1=80=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E4=B8=AD=E8=8E=B7=E5=8F=96=E9=83=A8=E4=BB=B6=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app-portal-view-model.ts | 8 ++--- .../view/chart-view-model/chart-view-model.ts | 8 ++--- .../view/edit-view-model/edit-view-model.ts | 8 ++--- .../view/edit-view3-model/edit-view3-model.ts | 4 +-- .../view/grid-view-model/grid-view-model.ts | 8 ++--- .../view/index-view-model/index-view-model.ts | 8 ++--- .../list-exp-view-model.ts | 3 +- .../view/list-view-model/list-view-model.ts | 8 ++--- .../src/view/md-view-model/md-view-model.ts | 3 +- .../mpickup-view2-model.ts | 8 ++--- .../pickup-view-model/pickup-view-model.ts | 6 +--- .../pickup-view2-model/pickup-view2-model.ts | 8 ++--- .../tree-exp-view-model.ts | 3 +- .../model/src/view/view-model/view-model.ts | 29 +++++++++++++++++++ .../wf-dyna-edit-view3-model.ts | 4 +-- 15 files changed, 53 insertions(+), 63 deletions(-) diff --git a/packages/model/src/view/app-portal-view-model/app-portal-view-model.ts b/packages/model/src/view/app-portal-view-model/app-portal-view-model.ts index 15449b9d17..3f345d0b5d 100644 --- a/packages/model/src/view/app-portal-view-model/app-portal-view-model.ts +++ b/packages/model/src/view/app-portal-view-model/app-portal-view-model.ts @@ -1,8 +1,4 @@ -import { - getControl, - IPSAppPortalView, - IPSSysDashboard, -} from '@ibiz/dynamic-model-api'; +import { IPSAppPortalView, IPSSysDashboard } from '@ibiz/dynamic-model-api'; import { DashboardModel } from '../../control'; import { DefectModelError } from '../../error'; import { ViewModel } from '../view-model/view-model'; @@ -21,7 +17,7 @@ export class AppPortalViewModel extends ViewModel { protected async onInit(): Promise { await super.onInit(); - const ctrl = getControl(this.source, 'dashboard') as IPSSysDashboard; + const ctrl = this.getControl('dashboard') as IPSSysDashboard; if (!ctrl) { throw new DefectModelError(this.source, '缺少叫dashboard的数据看板部件'); } diff --git a/packages/model/src/view/chart-view-model/chart-view-model.ts b/packages/model/src/view/chart-view-model/chart-view-model.ts index 02e6a06dbd..bdc7753740 100644 --- a/packages/model/src/view/chart-view-model/chart-view-model.ts +++ b/packages/model/src/view/chart-view-model/chart-view-model.ts @@ -1,8 +1,4 @@ -import { - IPSAppDEChartView, - IPSDEChart, - getControl, -} from '@ibiz/dynamic-model-api'; +import { IPSAppDEChartView, IPSDEChart } from '@ibiz/dynamic-model-api'; import { ViewModel } from '../view-model/view-model'; import { ChartModel } from '../../control'; import { DefectModelError } from '../../error'; @@ -12,7 +8,7 @@ export class ChartViewModel extends ViewModel { protected async onInit(): Promise { await super.onInit(); - const ctrl = getControl(this.source, 'chart') as IPSDEChart; + const ctrl = this.getControl('chart') as IPSDEChart; if (!ctrl) { throw new DefectModelError(this.source, '缺少叫chart的图表部件'); } diff --git a/packages/model/src/view/edit-view-model/edit-view-model.ts b/packages/model/src/view/edit-view-model/edit-view-model.ts index 7d4534a100..ce24fe7985 100644 --- a/packages/model/src/view/edit-view-model/edit-view-model.ts +++ b/packages/model/src/view/edit-view-model/edit-view-model.ts @@ -1,8 +1,4 @@ -import { - getControl, - IPSAppDEEditView, - IPSDEEditForm, -} from '@ibiz/dynamic-model-api'; +import { IPSAppDEEditView, IPSDEEditForm } from '@ibiz/dynamic-model-api'; import { EditFormModel } from '../../control'; import { DefectModelError } from '../../error'; import { ViewModel } from '../view-model/view-model'; @@ -23,7 +19,7 @@ export class EditViewModel< protected async onInit(): Promise { await super.onInit(); - const ctrl = getControl(this.source, 'form') as IPSDEEditForm; + const ctrl = this.getControl('form') as IPSDEEditForm; if (!ctrl) { throw new DefectModelError(this.source, '缺少叫form的编辑表单部件'); } diff --git a/packages/model/src/view/edit-view3-model/edit-view3-model.ts b/packages/model/src/view/edit-view3-model/edit-view3-model.ts index 53df49f6be..c7ba214bee 100644 --- a/packages/model/src/view/edit-view3-model/edit-view3-model.ts +++ b/packages/model/src/view/edit-view3-model/edit-view3-model.ts @@ -1,4 +1,4 @@ -import { getControl, IPSDEDRTab } from '@ibiz/dynamic-model-api'; +import { IPSDEDRTab } from '@ibiz/dynamic-model-api'; import { EditViewModel } from '..'; import { DRTabModel } from '../../control'; import { DefectModelError } from '../../error'; @@ -17,7 +17,7 @@ export class EditView3Model extends EditViewModel { protected async onInit(): Promise { await super.onInit(); - const ctrl = getControl(this.source, 'drtab') as IPSDEDRTab; + const ctrl = this.getControl('drtab') as IPSDEDRTab; if (!ctrl) { throw new DefectModelError(this.source, '缺少叫drtab的分页部件'); } diff --git a/packages/model/src/view/grid-view-model/grid-view-model.ts b/packages/model/src/view/grid-view-model/grid-view-model.ts index 649715d10c..430e29e521 100644 --- a/packages/model/src/view/grid-view-model/grid-view-model.ts +++ b/packages/model/src/view/grid-view-model/grid-view-model.ts @@ -1,8 +1,4 @@ -import { - getControl, - IPSAppDEGridView, - IPSDEGrid, -} from '@ibiz/dynamic-model-api'; +import { IPSAppDEGridView, IPSDEGrid } from '@ibiz/dynamic-model-api'; import { GridModel } from '../../control'; import { DefectModelError } from '../../error'; import { MDViewModel } from '../md-view-model/md-view-model'; @@ -35,7 +31,7 @@ export class GridViewModel extends MDViewModel { protected async onInit(): Promise { await super.onInit(); - const ctrl = getControl(this.source, 'grid') as IPSDEGrid; + const ctrl = this.getControl('grid') as IPSDEGrid; if (!ctrl) { throw new DefectModelError(this.source, '缺少叫grid的表格部件'); } diff --git a/packages/model/src/view/index-view-model/index-view-model.ts b/packages/model/src/view/index-view-model/index-view-model.ts index bf3dca61e2..b168d30e94 100644 --- a/packages/model/src/view/index-view-model/index-view-model.ts +++ b/packages/model/src/view/index-view-model/index-view-model.ts @@ -1,8 +1,4 @@ -import { - getControl, - IPSAppIndexView, - IPSAppMenu, -} from '@ibiz/dynamic-model-api'; +import { IPSAppIndexView, IPSAppMenu } from '@ibiz/dynamic-model-api'; import { AppMenuModel } from '../../control'; import { DefectModelError } from '../../error'; import { ViewModel } from '../view-model/view-model'; @@ -31,7 +27,7 @@ export class IndexViewModel extends ViewModel { protected async onInit(): Promise { await super.onInit(); - const ctrl = getControl(this.source, 'appmenu') as IPSAppMenu; + const ctrl = this.getControl('appmenu') as IPSAppMenu; if (!ctrl) { throw new DefectModelError(this.source, '缺少叫appmenu的菜单部件'); } diff --git a/packages/model/src/view/list-exp-view-model/list-exp-view-model.ts b/packages/model/src/view/list-exp-view-model/list-exp-view-model.ts index 22e8f3a27a..e9cf07a33b 100644 --- a/packages/model/src/view/list-exp-view-model/list-exp-view-model.ts +++ b/packages/model/src/view/list-exp-view-model/list-exp-view-model.ts @@ -1,5 +1,4 @@ import { - getControl, IPSAppDEListExplorerView, IPSListExpBar, } from '@ibiz/dynamic-model-api'; @@ -49,7 +48,7 @@ export class ListExpViewModel extends MDViewModel { await super.onInit(); // 获取分页面板 - const ctrl = getControl(this.source, 'listexpbar') as IPSListExpBar; + const ctrl = this.getControl('listexpbar') as IPSListExpBar; if (!ctrl) { throw new DefectModelError( this.source, diff --git a/packages/model/src/view/list-view-model/list-view-model.ts b/packages/model/src/view/list-view-model/list-view-model.ts index 5f6620adcb..587db18771 100644 --- a/packages/model/src/view/list-view-model/list-view-model.ts +++ b/packages/model/src/view/list-view-model/list-view-model.ts @@ -1,8 +1,4 @@ -import { - getControl, - IPSAppDEListView, - IPSDEList, -} from '@ibiz/dynamic-model-api'; +import { IPSAppDEListView, IPSDEList } from '@ibiz/dynamic-model-api'; import { ListModel } from '../../control'; import { DefectModelError } from '../../error'; import { MDViewModel } from '../md-view-model/md-view-model'; @@ -34,7 +30,7 @@ export class ListViewModel extends MDViewModel { protected async onInit(): Promise { await super.onInit(); - const ctrl = getControl(this.source, 'list') as IPSDEList; + const ctrl = this.getControl('list') as IPSDEList; if (!ctrl) { throw new DefectModelError(this.source, '缺少叫list的部件'); } diff --git a/packages/model/src/view/md-view-model/md-view-model.ts b/packages/model/src/view/md-view-model/md-view-model.ts index 85dbe6d001..7843dc16eb 100644 --- a/packages/model/src/view/md-view-model/md-view-model.ts +++ b/packages/model/src/view/md-view-model/md-view-model.ts @@ -1,5 +1,4 @@ import { - getControl, IPSAppDEMultiDataView, IPSDESearchForm, } from '@ibiz/dynamic-model-api'; @@ -42,7 +41,7 @@ export class MDViewModel< this.initPlaceHolder(); // 初始化搜索表单模型 - const ctrl = getControl(this.source, 'searchform') as IPSDESearchForm; + const ctrl = this.getControl('searchform') as IPSDESearchForm; if (ctrl) { this.searchForm = new SearchFormModel(ctrl); await this.searchForm.init(); diff --git a/packages/model/src/view/mpickup-view2-model/mpickup-view2-model.ts b/packages/model/src/view/mpickup-view2-model/mpickup-view2-model.ts index 256d66d2f3..d6958388a5 100644 --- a/packages/model/src/view/mpickup-view2-model/mpickup-view2-model.ts +++ b/packages/model/src/view/mpickup-view2-model/mpickup-view2-model.ts @@ -1,8 +1,4 @@ -import { - getControl, - IPSAppDEPickupView, - IPSTreeExpBar, -} from '@ibiz/dynamic-model-api'; +import { IPSAppDEPickupView, IPSTreeExpBar } from '@ibiz/dynamic-model-api'; import { TreeExpBarModel, TreeModel } from '../../control'; import { DefectModelError } from '../../error'; import { PickupViewModel } from '..'; @@ -37,7 +33,7 @@ export class MPickupView2Model extends PickupViewModel { await super.onInit(); // 获取树导航面板 - const ctrl = getControl(this.source, 'treeexpbar') as IPSTreeExpBar; + const ctrl = this.getControl('treeexpbar') as IPSTreeExpBar; if (!ctrl) { throw new DefectModelError( this.source, diff --git a/packages/model/src/view/pickup-view-model/pickup-view-model.ts b/packages/model/src/view/pickup-view-model/pickup-view-model.ts index 949c35ca6e..5245076bba 100644 --- a/packages/model/src/view/pickup-view-model/pickup-view-model.ts +++ b/packages/model/src/view/pickup-view-model/pickup-view-model.ts @@ -1,5 +1,4 @@ import { - getControl, IPSAppDEPickupView, IPSDEPickupViewPanel, } from '@ibiz/dynamic-model-api'; @@ -30,10 +29,7 @@ export class PickupViewModel< protected async onInit(): Promise { await super.onInit(); - const ctrl = getControl( - this.source, - 'pickupviewpanel', - ) as IPSDEPickupViewPanel; + const ctrl = this.getControl('pickupviewpanel') as IPSDEPickupViewPanel; if (!ctrl) { throw new DefectModelError( this.source, diff --git a/packages/model/src/view/pickup-view2-model/pickup-view2-model.ts b/packages/model/src/view/pickup-view2-model/pickup-view2-model.ts index 34d84590a7..674c4bf54c 100644 --- a/packages/model/src/view/pickup-view2-model/pickup-view2-model.ts +++ b/packages/model/src/view/pickup-view2-model/pickup-view2-model.ts @@ -1,8 +1,4 @@ -import { - getControl, - IPSAppDEPickupView, - IPSTreeExpBar, -} from '@ibiz/dynamic-model-api'; +import { IPSAppDEPickupView, IPSTreeExpBar } from '@ibiz/dynamic-model-api'; import { TreeExpBarModel, TreeModel } from '../../control'; import { DefectModelError } from '../../error'; import { PickupViewModel } from '..'; @@ -37,7 +33,7 @@ export class PickupView2Model extends PickupViewModel { await super.onInit(); // 获取树导航面板 - const ctrl = getControl(this.source, 'treeexpbar') as IPSTreeExpBar; + const ctrl = this.getControl('treeexpbar') as IPSTreeExpBar; if (!ctrl) { throw new DefectModelError( this.source, diff --git a/packages/model/src/view/tree-exp-view-model/tree-exp-view-model.ts b/packages/model/src/view/tree-exp-view-model/tree-exp-view-model.ts index 72c774e527..ec80eccb19 100644 --- a/packages/model/src/view/tree-exp-view-model/tree-exp-view-model.ts +++ b/packages/model/src/view/tree-exp-view-model/tree-exp-view-model.ts @@ -1,5 +1,4 @@ import { - getControl, IPSAppDETreeExplorerView, IPSListExpBar, } from '@ibiz/dynamic-model-api'; @@ -47,7 +46,7 @@ export class TreeExpViewModel extends MDViewModel { await super.onInit(); // 获取树导航面板 - const ctrl = getControl(this.source, 'treeexpbar') as IPSListExpBar; + const ctrl = this.getControl('treeexpbar') as IPSListExpBar; if (!ctrl) { throw new DefectModelError( this.source, diff --git a/packages/model/src/view/view-model/view-model.ts b/packages/model/src/view/view-model/view-model.ts index 5a6fd34554..035d16b353 100644 --- a/packages/model/src/view/view-model/view-model.ts +++ b/packages/model/src/view/view-model/view-model.ts @@ -2,7 +2,9 @@ import { getControl, IPSAppDEEditView, IPSAppView, + IPSControl, IPSDEToolbar, + IPSViewLayoutPanel, } from '@ibiz/dynamic-model-api'; import { AppEntityModel } from '../../app'; import { ToolbarModel } from '../../control'; @@ -82,6 +84,33 @@ export class ViewModel< return this.source.getPSSysCss()?.cssName; } + /** + * @description 视图布局面板 + * @readonly + * @memberof ViewModel + */ + get viewLayoutPanel(): IPSViewLayoutPanel | null { + return this.source.getPSViewLayoutPanel(); + } + + /** + * @description 获取部件 + * @public + * @param {string} name + * @returns {*} {(IPSControl | undefined)} + * @memberof ViewModel + */ + public getControl(name: string): IPSControl | undefined { + const control = getControl(this.source, name); + if (control) { + return getControl(this.source, name); + } + const layout = this.source.getPSViewLayoutPanel(); + if (layout) { + return getControl(layout, name); + } + } + /** * 初始化 * diff --git a/packages/model/src/view/wf-dyna-edit-view3-model/wf-dyna-edit-view3-model.ts b/packages/model/src/view/wf-dyna-edit-view3-model/wf-dyna-edit-view3-model.ts index 4b700cd677..638a189b74 100644 --- a/packages/model/src/view/wf-dyna-edit-view3-model/wf-dyna-edit-view3-model.ts +++ b/packages/model/src/view/wf-dyna-edit-view3-model/wf-dyna-edit-view3-model.ts @@ -1,4 +1,4 @@ -import { getControl, IPSDEDRTab } from '@ibiz/dynamic-model-api'; +import { IPSDEDRTab } from '@ibiz/dynamic-model-api'; import { WFDynaEditViewModel } from '..'; import { DRTabModel } from '../../control'; import { DefectModelError } from '../../error'; @@ -17,7 +17,7 @@ export class WFDynaEditView3Model extends WFDynaEditViewModel { protected async onInit(): Promise { await super.onInit(); - const ctrl = getControl(this.source, 'drtab') as IPSDEDRTab; + const ctrl = this.getControl('drtab') as IPSDEDRTab; if (!ctrl) { throw new DefectModelError(this.source, '缺少叫drtab的分页部件'); } -- Gitee