cloud-web-corejs 1.0.54-dev.134 → 1.0.54-dev.136

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.
@@ -1,1041 +1,1171 @@
1
- import {
2
- deepClone,
3
- translateOptionItems,
4
- getDSByName,
5
- overwriteObj,
6
- runDataSourceRequest,
7
- getReportGlobalMap,
8
- getAccessUrl
9
- } from "../../../../../components/xform/utils/util"
10
- import FormValidators from '../../../../../components/xform/utils/validators'
11
- import scriptHttpMixin from "../../../../../components/xform/mixins/scriptHttp";
12
- import defaultHandleMixin from "../../../../../components/xform/mixins/defaultHandle";
13
-
14
- let modules = {};
15
- const baseRefUtil = {
16
- deepClone,
17
- translateOptionItems,
18
- getDSByName,
19
- overwriteObj,
20
- runDataSourceRequest,
21
- FormValidators,
22
- getReportGlobalMap,
23
- getAccessUrl
24
- };
25
- modules = {
26
- mixins: [scriptHttpMixin, defaultHandleMixin],
27
- props: {
28
- columnConfig: {
29
- type: Object,
30
- default: null
31
- },
32
- tableParam: {
33
- type: Object,
34
- default: null
35
- },
36
- formItemProp: {
37
- type: String,
38
- default: null
39
- }
40
- },
41
- provide() {
42
- return {
43
- tableParam: this.tableParam,
44
- formItemProp: this.formItemProp
45
- };
46
- },
47
- inject: ["refList", "getFormConfig", "globalOptionData", "globalModel", "getOptionData", "getGlobalDsv",
48
- "getReadMode", "getSubFormFieldFlag", "getSubFormName", 'getReportTemplate', "getObjectFieldFlag", "getObjectName"
49
- ],
50
- data: function () {
51
- return {
52
- fieldReadonlyFlag: !1,
53
- requestAccess: null,
54
- extraAccessData: {},
55
- timerMap: {}
56
- }
57
- },
58
- beforeDestroy() {
59
- this.clearAllInterval();
60
- },
61
- created() {
62
- if (this.field.options.searchDialogConfig) {
63
- if (this.field.options.searchDialogConfig.multipleChoices === void 0) {
64
- if (this.field.type == 'vabsearch') {
65
- this.$set(this.field.options.searchDialogConfig, 'multipleChoices', false);
66
- } else {
67
- this.$set(this.field.options.searchDialogConfig, 'multipleChoices', true);
68
- }
69
- }
70
- }
71
- },
72
- mounted() {
73
-
74
- },
75
- watch: {
76
- currentValue(val) {
77
- this.initFieldModel(true)
78
- }
79
- },
80
- computed: {
81
- currentValue() {
82
- let currentData = this.tableParam && this.tableParam.row ? this.tableParam.row : this.formModel;
83
- let currentValue = currentData[this.fieldKeyName];
84
- return currentValue;
85
- },
86
- formConfig: function () {
87
- return this.getFormConfig();
88
- },
89
- subFormName: function () {
90
- return this.getSubFormName ? this.getSubFormName() : "";
91
- },
92
- subFormItemFlag: function () {
93
- return !!this.getSubFormFieldFlag && this.getSubFormFieldFlag();
94
- },
95
- formModel: {
96
- cache: !1,
97
- get: function () {
98
- return this.globalModel.formModel;
99
- }
100
- },
101
- isReadMode: function () {
102
- return !!this.getReadMode() || this.fieldReadonlyFlag;
103
- },
104
- optionLabel: function () {
105
- var e = this;
106
- if (null === this.fieldModel)
107
- return "--";
108
- var t = "--";
109
- return this.field.options.optionItems.forEach((function (i) {
110
- i.value !== e.fieldModel && -1 === e.findInArray(e.fieldModel, i.value) || (t = "--"
111
- === t ? i.label : t + " " + i.label);
112
- })),
113
- t;
114
- },
115
- tableRow() {
116
- let tableParam = this.tableParam;
117
- return tableParam && tableParam.row ? tableParam.row : null;
118
- },
119
- fieldKeyName() {
120
- let o = this.field.options.name;
121
- return (
122
- (this.field.options.keyNameEnabled
123
- && this.field.options.keyName)
124
- || o
125
- );
126
- },
127
- },
128
- methods: {
129
- initConfig() {
130
- let config = this.designer.getFieldWidgetByType(this.field.type);
131
- this.field.options = Object.assign({}, config.options, this.field.options);
132
- },
133
- findInArray: function (e, t) {
134
- if (!Array.isArray(e))
135
- return -1;
136
- var i = -1;
137
- return e.forEach((function (e, n) {
138
- e === t && (i = n);
139
- })),
140
- i;
141
- },
142
- getPropName: function () {
143
- if (this.formItemProp) {
144
- return this.formItemProp;
145
- } else {
146
- return this.subFormItemFlag && !this.designState
147
- ? this.subFormName
148
- + "."
149
- + this.subFormRowIndex
150
- + "."
151
- + this.fieldKeyName
152
- : this.getObjectFieldFlag() && !this.designState
153
- ? this.getObjectName() + "." + this.fieldKeyName
154
- : this.fieldKeyName;
155
- }
156
- },
157
- initFieldModel: function (flag) {
158
- var e = this;
159
- if (this.field.formItemFlag) {
160
- let currentData = this.tableParam && this.tableParam.row ? this.tableParam.row : this.formModel;
161
- /*if (this.subFormItemFlag && !this.designState) {
162
- var t = currentData[this.subFormName];
163
- return void 0 !== t && void 0 !== t[this.subFormRowIndex] && void 0 !== t[this.subFormRowIndex][
164
- this.fieldKeyName
165
- ] || void 0 === this.field.options.defaultValue ? void 0 === t[this.subFormRowIndex][this
166
- .fieldKeyName
167
- ] ? (this.fieldModel = null,
168
- t[this.subFormRowIndex][this.fieldKeyName] = null) : this.fieldModel = t[this
169
- .subFormRowIndex][this.fieldKeyName] : (this.fieldModel = this.field.options
170
- .defaultValue,
171
- t[this.subFormRowIndex][this.fieldKeyName] = this.field.options.defaultValue),
172
- setTimeout((function () {
173
- e.handleOnChangeForSubForm(e.fieldModel, e.oldFieldValue, t, e.subFormRowId)
174
- }), 800),
175
- this.oldFieldValue = baseRefUtil.deepClone(this.fieldModel),
176
- void this.initFileList();
177
- }*/
178
- let defaultValue = this.field.options.defaultValue;
179
- let dataId = this.getFormRef()?.dataId ?? null;
180
- if (void 0 === currentData[this.fieldKeyName]) {
181
-
182
- this.$set(currentData, this.fieldKeyName, null);
183
- }
184
- if (flag) {
185
- this.fieldModel = currentData[this.fieldKeyName];
186
- } else if (currentData[this.fieldKeyName] !== null) {
187
- this.fieldModel = currentData[this.fieldKeyName];
188
- } else {
189
- if (!dataId) {
190
- //新增
191
- if (!this.tableParam) {
192
- //主表
193
- if (this.isNotNullVal(defaultValue)) {
194
- this.setValue(defaultValue);
195
- }
196
- } else {
197
- //明细
198
- if (!this.tableParam.row.id && this.isNotNullVal(defaultValue)) {
199
- this.setValue(defaultValue);
200
- }
201
- }
202
- } else {
203
- //编辑
204
- if (!this.tableParam) {
205
- //主表
206
- } else {
207
- //明细
208
- if (!this.tableParam.row.id && this.isNotNullVal(defaultValue)) {
209
- this.setValue(defaultValue);
210
- }
211
- }
212
- }
213
- }
214
-
215
- /*if (this.fieldKeyName == "f_mobile" && !this.fieldModel) {
216
- }*/
217
- /*void 0 === currentData[this.fieldKeyName] && void 0 !== this.field.options.defaultValue
218
- ? this.fieldModel = this.field.options.defaultValue :
219
- void 0 === currentData[this.fieldKeyName] ? currentData[this.fieldKeyName] = null : this.fieldModel = currentData[this.fieldKeyName];*/
220
- this.oldFieldValue = baseRefUtil.deepClone(this.fieldModel);
221
- /*if (this.fieldKeyName == "f_contract" && !this.fieldModel) {
222
- }*/
223
- this.initFileList();
224
- }
225
- },
226
- isNotNullVal(val) {
227
- return val !== null && val !== undefined && val !== '';
228
- },
229
- initFileList: function () {
230
- "picture-upload" !== this.field.type && "file-upload" !== this.field.type || !0 === this.designState
231
- || this.fieldModel && (Array.isArray(this.fieldModel) ? this.fileList = baseRefUtil.deepClone(this
232
- .fieldModel) : this.fileList.splice(0, 0, baseRefUtil.deepClone(this.fieldModel)));
233
- },
234
- handleCreatedEnterEvent() {
235
- this.handleCustomEvent(this.field.options.onCreatedEnter);
236
- },
237
- initEventHandler() {
238
- this.designState
239
- || (this.$on("setFormData", (o) => {
240
- /*if (!this.subFormItemFlag)
241
- if (
242
- !!this.getObjectFieldFlag()
243
- && !this.designState
244
- ) {
245
- const e = this.getObjectModel();
246
- this.setValue(
247
- e === void 0
248
- ? null
249
- : e[this.fieldKeyName]
250
- );
251
- } else this.setValue(o[this.fieldKeyName]);*/
252
- this.subFormItemFlag || this.setValue(o[this.fieldKeyName]);
253
- }),
254
- this.$on("field-value-changed", (o) => {
255
- if (this.subFormItemFlag) {
256
- let e = this.formModel[this.subFormName];
257
- this.handleOnChangeForSubForm(
258
- o[0],
259
- o[1],
260
- e,
261
- this.subFormRowId
262
- );
263
- } else this.handleOnChange(o[0], o[1]);
264
- }),
265
- this.$on("field-value-changed", (function (e) {
266
- if (this.subFormItemFlag) {
267
- var t = this.formModel[this.subFormName];
268
- this.handleOnChangeForSubForm(e[0], e[1], t, this.subFormRowId);
269
- } else
270
- this.handleOnChange(e[0], e[1]);
271
- })),
272
- this.$on("sync-field-value", (o) => {
273
- const e = o[0],
274
- n = o[1];
275
- if (
276
- this.field.options.name === e
277
- || (!n && this.field.options.keyName !== e)
278
- || (!this.field.options.keyName
279
- && this.field.options.name !== n)
280
- || (!!this.field.options.keyName
281
- && !!n
282
- && this.field.options.keyName !== n)
283
- || o[5] !== this.getObjectName()
284
- )
285
- return;
286
- const s = o[2],
287
- c = o[3],
288
- u = o[4];
289
- !this.subFormName && !s
290
- ? this.setValue(u, !0)
291
- : this.subFormName === s
292
- && this.subFormRowId === c
293
- && this.setValue(u, !0);
294
- }),
295
- /*this.$on("calculate-formula", (o) => {
296
- if (
297
- !!this.field.options.formulaEnabled
298
- && !!this.field.options.formula
299
- ) {
300
- let e = o[1];
301
- const n = o[1].field.options.name;
302
- fieldIsUsedInFormula(
303
- n,
304
- this.field.options.formula,
305
- this.getFormRef()
306
- )
307
- && calculateFormula(
308
- this.getFormRef(),
309
- this.getGlobalDsv(),
310
- formulajs,
311
- this,
312
- e
313
- );
314
- }
315
- }),
316
- this.$on("calculate-formula-sfRowDeleted", (o) => {
317
- if (
318
- !!this.field.options.formulaEnabled
319
- && !!this.field.options.formula
320
- ) {
321
- const e = o[1];
322
- fieldIsUsedInFormula(
323
- e,
324
- this.field.options.formula,
325
- this.getFormRef()
326
- );
327
- }
328
- }),*/
329
- this.$on("loadOptionItemsFromDataSet", (o) => {
330
- this.loadOptionItemsFromDataSet(o),
331
- (this.dataSetLoadedFlag = !0);
332
- }),
333
- this.$on("reloadOptionItems", (o) => {
334
- (o.length === 0
335
- || o.indexOf(this.field.options.name) > -1)
336
- && this.initOptionItems(!0);
337
- }));
338
- },
339
- getEventParam() {
340
- let formRef = this.getFormRef();
341
- let dataId = formRef?.dataId;
342
- let formCode = formRef?.reportTemplate?.formCode;
343
- return {
344
- eventParamNames: ["dataId", "formCode"],
345
- eventParamValues: [dataId, formCode],
346
- }
347
- },
348
- handleCustomEvent(funtionStr, eventParamNames = [], eventParamValues = []) {
349
- if (!this.designState && funtionStr) {
350
- let eventParam = this.getEventParam();
351
- var e = new Function(...eventParam.eventParamNames, ...eventParamNames, funtionStr);
352
- return e.call(this, ...eventParam.eventParamValues, ...eventParamValues);
353
- }
354
- },
355
- handleOnCreated: function () {
356
- this.handleCustomEvent(this.field.options.onCreated);
357
- },
358
- handleOnMounted: function () {
359
- this.handleCustomEvent(this.field.options.onMounted);
360
- this.autoExcScript();
361
- },
362
- registerToRefList: function (e) {
363
- null !== this.refList && this.field.options.name && (this.tableParam && !this.designState ? (e
364
- && delete this.refList[e + "@row" + this.tableParam.rowIndex],
365
- this.refList[this.field.options.name + "@row" + this.tableParam.rowIndex] = this) : (e
366
- && delete this.refList[e],
367
- this.refList[this.field.options.name] = this));
368
-
369
-
370
- },
371
- unregisterFromRefList: function () {
372
- if (null !== this.refList && this.field.options.name) {
373
- var e = this.field.options.name;
374
- this.tableParam && !this.designState ? delete this.refList[e + "@row" + this.tableParam.rowIndex]
375
- : delete this.refList[e];
376
- }
377
- },
378
- async initOptionItems(keepSelected) {
379
- var t = this;
380
- if (this.designState) {
381
- return;
382
- }
383
-
384
- if ((this.field.type === 'radio') || (this.field.type === 'checkbox')
385
- || (this.field.type === 'select') || (this.field.type === 'cascader')) {
386
- let reportTemplate = this.getFormRef().reportTemplate;
387
- let formCode = reportTemplate.formCode;
388
- let formScriptEnabled = this.field.options.formScriptEnabled || false;
389
- let scriptCode = this.field.options.formScriptCode || "getList"
390
- if(formScriptEnabled){
391
- let accessParam = this.handleCustomEvent(this.field.options.formScriptParam)
392
- return this.formHttp({
393
- scriptCode: scriptCode,
394
- data: {
395
- formCode: formCode,
396
- formVersion: reportTemplate.formVersion,
397
- taBm: this.fieldKeyName,
398
- data: {
399
- ...accessParam,
400
- }
401
- },
402
- callback: res => {
403
- let rows = res.objx || [];
404
- this.loadOptions(rows);
405
- this.handleCustomEvent(this.field.options.formScriptSuccess,['res'],[res]);
406
- }
407
- });
408
- }else if(this.field.options.commonAttributeEnabled){
409
- let commonAttributeCode = this.field.options.commonAttributeCode
410
- if(!commonAttributeCode)return
411
- this.$getBaseDicts({
412
- code: commonAttributeCode,
413
- success: ({dicts, dictMap}) => {
414
- this.loadOptions(dicts);
415
- this.handleCustomEvent(this.field.options.formScriptSuccess,['res'],[dicts]);
416
- }
417
- });
418
- }
419
-
420
-
421
- return
422
- /*if (t.field.options.isLoadDataByAccess && t.field.options.scriptUuid) {
423
- this.scriptHttp(
424
- {
425
- options: t.field.options,
426
- params: {},
427
- callback: (res) => {
428
- let rows = res && res.objx ? res.objx : [];
429
- t.loadOptions(rows);
430
- }
431
- });
432
- } else if (!t.field.options.dsEnabled) {
433
- /!* 异步更新option-data之后globalOptionData不能获取到最新值,改用provide的getOptionData()方法 *!/
434
- const newOptionItems = this.getOptionData();
435
- if (!!newOptionItems && newOptionItems.hasOwnProperty(this.fieldKeyName)) {
436
- if (!!keepSelected) {
437
- this.reloadOptions(newOptionItems[this.fieldKeyName]);
438
- } else {
439
- this.loadOptions(newOptionItems[this.fieldKeyName]);
440
- }
441
- }
442
- } else {
443
- var n, a, l, s, r, d;
444
-
445
- await this.initAccess();
446
-
447
- let requestAccess = this.requestAccess;
448
- if (!requestAccess) {
449
- return;
450
- }
451
- return l = t.getGlobalDsv() || {},
452
- s = new Object({}),
453
- baseRefUtil.overwriteObj(s, l),
454
- s["widgetName"] = t.field.options.name,
455
- s.widgetKeyName = this.fieldKeyName,
456
- s["requestAccess"] = requestAccess,
457
- a = requestAccess.dsModel,
458
- // r = i.sent,
459
- baseRefUtil.runDataSourceRequest(a, s, t.getFormRef(), !1, t
460
- .$message).then(res => {
461
- t.loadOptions(res || []);
462
- });
463
- }*/
464
- }
465
- },
466
- refreshDefaultValue: function () {
467
- !0 === this.designState && void 0 !== this.field.options.defaultValue && (this.fieldModel = this.field
468
- .options.defaultValue);
469
- },
470
- clearFieldRules: function () {
471
- this.field.formItemFlag && this.rules.splice(0, this.rules.length);
472
- },
473
- buildFieldRules: function () {
474
- var e = this;
475
- if (this.field.formItemFlag) {
476
- if (this.rules.splice(0, this.rules.length),
477
- this.field.options.required && this.rules.push({
478
- required: !0,
479
- trigger: ["blur"],
480
- message: this.field.options.requiredHint || this.i18nt("render.hint.fieldRequired")
481
- }),
482
- this.field.options.validation) {
483
- var t = this.field.options.validation;
484
- a["a"][t] ? this.rules.push({
485
- validator: a["a"][t],
486
- trigger: ["blur", "change"],
487
- label: this.field.options.label,
488
- errorMsg: this.field.options.validationHint
489
- }) : this.rules.push({
490
- validator: a["a"]["regExp"],
491
- trigger: ["blur", "change"],
492
- regExp: t,
493
- label: this.field.options.label,
494
- errorMsg: this.field.options.validationHint
495
- });
496
- }
497
- if (this.field.options.onValidate) {
498
- var i = function (t, i, n) {
499
- var o = new Function("rule", "value", "callback", e.field.options.onValidate);
500
- return o.call(e, t, i, n);
501
- };
502
- this.rules.push({
503
- validator: i,
504
- trigger: ["blur", "change"],
505
- label: this.field.options.label
506
- });
507
- }
508
- }
509
- },
510
- disableChangeValidate: function () {
511
- this.rules && this.rules.forEach((function (e) {
512
- e.trigger && e.trigger.splice(0, e.trigger.length);
513
- }));
514
- },
515
- enableChangeValidate: function () {
516
- this.rules && this.rules.forEach((function (e) {
517
- e.trigger && (e.trigger.push("blur"),
518
- e.trigger.push("change"));
519
- }))
520
- },
521
- disableOptionOfList: function (e, t) {
522
- e && e.length > 0 && e.forEach((function (e) {
523
- e.value === t && (e.disabled = !0);
524
- }));
525
- },
526
- enableOptionOfList: function (e, t) {
527
- e && e.length > 0 && e.forEach((function (e) {
528
- e.value === t && (e.disabled = !1);
529
- }));
530
- },
531
- emitFieldDataChange(o, e) {
532
- this.$emit("field-value-changed", [o, e]),
533
- this.broadcast("FieldWidget", "sync-field-value", [
534
- this.field.options.name,
535
- this.field.options.keyName,
536
- this.subFormName,
537
- this.subFormRowId,
538
- o,
539
- this.getObjectName(),
540
- ]),
541
- /*this.getFormRef().broadcast(
542
- "FieldWidget",
543
- "calculate-formula",
544
- [o, this]
545
- ),*/
546
- this.dispatch("VFormRender", "fieldChange", [
547
- this.field.options.name,
548
- o,
549
- e,
550
- this.subFormName,
551
- this.subFormRowIndex,
552
- ]);
553
- },
554
- syncUpdateFormModel: function (e) {
555
- if (!this.designState)
556
- if (this.tableRow) {
557
- this.tableRow[this.fieldKeyName] = e;
558
- } else if (this.subFormItemFlag) {
559
- var t = this.formModel[this.subFormName] || [{}],
560
- i = t[this.subFormRowIndex];
561
- i[this.fieldKeyName] = e;
562
- } else
563
- this.formModel[this.fieldKeyName] = e;
564
- },
565
- handleChangeEvent: function (e) {
566
- this.syncUpdateFormModel(e),
567
- this.emitFieldDataChange(e, this.oldFieldValue),
568
- this.oldFieldValue = baseRefUtil.deepClone(e),
569
- this.dispatch("VFormRender", "fieldValidation", [this.getPropName()]);
570
- },
571
- handleFocusCustomEvent: function (e) {
572
- if (this.oldFieldValue = baseRefUtil.deepClone(this.fieldModel),
573
- this.field.options.onFocus) {
574
- var t = new Function("event", this.field.options.onFocus);
575
- t.call(this, e);
576
- }
577
- },
578
- handleBlurCustomEvent: function (e) {
579
- if (this.field.options.onBlur) {
580
- var t = new Function("event", this.field.options.onBlur);
581
- t.call(this, e);
582
- }
583
- },
584
- handleInputCustomEvent: function (e) {
585
- if (this.syncUpdateFormModel(e),
586
- this.dispatch("VFormRender", "fieldValidation", [this.getPropName()]),
587
- this.field.options.onInput) {
588
- var t = new Function("value", this.field.options.onInput);
589
- t.call(this, e);
590
- }
591
- },
592
- emitAppendButtonClick: function () {
593
- if (!this.designState) {
594
- if (this.field.options.onAppendButtonClick) {
595
- let tableParam = this.tableParam;
596
- let eventParamNames = [];
597
- let eventParamValues = [];
598
- if (tableParam) {
599
- eventParamNames = ['rowData', 'rowIndex'];
600
- eventParamValues = [tableParam.row, tableParam.rowIndex];
601
- }
602
-
603
- this.handleCustomEvent(this.field.options.onAppendButtonClick, eventParamNames, eventParamValues)
604
-
605
-
606
- // this.handleCustomEvent(this.field.options.onAppendButtonClick)
607
- } else {
608
- this.dispatch("VFormRender", "appendButtonClick", [this]);
609
- }
610
- this.handleCustomClickEvent();
611
- }
612
- },
613
- handleCustomClickEvent: function () {
614
- let tableParam = this.tableParam;
615
- let clickBindEvent = this.field.options.clickBindEvent;
616
- if (clickBindEvent == '1') {
617
- //打开选择弹框
618
- this.openSearchDialog(tableParam);
619
- } else if (clickBindEvent == '2') {
620
- //列表插入数据
621
- this.handleAddTableDataEvent();
622
- }
623
- },
624
- handleAddTableDataEvent() {
625
- let addTableDataConfig = this.field.options.addTableDataConfig || {};
626
- if (!addTableDataConfig.tableRef) return;
627
- let tableData = addTableDataConfig.tableData || {};
628
- this.getWidgetRef(addTableDataConfig.tableRef).addTableData([tableData]);
629
- },
630
- handleOnChange: function (e, t) {
631
- if (this.field.options.onChange) {
632
- var i = new Function("value", "oldValue", this.field.options.onChange);
633
- i.call(this, e, t);
634
- }
635
- },
636
- handleOnChangeForSubForm: function (e, t, i, n) {
637
- if (this.field.options.onChange) {
638
- var o = new Function("value", "oldValue", "subFormData", "rowId", this.field.options.onChange);
639
- o.call(this, e, t, i, n);
640
- }
641
- },
642
- handleButtonWidgetClick: function (event) {
643
- if (!this.designState) {
644
- if (this.field.options.onClick) {
645
- let tableParam = this.tableParam;
646
- let eventParamNames = ['event'];
647
- let eventParamValues = [event];
648
- if (tableParam) {
649
- eventParamNames = ['row', 'rowIndex', 'event'];
650
- eventParamValues = [tableParam.row, tableParam.rowIndex, event];
651
- }
652
- this.handleCustomEvent(this.field.options.onClick, eventParamNames, eventParamValues);
653
- } else {
654
- this.dispatch("VFormRender", "buttonClick", [this]);
655
- }
656
- this.handleCustomClickEvent();
657
- }
658
- },
659
- getSearchDialogSourceField(targetField) {
660
- let searchDialogConfig = this.field.options.searchDialogConfig || {};
661
- let tableData = searchDialogConfig.tableData || [];
662
- },
663
- openSearchDialog(tableParam) {
664
- let searchDialogConfig = this.field.options.searchDialogConfig || {};
665
- let formCode = searchDialogConfig.formCode;
666
- let tableData = searchDialogConfig.tableData || [];
667
- let formModel = this.formModel;
668
-
669
- let rows = []
670
- if (this.field.type == "vabsearch") {
671
- if (this.field.options.multipleChoices) {
672
- let fieldKeyName = this.fieldKeyName;
673
- let valueField = this.field.options.valueField || fieldKeyName;
674
- let vabSearchName = this.field.options.vabSearchName || fieldKeyName;
675
-
676
- rows = (this.fieldModel || []).map(row => {
677
- return {
678
- [searchDialogConfig.valueSourceField]: row[valueField],
679
- [searchDialogConfig.labelSourceField]: row[vabSearchName]
680
- }
681
- })
682
- }
683
- }
684
-
685
- this.getFormRef().openSearchDialog({
686
- formCode: formCode,
687
- rows,
688
- multiple: searchDialogConfig.multipleChoices || false,
689
- confirm: (rows) => {
690
- this.handleConfirmSearchDialog(rows, false);
691
- /*if(rows.length){
692
- let row = rows[0];
693
- if(this.field.type == "vabsearch"){
694
- let fieldKeyName = this.fieldKeyName;
695
- let vabSearchName = this.field.options.vabSearchName || fieldKeyName;
696
- if(tableParam){
697
- let rowData = tableParam.row;
698
- rowData[fieldKeyName] = row[searchDialogConfig.valueSourceField]
699
- if(searchDialogConfig.labelSourceField)rowData[vabSearchName] = row[searchDialogConfig.labelSourceField]
700
- tableData.forEach(item=>{
701
- rowData[item.targetField] = row[item.sourceField]
702
- })
703
- }else{
704
- this.fieldModel = row[searchDialogConfig.valueSourceField];
705
- if(searchDialogConfig.labelSourceField)this.showValue = row[searchDialogConfig.labelSourceField];
706
- tableData.forEach(item=>{
707
- // formModel[item.targetField] = row[item.sourceField]
708
- this.getWidgetRef(item.targetField).setValue(row[item.sourceField]??null)
709
- })
710
- }
711
- }else{
712
- if(searchDialogConfig.tableEnabled){
713
- if(!searchDialogConfig.tableRef || !tableData.length)return
714
- let addRows = rows.map(rowData=>{
715
- let itemData = {};
716
- tableData.forEach(item=>{
717
- itemData[item.targetField] = rowData[item.sourceField]
718
- })
719
- return itemData;
720
- });
721
- this.getWidgetRef(searchDialogConfig.tableRef).addTableData(addRows,searchDialogConfig.tableUniqueKey);
722
- }
723
- }
724
- }*/
725
- }
726
- });
727
- },
728
- handleClearSearchDialog() {
729
- let clickBindEvent = this.field.options.clickBindEvent;
730
- if (clickBindEvent == '1') {
731
- this.handleConfirmSearchDialog(null, true);
732
- }
733
- },
734
- getMultipleChoices() {
735
- let multipleChoices = this.field.options.multipleChoices
736
- return multipleChoices;
737
- },
738
- handleConfirmSearchDialog(rows, isClear) {
739
- if (!isClear && !rows.length) return;
740
- let tableParam = this.tableParam;
741
- let searchDialogConfig = this.field.options.searchDialogConfig || {};
742
- let formCode = searchDialogConfig.formCode;
743
- let tableData = searchDialogConfig.tableData || [];
744
- let formModel = this.formModel;
745
- let row = rows && rows.length ? rows[0] : null;
746
- let multipleChoices = this.field.options.searchDialogConfig.multipleChoices || false
747
- if (this.field.type == "vabsearch") {
748
- let fieldKeyName = this.fieldKeyName;
749
- let valueField = this.field.options.valueField || fieldKeyName;
750
- let vabSearchName = this.field.options.vabSearchName || fieldKeyName;
751
-
752
- if (tableParam) {
753
- let rowData = tableParam.row;
754
- if (multipleChoices) {
755
- if (isClear) {
756
- rowData[fieldKeyName] = []
757
- } else {
758
- rowData[fieldKeyName] = rows.map(item => {
759
- let newData = {};
760
- newData[valueField] = item[searchDialogConfig.valueSourceField] ?? null;
761
- newData[vabSearchName] = item[searchDialogConfig.labelSourceField] ?? null;
762
- tableData.forEach(item1 => {
763
- newData[item1.targetField] = item[item1.sourceField]
764
- })
765
- return newData
766
- })
767
- }
768
-
769
- } else {
770
- rowData[fieldKeyName] = !isClear ? row[searchDialogConfig.valueSourceField] : null;
771
- if (searchDialogConfig.labelSourceField) rowData[vabSearchName] = !isClear ? row[searchDialogConfig.labelSourceField] : null;
772
- tableData.forEach(item => {
773
- if (!isClear) {
774
- rowData[item.targetField] = row[item.sourceField]
775
- } else {
776
- rowData[item.targetField] = null;
777
- }
778
- })
779
- }
780
-
781
- } else {
782
- this.fieldModel = !isClear ? row[searchDialogConfig.valueSourceField] : null;
783
- if (searchDialogConfig.labelSourceField) {
784
- this.setShowValue(!isClear ? row[searchDialogConfig.labelSourceField] : null);
785
- }
786
- tableData.forEach(item => {
787
- // formModel[item.targetField] = row[item.sourceField]
788
- let value = !isClear ? (row[item.sourceField] ?? null) : null
789
- this.getWidgetRef(item.targetField).setValue(value)
790
- // formModel[item.targetField] = value;
791
- })
792
- // this.$forceUpdate();
793
- }
794
- } else {
795
- if (searchDialogConfig.tableEnabled) {
796
- if (!searchDialogConfig.tableRef || !tableData.length) return
797
- let addRows = rows.map(rowData => {
798
- let itemData = {};
799
- tableData.forEach(item => {
800
- itemData[item.targetField] = rowData[item.sourceField]
801
- })
802
- return itemData;
803
- });
804
- this.getWidgetRef(searchDialogConfig.tableRef).addTableData(addRows, searchDialogConfig.tableUniqueKey);
805
- } else if (!multipleChoices) {
806
- tableData.forEach(item => {
807
- let value = row[item.sourceField] ?? null
808
- // formModel[item.targetField] = value
809
- this.getWidgetRef(item.targetField).setValue(value)
810
- })
811
- // this.$forceUpdate();
812
- }
813
- }
814
-
815
- if(!isClear){
816
- this.$nextTick(()=>{
817
- this.handleCustomEvent(searchDialogConfig.confirmCallback,['rows'],[rows])
818
- })
819
- }
820
-
821
- },
822
- remoteQuery: function (e) {
823
- if (this.field.options.onRemoteQuery) {
824
- var t = new Function("keyword", this.field.options.onRemoteQuery);
825
- t.call(this, e);
826
- }
827
- },
828
- getFormRef: function () {
829
- return this.refList ? this.refList["v_form_ref"] : null;
830
- },
831
- getWidgetRef: function (e, t) {
832
- var i = this.refList[e];
833
- return !i && t && this.$message.error(this.i18nt("render.hint.refNotFound") + e),
834
- i;
835
- },
836
- getFieldEditor: function () {
837
- return this.$refs["fieldEditor"];
838
- },
839
- setValue: function (e) {
840
- if (this.field.formItemFlag) {
841
- let value = e ?? null;
842
- var t = baseRefUtil.deepClone(this.fieldModel);
843
- this.fieldModel = value,
844
- this.initFileList(),
845
- this.syncUpdateFormModel(value),
846
- this.emitFieldDataChange(value, t);
847
- }
848
- },
849
- getValue: function () {
850
- return this.fieldModel;
851
- },
852
- resetField: function () {
853
- if (!this.subFormItemFlag) {
854
- var e = this.field.options.defaultValue;
855
- this.setValue(e),
856
- "picture-upload" !== this.field.type && "file-upload" !== this.field.type || (this.$refs[
857
- "fieldEditor"].clearFiles(),
858
- this.fileList.splice(0, this.fileList.length));
859
- }
860
- },
861
- setWidgetOption: function (e, t) {
862
- this.field.options.hasOwnProperty(e) && (this.field.options[e] = t);
863
- },
864
- setReadonly: function (e) {
865
- this.field.options.readonly = e;
866
- },
867
- setDisabled: function (e) {
868
- this.field.options.disabled = e;
869
- },
870
- setAppendButtonVisible: function (e) {
871
- this.field.options.appendButton = e;
872
- },
873
- setAppendButtonDisabled: function (e) {
874
- this.field.options.appendButtonDisabled = e;
875
- },
876
- setHidden: function (e) {
877
- this.field.options.hidden = e,
878
- e ? this.clearFieldRules() : this.buildFieldRules();
879
- },
880
- setRequired: function (e) {
881
- this.field.options.required = e,
882
- this.buildFieldRules();
883
- },
884
- setLabel: function (e) {
885
- this.field.options.label = e;
886
- },
887
- focus: function () {
888
- this.getFieldEditor() && this.getFieldEditor().focus && this.getFieldEditor().focus();
889
- },
890
- clearSelectedOptions: function () {
891
- "checkbox" !== this.field.type && "radio" !== this.field.type && "select" !== this.field.type || (
892
- "checkbox" === this.field.type || "select" === this.field.type && this.field.options.multiple
893
- ? this.fieldModel = [] : this.fieldModel = "");
894
- },
895
- loadOptions: function (e) {
896
- this.field.options.optionItems = baseRefUtil.translateOptionItems(e, this.field.type, this.field.options
897
- .labelKey
898
- || "label", this.field.options.valueKey || "value");
899
- },
900
- reloadOptions: function (e) {
901
- this.field.options.optionItems = baseRefUtil.translateOptionItems(e, this.field.type, this.field.options
902
- .labelKey
903
- || "label", this.field.options.valueKey || "value");
904
- },
905
- getOptions: function () {
906
- return this.field.options.optionItems;
907
- },
908
- disableOption: function (e) {
909
- this.disableOptionOfList(this.field.options.optionItems, e);
910
- },
911
- enableOption: function (e) {
912
- this.enableOptionOfList(this.field.options.optionItems, e);
913
- },
914
- getOptionItems: function () {
915
- return this.field.options.optionItems;
916
- },
917
- setUploadHeader: function (e, t) {
918
- this.$set(this.uploadHeaders, e, t);
919
- },
920
- setUploadData: function (e, t) {
921
- this.$set(this.uploadData, e, t);
922
- },
923
- setToolbar: function (e) {
924
- this.customToolbar = e;
925
- },
926
- isSubFormItem: function () {
927
- return this.subFormItemFlag;
928
- },
929
- isSubFormField: function () {
930
- return this.subFormItemFlag;
931
- },
932
- setReadMode: function () {
933
- var e = !(arguments.length > 0 && void 0 !== arguments[0]) || arguments[0];
934
- this.fieldReadonlyFlag = e;
935
- },
936
- addCssClass: function (e) {
937
- this.field.options.customClass ? this.field.options.customClass.push(e) : this.field.options
938
- .customClass = [e];
939
- },
940
- removeCssClass: function (e) {
941
- if (this.field.options.customClass) {
942
- var t = -1;
943
- this.field.options.customClass.map((function (i, n) {
944
- i === e && (t = n);
945
- })),
946
- t > -1 && this.field.options.customClass.splice(t, 1);
947
- }
948
- },
949
- async initAccess() {
950
- if (this.field.options.accessCode) {
951
- return this.$http({
952
- url: SUPPORT_PREFIX + `/report_requestaccess/getByCode`,
953
- method: `post`,
954
- data: {
955
- stringOne: this.field.options.accessCode
956
- },
957
- isLoading: true,
958
- // modalStrictly: true,
959
- success: res => {
960
- let requestAccess = res.objx || {};
961
-
962
- let dsModel = {};
963
- if (requestAccess.accessViewContent) {
964
- dsModel = JSON.parse(requestAccess.accessViewContent);
965
- }
966
- if (!dsModel.headers) dsModel.headers = [];
967
- if (!dsModel.params) dsModel.params = [];
968
- if (!dsModel.data) dsModel.data = [];
969
- if (dsModel.dataHandlerCode == null) dsModel.dataHandlerCode = '';
970
- if (dsModel.configHandlerCode == null) dsModel.configHandlerCode = '';
971
- if (dsModel.errorHandlerCode == null) dsModel.errorHandlerCode = '';
972
-
973
- requestAccess.dsModel = dsModel;
974
- this.requestAccess = requestAccess;
975
- }
976
- });
977
- } else {
978
- return null;
979
- }
980
- },
981
- addExtraAccessData(data) {
982
- if (data) {
983
- Object.keys(data).forEach(field => {
984
- this.extraAccessData[field] = data[field];
985
- });
986
- }
987
- },
988
- clearExtraAccessData() {
989
- this.extraAccessData = {};
990
- },
991
- doAccess(accessCode, conditions, callback) {
992
- let path = baseRefUtil.getAccessUrl();
993
- let globalReqData = baseRefUtil.getReportGlobalMap(); //全局请求参数
994
- return this.$http({
995
- url: path,
996
- method: `post`,
997
- loadingTarget: document.body,
998
- data: {
999
- accessCode: accessCode,
1000
- conditions: {
1001
- ...conditions,
1002
- ...globalReqData
1003
- }
1004
- },
1005
- isLoading: true,
1006
- success: res => {
1007
- callback && callback(res)
1008
- }
1009
- });
1010
- },
1011
- autoExcScript() {
1012
- if (!this.designState && this.field.options.accessAutoExc) {
1013
- this.scriptHttp({
1014
- options: this.field.options
1015
- });
1016
- }
1017
- },
1018
- addInterval(handler, timeout) {
1019
- let timer = setInterval(handler, timeout);
1020
- this.timerMap[timer] = timer;
1021
- return timer;
1022
- },
1023
- clearAllInterval() {
1024
- let timerMap = this.timerMap;
1025
- for (let key in timerMap) {
1026
- let timer = timerMap[key];
1027
- clearInterval(timer);
1028
- }
1029
- this.timerMap = {};
1030
- },
1031
- getI18nLabel(label, path, param) {
1032
- return !this.designState && label ? this.$t2(label, path, param) : label;
1033
- },
1034
- getParentTarget() {
1035
- let name = this.parentWidget?.options?.name ?? null;
1036
- return name ? this.getWidgetRef(name) : null;
1037
- }
1038
- }
1039
- }
1040
-
1041
- export default modules;
1
+ import {
2
+ deepClone,
3
+ translateOptionItems,
4
+ getDSByName,
5
+ overwriteObj,
6
+ runDataSourceRequest,
7
+ getReportGlobalMap,
8
+ getAccessUrl,
9
+ } from "../../../../../components/xform/utils/util";
10
+ import FormValidators from "../../../../../components/xform/utils/validators";
11
+ import scriptHttpMixin from "../../../../../components/xform/mixins/scriptHttp";
12
+ import defaultHandleMixin from "../../../../../components/xform/mixins/defaultHandle";
13
+
14
+ let modules = {};
15
+ const baseRefUtil = {
16
+ deepClone,
17
+ translateOptionItems,
18
+ getDSByName,
19
+ overwriteObj,
20
+ runDataSourceRequest,
21
+ FormValidators,
22
+ getReportGlobalMap,
23
+ getAccessUrl,
24
+ };
25
+ modules = {
26
+ mixins: [scriptHttpMixin, defaultHandleMixin],
27
+ props: {
28
+ columnConfig: {
29
+ type: Object,
30
+ default: null,
31
+ },
32
+ tableParam: {
33
+ type: Object,
34
+ default: null,
35
+ },
36
+ formItemProp: {
37
+ type: String,
38
+ default: null,
39
+ },
40
+ },
41
+ provide() {
42
+ return {
43
+ tableParam: this.tableParam,
44
+ formItemProp: this.formItemProp,
45
+ };
46
+ },
47
+ inject: [
48
+ "refList",
49
+ "getFormConfig",
50
+ "globalOptionData",
51
+ "globalModel",
52
+ "getOptionData",
53
+ "getGlobalDsv",
54
+ "getReadMode",
55
+ "getSubFormFieldFlag",
56
+ "getSubFormName",
57
+ "getReportTemplate",
58
+ "getObjectFieldFlag",
59
+ "getObjectName",
60
+ ],
61
+ data: function () {
62
+ return {
63
+ fieldReadonlyFlag: !1,
64
+ requestAccess: null,
65
+ extraAccessData: {},
66
+ timerMap: {},
67
+ };
68
+ },
69
+ beforeDestroy() {
70
+ this.clearAllInterval();
71
+ },
72
+ created() {
73
+ if (this.field.options.searchDialogConfig) {
74
+ if (this.field.options.searchDialogConfig.multipleChoices === void 0) {
75
+ if (this.field.type == "vabsearch") {
76
+ this.$set(
77
+ this.field.options.searchDialogConfig,
78
+ "multipleChoices",
79
+ false
80
+ );
81
+ } else {
82
+ this.$set(
83
+ this.field.options.searchDialogConfig,
84
+ "multipleChoices",
85
+ true
86
+ );
87
+ }
88
+ }
89
+ }
90
+ },
91
+ mounted() {},
92
+ watch: {
93
+ currentValue(val) {
94
+ this.initFieldModel(true);
95
+ },
96
+ },
97
+ computed: {
98
+ currentValue() {
99
+ let currentData =
100
+ this.tableParam && this.tableParam.row
101
+ ? this.tableParam.row
102
+ : this.formModel;
103
+ let currentValue = currentData[this.fieldKeyName];
104
+ return currentValue;
105
+ },
106
+ formConfig: function () {
107
+ return this.getFormConfig();
108
+ },
109
+ subFormName: function () {
110
+ return this.getSubFormName ? this.getSubFormName() : "";
111
+ },
112
+ subFormItemFlag: function () {
113
+ return !!this.getSubFormFieldFlag && this.getSubFormFieldFlag();
114
+ },
115
+ formModel: {
116
+ cache: !1,
117
+ get: function () {
118
+ return this.globalModel.formModel;
119
+ },
120
+ },
121
+ isReadMode: function () {
122
+ return !!this.getReadMode() || this.fieldReadonlyFlag;
123
+ },
124
+ optionLabel: function () {
125
+ var e = this;
126
+ if (null === this.fieldModel) return "--";
127
+ var t = "--";
128
+ return (
129
+ this.field.options.optionItems.forEach(function (i) {
130
+ (i.value !== e.fieldModel &&
131
+ -1 === e.findInArray(e.fieldModel, i.value)) ||
132
+ (t = "--" === t ? i.label : t + " " + i.label);
133
+ }),
134
+ t
135
+ );
136
+ },
137
+ tableRow() {
138
+ let tableParam = this.tableParam;
139
+ return tableParam && tableParam.row ? tableParam.row : null;
140
+ },
141
+ fieldKeyName() {
142
+ let o = this.field.options.name;
143
+ return (
144
+ (this.field.options.keyNameEnabled && this.field.options.keyName) || o
145
+ );
146
+ },
147
+ },
148
+ methods: {
149
+ initConfig() {
150
+ let config = this.designer.getFieldWidgetByType(this.field.type);
151
+ this.field.options = Object.assign(
152
+ {},
153
+ config.options,
154
+ this.field.options
155
+ );
156
+ },
157
+ findInArray: function (e, t) {
158
+ if (!Array.isArray(e)) return -1;
159
+ var i = -1;
160
+ return (
161
+ e.forEach(function (e, n) {
162
+ e === t && (i = n);
163
+ }),
164
+ i
165
+ );
166
+ },
167
+ getPropName: function () {
168
+ if (this.formItemProp) {
169
+ return this.formItemProp;
170
+ } else {
171
+ return this.subFormItemFlag && !this.designState
172
+ ? this.subFormName +
173
+ "." +
174
+ this.subFormRowIndex +
175
+ "." +
176
+ this.fieldKeyName
177
+ : this.getObjectFieldFlag() && !this.designState
178
+ ? this.getObjectName() + "." + this.fieldKeyName
179
+ : this.fieldKeyName;
180
+ }
181
+ },
182
+ initFieldModel: function (flag) {
183
+ var e = this;
184
+ if (this.field.formItemFlag) {
185
+ let currentData =
186
+ this.tableParam && this.tableParam.row
187
+ ? this.tableParam.row
188
+ : this.formModel;
189
+ /*if (this.subFormItemFlag && !this.designState) {
190
+ var t = currentData[this.subFormName];
191
+ return void 0 !== t && void 0 !== t[this.subFormRowIndex] && void 0 !== t[this.subFormRowIndex][
192
+ this.fieldKeyName
193
+ ] || void 0 === this.field.options.defaultValue ? void 0 === t[this.subFormRowIndex][this
194
+ .fieldKeyName
195
+ ] ? (this.fieldModel = null,
196
+ t[this.subFormRowIndex][this.fieldKeyName] = null) : this.fieldModel = t[this
197
+ .subFormRowIndex][this.fieldKeyName] : (this.fieldModel = this.field.options
198
+ .defaultValue,
199
+ t[this.subFormRowIndex][this.fieldKeyName] = this.field.options.defaultValue),
200
+ setTimeout((function () {
201
+ e.handleOnChangeForSubForm(e.fieldModel, e.oldFieldValue, t, e.subFormRowId)
202
+ }), 800),
203
+ this.oldFieldValue = baseRefUtil.deepClone(this.fieldModel),
204
+ void this.initFileList();
205
+ }*/
206
+ let defaultValue = this.field.options.defaultValue;
207
+ let dataId = this.getFormRef()?.dataId ?? null;
208
+ if (void 0 === currentData[this.fieldKeyName]) {
209
+ this.$set(currentData, this.fieldKeyName, null);
210
+ }
211
+ if (flag) {
212
+ this.fieldModel = currentData[this.fieldKeyName];
213
+ } else if (currentData[this.fieldKeyName] !== null) {
214
+ this.fieldModel = currentData[this.fieldKeyName];
215
+ } else {
216
+ if (!dataId) {
217
+ //新增
218
+ if (!this.tableParam) {
219
+ //主表
220
+ if (this.isNotNullVal(defaultValue)) {
221
+ this.setValue(defaultValue);
222
+ }
223
+ } else {
224
+ //明细
225
+ if (!this.tableParam.row.id && this.isNotNullVal(defaultValue)) {
226
+ this.setValue(defaultValue);
227
+ }
228
+ }
229
+ } else {
230
+ //编辑
231
+ if (!this.tableParam) {
232
+ //主表
233
+ } else {
234
+ //明细
235
+ if (!this.tableParam.row.id && this.isNotNullVal(defaultValue)) {
236
+ this.setValue(defaultValue);
237
+ }
238
+ }
239
+ }
240
+ }
241
+
242
+ /*if (this.fieldKeyName == "f_mobile" && !this.fieldModel) {
243
+ }*/
244
+ /*void 0 === currentData[this.fieldKeyName] && void 0 !== this.field.options.defaultValue
245
+ ? this.fieldModel = this.field.options.defaultValue :
246
+ void 0 === currentData[this.fieldKeyName] ? currentData[this.fieldKeyName] = null : this.fieldModel = currentData[this.fieldKeyName];*/
247
+ this.oldFieldValue = baseRefUtil.deepClone(this.fieldModel);
248
+ /*if (this.fieldKeyName == "f_contract" && !this.fieldModel) {
249
+ }*/
250
+ this.initFileList();
251
+ }
252
+ },
253
+ isNotNullVal(val) {
254
+ return val !== null && val !== undefined && val !== "";
255
+ },
256
+ initFileList: function () {
257
+ ("picture-upload" !== this.field.type &&
258
+ "file-upload" !== this.field.type) ||
259
+ !0 === this.designState ||
260
+ (this.fieldModel &&
261
+ (Array.isArray(this.fieldModel)
262
+ ? (this.fileList = baseRefUtil.deepClone(this.fieldModel))
263
+ : this.fileList.splice(
264
+ 0,
265
+ 0,
266
+ baseRefUtil.deepClone(this.fieldModel)
267
+ )));
268
+ },
269
+ handleCreatedEnterEvent() {
270
+ this.handleCustomEvent(this.field.options.onCreatedEnter);
271
+ },
272
+ initEventHandler() {
273
+ this.designState ||
274
+ (this.$on("setFormData", (o) => {
275
+ /*if (!this.subFormItemFlag)
276
+ if (
277
+ !!this.getObjectFieldFlag()
278
+ && !this.designState
279
+ ) {
280
+ const e = this.getObjectModel();
281
+ this.setValue(
282
+ e === void 0
283
+ ? null
284
+ : e[this.fieldKeyName]
285
+ );
286
+ } else this.setValue(o[this.fieldKeyName]);*/
287
+ this.subFormItemFlag || this.setValue(o[this.fieldKeyName]);
288
+ }),
289
+ this.$on("field-value-changed", (o) => {
290
+ if (this.subFormItemFlag) {
291
+ let e = this.formModel[this.subFormName];
292
+ this.handleOnChangeForSubForm(o[0], o[1], e, this.subFormRowId);
293
+ } else this.handleOnChange(o[0], o[1]);
294
+ }),
295
+ this.$on("field-value-changed", function (e) {
296
+ if (this.subFormItemFlag) {
297
+ var t = this.formModel[this.subFormName];
298
+ this.handleOnChangeForSubForm(e[0], e[1], t, this.subFormRowId);
299
+ } else this.handleOnChange(e[0], e[1]);
300
+ }),
301
+ this.$on("sync-field-value", (o) => {
302
+ const e = o[0],
303
+ n = o[1];
304
+ if (
305
+ this.field.options.name === e ||
306
+ (!n && this.field.options.keyName !== e) ||
307
+ (!this.field.options.keyName && this.field.options.name !== n) ||
308
+ (!!this.field.options.keyName &&
309
+ !!n &&
310
+ this.field.options.keyName !== n) ||
311
+ o[5] !== this.getObjectName()
312
+ )
313
+ return;
314
+ const s = o[2],
315
+ c = o[3],
316
+ u = o[4];
317
+ !this.subFormName && !s
318
+ ? this.setValue(u, !0)
319
+ : this.subFormName === s &&
320
+ this.subFormRowId === c &&
321
+ this.setValue(u, !0);
322
+ }),
323
+ /*this.$on("calculate-formula", (o) => {
324
+ if (
325
+ !!this.field.options.formulaEnabled
326
+ && !!this.field.options.formula
327
+ ) {
328
+ let e = o[1];
329
+ const n = o[1].field.options.name;
330
+ fieldIsUsedInFormula(
331
+ n,
332
+ this.field.options.formula,
333
+ this.getFormRef()
334
+ )
335
+ && calculateFormula(
336
+ this.getFormRef(),
337
+ this.getGlobalDsv(),
338
+ formulajs,
339
+ this,
340
+ e
341
+ );
342
+ }
343
+ }),
344
+ this.$on("calculate-formula-sfRowDeleted", (o) => {
345
+ if (
346
+ !!this.field.options.formulaEnabled
347
+ && !!this.field.options.formula
348
+ ) {
349
+ const e = o[1];
350
+ fieldIsUsedInFormula(
351
+ e,
352
+ this.field.options.formula,
353
+ this.getFormRef()
354
+ );
355
+ }
356
+ }),*/
357
+ this.$on("loadOptionItemsFromDataSet", (o) => {
358
+ this.loadOptionItemsFromDataSet(o), (this.dataSetLoadedFlag = !0);
359
+ }),
360
+ this.$on("reloadOptionItems", (o) => {
361
+ (o.length === 0 || o.indexOf(this.field.options.name) > -1) &&
362
+ this.initOptionItems(!0);
363
+ }));
364
+ },
365
+ getEventParam() {
366
+ let formRef = this.getFormRef();
367
+ let dataId = formRef?.dataId;
368
+ let formCode = formRef?.reportTemplate?.formCode;
369
+ return {
370
+ eventParamNames: ["dataId", "formCode"],
371
+ eventParamValues: [dataId, formCode],
372
+ };
373
+ },
374
+ handleCustomEvent(funtionStr, eventParamNames = [], eventParamValues = []) {
375
+ if (!this.designState && funtionStr) {
376
+ let eventParam = this.getEventParam();
377
+ var e = new Function(
378
+ ...eventParam.eventParamNames,
379
+ ...eventParamNames,
380
+ funtionStr
381
+ );
382
+ return e.call(
383
+ this,
384
+ ...eventParam.eventParamValues,
385
+ ...eventParamValues
386
+ );
387
+ }
388
+ },
389
+ handleOnCreated: function () {
390
+ this.handleCustomEvent(this.field.options.onCreated);
391
+ },
392
+ handleOnMounted: function () {
393
+ this.handleCustomEvent(this.field.options.onMounted);
394
+ this.autoExcScript();
395
+ },
396
+ registerToRefList: function (e) {
397
+ /* null !== this.refList && this.field.options.name && (this.tableParam && !this.designState ? (e
398
+ && delete this.refList[e + "@row" + this.tableParam.rowIndex],
399
+ this.refList[this.field.options.name + "@row" + this.tableParam.rowIndex] = this) : (e
400
+ && delete this.refList[e],
401
+ this.refList[this.field.options.name] = this)); */
402
+ if (null !== this.refList && this.field.options.name) {
403
+ if (this.tableParam && !this.designState) {
404
+ let row = this.tableParam.row;
405
+ let keyVal = row._X_ROW_KEY;
406
+ e && delete this.refList[e + "_" + keyVal],
407
+ (this.refList[this.field.options.name + "_" + keyVal] = this);
408
+ } else {
409
+ e && delete this.refList[e],
410
+ (this.refList[this.field.options.name] = this);
411
+ }
412
+ }
413
+ },
414
+ getTableRowWidgetRef(index,name){
415
+ let tableRef = this.getWidgetRef(this.parentWidget.options.name)
416
+ tableRef.getTableRowWidgetRef(index,name)
417
+ },
418
+ unregisterFromRefList: function () {
419
+ if (null !== this.refList && this.field.options.name) {
420
+ var e = this.field.options.name;
421
+ this.tableParam && !this.designState
422
+ ? delete this.refList[e + "@row" + this.tableParam.rowIndex]
423
+ : delete this.refList[e];
424
+ }
425
+ },
426
+ async initOptionItems(keepSelected) {
427
+ var t = this;
428
+ if (this.designState) {
429
+ return;
430
+ }
431
+
432
+ if (
433
+ this.field.type === "radio" ||
434
+ this.field.type === "checkbox" ||
435
+ this.field.type === "select" ||
436
+ this.field.type === "cascader"
437
+ ) {
438
+ let reportTemplate = this.getFormRef().reportTemplate;
439
+ let formCode = reportTemplate.formCode;
440
+ let formScriptEnabled = this.field.options.formScriptEnabled || false;
441
+ let scriptCode = this.field.options.formScriptCode || "getList";
442
+ if (formScriptEnabled) {
443
+ let accessParam = this.handleCustomEvent(
444
+ this.field.options.formScriptParam
445
+ );
446
+ return this.formHttp({
447
+ scriptCode: scriptCode,
448
+ data: {
449
+ formCode: formCode,
450
+ formVersion: reportTemplate.formVersion,
451
+ taBm: this.fieldKeyName,
452
+ data: {
453
+ ...accessParam,
454
+ },
455
+ },
456
+ callback: (res) => {
457
+ let rows = res.objx || [];
458
+ this.loadOptions(rows);
459
+ this.handleCustomEvent(
460
+ this.field.options.formScriptSuccess,
461
+ ["res"],
462
+ [res]
463
+ );
464
+ },
465
+ });
466
+ } else if (this.field.options.commonAttributeEnabled) {
467
+ let commonAttributeCode = this.field.options.commonAttributeCode;
468
+ if (!commonAttributeCode) return;
469
+ this.$getBaseDicts({
470
+ code: commonAttributeCode,
471
+ success: ({ dicts, dictMap }) => {
472
+ this.loadOptions(dicts);
473
+ this.handleCustomEvent(
474
+ this.field.options.formScriptSuccess,
475
+ ["res"],
476
+ [dicts]
477
+ );
478
+ },
479
+ });
480
+ }
481
+
482
+ return;
483
+ /*if (t.field.options.isLoadDataByAccess && t.field.options.scriptUuid) {
484
+ this.scriptHttp(
485
+ {
486
+ options: t.field.options,
487
+ params: {},
488
+ callback: (res) => {
489
+ let rows = res && res.objx ? res.objx : [];
490
+ t.loadOptions(rows);
491
+ }
492
+ });
493
+ } else if (!t.field.options.dsEnabled) {
494
+ /!* 异步更新option-data之后globalOptionData不能获取到最新值,改用provide的getOptionData()方法 *!/
495
+ const newOptionItems = this.getOptionData();
496
+ if (!!newOptionItems && newOptionItems.hasOwnProperty(this.fieldKeyName)) {
497
+ if (!!keepSelected) {
498
+ this.reloadOptions(newOptionItems[this.fieldKeyName]);
499
+ } else {
500
+ this.loadOptions(newOptionItems[this.fieldKeyName]);
501
+ }
502
+ }
503
+ } else {
504
+ var n, a, l, s, r, d;
505
+
506
+ await this.initAccess();
507
+
508
+ let requestAccess = this.requestAccess;
509
+ if (!requestAccess) {
510
+ return;
511
+ }
512
+ return l = t.getGlobalDsv() || {},
513
+ s = new Object({}),
514
+ baseRefUtil.overwriteObj(s, l),
515
+ s["widgetName"] = t.field.options.name,
516
+ s.widgetKeyName = this.fieldKeyName,
517
+ s["requestAccess"] = requestAccess,
518
+ a = requestAccess.dsModel,
519
+ // r = i.sent,
520
+ baseRefUtil.runDataSourceRequest(a, s, t.getFormRef(), !1, t
521
+ .$message).then(res => {
522
+ t.loadOptions(res || []);
523
+ });
524
+ }*/
525
+ }
526
+ },
527
+ refreshDefaultValue: function () {
528
+ !0 === this.designState &&
529
+ void 0 !== this.field.options.defaultValue &&
530
+ (this.fieldModel = this.field.options.defaultValue);
531
+ },
532
+ clearFieldRules: function () {
533
+ this.field.formItemFlag && this.rules.splice(0, this.rules.length);
534
+ },
535
+ buildFieldRules: function () {
536
+ var e = this;
537
+ if (this.field.formItemFlag) {
538
+ if (
539
+ (this.rules.splice(0, this.rules.length),
540
+ this.field.options.required &&
541
+ this.rules.push({
542
+ required: !0,
543
+ trigger: ["blur"],
544
+ message:
545
+ this.field.options.requiredHint ||
546
+ this.i18nt("render.hint.fieldRequired"),
547
+ }),
548
+ this.field.options.validation)
549
+ ) {
550
+ var t = this.field.options.validation;
551
+ a["a"][t]
552
+ ? this.rules.push({
553
+ validator: a["a"][t],
554
+ trigger: ["blur", "change"],
555
+ label: this.field.options.label,
556
+ errorMsg: this.field.options.validationHint,
557
+ })
558
+ : this.rules.push({
559
+ validator: a["a"]["regExp"],
560
+ trigger: ["blur", "change"],
561
+ regExp: t,
562
+ label: this.field.options.label,
563
+ errorMsg: this.field.options.validationHint,
564
+ });
565
+ }
566
+ if (this.field.options.onValidate) {
567
+ var i = function (t, i, n) {
568
+ var o = new Function(
569
+ "rule",
570
+ "value",
571
+ "callback",
572
+ e.field.options.onValidate
573
+ );
574
+ return o.call(e, t, i, n);
575
+ };
576
+ this.rules.push({
577
+ validator: i,
578
+ trigger: ["blur", "change"],
579
+ label: this.field.options.label,
580
+ });
581
+ }
582
+ }
583
+ },
584
+ disableChangeValidate: function () {
585
+ this.rules &&
586
+ this.rules.forEach(function (e) {
587
+ e.trigger && e.trigger.splice(0, e.trigger.length);
588
+ });
589
+ },
590
+ enableChangeValidate: function () {
591
+ this.rules &&
592
+ this.rules.forEach(function (e) {
593
+ e.trigger && (e.trigger.push("blur"), e.trigger.push("change"));
594
+ });
595
+ },
596
+ disableOptionOfList: function (e, t) {
597
+ e &&
598
+ e.length > 0 &&
599
+ e.forEach(function (e) {
600
+ e.value === t && (e.disabled = !0);
601
+ });
602
+ },
603
+ enableOptionOfList: function (e, t) {
604
+ e &&
605
+ e.length > 0 &&
606
+ e.forEach(function (e) {
607
+ e.value === t && (e.disabled = !1);
608
+ });
609
+ },
610
+ emitFieldDataChange(o, e) {
611
+ this.$emit("field-value-changed", [o, e]),
612
+ this.broadcast("FieldWidget", "sync-field-value", [
613
+ this.field.options.name,
614
+ this.field.options.keyName,
615
+ this.subFormName,
616
+ this.subFormRowId,
617
+ o,
618
+ this.getObjectName(),
619
+ ]),
620
+ /*this.getFormRef().broadcast(
621
+ "FieldWidget",
622
+ "calculate-formula",
623
+ [o, this]
624
+ ),*/
625
+ this.dispatch("VFormRender", "fieldChange", [
626
+ this.field.options.name,
627
+ o,
628
+ e,
629
+ this.subFormName,
630
+ this.subFormRowIndex,
631
+ ]);
632
+ },
633
+ syncUpdateFormModel: function (e) {
634
+ if (!this.designState)
635
+ if (this.tableRow) {
636
+ this.tableRow[this.fieldKeyName] = e;
637
+ } else if (this.subFormItemFlag) {
638
+ var t = this.formModel[this.subFormName] || [{}],
639
+ i = t[this.subFormRowIndex];
640
+ i[this.fieldKeyName] = e;
641
+ } else this.formModel[this.fieldKeyName] = e;
642
+ },
643
+ handleChangeEvent: function (e) {
644
+ this.syncUpdateFormModel(e),
645
+ this.emitFieldDataChange(e, this.oldFieldValue),
646
+ (this.oldFieldValue = baseRefUtil.deepClone(e)),
647
+ this.dispatch("VFormRender", "fieldValidation", [this.getPropName()]);
648
+ },
649
+ handleFocusCustomEvent: function (e) {
650
+ if (
651
+ ((this.oldFieldValue = baseRefUtil.deepClone(this.fieldModel)),
652
+ this.field.options.onFocus)
653
+ ) {
654
+ var t = new Function("event", this.field.options.onFocus);
655
+ t.call(this, e);
656
+ }
657
+ },
658
+ handleBlurCustomEvent: function (e) {
659
+ if (this.field.options.onBlur) {
660
+ var t = new Function("event", this.field.options.onBlur);
661
+ t.call(this, e);
662
+ }
663
+ },
664
+ handleInputCustomEvent: function (e) {
665
+ if (
666
+ (this.syncUpdateFormModel(e),
667
+ this.dispatch("VFormRender", "fieldValidation", [this.getPropName()]),
668
+ this.field.options.onInput)
669
+ ) {
670
+ var t = new Function("value", this.field.options.onInput);
671
+ t.call(this, e);
672
+ }
673
+ },
674
+ emitAppendButtonClick: function () {
675
+ if (!this.designState) {
676
+ if (this.field.options.onAppendButtonClick) {
677
+ let tableParam = this.tableParam;
678
+ let eventParamNames = [];
679
+ let eventParamValues = [];
680
+ if (tableParam) {
681
+ eventParamNames = ["rowData", "rowIndex"];
682
+ eventParamValues = [tableParam.row, tableParam.rowIndex];
683
+ }
684
+
685
+ this.handleCustomEvent(
686
+ this.field.options.onAppendButtonClick,
687
+ eventParamNames,
688
+ eventParamValues
689
+ );
690
+
691
+ // this.handleCustomEvent(this.field.options.onAppendButtonClick)
692
+ } else {
693
+ this.dispatch("VFormRender", "appendButtonClick", [this]);
694
+ }
695
+ this.handleCustomClickEvent();
696
+ }
697
+ },
698
+ handleCustomClickEvent: function () {
699
+ let tableParam = this.tableParam;
700
+ let clickBindEvent = this.field.options.clickBindEvent;
701
+ if (clickBindEvent == "1") {
702
+ //打开选择弹框
703
+ this.openSearchDialog(tableParam);
704
+ } else if (clickBindEvent == "2") {
705
+ //列表插入数据
706
+ this.handleAddTableDataEvent();
707
+ }
708
+ },
709
+ handleAddTableDataEvent() {
710
+ let addTableDataConfig = this.field.options.addTableDataConfig || {};
711
+ if (!addTableDataConfig.tableRef) return;
712
+ let tableData = addTableDataConfig.tableData || {};
713
+ this.getWidgetRef(addTableDataConfig.tableRef).addTableData([tableData]);
714
+ },
715
+ handleOnChange: function (e, t) {
716
+ if (this.field.options.onChange) {
717
+ var i = new Function("value", "oldValue", this.field.options.onChange);
718
+ i.call(this, e, t);
719
+ }
720
+ },
721
+ handleOnChangeForSubForm: function (e, t, i, n) {
722
+ if (this.field.options.onChange) {
723
+ var o = new Function(
724
+ "value",
725
+ "oldValue",
726
+ "subFormData",
727
+ "rowId",
728
+ this.field.options.onChange
729
+ );
730
+ o.call(this, e, t, i, n);
731
+ }
732
+ },
733
+ handleButtonWidgetClick: function (event) {
734
+ if (!this.designState) {
735
+ if (this.field.options.onClick) {
736
+ let tableParam = this.tableParam;
737
+ let eventParamNames = ["event"];
738
+ let eventParamValues = [event];
739
+ if (tableParam) {
740
+ eventParamNames = ["row", "rowIndex", "event"];
741
+ eventParamValues = [tableParam.row, tableParam.rowIndex, event];
742
+ }
743
+ this.handleCustomEvent(
744
+ this.field.options.onClick,
745
+ eventParamNames,
746
+ eventParamValues
747
+ );
748
+ } else {
749
+ this.dispatch("VFormRender", "buttonClick", [this]);
750
+ }
751
+ this.handleCustomClickEvent();
752
+ }
753
+ },
754
+ getSearchDialogSourceField(targetField) {
755
+ let searchDialogConfig = this.field.options.searchDialogConfig || {};
756
+ let tableData = searchDialogConfig.tableData || [];
757
+ },
758
+ openSearchDialog(tableParam) {
759
+ let searchDialogConfig = this.field.options.searchDialogConfig || {};
760
+ let formCode = searchDialogConfig.formCode;
761
+ let tableData = searchDialogConfig.tableData || [];
762
+ let formModel = this.formModel;
763
+
764
+ let rows = [];
765
+ if (this.field.type == "vabsearch") {
766
+ if (this.field.options.multipleChoices) {
767
+ let fieldKeyName = this.fieldKeyName;
768
+ let valueField = this.field.options.valueField || fieldKeyName;
769
+ let vabSearchName = this.field.options.vabSearchName || fieldKeyName;
770
+
771
+ rows = (this.fieldModel || []).map((row) => {
772
+ return {
773
+ [searchDialogConfig.valueSourceField]: row[valueField],
774
+ [searchDialogConfig.labelSourceField]: row[vabSearchName],
775
+ };
776
+ });
777
+ }
778
+ }
779
+
780
+ this.getFormRef().openSearchDialog({
781
+ formCode: formCode,
782
+ rows,
783
+ multiple: searchDialogConfig.multipleChoices || false,
784
+ confirm: (rows) => {
785
+ this.handleConfirmSearchDialog(rows, false);
786
+ /*if(rows.length){
787
+ let row = rows[0];
788
+ if(this.field.type == "vabsearch"){
789
+ let fieldKeyName = this.fieldKeyName;
790
+ let vabSearchName = this.field.options.vabSearchName || fieldKeyName;
791
+ if(tableParam){
792
+ let rowData = tableParam.row;
793
+ rowData[fieldKeyName] = row[searchDialogConfig.valueSourceField]
794
+ if(searchDialogConfig.labelSourceField)rowData[vabSearchName] = row[searchDialogConfig.labelSourceField]
795
+ tableData.forEach(item=>{
796
+ rowData[item.targetField] = row[item.sourceField]
797
+ })
798
+ }else{
799
+ this.fieldModel = row[searchDialogConfig.valueSourceField];
800
+ if(searchDialogConfig.labelSourceField)this.showValue = row[searchDialogConfig.labelSourceField];
801
+ tableData.forEach(item=>{
802
+ // formModel[item.targetField] = row[item.sourceField]
803
+ this.getWidgetRef(item.targetField).setValue(row[item.sourceField]??null)
804
+ })
805
+ }
806
+ }else{
807
+ if(searchDialogConfig.tableEnabled){
808
+ if(!searchDialogConfig.tableRef || !tableData.length)return
809
+ let addRows = rows.map(rowData=>{
810
+ let itemData = {};
811
+ tableData.forEach(item=>{
812
+ itemData[item.targetField] = rowData[item.sourceField]
813
+ })
814
+ return itemData;
815
+ });
816
+ this.getWidgetRef(searchDialogConfig.tableRef).addTableData(addRows,searchDialogConfig.tableUniqueKey);
817
+ }
818
+ }
819
+ }*/
820
+ },
821
+ });
822
+ },
823
+ handleClearSearchDialog() {
824
+ let clickBindEvent = this.field.options.clickBindEvent;
825
+ if (clickBindEvent == "1") {
826
+ this.handleConfirmSearchDialog(null, true);
827
+ }
828
+ },
829
+ getMultipleChoices() {
830
+ let multipleChoices = this.field.options.multipleChoices;
831
+ return multipleChoices;
832
+ },
833
+ handleConfirmSearchDialog(rows, isClear) {
834
+ if (!isClear && !rows.length) return;
835
+ let tableParam = this.tableParam;
836
+ let searchDialogConfig = this.field.options.searchDialogConfig || {};
837
+ let formCode = searchDialogConfig.formCode;
838
+ let tableData = searchDialogConfig.tableData || [];
839
+ let formModel = this.formModel;
840
+ let row = rows && rows.length ? rows[0] : null;
841
+ let multipleChoices =
842
+ this.field.options.searchDialogConfig.multipleChoices || false;
843
+ if (this.field.type == "vabsearch") {
844
+ let fieldKeyName = this.fieldKeyName;
845
+ let valueField = this.field.options.valueField || fieldKeyName;
846
+ let vabSearchName = this.field.options.vabSearchName || fieldKeyName;
847
+
848
+ if (tableParam) {
849
+ let rowData = tableParam.row;
850
+ if (multipleChoices) {
851
+ if (isClear) {
852
+ rowData[fieldKeyName] = [];
853
+ } else {
854
+ rowData[fieldKeyName] = rows.map((item) => {
855
+ let newData = {};
856
+ newData[valueField] =
857
+ item[searchDialogConfig.valueSourceField] ?? null;
858
+ newData[vabSearchName] =
859
+ item[searchDialogConfig.labelSourceField] ?? null;
860
+ tableData.forEach((item1) => {
861
+ newData[item1.targetField] = item[item1.sourceField];
862
+ });
863
+ return newData;
864
+ });
865
+ }
866
+ } else {
867
+ rowData[fieldKeyName] = !isClear
868
+ ? row[searchDialogConfig.valueSourceField]
869
+ : null;
870
+ if (searchDialogConfig.labelSourceField)
871
+ rowData[vabSearchName] = !isClear
872
+ ? row[searchDialogConfig.labelSourceField]
873
+ : null;
874
+ tableData.forEach((item) => {
875
+ if (!isClear) {
876
+ rowData[item.targetField] = row[item.sourceField];
877
+ } else {
878
+ rowData[item.targetField] = null;
879
+ }
880
+ });
881
+ }
882
+ } else {
883
+ this.fieldModel = !isClear
884
+ ? row[searchDialogConfig.valueSourceField]
885
+ : null;
886
+ if (searchDialogConfig.labelSourceField) {
887
+ this.setShowValue(
888
+ !isClear ? row[searchDialogConfig.labelSourceField] : null
889
+ );
890
+ }
891
+ tableData.forEach((item) => {
892
+ // formModel[item.targetField] = row[item.sourceField]
893
+ let value = !isClear ? row[item.sourceField] ?? null : null;
894
+ this.getWidgetRef(item.targetField).setValue(value);
895
+ // formModel[item.targetField] = value;
896
+ });
897
+ // this.$forceUpdate();
898
+ }
899
+ } else {
900
+ if (searchDialogConfig.tableEnabled) {
901
+ if (!searchDialogConfig.tableRef || !tableData.length) return;
902
+ let addRows = rows.map((rowData) => {
903
+ let itemData = {};
904
+ tableData.forEach((item) => {
905
+ itemData[item.targetField] = rowData[item.sourceField];
906
+ });
907
+ return itemData;
908
+ });
909
+ this.getWidgetRef(searchDialogConfig.tableRef).addTableData(
910
+ addRows,
911
+ searchDialogConfig.tableUniqueKey
912
+ );
913
+ } else if (!multipleChoices) {
914
+ tableData.forEach((item) => {
915
+ let value = row[item.sourceField] ?? null;
916
+ // formModel[item.targetField] = value
917
+ this.getWidgetRef(item.targetField).setValue(value);
918
+ });
919
+ // this.$forceUpdate();
920
+ }
921
+ }
922
+
923
+ if (!isClear) {
924
+ this.$nextTick(() => {
925
+ this.handleCustomEvent(
926
+ searchDialogConfig.confirmCallback,
927
+ ["rows"],
928
+ [rows]
929
+ );
930
+ });
931
+ }
932
+ },
933
+ remoteQuery: function (e) {
934
+ if (this.field.options.onRemoteQuery) {
935
+ var t = new Function("keyword", this.field.options.onRemoteQuery);
936
+ t.call(this, e);
937
+ }
938
+ },
939
+ getFormRef: function () {
940
+ return this.refList ? this.refList["v_form_ref"] : null;
941
+ },
942
+ getWidgetRef: function (e, t) {
943
+ var i = this.refList[e];
944
+ return (
945
+ !i &&
946
+ t &&
947
+ this.$message.error(this.i18nt("render.hint.refNotFound") + e),
948
+ i
949
+ );
950
+ },
951
+ getFieldEditor: function () {
952
+ return this.$refs["fieldEditor"];
953
+ },
954
+ setValue: function (e) {
955
+ if (this.field.formItemFlag) {
956
+ let value = e ?? null;
957
+ var t = baseRefUtil.deepClone(this.fieldModel);
958
+ (this.fieldModel = value),
959
+ this.initFileList(),
960
+ this.syncUpdateFormModel(value),
961
+ this.emitFieldDataChange(value, t);
962
+ }
963
+ },
964
+ getValue: function () {
965
+ return this.fieldModel;
966
+ },
967
+ resetField: function () {
968
+ if (!this.subFormItemFlag) {
969
+ var e = this.field.options.defaultValue;
970
+ this.setValue(e),
971
+ ("picture-upload" !== this.field.type &&
972
+ "file-upload" !== this.field.type) ||
973
+ (this.$refs["fieldEditor"].clearFiles(),
974
+ this.fileList.splice(0, this.fileList.length));
975
+ }
976
+ },
977
+ setWidgetOption: function (e, t) {
978
+ this.field.options.hasOwnProperty(e) && (this.field.options[e] = t);
979
+ },
980
+ setReadonly: function (e) {
981
+ this.field.options.readonly = e;
982
+ },
983
+ setDisabled: function (e) {
984
+ this.field.options.disabled = e;
985
+ },
986
+ setAppendButtonVisible: function (e) {
987
+ this.field.options.appendButton = e;
988
+ },
989
+ setAppendButtonDisabled: function (e) {
990
+ this.field.options.appendButtonDisabled = e;
991
+ },
992
+ setHidden: function (e) {
993
+ (this.field.options.hidden = e),
994
+ e ? this.clearFieldRules() : this.buildFieldRules();
995
+ },
996
+ setRequired: function (e) {
997
+ (this.field.options.required = e), this.buildFieldRules();
998
+ },
999
+ setLabel: function (e) {
1000
+ this.field.options.label = e;
1001
+ },
1002
+ focus: function () {
1003
+ this.getFieldEditor() &&
1004
+ this.getFieldEditor().focus &&
1005
+ this.getFieldEditor().focus();
1006
+ },
1007
+ clearSelectedOptions: function () {
1008
+ ("checkbox" !== this.field.type &&
1009
+ "radio" !== this.field.type &&
1010
+ "select" !== this.field.type) ||
1011
+ ("checkbox" === this.field.type ||
1012
+ ("select" === this.field.type && this.field.options.multiple)
1013
+ ? (this.fieldModel = [])
1014
+ : (this.fieldModel = ""));
1015
+ },
1016
+ loadOptions: function (e) {
1017
+ this.field.options.optionItems = baseRefUtil.translateOptionItems(
1018
+ e,
1019
+ this.field.type,
1020
+ this.field.options.labelKey || "label",
1021
+ this.field.options.valueKey || "value"
1022
+ );
1023
+ },
1024
+ reloadOptions: function (e) {
1025
+ this.field.options.optionItems = baseRefUtil.translateOptionItems(
1026
+ e,
1027
+ this.field.type,
1028
+ this.field.options.labelKey || "label",
1029
+ this.field.options.valueKey || "value"
1030
+ );
1031
+ },
1032
+ getOptions: function () {
1033
+ return this.field.options.optionItems;
1034
+ },
1035
+ disableOption: function (e) {
1036
+ this.disableOptionOfList(this.field.options.optionItems, e);
1037
+ },
1038
+ enableOption: function (e) {
1039
+ this.enableOptionOfList(this.field.options.optionItems, e);
1040
+ },
1041
+ getOptionItems: function () {
1042
+ return this.field.options.optionItems;
1043
+ },
1044
+ setUploadHeader: function (e, t) {
1045
+ this.$set(this.uploadHeaders, e, t);
1046
+ },
1047
+ setUploadData: function (e, t) {
1048
+ this.$set(this.uploadData, e, t);
1049
+ },
1050
+ setToolbar: function (e) {
1051
+ this.customToolbar = e;
1052
+ },
1053
+ isSubFormItem: function () {
1054
+ return this.subFormItemFlag;
1055
+ },
1056
+ isSubFormField: function () {
1057
+ return this.subFormItemFlag;
1058
+ },
1059
+ setReadMode: function () {
1060
+ var e =
1061
+ !(arguments.length > 0 && void 0 !== arguments[0]) || arguments[0];
1062
+ this.fieldReadonlyFlag = e;
1063
+ },
1064
+ addCssClass: function (e) {
1065
+ this.field.options.customClass
1066
+ ? this.field.options.customClass.push(e)
1067
+ : (this.field.options.customClass = [e]);
1068
+ },
1069
+ removeCssClass: function (e) {
1070
+ if (this.field.options.customClass) {
1071
+ var t = -1;
1072
+ this.field.options.customClass.map(function (i, n) {
1073
+ i === e && (t = n);
1074
+ }),
1075
+ t > -1 && this.field.options.customClass.splice(t, 1);
1076
+ }
1077
+ },
1078
+ async initAccess() {
1079
+ if (this.field.options.accessCode) {
1080
+ return this.$http({
1081
+ url: SUPPORT_PREFIX + `/report_requestaccess/getByCode`,
1082
+ method: `post`,
1083
+ data: {
1084
+ stringOne: this.field.options.accessCode,
1085
+ },
1086
+ isLoading: true,
1087
+ // modalStrictly: true,
1088
+ success: (res) => {
1089
+ let requestAccess = res.objx || {};
1090
+
1091
+ let dsModel = {};
1092
+ if (requestAccess.accessViewContent) {
1093
+ dsModel = JSON.parse(requestAccess.accessViewContent);
1094
+ }
1095
+ if (!dsModel.headers) dsModel.headers = [];
1096
+ if (!dsModel.params) dsModel.params = [];
1097
+ if (!dsModel.data) dsModel.data = [];
1098
+ if (dsModel.dataHandlerCode == null) dsModel.dataHandlerCode = "";
1099
+ if (dsModel.configHandlerCode == null)
1100
+ dsModel.configHandlerCode = "";
1101
+ if (dsModel.errorHandlerCode == null) dsModel.errorHandlerCode = "";
1102
+
1103
+ requestAccess.dsModel = dsModel;
1104
+ this.requestAccess = requestAccess;
1105
+ },
1106
+ });
1107
+ } else {
1108
+ return null;
1109
+ }
1110
+ },
1111
+ addExtraAccessData(data) {
1112
+ if (data) {
1113
+ Object.keys(data).forEach((field) => {
1114
+ this.extraAccessData[field] = data[field];
1115
+ });
1116
+ }
1117
+ },
1118
+ clearExtraAccessData() {
1119
+ this.extraAccessData = {};
1120
+ },
1121
+ doAccess(accessCode, conditions, callback) {
1122
+ let path = baseRefUtil.getAccessUrl();
1123
+ let globalReqData = baseRefUtil.getReportGlobalMap(); //全局请求参数
1124
+ return this.$http({
1125
+ url: path,
1126
+ method: `post`,
1127
+ loadingTarget: document.body,
1128
+ data: {
1129
+ accessCode: accessCode,
1130
+ conditions: {
1131
+ ...conditions,
1132
+ ...globalReqData,
1133
+ },
1134
+ },
1135
+ isLoading: true,
1136
+ success: (res) => {
1137
+ callback && callback(res);
1138
+ },
1139
+ });
1140
+ },
1141
+ autoExcScript() {
1142
+ if (!this.designState && this.field.options.accessAutoExc) {
1143
+ this.scriptHttp({
1144
+ options: this.field.options,
1145
+ });
1146
+ }
1147
+ },
1148
+ addInterval(handler, timeout) {
1149
+ let timer = setInterval(handler, timeout);
1150
+ this.timerMap[timer] = timer;
1151
+ return timer;
1152
+ },
1153
+ clearAllInterval() {
1154
+ let timerMap = this.timerMap;
1155
+ for (let key in timerMap) {
1156
+ let timer = timerMap[key];
1157
+ clearInterval(timer);
1158
+ }
1159
+ this.timerMap = {};
1160
+ },
1161
+ getI18nLabel(label, path, param) {
1162
+ return !this.designState && label ? this.$t2(label, path, param) : label;
1163
+ },
1164
+ getParentTarget() {
1165
+ let name = this.parentWidget?.options?.name ?? null;
1166
+ return name ? this.getWidgetRef(name) : null;
1167
+ },
1168
+ },
1169
+ };
1170
+
1171
+ export default modules;