centaline-data-driven-v3 0.1.10 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,871 +5,936 @@ import common from '../../utils/common';
5
5
  import request from '../../utils/request';
6
6
 
7
7
  function loadSearchScreenApi(action, callBack, screenPara, prevParam, failCallBack) {
8
- if (action) {
9
- screenPara = screenPara ? screenPara : {};
10
- request.postHandler(common.globalUri(), { "action": action, "para": screenPara }).then(
11
- function (response) {
12
- if (response.rtnCode === Enum.ReturnCode.Successful) {
13
- let data = response.content;
14
- let rtn = loadSearchScreenModel(data, prevParam);
15
- if (callBack) {
16
- callBack(rtn);
17
- }
18
- }
19
- else {
20
- if (failCallBack) {
21
- failCallBack();
22
- }
23
- }
24
- }
25
- );
26
- }
8
+ if (action) {
9
+ screenPara = screenPara ? screenPara : {};
10
+ request.postHandler(common.globalUri(), { "action": action, "para": screenPara }).then(
11
+ function (response) {
12
+ if (response.rtnCode === Enum.ReturnCode.Successful) {
13
+ let data = response.content;
14
+ let rtn = loadSearchScreenModel(data, prevParam);
15
+ if (callBack) {
16
+ callBack(rtn);
17
+ }
18
+ }
19
+ else {
20
+ if (failCallBack) {
21
+ failCallBack();
22
+ }
23
+ }
24
+ }
25
+ );
26
+ }
27
27
  }
28
28
  function loadSearchScreenModel(source, prevParam) {
29
- let rtn = {
30
- formData:{
31
- form: null,
32
- formTable: null,
33
- excuteData: null,//fields
34
- fieldsDic: null,//fieldsDic
35
- source:null,
36
- _excuteListData: undefined,
37
- enableRelationFields(FlagRelation) {
38
- this.form.enableRelationFields = FlagRelation
39
- },
40
- //获取code1
41
- getCode1ByField1(id) {
42
- var rtn1 = this.fieldsDic[id];
43
- if (rtn1) {
44
- return rtn1.code1;
45
- }
46
- },
47
-
48
- //获取code2
49
- getCode2ByField1(id) {
50
- var rtn1 = this.fieldsDic[id];
51
- if (rtn1) {
52
- return rtn1.code2;
53
- }
54
- },
55
- setActionRouter(id, attrKey, attrValue) {
56
- var router = this.form.actionRouters.find((v1) => {
57
- return v1.key === id;
58
- });
59
- if (router) {
60
- router[attrKey] = attrValue;
61
- }
62
- },
63
- //获取Field的属性attrKey的值
64
- getValueByFieldName(id, attrKey) {
65
- attrKey = common.initialsToLowerCase(attrKey);
66
- var rtn1 = this.fieldsDic[id];
67
- if (rtn1) {
68
- return rtn1[attrKey];
69
- }
70
- },
71
- getValueByFieldNameFromParent(id, attrKey) {
72
- if (this.form && this.form.parentModelForm) {
73
- return this.form.parentModelForm.getValueByFieldName(id, attrKey);
74
- }
75
- return null;
76
- },
77
- //设置Field的属性attrKey的值
78
- setValueByFieldName(id, attrKey, attrValue) {
79
- attrKey = common.initialsToLowerCase(attrKey);
80
- var rtn1 = this.fieldsDic[id];
81
- if (rtn1) {
82
- if (attrKey == 'code1' && rtn1.controlType === Enum.ControlType.NumericTextBox
83
- && attrValue != undefined && attrValue != null && attrValue != '') {
84
- if (rtn1.decimals1 != undefined && rtn1.decimals1 != null && rtn1.decimals1 > -1) {
85
- attrValue = Number(attrValue).toFixed(rtn1.decimals1)
86
- }
87
- }
88
- else if (attrKey == 'code1' && (rtn1.controlType === Enum.ControlType.File
89
- || rtn1.controlType === Enum.ControlType.SliceUpload || rtn1.controlType === Enum.ControlType.PhotoSelect)
90
- && attrValue != undefined && attrValue != null && attrValue != '') {
91
- rtn1.jsSetFile(attrValue, rtn1);
92
- }
93
- rtn1[attrKey] = attrValue;
94
- if (rtn1.controlType === Enum.ControlType.Tags) {
95
- rtn1["value"] = JSON.parse(attrValue);
96
- }
97
- if (rtn1.controlType === Enum.ControlType.SearchListBox
98
- || rtn1.controlType === Enum.ControlType.ComboBox
99
- || rtn1.controlType === Enum.ControlType.MultiSelectWithSearch
100
- || rtn1.controlType === Enum.ControlType.MultiSelectNoSearch
101
- ) {
102
- if (rtn1["options"].length == 0) {
103
- rtn1["options"] = [{ value: '', label: '' }];
104
- }
105
- if (attrKey == 'code1') {
106
- rtn1["value"] = attrValue;
107
- rtn1["options"][0]["value"] = attrValue
108
- }
109
- if (attrKey == 'name1') {
110
- rtn1["options"][0]["label"] = attrValue
111
- }
112
- if (rtn1.itemKey) rtn1.itemKey = Math.random()
113
- }
114
- if (rtn1.is == 'ct-button') {
115
- if (common.flagApp() && this.form.$vue.loaded) {
116
- this.form.$vue.loaded(this.form)
117
- }
118
- }
119
- this.source.hiddenHandle(rtn1, this.form);
120
- if(this.source.requiredHandle){
121
- this.source.requiredHandle(rtn1, this.form);
122
- }
123
- }
124
- },
125
- setValueByFieldNameFromParent(id, attrKey, attrValue) {
126
- if (this.form && this.form.parentModelForm) {
127
- return this.form.parentModelForm.setValueByFieldName(id, attrKey, attrValue);
128
- }
129
- return null;
130
- },
131
- //设置Field的v1、v2的值
132
- setV1AndV2ByField1(id, code1, code2) {
133
- var rtn1 = this.fieldsDic[id];
134
- if (rtn1) {
135
- if (typeof rtn1.code1 !== 'undefined') {
136
- rtn1.code1 = code1;
137
- this.source.hiddenHandle(rtn1);//隐藏关联的
138
- }
139
- if (typeof rtn1.code2 !== 'undefined') {
140
- rtn1.code2 = code2;
141
- }
142
- }
143
- },
144
- clearMedia(id) {
145
- var rtn1 = this.fieldsDic[id];
146
- for (let i = 0; i < rtn1.fileSourceList.length; i++) {
147
- rtn1.fileSourceList[i].flagDeleted = true;
148
- }
149
- rtn1.fileList = [];
150
- },
151
- setTabsSelect(id) {
152
- if (this.form && this.form.$vue) {
153
- var f = this.fieldsDic[id];
154
- if (this.form.isHorizontalLayout) {
155
- this.form.$vue.activeName = f.collapseName.toString() === '-1' ? this.form.$vue.activeName : f.collapseName.toString();
156
- }
157
- }
158
- },
159
- //路由提交
160
- submit(fieldName1) {
161
- if (this.form && this.form.$vue) {
162
- this.form.$vue.fieldClickHandler({ fieldName1: fieldName1 });
163
- }
164
- },
165
-
166
- //获取列表数据
167
- get excuteListData() {
168
- if (this._excuteListData) {
169
- return this._excuteListData;
170
- }
171
- else {
172
- if (this.excuteData !== null) {
173
- this._excuteListData = this.excuteData.filter((v) => {
174
- return typeof v.is !== undefined && (v.is === 'ct-formlist' || v.is === 'ct-repeat');
175
- });
176
- }
177
- }
178
- return this._excuteListData;
179
- },
180
- setExcuteListData(fields) {
181
- this._excuteListData = null;
182
- if (fields !== null) {
183
- this.excuteData = fields;
184
- this._excuteListData = fields.filter((v) => {
185
- return typeof v.is !== undefined && (v.is === 'ct-formlist' || v.is === 'ct-repeat');
186
- });
187
- }
188
- },
189
- //获取列表的Field
190
- getListField(tableName, rowNum, fiedlId) {
191
- let listData = this.excuteListData.find((v) => {
192
- return v.name === tableName;
193
- });
194
- if (listData) {
195
- let field = null;
196
- //正在编辑的Field
197
- if (rowNum === null && (fiedlId === null || listData.currentEventField.fieldName1 === fiedlId)) {
198
- field = listData.currentEventField;
199
- }
200
- //正在编辑的行
201
- else if (rowNum === null && listData.currentRowIndex === 0) {
202
- let fields = listData.currentRow.data;
203
- field = fields[fiedlId];
204
- }
205
- //源数据
206
- else {
207
- if (rowNum === null && listData.currentRowIndex) {
208
- rowNum = listData.currentRowIndex;
209
- }
210
-
211
- if (rowNum === 0 || (rowNum && fiedlId)) {
212
- try {
213
- let fields = listData.rows[rowNum].field;
214
- field = fields.find((v) => {
215
- return v.fieldName1 === fiedlId;
216
- });
217
- } catch (e) {
218
- if (listData.rows.length <= rowNum) {
219
- common.message('获取列表行索引超出界限', 'error')
220
- }
221
- }
222
- }
223
- }
224
-
225
- return { listData: listData, field: field };
226
- }
227
- },
228
- //获取列表的行数(注意 这里包括列头)
229
- getListCount(tableName) {
230
- tableName = tableName ? tableName : this.form.scripts.$fd;
231
- let data = this.getListField(tableName, null, null);
232
- if (data) {
233
- return data.listData.rows.length;
234
- }
235
- },
236
- //获取表格某行某列的值
237
- getListFieldValue(tableName, rowNum, fiedlId, attrName, defaultValue) {
238
- tableName = tableName ? tableName : this.form.scripts.$fd;
239
- let data = this.getListField(tableName, rowNum, fiedlId);
240
-
241
- attrName = common.initialsToLowerCase(attrName);
242
- attrName = attrName ? attrName : 'code1';
243
-
244
- if (!fiedlId) {
245
- fiedlId = data.listData.currentEventField.fieldName1;
246
- }
247
- if (fiedlId && rowNum === null && fiedlId === data.listData.currentEventField.fieldName1) {
248
- data.field = data.listData.currentEventField;
249
- }
250
- rowNum = rowNum !== null ? rowNum : data.listData.currentRowIndex;
251
-
252
- //若该行正在编辑,则取编辑状态的。
253
- if (data && data.listData && data.listData.currentRow.data && data.listData.currentRow.data[fiedlId]
254
- && data.listData.currentRow.data.$sourceIndex === rowNum && data.listData.currentRow.isSet) {
255
- return data.listData.currentRow.data[fiedlId][attrName];
256
- }
257
- else if (data && data.field) {
258
- if (typeof defaultValue !== 'undefined' && data.listData.rows[rowNum].deleted) {//若该行被删除时,则直接返回默认值
259
- return defaultValue;
260
- }
261
- return data.field[attrName];
262
- }
263
- },
264
- //设置表格某行某列的值
265
- setListFieldValue(value, tableName, rowNum, fiedlId, attrName, flagTemplate) {
266
- value = value == undefined ? "" : value.toString();
267
- tableName = tableName ? tableName : this.form.scripts.$fd;
268
- let data = this.getListField(tableName, rowNum, fiedlId);
269
-
270
- attrName = common.initialsToLowerCase(attrName);
271
- attrName = attrName ? attrName : 'code1';
272
-
273
- if (!fiedlId) {
274
- fiedlId = data.listData.currentEventField.id;
275
- }
276
-
277
- rowNum = rowNum ? rowNum : data.listData.currentRowIndex;
278
-
279
- if (data) {
280
- //正在编辑的行
281
- if (data.listData.currentRow.data && data.listData.currentRow.data[fiedlId] && rowNum > -1
282
- && data.listData.currentRow.data.$sourceIndex === data.listData.source.rows[rowNum].$sourceIndex) {
283
- let currentField = data.listData.currentRow.data[fiedlId];
284
- currentField[attrName] = value;
285
- //校验自己
286
- if (currentField.validExcute) {
287
- currentField.validExcute();
288
- }
289
- if (data.field) {
290
- data.field[attrName] = value;
291
- }
292
- }
293
- else if (data.field) {
294
- if (data.field) {
295
- data.field[attrName] = value;
296
- }
297
- if (data.field.source) {
298
- data.field.source[attrName] = value;
299
- }
300
- if (flagTemplate) {
301
- data.field[attrName] = value;
302
- }
303
- if (data.listData.flagTemplate && data.listData.$vue) {
304
- data.listData.$vue.itemKey = Math.random()
305
- }
306
- }
307
-
308
- //如果有汇总列,触发重新计算汇总
309
- if (data.listData.showSummary) {
310
- data.listData.tableData.push({});
311
- data.listData.tableData.pop();
312
- }
313
-
314
- return true;
315
- }
316
- return false;
317
- },
318
- //设置表格选择路由
319
- setListSelectRouter(tableId, attrKey, attrValue) {
320
- let listData = this.excuteListData.find((v) => {
321
- return v.fieldName1 === tableId;
322
- });
323
- if (listData) {
324
- var router = listData.selectRouter;
325
- if (router) {
326
- router[attrKey] = attrValue;
327
- }
328
- }
329
- },
330
- //设置表格属性值
331
- setListAttr(tableId, attrName, attrValue) {
332
- let listData = this.excuteListData.find((v) => {
333
- return v.fieldName1 === tableId;
334
- });
335
- if (listData) {
336
- listData[attrName] = attrValue
337
- }
338
- },
339
- //新增表格数据
340
- insertRow(tableId, rows) {
341
- let listData = this.excuteListData.find((v) => {
342
- return v.fieldName1 === tableId;
343
- });
344
- if (listData) {
345
- listData.$vue.insertRow(rows);
346
- }
347
- },
348
- //添加单选表格数据
349
- insertSingleRow(tableId, row) {
350
- let listData = this.excuteListData.find((v) => {
351
- return v.fieldName1 === tableId;
352
- });
353
- if (listData) {
354
- listData.$vue.insertSingleRow(row);
355
- }
356
- },
357
- //新增或替换表格数据
358
- insertOrUpdateRow(tableId, row) {
359
- let listData = this.excuteListData.find((v) => {
360
- return v.fieldName1 === tableId;
361
- });
362
- if (listData) {
363
- listData.$vue.insertOrUpdateRow(row);
364
- }
365
- },
366
- //删除表格数据
367
- deleteRow(tableId, row) {
368
- let listData = this.excuteListData.find((v) => {
369
- return v.id === tableId;
370
- });
371
- if (listData) {
372
- listData.$vue.delRow(row);
373
- }
374
- },
375
- //清空表格数据
376
- clear(tableId) {
377
- let listData = this.excuteListData.find((v) => {
378
- return v.fieldName1 === tableId;
379
- });
380
- if (listData) {
381
- listData.$vue.deleteAll();
382
- }
383
- },
384
-
385
- //获取后台数据,并返回脚本。
386
- execServerScript(action, object, successCallback) {
387
- let formData = this;//作用域保存
388
-
389
- //是否是行内触发的
390
- let data = this.getListField(this.form.scripts.$fd, null, null);
391
- object.editMode = data ? 1 : 0;
392
-
393
- request.postHandler(common.globalUri(), { action: action, para: object }).then(
394
- function (response) {
395
- if (response.rtnCode === Enum.ReturnCode.Successful) {
396
- var data = response.content;
397
- if (response.clientActionType === Enum.ClientActionType.ExcuteScript && data) {
398
- common.excute.call(formData.form.scripts, data);
399
- }
400
- else
401
- if (response.clientActionType === Enum.ClientActionType.None && data && successCallback) {
402
- //因为要传参,并直接执行方法,故successCallback回调里要使用formData的话,要加this
403
- //若不能接受this,也可修改common.excute方法
404
- //successCallback.call(formData.form.scripts, data);
405
-
406
- //优化,不需要加this
407
- common.excuteFun.call(formData.form.scripts, successCallback, data);
408
- }
409
- }
410
- }
411
- );
412
- },
413
- execRouter(routerKey) {
414
- let field = { fieldName1: routerKey };
415
- this.form.$vue.fieldClickHandler(field);
416
- },
417
- //消息提示 type主题:success/warning/info/error。 duration 显示时间, 毫秒。设为 0 则不会自动关闭。 showClose 是否显示关闭按钮。
418
- message(message, type, center, duration, showClose, dangerouslyUseHTMLString) {
419
- common.message(message, type, center, duration, showClose, dangerouslyUseHTMLString)
420
- },
421
- },
422
- get title() {
423
- return source.title;
424
- },
425
- set title(v) {
426
- source.title = v;
427
- },
428
- get flagSearch() {
429
- if (source.flagSearch === true) {
430
- return true
431
- }
432
- return false
433
- },
434
- get parameterAction() {
435
- return source.parameterAction
436
- },
437
- _scripts: null,
438
- get scripts() {
439
- if (rtn._scripts !== null) {
440
- return rtn._scripts;
29
+ let rtn = {
30
+ formData: {
31
+ form: null,
32
+ formTable: null,
33
+ excuteData: null,//fields
34
+ fieldsDic: null,//fieldsDic
35
+ source: null,
36
+ _excuteListData: undefined,
37
+ enableRelationFields(FlagRelation) {
38
+ this.form.enableRelationFields = FlagRelation
39
+ },
40
+ //获取code1
41
+ getCode1ByField1(id) {
42
+ var rtn1 = this.fieldsDic[id];
43
+ if (rtn1) {
44
+ return rtn1.code1;
45
+ }
46
+ },
47
+
48
+ //获取code2
49
+ getCode2ByField1(id) {
50
+ var rtn1 = this.fieldsDic[id];
51
+ if (rtn1) {
52
+ return rtn1.code2;
53
+ }
54
+ },
55
+ setActionRouter(id, attrKey, attrValue) {
56
+ var router = this.form.actionRouters.find((v1) => {
57
+ return v1.key === id;
58
+ });
59
+ if (router) {
60
+ router[attrKey] = attrValue;
61
+ }
62
+ },
63
+ //获取Field的属性attrKey的值
64
+ getValueByFieldName(id, attrKey) {
65
+ attrKey = common.initialsToLowerCase(attrKey);
66
+ var rtn1 = this.fieldsDic[id];
67
+ if (rtn1) {
68
+ return rtn1[attrKey];
69
+ }
70
+ },
71
+ getValueByFieldNameFromParent(id, attrKey) {
72
+ if (this.form && this.form.parentModelForm) {
73
+ return this.form.parentModelForm.getValueByFieldName(id, attrKey);
74
+ }
75
+ return null;
76
+ },
77
+ //设置Field的属性attrKey的值
78
+ setValueByFieldName(id, attrKey, attrValue) {
79
+ attrKey = common.initialsToLowerCase(attrKey);
80
+ var rtn1 = this.fieldsDic[id];
81
+ if (rtn1) {
82
+ if (attrKey == 'code1' && rtn1.controlType === Enum.ControlType.NumericTextBox
83
+ && attrValue != undefined && attrValue != null && attrValue != '') {
84
+ if (rtn1.decimals1 != undefined && rtn1.decimals1 != null && rtn1.decimals1 > -1) {
85
+ attrValue = Number(attrValue).toFixed(rtn1.decimals1)
441
86
  }
442
- else {
443
- if (source.scripts) {
444
- rtn._scripts = base.common.eval(source.scripts);
445
- return rtn._scripts;
446
- }
447
- else {
448
- rtn._scripts = base.common.eval("");
449
- return rtn._scripts;
450
- }
87
+ }
88
+ else if (attrKey == 'code1' && (rtn1.controlType === Enum.ControlType.File
89
+ || rtn1.controlType === Enum.ControlType.SliceUpload || rtn1.controlType === Enum.ControlType.PhotoSelect)
90
+ && attrValue != undefined && attrValue != null && attrValue != '') {
91
+ rtn1.jsSetFile(attrValue, rtn1);
92
+ }
93
+ if (attrKey == 'hidden') {
94
+ rtn1['show'] = !attrValue
95
+ }
96
+ rtn1[attrKey] = attrValue;
97
+ if (rtn1.controlType === Enum.ControlType.Tags) {
98
+ rtn1["value"] = JSON.parse(attrValue);
99
+ }
100
+ if (rtn1.controlType === Enum.ControlType.SearchListBox
101
+ || rtn1.controlType === Enum.ControlType.ComboBox
102
+ || rtn1.controlType === Enum.ControlType.MultiSelectWithSearch
103
+ || rtn1.controlType === Enum.ControlType.MultiSelectNoSearch
104
+ ) {
105
+ if (rtn1["options"].length == 0) {
106
+ rtn1["options"] = [{ value: '', label: '' }];
451
107
  }
452
- },
453
- _screen: null,
454
- _btnScreen: null,
455
- _highScreen: null,
456
- _sourceFieldsArr: null,
457
- get sourceFieldsArr() {//原数据Fields数组
458
- if (this._sourceFieldsArr !== null) {
459
- return this._sourceFieldsArr;
108
+ if (attrKey == 'code1') {
109
+ rtn1["value"] = attrValue;
110
+ rtn1["options"][0]["value"] = attrValue
460
111
  }
461
- this._sourceFieldsArr = [];
462
-
463
- for (let key in source.fields) {
464
- if (source.fields[key].controlType === Enum.ControlType.From) {
465
- continue;
466
- }
467
- if ((source.fields[key].controlType === Enum.ControlType.DateRange
468
- || source.fields[key].controlType === Enum.ControlType.Location
469
- || source.fields[key].controlType === Enum.ControlType.MonthRange
470
- || source.fields[key].controlType === Enum.ControlType.DateTimeRange)
471
- && source.fields[key].code2 == undefined) {
472
- source.fields[key].code2 = '';
473
- }
474
- let field = source.fields[key];
475
- this._sourceFieldsArr.push(field);
112
+ if (attrKey == 'name1') {
113
+ rtn1["options"][0]["label"] = attrValue
476
114
  }
477
- return this._sourceFieldsArr;
478
- },
479
- //表单组件
480
- get screen() {
481
- if (this._screen !== null) {
482
- return this._screen;
115
+ if (rtn1.itemKey) rtn1.itemKey = Math.random()
116
+ }
117
+ if (rtn1.is == 'ct-button') {
118
+ if (common.flagApp() && this.form.$vue.loaded) {
119
+ this.form.$vue.loaded(this.form)
483
120
  }
484
- var rtnscreens = [];
485
- var advIndex = rtn.sourceFieldsArr.findIndex((v) => {
486
- return v.controlType === Enum.ControlType.ButtonSearch;
487
- });
488
- var screens = rtn.sourceFieldsArr.filter((v, i) => {
489
- return (advIndex === -1 || i < advIndex) && v.controlType !== Enum.ControlType.From;
490
- });
121
+ }
122
+ this.source.hiddenHandle(rtn1, this.form);
123
+ this.source.displayHandle(rtn1, this.form);
124
+ if (this.source.requiredHandle) {
125
+ this.source.requiredHandle(rtn1, this.form);
126
+ }
127
+ }
128
+ },
129
+ setValueByFieldNameFromParent(id, attrKey, attrValue) {
130
+ if (this.form && this.form.parentModelForm) {
131
+ return this.form.parentModelForm.setValueByFieldName(id, attrKey, attrValue);
132
+ }
133
+ return null;
134
+ },
135
+ //设置Field的v1、v2的值
136
+ setV1AndV2ByField1(id, code1, code2) {
137
+ var rtn1 = this.fieldsDic[id];
138
+ if (rtn1) {
139
+ if (typeof rtn1.code1 !== 'undefined') {
140
+ rtn1.code1 = code1;
141
+ this.source.hiddenHandle(rtn1, this.form);//隐藏关联的
142
+ this.source.displayHandle(rtn1, this.form);//显示关联的
143
+ }
144
+ if (typeof rtn1.code2 !== 'undefined') {
145
+ rtn1.code2 = code2;
146
+ }
147
+ }
148
+ },
149
+ clearMedia(id) {
150
+ var rtn1 = this.fieldsDic[id];
151
+ for (let i = 0; i < rtn1.fileSourceList.length; i++) {
152
+ rtn1.fileSourceList[i].flagDeleted = true;
153
+ }
154
+ rtn1.fileList = [];
155
+ },
156
+ setTabsSelect(id) {
157
+ if (this.form && this.form.$vue) {
158
+ var f = this.fieldsDic[id];
159
+ if (this.form.isHorizontalLayout) {
160
+ this.form.$vue.activeName = f.collapseName.toString() === '-1' ? this.form.$vue.activeName : f.collapseName.toString();
161
+ }
162
+ }
163
+ },
164
+ //路由提交
165
+ submit(fieldName1) {
166
+ if (this.form && this.form.$vue) {
167
+ this.form.$vue.fieldClickHandler({ fieldName1: fieldName1 });
168
+ }
169
+ },
491
170
 
492
- rtnscreens = this.initScreen(screens);
493
- rtnscreens.forEach((v) => {
494
- try {
495
- if (v.type !== Enum.ControlType.ButtonCommon) {
496
- v.action = 'search';
497
- }
498
- } catch (e) {
499
- }
500
- });
501
- this._screen = rtnscreens;
502
- return rtnscreens;
503
- },
504
- _screenDic: null,//字典,方便取值
505
- get screenDic() {
506
- rtn._screenDic = {};
507
- rtn.screen.forEach((f) => {
508
- rtn._screenDic[f.fieldName1] = f;
509
- });
510
- rtn.highScreen.forEach((f) => {
511
- rtn._screenDic[f.fieldName1] = f;
171
+ //获取列表数据
172
+ get excuteListData() {
173
+ if (this._excuteListData) {
174
+ return this._excuteListData;
175
+ }
176
+ else {
177
+ if (this.excuteData !== null) {
178
+ this._excuteListData = this.excuteData.filter((v) => {
179
+ return typeof v.is !== undefined && (v.is === 'ct-formlist' || v.is === 'ct-repeat');
512
180
  });
513
- return rtn._screenDic;
514
- },
515
- //"搜索"到"高级搜索"的中间的控件
516
- get btnScreen() {
517
- if (this._btnScreen !== null) {
518
- return this._btnScreen;
181
+ }
182
+ }
183
+ return this._excuteListData;
184
+ },
185
+ setExcuteListData(fields) {
186
+ this._excuteListData = null;
187
+ if (fields !== null) {
188
+ this.excuteData = fields;
189
+ this._excuteListData = fields.filter((v) => {
190
+ return typeof v.is !== undefined && (v.is === 'ct-formlist' || v.is === 'ct-repeat');
191
+ });
192
+ }
193
+ },
194
+ //获取列表的Field
195
+ getListField(tableName, rowNum, fiedlId) {
196
+ let listData = this.excuteListData.find((v) => {
197
+ return v.name === tableName;
198
+ });
199
+ if (listData) {
200
+ let field = null;
201
+ //正在编辑的Field
202
+ if (rowNum === null && (fiedlId === null || listData.currentEventField.fieldName1 === fiedlId)) {
203
+ field = listData.currentEventField;
204
+ }
205
+ //正在编辑的行
206
+ else if (rowNum === null && listData.currentRowIndex === 0) {
207
+ let fields = listData.currentRow.data;
208
+ field = fields[fiedlId];
209
+ }
210
+ //源数据
211
+ else {
212
+ if (rowNum === null && listData.currentRowIndex) {
213
+ rowNum = listData.currentRowIndex;
519
214
  }
520
- var rtnscreens = [];
521
- var buttonSearchIndex = rtn.sourceFieldsArr.findIndex((v) => {
522
- return v.controlType === Enum.ControlType.ButtonSearch;
523
- });
524
- var buttonAdvancedSearchIndex = rtn.sourceFieldsArr.findIndex((v) => {
525
- return v.controlType === Enum.ControlType.ButtonAdvancedSearch;
526
- });
527
215
 
528
- if (buttonSearchIndex > -1) {
529
- var screens = rtn.sourceFieldsArr.filter((v, i) => {
530
- return buttonSearchIndex <= i && (buttonAdvancedSearchIndex === -1 || i <= buttonAdvancedSearchIndex) && v.controlType !== Enum.ControlType.From;
216
+ if (rowNum === 0 || (rowNum && fiedlId)) {
217
+ try {
218
+ let fields = listData.rows[rowNum].field;
219
+ field = fields.find((v) => {
220
+ return v.fieldName1 === fiedlId;
531
221
  });
222
+ } catch (e) {
223
+ if (listData.rows.length <= rowNum) {
224
+ common.message('获取列表行索引超出界限', 'error')
225
+ }
226
+ }
227
+ }
228
+ }
229
+
230
+ return { listData: listData, field: field };
231
+ }
232
+ },
233
+ //获取列表的行数(注意 这里包括列头)
234
+ getListCount(tableName) {
235
+ tableName = tableName ? tableName : this.form.scripts.$fd;
236
+ let data = this.getListField(tableName, null, null);
237
+ if (data) {
238
+ return data.listData.rows.length;
239
+ }
240
+ },
241
+ //获取表格某行某列的值
242
+ getListFieldValue(tableName, rowNum, fiedlId, attrName, defaultValue) {
243
+ tableName = tableName ? tableName : this.form.scripts.$fd;
244
+ let data = this.getListField(tableName, rowNum, fiedlId);
245
+
246
+ attrName = common.initialsToLowerCase(attrName);
247
+ attrName = attrName ? attrName : 'code1';
248
+
249
+ if (!fiedlId) {
250
+ fiedlId = data.listData.currentEventField.fieldName1;
251
+ }
252
+ if (fiedlId && rowNum === null && fiedlId === data.listData.currentEventField.fieldName1) {
253
+ data.field = data.listData.currentEventField;
254
+ }
255
+ rowNum = rowNum !== null ? rowNum : data.listData.currentRowIndex;
256
+
257
+ //若该行正在编辑,则取编辑状态的。
258
+ if (data && data.listData && data.listData.currentRow.data && data.listData.currentRow.data[fiedlId]
259
+ && data.listData.currentRow.data.$sourceIndex === rowNum && data.listData.currentRow.isSet) {
260
+ return data.listData.currentRow.data[fiedlId][attrName];
261
+ }
262
+ else if (data && data.field) {
263
+ if (typeof defaultValue !== 'undefined' && data.listData.rows[rowNum].deleted) {//若该行被删除时,则直接返回默认值
264
+ return defaultValue;
265
+ }
266
+ return data.field[attrName];
267
+ }
268
+ },
269
+ //设置表格某行某列的值
270
+ setListFieldValue(value, tableName, rowNum, fiedlId, attrName, flagTemplate) {
271
+ value = value == undefined ? "" : value.toString();
272
+ tableName = tableName ? tableName : this.form.scripts.$fd;
273
+ let data = this.getListField(tableName, rowNum, fiedlId);
274
+
275
+ attrName = common.initialsToLowerCase(attrName);
276
+ attrName = attrName ? attrName : 'code1';
277
+
278
+ if (!fiedlId) {
279
+ fiedlId = data.listData.currentEventField.id;
280
+ }
532
281
 
533
- rtnscreens = this.initScreen(screens);
282
+ rowNum = rowNum ? rowNum : data.listData.currentRowIndex;
283
+
284
+ if (data) {
285
+ //正在编辑的行
286
+ if (data.listData.currentRow.data && data.listData.currentRow.data[fiedlId] && rowNum > -1
287
+ && data.listData.currentRow.data.$sourceIndex === data.listData.source.rows[rowNum].$sourceIndex) {
288
+ let currentField = data.listData.currentRow.data[fiedlId];
289
+ currentField[attrName] = value;
290
+ //校验自己
291
+ if (currentField.validExcute) {
292
+ currentField.validExcute();
534
293
  }
535
- this._btnScreen = rtnscreens;
536
- return rtnscreens;
537
- },
538
- //高级查询组件
539
- get highScreen() {
540
- if (this._highScreen !== null) {
541
- return this._highScreen;
294
+ if (data.field) {
295
+ data.field[attrName] = value;
542
296
  }
543
- var rtnscreens = [];
544
- var advIndex = rtn.sourceFieldsArr.findIndex((v) => {
545
- return v.controlType === Enum.ControlType.ButtonAdvancedSearch;
546
- });
547
- if (advIndex === -1) {
548
- advIndex = rtn.sourceFieldsArr.findIndex((v) => {
549
- return v.controlType === Enum.ControlType.ButtonReset;
550
- });
297
+ }
298
+ else if (data.field) {
299
+ if (data.field) {
300
+ data.field[attrName] = value;
551
301
  }
552
- if (advIndex === -1) {
553
- advIndex = rtn.sourceFieldsArr.findIndex((v) => {
554
- return v.controlType === Enum.ControlType.ButtonSearch;
555
- });
302
+ if (data.field.source) {
303
+ data.field.source[attrName] = value;
556
304
  }
557
- var screens = rtn.sourceFieldsArr.filter((v, i) => {
558
- return (advIndex !== -1 && i > advIndex) && v.controlType !== Enum.ControlType.From;
559
- });
560
- rtnscreens = this.initScreen(screens);
561
- rtnscreens.forEach((v) => {
562
- v.action = 'search';
563
- });
564
- this._highScreen = rtnscreens;
565
- return rtnscreens;
566
- },
567
- initScreen(screens) {
568
- var rtnscreens = [];
305
+ if (flagTemplate) {
306
+ data.field[attrName] = value;
307
+ }
308
+ if (data.listData.flagTemplate && data.listData.$vue) {
309
+ data.listData.$vue.itemKey = Math.random()
310
+ }
311
+ }
569
312
 
570
- screens.forEach((value) => {
571
- let item = LibFunction.GetControl(value, source, true, true);
313
+ //如果有汇总列,触发重新计算汇总
314
+ if (data.listData.showSummary) {
315
+ data.listData.tableData.push({});
316
+ data.listData.tableData.pop();
317
+ }
572
318
 
573
- if (item instanceof Object) {
574
- if (prevParam && typeof item.id !== 'undefined' && rtn.prevParams.includes(item.id) && prevParam[item.id]) {
575
- if (prevParam[item.id].code1) {
576
- item.code1 = prevParam[item.id].code1;
577
- }
578
- if (prevParam[item.id].code2) {
579
- item.code2 = prevParam[item.id].code2;
580
- }
581
- if (prevParam[item.id].name1) {
582
- item.name1 = prevParam[item.id].name1;
583
- }
584
- }
585
- item.form = rtn;
586
- hiddenHandle(item, rtn);//是否隐藏关联组件
587
- rtnscreens.push(item);
319
+ return true;
320
+ }
321
+ return false;
322
+ },
323
+ //设置表格选择路由
324
+ setListSelectRouter(tableId, attrKey, attrValue) {
325
+ let listData = this.excuteListData.find((v) => {
326
+ return v.fieldName1 === tableId;
327
+ });
328
+ if (listData) {
329
+ var router = listData.selectRouter;
330
+ if (router) {
331
+ router[attrKey] = attrValue;
332
+ }
333
+ }
334
+ },
335
+ //设置表格属性值
336
+ setListAttr(tableId, attrName, attrValue) {
337
+ let listData = this.excuteListData.find((v) => {
338
+ return v.fieldName1 === tableId;
339
+ });
340
+ if (listData) {
341
+ listData[attrName] = attrValue
342
+ }
343
+ },
344
+ //新增表格数据
345
+ insertRow(tableId, rows) {
346
+ let listData = this.excuteListData.find((v) => {
347
+ return v.fieldName1 === tableId;
348
+ });
349
+ if (listData) {
350
+ listData.$vue.insertRow(rows);
351
+ }
352
+ },
353
+ //添加单选表格数据
354
+ insertSingleRow(tableId, row) {
355
+ let listData = this.excuteListData.find((v) => {
356
+ return v.fieldName1 === tableId;
357
+ });
358
+ if (listData) {
359
+ listData.$vue.insertSingleRow(row);
360
+ }
361
+ },
362
+ //新增或替换表格数据
363
+ insertOrUpdateRow(tableId, row) {
364
+ let listData = this.excuteListData.find((v) => {
365
+ return v.fieldName1 === tableId;
366
+ });
367
+ if (listData) {
368
+ listData.$vue.insertOrUpdateRow(row);
369
+ }
370
+ },
371
+ //删除表格数据
372
+ deleteRow(tableId, row) {
373
+ let listData = this.excuteListData.find((v) => {
374
+ return v.id === tableId;
375
+ });
376
+ if (listData) {
377
+ listData.$vue.delRow(row);
378
+ }
379
+ },
380
+ //清空表格数据
381
+ clear(tableId) {
382
+ let listData = this.excuteListData.find((v) => {
383
+ return v.fieldName1 === tableId;
384
+ });
385
+ if (listData) {
386
+ listData.$vue.deleteAll();
387
+ }
388
+ },
389
+
390
+ //获取后台数据,并返回脚本。
391
+ execServerScript(action, object, successCallback) {
392
+ let formData = this;//作用域保存
393
+
394
+ //是否是行内触发的
395
+ let data = this.getListField(this.form.scripts.$fd, null, null);
396
+ object.editMode = data ? 1 : 0;
397
+
398
+ request.postHandler(common.globalUri(), { action: action, para: object }).then(
399
+ function (response) {
400
+ if (response.rtnCode === Enum.ReturnCode.Successful) {
401
+ var data = response.content;
402
+ if (response.clientActionType === Enum.ClientActionType.ExcuteScript && data) {
403
+ common.excute.call(formData.form.scripts, data);
404
+ }
405
+ else
406
+ if (response.clientActionType === Enum.ClientActionType.None && data && successCallback) {
407
+ //因为要传参,并直接执行方法,故successCallback回调里要使用formData的话,要加this
408
+ //若不能接受this,也可修改common.excute方法
409
+ //successCallback.call(formData.form.scripts, data);
410
+
411
+ //优化,不需要加this
412
+ common.excuteFun.call(formData.form.scripts, successCallback, data);
588
413
  }
589
- });
590
- return rtnscreens;
591
- },
592
- get shortcutForm() {
593
- var screens = source.fields.filter((v, i) => {
594
- return v.controlType === Enum.ControlType.From;
595
- });
596
- if (screens && screens.length > 0) {
597
- return screens[0];
598
414
  }
599
- return null;
600
- },
601
- reset() {
602
- this.screen.forEach((v) => {
603
- v.reset();
604
- });
605
- this.highScreen.forEach((v) => {
606
- v.reset();
607
- });
608
- },
609
- //获取搜索条件数据
610
- get searchData() {
611
- let rtn = {
612
- fields: []
613
- };
614
- this.screen.forEach((v) => {
615
- var tempObj = common.deepClone(v.searchObj);
616
- if ((tempObj.searchValue1 && tempObj.searchValue1 !== '') || (tempObj.searchValue2 && tempObj.searchValue2 !== '')) {
617
- if (isHandle(v.controlType)) {
618
- tempObj.searchValue1 = getNewSearchValue(tempObj);
619
- }
620
- rtn.fields.push(tempObj);
621
- }
622
- });
623
- this.highScreen.forEach((v) => {
624
- var tempObj = common.deepClone(v.searchObj);
625
- if ((tempObj.searchValue1 && tempObj.searchValue1 !== '') || (tempObj.searchValue2 && tempObj.searchValue2 !== '')) {
626
- if (isHandle(v.controlType)) {
627
- tempObj.searchValue1 = getNewSearchValue(tempObj);
628
- }
629
- rtn.fields.push(tempObj);
630
- }
631
- });
632
- return rtn;
633
- },
634
- get searchDataOfHide() {
635
- let rtn = {
636
- fields: []
637
- };
638
- this.screen.forEach((v) => {
639
- if (v.controlType === Enum.ControlType.Hidden) {
640
- var tempObj = common.deepClone(v.searchObj);
641
- if ((tempObj.searchValue1 && tempObj.searchValue1 !== '') || (tempObj.searchValue2 && tempObj.searchValue2 !== '')) {
642
- if (isHandle(v.controlType)) {
643
- tempObj.searchValue1 = getNewSearchValue(tempObj);
644
- }
645
- rtn.fields.push(tempObj);
646
- }
647
- }
648
- });
649
- this.highScreen.forEach((v) => {
650
- if (v.controlType === Enum.ControlType.Hidden) {
651
- var tempObj = common.deepClone(v.searchObj);
652
- if ((tempObj.searchValue1 && tempObj.searchValue1 !== '') || (tempObj.searchValue2 && tempObj.searchValue2 !== '')) {
653
- if (isHandle(v.controlType)) {
654
- tempObj.searchValue1 = getNewSearchValue(tempObj);
655
- }
656
- rtn.fields.push(tempObj);
657
- }
658
- }
659
- });
660
- return rtn;
661
- },
662
- //绑定联动参数组件
663
- getRefFieldPara(refFieldNameArr) {
664
- let submitData = {};
665
- var tempFormData = rtn.searchData;
666
- refFieldNameArr.forEach((v) => {
667
- tempFormData.fields.forEach((n) => {
668
- if (n.fieldName1 == v) submitData[v] = n.searchValue1;
669
- });
670
- });
671
- return submitData;
672
- },
673
- getParentFieldPara(parentFieldNameArr) {
674
- let submitData = {};
675
- var tempFormData = rtn.searchData;
676
- parentFieldNameArr.forEach((v) => {
677
- tempFormData.fields.forEach((n) => {
678
- if (n.fieldName1 == v) {
679
- let vs = v.split('.');
680
- submitData[vs[vs.length - 1]] = n.searchValue1;
681
- }
682
- });
683
- });
684
- if (JSON.stringify(submitData) == "{}") {
685
- return '';
415
+ }
416
+ );
417
+ },
418
+ execRouter(routerKey) {
419
+ let field = { fieldName1: routerKey };
420
+ this.form.$vue.fieldClickHandler(field);
421
+ },
422
+ //消息提示 type主题:success/warning/info/error。 duration 显示时间, 毫秒。设为 0 则不会自动关闭。 showClose 是否显示关闭按钮。
423
+ message(message, type, center, duration, showClose, dangerouslyUseHTMLString) {
424
+ common.message(message, type, center, duration, showClose, dangerouslyUseHTMLString)
425
+ },
426
+ },
427
+ get title() {
428
+ return source.title;
429
+ },
430
+ set title(v) {
431
+ source.title = v;
432
+ },
433
+ get flagSearch() {
434
+ if (source.flagSearch === true) {
435
+ return true
436
+ }
437
+ return false
438
+ },
439
+ get parameterAction() {
440
+ return source.parameterAction
441
+ },
442
+ _scripts: null,
443
+ get scripts() {
444
+ if (rtn._scripts !== null) {
445
+ return rtn._scripts;
446
+ }
447
+ else {
448
+ if (source.scripts) {
449
+ rtn._scripts = base.common.eval(source.scripts);
450
+ return rtn._scripts;
451
+ }
452
+ else {
453
+ rtn._scripts = base.common.eval("");
454
+ return rtn._scripts;
455
+ }
456
+ }
457
+ },
458
+ _screen: null,
459
+ _btnScreen: null,
460
+ _highScreen: null,
461
+ _sourceFieldsArr: null,
462
+ get sourceFieldsArr() {//原数据Fields数组
463
+ if (this._sourceFieldsArr !== null) {
464
+ return this._sourceFieldsArr;
465
+ }
466
+ this._sourceFieldsArr = [];
467
+
468
+ for (let key in source.fields) {
469
+ if (source.fields[key].controlType === Enum.ControlType.From) {
470
+ continue;
471
+ }
472
+ if ((source.fields[key].controlType === Enum.ControlType.DateRange
473
+ || source.fields[key].controlType === Enum.ControlType.Location
474
+ || source.fields[key].controlType === Enum.ControlType.MonthRange
475
+ || source.fields[key].controlType === Enum.ControlType.DateTimeRange)
476
+ && source.fields[key].code2 == undefined) {
477
+ source.fields[key].code2 = '';
478
+ }
479
+ let field = source.fields[key];
480
+ this._sourceFieldsArr.push(field);
481
+ }
482
+ return this._sourceFieldsArr;
483
+ },
484
+ //表单组件
485
+ get screen() {
486
+ if (this._screen !== null) {
487
+ return this._screen;
488
+ }
489
+ var rtnscreens = [];
490
+ var advIndex = rtn.sourceFieldsArr.findIndex((v) => {
491
+ return v.controlType === Enum.ControlType.ButtonSearch;
492
+ });
493
+ var screens = rtn.sourceFieldsArr.filter((v, i) => {
494
+ return (advIndex === -1 || i < advIndex) && v.controlType !== Enum.ControlType.From;
495
+ });
496
+
497
+ rtnscreens = this.initScreen(screens);
498
+ rtnscreens.forEach((v) => {
499
+ try {
500
+ if (v.type !== Enum.ControlType.ButtonCommon) {
501
+ v.action = 'search';
502
+ }
503
+ } catch (e) {
504
+ }
505
+ });
506
+ this._screen = rtnscreens;
507
+ return rtnscreens;
508
+ },
509
+ _screenDic: null,//字典,方便取值
510
+ get screenDic() {
511
+ rtn._screenDic = {};
512
+ rtn.screen.forEach((f) => {
513
+ rtn._screenDic[f.fieldName1] = f;
514
+ });
515
+ rtn.highScreen.forEach((f) => {
516
+ rtn._screenDic[f.fieldName1] = f;
517
+ });
518
+ return rtn._screenDic;
519
+ },
520
+ //"搜索"到"高级搜索"的中间的控件
521
+ get btnScreen() {
522
+ if (this._btnScreen !== null) {
523
+ return this._btnScreen;
524
+ }
525
+ var rtnscreens = [];
526
+ var buttonSearchIndex = rtn.sourceFieldsArr.findIndex((v) => {
527
+ return v.controlType === Enum.ControlType.ButtonSearch;
528
+ });
529
+ var buttonAdvancedSearchIndex = rtn.sourceFieldsArr.findIndex((v) => {
530
+ return v.controlType === Enum.ControlType.ButtonAdvancedSearch;
531
+ });
532
+
533
+ if (buttonSearchIndex > -1) {
534
+ var screens = rtn.sourceFieldsArr.filter((v, i) => {
535
+ return buttonSearchIndex <= i && (buttonAdvancedSearchIndex === -1 || i <= buttonAdvancedSearchIndex) && v.controlType !== Enum.ControlType.From;
536
+ });
537
+
538
+ rtnscreens = this.initScreen(screens);
539
+ }
540
+ this._btnScreen = rtnscreens;
541
+ return rtnscreens;
542
+ },
543
+ //高级查询组件
544
+ get highScreen() {
545
+ if (this._highScreen !== null) {
546
+ return this._highScreen;
547
+ }
548
+ var rtnscreens = [];
549
+ var advIndex = rtn.sourceFieldsArr.findIndex((v) => {
550
+ return v.controlType === Enum.ControlType.ButtonAdvancedSearch;
551
+ });
552
+ if (advIndex === -1) {
553
+ advIndex = rtn.sourceFieldsArr.findIndex((v) => {
554
+ return v.controlType === Enum.ControlType.ButtonReset;
555
+ });
556
+ }
557
+ if (advIndex === -1) {
558
+ advIndex = rtn.sourceFieldsArr.findIndex((v) => {
559
+ return v.controlType === Enum.ControlType.ButtonSearch;
560
+ });
561
+ }
562
+ var screens = rtn.sourceFieldsArr.filter((v, i) => {
563
+ return (advIndex !== -1 && i > advIndex) && v.controlType !== Enum.ControlType.From;
564
+ });
565
+ rtnscreens = this.initScreen(screens);
566
+ rtnscreens.forEach((v) => {
567
+ v.action = 'search';
568
+ });
569
+ this._highScreen = rtnscreens;
570
+ return rtnscreens;
571
+ },
572
+ initScreen(screens) {
573
+ var rtnscreens = [];
574
+
575
+ screens.forEach((value) => {
576
+ let item = LibFunction.GetControl(value, source, true, true);
577
+
578
+ if (item instanceof Object) {
579
+ if (prevParam && typeof item.id !== 'undefined' && rtn.prevParams.includes(item.id) && prevParam[item.id]) {
580
+ if (prevParam[item.id].code1) {
581
+ item.code1 = prevParam[item.id].code1;
686
582
  }
687
- else {
688
- if (parentFieldNameArr.length > 1) {
689
- return JSON.stringify(submitData);
690
- }
691
- else {
692
- let parentNameArr = parentFieldNameArr[0].split('.');
693
- return submitData[parentNameArr[parentNameArr.length - 1]];
694
- }
583
+ if (prevParam[item.id].code2) {
584
+ item.code2 = prevParam[item.id].code2;
585
+ }
586
+ if (prevParam[item.id].name1) {
587
+ item.name1 = prevParam[item.id].name1;
588
+ }
589
+ }
590
+ item.form = rtn;
591
+ hiddenHandle(item, rtn);//是否隐藏关联组件
592
+ displayHandle(item, rtn);//是否显示关联组件
593
+ rtnscreens.push(item);
594
+ }
595
+ });
596
+ return rtnscreens;
597
+ },
598
+ get shortcutForm() {
599
+ var screens = source.fields.filter((v, i) => {
600
+ return v.controlType === Enum.ControlType.From;
601
+ });
602
+ if (screens && screens.length > 0) {
603
+ return screens[0];
604
+ }
605
+ return null;
606
+ },
607
+ reset() {
608
+ this.screen.forEach((v) => {
609
+ v.reset();
610
+ });
611
+ this.highScreen.forEach((v) => {
612
+ v.reset();
613
+ });
614
+ },
615
+ //获取搜索条件数据
616
+ get searchData() {
617
+ let rtn = {
618
+ fields: []
619
+ };
620
+ this.screen.forEach((v) => {
621
+ var tempObj = common.deepClone(v.searchObj);
622
+ if ((tempObj.searchValue1 && tempObj.searchValue1 !== '') || (tempObj.searchValue2 && tempObj.searchValue2 !== '')) {
623
+ if (isHandle(v.controlType)) {
624
+ tempObj.searchValue1 = getNewSearchValue(tempObj);
625
+ }
626
+ rtn.fields.push(tempObj);
627
+ }
628
+ });
629
+ this.highScreen.forEach((v) => {
630
+ var tempObj = common.deepClone(v.searchObj);
631
+ if ((tempObj.searchValue1 && tempObj.searchValue1 !== '') || (tempObj.searchValue2 && tempObj.searchValue2 !== '')) {
632
+ if (isHandle(v.controlType)) {
633
+ tempObj.searchValue1 = getNewSearchValue(tempObj);
634
+ }
635
+ rtn.fields.push(tempObj);
636
+ }
637
+ });
638
+ return rtn;
639
+ },
640
+ get searchDataOfHide() {
641
+ let rtn = {
642
+ fields: []
643
+ };
644
+ this.screen.forEach((v) => {
645
+ if (v.controlType === Enum.ControlType.Hidden) {
646
+ var tempObj = common.deepClone(v.searchObj);
647
+ if ((tempObj.searchValue1 && tempObj.searchValue1 !== '') || (tempObj.searchValue2 && tempObj.searchValue2 !== '')) {
648
+ if (isHandle(v.controlType)) {
649
+ tempObj.searchValue1 = getNewSearchValue(tempObj);
650
+ }
651
+ rtn.fields.push(tempObj);
652
+ }
653
+ }
654
+ });
655
+ this.highScreen.forEach((v) => {
656
+ if (v.controlType === Enum.ControlType.Hidden) {
657
+ var tempObj = common.deepClone(v.searchObj);
658
+ if ((tempObj.searchValue1 && tempObj.searchValue1 !== '') || (tempObj.searchValue2 && tempObj.searchValue2 !== '')) {
659
+ if (isHandle(v.controlType)) {
660
+ tempObj.searchValue1 = getNewSearchValue(tempObj);
695
661
  }
696
- },
662
+ rtn.fields.push(tempObj);
663
+ }
664
+ }
665
+ });
666
+ return rtn;
667
+ },
668
+ //绑定联动参数组件
669
+ getRefFieldPara(refFieldNameArr) {
670
+ let submitData = {};
671
+ var tempFormData = rtn.searchData;
672
+ refFieldNameArr.forEach((v) => {
673
+ tempFormData.fields.forEach((n) => {
674
+ if (n.fieldName1 == v) submitData[v] = n.searchValue1;
675
+ });
676
+ });
677
+ return submitData;
678
+ },
679
+ getParentFieldPara(parentFieldNameArr) {
680
+ let submitData = {};
681
+ var tempFormData = rtn.searchData;
682
+ parentFieldNameArr.forEach((v) => {
683
+ tempFormData.fields.forEach((n) => {
684
+ if (n.fieldName1 == v) {
685
+ let vs = v.split('.');
686
+ submitData[vs[vs.length - 1]] = n.searchValue1;
687
+ }
688
+ });
689
+ });
690
+ if (JSON.stringify(submitData) == "{}") {
691
+ return '';
692
+ }
693
+ else {
694
+ if (parentFieldNameArr.length > 1) {
695
+ return JSON.stringify(submitData);
696
+ }
697
+ else {
698
+ let parentNameArr = parentFieldNameArr[0].split('.');
699
+ return submitData[parentNameArr[parentNameArr.length - 1]];
700
+ }
701
+ }
702
+ },
697
703
 
698
- };
699
- return rtn
704
+ };
705
+ return rtn
700
706
 
701
707
  }
702
708
  function getNewSearchValue(tempObj) {
703
- let codeList = JSON.parse(tempObj.searchValue1);
704
- let dataType = getDataType(tempObj.searchDataType);
705
- let code = '';
706
- let symbol = ',';
707
- if (dataType == Enum.SearchDataType.None) {
708
- codeList.forEach((v) => {
709
- if (!v.flagDeleted && v.code) {
710
- code += `'${v.code}'${symbol}`;
711
- }
712
- });
713
- }
714
- else {
715
- codeList.forEach((v) => {
716
- if (!v.flagDeleted && v.code) {
717
- code += `${v.code}${symbol}`;
718
- }
719
- });
720
- }
709
+ let codeList = JSON.parse(tempObj.searchValue1);
710
+ let dataType = getDataType(tempObj.searchDataType);
711
+ let code = '';
712
+ let symbol = ',';
713
+ if (dataType == Enum.SearchDataType.None) {
714
+ codeList.forEach((v) => {
715
+ if (!v.flagDeleted && v.code) {
716
+ code += `'${v.code}'${symbol}`;
717
+ }
718
+ });
719
+ }
720
+ else {
721
+ codeList.forEach((v) => {
722
+ if (!v.flagDeleted && v.code) {
723
+ code += `${v.code}${symbol}`;
724
+ }
725
+ });
726
+ }
721
727
 
722
- if (code.endsWith(`${symbol}`)) {
723
- code = code.substring(0, code.length - 1);
724
- }
725
- return code;
728
+ if (code.endsWith(`${symbol}`)) {
729
+ code = code.substring(0, code.length - 1);
730
+ }
731
+ return code;
726
732
  }
727
733
  //判断控件是否需要单独处理searchValue1
728
734
  function isHandle(type) {
729
- let result = false;
730
- switch (type) {
731
- case Enum.ControlType.CheckBoxList://复选列表
732
- case Enum.ControlType.MultiSelectNoSearch:
733
- case Enum.ControlType.MultiSelectWithSearch:
734
- result = true;
735
- break;
736
- default:
737
- result = false;
738
- break;
739
- }
740
- return result;
735
+ let result = false;
736
+ switch (type) {
737
+ case Enum.ControlType.CheckBoxList://复选列表
738
+ case Enum.ControlType.MultiSelectNoSearch:
739
+ case Enum.ControlType.MultiSelectWithSearch:
740
+ result = true;
741
+ break;
742
+ default:
743
+ result = false;
744
+ break;
745
+ }
746
+ return result;
741
747
  }
742
748
  //判断数据类型 1 是字符串 2是数字
743
749
  function getDataType(searchDataType) {
744
- let dataType = Enum.SearchDataType.None;
745
- switch (searchDataType) {
746
- case Enum.SearchDataType.Number:
747
- case Enum.SearchDataType.Money:
748
- dataType = Enum.SearchDataType.Number;
749
- break;
750
- }
751
- return dataType;
750
+ let dataType = Enum.SearchDataType.None;
751
+ switch (searchDataType) {
752
+ case Enum.SearchDataType.Number:
753
+ case Enum.SearchDataType.Money:
754
+ dataType = Enum.SearchDataType.Number;
755
+ break;
756
+ }
757
+ return dataType;
752
758
  }
753
759
  //隐藏关联组件
754
760
  function hiddenHandle(item, model) {
755
- if (item.fieldName1) {
756
- let field = null;
757
- if (model.sourceFieldsArr) {
758
- for (var i in model.sourceFieldsArr) {
759
- if (model.sourceFieldsArr[i].hiddenRelationField === item.fieldName1) {
760
- field = model.sourceFieldsArr[i];
761
- if (field) {
762
- let hiddenValueArr = field.hiddenRelationFieldValue.split(',');
763
- if (hiddenValueArr.indexOf(item.code1) > -1) {
764
- field.show = false;
765
- }
766
- else {
767
- field.show = true;
768
- }
769
- }
770
- }
761
+ if (item.fieldName1) {
762
+ let field = null;
763
+ if (model.sourceFieldsArr) {
764
+ for (var i in model.sourceFieldsArr) {
765
+ if (model.sourceFieldsArr[i].hiddenRelationField === item.fieldName1) {
766
+ field = model.sourceFieldsArr[i];
767
+ if (field) {
768
+ let hiddenValueArr = field.hiddenRelationFieldValue.split(',');
769
+ if (hiddenValueArr.indexOf(item.code1) > -1) {
770
+ field.show = false;
771
771
  }
772
+ else {
773
+ field.show = true;
774
+ }
775
+ }
772
776
  }
773
- if (model._screen) {
774
- for (var i in model._screen) {
775
- if (model._screen[i].hiddenRelationField === item.fieldName1) {
776
- field = model._screen[i];
777
- if (field) {
778
- let hiddenValueArr = field.hiddenRelationFieldValue.split(',');
779
- if (hiddenValueArr.indexOf(item.code1) > -1) {
780
- field.show = false;
781
- }
782
- else {
783
- field.show = true;
784
- }
785
- field.keyScreen = field.fieldName1 + Math.random();
786
- }
787
- }
777
+ }
778
+ }
779
+ if (model._screen) {
780
+ for (var i in model._screen) {
781
+ if (model._screen[i].hiddenRelationField === item.fieldName1) {
782
+ field = model._screen[i];
783
+ if (field) {
784
+ let hiddenValueArr = field.hiddenRelationFieldValue.split(',');
785
+ if (hiddenValueArr.indexOf(item.code1) > -1) {
786
+ field.show = false;
787
+ }
788
+ else {
789
+ field.show = true;
788
790
  }
791
+ field.keyScreen = field.fieldName1 + Math.random();
792
+ }
789
793
  }
794
+ }
795
+ }
790
796
 
791
- if (model._highScreen) {
792
- for (var i in model._highScreen) {
793
- if (model._highScreen[i].hiddenRelationField === item.fieldName1) {
794
- field = model._highScreen[i];
795
- if (field) {
796
- let hiddenValueArr = field.hiddenRelationFieldValue.split(',');
797
- if (hiddenValueArr.indexOf(item.code1) > -1) {
798
- field.show = false;
799
- }
800
- else {
801
- field.show = true;
802
- }
803
- field.keyScreen = field.fieldName1 + Math.random();
804
- }
805
- }
797
+ if (model._highScreen) {
798
+ for (var i in model._highScreen) {
799
+ if (model._highScreen[i].hiddenRelationField === item.fieldName1) {
800
+ field = model._highScreen[i];
801
+ if (field) {
802
+ let hiddenValueArr = field.hiddenRelationFieldValue.split(',');
803
+ if (hiddenValueArr.indexOf(item.code1) > -1) {
804
+ field.show = false;
806
805
  }
806
+ else {
807
+ field.show = true;
808
+ }
809
+ field.keyScreen = field.fieldName1 + Math.random();
810
+ }
807
811
  }
812
+ }
808
813
  }
814
+ }
809
815
  }
810
- function getAction(api, callback) {
811
- request.postHandler(common.globalUri(), {
812
- action: api
813
- })
814
- .then(function (response) {
815
- if (response.rtnCode === Enum.ReturnCode.Successful) {
816
- if (typeof callback !== 'undefined') {
817
- callback(response.content);
818
- }
816
+ //显示关联组件
817
+ function displayHandle(item, model) {
818
+ if (item.fieldName1) {
819
+ let field = null;
820
+ if (model.sourceFieldsArr) {
821
+ for (var i in model.sourceFieldsArr) {
822
+ if (model.sourceFieldsArr[i].displayRelationField === item.fieldName1) {
823
+ field = model.sourceFieldsArr[i];
824
+ if (field) {
825
+ let displayValueArr = field.displayRelationFieldValue.split(',');
826
+ if (displayValueArr.indexOf(item.code1) > -1) {
827
+ field.show = true;
819
828
  }
820
- })
821
- .catch((error) => {
822
- if (typeof callback !== 'undefined') {
823
- callback();
829
+ else {
830
+ field.show = false;
824
831
  }
825
- });
826
- }
827
- function changeHandler(field, model){
828
- hiddenHandle(field, model);
829
- clearRelatedHandle(field, model.screen)
830
- if (field.onChanged) {
831
- if (model.scripts) {
832
- model.scripts.formData.setExcuteListData(model.screen);
833
- }
834
- model.scripts.$fd = field.id;
835
- common.excute.call(model.scripts, field.onChanged);
832
+ }
833
+ }
836
834
  }
837
- if (field.onAfterChanged && field.controlType !== Enum.ControlType.NumericTextBox) {
838
- var router = model.actionRouters.find((v) => {
839
- return v.key === field.onAfterChanged;
840
- });
841
- if (router) {
842
- model.$vue.clickHandler(router);
835
+ }
836
+ if (model._screen) {
837
+ for (var i in model._screen) {
838
+ if (model._screen[i].displayRelationField === item.fieldName1) {
839
+ field = model._screen[i];
840
+ if (field) {
841
+ let displayValueArr = field.displayRelationFieldValue.split(',');
842
+ if (displayValueArr.indexOf(item.code1) > -1) {
843
+ field.show = true;
844
+ }
845
+ else {
846
+ field.show = false;
847
+ }
848
+ field.keyScreen = field.fieldName1 + Math.random();
849
+ }
843
850
  }
844
- else {
845
- if (model.scripts) {
846
- model.scripts.formData.setExcuteListData(model.fields);
851
+ }
852
+ }
853
+
854
+ if (model._highScreen) {
855
+ for (var i in model._highScreen) {
856
+ if (model._highScreen[i].displayRelationField === item.fieldName1) {
857
+ field = model._highScreen[i];
858
+ if (field) {
859
+ let displayValueArr = field.displayRelationFieldValue.split(',');
860
+ if (displayValueArr.indexOf(item.code1) > -1) {
861
+ field.show = true;
862
+ }
863
+ else {
864
+ field.show = false;
865
+ }
866
+ field.keyScreen = field.fieldName1 + Math.random();
847
867
  }
848
- model.scripts.$fd = field.id;
849
- common.excute.call(model.scripts, field.onAfterChanged);
850
868
  }
851
869
  }
870
+ }
871
+ }
852
872
  }
853
- //清除关联当前组件的组件值
854
- function clearRelatedHandle(field, fields) {
855
- var f = fields.filter((v) => {
856
- return v.parentField && field.fieldName1 && (',' + v.parentField + ',').indexOf(',' + field.fieldName1 + ',') > -1;
857
- });
858
- f.forEach((v) => {
859
- if (v.reset) {
860
- v.reset();
873
+ function getAction(api, callback) {
874
+ request.postHandler(common.globalUri(), {
875
+ action: api
876
+ })
877
+ .then(function (response) {
878
+ if (response.rtnCode === Enum.ReturnCode.Successful) {
879
+ if (typeof callback !== 'undefined') {
880
+ callback(response.content);
881
+ }
882
+ }
883
+ })
884
+ .catch((error) => {
885
+ if (typeof callback !== 'undefined') {
886
+ callback();
861
887
  }
862
- clearRelatedHandle(v, fields)
863
888
  });
889
+ }
890
+ function changeHandler(field, model) {
891
+ hiddenHandle(field, model);
892
+ displayHandle(field, model);
893
+ clearRelatedHandle(field, model.screen)
894
+ if (field.onChanged) {
895
+ if (model.scripts) {
896
+ model.scripts.formData.setExcuteListData(model.screen);
897
+ }
898
+ model.scripts.$fd = field.id;
899
+ common.excute.call(model.scripts, field.onChanged);
900
+ }
901
+ if (field.onAfterChanged && field.controlType !== Enum.ControlType.NumericTextBox) {
902
+ var router = model.actionRouters.find((v) => {
903
+ return v.key === field.onAfterChanged;
904
+ });
905
+ if (router) {
906
+ model.$vue.clickHandler(router);
907
+ }
908
+ else {
909
+ if (model.scripts) {
910
+ model.scripts.formData.setExcuteListData(model.fields);
911
+ }
912
+ model.scripts.$fd = field.id;
913
+ common.excute.call(model.scripts, field.onAfterChanged);
914
+ }
864
915
  }
916
+ }
917
+ //清除关联当前组件的组件值
918
+ function clearRelatedHandle(field, fields) {
919
+ var f = fields.filter((v) => {
920
+ return v.parentField && field.fieldName1 && (',' + v.parentField + ',').indexOf(',' + field.fieldName1 + ',') > -1;
921
+ });
922
+ f.forEach((v) => {
923
+ if (v.reset) {
924
+ v.reset();
925
+ }
926
+ clearRelatedHandle(v, fields)
927
+ });
928
+ }
865
929
  const SearchScreen = {
866
- loadSearchScreenApi,
867
- loadSearchScreenModel,
868
- hiddenHandle,
869
- isHandle,
870
- getNewSearchValue,
871
- getAction,
872
- changeHandler,
873
- clearRelatedHandle
930
+ loadSearchScreenApi,
931
+ loadSearchScreenModel,
932
+ hiddenHandle,
933
+ displayHandle,
934
+ isHandle,
935
+ getNewSearchValue,
936
+ getAction,
937
+ changeHandler,
938
+ clearRelatedHandle
874
939
  };
875
940
  export default SearchScreen;