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