提交 5779ec53 编写于 作者: zhujiamin's avatar zhujiamin

模型获取 分组数据 --fix2

上级 0270b109
......@@ -162,7 +162,7 @@
* @type {boolean}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public group_detail:any = {};
public group_detail:any = <#if ctrl.getGroupPSCodeList?? && ctrl.getGroupPSCodeList()?? && ctrl.getGroupPSCodeList().getAllPSCodeItems?? && ctrl.getGroupPSCodeList().getAllPSCodeItems()??> <#assign codelist = ctrl.getGroupPSCodeList().getAllPSCodeItems()> {<#list codelist as item> <#if item.getValue?? && item.getValue()?? && item.getName?? && item.getName()??>'${item.getValue()}':'${item.getName()}',</#if></#list>}</#if>;
/**
* 分组数据
......@@ -172,6 +172,14 @@
*/
public group_data?:any = [];
/**
* 分组标识
*
* @type {array}
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public group_field:string = <#if ctrl.getGroupPSDEField?? && ctrl.getGroupPSDEField()?? && ctrl.getGroupPSDEField().getCodeName?? && ctrl.getGroupPSDEField().getCodeName()??>'${ctrl.getGroupPSDEField().getCodeName()?lower_case}'</#if>;
/**
* 存放数据选择数组(单选)
*
......@@ -542,9 +550,42 @@
Object.assign(item,this.getActionState(item));
this.setSlidingDisabled(item);
});
if(this.isEnableGroup){
this.getGroupData(this.items);
}
return response;
}
/**
* 获取分组数据
*
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public getGroupData(items:any){
let data:any =[];
let obj:any = {};
items.forEach((item:any,index:number,items:Array<number>)=>{
if(!obj[item[this.group_field]]){
obj[item[this.group_field]] = item[this.group_field];
data.push(this.filterByTag(items,item[this.group_field]));
}
})
data.forEach((arr:any,index:number)=>{
this.group_data[index] = {};
this.group_data[index].text = this.group_detail[ arr[0][this.group_field] ];
this.group_data[index].items = arr;
})
}
/**
* 单条件过滤数组数据
*
* @memberof ${srfclassname('${ctrl.codeName}')}
*/
public filterByTag(arr:Array<number>, tag:any) {
return arr.filter((item:any) => item[this.group_field] == tag);
}
/**
* 全选
*
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册