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

update:更新表格

上级 ebf085ef
...@@ -13,7 +13,7 @@ export interface GridControlState extends MainControlState { ...@@ -13,7 +13,7 @@ export interface GridControlState extends MainControlState {
* @type {IParam[]} * @type {IParam[]}
* @memberof GridControlState * @memberof GridControlState
*/ */
items: IParam[]; data: IParam[];
/** /**
* @description 表格列模型 * @description 表格列模型
...@@ -34,7 +34,7 @@ export interface GridControlState extends MainControlState { ...@@ -34,7 +34,7 @@ export interface GridControlState extends MainControlState {
* @type {IParam} * @type {IParam}
* @memberof GridControlState * @memberof GridControlState
*/ */
rules: IParam; rules: IParam[];
/** /**
* @description 是否多选 * @description 是否多选
...@@ -79,93 +79,31 @@ export interface GridControlState extends MainControlState { ...@@ -79,93 +79,31 @@ export interface GridControlState extends MainControlState {
selectFirstDefault: boolean; selectFirstDefault: boolean;
/** /**
* @description 当前页 * @description 表格聚合
* @type {number}
* @memberof GridControlState
*/
current: number;
/**
* @description 分页大小
* @type {number}
* @memberof GridControlState
*/
pageSize: number;
/**
* @description 是否启用分页
* @type {boolean}
* @memberof GridControlState
*/
enablePagingBar: boolean;
/**
* @description 数据聚合
* @type {IParam} * @type {IParam}
* @memberof GridControlState * @memberof GridControlState
*/ */
dataAgg: string[]; gridAgg: IParam;
/**
* @description 聚合模式
* @type {string}
* @memberof GridControlState
*/
aggMode: string;
/**
* @description 聚合实体
* @type {string}
* @memberof GridControlState
*/
aggEntity: string,
/**
* @description 聚合数据集
* @type {string}
* @memberof GridControlState
*/
aggDataSet: string,
/**
* @description 分组模式
* @type {string}
* @memberof GridControlState
*/
groupMode: string;
/**
* @description 分组属性
* @type {string}
* @memberof GridControlState
*/
groupField: string;
/** /**
* @description 分组代码表 * @description 表格分组
* @type {*} * @type {IParam}
* @memberof GridControlState * @memberof GridControlState
*/ */
groupCodeList: any; gridGroup: IParam;
/** /**
* @description 禁用排序 * @description 表格排序
* @type {boolean} * @type {IParam}
* @memberof GridControlState * @memberof GridControlState
*/ */
noSort: boolean; gridSort: IParam;
/** /**
* @description 排序方向 * @description 表格分页
* @type {string} * @type {IParam}
* @memberof GridControlState * @memberof GridControlState
*/ */
minorSortDir: string; gridPaging: IParam
/**
* @description 排序属性
* @type {string}
* @memberof GridControlState
*/
minorSortPSDEF: string;
} }
...@@ -38,10 +38,10 @@ export class GridControl extends MainControl { ...@@ -38,10 +38,10 @@ export class GridControl extends MainControl {
* @memberof GridControl * @memberof GridControl
*/ */
public gridDataChange(rowIndex: number, name: string, value: any){ public gridDataChange(rowIndex: number, name: string, value: any){
if (this.controlState.items[rowIndex][name] !== value) { if (this.controlState.data[rowIndex][name] !== value) {
this.controlState.items[rowIndex][name] = value; this.controlState.data[rowIndex][name] = value;
if (!this.controlState.items[rowIndex]["rowDataState"]) { if (!this.controlState.data[rowIndex]["rowDataState"]) {
this.controlState.items[rowIndex]["rowDataState"] = "update"; this.controlState.data[rowIndex]["rowDataState"] = "update";
} }
} }
} }
...@@ -82,8 +82,9 @@ export class GridControl extends MainControl { ...@@ -82,8 +82,9 @@ export class GridControl extends MainControl {
* @memberof GridControl * @memberof GridControl
*/ */
public autoGroup() { public autoGroup() {
const { groupField } = this.controlState; const { gridGroup } = this.controlState;
const dataRef = toRef(this.controlState, "items"); const { groupField } = gridGroup;
const dataRef = toRef(this.controlState, "data");
let autoGroup: string[] = []; let autoGroup: string[] = [];
dataRef.value.forEach((item: IParam) => { dataRef.value.forEach((item: IParam) => {
if (item.hasOwnProperty(groupField)) { if (item.hasOwnProperty(groupField)) {
...@@ -117,8 +118,9 @@ export class GridControl extends MainControl { ...@@ -117,8 +118,9 @@ export class GridControl extends MainControl {
* @memberof GridControl * @memberof GridControl
*/ */
public async codeListGroup() { public async codeListGroup() {
const { groupField } = this.controlState; const { gridGroup } = this.controlState;
const dataRef = toRef(this.controlState, "items"); const { groupField } = gridGroup;
const dataRef = toRef(this.controlState, "data");
// TODO 代码表数据 // TODO 代码表数据
let codeListGroup: IParam[] = []; let codeListGroup: IParam[] = [];
if (codeListGroup.length > 0) { if (codeListGroup.length > 0) {
...@@ -161,7 +163,7 @@ export class GridControl extends MainControl { ...@@ -161,7 +163,7 @@ export class GridControl extends MainControl {
* @memberof GridControl * @memberof GridControl
*/ */
public calcGridAuthState() { public calcGridAuthState() {
const dataRef = toRef(this.controlState, "items"); const dataRef = toRef(this.controlState, "data");
const columnsModelRef = toRef(this.controlState, "columnsModel"); const columnsModelRef = toRef(this.controlState, "columnsModel");
let columnModel = this.getGridColumn(columnsModelRef.value, "UAGRIDCOLUMN"); let columnModel = this.getGridColumn(columnsModelRef.value, "UAGRIDCOLUMN");
if (columnModel) { if (columnModel) {
...@@ -208,8 +210,9 @@ export class GridControl extends MainControl { ...@@ -208,8 +210,9 @@ export class GridControl extends MainControl {
* @memberof GridControl * @memberof GridControl
*/ */
public handleGridGroup() { public handleGridGroup() {
const { groupMode, groupField } = this.controlState; const { gridGroup } = this.controlState;
if (groupField && !Object.is(groupMode, "NONE")) { const { enableGroup, groupField, groupMode } = gridGroup;
if (enableGroup && groupField && !Object.is(groupMode, "NONE")) {
if (Object.is(groupMode, "AUTO")) { if (Object.is(groupMode, "AUTO")) {
this.autoGroup(); this.autoGroup();
} else if (Object.is(groupMode, "CODELIST")) { } else if (Object.is(groupMode, "CODELIST")) {
...@@ -224,7 +227,7 @@ export class GridControl extends MainControl { ...@@ -224,7 +227,7 @@ export class GridControl extends MainControl {
* @memberof GridControl * @memberof GridControl
*/ */
public async remoteAgg(): Promise<IParam[]> { public async remoteAgg(): Promise<IParam[]> {
const { aggEntity, aggDataSet } = this.controlState; const { gridAgg } = this.controlState;
const aggData: IParam[] = []; const aggData: IParam[] = [];
// TODO 调用服务获取聚合数据 // TODO 调用服务获取聚合数据
return aggData; return aggData;
...@@ -280,22 +283,32 @@ export class GridControl extends MainControl { ...@@ -280,22 +283,32 @@ export class GridControl extends MainControl {
* @memberof GridControl * @memberof GridControl
*/ */
public async handleDataAgg() { public async handleDataAgg() {
const { aggMode, enablePagingBar } = this.controlState; const { gridPaging, gridGroup } = this.controlState;
const gridAggRef = toRef(this.controlState, "gridAgg");
let { aggMode, aggData } = gridAggRef.value;
const { enableGroup } = gridGroup;
if (!Object.is(aggMode, "NONE")) { if (!Object.is(aggMode, "NONE")) {
const dataAggRef = toRef(this.controlState, "dataAgg"); const { enablePagingBar, current, pageSize} = gridPaging;
const currentRef = toRef(this.controlState, "current"); let dataAgg: IParam[] = [];
const pageSizeRef = toRef(this.controlState, "pageSize");
let aggData: IParam[] = [];
if (Object.is(aggMode, "PAGE")) { if (Object.is(aggMode, "PAGE")) {
const dataRef = toRef(this.controlState, "items"); const dataRef = toRef(this.controlState, "data");
aggData = [...dataRef.value]; dataAgg = [...dataRef.value];
} else if (Object.is(aggMode, "ALL")) { } else if (Object.is(aggMode, "ALL")) {
aggData = await this.remoteAgg(); dataAgg = await this.remoteAgg();
} }
if (enablePagingBar) { if (enablePagingBar) {
const start: number = (currentRef.value - 1) * pageSizeRef.value > 0 ? (currentRef.value - 1) * pageSizeRef.value - 1 : 0; const start: number = (current - 1) * pageSize > 0 ? (current - 1) * pageSize - 1 : 0;
const end: number = currentRef.value * pageSizeRef.value; const end: number = current * pageSize;
aggData = aggData.slice(start, end); dataAgg = dataAgg.slice(start, end);
}
if (enableGroup) {
const _dataAgg: IParam[] = [];
dataAgg.forEach((item: IParam) => {
item.children?.forEach((child: IParam) => {
_dataAgg.push(child);
})
})
dataAgg = _dataAgg;
} }
const columnsModelRef = toRef(this.controlState, "columnsModel"); const columnsModelRef = toRef(this.controlState, "columnsModel");
const columnsModel: IParam[] = []; const columnsModel: IParam[] = [];
...@@ -304,11 +317,9 @@ export class GridControl extends MainControl { ...@@ -304,11 +317,9 @@ export class GridControl extends MainControl {
columnsModel.push(column); columnsModel.push(column);
} }
}); });
const dataAgg: string[] = [];
columnsModel.forEach((column: IParam) => { columnsModel.forEach((column: IParam) => {
dataAgg.push(this.getAggValue(aggData, column)) aggData.push(this.getAggValue(dataAgg, column))
}) })
dataAggRef.value = [...dataAgg];
} }
} }
...@@ -328,7 +339,7 @@ export class GridControl extends MainControl { ...@@ -328,7 +339,7 @@ export class GridControl extends MainControl {
}); });
selectedRowKeysRef.value = selectedRowKeys; selectedRowKeysRef.value = selectedRowKeys;
} else if (selectFirstDefault) { } else if (selectFirstDefault) {
const dataRef = toRef(this.controlState, "items"); const dataRef = toRef(this.controlState, "data");
if (dataRef.value[0]) { if (dataRef.value[0]) {
this.emit("ctrlEvent", { this.emit("ctrlEvent", {
tag: controlName, tag: controlName,
...@@ -350,14 +361,15 @@ export class GridControl extends MainControl { ...@@ -350,14 +361,15 @@ export class GridControl extends MainControl {
const load = async (opt: any = {})=>{ const load = async (opt: any = {})=>{
try { try {
const { const {
controlService, context, viewParams, showBusyIndicator, noSort, minorSortDir, minorSortPSDEF, controlService, context, viewParams, showBusyIndicator, controlAction, gridSort
enablePagingBar, controlAction
} = this.controlState; } = this.controlState;
const dataRef = toRef(this.controlState, "items"); const dataRef = toRef(this.controlState, "data");
const paginationRef = toRef(this.controlState, "pagination"); const gridPagingRef = toRef(this.controlState, "gridPaging");
if(!controlAction.loadAction){ if(!controlAction.loadAction){
return; return;
} }
const { noSort, minorSortDir, minorSortPSDEF} = gridSort;
let { enablePagingBar, pagination, current, pageSize} = gridPagingRef.value;
const arg: any = { ...opt }; const arg: any = { ...opt };
let _context = deepCopy(context ? context : {}); let _context = deepCopy(context ? context : {});
let _viewParams = deepCopy(viewParams ? context : {}); let _viewParams = deepCopy(viewParams ? context : {});
...@@ -365,9 +377,7 @@ export class GridControl extends MainControl { ...@@ -365,9 +377,7 @@ export class GridControl extends MainControl {
Object.assign(_viewParams, { sort: `${minorSortPSDEF},${minorSortDir}`}); Object.assign(_viewParams, { sort: `${minorSortPSDEF},${minorSortDir}`});
} }
if (enablePagingBar) { if (enablePagingBar) {
const currentRef = toRef(this.controlState, "current"); Object.assign(_viewParams, { page: current - 1, size: pageSize});
const pageSizeRef = toRef(this.controlState, "pageSize");
Object.assign(_viewParams, { page: currentRef.value - 1, size: pageSizeRef.value});
} }
Object.assign(arg, { viewParams: _viewParams }); Object.assign(arg, { viewParams: _viewParams });
const response = await controlService.get( const response = await controlService.get(
...@@ -378,7 +388,7 @@ export class GridControl extends MainControl { ...@@ -378,7 +388,7 @@ export class GridControl extends MainControl {
if (response.status || response.status == 200) { if (response.status || response.status == 200) {
dataRef.value = response.data; dataRef.value = response.data;
if (enablePagingBar) { if (enablePagingBar) {
paginationRef.value['total'] = response.total; pagination['total'] = response.total;
} }
this.calcGridAuthState(); this.calcGridAuthState();
this.handleDefaultSelect(); this.handleDefaultSelect();
...@@ -387,7 +397,7 @@ export class GridControl extends MainControl { ...@@ -387,7 +397,7 @@ export class GridControl extends MainControl {
} }
} catch (error) { } catch (error) {
// todo 错误异常处理 // todo 错误异常处理
console.error(error) console.log(this.controlState.gridAgg);
} }
} }
...@@ -419,10 +429,10 @@ export class GridControl extends MainControl { ...@@ -419,10 +429,10 @@ export class GridControl extends MainControl {
const { viewSubject, controlName } = this.controlState; const { viewSubject, controlName } = this.controlState;
const save = async (opt: any = {}) => { const save = async (opt: any = {}) => {
try { try {
const { controlService, context, viewParams, showBusyIndicator, items, controlAction } = this.controlState; const { controlService, context, viewParams, showBusyIndicator, data, controlAction } = this.controlState;
// TODO 值规则校验处理 // TODO 值规则校验处理
for (const item of items) { for (const item of data) {
const { updateAction, createAction } = controlAction; const { updateAction, createAction } = controlAction;
const saveAction: any = item.rowDataState == "update" ? updateAction : item.rowDataState == "create" ? createAction : ""; const saveAction: any = item.rowDataState == "update" ? updateAction : item.rowDataState == "create" ? createAction : "";
const saveFunName = item.rowDataState; const saveFunName = item.rowDataState;
...@@ -480,7 +490,7 @@ export class GridControl extends MainControl { ...@@ -480,7 +490,7 @@ export class GridControl extends MainControl {
if (!controlAction.removeAction) { if (!controlAction.removeAction) {
return; return;
} }
const dataRef = toRef(this.controlState, "items"); const dataRef = toRef(this.controlState, "data");
const data: IParam[] = []; const data: IParam[] = [];
opt.forEach((item: IParam, index: number) => { opt.forEach((item: IParam, index: number) => {
if (Object.is(item.srfuf, "0")) { if (Object.is(item.srfuf, "0")) {
...@@ -554,7 +564,7 @@ export class GridControl extends MainControl { ...@@ -554,7 +564,7 @@ export class GridControl extends MainControl {
if (!controlAction.loadDraftAction) { if (!controlAction.loadDraftAction) {
return; return;
} }
const dataRef = toRef(this.controlState, "items"); const dataRef = toRef(this.controlState, "data");
let _context = deepCopy(context); let _context = deepCopy(context);
let _viewParams = deepCopy(viewParams); let _viewParams = deepCopy(viewParams);
const arg: any = {...opt}; const arg: any = {...opt};
......
...@@ -23,46 +23,44 @@ export const CtrlConfig = { ...@@ -23,46 +23,44 @@ export const CtrlConfig = {
controlCodeName: "{{ctrl.codeName}}", controlCodeName: "{{ctrl.codeName}}",
controlName: "{{ctrl.name}}", controlName: "{{ctrl.name}}",
controlService: new GridService<ControlVO>(ControlVO, new {{pascalCase ctrl.psAppDataEntity.codeName}}Service() ), controlService: new GridService<ControlVO>(ControlVO, new {{pascalCase ctrl.psAppDataEntity.codeName}}Service() ),
items: [], data: [],
dataAgg: [],
selectedRowKeys: [], selectedRowKeys: [],
aggMode: "{{ctrl.aggMode}}", gridAgg: {
{{#if (eq ctrl.aggMode 'ALL')}} aggMode: "{{ctrl.aggMode}}",
aggEntity: "{{ctrl.aggPSAppDataEntity.codeName}}", aggData: [],
aggDataSet: "{{ctrl.aggPSAppDEDataSet.codeName}}", {{#if ctrl.aggPSAppDataEntity}}
{{/if}} aggEntity: "{{ctrl.aggPSAppDataEntity.codeName}}",
{{#if ctrl.enableGroup}} aggDataSet: "{{ctrl.aggPSAppDEDataSet.codeName}}",
groupMode: "{{ctrl.groupMode}}", {{/if}}
groupField: "{{lowerCase ctrl.groupPSAppDEField.codeName}}", },
{{#if ctrl.groupPSCodeList}} gridGroup: {
groupCodeList: { enableGroup: {{ctrl.enableGroup}},
codeListTag: "{{ctrl.groupPSCodeList.codeName}}", groupMode: "{{ctrl.groupMode}}",
codeListType: "{{ctrl.groupPSCodeList.codeListType}}", groupField: "{{lowerCase ctrl.groupPSAppDEField.codeName}}",
{{#if ctrl.groupPSCodeList}}
groupCodeList: {
codeListTag: "{{ctrl.groupPSCodeList.codeName}}",
codeListType: "{{ctrl.groupPSCodeList.codeListType}}",
},
{{/if}}
},
gridSort: {
noSort: {{ctrl.noSort}}}},
minorSortDir: "{{#if ctrl.minorSortDir}}{{ctrl.minorSortDir}}{{/if}}",
minorSortPSDEF: "{{ctrl.minorSortPSAppDEField.codeName}}",
}, },
{{/if}} gridPaging: {
{{/if}} enablePagingBar: {{ctrl.enablePagingBar}},
{{#if ctrl.noSort}} current: 1,
noSort: true, pageSize: {{#if ctrl.pagingSize}}{{ctrl.pagingSize}}{{else}}20{{/if}},
{{else}} pagination: {{#if ctrl.enablePagingBar}}{
noSort: false, position: ['bottomRight'],
minorSortDir: "{{#if ctrl.minorSortDir}}{{ctrl.minorSortDir}}{{/if}}", defaultPageSize: {{#if ctrl.pagingSize}}{{ctrl.pagingSize}}{{else}}20{{/if}},
minorSortPSDEF: "{{ctrl.minorSortPSAppDEField.codeName}}", showQuickJumper: true,
{{/if}} showTotal: (total: number, range: IParam[]) => `${range[0]}-${range[1]} of ${total} items`,
{{#if ctrl.enablePagingBar}} pageSizeOptions: ['10','20','50','100'],
enablePagingBar: true, }{{else}}false{{/if}},
current: 1,
pageSize: {{#if ctrl.pagingSize}}{{ctrl.pagingSize}}{{else}}20{{/if}},
pagination: {
position: ['bottomRight'],
defaultPageSize: {{#if ctrl.pagingSize}}{{ctrl.pagingSize}}{{else}}20{{/if}},
showQuickJumper: true,
showTotal: (total: number, range: IParam[]) => `${range[0]}-${range[1]} of ${total} items`,
pageSizeOptions: ['10','20','50','100'],
}, },
{{else}}
enablePagingBar: false,
pagination: false,
{{/if}}
uAColumnModel:[ uAColumnModel:[
{{#each ctrl.psDEGridColumns as | column |}} {{#each ctrl.psDEGridColumns as | column |}}
{{>(lookup 'UACOLUMNMODEL') item=column}} {{>(lookup 'UACOLUMNMODEL') item=column}}
......
...@@ -112,10 +112,10 @@ const handleChange = (pagination: IParam, filters: IParam, sorter: IParam, data: ...@@ -112,10 +112,10 @@ const handleChange = (pagination: IParam, filters: IParam, sorter: IParam, data:
:showHeader="{{#if ctrl.hideHeader}}false{{else}}true{{/if}}" :showHeader="{{#if ctrl.hideHeader}}false{{else}}true{{/if}}"
:scroll="gridScrollOption" :scroll="gridScrollOption"
:sortDirections="['ascend', 'descend']" :sortDirections="['ascend', 'descend']"
:data-source="state.items" :data-source="state.data"
:row-selection="rowSelectionOption" :row-selection="rowSelectionOption"
:columns="state.columnsModel" :columns="state.columnsModel"
:pagination="state.pagination" :pagination="state.gridPaging.pagination"
:customRow="customRow" :customRow="customRow"
:rowClassName="rowClassName" :rowClassName="rowClassName"
@change="handleChange" @change="handleChange"
...@@ -142,7 +142,7 @@ const handleChange = (pagination: IParam, filters: IParam, sorter: IParam, data: ...@@ -142,7 +142,7 @@ const handleChange = (pagination: IParam, filters: IParam, sorter: IParam, data:
<a-table-summary> <a-table-summary>
<a-table-summary-row> <a-table-summary-row>
<a-table-summary-cell align="center">数据聚合</a-table-summary-cell> <a-table-summary-cell align="center">数据聚合</a-table-summary-cell>
<a-table-summary-cell v-for="(item, index) in state.dataAgg" :key="index"> <a-table-summary-cell v-for="(item, index) in state.gridAgg.aggData" :key="index">
<span>\{{item}}</span> <span>\{{item}}</span>
</a-table-summary-cell> </a-table-summary-cell>
</a-table-summary-row> </a-table-summary-row>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册