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

表格部件代码表分组

上级 55a3fb4b
......@@ -617,6 +617,22 @@ ${gridColumn.getName()}
*/
public groupMode:string ="<#if ctrl.getGroupMode()??>${ctrl.getGroupMode()}</#if>";
/**
* 分组代码表标识
*
* @type {string}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public codelistTag: 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>";
/**
* 获取界面行为权限状态
*
......@@ -837,7 +853,7 @@ ${gridColumn.getName()}
this.getAggData();
</#if>
<#if ctrl.isEnableGroup()>
this.drawGroup();
this.group();
</#if>
}).catch((response: any) => {
if (response && response.status === 401) {
......@@ -913,7 +929,6 @@ ${gridColumn.getName()}
this.$Notice.success({ title: '', desc: (this.$t('app.gridpage.delSuccess') as string) });
}
//删除items中已删除的项
console.log(this.items);
_datas.forEach((data: any) => {
this.items.some((item:any,index:number)=>{
if(Object.is(item.srfkey,data.srfkey)){
......@@ -1415,6 +1430,110 @@ ${gridColumn.getName()}
}
}
/**
* 分组方法
*
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public group(){
if(Object.is(this.groupMode,"AUTO")){
this.drawGroup();
}else if(Object.is(this.groupMode,"CODELIST")){
this.drawCodelistGroup();
}
}
/**
* 根据分组代码表绘制分组列表
*
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public async drawCodelistGroup(){
if(!this.isEnableGroup) return;
// 分组
let allGroup: 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);
}
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.groupField])){
item.groupById = Number((i+1) * 10 + (i+1) * 1);
item.group = '';
children.push(item);
}
});
const tree: any ={
groupById: Number((i+1)*10);
group: group.label,
<#if ctrl.getPSDEGridColumns()??>
<#list ctrl.getPSDEGridColumns() as singleColumn>
<#if singleColumn.getColumnType()?? && singleColumn.getColumnType() == "UAGRIDCOLUMN">
<#if singleColumn.getPSDEUIActionGroup()?? && singleColumn.getPSDEUIActionGroup().getPSUIActions()??>
<#list singleColumn.getPSDEUIActionGroup().getPSUIActions() as singleUIAction>
${singleUIAction.getCodeName()}:{
visabled: false
},
</#list>
</#if>
<#else>
${singleColumn.getCodeName()}:'',
</#if>
</#list>
</#if>
children: children
}
groupTree.push(tree);
});
let child:Array<any> = [];
this.items.forEach((item: any)=>{
let i = allGroup.findIndex((group: any)=>Object.is(group.label,item[this.groupField]));
if(i < 0){
item.groupById = Number((allGroup.length+1) * 10 + (allGroup.length+1) * 1);
item.group = '';
child.push(item);
}
})
const Tree: any = {
groupById: Number((allGroup.length+1)*10);
group: this.$t('app.gridpage.other'),
<#if ctrl.getPSDEGridColumns()??>
<#list ctrl.getPSDEGridColumns() as singleColumn>
<#if singleColumn.getColumnType()?? && singleColumn.getColumnType() == "UAGRIDCOLUMN">
<#if singleColumn.getPSDEUIActionGroup()?? && singleColumn.getPSDEUIActionGroup().getPSUIActions()??>
<#list singleColumn.getPSDEUIActionGroup().getPSUIActions() as singleUIAction>
${singleUIAction.getCodeName()}:{
visabled: false
},
</#list>
</#if>
<#else>
${singleColumn.getCodeName()}:'',
</#if>
</#list>
</#if>
children: child
}
if(child && child.length > 0){
groupTree.push(Tree);
}
this.items = groupTree;
if(this.actualIsOpenEdit) {
for(let i = 0; i < this.items.length; i++) {
this.gridItemsModel.push(this.getGridRowModel());
}
}
}
/**
* 绘制分组
*
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册