1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import { IPSAppDEGridView, IPSDEGrid, IPSDEToolbarItem } from '@ibiz/dynamic-model-api';
import { GirdViewInterface, ModelTool, Util } from 'ibiz-core';
import { MDViewBase } from './mdview-base';
/**
* 表格视图基类
*
* @export
* @class GridViewBase
* @extends {MDViewBase}
* @implements {GirdViewInterface}
*/
export class GridViewBase extends MDViewBase implements GirdViewInterface {
/**
* 视图实例
*
* @memberof GridViewBase
*/
public declare viewInstance: IPSAppDEGridView;
/**
* 表格实例
*
* @memberof GridViewBase
*/
public gridInstance!: IPSDEGrid;
/**
* 引擎初始化
*
* @param {*} [opts={}] 引擎参数
* @memberof GridViewBase
*/
public engineInit(opts: any = {}): void {
if (this.Environment && this.Environment.isPreviewMode) {
return;
}
if (this.engine && this.gridInstance) {
let engineOpts = Object.assign({
view: this,
p2k: '0',
isLoadDefault: this.viewInstance?.loadDefault,
keyPSDEField: this.appDeCodeName.toLowerCase(),
majorPSDEField: this.appDeMajorFieldName.toLowerCase(),
opendata: (args: any[], fullargs?: any[], params?: any, $event?: any, xData?: any) => {
this.opendata(args, fullargs, params, $event, xData);
},
newdata: (args: any[], fullargs?: any[], params?: any, $event?: any, xData?: any) => {
this.newdata(args, fullargs, params, $event, xData);
},
grid: (this.$refs[this.gridInstance?.name] as any).ctrl,
}, opts)
if (this.searchFormInstance?.name && this.$refs[this.searchFormInstance.name]) {
engineOpts.searchform = ((this.$refs[this.searchFormInstance.name] as any).ctrl);
}
if (this.quickSearchFormInstance?.name && this.$refs[this.quickSearchFormInstance.name]) {
engineOpts.quicksearchform = ((this.$refs[this.quickSearchFormInstance.name] as any).ctrl);
}
if (this.searchBarInstance?.name && this.$refs[this.searchBarInstance.name]) {
engineOpts.searchbar = ((this.$refs[this.searchBarInstance.name] as any).ctrl);
}
this.engine.init(engineOpts);
}
}
/**
* 初始化表格视图实例
*
* @memberof GridViewBase
*/
public async viewModelInit() {
await super.viewModelInit();
this.gridInstance = ModelTool.findPSControlByType("GRID", this.viewInstance.getPSControls());
}
/**
* 渲染视图主体内容区
*
* @memberof GridViewBase
*/
public renderMainContent() {
if (!this.gridInstance) {
return;
}
let { targetCtrlName, targetCtrlParam, targetCtrlEvent }: { targetCtrlName: string, targetCtrlParam: any, targetCtrlEvent: any } = this.computeTargetCtrlData(this.gridInstance);
return this.$createElement(targetCtrlName, { props: targetCtrlParam, ref: this.gridInstance?.name, on: targetCtrlEvent });
}
/**
* 计算目标部件所需参数
*
* @param {any} [controlInstance] 部件模型实例
* @returns
* @memberof GridViewBase
*/
public computeTargetCtrlData(controlInstance: any, args?: any) {
const { targetCtrlName, targetCtrlParam, targetCtrlEvent } = super.computeTargetCtrlData(controlInstance, args);
Object.assign(targetCtrlParam.staticProps, {
isOpenEdit: this.viewInstance?.rowEditDefault,
gridRowActiveMode: this.viewInstance?.gridRowActiveMode,
});
return { targetCtrlName: targetCtrlName, targetCtrlParam: targetCtrlParam, targetCtrlEvent: targetCtrlEvent };
}
/**
* 部件事件
* @param ctrl 部件
* @param action 行为
* @param data 数据
*
* @memberof GridViewBase
*/
public onCtrlEvent(controlname: string, action: string, data: any) {
if(action) {
switch (action) {
case "save":
this.$emit("view-event", { action: "drdatasaved", data: data });
break;
case "search":
this.onSearch(data);
break;
default:
super.onCtrlEvent(controlname, action, data);
break;
}
}
}
/**
* 初始化工具栏项
*
* @param {IPSDEToolbarItem} item
*
* @@memberof ViewBase
*/
initToolBarItems(item: IPSDEToolbarItem): void {
const tempModel: any = super.initToolBarItems(item);
// 导出最大行数
if(tempModel?.uiaction?.uIActionTag == "ExportExcel"){
const gridInstance = ModelTool.findPSControlByType("GRID",this.viewInstance.getPSControls());
const maxRowCount = gridInstance.getPSDEDataExport()?.maxRowCount;
if(maxRowCount){
tempModel.MaxRowCount = maxRowCount;
}
}
return tempModel;
}
}