cloud-web-corejs 1.0.315 → 1.0.317

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.
Files changed (25) hide show
  1. package/package.json +1 -1
  2. package/src/components/hiprint/view/json-view.vue +4 -4
  3. package/src/components/mobile/wf/content.vue +2 -2
  4. package/src/components/xform/form-designer/designer.js +1 -0
  5. package/src/components/xform/form-designer/form-widget/dialog/formDialog.vue +30 -4
  6. package/src/components/xform/form-designer/form-widget/dialog/searchFormDialog.vue +27 -4
  7. package/src/components/xform/form-designer/setting-panel/form-setting.vue +60 -39
  8. package/src/components/xform/form-designer/setting-panel/property-editor/container-tab/tab-lazyRender-editor.vue +27 -0
  9. package/src/components/xform/form-designer/setting-panel/property-editor/event-handler/onTabChange-editor.vue +28 -0
  10. package/src/components/xform/form-designer/setting-panel/property-editor/event-handler/onTabClick-editor.vue +28 -0
  11. package/src/components/xform/form-designer/setting-panel/property-editor/project-tag-editor.vue +2 -4
  12. package/src/components/xform/form-designer/setting-panel/propertyRegister.js +8 -3
  13. package/src/components/xform/form-designer/widget-panel/widgetsConfig.js +9 -0
  14. package/src/components/xform/form-render/container-item/containerItemMixin.js +489 -404
  15. package/src/components/xform/form-render/container-item/data-table-mixin.js +1 -0
  16. package/src/components/xform/form-render/container-item/panel-item.vue +1 -1
  17. package/src/components/xform/form-render/container-item/tab-item.vue +48 -0
  18. package/src/components/xform/form-render/indexMixin.js +17 -2
  19. package/src/components/xform/form-render/pageDialogScope.js +54 -0
  20. package/src/components/xform/icon-picker/index.vue +1 -1
  21. package/src/components/xform/lang/en-US.js +3 -0
  22. package/src/components/xform/lang/zh-CN.js +3 -0
  23. package/src/components/xform/utils/util.js +1 -0
  24. package/src/directive/el-drag-dialog/drag.js +32 -2
  25. package/src/views/user/form/view/list.vue +24 -1
@@ -1,404 +1,489 @@
1
- import {
2
- traverseFieldWidgetsOfContainer,
3
- traverseWidgetsOfContainer,
4
- } from "../../../../components/xform/utils/util";
5
- import {
6
- getReportGlobalMap,
7
- getAccessUrl,
8
- } from "../../../../components/xform/utils/util";
9
- import scriptHttpMixin from "../../../../components/xform/mixins/scriptHttp";
10
- import defaultHandleMixin from "../../../../components/xform/mixins/defaultHandle";
11
- import settingConfig from "@/settings.js";
12
- let modules = {};
13
- const isDev = process.env.NODE_ENV === "development";
14
- const baseRefUtil = {
15
- traverseFieldWidgetsOfContainer,
16
- getReportGlobalMap,
17
- getAccessUrl,
18
- };
19
- modules = {
20
- props: {
21
- tableParam: {
22
- type: Object,
23
- default: null,
24
- },
25
- formItemProp: {
26
- type: String,
27
- default: null,
28
- },
29
- },
30
- mixins: [scriptHttpMixin, defaultHandleMixin],
31
- inject: ["widgetKeyNameMap", "doScriptAccess", "getReportTemplate"],
32
- data() {
33
- return {
34
- extraAccessData: {},
35
- timerMap: {},
36
- };
37
- },
38
- computed: {
39
- customClass() {
40
- return this.widget.options.customClass || "";
41
- },
42
-
43
- formModel: {
44
- cache: false,
45
- get() {
46
- return this.globalModel.formModel;
47
- },
48
- },
49
- fieldKeyName() {
50
- let o = this.widget.options.name;
51
- return (
52
- (this.widget.options.keyNameEnabled && this.widget.options.keyName) || o
53
- );
54
- },
55
- },
56
- beforeDestroy() {
57
- this.clearAllInterval();
58
- },
59
- created() {},
60
- mounted() {
61
- this.callSetHidden();
62
- },
63
- methods: {
64
- setFormScriptEnabled(value) {
65
- this.widget.options.formScriptEnabled = value || false;
66
- },
67
- unregisterFromRefList() {
68
- //销毁容器组件时注销组件ref
69
- // 注销 key 必须与 refMixin.initRefList 对齐:行内容器注册的是 name + "@row" + rowIndex,
70
- // 且 initRefList 会无条件注册一份不带后缀的 name。仅当 key 仍指向当前实例时才删除,
71
- // 避免同名容器重建时误删新注册的实例。
72
- if (this.refList !== null && !!this.widget.options.name) {
73
- let name = this.widget.options.name;
74
- let inRow =
75
- this.subFormRowIndex !== -1 &&
76
- this.subFormRowIndex !== void 0 &&
77
- !!this.tableParam;
78
- let key = inRow ? name + "@row" + this.tableParam.rowIndex : name;
79
- if (this.refList[key] === this) {
80
- delete this.refList[key];
81
- }
82
- if (key !== name && this.refList[name] === this) {
83
- delete this.refList[name];
84
- }
85
- }
86
- },
87
-
88
- /* 主动触发setHidden()方法,以清空被隐藏容器内字段组件的校验规则!! */
89
- callSetHidden() {
90
- if (this.widget.options.hidden === true) {
91
- this.setHidden(true);
92
- }
93
- },
94
-
95
- //--------------------- 以下为组件支持外部调用的API方法 begin ------------------//
96
- /* 提示:用户可自行扩充这些方法!!! */
97
-
98
- setHidden(flag) {
99
- this.widget.options.hidden = flag;
100
-
101
- /* 容器被隐藏后,需要同步清除容器内部字段组件的校验规则 */
102
- let clearRulesFn = (fieldWidget) => {
103
- let fwName = fieldWidget.options.name;
104
- let fwRef = this.getWidgetRef(fwName);
105
- if (flag && !!fwRef && !!fwRef.clearFieldRules) {
106
- fwRef.clearFieldRules();
107
- }
108
-
109
- if (!flag && !!fwRef && !!fwRef.buildFieldRules) {
110
- fwRef.buildFieldRules();
111
- }
112
- };
113
-
114
- baseRefUtil.traverseFieldWidgetsOfContainer(this.widget, clearRulesFn);
115
- },
116
- /**
117
- * 禁用或启用容器组件(包含容器内部的所有组件)
118
- * @param flag
119
- */
120
- /* setDisabled(flag) {
121
- const fwHandler = (fw) => {
122
- const fwName = fw.options.name
123
- const fwRef = this.getWidgetRef(fwName)
124
- if (!!fwRef && !!fwRef.setDisabled) {
125
- fwRef.setDisabled(flag, true)
126
- }
127
- }
128
- const cwHandler = (cw) => {
129
- if (cw.id === this.widget.id) { //避免死循环!!!
130
- return
131
- }
132
-
133
- const cwName = cw.options.name
134
- const cwRef = this.getWidgetRef(cwName)
135
- if (!!cwRef && !!cwRef.setDisabled) {
136
- cwRef.setDisabled(flag)
137
- }
138
- }
139
- traverseWidgetsOfContainer(this.widget, fwHandler, cwHandler)
140
-
141
- //注意:单行子表单、多行子表单容器的setDisabled方法由单行子表单、多行子表单组件自己实现!!
142
- }, */
143
-
144
- activeTab(tabIndex) {
145
- //tabIndex从0计数
146
- if (tabIndex >= 0 && tabIndex < this.widget.tabs.length) {
147
- this.widget.tabs.forEach((tp, idx) => {
148
- tp.options.active = idx === tabIndex;
149
- if (idx === tabIndex) {
150
- this.activeTabName = tp.options.name;
151
- }
152
- });
153
- }
154
- },
155
-
156
- disableTab(tabIndex) {
157
- if (tabIndex >= 0 && tabIndex < this.widget.tabs.length) {
158
- this.widget.tabs[tabIndex].options.disabled = true;
159
- }
160
- },
161
-
162
- enableTab(tabIndex) {
163
- if (tabIndex >= 0 && tabIndex < this.widget.tabs.length) {
164
- this.widget.tabs[tabIndex].options.disabled = false;
165
- }
166
- },
167
-
168
- hideTab(tabIndex) {
169
- if (tabIndex >= 0 && tabIndex < this.widget.tabs.length) {
170
- this.widget.tabs[tabIndex].options.hidden = true;
171
- }
172
- },
173
-
174
- showTab(tabIndex) {
175
- if (tabIndex >= 0 && tabIndex < this.widget.tabs.length) {
176
- this.widget.tabs[tabIndex].options.hidden = false;
177
- }
178
- },
179
-
180
- setWidgetOption(optionName, optionValue) {
181
- //通用组件选项修改API
182
- if (this.widget.options.hasOwnProperty(optionName)) {
183
- this.widget.options[optionName] = optionValue;
184
- }
185
- },
186
-
187
- /**
188
- * 获取子表单的行数
189
- */
190
- getSubFormRowCount() {
191
- return !this.rowIdData ? 0 : this.rowIdData.length;
192
- },
193
-
194
- disableSubFormRow(rowIndex) {
195
- this.widget.widgetList.forEach((subWidget) => {
196
- let swRefName =
197
- subWidget.options.name + "@row" + this.rowIdData[rowIndex];
198
- let foundSW = this.getWidgetRef(swRefName);
199
- if (!!foundSW) {
200
- foundSW.setDisabled(true);
201
- }
202
- });
203
- },
204
-
205
- enableSubFormRow(rowIndex) {
206
- this.widget.widgetList.forEach((subWidget) => {
207
- let swRefName =
208
- subWidget.options.name + "@row" + this.rowIdData[rowIndex];
209
- let foundSW = this.getWidgetRef(swRefName);
210
- if (!!foundSW) {
211
- foundSW.setDisabled(false);
212
- }
213
- });
214
- },
215
-
216
- disableSubForm() {
217
- if (this.rowIdData.length > 0) {
218
- this.rowIdData.forEach((dataRow, rIdx) => {
219
- this.disableSubFormRow(rIdx);
220
- });
221
- }
222
-
223
- //禁用3个操作按钮
224
- this.actionDisabled = true;
225
- },
226
-
227
- enableSubForm() {
228
- if (this.rowIdData.length > 0) {
229
- this.rowIdData.forEach((dataRow, rIdx) => {
230
- this.enableSubFormRow(rIdx);
231
- });
232
- }
233
-
234
- //启用3个操作按钮
235
- this.actionDisabled = false;
236
- },
237
-
238
- resetSubForm() {
239
- //重置subForm数据为空
240
- if (this.widget.type === "sub-form") {
241
- let subFormModel = this.formModel[this.widget.options.name];
242
- if (!!subFormModel) {
243
- subFormModel.splice(0, subFormModel.length);
244
- this.rowIdData.splice(0, this.rowIdData.length);
245
- }
246
-
247
- if (this.widget.options.showBlankRow) {
248
- this.addSubFormRow();
249
- }
250
- }
251
- },
252
-
253
- getSubFormValues(needValidation = true) {
254
- if (this.widget.type === "sub-form") {
255
- //TODO: 逐行校验子表单!暂未实现!!
256
- return this.formModel[this.widget.options.name];
257
- } else {
258
- this.$message.error(this.i18nt("render.hint.nonSubFormType"));
259
- }
260
- },
261
-
262
- setSubFormValues(subFormValues) {
263
- //TODO: 待实现!!
264
- },
265
-
266
- // validateField(fieldName) { //逐行校验子表单字段
267
- // //TODO:
268
- // },
269
- //
270
- // validateSubForm() { //逐行校验子表单全部字段
271
- // //TODO:
272
- // },
273
-
274
- /**
275
- * 动态增加自定义css样式
276
- * @param className
277
- */
278
- addCssClass(className) {
279
- if (!this.widget.options.customClass) {
280
- this.widget.options.customClass = [className];
281
- } else {
282
- this.widget.options.customClass.push(className);
283
- }
284
- },
285
-
286
- /**
287
- * 动态移除自定义css样式
288
- * @param className
289
- */
290
- removeCssClass(className) {
291
- if (!this.widget.options.customClass) {
292
- return;
293
- }
294
-
295
- let foundIdx = -1;
296
- this.widget.options.customClass.map((cc, idx) => {
297
- if (cc === className) {
298
- foundIdx = idx;
299
- }
300
- });
301
- if (foundIdx > -1) {
302
- this.widget.options.customClass.splice(foundIdx, 1);
303
- }
304
- },
305
- handleOnCreated: function () {
306
- this.handleCustomEvent(this.widget.options.onCreated);
307
- },
308
- handleOnMounted: function () {
309
- this.handleCustomEvent(this.widget.options.onMounted);
310
- // this.autoExcScript();
311
- },
312
- addExtraAccessData(data) {
313
- if (data) {
314
- Object.keys(data).forEach((field) => {
315
- this.extraAccessData[field] = data[field];
316
- });
317
- }
318
- },
319
- clearExtraAccessData() {
320
- this.extraAccessData = {};
321
- },
322
- doAccess(accessCode, conditions, callback) {
323
- let path = baseRefUtil.getAccessUrl();
324
- let globalReqData = baseRefUtil.getReportGlobalMap(); //全局请求参数
325
- return this.$http({
326
- url: path,
327
- method: `post`,
328
- loadingTarget: document.body,
329
- data: {
330
- accessCode: accessCode,
331
- conditions: {
332
- ...conditions,
333
- ...globalReqData,
334
- },
335
- },
336
- isLoading: true,
337
- success: (res) => {
338
- callback && callback(res.objx);
339
- },
340
- });
341
- },
342
- //--------------------- 以上为组件支持外部调用的API方法 end ------------------//
343
- getEventParam() {
344
- let formRef = this.getFormRef();
345
- let dataId = formRef?.dataId;
346
- let formCode = formRef?.reportTemplate?.formCode;
347
- return {
348
- eventParamNames: ["dataId", "formCode"],
349
- eventParamValues: [dataId, formCode],
350
- };
351
- },
352
- handleCustomEvent(funtionStr, eventParamNames = [], eventParamValues = []) {
353
- if (!this.designState && funtionStr) {
354
- let eventParam = this.getEventParam();
355
- var e = new Function(
356
- ...eventParam.eventParamNames,
357
- ...eventParamNames,
358
- funtionStr
359
- );
360
- // return e.call(this, ...eventParam.eventParamValues, ...eventParamValues);
361
- let that = this;
362
- try {
363
- return e.call(
364
- this,
365
- ...eventParam.eventParamValues,
366
- ...eventParamValues
367
- );
368
- } catch (error) {
369
- if (settingConfig.fontErrorTipEnabled) {
370
- that.$errorMsg({
371
- rmid: that.$t1("前端脚本异常"),
372
- content: error.message,
373
- type: "error",
374
- _errorMsg: error.stack,
375
- });
376
- }
377
- throw error;
378
- }
379
- }
380
- },
381
- addInterval(handler, timeout) {
382
- let timer = setInterval(handler, timeout);
383
- this.timerMap[timer] = timer;
384
- return timer;
385
- },
386
- clearAllInterval() {
387
- let timerMap = this.timerMap;
388
- for (let key in timerMap) {
389
- let timer = timerMap[key];
390
- clearInterval(timer);
391
- }
392
- this.timerMap = {};
393
- },
394
- getI18nLabel(label, path, param) {
395
- return !this.designState && label ? this.$t2(label, path, param) : label;
396
- },
397
- getParentTarget() {
398
- let name = this.parentWidget?.options?.name ?? null;
399
- return name ? this.getWidgetRef(name) : null;
400
- },
401
- },
402
- };
403
-
404
- export default modules;
1
+ import {
2
+ traverseFieldWidgetsOfContainer,
3
+ traverseWidgetsOfContainer,
4
+ } from "../../../../components/xform/utils/util";
5
+ import {
6
+ getReportGlobalMap,
7
+ getAccessUrl,
8
+ } from "../../../../components/xform/utils/util";
9
+ import scriptHttpMixin from "../../../../components/xform/mixins/scriptHttp";
10
+ import defaultHandleMixin from "../../../../components/xform/mixins/defaultHandle";
11
+ import settingConfig from "@/settings.js";
12
+ let modules = {};
13
+ const isDev = process.env.NODE_ENV === "development";
14
+ const baseRefUtil = {
15
+ traverseFieldWidgetsOfContainer,
16
+ getReportGlobalMap,
17
+ getAccessUrl,
18
+ };
19
+ modules = {
20
+ props: {
21
+ tableParam: {
22
+ type: Object,
23
+ default: null,
24
+ },
25
+ formItemProp: {
26
+ type: String,
27
+ default: null,
28
+ },
29
+ },
30
+ mixins: [scriptHttpMixin, defaultHandleMixin],
31
+ inject: ["widgetKeyNameMap", "doScriptAccess", "getReportTemplate"],
32
+ data() {
33
+ return {
34
+ extraAccessData: {},
35
+ timerMap: {},
36
+ };
37
+ },
38
+ computed: {
39
+ customClass() {
40
+ return this.widget.options.customClass || "";
41
+ },
42
+
43
+ formModel: {
44
+ cache: false,
45
+ get() {
46
+ return this.globalModel.formModel;
47
+ },
48
+ },
49
+ fieldKeyName() {
50
+ let o = this.widget.options.name;
51
+ return (
52
+ (this.widget.options.keyNameEnabled && this.widget.options.keyName) || o
53
+ );
54
+ },
55
+ },
56
+ beforeDestroy() {
57
+ this.clearAllInterval();
58
+ },
59
+ created() {},
60
+ mounted() {
61
+ this.callSetHidden();
62
+ },
63
+ methods: {
64
+ setFormScriptEnabled(value) {
65
+ this.widget.options.formScriptEnabled = value || false;
66
+ },
67
+ unregisterFromRefList() {
68
+ //销毁容器组件时注销组件ref
69
+ // 注销 key 必须与 refMixin.initRefList 对齐:行内容器注册的是 name + "@row" + rowIndex,
70
+ // 且 initRefList 会无条件注册一份不带后缀的 name。仅当 key 仍指向当前实例时才删除,
71
+ // 避免同名容器重建时误删新注册的实例。
72
+ if (this.refList !== null && !!this.widget.options.name) {
73
+ let name = this.widget.options.name;
74
+ let inRow
75
+ = this.subFormRowIndex !== -1
76
+ && this.subFormRowIndex !== void 0
77
+ && !!this.tableParam;
78
+ let key = inRow ? name + "@row" + this.tableParam.rowIndex : name;
79
+ if (this.refList[key] === this) {
80
+ delete this.refList[key];
81
+ }
82
+ if (key !== name && this.refList[name] === this) {
83
+ delete this.refList[name];
84
+ }
85
+ }
86
+ },
87
+
88
+ /* 主动触发setHidden()方法,以清空被隐藏容器内字段组件的校验规则!! */
89
+ callSetHidden() {
90
+ if (this.widget.options.hidden === true) {
91
+ this.setHidden(true);
92
+ }
93
+ },
94
+
95
+ //--------------------- 以下为组件支持外部调用的API方法 begin ------------------//
96
+ /* 提示:用户可自行扩充这些方法!!! */
97
+
98
+ setHidden(flag) {
99
+ this.widget.options.hidden = flag;
100
+
101
+ /* 容器被隐藏后,需要同步清除容器内部字段组件的校验规则 */
102
+ let clearRulesFn = (fieldWidget) => {
103
+ let fwName = fieldWidget.options.name;
104
+ let fwRef = this.getWidgetRef(fwName);
105
+ if (flag && !!fwRef && !!fwRef.clearFieldRules) {
106
+ fwRef.clearFieldRules();
107
+ }
108
+
109
+ if (!flag && !!fwRef && !!fwRef.buildFieldRules) {
110
+ fwRef.buildFieldRules();
111
+ }
112
+ };
113
+
114
+ baseRefUtil.traverseFieldWidgetsOfContainer(this.widget, clearRulesFn);
115
+ },
116
+ /**
117
+ * 禁用或启用容器组件(包含容器内部的所有组件)
118
+ * @param flag
119
+ */
120
+ /* setDisabled(flag) {
121
+ const fwHandler = (fw) => {
122
+ const fwName = fw.options.name
123
+ const fwRef = this.getWidgetRef(fwName)
124
+ if (!!fwRef && !!fwRef.setDisabled) {
125
+ fwRef.setDisabled(flag, true)
126
+ }
127
+ }
128
+ const cwHandler = (cw) => {
129
+ if (cw.id === this.widget.id) { //避免死循环!!!
130
+ return
131
+ }
132
+
133
+ const cwName = cw.options.name
134
+ const cwRef = this.getWidgetRef(cwName)
135
+ if (!!cwRef && !!cwRef.setDisabled) {
136
+ cwRef.setDisabled(flag)
137
+ }
138
+ }
139
+ traverseWidgetsOfContainer(this.widget, fwHandler, cwHandler)
140
+
141
+ //注意:单行子表单、多行子表单容器的setDisabled方法由单行子表单、多行子表单组件自己实现!!
142
+ }, */
143
+
144
+ activeTab(tabIndex) {
145
+ //tabIndex从0计数
146
+ if (tabIndex >= 0 && tabIndex < this.widget.tabs.length) {
147
+ this.widget.tabs.forEach((tp, idx) => {
148
+ tp.options.active = idx === tabIndex;
149
+ if (idx === tabIndex) {
150
+ this.activeTabName = tp.options.name;
151
+ }
152
+ });
153
+ }
154
+ },
155
+
156
+ getTabIndexByName(name) {
157
+ //按页签的 options.name(el-tabs pane name)找下标;不存在返回 -1
158
+ return (this.widget.tabs || []).findIndex((tp) => tp.options.name === name);
159
+ },
160
+
161
+ getTabIndexByLabel(label) {
162
+ //按页签显示名找下标:同时比对配置值与 i18n 翻译值(页面上看到的是翻译后的文案);
163
+ //重名页签取第一个
164
+ return (this.widget.tabs || []).findIndex((tp) => {
165
+ let tpLabel = tp.options.label;
166
+ return tpLabel === label || this.getI18nLabel(tpLabel) === label;
167
+ });
168
+ },
169
+
170
+ activeTabByName(name) {
171
+ //按页签名切换,脚本里免去找下标;未找到时静默忽略
172
+ let index = this.getTabIndexByName(name);
173
+ if (index >= 0) {
174
+ this.activeTab(index);
175
+ }
176
+ },
177
+
178
+ activeTabByLabel(label) {
179
+ let index = this.getTabIndexByLabel(label);
180
+ if (index >= 0) {
181
+ this.activeTab(index);
182
+ }
183
+ },
184
+
185
+ disableTabByName(name) {
186
+ let index = this.getTabIndexByName(name);
187
+ if (index >= 0) {
188
+ this.disableTab(index);
189
+ }
190
+ },
191
+
192
+ disableTabByLabel(label) {
193
+ let index = this.getTabIndexByLabel(label);
194
+ if (index >= 0) {
195
+ this.disableTab(index);
196
+ }
197
+ },
198
+
199
+ enableTabByName(name) {
200
+ let index = this.getTabIndexByName(name);
201
+ if (index >= 0) {
202
+ this.enableTab(index);
203
+ }
204
+ },
205
+
206
+ enableTabByLabel(label) {
207
+ let index = this.getTabIndexByLabel(label);
208
+ if (index >= 0) {
209
+ this.enableTab(index);
210
+ }
211
+ },
212
+
213
+ hideTabByName(name) {
214
+ let index = this.getTabIndexByName(name);
215
+ if (index >= 0) {
216
+ this.hideTab(index);
217
+ }
218
+ },
219
+
220
+ hideTabByLabel(label) {
221
+ let index = this.getTabIndexByLabel(label);
222
+ if (index >= 0) {
223
+ this.hideTab(index);
224
+ }
225
+ },
226
+
227
+ showTabByName(name) {
228
+ let index = this.getTabIndexByName(name);
229
+ if (index >= 0) {
230
+ this.showTab(index);
231
+ }
232
+ },
233
+
234
+ showTabByLabel(label) {
235
+ let index = this.getTabIndexByLabel(label);
236
+ if (index >= 0) {
237
+ this.showTab(index);
238
+ }
239
+ },
240
+
241
+ disableTab(tabIndex) {
242
+ if (tabIndex >= 0 && tabIndex < this.widget.tabs.length) {
243
+ this.widget.tabs[tabIndex].options.disabled = true;
244
+ }
245
+ },
246
+
247
+ enableTab(tabIndex) {
248
+ if (tabIndex >= 0 && tabIndex < this.widget.tabs.length) {
249
+ this.widget.tabs[tabIndex].options.disabled = false;
250
+ }
251
+ },
252
+
253
+ hideTab(tabIndex) {
254
+ if (tabIndex >= 0 && tabIndex < this.widget.tabs.length) {
255
+ this.widget.tabs[tabIndex].options.hidden = true;
256
+ }
257
+ },
258
+
259
+ showTab(tabIndex) {
260
+ if (tabIndex >= 0 && tabIndex < this.widget.tabs.length) {
261
+ this.widget.tabs[tabIndex].options.hidden = false;
262
+ }
263
+ },
264
+
265
+ setWidgetOption(optionName, optionValue) {
266
+ //通用组件选项修改API
267
+ if (this.widget.options.hasOwnProperty(optionName)) {
268
+ this.widget.options[optionName] = optionValue;
269
+ }
270
+ },
271
+
272
+ /**
273
+ * 获取子表单的行数
274
+ */
275
+ getSubFormRowCount() {
276
+ return !this.rowIdData ? 0 : this.rowIdData.length;
277
+ },
278
+
279
+ disableSubFormRow(rowIndex) {
280
+ this.widget.widgetList.forEach((subWidget) => {
281
+ let swRefName
282
+ = subWidget.options.name + "@row" + this.rowIdData[rowIndex];
283
+ let foundSW = this.getWidgetRef(swRefName);
284
+ if (!!foundSW) {
285
+ foundSW.setDisabled(true);
286
+ }
287
+ });
288
+ },
289
+
290
+ enableSubFormRow(rowIndex) {
291
+ this.widget.widgetList.forEach((subWidget) => {
292
+ let swRefName
293
+ = subWidget.options.name + "@row" + this.rowIdData[rowIndex];
294
+ let foundSW = this.getWidgetRef(swRefName);
295
+ if (!!foundSW) {
296
+ foundSW.setDisabled(false);
297
+ }
298
+ });
299
+ },
300
+
301
+ disableSubForm() {
302
+ if (this.rowIdData.length > 0) {
303
+ this.rowIdData.forEach((dataRow, rIdx) => {
304
+ this.disableSubFormRow(rIdx);
305
+ });
306
+ }
307
+
308
+ //禁用3个操作按钮
309
+ this.actionDisabled = true;
310
+ },
311
+
312
+ enableSubForm() {
313
+ if (this.rowIdData.length > 0) {
314
+ this.rowIdData.forEach((dataRow, rIdx) => {
315
+ this.enableSubFormRow(rIdx);
316
+ });
317
+ }
318
+
319
+ //启用3个操作按钮
320
+ this.actionDisabled = false;
321
+ },
322
+
323
+ resetSubForm() {
324
+ //重置subForm数据为空
325
+ if (this.widget.type === "sub-form") {
326
+ let subFormModel = this.formModel[this.widget.options.name];
327
+ if (!!subFormModel) {
328
+ subFormModel.splice(0, subFormModel.length);
329
+ this.rowIdData.splice(0, this.rowIdData.length);
330
+ }
331
+
332
+ if (this.widget.options.showBlankRow) {
333
+ this.addSubFormRow();
334
+ }
335
+ }
336
+ },
337
+
338
+ getSubFormValues(needValidation = true) {
339
+ if (this.widget.type === "sub-form") {
340
+ //TODO: 逐行校验子表单!暂未实现!!
341
+ return this.formModel[this.widget.options.name];
342
+ } else {
343
+ this.$message.error(this.i18nt("render.hint.nonSubFormType"));
344
+ }
345
+ },
346
+
347
+ setSubFormValues(subFormValues) {
348
+ //TODO: 待实现!!
349
+ },
350
+
351
+ // validateField(fieldName) { //逐行校验子表单字段
352
+ // //TODO:
353
+ // },
354
+ //
355
+ // validateSubForm() { //逐行校验子表单全部字段
356
+ // //TODO:
357
+ // },
358
+
359
+ /**
360
+ * 动态增加自定义css样式
361
+ * @param className
362
+ */
363
+ addCssClass(className) {
364
+ if (!this.widget.options.customClass) {
365
+ this.widget.options.customClass = [className];
366
+ } else {
367
+ this.widget.options.customClass.push(className);
368
+ }
369
+ },
370
+
371
+ /**
372
+ * 动态移除自定义css样式
373
+ * @param className
374
+ */
375
+ removeCssClass(className) {
376
+ if (!this.widget.options.customClass) {
377
+ return;
378
+ }
379
+
380
+ let foundIdx = -1;
381
+ this.widget.options.customClass.map((cc, idx) => {
382
+ if (cc === className) {
383
+ foundIdx = idx;
384
+ }
385
+ });
386
+ if (foundIdx > -1) {
387
+ this.widget.options.customClass.splice(foundIdx, 1);
388
+ }
389
+ },
390
+ handleOnCreated: function () {
391
+ this.handleCustomEvent(this.widget.options.onCreated);
392
+ },
393
+ handleOnMounted: function () {
394
+ this.handleCustomEvent(this.widget.options.onMounted);
395
+ // this.autoExcScript();
396
+ },
397
+ addExtraAccessData(data) {
398
+ if (data) {
399
+ Object.keys(data).forEach((field) => {
400
+ this.extraAccessData[field] = data[field];
401
+ });
402
+ }
403
+ },
404
+ clearExtraAccessData() {
405
+ this.extraAccessData = {};
406
+ },
407
+ doAccess(accessCode, conditions, callback) {
408
+ let path = baseRefUtil.getAccessUrl();
409
+ let globalReqData = baseRefUtil.getReportGlobalMap(); //全局请求参数
410
+ return this.$http({
411
+ url: path,
412
+ method: `post`,
413
+ loadingTarget: document.body,
414
+ data: {
415
+ accessCode: accessCode,
416
+ conditions: {
417
+ ...conditions,
418
+ ...globalReqData,
419
+ },
420
+ },
421
+ isLoading: true,
422
+ success: (res) => {
423
+ callback && callback(res.objx);
424
+ },
425
+ });
426
+ },
427
+ //--------------------- 以上为组件支持外部调用的API方法 end ------------------//
428
+ getEventParam() {
429
+ let formRef = this.getFormRef();
430
+ let dataId = formRef?.dataId;
431
+ let formCode = formRef?.reportTemplate?.formCode;
432
+ return {
433
+ eventParamNames: ["dataId", "formCode"],
434
+ eventParamValues: [dataId, formCode],
435
+ };
436
+ },
437
+ handleCustomEvent(funtionStr, eventParamNames = [], eventParamValues = []) {
438
+ if (!this.designState && funtionStr) {
439
+ let eventParam = this.getEventParam();
440
+ var e = new Function(
441
+ ...eventParam.eventParamNames,
442
+ ...eventParamNames,
443
+ funtionStr
444
+ );
445
+ // return e.call(this, ...eventParam.eventParamValues, ...eventParamValues);
446
+ let that = this;
447
+ try {
448
+ return e.call(
449
+ this,
450
+ ...eventParam.eventParamValues,
451
+ ...eventParamValues
452
+ );
453
+ } catch (error) {
454
+ if (settingConfig.fontErrorTipEnabled) {
455
+ that.$errorMsg({
456
+ rmid: that.$t1("前端脚本异常"),
457
+ content: error.message,
458
+ type: "error",
459
+ _errorMsg: error.stack,
460
+ });
461
+ }
462
+ throw error;
463
+ }
464
+ }
465
+ },
466
+ addInterval(handler, timeout) {
467
+ let timer = setInterval(handler, timeout);
468
+ this.timerMap[timer] = timer;
469
+ return timer;
470
+ },
471
+ clearAllInterval() {
472
+ let timerMap = this.timerMap;
473
+ for (let key in timerMap) {
474
+ let timer = timerMap[key];
475
+ clearInterval(timer);
476
+ }
477
+ this.timerMap = {};
478
+ },
479
+ getI18nLabel(label, path, param) {
480
+ return !this.designState && label ? this.$t2(label, path, param) : label;
481
+ },
482
+ getParentTarget() {
483
+ let name = this.parentWidget?.options?.name ?? null;
484
+ return name ? this.getWidgetRef(name) : null;
485
+ },
486
+ },
487
+ };
488
+
489
+ export default modules;