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

视图消息获取数据集

上级 287c6c74
...@@ -37,52 +37,32 @@ export default class ${srfclassname('${item.getCodeName()}')}MessageServiceBase ...@@ -37,52 +37,32 @@ export default class ${srfclassname('${item.getCodeName()}')}MessageServiceBase
public cacheTimeout:number = ${item.getCacheTimeout()?c}; public cacheTimeout:number = ${item.getCacheTimeout()?c};
/** /**
* 消息内容属性名 * 过期时间
* *
* @type {string} * @type any
* @memberof ${srfclassname('${item.getCodeName()}')}MessageServiceBase
*/
public contentField:string = "<#if item.getContentPSDEField()??>${item.getContentPSDEField().getCodeName()}</#if>";
/**
* 消息位置属性名
*
* @type {string}
* @memberof ${srfclassname('${item.getCodeName()}')}MessageServiceBase
*/
public msgPosField:string = "<#if item.getMsgPosPSDEField()??>${item.getMsgPosPSDEField().getCodeName()}</#if>";
/**
* 消息类型属性名
*
* @type {string}
* @memberof ${srfclassname('${item.getCodeName()}')}MessageServiceBase
*/
public msgTypeField:string = "<#if item.getMsgTypePSDEField()??>${item.getMsgTypePSDEField().getCodeName()}</#if>";
/**
* 消息排序值属性名
*
* @type {string}
* @memberof ${srfclassname('${item.getCodeName()}')}MessageServiceBase * @memberof ${srfclassname('${item.getCodeName()}')}MessageServiceBase
*/ */
public orderValueField:string = "<#if item.getOrderValuePSDEField()??>${item.getOrderValuePSDEField().getCodeName()}</#if>"; public static expirationTime:any;
/** /**
* 消息移除标识属性名 * 获取过期时间
* *
* @type {string} * @type any
* @memberof ${srfclassname('${item.getCodeName()}')}MessageServiceBase * @memberof ${srfclassname('${item.getCodeName()}')}MessageServiceBase
*/ */
public removeFlagField:string = "<#if item.getRemoveFlagPSDEField()??>${item.getRemoveFlagPSDEField().getCodeName()}</#if>"; public getExpirationTime(){
return ${srfclassname('${item.getCodeName()}')}MessageServiceBase.expirationTime;
}
/** /**
* 消息抬头属性名 * 设置过期时间
* *
* @type {string} * @type any
* @memberof ${srfclassname('${item.getCodeName()}')}MessageServiceBase * @memberof ${srfclassname('${item.getCodeName()}')}MessageServiceBase
*/ */
public getTitlePSDEField:string = "<#if item.getTitlePSDEField()??>${item.getTitlePSDEField().getCodeName()}</#if>"; public setExpirationTime(value:any){
${srfclassname('${item.getCodeName()}')}MessageServiceBase.expirationTime = value;
}
/** /**
* 应用实体对象名 * 应用实体对象名
...@@ -127,7 +107,76 @@ export default class ${srfclassname('${item.getCodeName()}')}MessageServiceBase ...@@ -127,7 +107,76 @@ export default class ${srfclassname('${item.getCodeName()}')}MessageServiceBase
this.position = "<#if item.getPosition() !="">${item.getPosition()}<#else>TOP</#if>"; this.position = "<#if item.getPosition() !="">${item.getPosition()}<#else>TOP</#if>";
this.type = "<#if item.getMessageType() !="">${item.getMessageType()}<#else>INFO</#if>"; this.type = "<#if item.getMessageType() !="">${item.getMessageType()}<#else>INFO</#if>";
this.isEnableRemove = ${item.isEnableRemove()?c}; this.isEnableRemove = ${item.isEnableRemove()?c};
this.order = 1;
this.dynamicMode = "<#if item.getDynamicMode() == 0>STATIC<#else>DYNAMIC</#if>"; this.dynamicMode = "<#if item.getDynamicMode() == 0>STATIC<#else>DYNAMIC</#if>";
} }
<#-- 动态模式为实体数据集合start -->
<#if item.getDynamicMode() == 1>
/**
* 获取远程数据
*
* @param {*} context
* @param {*} data
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof ${srfclassname('${item.getCodeName()}')}MessageServiceBase
*/
public getItems(context: any={}, data: any={}, isloading?: boolean): Promise<any> {
return new Promise((resolve, reject) => {
this.entityService.getService(this.appDataEntityName.toLowerCase()).then((service:any) =>{
if(service[this.appDataSetName] && service[this.appDataSetName] instanceof Function){
const promise: Promise<any> = service[this.appDataSetName](context, data, isloading);
promise.then((response: any) => {
if (response && response.status === 200) {
const data = response.data;
resolve(this.doItems(data));
} else {
resolve([]);
}
}).catch((response: any) => {
console.error(response);
reject(response);
});
}
})
});
}
/**
* 处理数据
*
* @public
* @param {any[]} items
* @returns {any[]}
* @memberof ${srfclassname('${item.getCodeName()}')}MessageServiceBase
*/
public doItems(items: any[]): any[] {
let _items: any[] = [];
items.forEach((item: any) => {
let itemdata:any = {
id:"${item.getId()}",
name:"${item.getName()}",
codename:"<#if item.getCodeName()??>${item.getCodeName()}</#if>",
title:"<#if item.getTitle()??>${item.getTitle()}</#if>",
content:"<#if item.getTitle()??>${item.getTitle()}</#if>",
closeMode:"",
position:"<#if item.getPosition() !="">${item.getPosition()}<#else>TOP</#if>",
type:"<#if item.getMessageType() !="">${item.getMessageType()}<#else>INFO</#if>",
isEnableRemove:${item.isEnableRemove()?c},
order:1,
dynamicMode:"DYNAMIC"
};
<#if item.getTitlePSDEField()??>Object.assign(itemdata,{title:item['${item.getTitlePSDEField().getCodeName()?lower_case}']});</#if>
<#if item.getContentPSDEField()??>Object.assign(itemdata,{content:item['${item.getContentPSDEField().getCodeName()?lower_case}']});</#if>
<#if item.getMsgPosPSDEField()??>Object.assign(itemdata,{position:item['${item.getMsgPosPSDEField().getCodeName()?lower_case}']});</#if>
<#if item.getMsgTypePSDEField()??>Object.assign(itemdata,{type:item['${item.getMsgTypePSDEField().getCodeName()?lower_case}']});</#if>
<#if item.getOrderValuePSDEField()??>Object.assign(itemdata,{order:item['${item.getOrderValuePSDEField().getCodeName()?lower_case}']});</#if>
<#if item.getRemoveFlagPSDEField()??>Object.assign(itemdata,{isEnableRemove:item['${item.getRemoveFlagPSDEField().getCodeName()?lower_case}']});</#if>
_items.push(itemdata);
});
return _items;
}
</#if>
<#-- 动态模式为实体数据集合end -->
} }
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册