提交 8db35ec3 编写于 作者: Shine-zwj's avatar Shine-zwj

支持表格分组属性配置代码表情况

上级 641a67f4
......@@ -609,6 +609,22 @@ ${gridColumn.getName()}
*/
public groupAppField:string ="<#if ctrl.getGroupPSDEField()??>${ctrl.getGroupPSDEField().getCodeName()?lower_case}</#if>";
/**
* 分组属性代码表标识
*
* @type {string}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public groupAppFieldCodelistTag:string ="<#if ctrl.getGroupPSDEField()?? && ctrl.getGroupPSDEField().getPSCodeList?? && ctrl.getGroupPSDEField().getPSCodeList()??>${ctrl.getGroupPSDEField().getPSCodeList().getCodeName()}</#if>";
/**
* 分组属性代码表类型
*
* @type {string}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public groupAppFieldCodelistType: string = "<#if ctrl.getGroupPSDEField()?? && ctrl.getGroupPSDEField().getPSCodeList?? && ctrl.getGroupPSDEField().getPSCodeList()??>${ctrl.getGroupPSDEField().getPSCodeList().getCodeListType()}</#if>";
/**
* 分组模式
*
......@@ -1443,30 +1459,55 @@ ${gridColumn.getName()}
}
}
/**
* 获取表格分组相关代码表
*
* @param {string} codelistType 代码表类型
* @param {string} codelistTag 代码表标识
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public getGroupCodelist(codelistType: string,codelistTag:string){
let codelist: Array<any> = [];
// 动态代码表
if (Object.is(codelistType, "DYNAMIC")) {
this.codeListService.getItems(codelistTag).then((res: any)=>{
codelist = res;
}).catch((error: any) => {
});
// 静态代码表
} else if(Object.is(codelistType, "STATIC")){
codelist = this.$store.getters.getCodeListItems(codelistTag);
}
return codelist;
}
/**
* 根据分组代码表绘制分组列表
*
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public async drawCodelistGroup(){
public drawCodelistGroup(){
if(!this.isEnableGroup) return;
// 分组
let allGroup: Array<any> = [];
let allGroupField: Array<any> =[];
let groupTree:Array<any> = [];
// 动态代码表
if (Object.is(this.codelistType, "DYNAMIC")) {
allGroup = await this.codeListService.getItems(this.codelistTag);
// 静态代码表
} else if(Object.is(this.codelistType, "STATIC")){
allGroup = this.$store.getters.getCodeListItems(this.codelistTag);
}
allGroup = this.getGroupCodelist(this.codelistType,this.codelistTag);
allGroupField = this.getGroupCodelist(this.groupAppFieldCodelistType,this.groupAppFieldCodelistTag);
if(allGroup.length == 0){
console.warn("分组数据无效");
}
allGroup.forEach((group: any,i: number)=>{
let children:Array<any> = [];
this.items.forEach((item: any,j: number)=>{
if(Object.is(group.label,item[this.groupAppField])){
if(allGroupField && allGroupField.length > 0){
const arr:Array<any> = allGroupField.filter((field:any)=>{return field.value == item[this.groupAppField]});
if(Object.is(group.label,arr[0].label)){
item.groupById = Number((i+1) * 100 + (i+1) * 1);
item.group = '';
children.push(item);
}
}else if(Object.is(group.label,item[this.groupAppField])){
item.groupById = Number((i+1) * 100 + (i+1) * 1);
item.group = '';
children.push(item);
......@@ -1503,7 +1544,18 @@ ${gridColumn.getName()}
});
let child:Array<any> = [];
this.items.forEach((item: any,index: number)=>{
let i = allGroup.findIndex((group: any)=>Object.is(group.label,item[this.groupAppField]));
let i: number = 0;
if(allGroupField && allGroupField.length > 0){
const arr:Array<any> = allGroupField.filter((field:any)=>{return field.value == item[this.groupAppField]});
i = allGroup.findIndex((group: any)=>Object.is(group.label,arr[0].label));
}else{
i = allGroup.findIndex((group: any)=>Object.is(group.label,item[this.groupAppField]));
}
if(i < 0){
item.groupById = Number((allGroup.length+1) * 100 + (index+1) * 1);
item.group = '';
child.push(item);
}
if(i < 0){
item.groupById = Number((allGroup.length+1) * 100 + (index+1) * 1);
item.group = '';
......@@ -1557,10 +1609,17 @@ ${gridColumn.getName()}
if(!this.isEnableGroup) return;
// 分组
let allGroup: Array<any> = [];
let allGroupField: Array<any> =[];
allGroupField = this.getGroupCodelist(this.groupAppFieldCodelistType,this.groupAppFieldCodelistTag);
this.items.forEach((item: any)=>{
if(item.hasOwnProperty(this.groupAppField)){
if(allGroupField && allGroupField.length > 0){
const arr:Array<any> = allGroupField.filter((field:any)=>{return field.value == item[this.groupAppField]});
allGroup.push(arr[0].label);
}else{
allGroup.push(item[this.groupAppField]);
}
}
});
let groupTree:Array<any> = [];
allGroup = [...new Set(allGroup)];
......@@ -1571,8 +1630,15 @@ ${gridColumn.getName()}
allGroup.forEach((group: any, groupIndex: number)=>{
let children:Array<any> = [];
this.items.forEach((item: any,itemIndex: number)=>{
if(Object.is(group,item[this.groupAppField])){
item.groupById = Number((groupIndex+1) * 100 + (itemIndex+1) * 1);
if(allGroupField && allGroupField.length > 0){
const arr:Array<any> = allGroupField.filter((field:any)=>{return field.value == item[this.groupAppField]});
if(Object.is(group,arr[0].label)){
item.groupById = Number((groupIndex+1) * 100 + (groupIndex+1) * 1);
item.group = '';
children.push(item);
}
}else if(Object.is(group,item[this.groupAppField])){
item.groupById = Number((groupIndex+1) * 100 + (groupIndex+1) * 1);
item.group = '';
children.push(item);
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册