@fecp/designer 5.6.23 → 5.6.24

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 (26) hide show
  1. package/es/designer/package.json.mjs +1 -1
  2. package/es/designer.css +258 -258
  3. package/es/packages/vue/src/components/dialog/DialogRenderer.vue2.mjs +7 -7
  4. package/es/packages/vue/src/components/forms/form/Form.vue2.mjs +1370 -0
  5. package/es/packages/vue/src/components/forms/form/FormAnchorNav.vue2.mjs +113 -0
  6. package/es/packages/vue/src/components/forms/form/RightAnchorNav.vue2.mjs +128 -0
  7. package/es/packages/vue/src/components/forms/form/index.mjs +2 -2
  8. package/es/packages/vue/src/components/layout/layoutCard/LayoutCard.vue.mjs +4 -4
  9. package/es/packages/vue/src/components/table/Table.vue.mjs +22 -10
  10. package/es/packages/vue/src/components/table/TableColumn.vue.mjs +54 -5
  11. package/es/packages/vue/src/components/table/index.mjs +2 -2
  12. package/es/packages/vue/src/composables/usePageEvents.mjs +55 -3
  13. package/lib/designer/package.json.js +1 -1
  14. package/lib/designer/src/packages/form/index.vue.js +1 -1
  15. package/lib/designer/src/packages/form/property/index.vue.js +1 -1
  16. package/lib/designer.css +258 -258
  17. package/lib/packages/vue/src/components/dialog/DialogRenderer.vue2.js +10 -10
  18. package/lib/packages/vue/src/components/forms/form/Form.vue2.js +1370 -0
  19. package/lib/packages/vue/src/components/forms/form/FormAnchorNav.vue2.js +113 -0
  20. package/lib/packages/vue/src/components/forms/form/RightAnchorNav.vue2.js +128 -0
  21. package/lib/packages/vue/src/components/forms/form/index.js +1 -1
  22. package/lib/packages/vue/src/components/layout/layoutCard/LayoutCard.vue.js +1 -1
  23. package/lib/packages/vue/src/components/table/Table.vue.js +22 -10
  24. package/lib/packages/vue/src/components/table/TableColumn.vue.js +54 -5
  25. package/lib/packages/vue/src/composables/usePageEvents.js +55 -3
  26. package/package.json +1 -1
@@ -0,0 +1,1370 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ require("../../../../../../node_modules/element-plus/es/index.js");
4
+ ;/* empty css */
5
+ ;/* empty css */
6
+ ;/* empty css */
7
+ ;/* empty css */
8
+ ;/* empty css */
9
+ ;/* empty css */
10
+ ;/* empty css */
11
+ ;/* empty css */
12
+ const Vue = require("vue");
13
+ require("../../../../../../node_modules/grid-layout-plus/es/index.js");
14
+ const getInstance = require("../../../utils/getInstance.js");
15
+ const getJsonAsyncUtil = require("../../../utils/getJsonAsyncUtil.js");
16
+ const index$8 = require("../formItem/index.js");
17
+ const datasource = require("../../../utils/datasource.js");
18
+ const validation = require("./validation.js");
19
+ const parseRouteParams = require("../../../utils/parseRouteParams.js");
20
+ const common = require("../../../utils/common.js");
21
+ ;/* empty css */
22
+ ;/* empty css */
23
+ ;/* empty css */
24
+ const calculate = require("../../../utils/formulajs/calculate.js");
25
+ const eventFlowHandler = require("../../../utils/eventFlow/eventFlowHandler.js");
26
+ require("vxe-table");
27
+ require("xe-utils");
28
+ ;/* empty css */
29
+ ;/* empty css */
30
+ ;/* empty css */
31
+ ;/* empty css */
32
+ ;/* empty css */
33
+ ;/* empty css */
34
+ ;/* empty css */
35
+ ;/* empty css */
36
+ ;/* empty css */
37
+ ;/* empty css */
38
+ const _pluginVue_exportHelper = require("../../../../../../_virtual/_plugin-vue_export-helper.js");
39
+ const parseFilterConfig = require("../../../utils/parseFilterConfig.js");
40
+ ;/* empty css */
41
+ ;/* empty css */
42
+ ;/* empty css */
43
+ ;/* empty css */
44
+ ;/* empty css */
45
+ ;/* empty css */
46
+ ;/* empty css */
47
+ ;/* empty css */
48
+ ;/* empty css */
49
+ require("../../../../../../node_modules/element-plus/theme-chalk/el-date-picker.css.js");
50
+ require("../text/index.js");
51
+ require("../select/index.js");
52
+ require("../multipleSelection/index.js");
53
+ require("../date/index.js");
54
+ require("../number/index.js");
55
+ ;/* empty css */
56
+ ;/* empty css */
57
+ ;/* empty css */
58
+ ;/* empty css */
59
+ ;/* empty css */
60
+ ;/* empty css */
61
+ require("../../../../../../node_modules/element-plus/theme-chalk/el-tab-pane.css.js");
62
+ ;/* empty css */
63
+ const eventBus = require("../../../utils/eventBus.js");
64
+ require("../../../../../../node_modules/decimal.js/decimal.js");
65
+ const vuex_esmBundler = require("../../../../../../node_modules/vuex/dist/vuex.esm-bundler.js");
66
+ ;/* empty css */
67
+ const usePageEvents = require("../../../composables/usePageEvents.js");
68
+ const index$5 = require("../../details/header/index.js");
69
+ const index$6 = require("../../details/main/index.js");
70
+ const index$9 = require("../../details/footer/index.js");
71
+ const FormAnchorNav = require("./FormAnchorNav.vue2.js");
72
+ const RightAnchorNav = require("./RightAnchorNav.vue2.js");
73
+ const moment = require("../../../../../../node_modules/moment/dist/moment.js");
74
+ const index$2 = require("../../../api/index.js");
75
+ const importantDataChange = require("../../../utils/importantDataChange.js");
76
+ ;/* empty css */
77
+ ;/* empty css */
78
+ ;/* empty css */
79
+ ;/* empty css */
80
+ ;/* empty css */
81
+ ;/* empty css */
82
+ ;/* empty css */
83
+ ;/* empty css */
84
+ ;/* empty css */
85
+ ;/* empty css */
86
+ ;/* empty css */
87
+ ;/* empty css */
88
+ ;/* empty css */
89
+ const index = require("../../../../../../node_modules/element-plus/es/hooks/use-locale/index.js");
90
+ const index$1 = require("../../../../../../node_modules/element-plus/es/components/message/index.js");
91
+ const index$3 = require("../../../../../../node_modules/element-plus/es/components/container/index.js");
92
+ const index$4 = require("../../../../../../node_modules/element-plus/es/components/col/index.js");
93
+ const index$7 = require("../../../../../../node_modules/element-plus/es/components/form/index.js");
94
+ const gridLayout_vue = require("../../../../../../node_modules/grid-layout-plus/es/components/grid-layout.vue.js");
95
+ const _hoisted_1 = ["name", "value"];
96
+ const _sfc_main = /* @__PURE__ */ Object.assign({
97
+ inheritAttrs: false
98
+ }, {
99
+ __name: "Form",
100
+ props: {
101
+ templateKey: {
102
+ type: String,
103
+ default: ""
104
+ },
105
+ initOption: {
106
+ type: Object,
107
+ default: () => {
108
+ }
109
+ },
110
+ modelValue: {
111
+ type: Object,
112
+ default: () => {
113
+ }
114
+ },
115
+ isSubForm: {
116
+ type: Boolean,
117
+ default: false
118
+ },
119
+ isDialog: {
120
+ type: Boolean,
121
+ default: false
122
+ },
123
+ canPageEvent: {
124
+ type: Boolean,
125
+ default: true
126
+ },
127
+ initSearchData: {
128
+ type: Object,
129
+ default: {}
130
+ },
131
+ initFormMode: {
132
+ type: String,
133
+ default: ""
134
+ },
135
+ isApproval: {
136
+ type: Boolean,
137
+ default: false
138
+ },
139
+ class: {
140
+ type: String,
141
+ default: ""
142
+ }
143
+ },
144
+ emits: [
145
+ "submit",
146
+ "change",
147
+ "validate",
148
+ "loaded",
149
+ "update:modelValue",
150
+ "layoutUpdated"
151
+ ],
152
+ setup(__props, { expose: __expose, emit: __emit }) {
153
+ const store = vuex_esmBundler.useStore();
154
+ window.$user = store.getters.user;
155
+ const props = __props;
156
+ index.useLocale();
157
+ const emit = __emit;
158
+ const instance = Vue.getCurrentInstance();
159
+ const ctx = getInstance.getCurrentVueInstance();
160
+ const fecFormRef = Vue.ref(null);
161
+ const formRef = Vue.ref(null);
162
+ const gridLayout = Vue.ref(null);
163
+ const configLoading = Vue.ref(true);
164
+ const localConfig = Vue.ref({});
165
+ const formData = Vue.ref({});
166
+ const formRules = Vue.ref({});
167
+ const dataSourceOptions = Vue.ref({});
168
+ const dictionaryOptions = Vue.ref({});
169
+ const productData = Vue.ref({});
170
+ const fieldsData = Vue.ref([]);
171
+ const hiddenFields = Vue.ref([]);
172
+ const dataChangeManager = Vue.ref(null);
173
+ const prevFormData = Vue.ref({});
174
+ let linkaged = false;
175
+ const rowHeight = Vue.ref(1);
176
+ const pageEvents = props.canPageEvent ? usePageEvents.usePageEvents(() => ({
177
+ pageEventConfig: localConfig.value.pageEventConfig,
178
+ fields: [...fieldsData.value, ...hiddenFields.value],
179
+ instance,
180
+ formData: formData.value,
181
+ localConfig: localConfig.value,
182
+ initSearchData: props.initSearchData,
183
+ components: {
184
+ form: ctx
185
+ }
186
+ })) : null;
187
+ if (pageEvents) {
188
+ pageEvents.handleBeforeUnmount();
189
+ pageEvents.handleUnmounted();
190
+ }
191
+ const formMode = Vue.ref("");
192
+ Vue.watch(
193
+ () => props.templateKey,
194
+ (key) => {
195
+ if (key) {
196
+ loadConfig("dynamic");
197
+ }
198
+ }
199
+ );
200
+ let isSyncingToParent = false;
201
+ Vue.watch(
202
+ () => props.modelValue,
203
+ (newVal, oldVal) => {
204
+ if (isSyncingToParent) return;
205
+ if (JSON.stringify(newVal) !== JSON.stringify(oldVal)) {
206
+ loadFormData("change");
207
+ }
208
+ }
209
+ );
210
+ const loadConfig = async (state) => {
211
+ if (!props.templateKey && (!props.initOption || Object.keys(props.initOption).length == 0)) {
212
+ return;
213
+ }
214
+ prevFormData.value = {};
215
+ linkaged = false;
216
+ configLoading.value = true;
217
+ try {
218
+ let option = await getJsonAsyncUtil.default(
219
+ ctx.$http,
220
+ props.templateKey,
221
+ "form",
222
+ props.initOption
223
+ );
224
+ rowHeight.value = option.labelPosition == "top" ? 1.5 : 1;
225
+ localConfig.value = option;
226
+ if (props.initFormMode) {
227
+ formMode.value = props.initFormMode;
228
+ } else {
229
+ formMode.value = option.formMode;
230
+ }
231
+ fieldsData.value = option.fieldsData.map((item) => {
232
+ if (formMode.value == "query") {
233
+ item.component.disabled = true;
234
+ }
235
+ return item.component;
236
+ });
237
+ hiddenFields.value = option.hiddenFields || [];
238
+ loadFormData(state);
239
+ loadEventFlow();
240
+ if (pageEvents && localConfig.value.pageEventConfig) {
241
+ const onCreatedEvent = localConfig.value.pageEventConfig.find(
242
+ (e) => e.name === "onCreated"
243
+ );
244
+ if (onCreatedEvent) {
245
+ console.log("🚀 页面 onCreated 事件触发");
246
+ try {
247
+ await pageEvents.executeEvent("onCreated");
248
+ } catch (error) {
249
+ }
250
+ }
251
+ }
252
+ await loadFieldDataSources();
253
+ await loadProductData();
254
+ applyProductConfigToForm();
255
+ mergeOptionsToFields();
256
+ initGridLayoutDataConfig();
257
+ initLinkage();
258
+ await initImportantDataChange();
259
+ emit("loaded", option, getFormData());
260
+ } catch (error) {
261
+ console.error("加载配置失败:", error);
262
+ index$1.ElMessage.error("加载配置失败");
263
+ } finally {
264
+ configLoading.value = false;
265
+ }
266
+ };
267
+ function layoutUpdated(layoutData) {
268
+ emit("layoutUpdated", layoutData);
269
+ }
270
+ const loadFormData = (state) => {
271
+ var _a;
272
+ const defaultData = {};
273
+ const rules = {};
274
+ if (fieldsData.value) {
275
+ (_a = fieldsData.value) == null ? void 0 : _a.forEach((component) => {
276
+ if (component.fieldName) {
277
+ let defaultValue = component.defaultValue || null;
278
+ if (component.fieldType == "number") {
279
+ defaultValue = Number(defaultValue || 0);
280
+ }
281
+ defaultData[component.fieldName] = defaultValue;
282
+ }
283
+ if (state != "change") {
284
+ if (component.fieldName) {
285
+ const fieldRules = validation.generateFieldRules(component, formData, [
286
+ ...fieldsData.value,
287
+ ...hiddenFields.value
288
+ ]);
289
+ if (fieldRules.length > 0) {
290
+ rules[component.fieldName] = fieldRules;
291
+ }
292
+ }
293
+ }
294
+ });
295
+ }
296
+ if (hiddenFields.value && hiddenFields.value.length > 0) {
297
+ hiddenFields.value.forEach((field) => {
298
+ if (field.fieldName) {
299
+ if (typeof field.value == "object") {
300
+ const value = parseRouteParams.parseSingleParamValue(
301
+ field.value || field.defaultValue,
302
+ defaultData,
303
+ [...fieldsData.value, ...hiddenFields.value]
304
+ );
305
+ if (value) {
306
+ defaultData[field.fieldName] = value;
307
+ }
308
+ } else if (field.value) {
309
+ defaultData[field.fieldName] = field.value;
310
+ }
311
+ }
312
+ });
313
+ }
314
+ if (state == "dynamic") {
315
+ formData.value = { ...setFormData(props.modelValue, true), ...defaultData };
316
+ } else {
317
+ formData.value = { ...defaultData, ...setFormData(props.modelValue, true) };
318
+ }
319
+ if (state != "change") {
320
+ formRules.value = rules;
321
+ }
322
+ };
323
+ const loadFieldDataSources = async () => {
324
+ var _a, _b;
325
+ const fields = fieldsData.value || [];
326
+ const fieldDataSources = /* @__PURE__ */ new Set();
327
+ const dictionaryKeys = /* @__PURE__ */ new Set();
328
+ for (const component of fields) {
329
+ const fieldType = component.fieldType;
330
+ if ((fieldType === "select" || fieldType === "multipleSelection" || fieldType === "radio" || fieldType === "checkbox" || fieldType === "cascader") && component.optionConfig) {
331
+ const { optionSource, dataSourceValue, dictionaryValue } = component.optionConfig;
332
+ if (optionSource === "dataSource" && dataSourceValue) {
333
+ fieldDataSources.add(dataSourceValue);
334
+ } else if (optionSource === "dictionary" && dictionaryValue) {
335
+ dictionaryKeys.add(dictionaryValue);
336
+ }
337
+ }
338
+ }
339
+ for (const dataSourceId of fieldDataSources) {
340
+ if (dataSourceOptions.value[dataSourceId]) continue;
341
+ try {
342
+ const dsManager = datasource.createDataSource({
343
+ http: ctx.$http,
344
+ dataSources: localConfig.value.dataSources,
345
+ currentDataSourceId: dataSourceId,
346
+ pagination: false,
347
+ data: formData.value,
348
+ fields: [...fieldsData.value, ...hiddenFields.value]
349
+ });
350
+ const data = await dsManager.fetch();
351
+ let options = [];
352
+ if (Array.isArray(data)) {
353
+ options = data;
354
+ } else if (typeof data === "object") {
355
+ options = Array.isArray(data.data) ? data.data : ((_a = data.data) == null ? void 0 : _a.records) || ((_b = data.data) == null ? void 0 : _b.list) || [];
356
+ }
357
+ dataSourceOptions.value[dataSourceId] = options;
358
+ dsManager.destroy();
359
+ } catch (error) {
360
+ console.error(`Failed to load data source ${dataSourceId}:`, error);
361
+ }
362
+ }
363
+ if (dictionaryKeys.size > 0) {
364
+ try {
365
+ const keyName = Array.from(dictionaryKeys).join(",");
366
+ const response = await ctx.$http.postForm(
367
+ "/" + window.$servers.base + "/parm/sysParmDic/getDicListByKey",
368
+ {
369
+ keyName
370
+ }
371
+ );
372
+ const dictionaryData = response;
373
+ if (typeof dictionaryData === "object") {
374
+ Object.keys(dictionaryData).forEach((dictKey) => {
375
+ if (dictionaryKeys.has(dictKey)) {
376
+ const dictItems = dictionaryData[dictKey];
377
+ if (Array.isArray(dictItems)) {
378
+ dictionaryOptions.value[dictKey] = dictItems;
379
+ }
380
+ }
381
+ });
382
+ }
383
+ } catch (error) {
384
+ console.error("Failed to load dictionary data:", error);
385
+ }
386
+ }
387
+ };
388
+ const mergeOptionsToFields = () => {
389
+ if (fieldsData.value) {
390
+ fieldsData.value.forEach((component) => {
391
+ if (!component.optionConfig) return;
392
+ const {
393
+ optionSource,
394
+ dataSourceValue,
395
+ dictionaryValue,
396
+ displayField,
397
+ valueField,
398
+ idField,
399
+ pidField
400
+ } = component.optionConfig;
401
+ if (optionSource === "dataSource" && dataSourceOptions.value[dataSourceValue]) {
402
+ const rawOptions = dataSourceOptions.value[dataSourceValue];
403
+ const labelField = displayField || "label";
404
+ const keyField = valueField || "value";
405
+ component.optionConfig.options = rawOptions.map((item) => ({
406
+ label: item[labelField],
407
+ value: item[keyField],
408
+ disabled: item.disabled || false,
409
+ ...item
410
+ }));
411
+ } else if (optionSource === "dictionary" && dictionaryOptions.value[dictionaryValue]) {
412
+ const rawOptions = dictionaryOptions.value[dictionaryValue];
413
+ const labelField = "optName";
414
+ const keyField = "optCode";
415
+ component.optionConfig.options = rawOptions.map((item) => ({
416
+ label: item[labelField],
417
+ value: item[keyField],
418
+ disabled: item.disabled || false
419
+ }));
420
+ } else if (optionSource === "custom") {
421
+ component.optionConfig.options = component.optionConfig.options || [];
422
+ }
423
+ applyProductConfigFilter(component);
424
+ });
425
+ }
426
+ };
427
+ const loadProductData = async () => {
428
+ if (!localConfig.value || !localConfig.value.prodConfig) {
429
+ return;
430
+ }
431
+ const { prodId } = localConfig.value.prodConfig;
432
+ if (!prodId) {
433
+ return;
434
+ }
435
+ const field = [...fieldsData.value, ...hiddenFields.value].find(
436
+ (item) => item.id == prodId.value
437
+ );
438
+ if (!field) {
439
+ return;
440
+ }
441
+ const prodIdValue = formData.value[field.fieldName];
442
+ if (!prodIdValue) {
443
+ return;
444
+ }
445
+ try {
446
+ const response = await index$2.default.getProductData(ctx.$http, prodIdValue);
447
+ productData.value = response;
448
+ console.log("产品数据加载成功:", productData.value);
449
+ } catch (error) {
450
+ console.error("获取产品数据失败:", error);
451
+ productData.value = {};
452
+ }
453
+ };
454
+ const prodRules = Vue.ref({});
455
+ const applyProductConfigToForm = () => {
456
+ if (!localConfig.value || !localConfig.value.prodConfig || !productData.value) {
457
+ return;
458
+ }
459
+ const { defaultValueConfigs, validationConfigs } = localConfig.value.prodConfig;
460
+ if (defaultValueConfigs && defaultValueConfigs.length > 0) {
461
+ defaultValueConfigs.forEach((config) => {
462
+ if (config.pageField && config.productConfigField) {
463
+ const defaultValue = productData.value[config.productConfigField];
464
+ if (defaultValue !== void 0) {
465
+ const formField = [...fieldsData.value, ...hiddenFields.value].find(
466
+ (item) => item.id == config.pageField
467
+ );
468
+ if (formField && !formData.value[formField.fieldName]) {
469
+ formData.value[formField.fieldName] = defaultValue;
470
+ }
471
+ }
472
+ }
473
+ });
474
+ }
475
+ if (validationConfigs && validationConfigs.length > 0) {
476
+ validationConfigs.forEach((config) => {
477
+ if (config.pageField && (config.minProductField || config.maxProductField)) {
478
+ const minValue = productData.value[config.minProductField];
479
+ const maxValue = productData.value[config.maxProductField];
480
+ if (minValue !== void 0 || maxValue !== void 0) {
481
+ const formField = [...fieldsData.value, ...hiddenFields.value].find(
482
+ (item) => item.id == config.pageField
483
+ );
484
+ if (formField && !prodRules.value[formField.fieldName]) {
485
+ prodRules.value[formField.fieldName] = [];
486
+ }
487
+ const customValidator = (rule, value, callback) => {
488
+ if (value === null || value === void 0 || value === "") {
489
+ callback();
490
+ return;
491
+ }
492
+ const numValue = Number(value);
493
+ if (isNaN(numValue)) {
494
+ callback(new Error("请输入有效的数字"));
495
+ return;
496
+ }
497
+ const formatValue = (val) => {
498
+ if (val === void 0 || val === null) return "";
499
+ const num = Number(val);
500
+ if (config.format === "amount") {
501
+ return `${num.toLocaleString()}元`;
502
+ } else if (config.format === "percent") {
503
+ return `${(num * 100).toFixed(2)}%`;
504
+ }
505
+ return num;
506
+ };
507
+ let errorMessage = "";
508
+ if (minValue !== void 0 && numValue < Number(minValue)) {
509
+ errorMessage = `不能小于 ${formatValue(minValue)}`;
510
+ }
511
+ if (maxValue !== void 0 && numValue > Number(maxValue)) {
512
+ if (errorMessage) {
513
+ errorMessage = `${errorMessage} 且 不能大于 ${formatValue(
514
+ maxValue
515
+ )}`;
516
+ } else {
517
+ errorMessage = `不能大于 ${formatValue(maxValue)}`;
518
+ }
519
+ }
520
+ if (errorMessage) {
521
+ callback(new Error(errorMessage));
522
+ } else {
523
+ callback();
524
+ }
525
+ };
526
+ const customRule = {
527
+ validator: customValidator,
528
+ trigger: "blur"
529
+ };
530
+ prodRules.value[formField.fieldName].push(customRule);
531
+ }
532
+ }
533
+ });
534
+ for (let fieldName in prodRules.value) {
535
+ if (formRules.value[fieldName]) {
536
+ formRules.value[fieldName].push(...prodRules.value[fieldName]);
537
+ } else {
538
+ formRules.value[fieldName] = prodRules.value[fieldName];
539
+ }
540
+ }
541
+ }
542
+ };
543
+ const applyProductConfigFilter = (component) => {
544
+ if (!localConfig.value || !localConfig.value.prodConfig || !productData.value) {
545
+ return;
546
+ }
547
+ const { optionConfigs } = localConfig.value.prodConfig;
548
+ if (!optionConfigs || !component.optionConfig || !component.optionConfig.options) {
549
+ return;
550
+ }
551
+ const componentConfig = optionConfigs.find(
552
+ (item) => item.pageField == component.id
553
+ );
554
+ if (!componentConfig || !componentConfig.productConfigField) {
555
+ return;
556
+ }
557
+ const fieldValue = productData.value[componentConfig.productConfigField];
558
+ if (!fieldValue) {
559
+ return;
560
+ }
561
+ const allowedValues = Array.isArray(fieldValue) ? fieldValue : fieldValue.split("|");
562
+ component.optionConfig.options = component.optionConfig.options.filter(
563
+ (option) => {
564
+ const optionValue = option.value !== void 0 ? option.value : option;
565
+ return allowedValues.includes(optionValue);
566
+ }
567
+ );
568
+ if (component.optionConfig.options.length === 0) {
569
+ component.optionConfig.options = [
570
+ {
571
+ label: `无可用选项(产品配置限制)`,
572
+ value: "",
573
+ disabled: true
574
+ }
575
+ ];
576
+ }
577
+ };
578
+ const initImportantDataChange = async () => {
579
+ var _a;
580
+ const importantDataChangeConfig = ((_a = localConfig.value) == null ? void 0 : _a.importantDataChange) || [];
581
+ if (importantDataChangeConfig.length === 0) return;
582
+ const fieldMap = {};
583
+ [...fieldsData.value, ...hiddenFields.value].forEach((field) => {
584
+ if (field.fieldName) {
585
+ fieldMap[field.id] = { fieldName: field.fieldName };
586
+ }
587
+ });
588
+ dataChangeManager.value = new importantDataChange.ImportantDataChangeManager(
589
+ importantDataChangeConfig,
590
+ {
591
+ http: ctx.$http,
592
+ fieldMap,
593
+ model: formData.value
594
+ }
595
+ );
596
+ try {
597
+ await dataChangeManager.value.fetchChanges();
598
+ } catch (e) {
599
+ console.warn("[ImportantDataChange] 拉取变更日志失败:", e);
600
+ }
601
+ };
602
+ const handleEvent = Vue.ref(null);
603
+ function loadEventFlow() {
604
+ const {
605
+ getEventHandlers: createEventHandlers,
606
+ handleEvent: createHandleEvent
607
+ } = eventFlowHandler.useEventFlow({
608
+ fields: [...fieldsData.value, ...hiddenFields.value],
609
+ instance,
610
+ localConfig: localConfig.value,
611
+ components: {
612
+ form: ctx
613
+ }
614
+ });
615
+ handleEvent.value = createHandleEvent;
616
+ const getEventHandlers = (row, item, eventConfig) => {
617
+ return createEventHandlers(item, row, eventConfig);
618
+ };
619
+ fieldsData.value.forEach((component) => {
620
+ if (component.fieldName) {
621
+ component.eventHandlers = getEventHandlers(
622
+ formData.value,
623
+ component,
624
+ component.eventConfig
625
+ );
626
+ }
627
+ });
628
+ }
629
+ function handleLabelLink(config) {
630
+ var _a;
631
+ handleEvent.value(
632
+ getFormData(),
633
+ config,
634
+ (_a = config.labelLinkEventConfig) == null ? void 0 : _a.find((item) => item.name == "Click")
635
+ );
636
+ }
637
+ const gridLayoutFieldsData = Vue.ref([]);
638
+ const oriGridLayoutData = Vue.ref([]);
639
+ const formItemRefs = Vue.ref(/* @__PURE__ */ new Map());
640
+ const setFormItemRef = (el, component) => {
641
+ if (!el) {
642
+ if (component && component.id) {
643
+ formItemRefs.value.delete(component.id);
644
+ }
645
+ return;
646
+ }
647
+ if (component && component.id) {
648
+ formItemRefs.value.set(String(component.id), el);
649
+ }
650
+ };
651
+ const getFormItemRef = (fieldId) => {
652
+ const formItem = formItemRefs.value.get(fieldId);
653
+ if (!formItem) {
654
+ console.log(`未找到 fieldId: ${fieldId} 的 FormItem 组件`);
655
+ return null;
656
+ }
657
+ console.log(`找到 FormItem 组件:`, formItem);
658
+ if (typeof formItem.getInnerComponentRef === "function") {
659
+ const innerRef = formItem.getInnerComponentRef();
660
+ console.log(`内部组件 ref:`, innerRef);
661
+ return innerRef;
662
+ } else {
663
+ console.log(`FormItem 组件没有 getInnerComponentRef 方法`);
664
+ return null;
665
+ }
666
+ };
667
+ function initGridLayoutDataConfig() {
668
+ let gridLayoutData = common.cloneDeep(localConfig.value.fieldsData || []);
669
+ gridLayoutData = gridLayoutData.map((item) => {
670
+ item.isResizable = false;
671
+ const component = item.component;
672
+ item.y = item.y * 60;
673
+ if (component.fieldType == "subTitle" || component.fieldType == "h2") {
674
+ item.h = item.h * 40;
675
+ } else if (component.fieldType == "divider") {
676
+ item.h = item.h * 0;
677
+ } else if (!item.fixedH) {
678
+ item.h = item.h * 60;
679
+ } else if (item.fixedH) {
680
+ item.h = item.h / (localConfig.value.labelPosition == "top" ? 1.5 : 1);
681
+ }
682
+ if (formMode.value == "query") {
683
+ if (item.component.displayMode == "edit") {
684
+ item.hidden = true;
685
+ }
686
+ } else {
687
+ if (item.component.displayMode == "query") {
688
+ item.hidden = true;
689
+ }
690
+ }
691
+ return item;
692
+ });
693
+ oriGridLayoutData.value = gridLayoutData;
694
+ }
695
+ const getFieldError = (fieldName) => {
696
+ var _a;
697
+ if (!formRef.value) return "";
698
+ const field = (_a = formRef.value.fields) == null ? void 0 : _a.find((f) => f.prop === fieldName);
699
+ return (field == null ? void 0 : field.validateMessage) || "";
700
+ };
701
+ const handleFieldChange = (config, value) => {
702
+ console.log("🚀 ~ handleFieldChange ~ value:", config.fieldName, value);
703
+ };
704
+ const handleCustomButtonClick = (button) => {
705
+ var _a;
706
+ const opt = { ...button };
707
+ opt.isApproval = false;
708
+ handleEvent.value(
709
+ getFormData(),
710
+ opt,
711
+ (_a = button.eventConfig) == null ? void 0 : _a.find((item) => item.name == "Click")
712
+ );
713
+ };
714
+ const handleActionClick = (button) => {
715
+ var _a;
716
+ handleEvent.value(
717
+ getFormData(),
718
+ button,
719
+ (_a = button.eventConfig) == null ? void 0 : _a.find((item) => item.name == "Click")
720
+ );
721
+ };
722
+ const hasSaveButton = () => {
723
+ var _a, _b;
724
+ return (_b = (_a = localConfig.value.pageFooterConfig) == null ? void 0 : _a.actions) == null ? void 0 : _b.some(
725
+ (item) => item.isApproval
726
+ );
727
+ };
728
+ const handleApprovalEvent = (isSubmit) => {
729
+ return new Promise((resolve, reject) => {
730
+ var _a, _b;
731
+ const actions = ((_a = localConfig.value.pageFooterConfig) == null ? void 0 : _a.actions) || [];
732
+ const approvalAction = actions.find((item) => item.isApproval);
733
+ if (approvalAction) {
734
+ let action = { ...approvalAction };
735
+ if (!isSubmit) {
736
+ action.isApproval = false;
737
+ }
738
+ handleEvent.value(
739
+ formData.value,
740
+ action,
741
+ (_b = approvalAction.eventConfig) == null ? void 0 : _b.find((item) => item.name == "Click")
742
+ ).then(() => {
743
+ resolve();
744
+ }).catch((error) => {
745
+ reject(error);
746
+ });
747
+ }
748
+ });
749
+ };
750
+ const validate = () => {
751
+ var _a;
752
+ const subFormComps = gridLayoutFieldsData.value.filter((item) => item.component.fieldType == "subForm").map((item) => item.component);
753
+ const subFormPromises = subFormComps.map((subForm) => {
754
+ var _a2, _b;
755
+ const subFormRef = getFormItemRef(String(subForm.id));
756
+ return ((_b = (_a2 = subFormRef == null ? void 0 : subFormRef.subFormRef) == null ? void 0 : _a2.validate) == null ? void 0 : _b.call(_a2)) || Promise.resolve();
757
+ });
758
+ subFormPromises.push((_a = formRef.value) == null ? void 0 : _a.validate());
759
+ return Promise.all(subFormPromises).then(() => getFormData());
760
+ };
761
+ const docValidate = () => {
762
+ const documentComps = gridLayoutFieldsData.value.filter((item) => item.component.fieldType == "document").map((item) => item.component);
763
+ const compPromises = documentComps.map((comp) => {
764
+ var _a;
765
+ const compRef = getFormItemRef(String(comp.id));
766
+ return ((_a = compRef == null ? void 0 : compRef.validate) == null ? void 0 : _a.call(compRef)) || Promise.resolve();
767
+ });
768
+ return Promise.all(compPromises);
769
+ };
770
+ const resetFields = () => {
771
+ var _a, _b;
772
+ (_a = formRef.value) == null ? void 0 : _a.clearValidate();
773
+ (_b = formRef.value) == null ? void 0 : _b.resetFields();
774
+ loadFormData();
775
+ };
776
+ const valueFormatMap = {
777
+ date: "YYYYMMDD",
778
+ week: "YYYYMMDD",
779
+ month: "YYYYMM",
780
+ year: "YYYY",
781
+ datetime: "YYYYMMDDHHmmss"
782
+ };
783
+ const formValueFormatMap = {
784
+ date: "YYYY/MM/DD",
785
+ week: "YYYY/MM/DD",
786
+ month: "YYYY/MM",
787
+ year: "YYYY",
788
+ datetime: "YYYY/MM/DD HH:mm:ss"
789
+ };
790
+ const getFormData = () => {
791
+ const result = { ...formData.value };
792
+ const processField = (field) => {
793
+ const fieldName = field.fieldName;
794
+ const fieldType = field.fieldType;
795
+ const value = result[fieldName];
796
+ if (fieldName && (fieldType === "checkbox" || fieldType === "multipleSelection" || fieldType === "cascader" || fieldType === "area" || fieldType === "industry")) {
797
+ let splitStr = "|";
798
+ if (fieldType === "cascader" || fieldType === "area" || fieldType === "industry") {
799
+ splitStr = ",";
800
+ }
801
+ if (Array.isArray(value)) {
802
+ result[fieldName] = value.join(splitStr);
803
+ }
804
+ } else if (fieldName && fieldType === "date" && value) {
805
+ const dateValueType = field.dateValueType;
806
+ const valueFormat = valueFormatMap[field.dateType] || "YYYYMMDD";
807
+ const formValueFormat = formValueFormatMap[field.dateType] || "YYYY/MM/DD";
808
+ switch (dateValueType) {
809
+ case "date":
810
+ result[fieldName] = moment.default(value, formValueFormat).toDate();
811
+ break;
812
+ case "timestamp":
813
+ result[fieldName] = moment.default(value, formValueFormat).valueOf();
814
+ break;
815
+ case "string":
816
+ default:
817
+ result[fieldName] = moment.default(value, formValueFormat).format(
818
+ valueFormat
819
+ );
820
+ break;
821
+ }
822
+ }
823
+ if (fieldType != "number" && !result[fieldName]) {
824
+ result[fieldName] = "";
825
+ }
826
+ };
827
+ if (fieldsData.value) {
828
+ fieldsData.value.forEach((component) => {
829
+ processField(component);
830
+ });
831
+ }
832
+ if (hiddenFields.value && hiddenFields.value.length > 0) {
833
+ hiddenFields.value.forEach((field) => {
834
+ processField(field);
835
+ });
836
+ }
837
+ return result;
838
+ };
839
+ const setFormData = (data, flag = false) => {
840
+ const processedData = { ...data };
841
+ const processField = (field) => {
842
+ const fieldName = field.fieldName;
843
+ const fieldType = field.fieldType;
844
+ if (!processedData.hasOwnProperty(fieldName)) {
845
+ return;
846
+ }
847
+ const value = processedData[fieldName];
848
+ if (fieldName && (fieldType === "checkbox" || fieldType === "multipleSelection" || fieldType === "cascader" || fieldType === "area" || fieldType === "industry")) {
849
+ let splitStr = "|";
850
+ if (fieldType === "cascader" || fieldType === "area" || fieldType === "industry") {
851
+ splitStr = ",";
852
+ }
853
+ if (typeof value === "string" && value.includes(splitStr)) {
854
+ processedData[fieldName] = value.split(splitStr);
855
+ } else if (typeof value === "string" && value !== "") {
856
+ processedData[fieldName] = [value];
857
+ } else if (value === "" || value === null || value === void 0) {
858
+ processedData[fieldName] = [];
859
+ }
860
+ processedData[fieldName] = processedData[fieldName].map((item) => {
861
+ if (item.indexOf(",") > -1) {
862
+ return item.split(",");
863
+ }
864
+ return item;
865
+ });
866
+ } else if (fieldName && fieldType === "date" && value) {
867
+ const valueFormat = valueFormatMap[field.dateType] || "YYYYMMDD";
868
+ const formValueFormat = formValueFormatMap[field.dateType] || "YYYY/MM/DD";
869
+ processedData[fieldName] = moment.default(value, valueFormat).format(
870
+ formValueFormat
871
+ );
872
+ }
873
+ };
874
+ if (fieldsData.value) {
875
+ fieldsData.value.forEach((component) => {
876
+ processField(component);
877
+ });
878
+ }
879
+ if (hiddenFields.value && hiddenFields.value.length > 0) {
880
+ hiddenFields.value.forEach((field) => {
881
+ processField(field);
882
+ });
883
+ }
884
+ if (flag) {
885
+ return common.removeEmptyValues(processedData);
886
+ }
887
+ Object.assign(formData.value, processedData);
888
+ };
889
+ Vue.onMounted(() => {
890
+ loadConfig();
891
+ });
892
+ Vue.onBeforeUnmount(() => {
893
+ formItemRefs.value.clear();
894
+ });
895
+ const findChangedFields = (newData, oldData) => {
896
+ const changedFields = [];
897
+ const allKeys = /* @__PURE__ */ new Set([
898
+ ...Object.keys(newData || {}),
899
+ ...Object.keys(oldData || {})
900
+ ]);
901
+ let initFlag = false;
902
+ if (Object.keys(oldData || {}).length === 0) {
903
+ initFlag = true;
904
+ }
905
+ for (const key of allKeys) {
906
+ if (initFlag) {
907
+ changedFields.push(key);
908
+ continue;
909
+ }
910
+ const hasKeyInNew = newData && Object.prototype.hasOwnProperty.call(newData, key);
911
+ const hasKeyInOld = oldData && Object.prototype.hasOwnProperty.call(oldData, key);
912
+ if (!hasKeyInNew && !hasKeyInOld) {
913
+ continue;
914
+ }
915
+ const newVal = hasKeyInNew ? newData[key] : void 0;
916
+ const oldVal = hasKeyInOld ? oldData[key] : void 0;
917
+ if (!newVal && !oldVal && Object.keys(oldData || {}).length === 0) {
918
+ continue;
919
+ }
920
+ if (JSON.stringify(newVal) != JSON.stringify(oldVal)) {
921
+ changedFields.push(key);
922
+ }
923
+ }
924
+ return changedFields;
925
+ };
926
+ const filterRelevantLinkageConfigs = (changedFieldNames, linkedConfig, fields) => {
927
+ const result = {
928
+ dataLink: [],
929
+ visibility: [],
930
+ required: [],
931
+ readonly: [],
932
+ disabled: [],
933
+ options: []
934
+ };
935
+ if (!linkedConfig || changedFieldNames.length === 0) {
936
+ return result;
937
+ }
938
+ const changedFieldIds = changedFieldNames.map((fieldName) => {
939
+ const field = fields.find((f) => f.fieldName == fieldName);
940
+ return field ? field.id : null;
941
+ }).filter((id) => id !== null);
942
+ if (linkedConfig.dataLink) {
943
+ result.dataLink = linkedConfig.dataLink.filter((item) => {
944
+ return changedFieldIds.some(
945
+ (fieldId) => parseFilterConfig.checkFieldInFilterConfig(item.filterConfig, fieldId) || parseFilterConfig.checkFieldInResultConfig(item.fieldAssignments, fieldId, fields)
946
+ );
947
+ });
948
+ }
949
+ if (linkedConfig.options) {
950
+ result.options = linkedConfig.options.filter((item) => {
951
+ return changedFieldIds.some(
952
+ (fieldId) => parseFilterConfig.checkFieldInFilterConfig(item.filterConfig, fieldId)
953
+ );
954
+ });
955
+ }
956
+ if (linkedConfig.visibility) {
957
+ result.visibility = linkedConfig.visibility;
958
+ }
959
+ if (linkedConfig.required) {
960
+ result.required = linkedConfig.required;
961
+ }
962
+ if (linkedConfig.readonly) {
963
+ result.readonly = linkedConfig.readonly;
964
+ }
965
+ if (linkedConfig.disabled) {
966
+ result.disabled = linkedConfig.disabled;
967
+ }
968
+ return result;
969
+ };
970
+ let isApplyingLinkage = false;
971
+ const applyLinkageEffectsForChangedFields = (changedFieldNames) => {
972
+ var _a;
973
+ if (isApplyingLinkage) return;
974
+ isApplyingLinkage = true;
975
+ const linkedConfig = localConfig.value.linkedConfig || {};
976
+ const fields = [...fieldsData.value, ...hiddenFields.value];
977
+ const relevantConfigs = filterRelevantLinkageConfigs(
978
+ changedFieldNames,
979
+ linkedConfig,
980
+ fields
981
+ );
982
+ relevantConfigs.dataLink.forEach((item) => {
983
+ if (parseFilterConfig.checkFilterMatch(item.filterConfig, formData.value, fields)) {
984
+ const fieldAssignments = item.fieldAssignments || [];
985
+ fieldAssignments.forEach((assignment) => {
986
+ var _a2, _b;
987
+ const fieldId = assignment.fieldId;
988
+ const formulaText = (_b = (_a2 = assignment.formula) == null ? void 0 : _a2.value) == null ? void 0 : _b.text;
989
+ const field = fields.find((f) => f.id == fieldId);
990
+ if (field && formulaText) {
991
+ const calcResult = calculate.calculate({
992
+ text: formulaText,
993
+ marks: [],
994
+ value: formData.value,
995
+ fieldsList: fields
996
+ });
997
+ if (!common.isEqual(formData.value[field.fieldName], calcResult)) {
998
+ formData.value[field.fieldName] = calcResult;
999
+ }
1000
+ }
1001
+ });
1002
+ }
1003
+ });
1004
+ const updatedLayoutData = common.cloneDeep(oriGridLayoutData.value || []);
1005
+ relevantConfigs.options.forEach((item) => {
1006
+ if (parseFilterConfig.checkFilterMatch(item.filterConfig, formData.value, fields)) {
1007
+ const fieldAssignments = item.fieldAssignments || [];
1008
+ fieldAssignments.forEach((assignment) => {
1009
+ const fieldId = assignment.fieldId;
1010
+ const optionsOpt = assignment.optionsOpt || [];
1011
+ const layoutFieldItem = updatedLayoutData.find((g) => g.id == fieldId);
1012
+ if (layoutFieldItem && optionsOpt.length > 0) {
1013
+ const oriOptions = layoutFieldItem.component.optionConfig.options;
1014
+ layoutFieldItem.component.optionConfig.options = oriOptions.filter(
1015
+ (item2) => optionsOpt.includes(item2.value)
1016
+ );
1017
+ }
1018
+ });
1019
+ }
1020
+ });
1021
+ relevantConfigs.visibility.forEach((item) => {
1022
+ const dataLinkFieldList = item.dataLinkFieldList || [];
1023
+ dataLinkFieldList.forEach((fieldId) => {
1024
+ const layoutFieldItem = updatedLayoutData.find((g) => g.id == fieldId);
1025
+ if (layoutFieldItem) {
1026
+ layoutFieldItem.hidden = true;
1027
+ }
1028
+ });
1029
+ if (parseFilterConfig.checkFilterMatch(item.filterConfig, formData.value, fields)) {
1030
+ dataLinkFieldList.forEach((fieldId) => {
1031
+ const layoutFieldItem = updatedLayoutData.find((g) => g.id == fieldId);
1032
+ if (layoutFieldItem) {
1033
+ layoutFieldItem.hidden = false;
1034
+ }
1035
+ });
1036
+ }
1037
+ });
1038
+ relevantConfigs.required.forEach((item) => {
1039
+ const dataLinkFieldList = item.dataLinkFieldList || [];
1040
+ dataLinkFieldList.forEach((fieldId) => {
1041
+ const layoutFieldItem = updatedLayoutData.find((g) => g.id == fieldId);
1042
+ if (layoutFieldItem) {
1043
+ layoutFieldItem.component.required = false;
1044
+ }
1045
+ });
1046
+ if (parseFilterConfig.checkFilterMatch(item.filterConfig, formData.value, fields)) {
1047
+ dataLinkFieldList.forEach((fieldId) => {
1048
+ const layoutFieldItem = updatedLayoutData.find((g) => g.id == fieldId);
1049
+ if (layoutFieldItem) {
1050
+ layoutFieldItem.component.required = true;
1051
+ }
1052
+ });
1053
+ }
1054
+ });
1055
+ const rules = {};
1056
+ updatedLayoutData.forEach(({ component }) => {
1057
+ if (component.fieldName) {
1058
+ const fieldRules = validation.generateFieldRules(component, formData, fields);
1059
+ if (fieldRules.length > 0) {
1060
+ rules[component.fieldName] = fieldRules;
1061
+ }
1062
+ }
1063
+ });
1064
+ for (let fieldName in prodRules.value) {
1065
+ if (rules[fieldName]) {
1066
+ rules[fieldName].push(...prodRules.value[fieldName]);
1067
+ } else {
1068
+ rules[fieldName] = prodRules.value[fieldName];
1069
+ }
1070
+ }
1071
+ formRules.value = rules;
1072
+ if (formMode.value != "query") {
1073
+ relevantConfigs.readonly.forEach((item) => {
1074
+ const dataLinkFieldList = item.dataLinkFieldList || [];
1075
+ dataLinkFieldList.forEach((fieldId) => {
1076
+ const layoutFieldItem = updatedLayoutData.find((g) => g.id == fieldId);
1077
+ if (layoutFieldItem) {
1078
+ layoutFieldItem.component.readOnly = false;
1079
+ }
1080
+ });
1081
+ if (parseFilterConfig.checkFilterMatch(item.filterConfig, formData.value, fields)) {
1082
+ dataLinkFieldList.forEach((fieldId) => {
1083
+ const layoutFieldItem = updatedLayoutData.find(
1084
+ (g) => g.id == fieldId
1085
+ );
1086
+ if (layoutFieldItem) {
1087
+ layoutFieldItem.component.readOnly = true;
1088
+ }
1089
+ });
1090
+ }
1091
+ });
1092
+ relevantConfigs.disabled.forEach((item) => {
1093
+ const dataLinkFieldList = item.dataLinkFieldList || [];
1094
+ dataLinkFieldList.forEach((fieldId) => {
1095
+ const layoutFieldItem = updatedLayoutData.find((g) => g.id == fieldId);
1096
+ if (layoutFieldItem) {
1097
+ layoutFieldItem.component.disabled = false;
1098
+ }
1099
+ });
1100
+ if (parseFilterConfig.checkFilterMatch(item.filterConfig, formData.value, fields)) {
1101
+ dataLinkFieldList.forEach((fieldId) => {
1102
+ const layoutFieldItem = updatedLayoutData.find(
1103
+ (g) => g.id == fieldId
1104
+ );
1105
+ if (layoutFieldItem) {
1106
+ layoutFieldItem.component.disabled = true;
1107
+ }
1108
+ });
1109
+ }
1110
+ });
1111
+ }
1112
+ const fieldsConfigArr = updatedLayoutData.filter((item) => !item.hidden);
1113
+ gridLayoutFieldsData.value = sortLayoutItems(fieldsConfigArr);
1114
+ (_a = gridLayout == null ? void 0 : gridLayout.value) == null ? void 0 : _a.resizeEvent();
1115
+ isApplyingLinkage = false;
1116
+ };
1117
+ function sortLayoutItems(arr) {
1118
+ return [...arr].sort((a, b) => {
1119
+ if (a.y !== b.y) {
1120
+ return a.y - b.y;
1121
+ }
1122
+ return a.x - b.x;
1123
+ });
1124
+ }
1125
+ const subTableCounts = Vue.ref({});
1126
+ const navLinkCompId = Vue.ref("");
1127
+ const anchorNavLinks = Vue.computed(() => {
1128
+ var _a;
1129
+ const baseId = (_a = gridLayoutFieldsData.value) == null ? void 0 : _a[0].id;
1130
+ const list = gridLayoutFieldsData.value.map((item) => {
1131
+ if (item.component.fieldType == "h2") {
1132
+ return {
1133
+ id: item.id,
1134
+ title: item.component.label
1135
+ };
1136
+ } else if (item.component.titleMode == "label") {
1137
+ return {
1138
+ id: item.id,
1139
+ title: item.component.label,
1140
+ count: subTableCounts.value[item.id] ?? 0
1141
+ };
1142
+ } else {
1143
+ return null;
1144
+ }
1145
+ }).filter(Boolean);
1146
+ if (list.length == 0) {
1147
+ return list;
1148
+ }
1149
+ return [{ id: baseId, title: "基本信息" }, ...list];
1150
+ });
1151
+ eventBus.default.on("onSubTableDataLoaded", ({ subTableConfig, visibleData }) => {
1152
+ const id = subTableConfig.id;
1153
+ const count = (visibleData == null ? void 0 : visibleData.length) || 0;
1154
+ subTableCounts.value[id] = count;
1155
+ });
1156
+ const navType = Vue.computed(() => {
1157
+ var _a;
1158
+ if ((localConfig.value.navigationEnabled ?? true) && !props.isSubForm && ((_a = anchorNavLinks.value) == null ? void 0 : _a.length) > 0 && fecFormRef.value) {
1159
+ if (fecFormRef.value.$el.closest(".fec-layout-row")) {
1160
+ return "top";
1161
+ } else {
1162
+ if (!props.isDialog) {
1163
+ return "right";
1164
+ } else {
1165
+ return "";
1166
+ }
1167
+ }
1168
+ } else {
1169
+ return "";
1170
+ }
1171
+ });
1172
+ function initLinkage() {
1173
+ const changedFields = findChangedFields(formData.value, prevFormData.value);
1174
+ if (changedFields.length > 0) {
1175
+ applyLinkageEffectsForChangedFields(changedFields);
1176
+ }
1177
+ prevFormData.value = { ...formData.value };
1178
+ linkaged = true;
1179
+ }
1180
+ Vue.watch(
1181
+ formData,
1182
+ (newVal, oldVal) => {
1183
+ if (!linkaged) {
1184
+ return;
1185
+ }
1186
+ const lastValue = { ...prevFormData.value };
1187
+ if (common.isEqual(newVal, lastValue)) {
1188
+ return;
1189
+ }
1190
+ const changedFields = findChangedFields(newVal, lastValue);
1191
+ if (changedFields.length > 0) {
1192
+ applyLinkageEffectsForChangedFields(changedFields);
1193
+ }
1194
+ prevFormData.value = { ...formData.value };
1195
+ isSyncingToParent = true;
1196
+ emit("update:modelValue", getFormData());
1197
+ Vue.nextTick(() => {
1198
+ isSyncingToParent = false;
1199
+ });
1200
+ },
1201
+ { deep: true }
1202
+ );
1203
+ function setFormItemHeight(id, fixedH, h) {
1204
+ var _a;
1205
+ const item = gridLayoutFieldsData.value.find((item2) => item2.id == id);
1206
+ if (!fixedH) {
1207
+ item.h = h * 60;
1208
+ } else if (fixedH) {
1209
+ item.h = h / (localConfig.value.labelPosition == "top" ? 1.5 : 1);
1210
+ }
1211
+ const oriItem = oriGridLayoutData.value.find((item2) => item2.id == id);
1212
+ if (!fixedH) {
1213
+ oriItem.h = h * 60;
1214
+ } else if (fixedH) {
1215
+ oriItem.h = h / (localConfig.value.labelPosition == "top" ? 1.5 : 1);
1216
+ }
1217
+ (_a = gridLayout == null ? void 0 : gridLayout.value) == null ? void 0 : _a.resizeEvent();
1218
+ }
1219
+ Vue.provide("formData", formData);
1220
+ Vue.provide("localConfig", localConfig);
1221
+ Vue.provide("fieldsData", fieldsData);
1222
+ Vue.provide("hiddenFields", hiddenFields);
1223
+ Vue.provide("rowHeight", rowHeight);
1224
+ Vue.provide("gridLayout", gridLayout);
1225
+ Vue.provide("gridLayoutFieldsData", gridLayoutFieldsData);
1226
+ Vue.provide("setFormItemHeight", setFormItemHeight);
1227
+ Vue.provide("formCtx", ctx);
1228
+ Vue.provide("handleEvent", handleEvent);
1229
+ Vue.provide("getFormData", getFormData);
1230
+ __expose({
1231
+ validate,
1232
+ docValidate,
1233
+ resetFields,
1234
+ getFormData,
1235
+ setFormData,
1236
+ getFormItemRef,
1237
+ formRef,
1238
+ localConfig,
1239
+ handleApprovalEvent,
1240
+ hasSaveButton
1241
+ });
1242
+ return (_ctx, _cache) => {
1243
+ const _component_el_form = index$7.ElForm;
1244
+ const _component_el_col = index$4.ElCol;
1245
+ const _component_el_container = index$3.ElContainer;
1246
+ const _directive_fec_layout = Vue.resolveDirective("fec-layout");
1247
+ return !configLoading.value ? Vue.withDirectives((Vue.openBlock(), Vue.createBlock(_component_el_container, {
1248
+ key: 0,
1249
+ class: Vue.normalizeClass(["fec-form", __props.class]),
1250
+ "data-id": localConfig.value.templateKey,
1251
+ "data-name": localConfig.value.templateName,
1252
+ "data-pkId": localConfig.value.pkId,
1253
+ "data-version": "v5",
1254
+ ref_key: "fecFormRef",
1255
+ ref: fecFormRef
1256
+ }, {
1257
+ default: Vue.withCtx(() => [
1258
+ Vue.createVNode(_component_el_col, {
1259
+ span: Vue.unref(navType) == "right" ? 21 : 24,
1260
+ class: "fec-form-col",
1261
+ style: Vue.normalizeStyle({ marginRight: Vue.unref(navType) == "right" ? "4px" : "0" })
1262
+ }, {
1263
+ default: Vue.withCtx(() => [
1264
+ Vue.createVNode(Vue.unref(index$5.header), {
1265
+ showBack: !__props.isSubForm && !__props.isDialog,
1266
+ isApproval: __props.isApproval,
1267
+ pageHeaderConfig: localConfig.value.pageHeaderConfig,
1268
+ onActionClick: handleActionClick
1269
+ }, null, 8, ["showBack", "isApproval", "pageHeaderConfig"]),
1270
+ Vue.unref(navType) == "top" ? (Vue.openBlock(), Vue.createBlock(FormAnchorNav.default, {
1271
+ key: 0,
1272
+ fecFormRef: fecFormRef.value,
1273
+ links: Vue.unref(anchorNavLinks),
1274
+ modelValue: navLinkCompId.value,
1275
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => navLinkCompId.value = $event)
1276
+ }, null, 8, ["fecFormRef", "links", "modelValue"])) : Vue.createCommentVNode("", true),
1277
+ Vue.createVNode(Vue.unref(index$6.main), null, {
1278
+ default: Vue.withCtx(() => [
1279
+ Vue.createVNode(_component_el_form, {
1280
+ ref_key: "formRef",
1281
+ ref: formRef,
1282
+ model: formData.value,
1283
+ rules: formRules.value,
1284
+ "label-position": localConfig.value.labelPosition,
1285
+ style: { padding: "0", width: "100%" },
1286
+ class: Vue.normalizeClass({ "fec-el-form": !__props.isSubForm }),
1287
+ "validate-on-rule-change": false,
1288
+ size: "large",
1289
+ "scroll-to-error": ""
1290
+ }, {
1291
+ default: Vue.withCtx(() => [
1292
+ Vue.createVNode(Vue.unref(gridLayout_vue.default), {
1293
+ ref_key: "gridLayout",
1294
+ ref: gridLayout,
1295
+ layout: gridLayoutFieldsData.value,
1296
+ "onUpdate:layout": _cache[1] || (_cache[1] = ($event) => gridLayoutFieldsData.value = $event),
1297
+ "row-height": rowHeight.value,
1298
+ margin: [0, 0],
1299
+ "use-css-transforms": false,
1300
+ "col-num": localConfig.value.columns,
1301
+ "is-draggable": false,
1302
+ "is-resizable": false,
1303
+ onLayoutUpdated: layoutUpdated
1304
+ }, {
1305
+ item: Vue.withCtx(({ item: { component } }) => [
1306
+ Vue.createVNode(Vue.unref(index$8.FormItem), {
1307
+ ref: (el) => setFormItemRef(el, component),
1308
+ modelValue: formData.value[component.fieldName],
1309
+ "onUpdate:modelValue": ($event) => formData.value[component.fieldName] = $event,
1310
+ config: component,
1311
+ localConfig: localConfig.value,
1312
+ error: getFieldError(component.fieldName),
1313
+ formRef: formRef.value,
1314
+ formMode: formMode.value,
1315
+ dataChangeManager: dataChangeManager.value,
1316
+ onChange: handleFieldChange,
1317
+ onLabelLink: handleLabelLink
1318
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "config", "localConfig", "error", "formRef", "formMode", "dataChangeManager"])
1319
+ ]),
1320
+ _: 1
1321
+ }, 8, ["layout", "row-height", "col-num"]),
1322
+ (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(hiddenFields.value, (field) => {
1323
+ return Vue.openBlock(), Vue.createElementBlock("input", {
1324
+ key: field.fieldName,
1325
+ type: "hidden",
1326
+ name: field.fieldName,
1327
+ value: formData.value[field.fieldName]
1328
+ }, null, 8, _hoisted_1);
1329
+ }), 128))
1330
+ ]),
1331
+ _: 1
1332
+ }, 8, ["model", "rules", "label-position", "class"])
1333
+ ]),
1334
+ _: 1
1335
+ }),
1336
+ !__props.isSubForm && !__props.isDialog && !__props.isApproval ? (Vue.openBlock(), Vue.createBlock(Vue.unref(index$9.footer), {
1337
+ key: 1,
1338
+ formMode: formMode.value,
1339
+ pageFooterConfig: localConfig.value.pageFooterConfig,
1340
+ onCustomButtonClick: handleCustomButtonClick
1341
+ }, null, 8, ["formMode", "pageFooterConfig"])) : Vue.createCommentVNode("", true)
1342
+ ]),
1343
+ _: 1
1344
+ }, 8, ["span", "style"]),
1345
+ Vue.unref(navType) == "right" ? (Vue.openBlock(), Vue.createBlock(_component_el_col, {
1346
+ key: 0,
1347
+ span: 3,
1348
+ class: "fec-form-col",
1349
+ style: { "margin-left": "4px" }
1350
+ }, {
1351
+ default: Vue.withCtx(() => [
1352
+ Vue.createVNode(RightAnchorNav.default, {
1353
+ fecFormRef: fecFormRef.value,
1354
+ links: Vue.unref(anchorNavLinks),
1355
+ modelValue: navLinkCompId.value,
1356
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => navLinkCompId.value = $event)
1357
+ }, null, 8, ["fecFormRef", "links", "modelValue"])
1358
+ ]),
1359
+ _: 1
1360
+ })) : Vue.createCommentVNode("", true)
1361
+ ]),
1362
+ _: 1
1363
+ }, 8, ["class", "data-id", "data-name", "data-pkId"])), [
1364
+ [_directive_fec_layout]
1365
+ ]) : Vue.createCommentVNode("", true);
1366
+ };
1367
+ }
1368
+ });
1369
+ const _Form = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-2a14b0ea"]]);
1370
+ exports.default = _Form;