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

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

上级 c251dfb6
......@@ -101,6 +101,14 @@ import CodeListService from "@/codelist/codelist-service";
../@MACRO/CONTROL/CONTROL_HEADER-BASE.vue.ftl
</#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";
*/
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";
</#if>
<#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}
* @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";
*/
public async drawCodelistGroup(){
let groups: Array<any> = [];
let fields: Array<any> = [];
let groupTree:Array<any> = [];
let data:Array<any> = [...this.items];
// 动态代码表
if (Object.is(this.codelistType, "DYNAMIC")) {
groups = await this.codeListService.getItems(this.tag);
// 静态代码表
} else if(Object.is(this.codelistType, "STATIC")){
groups = this.$store.getters.getCodeListItems(this.tag);
if(Object.keys(this.groupCodelist).length > 0){
let groupCodelist: any = await this.codeListService.getDataItems(this.groupCodelist);
groups = Util.deepCopy(groupCodelist);
}
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("分组数据无效");
......@@ -287,7 +291,12 @@ import CodeListService from "@/codelist/codelist-service";
groups.forEach((group: any,i: number)=>{
let children:Array<any> = [];
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);
}
});
......@@ -299,7 +308,15 @@ import CodeListService from "@/codelist/codelist-service";
});
let child:Array<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){
child.push(item);
}
......@@ -321,12 +338,22 @@ import CodeListService from "@/codelist/codelist-service";
*
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public drawGroup(){
public async drawGroup(){
let data:Array<any> = [...this.items];
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)=>{
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)];
......
......@@ -148,6 +148,15 @@ import CodeListService from "@/codelist/codelist-service";
<#ibizinclude>
../@MACRO/CONTROL/CONTROL_HEADER-BASE.vue.ftl
</#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";
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
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";
</#if>
<#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}
* @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";
*/
public async drawCodelistGroup(){
let groups: Array<any> = [];
let fields: Array<any> = [];
let groupTree:Array<any> = [];
let data:Array<any> = [...this.items];
// 动态代码表
if (Object.is(this.codelistType, "DYNAMIC")) {
groups = await this.codeListService.getItems(this.tag);
// 静态代码表
} else if(Object.is(this.codelistType, "STATIC")){
groups = this.$store.getters.getCodeListItems(this.tag);
if(Object.keys(this.groupCodelist).length > 0){
let groupCodelist: any = await this.codeListService.getDataItems(this.groupCodelist);
groups = Util.deepCopy(groupCodelist);
}
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)=>{
let children:Array<any> = [];
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);
}
});
......@@ -343,7 +356,15 @@ import CodeListService from "@/codelist/codelist-service";
});
let child:Array<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){
child.push(item);
}
......@@ -352,7 +373,9 @@ import CodeListService from "@/codelist/codelist-service";
group: this.$t('app.commonWords.other'),
children: child
}
groupTree.push(Tree);
if(child && child.length > 0){
groupTree.push(Tree);
}
this.groupData = [...groupTree];
}
</#if>
......@@ -363,15 +386,28 @@ import CodeListService from "@/codelist/codelist-service";
*
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public drawGroup(){
public async drawGroup(){
let data:Array<any> = [...this.items];
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)=>{
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)];
if(groups.length == 0){
console.warn("分组数据无效");
}
let groupTree:Array<any> = [];
groups.forEach((group: any,i: number)=>{
let children:Array<any> = [];
......@@ -380,6 +416,7 @@ import CodeListService from "@/codelist/codelist-service";
children.push(item);
}
});
group = group ? group : this.$t('app.commonWords.other');
const tree: any ={
group: group,
children: children
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册