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

列表自动分组时,分组属性为空,则归入其他分组

上级 50b9a9f7
...@@ -259,6 +259,9 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -259,6 +259,9 @@ import CodeListService from "@/codelist/codelist-service";
} else if(Object.is(this.codelistType, "STATIC")){ } else if(Object.is(this.codelistType, "STATIC")){
groups = this.$store.getters.getCodeListItems(this.tag); groups = this.$store.getters.getCodeListItems(this.tag);
} }
if(groups.length == 0){
console.warn("分组数据无效");
}
groups.forEach((group: any,i: number)=>{ groups.forEach((group: any,i: number)=>{
let children:Array<any> = []; let children:Array<any> = [];
data.forEach((item: any,j: number)=>{ data.forEach((item: any,j: number)=>{
...@@ -274,7 +277,7 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -274,7 +277,7 @@ import CodeListService from "@/codelist/codelist-service";
}); });
let child:Array<any> = []; let child:Array<any> = [];
data.forEach((item: any)=>{ data.forEach((item: any)=>{
let i = groups.findIndex((group: any)=>Object.is(group,item[this.groupField])); let i = groups.findIndex((group: any)=>Object.is(group.label,item[this.groupField]));
if(i < 0){ if(i < 0){
child.push(item); child.push(item);
} }
...@@ -303,6 +306,9 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -303,6 +306,9 @@ import CodeListService from "@/codelist/codelist-service";
} }
}); });
groups = [...new Set(groups)]; groups = [...new Set(groups)];
if(groups.length == 0){
console.warn("分组数据无效");
}
let groupTree:Array<any> = []; let groupTree:Array<any> = [];
groups.forEach((group: any,i: number)=>{ groups.forEach((group: any,i: number)=>{
let children:Array<any> = []; let children:Array<any> = [];
...@@ -311,6 +317,7 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -311,6 +317,7 @@ import CodeListService from "@/codelist/codelist-service";
children.push(item); children.push(item);
} }
}); });
group = group ? group : this.$t('app.commonWords.other');
const tree: any ={ const tree: any ={
group: group, group: group,
children: children children: children
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册