提交 a1af18f0 编写于 作者: tony001's avatar tony001

update:调整uiservice

上级 59fc6e29
import { IParam } from "@core"; import { IParam } from "@core";
import { Environment } from "@/environments/environment";
/** /**
* 界面服务基类 * 界面服务基类
...@@ -17,6 +18,36 @@ export class UIServiceBase { ...@@ -17,6 +18,36 @@ export class UIServiceBase {
*/ */
protected context: IParam; protected context: IParam;
/**
* 应用实体主键属性
*
* @protected
* @type {string}
* @memberof UIServiceBase
*/
protected appDeKeyFieldName: string = '';
/**
* 主状态属性集合
*
* @memberof UIServiceBase
*/
protected mainStateFields: Array<string> = [];
/**
* 主状态集合Map
*
* @memberof UIServiceBase
*/
protected allDeMainStateMap: Map<string, string> = new Map();
/**
* 主状态操作标识Map
*
* @memberof UIServiceBase
*/
protected allDeMainStateOPPrivsMap: Map<string, any> = new Map();
/** /**
* *
* @param {*} [opts={}] * @param {*} [opts={}]
...@@ -27,24 +58,88 @@ export class UIServiceBase { ...@@ -27,24 +58,88 @@ export class UIServiceBase {
} }
/** /**
* 界面行为模型对象 * 获取数据对象所有的操作标识
* *
* @type {*} * @param data 当前数据
* @memberof UIServiceBase * @param dataaccaction 数据操作标识
* @memberof UIServiceBase
*/ */
public uiActionModes: any = {}; protected getAllOPPrivs(data: any, dataaccaction: string) {
if (!Environment.enablePermissionValid) {
return 1;
}
if (data && (Object.keys(data).length > 0)) {
const curActiveKey: string = `${data[this.appDeKeyFieldName?.toLowerCase()]}`;
//const result = this.authService.getOPPrivs(curActiveKey, dataaccaction, this.getDEMainStateOPPrivs(data));
return 1;
} else {
// const result = this.authService.getOPPrivs(undefined, dataaccaction, undefined);
return 1;
}
}
/** /**
* 获取数据对象当前操作标识
* *
* 获取界面行为模型对象 * @param data 当前数据
* @memberof UIServiceBase
*/
protected getDEMainStateOPPrivs(data: any) {
const mainStateTag = this.getDEMainStateTag(data);
if (mainStateTag) {
return this.allDeMainStateOPPrivsMap.get(mainStateTag);
} else {
return null;
}
}
/**
* 获取数据对象的主状态标识
* *
* @param {string} actionName * @param data 当前数据
* @memberof UIServiceBase * @memberof UIServiceBase
*/ */
public getUIActionModel(actionName: string) { protected getDEMainStateTag(data: IParam) {
if (!actionName) { const mainStateFields: string[] = [];
return; if (mainStateFields.length === 0) return null;
mainStateFields.forEach((singleMainField: any) => {
if (!(singleMainField in data)) {
console.warn(
`当前数据对象不包含属性「${singleMainField}」,根据「${singleMainField}」属性进行的主状态计算默认为空值`,
);
}
});
for (let i = 0; i <= 1; i++) {
let strTag: string =
data[mainStateFields[0]] != null && data[mainStateFields[0]] !== ''
? i == 0
? `${data[mainStateFields[0]]}`
: ''
: '';
if (mainStateFields.length >= 2) {
for (let j = 0; j <= 1; j++) {
let strTag2: string =
data[mainStateFields[1]] != null && data[mainStateFields[1]] !== ''
? `${strTag}__${j == 0 ? `${data[mainStateFields[1]]}` : ''}`
: strTag;
if (mainStateFields.length >= 3) {
for (let k = 0; k <= 1; k++) {
let strTag3: string =
data[mainStateFields[2]] != null && data[mainStateFields[2]] !== ''
? `${strTag2}__${k == 0 ? `${data[mainStateFields[2]]}` : ''}`
: strTag2;
// 判断是否存在
return this.allDeMainStateMap.get(strTag3);
}
} else {
return this.allDeMainStateMap.get(strTag2);
}
}
} else {
return this.allDeMainStateMap.get(strTag);
}
} }
return this.uiActionModes[actionName] ? this.uiActionModes[actionName] : null; return null;
} }
} }
...@@ -9,22 +9,64 @@ import { AppFrontAction, AppBackendAction } from '@core'; ...@@ -9,22 +9,64 @@ import { AppFrontAction, AppBackendAction } from '@core';
*/ */
export class {{pascalCase appEntity.codeName}}UIServiceBase extends UIServiceBase { export class {{pascalCase appEntity.codeName}}UIServiceBase extends UIServiceBase {
/** /**
* Creates an instance of {{pascalCase appEntity.codeName}}UIServiceBase * Creates an instance of {{pascalCase appEntity.codeName}}UIServiceBase
* *
* @param {*} [opts={}] * @param {*} [opts={}]
* @memberof {{pascalCase appEntity.codeName}}UIServiceBase * @memberof {{pascalCase appEntity.codeName}}UIServiceBase
*/ */
constructor(opts: IParam = {}) { constructor(opts: IParam = {}) {
super(opts); super(opts);
} this.initBasicData();
}
{{!-- 遍历界面行为 --}} /**
* 初始化基础数据
*
* @memberof {{pascalCase appEntity.codeName}}UIServiceBase
*/
public initBasicData() {
// 应用实体主键属性
this.appDeKeyFieldName = '{{lowerCase appEntity.pSDataEntity.keyPSDEField.codeName}}';
{{#if appEntity.pSDataEntity.dEMainStateDEFields}}
// 主状态属性集合
this.mainStateFields = [
{{~#each appEntity.pSDataEntity.dEMainStateDEFields as | mainStateDEField |~}}
'{{lowerCase mainStateDEField.codeName}}'{{#unless @last}},{{/unless}}
{{~/each~}}
];
{{/if}}
{{#if appEntity.allPSDEMainStates}}
// 主状态集合Map
{{#each appEntity.allPSDEMainStates as | mainState |}}
this.allDeMainStateMap.set('{{mainState.mSTag}}', '{{mainState.mSTag}}');
{{/each}}
// 主状态操作标识Map
{{#each appEntity.allPSDEMainStates as | mainState |}}
this.allDeMainStateOPPrivsMap.set('{{mainState.mSTag}}', Object.assign({
{{~#each appEntity.allPSDEOPPrivs as | deOPPriv |~}}
'${deOPPriv.name}':{{#if deOPPriv.isOPPrivAllowMode}}1{{else}}0{{/if}}{{#unless @last}},{{/unless}}
{{~/each~}}
},
{
{{~#each mainState.pSDEMainStateOPPrivs as | deMainStateOPPriv |~}}
'${deMainStateOPPriv.name}':{{#if deMainStateOPPriv.isOPPrivAllowMode}}1{{else}}0{{/if}}{{#unless @last}},{{/unless}}
{{~/each~}}
}));
{{/each}}
{{/if}}
}
public uiActionModes = { {{!-- 遍历界面行为 --}}
{{~#each appEntity.appDEUIActions as | appDEUIAction | }} {{~#each appEntity.appDEUIActions as | appDEUIAction | }}
"{{appDEUIAction.codeName}}":{ /**
* {{appDEUIAction.caption}}
*
* @param {*} params
* @memberof {{pascalCase appEntity.codeName}}UIServiceBase
*/
public async {{appDEUIAction.codeName}}(uiAction:any, params:any){
const actionModel = {
codeName:'{{appDEUIAction.codeName}}', codeName:'{{appDEUIAction.codeName}}',
uIActionMode:'{{appDEUIAction.UIActionMode}}', uIActionMode:'{{appDEUIAction.UIActionMode}}',
actionTarget:'{{upperCase appDEUIAction.actionTarget}}', actionTarget:'{{upperCase appDEUIAction.actionTarget}}',
...@@ -40,19 +82,7 @@ export class {{pascalCase appEntity.codeName}}UIServiceBase extends UIServiceBas ...@@ -40,19 +82,7 @@ export class {{pascalCase appEntity.codeName}}UIServiceBase extends UIServiceBas
nextActionCodeName:'{{appDEUIAction.nextActionCodeName}}', nextActionCodeName:'{{appDEUIAction.nextActionCodeName}}',
navContexts:{{appDEUIAction.navContexts}}, navContexts:{{appDEUIAction.navContexts}},
navParams:{{appDEUIAction.navParams}} navParams:{{appDEUIAction.navParams}}
}, };
{{/each}}
};
{{~#each appEntity.appDEUIActions as | appDEUIAction | }}
/**
* {{appDEUIAction.caption}}
*
* @param {*} params
* @memberof {{pascalCase appEntity.codeName}}UIServiceBase
*/
public async {{appDEUIAction.codeName}}(uiAction:any, params:any){
const actionModel = this.getUIActionModel('{{appDEUIAction.codeName}}');
{{#eq appDEUIAction.UIActionMode 'FRONT'}} {{#eq appDEUIAction.UIActionMode 'FRONT'}}
AppFrontAction.doAction(actionModel, params); AppFrontAction.doAction(actionModel, params);
{{/eq}} {{/eq}}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册