diff --git a/packages/md-design/src/entity/index.ts b/packages/md-design/src/entity/index.ts index 4d81b5186dfa6a2543897971a70807766efcc0bf..628b0e067a38d8341e06e35ee18d07a91b426146 100644 --- a/packages/md-design/src/entity/index.ts +++ b/packages/md-design/src/entity/index.ts @@ -1,2 +1,5 @@ export { PSDEDataView } from './psdedata-view/psdedata-view'; export { PSDEList } from './psdelist/psdelist'; +export { PSDEListItem } from './psdelist-item/psdelist-item'; +export { PSDEListLogic } from './psdelist-logic/psdelist-logic'; +export { PSDEDataViewLogic } from './psdedata-view-logic/psdedata-view-logic'; diff --git a/packages/md-design/src/entity/psdedata-view-logic/psdedata-view-logic.ts b/packages/md-design/src/entity/psdedata-view-logic/psdedata-view-logic.ts new file mode 100644 index 0000000000000000000000000000000000000000..f29d56c44996a9f95808fb6395699de973dc65a9 --- /dev/null +++ b/packages/md-design/src/entity/psdedata-view-logic/psdedata-view-logic.ts @@ -0,0 +1,27 @@ +import { AppDataEntity } from '@ibiz-template/runtime'; + +export class PSDEDataViewLogic extends AppDataEntity { + get itemtype() { + return 'PSDEDATAVIEWLOGIC'; + } + + get text() { + let text = `事件[${this.eventnames || ''}]`; + if (this.dstlogictype === 'DEUIACTION') { + text += `触发界面行为==>${this.psdeuiactionname || ''}`; + } else if (this.dstlogictype === 'DEUILOGIC') { + text += `触发界面逻辑==>${this.psdelogicname || ''}`; + } else if (this.dstlogictype === 'PFPLUGIN') { + text += `触发插件调用==>${this.pssyspfpluginname || ''}`; + } else if (this.dstlogictype === 'SCRIPT') { + text += `触发脚本代码`; + } + return text; + } + + clone(): PSDEDataViewLogic { + const entity = new PSDEDataViewLogic(this._entity, this._data); + entity.srfkey = this.srfkey; + return entity; + } +} diff --git a/packages/md-design/src/entity/psdelist-item/psdelist-item.ts b/packages/md-design/src/entity/psdelist-item/psdelist-item.ts new file mode 100644 index 0000000000000000000000000000000000000000..eaa6b2bfe8d2a927a7948b7276a800b61790c692 --- /dev/null +++ b/packages/md-design/src/entity/psdelist-item/psdelist-item.ts @@ -0,0 +1,25 @@ +import { AppDataEntity } from '@ibiz-template/runtime'; +import { notNilEmpty } from 'qx-util'; + +export class PSDEListItem extends AppDataEntity { + get text() { + let caption = ''; + if (notNilEmpty(this.caption)) { + caption += this.caption; + } + if (notNilEmpty(this.psdelistitemname)) { + if (notNilEmpty(caption)) { + caption += `(${this.psdelistitemname})`; + } else { + caption = this.psdelistitemname; + } + } + return caption; + } + + clone(): PSDEListItem { + const entity = new PSDEListItem(this._entity, this._data); + entity.srfkey = this.srfkey; + return entity; + } +} diff --git a/packages/md-design/src/entity/psdelist-logic/psdelist-logic.ts b/packages/md-design/src/entity/psdelist-logic/psdelist-logic.ts new file mode 100644 index 0000000000000000000000000000000000000000..645203455f5241c5182c4ab0bb5748c693d8137d --- /dev/null +++ b/packages/md-design/src/entity/psdelist-logic/psdelist-logic.ts @@ -0,0 +1,27 @@ +import { AppDataEntity } from '@ibiz-template/runtime'; + +export class PSDEListLogic extends AppDataEntity { + get itemtype() { + return 'PSDELISTLOGIC'; + } + + get text() { + let text = `事件[${this.eventnames || ''}]`; + if (this.dstlogictype === 'DEUIACTION') { + text += `触发界面行为==>${this.psdeuiactionname || ''}`; + } else if (this.dstlogictype === 'DEUILOGIC') { + text += `触发界面逻辑==>${this.psdelogicname || ''}`; + } else if (this.dstlogictype === 'PFPLUGIN') { + text += `触发插件调用==>${this.pssyspfpluginname || ''}`; + } else if (this.dstlogictype === 'SCRIPT') { + text += `触发脚本代码`; + } + return text; + } + + clone(): PSDEListLogic { + const entity = new PSDEListLogic(this._entity, this._data); + entity.srfkey = this.srfkey; + return entity; + } +} diff --git a/packages/md-design/src/panel-items/de-data-view-design-material-area/de-data-view-design-material-area.controller.ts b/packages/md-design/src/panel-items/de-data-view-design-material-area/de-data-view-design-material-area.controller.ts index 01b1c390233f686f60a41e02390e781dadcdc67e..79fdc06197d1b716b7728a6364230c7f6ab8d88f 100644 --- a/packages/md-design/src/panel-items/de-data-view-design-material-area/de-data-view-design-material-area.controller.ts +++ b/packages/md-design/src/panel-items/de-data-view-design-material-area/de-data-view-design-material-area.controller.ts @@ -4,7 +4,7 @@ import { IDEToolbar, IDEToolbarItem, } from '@ibiz/model-core'; -import { RuntimeError } from '@ibiz-template/core'; +import { IPortalMessage, RuntimeError } from '@ibiz-template/core'; import { IAppDEService, UIActionUtil, @@ -139,7 +139,112 @@ export class DEDataViewDesignMaterialAreaController extends PanelDesignMaterialA } } + /** + * 加载数据项 + * + * @author zhanghengfeng + * @date 2024-11-14 20:11:04 + * @protected + * @return {*} {Promise} + */ + protected async loadDataItems(): Promise { + const res = await this.dataItemService.fetchDefault( + this.viewContext, + this.panel.params, + ); + if (res.ok && Array.isArray(res.data)) { + this.state.dataItems = res.data; + } + } + + /** + * 加载卡片逻辑 + * + * @author zhanghengfeng + * @date 2024-11-14 20:11:31 + * @protected + * @return {*} {Promise} + */ + protected async loadDataViewLogicItems(): Promise { + const res = await this.dataviewLogicService.fetchDefault( + this.viewContext, + this.panel.params, + ); + if (res.ok && Array.isArray(res.data)) { + this.state.dataviewLogicItems = res.data; + } + } + + /** + * 加载数据 + * + * @author zhanghengfeng + * @date 2024-11-14 20:11:01 + * @protected + * @return {*} {Promise} + */ protected async load(): Promise { await super.load(); + await this.loadDataItems(); + await this.loadDataViewLogicItems(); + } + + /** + * 监听数据变化 + * + * @author zhanghengfeng + * @date 2024-11-14 20:11:17 + * @protected + * @param {IPortalMessage} msg + */ + protected onDEDataChange(msg: IPortalMessage): void { + const data = msg.data as IData; + const nameList = [ + this.itemEntity.codeName, + 'PSDEListItem', + 'PSDEDataViewLogic', + ]; + if (data && nameList.includes(data.srfdecodename)) { + this.refresh(); + } + } + + /** + * 删除数据项 + * + * @author zhanghengfeng + * @date 2024-11-14 20:11:31 + * @param {IData} item + * @return {*} {Promise} + */ + public async removeDataItem(item: IData): Promise { + const res = await this.dataItemService.removeTemp(this.viewContext, item); + if (res.ok && res.data) { + if (this.state.activeItem === res.data.srfkey) { + this.view.call('onActiveRoot'); + } + await this.loadDataItems(); + } + } + + /** + * 删除卡片逻辑 + * + * @author zhanghengfeng + * @date 2024-11-14 20:11:49 + * @param {IData} item + * @return {*} {Promise} + */ + public async removeDataViewLogicItem(item: IData): Promise { + const res = await this.dataviewLogicService.removeTemp( + this.viewContext, + item, + ); + if (res.ok && res.data) { + if (this.state.activeItem === res.data.srfkey) { + this.view.call('onActiveRoot'); + } + await this.loadDataViewLogicItems(); + } } } diff --git a/packages/md-design/src/panel-items/de-data-view-design-material-area/de-data-view-design-material-area.tsx b/packages/md-design/src/panel-items/de-data-view-design-material-area/de-data-view-design-material-area.tsx index b16e29c639673ce07b617db14b2191a6ae9b89cd..650eec7f778c56be6c709b0f4ad0cfe622f7dfad 100644 --- a/packages/md-design/src/panel-items/de-data-view-design-material-area/de-data-view-design-material-area.tsx +++ b/packages/md-design/src/panel-items/de-data-view-design-material-area/de-data-view-design-material-area.tsx @@ -89,7 +89,7 @@ export default defineComponent({ event: MouseEvent; action: IDEToolbarItem; }) => c.excuteAction(event, action)} - // onRemove={(item: IData) => c.removeViewRV(item)} + onRemove={(item: IData) => c.removeDataItem(item)} > c.excuteAction(event, action)} - // onRemove={(item: IData) => c.removeViewLogic(item)} + onRemove={(item: IData) => + c.removeDataViewLogicItem(item) + } > diff --git a/packages/md-design/src/panel-items/de-list-design-material-area/de-list-design-material-area.controller.ts b/packages/md-design/src/panel-items/de-list-design-material-area/de-list-design-material-area.controller.ts index 093796087746f7a8c82a1c5fca5aea0fe7b55867..13d62c853b578a1400aaaab09b102a9bf40060ac 100644 --- a/packages/md-design/src/panel-items/de-list-design-material-area/de-list-design-material-area.controller.ts +++ b/packages/md-design/src/panel-items/de-list-design-material-area/de-list-design-material-area.controller.ts @@ -4,7 +4,7 @@ import { IDEToolbar, IDEToolbarItem, } from '@ibiz/model-core'; -import { RuntimeError } from '@ibiz-template/core'; +import { IPortalMessage, RuntimeError } from '@ibiz-template/core'; import { IAppDEService, UIActionUtil, @@ -139,7 +139,109 @@ export class DEListDesignMaterialAreaController extends PanelDesignMaterialAreaC } } + /** + * 加载数据项 + * + * @author zhanghengfeng + * @date 2024-11-14 20:11:28 + * @protected + * @return {*} {Promise} + */ + protected async loadDataItems(): Promise { + const res = await this.dataItemService.fetchDefault( + this.viewContext, + this.panel.params, + ); + if (res.ok && Array.isArray(res.data)) { + this.state.dataItems = res.data; + } + } + + /** + * 加载列表逻辑 + * + * @author zhanghengfeng + * @date 2024-11-14 20:11:42 + * @protected + * @return {*} {Promise} + */ + protected async loadListLogicItems(): Promise { + const res = await this.listLogicService.fetchDefault( + this.panel.context, + this.panel.params, + ); + if (res.ok && Array.isArray(res.data)) { + this.state.listLogicItems = res.data; + } + } + + /** + * 加载数据 + * + * @author zhanghengfeng + * @date 2024-11-14 20:11:00 + * @protected + * @return {*} {Promise} + */ protected async load(): Promise { await super.load(); + await this.loadDataItems(); + await this.loadListLogicItems(); + } + + /** + * 监听数据变化 + * + * @author zhanghengfeng + * @date 2024-11-14 20:11:18 + * @protected + * @param {IPortalMessage} msg + */ + protected onDEDataChange(msg: IPortalMessage): void { + const data = msg.data as IData; + const nameList = [ + this.itemEntity.codeName, + 'PSDEListItem', + 'PSDEListLogic', + ]; + if (data && nameList.includes(data.srfdecodename)) { + this.refresh(); + } + } + + /** + * 删除数据项 + * + * @author zhanghengfeng + * @date 2024-11-14 20:11:29 + * @param {IData} item + * @return {*} {Promise} + */ + public async removeDataItem(item: IData): Promise { + const res = await this.dataItemService.removeTemp(this.viewContext, item); + if (res.ok && res.data) { + if (this.state.activeItem === res.data.srfkey) { + this.view.call('onActiveRoot'); + } + await this.loadDataItems(); + } + } + + /** + * 删除列表逻辑 + * + * @author zhanghengfeng + * @date 2024-11-14 20:11:20 + * @param {IData} item + * @return {*} {Promise} + */ + public async removeListLogicItem(item: IData): Promise { + const res = await this.listLogicService.removeTemp(this.viewContext, item); + if (res.ok && res.data) { + if (this.state.activeItem === res.data.srfkey) { + this.view.call('onActiveRoot'); + } + await this.loadListLogicItems(); + } } } diff --git a/packages/md-design/src/panel-items/de-list-design-material-area/de-list-design-material-area.tsx b/packages/md-design/src/panel-items/de-list-design-material-area/de-list-design-material-area.tsx index d25205e0c82b074b7a5ac6efd922689ab20331cf..7b357afa030af57c884710f6c2dc1abdcb2cb42b 100644 --- a/packages/md-design/src/panel-items/de-list-design-material-area/de-list-design-material-area.tsx +++ b/packages/md-design/src/panel-items/de-list-design-material-area/de-list-design-material-area.tsx @@ -89,7 +89,7 @@ export default defineComponent({ event: MouseEvent; action: IDEToolbarItem; }) => c.excuteAction(event, action)} - // onRemove={(item: IData) => c.removeViewRV(item)} + onRemove={(item: IData) => c.removeDataItem(item)} > c.excuteAction(event, action)} - // onRemove={(item: IData) => c.removeViewLogic(item)} + onRemove={(item: IData) => c.removeListLogicItem(item)} > diff --git a/packages/md-design/src/service/index.ts b/packages/md-design/src/service/index.ts index 21c518e21ff0e0483098dde46c94ef598ddab3dd..0dad081ca6e7086faf79bbba4b832928345df04e 100644 --- a/packages/md-design/src/service/index.ts +++ b/packages/md-design/src/service/index.ts @@ -9,6 +9,9 @@ import { } from '@ibiz-template-plugin/panel-design'; import { PSDEDataViewService } from './psdedata-view/psdedata-view.service'; import { PSDEListService } from './psdelist/psdelist.service'; +import { PSDEListItemService } from './psdelist-item/psdelist-item.service'; +import { PSDEListLogicService } from './psdelist-logic/psdelist-logic.service'; +import { PSDEDataViewLogicService } from './psdedata-view-logic/psdedata-view-logic.service'; export default { install(_app: App) { @@ -48,5 +51,23 @@ export default { return new PSPanelItemLogicService(srfSessionId, entityModel); }, ); + DEServiceUtil.register( + 'mddesign.psdelistitem', + async (srfSessionId: string, entityModel: IAppDataEntity) => { + return new PSDEListItemService(srfSessionId, entityModel); + }, + ); + DEServiceUtil.register( + 'mddesign.psdelistlogic', + async (srfSessionId: string, entityModel: IAppDataEntity) => { + return new PSDEListLogicService(srfSessionId, entityModel); + }, + ); + DEServiceUtil.register( + 'mddesign.psdedataviewlogic', + async (srfSessionId: string, entityModel: IAppDataEntity) => { + return new PSDEDataViewLogicService(srfSessionId, entityModel); + }, + ); }, }; diff --git a/packages/md-design/src/service/psdedata-view-logic/psdedata-view-logic.service.ts b/packages/md-design/src/service/psdedata-view-logic/psdedata-view-logic.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..e464ede60cc7e8c960c3e546d83f373a0b991d49 --- /dev/null +++ b/packages/md-design/src/service/psdedata-view-logic/psdedata-view-logic.service.ts @@ -0,0 +1,8 @@ +import { DEService, IDataEntity } from '@ibiz-template/runtime'; +import { PSDEDataViewLogic } from '../../entity'; + +export class PSDEDataViewLogicService extends DEService { + protected newEntity(data: IData | IDataEntity): IDataEntity { + return new PSDEDataViewLogic(this.model, data); + } +} diff --git a/packages/md-design/src/service/psdelist-item/psdelist-item.service.ts b/packages/md-design/src/service/psdelist-item/psdelist-item.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..e2aafabd366c207214554a98a0bea3f11057c711 --- /dev/null +++ b/packages/md-design/src/service/psdelist-item/psdelist-item.service.ts @@ -0,0 +1,46 @@ +/* eslint-disable no-constant-condition */ +/* eslint-disable no-plusplus */ +import { DEService, IDataEntity } from '@ibiz-template/runtime'; +import { IHttpResponse } from '@ibiz-template/core'; +import { notNilEmpty } from 'qx-util'; +import { PSDEListItem } from '../../entity'; + +export class PSDEListItemService extends DEService { + protected newEntity(data: IData | IDataEntity): IDataEntity { + return new PSDEListItem(this.model, data); + } + + async exec( + id: string, + context: IContext, + params?: IData | IData[], + params2?: IParams, + header?: IData, + ): Promise { + const res = await super.exec(id, context, params, params2, header); + if (id === 'getdrafttemp' && res.ok && res.data) { + await this.fillDefault(context, res.data as PSDEListItem); + } + return res; + } + + async fillDefault(context: IContext, entity: PSDEListItem): Promise { + entity.itemtype = 'DATAITEM'; + const res = await this.fetchDefault(context); + const items = res.data; + if (notNilEmpty(items)) { + let num = 0; + while (true) { + const text = num > 0 ? `dataitem${num}` : 'dataitem'; + const i = items.findIndex(item => item.psdelistitemname === text); + if (i === -1) { + entity.psdelistitemname = text; + break; + } + num++; + } + } else { + entity.psdelistitemname = 'dataitem'; + } + } +} diff --git a/packages/md-design/src/service/psdelist-logic/psdelist-logic.service.ts b/packages/md-design/src/service/psdelist-logic/psdelist-logic.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..ccc1de745c4569a2dcf46051710b4fd42de094bc --- /dev/null +++ b/packages/md-design/src/service/psdelist-logic/psdelist-logic.service.ts @@ -0,0 +1,8 @@ +import { DEService, IDataEntity } from '@ibiz-template/runtime'; +import { PSDEListLogic } from '../../entity'; + +export class PSDEListLogicService extends DEService { + protected newEntity(data: IData | IDataEntity): IDataEntity { + return new PSDEListLogic(this.model, data); + } +} diff --git a/packages/md-design/src/views/md-design-view/md-design-view.engine.ts b/packages/md-design/src/views/md-design-view/md-design-view.engine.ts index a6d4dddd854ad0b5bd8330f70097a49c0149b230..b522e94917d1696ff7850cbff41a448f6c2b65ee 100644 --- a/packages/md-design/src/views/md-design-view/md-design-view.engine.ts +++ b/packages/md-design/src/views/md-design-view/md-design-view.engine.ts @@ -3,4 +3,19 @@ import { MDDesignViewController } from './md-design-view.controller'; export class MDDesignViewEngine extends PanelDesignViewEngine { protected declare view: MDDesignViewController; + + /** + * 初始化自定义参数 + * + * @author zhanghengfeng + * @date 2024-11-14 20:11:04 + * @protected + */ + protected initCustomParams(): void { + super.initCustomParams(); + const data = this.view.state.data; + if (data && data.psdeid) { + this.view.context.psdataentity = data.psdeid; + } + } }