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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
import { CodeListService, MobMDControlInterface, Util } from 'ibiz-core'
import { MainControlBase } from './main-control-base';
import { DataServiceHelp } from 'ibiz-core';
/**
* 多数据部件基类
*
* @export
* @class MDControlBase
* @extends {MainControlBase}
*/
export class MDControlBase extends MainControlBase implements MobMDControlInterface {
/**
* 代码表服务对象
*
* @type {CodeListService}
* @memberof MDControlBase
*/
public codeListService!: CodeListService;
/**
* 选中行数据
*
* @type {any[]}
* @memberof MDControlBase
*/
public selections: any[] = [];
/**
* 是否正在加载中
*
* @type {boolean}
* @memberof MobMDCtrlControlBase
*/
public isLoadding: boolean = false;
/**
* 部件行为--update
*
* @type {string}
* @memberof MDControlBase
*/
public updateAction?: string;
/**
* 部件行为--fetch
*
* @type {string}
* @memberof MDControlBase
*/
public fetchAction?: string;
/**
* 部件行为--remove
*
* @type {string}
* @memberof MDControlBase
*/
public removeAction?: string;
/**
* 部件行为--load
*
* @type {string}
* @memberof MDControlBase
*/
public loadAction?: string;
/**
* 部件行为--loaddraft
*
* @type {string}
* @memberof MDControlBase
*/
public loaddraftAction?: string;
/**
* 部件行为--create
*
* @type {string}
* @memberof MDControlBase
*/
public createAction?: string;
/**
* 数据映射(数据项名称和UI名称的映射)
*
* @memberof MDControlBase
*/
public dataMap: Map<string, any> = new Map();
/**
* 当前页
*
* @type {number}
* @memberof MDControlBase
*/
public curPage: number = 0;
/**
* 数据
*
* @type {any[]}
* @memberof MDControlBase
*/
public items: any[] = [];
/**
* 是否支持分页
*
* @type {boolean}
* @memberof MDControlBase
*/
public isEnablePagingBar: boolean = true;
/**
* 是否禁用排序
*
* @type {boolean}
* @memberof MDControlBase
*/
public isNoSort: boolean = false;
/**
* 排序方向
*
* @type {string}
* @memberof MDControlBase
*/
public minorSortDir: string = '';
/**
* 排序字段
*
* @type {string}
* @memberof MDControlBase
*/
public minorSortPSDEF: string = '';
/**
* 分页条数
*
* @type {number}
* @memberof MDControlBase
*/
public limit: number = 20;
/**
* 总条数
*
* @type {number}
* @memberof MDControlBase
*/
public totalRecord: number = 0;
/**
* 是否单选
*
* @type {boolean}
* @memberof GridControlBase
*/
public isSingleSelect?: boolean;
/**
* 是否默认选中第一条数据
*
* @type {boolean}
* @memberof MDControlBase
*/
public isSelectFirstDefault: boolean = false;
/**
* 启用下拉刷新
*
* @type {boolean}
* @memberof MDControlBase
*/
public enablePullDownRefresh: boolean = true;
/**
* 监听静态参数变化
*
* @param {*} newVal
* @param {*} oldVal
* @memberof ListControlBase
*/
public onStaticPropsChange(newVal: any, oldVal: any) {
if (newVal && !Util.isFieldsSame(newVal, oldVal)) {
this.isSingleSelect = newVal.isSingleSelect !== false;
this.isSelectFirstDefault = newVal.isSelectFirstDefault === true;
this.enablePullDownRefresh = newVal.enablePullDownRefresh === true;
super.onStaticPropsChange(newVal, oldVal);
}
}
/**
* 部件模型数据初始化
*
* @memberof MEditViewPanelControlBase
*/
public async ctrlModelInit(args?: any) {
await super.ctrlModelInit();
if (this.controlInstance.appDataEntity && !(this.Environment?.isPreviewMode)) {
this.appEntityService = await DataServiceHelp.getInstance().getService(this.controlInstance?.getPSAppDataEntity(), { context: this.context });
}
this.limit = this.controlInstance?.pagingSize ? this.controlInstance.pagingSize : 20;
this.minorSortDir = this.controlInstance?.minorSortDir ? this.controlInstance.minorSortDir : "";
this.minorSortPSDEF = this.controlInstance?.getMinorSortPSAppDEField?.()?.codeName?.toLowerCase() || '';
this.loaddraftAction = this.controlInstance?.getGetDraftPSControlAction?.()?.getPSAppDEMethod?.()?.codeName || "GetDraft";
this.loadAction = this.controlInstance?.getGetPSControlAction?.()?.getPSAppDEMethod?.()?.codeName || "Get";
this.removeAction = this.controlInstance?.getRemovePSControlAction?.()?.getPSAppDEMethod?.()?.codeName || "Remove";
this.updateAction = this.controlInstance?.getUpdatePSControlAction?.()?.getPSAppDEMethod?.()?.codeName || "Update";
this.fetchAction = this.controlInstance?.getFetchPSControlAction?.()?.getPSAppDEMethod?.()?.codeName || "FetchDefault";
this.createAction = this.controlInstance?.getCreatePSControlAction?.()?.getPSAppDEMethod?.()?.codeName || "Create";
this.initDataMap();
}
/**
* 多数据部件初始化
*
* @memberof MDControlBase
*/
public ctrlInit() {
super.ctrlInit();
let _this: any = this;
this.codeListService = new CodeListService({ $store: _this.$store });
}
/**
* 执行destroyed后的逻辑
*
* @memberof MDControlBase
*/
public ctrlDestroyed() {
super.ctrlDestroyed();
if (this.appStateEvent) {
this.appStateEvent.unsubscribe();
}
}
/**
* 获取多项数据
*
* @returns {any[]}
* @memberof MDControlBase
*/
public getDatas(): any[] {
return this.selections;
}
/**
* 获取单项树
*
* @returns {*}
* @memberof MDControlBase
*/
public getData(): any {
return this.selections[0];
}
/**
* 初始化数据映射
*
* @memberof MDControlBase
*/
public initDataMap() { }
}