From c34053034220a17466d3db51923e5217cfb8b2fa Mon Sep 17 00:00:00 2001 From: zhf <1204297681@qq.com> Date: Sun, 29 Sep 2024 20:31:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A7=86=E5=9B=BE=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E8=A1=A5=E5=85=85=E5=B7=A6=E4=BE=A7=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E5=8C=BA=E7=BB=98=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../view-design-collapse-control.scss | 127 +++++++ .../view-design-collapse-control.tsx | 223 ++++++++++++- .../view-design-collapse-list.scss | 59 +++- .../view-design-collapse-list.tsx | 91 ++++- .../view-design-structure-tree.scss | 18 +- .../view-design-structure-tree.tsx | 195 ++++++++--- .../view-design-material-tree.controller.ts | 243 +++++++++++++- .../view-design-material-tree.scss | 12 + .../view-design-material-tree.state.ts | 54 +++ .../view-design-material-tree.tsx | 37 ++- .../psdeview-ctrl/psdeview-ctrl.service.ts | 314 ++++++++++++++++++ .../psdeview-rv/psdeview-rv.service.ts | 110 ++++++ packages/view-design/src/utils/index.ts | 1 + packages/view-design/src/utils/view-rvmode.ts | 23 ++ 14 files changed, 1449 insertions(+), 58 deletions(-) create mode 100644 packages/view-design/src/utils/view-rvmode.ts diff --git a/packages/view-design/src/components/view-design-collapse-control/view-design-collapse-control.scss b/packages/view-design/src/components/view-design-collapse-control/view-design-collapse-control.scss index d4253077..1cf5bb17 100644 --- a/packages/view-design/src/components/view-design-collapse-control/view-design-collapse-control.scss +++ b/packages/view-design/src/components/view-design-collapse-control/view-design-collapse-control.scss @@ -28,3 +28,130 @@ } } } + +@include b(view-design-collapse-control-item) { + position: relative; + display: flex; + align-items: center; + height: 28px; + padding-left: 25px; + line-height: 28px; + cursor: pointer; + + @include when(active) { + color: getCssVar(color, primary, text); + background-color: getCssVar(color, primary); + + .#{bem('view-design-collapse-control-item-wrapper', 'disable-icon')}, + .#{bem('view-design-collapse-control-item-wrapper', 'occupied-caption')} { + color: getCssVar(color, danger, light, active); + } + } + + @include e(icon) { + position: absolute; + left: 6px; + + > svg { + width: 13px; + height: 13px; + } + } +} + +@include b(view-design-collapse-control-item-wrapper) { + display: flex; + align-items: center; + justify-content: center; + + @include e(disable-icon) { + position: absolute; + top: 50%; + left: 7px; + display: flex; + align-items: center; + justify-content: center; + line-height: 0; + color: getCssVar(color, danger); + transform: translateY(-50%); + + > svg { + width: 13px; + height: 13px; + } + } + + @include e(warn-icon) { + position: absolute; + left: 10px; + display: flex; + align-items: center; + justify-content: center; + } + + @include e(close-icon) { + position: absolute; + right: 23px; + display: flex; + align-items: center; + justify-content: center; + + > svg { + width: 13px; + height: 13px; + } + } + + @include e(caption) { + flex: 1; + width: 101px; + margin-right: 64px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + + @include e(occupied-caption) { + color: getCssVar(color, danger); + } + + @include e(no-set-caption) { + flex: 1; + margin-right: 64px; + overflow: hidden; + color: getCssVar(color, text, 3); + text-overflow: ellipsis; + white-space: nowrap; + } +} + +@include b(view-design-collapse-control-item-ctrl-name-wrapper) { + position: absolute; + right: 36px; + display: flex; + flex-flow: row nowrap; + place-content: center center; + align-items: center; + width: 130px; +} + +@include b(view-design-collapse-control-item-ctrl-name) { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +@include b(view-design-collapse-control-splitter) { + display: flex; + flex-direction: row; + place-content: center center; + align-items: center; + width: 100%; + height: 4px; + + @include b(view-design-collapse-control-sp-line) { + width: 90%; + height: 1px; + background: getCssVar(color, border); + } +} diff --git a/packages/view-design/src/components/view-design-collapse-control/view-design-collapse-control.tsx b/packages/view-design/src/components/view-design-collapse-control/view-design-collapse-control.tsx index fef6d801..96cbb600 100644 --- a/packages/view-design/src/components/view-design-collapse-control/view-design-collapse-control.tsx +++ b/packages/view-design/src/components/view-design-collapse-control/view-design-collapse-control.tsx @@ -1,4 +1,4 @@ -import { defineComponent } from 'vue'; +import { PropType, computed, defineComponent, ref } from 'vue'; import { useNamespace } from '@ibiz-template/vue3-util'; import './view-design-collapse-control.scss'; @@ -9,19 +9,187 @@ export default defineComponent({ type: String, default: '', }, + defaultItems: { + type: Array as PropType, + default: () => [], + }, + items: { + type: Array as PropType, + default: () => [], + }, + panelItems: { + type: Array as PropType, + default: () => [], + }, + activeItem: { + type: String, + }, + isDefaultLayout: { + type: Boolean, + default: false, + }, }, - setup() { + emits: ['item-click', 'remove'], + setup(props, { emit }) { const ns = useNamespace('view-design-collapse-control'); + // 收缩值 + const collapseValue = ref('control'); + + // 数据 + const data = computed(() => { + const noSetItems: IData[] = [...props.defaultItems]; + const inSetItems: IData[] = []; + const otherItems: IData[] = [...props.items]; + props.items.forEach(item => { + props.defaultItems.forEach(defaultItem => { + if ( + item.psdeviewctrlname?.toLowerCase() === + defaultItem.psvtctrlname?.toLowerCase() + ) { + const index = noSetItems.findIndex(noSetItem => { + return ( + noSetItem.psvtctrlname?.toLowerCase() === + defaultItem.psvtctrlname?.toLowerCase() + ); + }); + if (index !== -1) { + noSetItems.splice(index, 1); + inSetItems.push(item); + } + } + }); + }); + inSetItems.forEach(item => { + const index = otherItems.findIndex(otherItem => { + return ( + otherItem.psdeviewctrlname?.toLowerCase() === + item.psdeviewctrlname?.toLowerCase() + ); + }); + if (index !== -1) { + otherItems.splice(index, 1); + } + }); + + return { + noSetItems, + inSetItems, + otherItems, + }; + }); + + // 处理项点击 + const handleItemClick = (item: IData) => { + emit('item-click', item); + }; + + // 处理项删除 + const handleRemove = (item: IData) => { + emit('remove', item); + }; + return { ns, + collapseValue, + data, + handleItemClick, + handleRemove, }; }, render() { + const renderItems = (items: IData[]) => { + return items.map(item => { + let isOccupied = false; + this.panelItems.forEach(panelItem => { + if ( + panelItem.pssysviewpanelitemname?.toLowerCase() === + item.psdeviewctrlname?.toLowerCase() + ) { + isOccupied = true; + } + }); + if (this.isDefaultLayout) { + isOccupied = true; + } + return ( +
{ + e.stopPropagation(); + this.handleItemClick(item); + }} + > +
+ + + + + + {item.validflag === 0 || isOccupied ? ( + '' + ) : ( + ! + )} + + {item.text} + +
+ + {item.psctrlname ? item.psctrlname : '-'} + +
+
{ + e.stopPropagation(); + this.handleRemove(item); + }} + > + + + +
+
+
+ ); + }); + }; return (
- - + + {{ title: () => { return ( @@ -33,6 +201,53 @@ export default defineComponent({
); }, + default: () => { + return [ + renderItems(this.data.inSetItems), + this.data.noSetItems.map(item => { + return ( +
+
+ + + +
+
+ + {item.psvtctrlname} + +
+ + {item.psctrlname ? item.psctrlname : '-'} + +
+
+
+ ); + }), + this.data.otherItems.length > 0 && + (this.data.inSetItems.length > 0 || + this.data.noSetItems.length > 0) ? ( +
+
+
+ ) : null, + renderItems(this.data.otherItems), + ]; + }, }} diff --git a/packages/view-design/src/components/view-design-collapse-list/view-design-collapse-list.scss b/packages/view-design/src/components/view-design-collapse-list/view-design-collapse-list.scss index 633c44e5..da4e87cf 100644 --- a/packages/view-design/src/components/view-design-collapse-list/view-design-collapse-list.scss +++ b/packages/view-design/src/components/view-design-collapse-list/view-design-collapse-list.scss @@ -27,4 +27,61 @@ padding: 0; } } -} \ No newline at end of file +} + +@include b(view-design-collapse-list-item) { + position: relative; + display: flex; + align-items: center; + height: 28px; + padding-left: 25px; + line-height: 28px; + cursor: pointer; + + @include when(active) { + color: getCssVar(color, primary, text); + background-color: getCssVar(color, primary); + + @include e(disable-icon) { + color: getCssVar(color, danger, light, active); + } + } + + @include e(disable-icon) { + position: absolute; + top: 50%; + left: 7px; + display: flex; + align-items: center; + justify-content: center; + line-height: 0; + color: getCssVar(color, danger); + transform: translateY(-50%); + + > svg { + width: 13px; + height: 13px; + } + } + + @include e(caption) { + flex: 1; + margin-right: 64px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + + @include e(close-icon) { + position: absolute; + right: 50px; + display: flex; + align-items: center; + justify-content: center; + + > svg { + width: 13px; + height: 13px; + } + } +} diff --git a/packages/view-design/src/components/view-design-collapse-list/view-design-collapse-list.tsx b/packages/view-design/src/components/view-design-collapse-list/view-design-collapse-list.tsx index 34cf9476..ea75c5ad 100644 --- a/packages/view-design/src/components/view-design-collapse-list/view-design-collapse-list.tsx +++ b/packages/view-design/src/components/view-design-collapse-list/view-design-collapse-list.tsx @@ -1,4 +1,4 @@ -import { defineComponent } from 'vue'; +import { PropType, defineComponent, ref } from 'vue'; import { useNamespace } from '@ibiz-template/vue3-util'; import './view-design-collapse-list.scss'; @@ -9,19 +9,43 @@ export default defineComponent({ type: String, default: '', }, + items: { + type: Array as PropType, + default: () => [], + }, + activeItem: { + type: String, + }, }, - setup() { + emits: ['item-click', 'remove'], + setup(_props, { emit }) { const ns = useNamespace('view-design-collapse-list'); + // 收缩值 + const collapseValue = ref('list'); + + // 处理项点击 + const handleItemClick = (item: IData) => { + emit('item-click', item); + }; + + // 处理项添加 + const handleRemove = (item: IData) => { + emit('remove', item); + }; + return { ns, + collapseValue, + handleItemClick, + handleRemove, }; }, render() { return (
- - + + {{ title: () => { return ( @@ -33,6 +57,65 @@ export default defineComponent({
); }, + default: () => { + return this.items.map(item => { + return ( +
{ + e.stopPropagation(); + this.handleItemClick(item); + }} + > + + + + + + + {item.text} + +
{ + e.stopPropagation(); + this.handleRemove(item); + }} + > + + + +
+
+ ); + }); + }, }} diff --git a/packages/view-design/src/components/view-design-structure-tree/view-design-structure-tree.scss b/packages/view-design/src/components/view-design-structure-tree/view-design-structure-tree.scss index 02e0dd6d..ba170562 100644 --- a/packages/view-design/src/components/view-design-structure-tree/view-design-structure-tree.scss +++ b/packages/view-design/src/components/view-design-structure-tree/view-design-structure-tree.scss @@ -26,10 +26,24 @@ font-size: 12px; line-height: 28px; - @include e(action) { + .el-tooltip__trigger { display: flex; align-items: center; justify-content: center; - cursor: pointer; + } + + .el-tooltip__trigger:not(:first-child) { + margin-left: 20px; + } +} + +@include b(view-design-structure-tree-header-content) { + display: flex; + align-items: center; +} + +@include b(view-design-structure-tree-popper) { + .el-popper__arrow { + display: block; } } diff --git a/packages/view-design/src/components/view-design-structure-tree/view-design-structure-tree.tsx b/packages/view-design/src/components/view-design-structure-tree/view-design-structure-tree.tsx index e3e70bb1..774515f5 100644 --- a/packages/view-design/src/components/view-design-structure-tree/view-design-structure-tree.tsx +++ b/packages/view-design/src/components/view-design-structure-tree/view-design-structure-tree.tsx @@ -1,18 +1,34 @@ -import { defineComponent, ref } from 'vue'; +import { computed, defineComponent, ref } from 'vue'; import { useNamespace } from '@ibiz-template/vue3-util'; import './view-design-structure-tree.scss'; export default defineComponent({ name: 'IBizViewDesignStructureTree', - setup() { + props: { + isDefaultLayout: { + type: Boolean, + default: false, + }, + }, + setup(props) { const ns = useNamespace('view-design-structure-tree'); // 搜索值 const searchValue = ref(''); + // 是否可拖拽 + const enableDraggable = computed(() => { + if (searchValue.value || props.isDefaultLayout) { + return false; + } + + return true; + }); + return { ns, searchValue, + enableDraggable, }; }, render() { @@ -33,53 +49,152 @@ export default defineComponent({
布局结构
-
- - + + + + + + + + + + + + + ) : ( +
+ + - + - - + + + + + + - - - -
+ + + + + + + + + + + + + + + + +
+ )}
- +
); diff --git a/packages/view-design/src/panel-items/view-design-material-tree/view-design-material-tree.controller.ts b/packages/view-design/src/panel-items/view-design-material-tree/view-design-material-tree.controller.ts index fd1cae12..e78e0736 100644 --- a/packages/view-design/src/panel-items/view-design-material-tree/view-design-material-tree.controller.ts +++ b/packages/view-design/src/panel-items/view-design-material-tree/view-design-material-tree.controller.ts @@ -1,5 +1,10 @@ -import { PanelItemController, getControl } from '@ibiz-template/runtime'; import { + IAppDEService, + PanelItemController, + getControl, +} from '@ibiz-template/runtime'; +import { + IAppDataEntity, IDEEditForm, IDEFormGroupPanel, IDEFormPage, @@ -7,6 +12,7 @@ import { } from '@ibiz/model-core'; import { clone } from 'ramda'; import { ViewDesignMaterialTreeState } from './view-design-material-tree.state'; +import { DEViewBaseDesignController } from '../../views/de-view-base-design/de-view-base-design.controller'; export class ViewDesignMaterialTreeController extends PanelItemController { declare state: ViewDesignMaterialTreeState; @@ -15,6 +21,14 @@ export class ViewDesignMaterialTreeController extends PanelItemController { return new ViewDesignMaterialTreeState(this.parent?.state); } + /** + * 素材表单 + * + * @author zhanghengfeng + * @date 2024-09-29 20:09:48 + * @readonly + * @type {IDEEditForm} + */ get materialForm(): IDEEditForm { return getControl(this.panel.view.model, 'material') as IDEEditForm; } @@ -28,10 +42,226 @@ export class ViewDesignMaterialTreeController extends PanelItemController { */ materialGroups: IDEFormGroupPanel[] = []; + /** + * 视图控制器 + * + * @author zhanghengfeng + * @date 2024-09-29 20:09:01 + * @readonly + * @type {DEViewBaseDesignController} + */ + get view(): DEViewBaseDesignController { + return this.panel.view as DEViewBaseDesignController; + } + + /** + * 主表单 + * + * @author zhanghengfeng + * @date 2024-09-29 20:09:10 + * @readonly + * @type {IDEEditForm} + */ + get majorForm(): IDEEditForm { + return getControl(this.view.model, 'form') as IDEEditForm; + } + + /** + * 项表单 + * + * @author zhanghengfeng + * @date 2024-09-29 20:09:21 + * @readonly + * @type {IDEEditForm} + */ + get itemForm(): IDEEditForm { + return getControl(this.view.model, 'item') as IDEEditForm; + } + + /** + * 主实体 + * + * @author zhanghengfeng + * @date 2024-09-29 20:09:35 + * @protected + * @type {IAppDataEntity} + */ + protected majorEntity!: IAppDataEntity; + + /** + * 主实体服务 + * + * @author zhanghengfeng + * @date 2024-09-29 20:09:46 + * @protected + * @type {IAppDEService} + */ + protected majorService!: IAppDEService; + + /** + * 项实体 + * + * @author zhanghengfeng + * @date 2024-09-29 20:09:58 + * @protected + * @type {IAppDataEntity} + */ + protected itemEntity!: IAppDataEntity; + + /** + * 项实体服务 + * + * @author zhanghengfeng + * @date 2024-09-29 20:09:08 + * @protected + * @type {IAppDEService} + */ + protected itemService!: IAppDEService; + + /** + * 视图控件服务 + * + * @author zhanghengfeng + * @date 2024-09-29 20:09:35 + * @protected + * @type {IAppDEService} + */ + protected viewCtrlService!: IAppDEService; + + /** + * 视图关系界面服务 + * + * @author zhanghengfeng + * @date 2024-09-29 20:09:52 + * @protected + * @type {IAppDEService} + */ + protected viewRVService!: IAppDEService; + + /** + * 视图逻辑服务 + * + * @author zhanghengfeng + * @date 2024-09-29 20:09:10 + * @protected + * @type {IAppDEService} + */ + protected viewLogicService!: IAppDEService; + protected async onInit(): Promise { await super.onInit(); this.initMaterialGroups(); this.state.activeGroups = this.materialGroups.map(group => group.codeName!); + this.state.activeItem = this.view.select.data?.id || ''; + this.handleSelectDataChange = this.handleSelectDataChange.bind(this); + this.view.select.on(this.handleSelectDataChange); + // 初始化当前数据服务 + await this.initBaseResource(); + // 加载数据 + await this.load(); + } + + /** + * 初始化基础资源 + * + * @author zhanghengfeng + * @date 2024-09-29 20:09:47 + * @protected + * @return {*} {Promise} + */ + protected async initBaseResource(): Promise { + const app = ibiz.hub.getApp(this.view.model.appId); + this.majorEntity = await ibiz.hub.getAppDataEntity( + this.majorForm.appDataEntityId!, + this.view.model.appId, + ); + this.majorService = await app.deService.getService( + this.panel.context, + this.majorForm.appDataEntityId!, + ); + this.itemEntity = await ibiz.hub.getAppDataEntity( + this.itemForm.appDataEntityId!, + this.view.model.appId, + ); + this.itemService = await app.deService.getService( + this.panel.context, + this.itemForm.appDataEntityId!, + ); + this.viewCtrlService = await app.deService.getService( + this.panel.context, + 'viewdesign.psdeviewctrl', + ); + this.viewRVService = await app.deService.getService( + this.panel.context, + 'viewdesign.psdeviewrv', + ); + this.viewLogicService = await app.deService.getService( + this.panel.context, + 'viewdesign.psdeviewlogic', + ); + } + + /** + * 加载数据 + * + * @author zhanghengfeng + * @date 2024-09-29 20:09:17 + * @protected + * @return {*} {Promise} + */ + protected async load(): Promise { + const viewCtrlResult = await this.viewCtrlService.fetchDefault( + this.panel.context, + this.panel.params, + ); + if (viewCtrlResult.ok && Array.isArray(viewCtrlResult.data)) { + this.state.viewCtrlItems = viewCtrlResult.data; + } + const viewRVResult = await this.viewRVService.fetchDefault( + this.panel.context, + this.panel.params, + ); + if (viewRVResult.ok && Array.isArray(viewRVResult.data)) { + this.state.viewRVItems = viewRVResult.data; + } + const viewLogicResult = await this.viewLogicService.fetchDefault( + this.panel.context, + this.panel.params, + ); + if (viewLogicResult.ok && Array.isArray(viewLogicResult.data)) { + this.state.viewLogicItems = viewLogicResult.data; + } + } + + /** + * 处理选中数据变化 + * + * @author zhanghengfeng + * @date 2024-09-29 20:09:34 + * @param {(IData | null)} [data] + */ + handleSelectDataChange(data?: IData | null): void { + this.state.activeItem = data?.id || ''; + } + + /** + * 处理数据选中 + * + * @author zhanghengfeng + * @date 2024-09-29 20:09:50 + * @param {IData} item + * @return {*} {void} + */ + handleItemSelect(item: IData): void { + if (!item) { + return; + } + this.view.call('onActive', { + id: item.srfkey!, + label: item.srfmajortext!, + type: item.itemtype, + data: item, + }); } /** @@ -70,4 +300,15 @@ export class ViewDesignMaterialTreeController extends PanelItemController { this.materialGroups = clone(groups); } } + + /** + * 销毁方法 + * + * @author zhanghengfeng + * @date 2024-09-29 20:09:19 + */ + destroy(): void { + super.destroy(); + this.view.select.off(this.handleSelectDataChange); + } } diff --git a/packages/view-design/src/panel-items/view-design-material-tree/view-design-material-tree.scss b/packages/view-design/src/panel-items/view-design-material-tree/view-design-material-tree.scss index fbe6416b..afd9fe45 100644 --- a/packages/view-design/src/panel-items/view-design-material-tree/view-design-material-tree.scss +++ b/packages/view-design/src/panel-items/view-design-material-tree/view-design-material-tree.scss @@ -5,8 +5,20 @@ } @include b(view-design-material-tree-caption) { + flex: 0 0 auto; padding: 0 10px; font-size: 18px; line-height: 40px; cursor: pointer; } + +@include b(view-design-material-tree-container) { + display: flex; + flex-direction: column; + height: 100%; +} + +@include b(view-design-material-tree-content) { + flex: 1 1 0; + overflow: auto; +} diff --git a/packages/view-design/src/panel-items/view-design-material-tree/view-design-material-tree.state.ts b/packages/view-design/src/panel-items/view-design-material-tree/view-design-material-tree.state.ts index 61973f5a..365c32a1 100644 --- a/packages/view-design/src/panel-items/view-design-material-tree/view-design-material-tree.state.ts +++ b/packages/view-design/src/panel-items/view-design-material-tree/view-design-material-tree.state.ts @@ -27,4 +27,58 @@ export class ViewDesignMaterialTreeState extends PanelItemState { * @type {string} */ activePage: string = ''; + + /** + * 面板项 + * + * @author zhanghengfeng + * @date 2024-09-29 20:09:47 + * @type {IData[]} + */ + panelItems: IData[] = []; + + /** + * 视图默认控件 + * + * @author zhanghengfeng + * @date 2024-09-29 20:09:57 + * @type {IData[]} + */ + viewCtrlDefaultItems: IData[] = []; + + /** + * 视图控件 + * + * @author zhanghengfeng + * @date 2024-09-29 20:09:18 + * @type {IData[]} + */ + viewCtrlItems: IData[] = []; + + /** + * 视图关系界面 + * + * @author zhanghengfeng + * @date 2024-09-29 20:09:32 + * @type {IData[]} + */ + viewRVItems: IData[] = []; + + /** + * 视图逻辑 + * + * @author zhanghengfeng + * @date 2024-09-29 20:09:44 + * @type {IData[]} + */ + viewLogicItems: IData[] = []; + + /** + * 激活项标识 + * + * @author zhanghengfeng + * @date 2024-09-29 20:09:56 + * @type {string} + */ + activeItem: string = ''; } diff --git a/packages/view-design/src/panel-items/view-design-material-tree/view-design-material-tree.tsx b/packages/view-design/src/panel-items/view-design-material-tree/view-design-material-tree.tsx index c1234fd4..41e1cfd4 100644 --- a/packages/view-design/src/panel-items/view-design-material-tree/view-design-material-tree.tsx +++ b/packages/view-design/src/panel-items/view-design-material-tree/view-design-material-tree.tsx @@ -28,6 +28,7 @@ export default defineComponent({ }; }, render() { + const c = this.controller; if (this.controller.state.activePage === 'viewdesign') { return (
@@ -45,13 +46,37 @@ export default defineComponent({ }, bottom: () => { return ( -
-
- {this.controller.panel.view?.state?.caption || ''} +
+
{ + c.view.call('onActiveRoot'); + }} + > + {this.controller.view?.state?.data?.srfmajortext || ''} +
+
+ c.handleItemSelect(item)} + > + c.handleItemSelect(item)} + > + c.handleItemSelect(item)} + >
- - -
); }, diff --git a/packages/view-design/src/service/psdeview-ctrl/psdeview-ctrl.service.ts b/packages/view-design/src/service/psdeview-ctrl/psdeview-ctrl.service.ts index 9dcf78c8..387d90e9 100644 --- a/packages/view-design/src/service/psdeview-ctrl/psdeview-ctrl.service.ts +++ b/packages/view-design/src/service/psdeview-ctrl/psdeview-ctrl.service.ts @@ -1,8 +1,322 @@ +/* eslint-disable eqeqeq */ import { DEService, IDataEntity } from '@ibiz-template/runtime'; +import { IHttpResponse } from '@ibiz-template/core'; +import { notNilEmpty } from 'qx-util'; import { PSDEViewCtrl } from '../../entity'; export class PSDEViewCtrlService extends DEService { protected newEntity(data: IData | IDataEntity): IDataEntity { + this.fillCtrlName(data); + this.fillConfigInfo(data); return new PSDEViewCtrl(this.model, data); } + + async exec( + id: string, + context: IContext, + params?: IData | IData[], + params2?: IParams, + header?: IData, + ): Promise { + if (id === 'update' && params) { + if (Array.isArray(params)) { + params.forEach(param => { + this.fillCtrlName(param); + this.fillConfigInfo(param); + }); + } else { + this.fillCtrlName(params); + this.fillConfigInfo(params); + } + } + if (id === 'get') { + const res = await super.exec(id, context, params, params2, header); + if (res.ok && res.data) { + this.fillCtrlName(res.data); + } + return res; + } + return super.exec(id, context, params, params2, header); + } + + /** + * 填充通用部件属性 + * + * @author zhanghengfeng + * @date 2024-09-29 19:09:53 + * @protected + * @param {IData} entity + */ + protected fillCtrlName(entity: IData): void { + if (!entity) { + return; + } + if (notNilEmpty(entity.psdeviewctrltype)) { + entity.configinfoex = entity.configinfo; + if ( + entity.psdeviewctrltype == 'CALENDAR' || + entity.psdeviewctrltype == 'CALENDAREXPBAR' + ) { + entity.psctrlid = entity.pssyscalendarid; + entity.psctrlname = entity.pssyscalendarname; + } + if ( + entity.psdeviewctrltype == 'MAP' || + entity.psdeviewctrltype == 'MAPEXPBAR' + ) { + entity.psctrlid = entity.pssysmapviewid; + entity.psctrlname = entity.pssysmapviewname; + } + if ( + entity.psdeviewctrltype == 'CHART' || + entity.psdeviewctrltype == 'CHARTEXPBAR' + ) { + entity.psctrlid = entity.psdechartid; + entity.psctrlname = entity.psdechartname; + } + if (entity.psdeviewctrltype == 'DASHBOARD') { + entity.psctrlid = entity.pssysdashboardid; + entity.psctrlname = entity.pssysdashboardname; + } + if ( + entity.psdeviewctrltype == 'DATAVIEW' || + entity.psdeviewctrltype == 'DATAVIEWEXPBAR' || + entity.psdeviewctrltype == 'KANBAN' + ) { + entity.psctrlid = entity.psdedataviewid; + entity.psctrlname = entity.psdedataviewname; + } + if (entity.psdeviewctrltype == 'DRBAR') { + entity.psctrlid = entity.psdedrid; + entity.psctrlname = entity.psdedrname; + } + if (entity.psdeviewctrltype == 'DRTAB') { + entity.psctrlid = entity.psdedrid; + entity.psctrlname = entity.psdedrname; + } + if ( + entity.psdeviewctrltype == 'GRID' || + entity.psdeviewctrltype == 'GRIDEXPBAR' + ) { + entity.psctrlid = entity.psdegridid; + entity.psctrlname = entity.psdegridname; + } + if ( + entity.psdeviewctrltype == 'LIST' || + entity.psdeviewctrltype == 'LISTEXPBAR' + ) { + entity.psctrlid = entity.psdelistid; + entity.psctrlname = entity.psdelistname; + } + if (entity.psdeviewctrltype == 'MOBMDCTRL') { + entity.psctrlid = entity.psdelistid; + entity.psctrlname = entity.psdelistname; + } + if (entity.psdeviewctrltype == 'FORM') { + entity.psctrlid = entity.psdeformid; + entity.psctrlname = entity.psdeformname; + } + if (entity.psdeviewctrltype == 'PANEL') { + entity.psctrlid = entity.pssysviewpanelid; + entity.psctrlname = entity.pssysviewpanelname; + } + if (entity.psdeviewctrltype == 'REPORTPANEL') { + entity.psctrlid = entity.psdereportid; + entity.psctrlname = entity.psdereportname; + } + if (entity.psdeviewctrltype == 'SEARCHBAR') { + entity.psctrlid = entity.pssyssearchbarid; + entity.psctrlname = entity.pssyssearchbarname; + } + if (entity.psdeviewctrltype == 'SEARCHFORM') { + entity.psctrlid = entity.psdeformid; + entity.psctrlname = entity.psdeformname; + } + if (entity.psdeviewctrltype == 'TOOLBAR') { + entity.psctrlid = entity.psdetoolbarid; + entity.psctrlname = entity.psdetoolbarname; + } + if (entity.psdeviewctrltype == 'TREEEXPBAR') { + entity.psctrlid = entity.psdetreeviewid; + entity.psctrlname = entity.psdetreeviewname; + } + if ( + entity.psdeviewctrltype == 'TREEVIEW' || + entity.psdeviewctrltype == 'GANTT' || + entity.psdeviewctrltype == 'TREEGRIDEX' + ) { + entity.psctrlid = entity.psdetreeviewid; + entity.psctrlname = entity.psdetreeviewname; + } + if (entity.psdeviewctrltype == 'TREEGRID') { + entity.psctrlid = entity.psdegridid; + entity.psctrlname = entity.psdegridname; + } + if ( + entity.psdeviewctrltype == 'WIZARDPANEL' || + entity.psdeviewctrltype == 'STATEWIZARDPANEL' + ) { + entity.psctrlid = entity.psdewizardid; + entity.psctrlname = entity.psdewizardname; + } + } + } + + /** + * 填充通用部件说明 + * + * @author zhanghengfeng + * @date 2024-09-29 19:09:27 + * @protected + * @param {IData} entity + */ + protected fillConfigInfo(entity: IData): void { + if (!entity) { + return; + } + let strConfigInfo = ''; + if (notNilEmpty(entity.psdetoolbarname)) { + if (notNilEmpty(strConfigInfo)) { + strConfigInfo += ';'; + } + strConfigInfo += '[工具栏]'; + strConfigInfo += entity.psdetoolbarname; + } + if (notNilEmpty(entity.psdegridname)) { + if (notNilEmpty(strConfigInfo)) { + strConfigInfo += ';'; + } + strConfigInfo += '[表格]'; + strConfigInfo += entity.psdegridname; + } + if (notNilEmpty(entity.psdedataviewname)) { + if (notNilEmpty(strConfigInfo)) { + strConfigInfo += ';'; + } + strConfigInfo += '[数据视图]'; + strConfigInfo += entity.psdedataviewname; + } + + if (notNilEmpty(entity.psdeformname)) { + if (notNilEmpty(strConfigInfo)) { + strConfigInfo += ';'; + } + strConfigInfo += '[表单]'; + strConfigInfo += entity.psdeformname; + } + + if (notNilEmpty(entity.psdedrname)) { + if (notNilEmpty(strConfigInfo)) { + strConfigInfo += ';'; + } + strConfigInfo += '[关系组]'; + strConfigInfo += entity.psdedrname; + } + + if (notNilEmpty(entity.psdeviewname)) { + if (notNilEmpty(strConfigInfo)) { + strConfigInfo += ';'; + } + strConfigInfo += '[实体视图]'; + strConfigInfo += entity.psdeviewname; + } + + if (notNilEmpty(entity.psdetreeviewname)) { + if (notNilEmpty(strConfigInfo)) { + strConfigInfo += ';'; + } + strConfigInfo += '[树视图]'; + strConfigInfo += entity.psdetreeviewname; + } + + if (notNilEmpty(entity.psdechartname)) { + if (notNilEmpty(strConfigInfo)) { + strConfigInfo += ';'; + } + strConfigInfo += '[数据图表]'; + strConfigInfo += entity.psdechartname; + } + + if (notNilEmpty(entity.psdereportname)) { + if (notNilEmpty(strConfigInfo)) { + strConfigInfo += ';'; + } + strConfigInfo += '[报表]'; + strConfigInfo += entity.psdereportname; + } + + if (notNilEmpty(entity.psdelistname)) { + if (notNilEmpty(strConfigInfo)) { + strConfigInfo += ';'; + } + strConfigInfo += '[数据列表]'; + strConfigInfo += entity.psdelistname; + } + + if (notNilEmpty(entity.psdewizardname)) { + if (notNilEmpty(strConfigInfo)) { + strConfigInfo += ';'; + } + strConfigInfo += '[向导]'; + strConfigInfo += entity.psdewizardname; + } + + if (notNilEmpty(entity.pssysdashboardname)) { + if (notNilEmpty(strConfigInfo)) { + strConfigInfo += ';'; + } + strConfigInfo += '[数据看板]'; + strConfigInfo += entity.pssysdashboardname; + } + + if (notNilEmpty(entity.pssyscalendarname)) { + if (notNilEmpty(strConfigInfo)) { + strConfigInfo += ';'; + } + strConfigInfo += '[日历部件]'; + strConfigInfo += entity.pssyscalendarname; + } + + if (notNilEmpty(entity.pssysmapviewname)) { + if (notNilEmpty(strConfigInfo)) { + strConfigInfo += ';'; + } + strConfigInfo += '[地图部件]'; + strConfigInfo += entity.pssysmapviewname; + } + + if (notNilEmpty(entity.pssyssearchbarname)) { + if (notNilEmpty(strConfigInfo)) { + strConfigInfo += ';'; + } + strConfigInfo += '[搜索栏]'; + strConfigInfo += entity.pssyssearchbarname; + } + + if (notNilEmpty(entity.pssysmsgtemplname)) { + if (notNilEmpty(strConfigInfo)) { + strConfigInfo += ';'; + } + strConfigInfo += '[消息模板]'; + strConfigInfo += entity.pssysmsgtemplname; + } + + if (notNilEmpty(entity.psdeactionname)) { + if (notNilEmpty(strConfigInfo)) { + strConfigInfo += ';'; + } + strConfigInfo += '[处理行为]'; + strConfigInfo += entity.psdeactionname; + } + + if (notNilEmpty(entity.psdedatasetname)) { + if (notNilEmpty(strConfigInfo)) { + strConfigInfo += ';'; + } + strConfigInfo += '[数据集合]'; + strConfigInfo += entity.psdedatasetname; + } + + entity.configinfo = strConfigInfo; + } } diff --git a/packages/view-design/src/service/psdeview-rv/psdeview-rv.service.ts b/packages/view-design/src/service/psdeview-rv/psdeview-rv.service.ts index 88fd7831..95963c36 100644 --- a/packages/view-design/src/service/psdeview-rv/psdeview-rv.service.ts +++ b/packages/view-design/src/service/psdeview-rv/psdeview-rv.service.ts @@ -1,8 +1,118 @@ +/* eslint-disable eqeqeq */ +/* eslint-disable no-plusplus */ import { DEService, IDataEntity } from '@ibiz-template/runtime'; +import { IHttpResponse } from '@ibiz-template/core'; +import { isNilOrEmpty, notNilEmpty } from 'qx-util'; import { PSDEViewRV } from '../../entity'; +import { ViewRVModeCodeList } from '../../utils'; export class PSDEViewRVService extends DEService { protected newEntity(data: IData | IDataEntity): IDataEntity { + this.calcPSDEViewRVName(data); return new PSDEViewRV(this.model, data); } + + async exec( + id: string, + context: IContext, + params?: IData | IData[], + params2?: IParams, + header?: IData, + ): Promise { + if (id === 'update' && params) { + if (Array.isArray(params)) { + params.forEach(param => { + this.recalcRefModeAndRefModeParam(param); + }); + } else { + this.recalcRefModeAndRefModeParam(params); + } + } + if (id === 'get') { + const res = await super.exec(id, context, params, params2, header); + if (res.ok && res.data) { + res.data.defviewflag = this.calcDefaultViewType(res.data); + } + return res; + } + return super.exec(id, context, params, params2, header); + } + + /** + * 计算名称 + * + * @author zhanghengfeng + * @date 2024-09-29 19:09:33 + * @protected + * @param {IData} rv + */ + protected calcPSDEViewRVName(rv: IData): void { + if (!rv) { + return; + } + if (rv.refmode != 'CUSTOM') { + if (isNilOrEmpty(rv.refparam)) { + rv.psdeviewrvname = rv.refmode; + } else { + rv.psdeviewrvname = `${rv.refmode}:${rv.refparam}`; + } + } + if (isNilOrEmpty(rv.refmodetext)) { + rv.refmodetext = rv.refparamdesc; + } + this.recalcRefModeAndRefModeParam(rv); + } + + /** + * 重新计算模式和参数 + * + * @author zhanghengfeng + * @date 2024-09-29 19:09:20 + * @protected + * @param {IData} rv + */ + protected recalcRefModeAndRefModeParam(rv: IData): void { + if ( + isNilOrEmpty(rv.refmode) && + notNilEmpty(rv.psdeviewrvname) && + rv.refmode != 'CUSTOM' + ) { + let var2 = ''; + let var3 = ''; + let var4 = rv.psdeviewrvname.indexOf(':'); + if (var4 == -1) { + var2 = rv.psdeviewrvname; + } else { + var2 = rv.psdeviewrvname.substring(0, var4); + ++var4; + if (var4 < rv.psdeviewrvname.length) { + var3 = rv.psdeviewrvname.substring(var4); + } + } + + const var5 = ViewRVModeCodeList.getValue(var2); + if (var5 == null) { + var2 = 'CUSTOM'; + var3 = ''; + } + rv.refmode = var2; + rv.refparam = var3; + } + } + + /** + * 计算是否引用类型为预置视图类型 + * + * @author zhanghengfeng + * @date 2024-09-29 19:09:26 + * @protected + * @param {IData} psdeviewrv + * @return {*} + */ + protected calcDefaultViewType(psdeviewrv: IData): number { + if (notNilEmpty(psdeviewrv.minorpsdeviewid)) { + return 0; + } + return 1; + } } diff --git a/packages/view-design/src/utils/index.ts b/packages/view-design/src/utils/index.ts index 744176a5..bd73ce94 100644 --- a/packages/view-design/src/utils/index.ts +++ b/packages/view-design/src/utils/index.ts @@ -1 +1,2 @@ export { SelectState } from './select-state/select-state'; +export { ViewRVModeCodeList } from './view-rvmode'; diff --git a/packages/view-design/src/utils/view-rvmode.ts b/packages/view-design/src/utils/view-rvmode.ts new file mode 100644 index 00000000..6057d4c4 --- /dev/null +++ b/packages/view-design/src/utils/view-rvmode.ts @@ -0,0 +1,23 @@ +/** + * 视图关系界面模式 + * + * @author zhanghengfeng + * @date 2024-09-29 20:09:22 + * @export + * @class ViewRVModeCodeList + */ +export class ViewRVModeCodeList { + static readonly data = { + NEWDATA: '新建数据视图', + EDITDATA: '编辑数据视图', + NEWDATAWIZARD: '新建数据向导视图', + MPICKUPVIEW: '批添加多选数据视图', + RDITEM: '重定向视图项', + EDITDATAX: '编辑数据视图(动态视图)', + CUSTOM: '自定义', + }; + + static getValue(key: string): string { + return this.data[key]; + } +} -- Gitee