<#-- 保存变更 --> <#macro dataSaveChanges item> /** * ${item.getCaption()} * * @param {any[]} args 当前数据 * @param {any} context 行为附加上下文 * @param {*} [params] 附加参数 * @param {*} [$event] 事件源 * @param {*} [xData] 执行行为所需当前部件 * @param {*} [actionContext] 执行行为上下文 * @param {*} [srfParentDeName] 父实体名称 */ public async ${item.getFullCodeName()}(args: any[], context: any = {}, params: any = {}, $event?: any, xData?: any, actionContext?: any, srfParentDeName?: string) { // 选择视图保存变更 if (Object.is(this.viewType, 'DEPICKUPVIEW') || Object.is(this.viewType, 'DEMPICKUPVIEW')) { this.$emit('viewdataschange', actionContext.viewSelections); this.$emit('close', null); } else { <#if item.getPSAppDataEntity?? && item.getPSAppDataEntity()??> // 准备上下文参数 const tempContext = {...context}; if (xData && xData.context) { Object.assign(tempContext, xData.context); } const data = args[0]; let action: string | undefined = undefined; const service = await window.entityServiceRegister.getService('${item.getPSAppDataEntity().getCodeName()?lower_case}'); if (service) { const key = service.APPDEKEY.toLowerCase(); const name = service.APPLYDEKEY.toLowerCase(); if (data.hasOwnProperty(key)) { Object.assign(tempContext, { [name]: data[key] }); action = 'Update'; } else { action = 'Create'; } if (service[action] && service[action] instanceof Function) { service[action](tempContext, data).then((response: any) => { if (!response.status || response.status !== 200) { actionContext.$Notice.error({ title: '错误', desc: '当前环境无法执行保存变更逻辑[执行行为异常]' }); } }).catch((error: any) => { actionContext.$Notice.error({ title: '错误', desc: '当前环境无法执行保存变更逻辑[执行行为异常]' }); }) } else { actionContext.$Notice.error({ title: '错误', desc: '当前环境无法执行保存变更逻辑[执行行为异常]' }); } } <#else> actionContext.$Notice.error({ title: '错误', desc: '保存变更行为未配置实体' }); </#if> } } </#macro>