提交 8092ea74 编写于 作者: Mosher's avatar Mosher

update:更新表格部件

支持代码表分组
操作列呈现
上级 0e89d33b
<div v-if="Object.is(column.dataIndex, '{{#if item.dataItemName}}{{lowerCase item.dataItemName}}{{else}}{{item.codeName}}{{/if}}')" class="header-cell"> <div v-if="Object.is(column.dataIndex, '{{#if item.dataItemName}}{{lowerCase item.dataItemName}}{{else}}{{item.codeName}}{{/if}}')" class="header-cell{{#if item.headerPSSysCss}} {{item.headerPSSysCss.cssName}}{{/if}}">
{{#if item.psSysImage}} {{#if item.psSysImage}}
<AppIconText {{#if item.psSysImage.cssClass}}iconClass="{{item.psSysImage.cssClass}}"{{/if}} {{#if item.psSysImage.imagePath}}imgPath="{{item.psSysImage.imagePath}}"{{/if}}/> <AppIconText {{#if item.psSysImage.cssClass}}iconClass="{{item.psSysImage.cssClass}}"{{/if}} {{#if item.psSysImage.imagePath}}imgPath="{{item.psSysImage.imagePath}}"{{/if}}/>
<span class="title">\{{title}}</span> <span class="title">\{{title}}</span>
......
{{#unless (or item.hideDefault item.hiddenDataItem)}} {{#unless (or item.hideDefault item.hiddenDataItem)}}
{ {
title: "{{item.caption}}", title: "{{item.caption}}",
columnType: "{{item.columnType}}", columnType: "{{item.columnType}}",
{{#if item.align}} {{#if item.align}}
align: "{{lowerCase item.align}}", align: "{{lowerCase item.align}}",
{{/if}} {{/if}}
{{#if (eq item.widthUnit 'PX')}} {{#if (eq item.widthUnit 'PX')}}
width: {{item.width}}, width: {{item.width}},
{{else}} {{else}}
minWidth: {{item.width}}, minWidth: {{item.width}},
{{/if}} {{/if}}
resizable: true, resizable: true,
{{#eq item.columnType 'GROUPGRIDCOLUMN'}} {{#eq item.columnType 'GROUPGRIDCOLUMN'}}
children: [ children: [
{{#each item.psDEGridColumns as | column |}} {{#each item.psDEGridColumns as | column |}}
{{> @macro/front-end/widgets/grid-detail/include-grid.hbs type="COLUMNMODEL" item=column}} {{> @macro/front-end/widgets/grid-detail/include-grid.hbs type="COLUMNMODEL" item=column}}
{{/each}} {{/each}}
], ],
{{else}} {{else}}
{{#eq item.columnType 'UAGRIDCOLUMN'}} {{#eq item.columnType 'UAGRIDCOLUMN'}}
fixed: "right", fixed: "right",
{{/eq}} {{/eq}}
dataIndex: "{{#if item.dataItemName}}{{lowerCase item.dataItemName}}{{else}}{{lowerCase item.codeName}}{{/if}}", dataIndex: "{{#if item.dataItemName}}{{lowerCase item.dataItemName}}{{else}}{{lowerCase item.codeName}}{{/if}}",
ellipsis: true, ellipsis: true,
enableSort: {{item.enableSort}}, enableSort: {{item.enableSort}},
{{#if item.aggMode}} {{#if item.aggMode}}
aggMode: "{{item.aggMode}}", aggMode: "{{item.aggMode}}",
{{/if}} {{/if}}
{{/eq}} {{/eq}}
}, },
{{/unless}} {{/unless}}
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
{{/each}} {{/each}}
{{else}} {{else}}
{{#unless (or item.hideDefault item.hiddenDataItem)}} {{#unless (or item.hideDefault item.hiddenDataItem)}}
<div v-if="Object.is(column.dataIndex, '{{#if item.dataItemName}}{{lowerCase item.dataItemName}}{{else}}{{item.codeName}}{{/if}}')" class="table-cell"> <div v-if="Object.is(column.dataIndex, '{{#if item.dataItemName}}{{lowerCase item.dataItemName}}{{else}}{{item.codeName}}{{/if}}')" class="table-cell {{#if item.cellPSSysCss}} {{item.cellPSSysCss.cssName}}{{/if}}">
{{#if (eq item.columnType 'DEFGRIDCOLUMN')}} {{#if (eq item.columnType 'DEFGRIDCOLUMN')}}
{{#if item.enableRowEdit}} {{#if item.enableRowEdit}}
<div v-if="state.rowEditState" class="editor-cell"> <div v-if="state.rowEditState" class="editor-cell">
......
...@@ -3,9 +3,11 @@ ...@@ -3,9 +3,11 @@
{{> @macro/front-end/widgets/grid-detail/include-grid.hbs type="UACOLUMNMODEL" item=column}} {{> @macro/front-end/widgets/grid-detail/include-grid.hbs type="UACOLUMNMODEL" item=column}}
{{/each}} {{/each}}
{{else if (eq item.columnType 'UAGRIDCOLUMN')}} {{else if (eq item.columnType 'UAGRIDCOLUMN')}}
{{lowerCase item.codeName}}: [
{{#each item.psDEUIActionGroup.psUIActionGroupDetails as | action |}} {{#each item.psDEUIActionGroup.psUIActionGroupDetails as | action |}}
{{#action}} {{#action}}
{ name: "{{name}}", caption: "{{psUIAction.caption}}", showIcon: {{showIcon}}, showCaption: {{showCaption}}, separator: {{addSeparator}}, uIActionTag: "{{psUIAction.uIActionTag}}", noPrivDisplayMode: "{{psUIAction.noPrivDisplayMode}}", dataAccessAction: '{{psUIAction.dataAccessAction}}', actionTarget: '{{psUIAction.actionTarget}}', disabled: false, visible: true,{{#if psUIAction.psSysImage}}{{#if psUIAction.psSysImage.imagePath}} imgPath: "{{psUIAction.psSysImage.imagePath}}",{{/if}}{{#if psUIAction.psSysImage.cssClass}} iconClass: "{{psUIAction.psSysImage.cssClass}}",{{/if}}{{/if}} }, { name: "{{name}}", caption: "{{psUIAction.caption}}", showIcon: {{showIcon}}, showCaption: {{showCaption}}, separator: {{addSeparator}}, uIActionTag: "{{psUIAction.uIActionTag}}", noPrivDisplayMode: "{{psUIAction.noPrivDisplayMode}}", dataAccessAction: '{{psUIAction.dataAccessAction}}', actionTarget: '{{psUIAction.actionTarget}}', disabled: false, visible: true,{{#if psUIAction.psSysImage}}{{#if psUIAction.psSysImage.imagePath}} imgPath: "{{psUIAction.psSysImage.imagePath}}",{{/if}}{{#if psUIAction.psSysImage.cssClass}} iconClass: "{{psUIAction.psSysImage.cssClass}}",{{/if}}{{/if}} },
{{/action}} {{/action}}
{{/each}} {{/each}}
],
{{/if}} {{/if}}
\ No newline at end of file
...@@ -27,7 +27,7 @@ export interface GridControlState extends MDControlState { ...@@ -27,7 +27,7 @@ export interface GridControlState extends MDControlState {
* @type {IParam} * @type {IParam}
* @memberof GridControlState * @memberof GridControlState
*/ */
uAColumnModel: IParam[]; uAColumnModel: IParam;
/** /**
* @description 值规则 * @description 值规则
......
import { DataTypes, dateFormat, deepCopy, GridControlState, IActionParam, IParam, MDControl } from "@core"; import { DataTypes, dateFormat, deepCopy, GridControlState, IActionParam, IParam, isExistAndNotEmpty, MDControl } from "@core";
import { createUUID } from "qx-util"; import { createUUID } from "qx-util";
import schema, { ErrorList, FieldErrorList } from 'async-validator'; import schema, { ErrorList, FieldErrorList } from 'async-validator';
/** /**
...@@ -220,8 +220,15 @@ export class GridControl extends MDControl { ...@@ -220,8 +220,15 @@ export class GridControl extends MDControl {
*/ */
public handleStateChange() { public handleStateChange() {
// 计算表格操作列行为权限 // 计算表格操作列行为权限
const { items, columnsModel } = toRefs(this.state); const { items, uAColumnModel } = toRefs(this.state);
// this.getActionAuthState if (items.value.length > 0 && uAColumnModel.value && Object.keys(uAColumnModel.value).length > 0) {
Object.keys(uAColumnModel.value).forEach((key: string) => {
const tempActionModel = uAColumnModel.value[key];
items.value.forEach((item: any) => {
Object.assign(item, { [key]: this.getActionAuthState(item, tempActionModel) });
});
})
}
// 处理分组 // 处理分组
this.handleDataGroup(); this.handleDataGroup();
// 处理数据聚合 // 处理数据聚合
...@@ -405,44 +412,60 @@ export class GridControl extends MDControl { ...@@ -405,44 +412,60 @@ export class GridControl extends MDControl {
* @protected * @protected
* @memberof MDControl * @memberof MDControl
*/ */
protected codeListGroupData() { protected async codeListGroupData() {
const { gridGroup } = this.state; const { groupField, groupCodeList } = this.state.mdCtrlGroup;
const { items, columnsModel } = toRefs(this.state); const { items, context, viewParams, columnsModel } = toRefs(this.state);
const { groupField } = gridGroup; if (!groupCodeList || !isExistAndNotEmpty(groupCodeList.codeListTag)) {
// TODO 代码表数据 App.getNotificationService().warning({
let codeListGroup: IParam[] = []; message: '警告',
if (codeListGroup.length > 0) { description: '未配置分组代码表'
const groupColumn = this.getGridColumn(columnsModel.value, "GROUP"); });
const gridData: IParam[] = []; return;
const otherGroup: IParam[] = []; }
codeListGroup.forEach((group: IParam) => { const codeListService = App.getCodeListService();
const children: IParam[] = []; let codeListItems: IParam[] = [];
items.value.forEach((item: IParam) => { try {
if (Object.is(group.value, item[groupField])) { codeListItems = await codeListService.getCodeListItems({
children.push(item); tag: groupCodeList.codeListTag,
} context,
}); viewParams
gridData.push({
srfkey: createUUID(),
[groupColumn.dataIndex]: group.text,
children: deepCopy(children),
})
}); });
} catch(error) {
console.warn(`分组代码表 ${groupCodeList.codeListTag} 获取数据项异常`);
}
// 分组列
const groupColumn = this.getGridColumn(columnsModel.value, "GROUP");
// 分组数据集合
const groupItems: IParam[] = [];
// 其他分组项
const otherGroupItems: IParam[] = [];
codeListItems.forEach((group: IParam) => {
const children: IParam[] = [];
items.value.forEach((item: IParam) => { items.value.forEach((item: IParam) => {
const index: number = codeListGroup.findIndex((_item: IParam) => Object.is(item[groupField], _item.value)); if (Object.is(group.value, item[groupField])) {
if (index < 0) { children.push(item);
otherGroup.push(item);
} }
}); });
if (otherGroup.length > 0) { groupItems.push({
gridData.push({ srfkey: createUUID(),
srfkey: createUUID(), [groupColumn.dataIndex]: group.text,
[groupColumn.dataIndex]: "其它", children: children
children: deepCopy(otherGroup), })
}) });
items.value.forEach((item: IParam) => {
const index: number = codeListItems.findIndex((_item: IParam) => Object.is(item[groupField], _item.value));
if (index < 0) {
otherGroupItems.push(item);
} }
items.value = gridData; });
if (otherGroupItems.length > 0) {
groupItems.push({
srfkey: createUUID(),
[groupColumn.dataIndex]: "其它",
children: otherGroupItems,
})
} }
this.state.items = [...groupItems];
} }
/** /**
......
...@@ -32,20 +32,6 @@ export class MainControl extends ControlBase { ...@@ -32,20 +32,6 @@ export class MainControl extends ControlBase {
this.state.controlAction = toRef(this.props, 'controlAction') as any; this.state.controlAction = toRef(this.props, 'controlAction') as any;
} }
/**
* 获取指定数据的操作权限
*
* @param {IParam} data 指定数据
* @param {IParam} actionModel 界面行为模型
* @memberof MainControl
*/
public async getActionAuthState(data: IParam, actionModel: IParam) {
const { context, appEntityCodeName } = this.state;
const tempUIservice = await App.getUIService(appEntityCodeName.toLowerCase(), context);
UIUtil.calcActionItemAuthState(data, actionModel, tempUIservice);
return actionModel;
}
/** /**
*@description 使用UI服务 *@description 使用UI服务
* *
......
import { MDControlState, MainControl, deepCopy, IActionParam, IParam, UIBase } from '@core'; import { MDControlState, MainControl, deepCopy, IActionParam, IParam, UIBase, isExistAndNotEmpty, UIUtil } from '@core';
import { Modal } from 'ant-design-vue';
/** /**
* @description 多数据部件 * @description 多数据部件
...@@ -444,6 +445,18 @@ export class MDControl extends MainControl { ...@@ -444,6 +445,18 @@ export class MDControl extends MainControl {
*/ */
protected setUpdateDefault(): void { } protected setUpdateDefault(): void { }
/**
* 获取指定数据的操作权限
*
* @param {IParam} data 指定数据
* @memberof MDControl
*/
public getActionAuthState(data: IParam, tempActionModel: IParam) {
const { UIService } = toRefs(this.state);
UIUtil.calcActionItemAuthState(data, tempActionModel, UIService);
return tempActionModel;
}
/** /**
* 获取当前激活数据 * 获取当前激活数据
* *
......
...@@ -55,7 +55,7 @@ export const ctrlState = { ...@@ -55,7 +55,7 @@ export const ctrlState = {
groupField: "{{lowerCase ctrl.groupPSAppDEField.codeName}}", groupField: "{{lowerCase ctrl.groupPSAppDEField.codeName}}",
{{#if ctrl.groupPSCodeList}} {{#if ctrl.groupPSCodeList}}
groupCodeList: { groupCodeList: {
codeListTag: "{{ctrl.groupPSCodeList.codeName}}", codeListTag: "{{ctrl.groupPSCodeList.codeListTag}}",
codeListType: "{{ctrl.groupPSCodeList.codeListType}}", codeListType: "{{ctrl.groupPSCodeList.codeListType}}",
}, },
{{/if}} {{/if}}
...@@ -87,11 +87,11 @@ export const ctrlState = { ...@@ -87,11 +87,11 @@ export const ctrlState = {
aggDataSet: "{{ctrl.aggPSAppDEDataSet.codeName}}", aggDataSet: "{{ctrl.aggPSAppDEDataSet.codeName}}",
{{/if}} {{/if}}
}, },
uAColumnModel:[ uAColumnModel: {
{{#each ctrl.psDEGridColumns as | column |}} {{#each ctrl.psDEGridColumns as | column |}}
{{> @macro/front-end/widgets/grid-detail/include-grid.hbs type="UACOLUMNMODEL" item=column}} {{> @macro/front-end/widgets/grid-detail/include-grid.hbs type="UACOLUMNMODEL" item=column}}
{{/each}} {{/each}}
], },
gridEditState:{ gridEditState:{
{{#each ctrl.psDEGridEditItems as | column |}} {{#each ctrl.psDEGridEditItems as | column |}}
{{#if column.codeName }} {{#if column.codeName }}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册