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

新增:列表,数据视图支持分组时分组属性配置了代码表的情况

上级 c251dfb6
...@@ -101,6 +101,14 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -101,6 +101,14 @@ import CodeListService from "@/codelist/codelist-service";
../@MACRO/CONTROL/CONTROL_HEADER-BASE.vue.ftl ../@MACRO/CONTROL/CONTROL_HEADER-BASE.vue.ftl
</#ibizinclude> </#ibizinclude>
/**
* 代码表服务对象
*
* @type {CodeListService}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public codeListService:CodeListService = new CodeListService({ $store: this.$store });
/** /**
* 获取多项数据 * 获取多项数据
* *
...@@ -209,6 +217,14 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -209,6 +217,14 @@ import CodeListService from "@/codelist/codelist-service";
*/ */
public groupField: string = "<#if ctrl.getGroupPSDEField?? && ctrl.getGroupPSDEField()??>${ctrl.getGroupPSDEField().getCodeName()?lower_case}</#if>"; public groupField: string = "<#if ctrl.getGroupPSDEField?? && ctrl.getGroupPSDEField()??>${ctrl.getGroupPSDEField().getCodeName()?lower_case}</#if>";
/**
* 分组属性代码表
*
* @type {string}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public groupFieldCodelist: any = {<#if ctrl.getGroupPSDEField()?? && ctrl.getGroupPSDEField().getPSCodeList?? && ctrl.getGroupPSDEField().getPSCodeList()??>type: '${ctrl.getGroupPSDEField().getPSCodeList().getCodeListType()}',tag: '${ctrl.getGroupPSDEField().getPSCodeList().getCodeName()}'</#if>};
/** /**
* 分组数据 * 分组数据
* *
...@@ -241,29 +257,14 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -241,29 +257,14 @@ import CodeListService from "@/codelist/codelist-service";
</#if> </#if>
<#if ctrl.getGroupMode?? && ctrl.getGroupMode() == 'CODELIST'> <#if ctrl.getGroupMode?? && ctrl.getGroupMode() == 'CODELIST'>
/**
* 代码表服务对象
*
* @type {CodeListService}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public codeListService:CodeListService = new CodeListService({ $store: this.$store });
/**
* 分组代码表标识
*
* @type {string}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public tag: string = "<#if ctrl.getGroupPSCodeList?? && ctrl.getGroupPSCodeList()??>${ctrl.getGroupPSCodeList().getCodeName()}</#if>";
/** /**
* 分组代码表类型 * 分组代码表
* *
* @type {string} * @type {string}
* @memberof ${srfclassname('${ctrl.codeName}')}Base * @memberof ${srfclassname('${ctrl.codeName}')}Base
*/ */
public codelistType: string = "<#if ctrl.getGroupPSCodeList?? && ctrl.getGroupPSCodeList()??>${ctrl.getGroupPSCodeList().getCodeListType()}</#if>"; public groupCodelist: any = {<#if ctrl.getGroupPSCodeList?? && ctrl.getGroupPSCodeList()??>type:'${ctrl.getGroupPSCodeList().getCodeListType()}',tag:'${ctrl.getGroupPSCodeList().getCodeName()}'</#if>};
/** /**
* 根据分组代码表绘制分组列表 * 根据分组代码表绘制分组列表
...@@ -272,14 +273,17 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -272,14 +273,17 @@ import CodeListService from "@/codelist/codelist-service";
*/ */
public async drawCodelistGroup(){ public async drawCodelistGroup(){
let groups: Array<any> = []; let groups: Array<any> = [];
let fields: Array<any> = [];
let groupTree:Array<any> = []; let groupTree:Array<any> = [];
let data:Array<any> = [...this.items]; let data:Array<any> = [...this.items];
// 动态代码表 if(Object.keys(this.groupCodelist).length > 0){
if (Object.is(this.codelistType, "DYNAMIC")) { let groupCodelist: any = await this.codeListService.getDataItems(this.groupCodelist);
groups = await this.codeListService.getItems(this.tag); groups = Util.deepCopy(groupCodelist);
// 静态代码表
} else if(Object.is(this.codelistType, "STATIC")){ }
groups = this.$store.getters.getCodeListItems(this.tag); if(Object.keys(this.groupFieldCodelist).length > 0){
let fieldCodelist: any = await this.codeListService.getDataItems(this.groupFieldCodelist);
fields = Util.deepCopy(fieldCodelist);
} }
if(groups.length == 0){ if(groups.length == 0){
console.warn("分组数据无效"); console.warn("分组数据无效");
...@@ -287,7 +291,12 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -287,7 +291,12 @@ import CodeListService from "@/codelist/codelist-service";
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)=>{
if(Object.is(group.label,item[this.groupField])){ if(fields && fields.length > 0){
const arr:Array<any> = fields.filter((field:any)=>{return field.value == item[this.groupField]});
if(arr && arr.length>0 && Object.is(group.label,arr[0].label)) {
children.push(item);
}
}else if(Object.is(group.label,item[this.groupField])){
children.push(item); children.push(item);
} }
}); });
...@@ -299,7 +308,15 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -299,7 +308,15 @@ 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.label,item[this.groupField])); let i: number = 0;
if(fields && fields.length > 0){
const arr:Array<any> = fields.filter((field:any)=>{return field.value == item[this.groupField]});
if(arr && arr.length>0) {
i = groups.findIndex((group: any)=>Object.is(group.label,arr[0].label));
}
}else{
i = groups.findIndex((group: any)=>Object.is(group.label,item[this.groupField]));
}
if(i < 0){ if(i < 0){
child.push(item); child.push(item);
} }
...@@ -321,12 +338,22 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -321,12 +338,22 @@ import CodeListService from "@/codelist/codelist-service";
* *
* @memberof ${srfclassname('${ctrl.codeName}')}Base * @memberof ${srfclassname('${ctrl.codeName}')}Base
*/ */
public drawGroup(){ public async drawGroup(){
let data:Array<any> = [...this.items]; let data:Array<any> = [...this.items];
let groups:Array<any> = []; let groups:Array<any> = [];
let fields: Array<any> = [];
if(Object.keys(this.groupFieldCodelist).length > 0){
let fieldCodelist: any = await this.codeListService.getDataItems(this.groupFieldCodelist);
fields = Util.deepCopy(fieldCodelist);
}
data.forEach((item: any)=>{ data.forEach((item: any)=>{
if(item.hasOwnProperty(this.groupField)){ if(item.hasOwnProperty(this.groupField)){
groups.push(item[this.groupField]); if(fields && fields.length > 0){
const arr:Array<any> = fields.filter((field:any)=>{return field.value == item[this.groupField]});
groups.push(arr[0].label);
}else{
groups.push(item[this.groupField]);
}
} }
}); });
groups = [...new Set(groups)]; groups = [...new Set(groups)];
......
...@@ -148,6 +148,15 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -148,6 +148,15 @@ import CodeListService from "@/codelist/codelist-service";
<#ibizinclude> <#ibizinclude>
../@MACRO/CONTROL/CONTROL_HEADER-BASE.vue.ftl ../@MACRO/CONTROL/CONTROL_HEADER-BASE.vue.ftl
</#ibizinclude> </#ibizinclude>
/**
* 代码表服务对象
*
* @type {CodeListService}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public codeListService:CodeListService = new CodeListService({ $store: this.$store });
/** /**
* 获取多项数据 * 获取多项数据
* *
...@@ -255,7 +264,15 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -255,7 +264,15 @@ import CodeListService from "@/codelist/codelist-service";
* @memberof ${srfclassname('${ctrl.codeName}')}Base * @memberof ${srfclassname('${ctrl.codeName}')}Base
*/ */
public groupField: string = "<#if ctrl.getGroupPSDEField?? && ctrl.getGroupPSDEField()??>${ctrl.getGroupPSDEField().getCodeName()?lower_case}</#if>"; public groupField: string = "<#if ctrl.getGroupPSDEField?? && ctrl.getGroupPSDEField()??>${ctrl.getGroupPSDEField().getCodeName()?lower_case}</#if>";
/**
* 分组属性代码表
*
* @type {string}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public groupFieldCodelist: any = {<#if ctrl.getGroupPSDEField()?? && ctrl.getGroupPSDEField().getPSCodeList?? && ctrl.getGroupPSDEField().getPSCodeList()??>type: '${ctrl.getGroupPSDEField().getPSCodeList().getCodeListType()}',tag: '${ctrl.getGroupPSDEField().getPSCodeList().getCodeName()}'</#if>};
/** /**
* 分组数据 * 分组数据
* *
...@@ -288,29 +305,14 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -288,29 +305,14 @@ import CodeListService from "@/codelist/codelist-service";
</#if> </#if>
<#if ctrl.getGroupMode?? && ctrl.getGroupMode() == 'CODELIST'> <#if ctrl.getGroupMode?? && ctrl.getGroupMode() == 'CODELIST'>
/**
* 代码表服务对象
*
* @type {CodeListService}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public codeListService:CodeListService = new CodeListService({ $store: this.$store });
/**
* 分组代码表标识
*
* @type {string}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public tag: string = "<#if ctrl.getGroupPSCodeList?? && ctrl.getGroupPSCodeList()??>${ctrl.getGroupPSCodeList().getCodeName()}</#if>";
/** /**
* 分组代码表类型 * 分组代码表
* *
* @type {string} * @type {string}
* @memberof ${srfclassname('${ctrl.codeName}')}Base * @memberof ${srfclassname('${ctrl.codeName}')}Base
*/ */
public codelistType: string = "<#if ctrl.getGroupPSCodeList?? && ctrl.getGroupPSCodeList()??>${ctrl.getGroupPSCodeList().getCodeListType()}</#if>"; public groupCodelist: any = {<#if ctrl.getGroupPSCodeList?? && ctrl.getGroupPSCodeList()??>type:'${ctrl.getGroupPSCodeList().getCodeListType()}',tag:'${ctrl.getGroupPSCodeList().getCodeName()}'</#if>};
/** /**
* 根据分组代码表绘制分组列表 * 根据分组代码表绘制分组列表
...@@ -319,19 +321,30 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -319,19 +321,30 @@ import CodeListService from "@/codelist/codelist-service";
*/ */
public async drawCodelistGroup(){ public async drawCodelistGroup(){
let groups: Array<any> = []; let groups: Array<any> = [];
let fields: Array<any> = [];
let groupTree:Array<any> = []; let groupTree:Array<any> = [];
let data:Array<any> = [...this.items]; let data:Array<any> = [...this.items];
// 动态代码表 if(Object.keys(this.groupCodelist).length > 0){
if (Object.is(this.codelistType, "DYNAMIC")) { let groupCodelist: any = await this.codeListService.getDataItems(this.groupCodelist);
groups = await this.codeListService.getItems(this.tag); groups = Util.deepCopy(groupCodelist);
// 静态代码表
} else if(Object.is(this.codelistType, "STATIC")){ }
groups = this.$store.getters.getCodeListItems(this.tag); if(Object.keys(this.groupFieldCodelist).length > 0){
let fieldCodelist: any = await this.codeListService.getDataItems(this.groupFieldCodelist);
fields = Util.deepCopy(fieldCodelist);
}
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)=>{
if(Object.is(group.label,item[this.groupField])){ if(fields && fields.length > 0){
const arr:Array<any> = fields.filter((field:any)=>{return field.value == item[this.groupField]});
if(arr && arr.length>0 && Object.is(group.label,arr[0].label)) {
children.push(item);
}
}else if(Object.is(group.label,item[this.groupField])){
children.push(item); children.push(item);
} }
}); });
...@@ -343,7 +356,15 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -343,7 +356,15 @@ 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: number = 0;
if(fields && fields.length > 0){
const arr:Array<any> = fields.filter((field:any)=>{return field.value == item[this.groupField]});
if(arr && arr.length>0) {
i = groups.findIndex((group: any)=>Object.is(group.label,arr[0].label));
}
}else{
i = groups.findIndex((group: any)=>Object.is(group.label,item[this.groupField]));
}
if(i < 0){ if(i < 0){
child.push(item); child.push(item);
} }
...@@ -352,7 +373,9 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -352,7 +373,9 @@ import CodeListService from "@/codelist/codelist-service";
group: this.$t('app.commonWords.other'), group: this.$t('app.commonWords.other'),
children: child children: child
} }
groupTree.push(Tree); if(child && child.length > 0){
groupTree.push(Tree);
}
this.groupData = [...groupTree]; this.groupData = [...groupTree];
} }
</#if> </#if>
...@@ -363,15 +386,28 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -363,15 +386,28 @@ import CodeListService from "@/codelist/codelist-service";
* *
* @memberof ${srfclassname('${ctrl.codeName}')}Base * @memberof ${srfclassname('${ctrl.codeName}')}Base
*/ */
public drawGroup(){ public async drawGroup(){
let data:Array<any> = [...this.items]; let data:Array<any> = [...this.items];
let groups:Array<any> = []; let groups:Array<any> = [];
let fields: Array<any> = [];
if(Object.keys(this.groupFieldCodelist).length > 0){
let fieldCodelist: any = await this.codeListService.getDataItems(this.groupFieldCodelist);
fields = Util.deepCopy(fieldCodelist);
}
data.forEach((item: any)=>{ data.forEach((item: any)=>{
if(item.hasOwnProperty(this.groupField)){ if(item.hasOwnProperty(this.groupField)){
groups.push(item[this.groupField]); if(fields && fields.length > 0){
const arr:Array<any> = fields.filter((field:any)=>{return field.value == item[this.groupField]});
groups.push(arr[0].label);
}else{
groups.push(item[this.groupField]);
}
} }
}); });
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> = [];
...@@ -380,6 +416,7 @@ import CodeListService from "@/codelist/codelist-service"; ...@@ -380,6 +416,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 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册