@fecp/designer 5.6.29 → 5.6.31
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/_virtual/_commonjsHelpers.mjs +25 -0
- package/es/_virtual/index.mjs +4 -4
- package/es/_virtual/index2.mjs +2 -5
- package/es/_virtual/index3.mjs +5 -3
- package/es/_virtual/index4.mjs +5 -2
- package/es/_virtual/index5.mjs +3 -2
- package/es/_virtual/index6.mjs +4 -0
- package/es/_virtual/index7.mjs +4 -0
- package/es/config-dev.js +2 -0
- package/es/designer/package.json.mjs +1 -1
- package/es/designer/src/axios/config.mjs +10 -3
- package/es/designer/src/axios/crypto.mjs +1 -5
- package/es/designer/src/packages/aiForm/AiDiffTable.vue.mjs +152 -0
- package/es/designer/src/packages/aiForm/api.mjs +21 -0
- package/es/designer/src/packages/aiForm/apply.mjs +153 -0
- package/es/designer/src/packages/aiForm/compressConfig.mjs +69 -0
- package/es/designer/src/packages/aiForm/constants.mjs +184 -0
- package/es/designer/src/packages/aiForm/diff.mjs +140 -0
- package/es/designer/src/packages/aiForm/index.vue.mjs +301 -0
- package/es/designer/src/packages/aiForm/normalizeFieldList.mjs +138 -0
- package/es/designer/src/packages/aiForm/parseAiResult.mjs +245 -0
- package/es/designer/src/packages/aiForm/prompt.mjs +130 -0
- package/es/designer/src/packages/aiForm/useAiFormDrawer.mjs +16 -0
- package/es/designer/src/packages/dataSource/dataSource.vue.mjs +45 -30
- package/es/designer/src/packages/form/headerBtn.vue.mjs +4 -1
- package/es/designer/src/packages/form/index.vue.mjs +16 -2
- package/es/designer/src/packages/utils/datasource.mjs +14 -1
- package/es/designer.css +523 -232
- package/es/node_modules/@braintree/sanitize-url/dist/index.mjs +1 -1
- package/es/node_modules/diagram-js/lib/model/index.mjs +1 -1
- package/es/node_modules/element-plus/es/utils/vue/icon.mjs +1 -1
- package/es/node_modules/highlight.js/es/index.mjs +1 -1
- package/es/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-LMCZKHZV.mjs +1 -1
- package/es/node_modules/mermaid/dist/chunks/mermaid.core/chunk-32BRIVSS.mjs +1 -1
- package/es/node_modules/mermaid/dist/chunks/mermaid.core/chunk-ICXQ74PX.mjs +1 -1
- package/es/node_modules/mermaid/dist/chunks/mermaid.core/classDiagram-OUVF2IWQ.mjs +1 -1
- package/es/node_modules/mermaid/dist/chunks/mermaid.core/classDiagram-v2-EOCWNBFH.mjs +1 -1
- package/es/node_modules/mermaid/dist/chunks/mermaid.core/flowDiagram-23GEKE2U.mjs +1 -1
- package/es/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-NO4QXBWP.mjs +1 -1
- package/es/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-DBY2YBRQ.mjs +1 -1
- package/es/node_modules/mermaid/dist/chunks/mermaid.core/stateDiagram-2N3HPSRC.mjs +1 -1
- package/es/node_modules/mermaid/dist/chunks/mermaid.core/stateDiagram-v2-6OUMAXLB.mjs +1 -1
- package/es/node_modules/mermaid/dist/chunks/mermaid.core/swimlanesDiagram-G3AALYLV.mjs +1 -1
- package/es/node_modules/object-refs/index.mjs +1 -1
- package/es/packages/mobile/src/axios/config.mjs +8 -4
- package/es/packages/mobile/src/components/ai/MarkdownRenderer/MarkdownRenderer.vue.mjs +1 -1
- package/es/packages/mobile/src/components/custom/approvalBar/ApprovalBar.vue.mjs +53 -13
- package/es/packages/mobile/src/components/custom/approvalBar/FlowUserSelect.vue.mjs +215 -0
- package/es/packages/mobile/src/components/dataDisplay/cardList/CardList.vue.mjs +19 -15
- package/es/packages/mobile/src/utils/datasource.mjs +14 -1
- package/es/packages/mobile/src/utils/formatterUtil.mjs +24 -12
- package/es/packages/vue/src/components/dialog/DialogRenderer.vue2.mjs +75 -8
- package/es/packages/vue/src/components/dialog/index.mjs +2 -1
- package/es/packages/vue/src/components/forms/form/Form.vue.mjs +10 -49
- package/es/packages/vue/src/components/forms/formItem/FormItem.vue.mjs +2 -12
- package/es/packages/vue/src/components/forms/roleSelect/RoleSelect.vue.mjs +9 -3
- package/es/packages/vue/src/components/forms/userSelect/UserSelect.vue.mjs +9 -3
- package/es/packages/vue/src/components/table/Table.vue.mjs +119 -11
- package/es/packages/vue/src/utils/datasource.mjs +14 -1
- package/lib/_virtual/_commonjsHelpers.js +25 -0
- package/lib/_virtual/index.js +4 -4
- package/lib/_virtual/index2.js +3 -6
- package/lib/_virtual/index3.js +6 -4
- package/lib/_virtual/index4.js +6 -3
- package/lib/_virtual/index5.js +3 -2
- package/lib/_virtual/index6.js +4 -0
- package/lib/_virtual/index7.js +4 -0
- package/lib/config-dev.js +2 -0
- package/lib/designer/package.json.js +1 -1
- package/lib/designer/src/axios/config.js +10 -3
- package/lib/designer/src/axios/crypto.js +0 -4
- package/lib/designer/src/packages/aiForm/AiDiffTable.vue.js +152 -0
- package/lib/designer/src/packages/aiForm/api.js +21 -0
- package/lib/designer/src/packages/aiForm/apply.js +153 -0
- package/lib/designer/src/packages/aiForm/compressConfig.js +69 -0
- package/lib/designer/src/packages/aiForm/constants.js +184 -0
- package/lib/designer/src/packages/aiForm/diff.js +140 -0
- package/lib/designer/src/packages/aiForm/index.vue.js +301 -0
- package/lib/designer/src/packages/aiForm/normalizeFieldList.js +138 -0
- package/lib/designer/src/packages/aiForm/parseAiResult.js +245 -0
- package/lib/designer/src/packages/aiForm/prompt.js +130 -0
- package/lib/designer/src/packages/aiForm/useAiFormDrawer.js +16 -0
- package/lib/designer/src/packages/dataSource/dataSource.vue.js +44 -29
- package/lib/designer/src/packages/form/headerBtn.vue.js +4 -1
- package/lib/designer/src/packages/form/index.vue.js +15 -1
- package/lib/designer/src/packages/utils/datasource.js +14 -1
- package/lib/designer.css +523 -232
- package/lib/node_modules/@braintree/sanitize-url/dist/index.js +1 -1
- package/lib/node_modules/diagram-js/lib/model/index.js +1 -1
- package/lib/node_modules/highlight.js/es/index.js +1 -1
- package/lib/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-LMCZKHZV.js +1 -1
- package/lib/node_modules/mermaid/dist/chunks/mermaid.core/chunk-32BRIVSS.js +1 -1
- package/lib/node_modules/mermaid/dist/chunks/mermaid.core/chunk-ICXQ74PX.js +1 -1
- package/lib/node_modules/mermaid/dist/chunks/mermaid.core/classDiagram-OUVF2IWQ.js +1 -1
- package/lib/node_modules/mermaid/dist/chunks/mermaid.core/classDiagram-v2-EOCWNBFH.js +1 -1
- package/lib/node_modules/mermaid/dist/chunks/mermaid.core/flowDiagram-23GEKE2U.js +1 -1
- package/lib/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-NO4QXBWP.js +1 -1
- package/lib/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-DBY2YBRQ.js +1 -1
- package/lib/node_modules/mermaid/dist/chunks/mermaid.core/stateDiagram-2N3HPSRC.js +1 -1
- package/lib/node_modules/mermaid/dist/chunks/mermaid.core/stateDiagram-v2-6OUMAXLB.js +1 -1
- package/lib/node_modules/mermaid/dist/chunks/mermaid.core/swimlanesDiagram-G3AALYLV.js +1 -1
- package/lib/node_modules/object-refs/index.js +1 -1
- package/lib/packages/mobile/src/axios/config.js +8 -4
- package/lib/packages/mobile/src/components/ai/MarkdownRenderer/MarkdownRenderer.vue.js +1 -1
- package/lib/packages/mobile/src/components/custom/approvalBar/ApprovalBar.vue.js +52 -12
- package/lib/packages/mobile/src/components/custom/approvalBar/FlowUserSelect.vue.js +215 -0
- package/lib/packages/mobile/src/components/dataDisplay/cardList/CardList.vue.js +19 -15
- package/lib/packages/mobile/src/utils/datasource.js +14 -1
- package/lib/packages/mobile/src/utils/formatterUtil.js +24 -12
- package/lib/packages/vue/src/components/dialog/DialogRenderer.vue2.js +75 -8
- package/lib/packages/vue/src/components/dialog/index.js +2 -1
- package/lib/packages/vue/src/components/forms/form/Form.vue.js +9 -48
- package/lib/packages/vue/src/components/forms/formItem/FormItem.vue.js +1 -11
- package/lib/packages/vue/src/components/forms/roleSelect/RoleSelect.vue.js +9 -3
- package/lib/packages/vue/src/components/forms/userSelect/UserSelect.vue.js +9 -3
- package/lib/packages/vue/src/components/table/Table.vue.js +118 -10
- package/lib/packages/vue/src/utils/datasource.js +14 -1
- package/package.json +1 -1
|
@@ -0,0 +1,301 @@
|
|
|
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
|
+
const eventBus = require("../utils/eventBus.js");
|
|
14
|
+
const common = require("../utils/common.js");
|
|
15
|
+
const AiDiffTable = require("./AiDiffTable.vue.js");
|
|
16
|
+
const compressConfig = require("./compressConfig.js");
|
|
17
|
+
const normalizeFieldList = require("./normalizeFieldList.js");
|
|
18
|
+
const prompt = require("./prompt.js");
|
|
19
|
+
const api = require("./api.js");
|
|
20
|
+
const parseAiResult = require("./parseAiResult.js");
|
|
21
|
+
const diff = require("./diff.js");
|
|
22
|
+
const apply = require("./apply.js");
|
|
23
|
+
;/* empty css */
|
|
24
|
+
const _pluginVue_exportHelper = require("../../../../_virtual/_plugin-vue_export-helper.js");
|
|
25
|
+
const index = require("../../../../node_modules/element-plus/es/components/drawer/index.js");
|
|
26
|
+
const index$1 = require("../../../../node_modules/element-plus/es/components/input/index.js");
|
|
27
|
+
const index$2 = require("../../../../node_modules/element-plus/es/components/collapse/index.js");
|
|
28
|
+
const index$3 = require("../../../../node_modules/element-plus/es/components/button/index.js");
|
|
29
|
+
const index$4 = require("../../../../node_modules/element-plus/es/components/alert/index.js");
|
|
30
|
+
const index$5 = require("../../../../node_modules/element-plus/es/components/message/index.js");
|
|
31
|
+
const cloneDeep = require("../../../../node_modules/lodash-es/cloneDeep.js");
|
|
32
|
+
const _hoisted_1 = { class: "ai-form-drawer" };
|
|
33
|
+
const _hoisted_2 = { class: "ctx-bar" };
|
|
34
|
+
const _hoisted_3 = {
|
|
35
|
+
key: 0,
|
|
36
|
+
class: "dot"
|
|
37
|
+
};
|
|
38
|
+
const _hoisted_4 = { key: 1 };
|
|
39
|
+
const _hoisted_5 = { class: "block" };
|
|
40
|
+
const _hoisted_6 = { class: "block" };
|
|
41
|
+
const _hoisted_7 = {
|
|
42
|
+
key: 1,
|
|
43
|
+
class: "block"
|
|
44
|
+
};
|
|
45
|
+
const drawerSize = "600px";
|
|
46
|
+
const _sfc_main = {
|
|
47
|
+
__name: "index",
|
|
48
|
+
props: {
|
|
49
|
+
modelValue: { type: Boolean, default: false }
|
|
50
|
+
},
|
|
51
|
+
emits: ["update:modelValue"],
|
|
52
|
+
setup(__props, { emit: __emit }) {
|
|
53
|
+
const props = __props;
|
|
54
|
+
const emit = __emit;
|
|
55
|
+
const visible = Vue.computed({
|
|
56
|
+
get: () => props.modelValue,
|
|
57
|
+
set: (val) => emit("update:modelValue", val)
|
|
58
|
+
});
|
|
59
|
+
const requirement = Vue.ref("");
|
|
60
|
+
const fieldListRaw = Vue.ref("");
|
|
61
|
+
const generating = Vue.ref(false);
|
|
62
|
+
const errorMessage = Vue.ref("");
|
|
63
|
+
const diffResult = Vue.ref(null);
|
|
64
|
+
const aiFormConfig = Vue.ref({});
|
|
65
|
+
const applied = Vue.ref(false);
|
|
66
|
+
const lastSnapshot = Vue.ref(null);
|
|
67
|
+
const sessionId = Vue.ref(createSessionId());
|
|
68
|
+
const canGenerate = Vue.computed(() => requirement.value.trim().length > 0 && !generating.value);
|
|
69
|
+
Vue.watch(visible, (val) => {
|
|
70
|
+
if (!val) return;
|
|
71
|
+
sessionId.value = createSessionId();
|
|
72
|
+
applied.value = false;
|
|
73
|
+
diffResult.value = null;
|
|
74
|
+
lastSnapshot.value = null;
|
|
75
|
+
errorMessage.value = "";
|
|
76
|
+
});
|
|
77
|
+
const editConfig = Vue.computed(() => common.getEditConfigData() || {});
|
|
78
|
+
const fieldCount = Vue.computed(() => (editConfig.value.fieldsData || []).length);
|
|
79
|
+
const columns = Vue.computed(() => editConfig.value.columns ?? 2);
|
|
80
|
+
const dsCount = Vue.computed(() => (editConfig.value.dataSources || []).length);
|
|
81
|
+
const dictCount = Vue.computed(() => {
|
|
82
|
+
const list = editConfig.value.fieldsData || [];
|
|
83
|
+
const set = /* @__PURE__ */ new Set();
|
|
84
|
+
list.forEach((it) => {
|
|
85
|
+
var _a, _b;
|
|
86
|
+
const key = (_b = (_a = it == null ? void 0 : it.component) == null ? void 0 : _a.optionConfig) == null ? void 0 : _b.dictionaryValue;
|
|
87
|
+
if (key) set.add(key);
|
|
88
|
+
});
|
|
89
|
+
return set.size;
|
|
90
|
+
});
|
|
91
|
+
async function handleGenerate() {
|
|
92
|
+
if (!canGenerate.value) return;
|
|
93
|
+
errorMessage.value = "";
|
|
94
|
+
diffResult.value = null;
|
|
95
|
+
applied.value = false;
|
|
96
|
+
aiFormConfig.value = {};
|
|
97
|
+
generating.value = true;
|
|
98
|
+
try {
|
|
99
|
+
const cfg = common.getEditConfigData();
|
|
100
|
+
const aiInput = compressConfig.buildAiInput(cfg);
|
|
101
|
+
const fieldList = normalizeFieldList.normalizeFieldList(fieldListRaw.value);
|
|
102
|
+
const payload = {
|
|
103
|
+
sessionId: sessionId.value,
|
|
104
|
+
scene: "formConfig",
|
|
105
|
+
systemPrompt: prompt.SYSTEM_PROMPT,
|
|
106
|
+
prompt: requirement.value.trim(),
|
|
107
|
+
currentConfig: aiInput.currentConfig,
|
|
108
|
+
dataSources: aiInput.dataSources,
|
|
109
|
+
dictionaries: aiInput.dictionaries,
|
|
110
|
+
fieldList,
|
|
111
|
+
history: []
|
|
112
|
+
};
|
|
113
|
+
payload.userPrompt = prompt.buildUserPrompt({
|
|
114
|
+
requirement: requirement.value.trim(),
|
|
115
|
+
currentConfig: aiInput.currentConfig,
|
|
116
|
+
dataSources: aiInput.dataSources,
|
|
117
|
+
dictionaries: aiInput.dictionaries,
|
|
118
|
+
fieldList,
|
|
119
|
+
history: []
|
|
120
|
+
});
|
|
121
|
+
const res = await api.generateFormConfig(payload);
|
|
122
|
+
const parsed = parseAiResult.parseAiResult(res.json ?? res.raw);
|
|
123
|
+
if (!parsed.ok) {
|
|
124
|
+
errorMessage.value = parsed.reason || "生成失败,请调整描述后重试。";
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
aiFormConfig.value = parsed.config.formConfig || {};
|
|
128
|
+
const next = diff.diffAiFields(parsed.config.fields, cfg);
|
|
129
|
+
const s = next.stats;
|
|
130
|
+
if (!s.add && !s.modify && !s.remove) {
|
|
131
|
+
diffResult.value = null;
|
|
132
|
+
index$5.ElMessage.info("AI 返回的配置与当前表单一致,没有需要应用的变更");
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
diffResult.value = next;
|
|
136
|
+
applied.value = true;
|
|
137
|
+
applyToCanvas(cfg);
|
|
138
|
+
index$5.ElMessage.success("AI 配置已应用到表单");
|
|
139
|
+
} catch (e) {
|
|
140
|
+
errorMessage.value = (e == null ? void 0 : e.message) || "请求失败,请稍后重试。";
|
|
141
|
+
} finally {
|
|
142
|
+
generating.value = false;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function applyToCanvas(cfg) {
|
|
146
|
+
const target = cfg || common.getEditConfigData();
|
|
147
|
+
const { fieldsData, formConfig } = apply.applyChanges({
|
|
148
|
+
editConfigData: target,
|
|
149
|
+
diffResult: diffResult.value,
|
|
150
|
+
aiFormConfig: aiFormConfig.value
|
|
151
|
+
});
|
|
152
|
+
lastSnapshot.value = cloneDeep.default({
|
|
153
|
+
fieldsData: target.fieldsData || [],
|
|
154
|
+
columns: target.columns,
|
|
155
|
+
labelWidth: target.labelWidth,
|
|
156
|
+
labelPosition: target.labelPosition
|
|
157
|
+
});
|
|
158
|
+
target.fieldsData = fieldsData;
|
|
159
|
+
target.columns = formConfig.columns;
|
|
160
|
+
if (formConfig.labelWidth != null) target.labelWidth = formConfig.labelWidth;
|
|
161
|
+
if (formConfig.labelPosition) target.labelPosition = formConfig.labelPosition;
|
|
162
|
+
common.setEditConfigData(target);
|
|
163
|
+
eventBus.default.emit("refreshFormFields");
|
|
164
|
+
}
|
|
165
|
+
function handleUndo() {
|
|
166
|
+
if (!lastSnapshot.value) return;
|
|
167
|
+
const snap = cloneDeep.default(lastSnapshot.value);
|
|
168
|
+
const cfg = common.getEditConfigData();
|
|
169
|
+
cfg.fieldsData = snap.fieldsData;
|
|
170
|
+
cfg.columns = snap.columns;
|
|
171
|
+
cfg.labelWidth = snap.labelWidth;
|
|
172
|
+
cfg.labelPosition = snap.labelPosition;
|
|
173
|
+
common.setEditConfigData(cfg);
|
|
174
|
+
eventBus.default.emit("refreshFormFields");
|
|
175
|
+
lastSnapshot.value = null;
|
|
176
|
+
diffResult.value = null;
|
|
177
|
+
applied.value = false;
|
|
178
|
+
index$5.ElMessage.success("已撤销本次 AI 改动");
|
|
179
|
+
}
|
|
180
|
+
function createSessionId() {
|
|
181
|
+
return `formConfig_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
182
|
+
}
|
|
183
|
+
return (_ctx, _cache) => {
|
|
184
|
+
const _component_el_input = index$1.ElInput;
|
|
185
|
+
const _component_el_collapse_item = index$2.ElCollapseItem;
|
|
186
|
+
const _component_el_collapse = index$2.ElCollapse;
|
|
187
|
+
const _component_el_button = index$3.ElButton;
|
|
188
|
+
const _component_el_alert = index$4.ElAlert;
|
|
189
|
+
const _component_el_drawer = index.ElDrawer;
|
|
190
|
+
return Vue.openBlock(), Vue.createBlock(_component_el_drawer, {
|
|
191
|
+
modelValue: visible.value,
|
|
192
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => visible.value = $event),
|
|
193
|
+
title: "AI 表单助手",
|
|
194
|
+
direction: "rtl",
|
|
195
|
+
size: drawerSize,
|
|
196
|
+
"append-to-body": "",
|
|
197
|
+
"close-on-click-modal": false,
|
|
198
|
+
class: "ai-form-drawer-root"
|
|
199
|
+
}, {
|
|
200
|
+
footer: Vue.withCtx(() => [
|
|
201
|
+
Vue.createVNode(_component_el_button, {
|
|
202
|
+
onClick: _cache[2] || (_cache[2] = ($event) => visible.value = false)
|
|
203
|
+
}, {
|
|
204
|
+
default: Vue.withCtx(() => _cache[9] || (_cache[9] = [
|
|
205
|
+
Vue.createTextVNode("关闭")
|
|
206
|
+
])),
|
|
207
|
+
_: 1
|
|
208
|
+
}),
|
|
209
|
+
lastSnapshot.value ? (Vue.openBlock(), Vue.createBlock(_component_el_button, {
|
|
210
|
+
key: 0,
|
|
211
|
+
type: "warning",
|
|
212
|
+
plain: "",
|
|
213
|
+
disabled: generating.value,
|
|
214
|
+
onClick: handleUndo
|
|
215
|
+
}, {
|
|
216
|
+
default: Vue.withCtx(() => _cache[10] || (_cache[10] = [
|
|
217
|
+
Vue.createTextVNode(" 撤销本次 AI 改动 ")
|
|
218
|
+
])),
|
|
219
|
+
_: 1
|
|
220
|
+
}, 8, ["disabled"])) : Vue.createCommentVNode("", true)
|
|
221
|
+
]),
|
|
222
|
+
default: Vue.withCtx(() => [
|
|
223
|
+
Vue.createElementVNode("div", _hoisted_1, [
|
|
224
|
+
Vue.createElementVNode("div", _hoisted_2, [
|
|
225
|
+
Vue.createElementVNode("span", null, "当前表单:" + Vue.toDisplayString(fieldCount.value) + " 个字段 / " + Vue.toDisplayString(columns.value) + " 列", 1),
|
|
226
|
+
_cache[4] || (_cache[4] = Vue.createElementVNode("span", { class: "dot" }, "·", -1)),
|
|
227
|
+
Vue.createElementVNode("span", null, "数据源 " + Vue.toDisplayString(dsCount.value) + " 个", 1),
|
|
228
|
+
dictCount.value ? (Vue.openBlock(), Vue.createElementBlock("span", _hoisted_3, "·")) : Vue.createCommentVNode("", true),
|
|
229
|
+
dictCount.value ? (Vue.openBlock(), Vue.createElementBlock("span", _hoisted_4, "已知字典 " + Vue.toDisplayString(dictCount.value) + " 个", 1)) : Vue.createCommentVNode("", true)
|
|
230
|
+
]),
|
|
231
|
+
Vue.createElementVNode("div", _hoisted_5, [
|
|
232
|
+
_cache[5] || (_cache[5] = Vue.createElementVNode("div", { class: "block-title" }, "需求描述", -1)),
|
|
233
|
+
Vue.createVNode(_component_el_input, {
|
|
234
|
+
modelValue: requirement.value,
|
|
235
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => requirement.value = $event),
|
|
236
|
+
type: "textarea",
|
|
237
|
+
rows: 4,
|
|
238
|
+
resize: "none",
|
|
239
|
+
maxlength: "1000",
|
|
240
|
+
"show-word-limit": "",
|
|
241
|
+
placeholder: "描述你要生成的表单,或要对当前表单做什么修改。例如:新增一个出差申请表单,包含申请人、出差事由、起止日期、费用预算",
|
|
242
|
+
onKeydown: Vue.withKeys(Vue.withModifiers(handleGenerate, ["ctrl"]), ["enter"])
|
|
243
|
+
}, null, 8, ["modelValue", "onKeydown"])
|
|
244
|
+
]),
|
|
245
|
+
Vue.createElementVNode("div", _hoisted_6, [
|
|
246
|
+
Vue.createVNode(_component_el_collapse, null, {
|
|
247
|
+
default: Vue.withCtx(() => [
|
|
248
|
+
Vue.createVNode(_component_el_collapse_item, {
|
|
249
|
+
name: "fieldList",
|
|
250
|
+
title: "字段清单(可选)"
|
|
251
|
+
}, {
|
|
252
|
+
default: Vue.withCtx(() => [
|
|
253
|
+
_cache[6] || (_cache[6] = Vue.createElementVNode("div", { class: "hint" }, " 粘贴 CREATE TABLE 或 Java 实体类,AI 会优先采用其中的字段名、类型与注释。不填则由 AI 自行设计。 ", -1)),
|
|
254
|
+
Vue.createVNode(_component_el_input, {
|
|
255
|
+
modelValue: fieldListRaw.value,
|
|
256
|
+
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => fieldListRaw.value = $event),
|
|
257
|
+
type: "textarea",
|
|
258
|
+
rows: 6,
|
|
259
|
+
resize: "none",
|
|
260
|
+
placeholder: "例如:CREATE TABLE t_contract ( customer_name varchar(100) COMMENT '客户名称', amount decimal(18,2) COMMENT '合同金额' );"
|
|
261
|
+
}, null, 8, ["modelValue"])
|
|
262
|
+
]),
|
|
263
|
+
_: 1
|
|
264
|
+
})
|
|
265
|
+
]),
|
|
266
|
+
_: 1
|
|
267
|
+
})
|
|
268
|
+
]),
|
|
269
|
+
Vue.createVNode(_component_el_button, {
|
|
270
|
+
class: "gen-btn",
|
|
271
|
+
type: "primary",
|
|
272
|
+
loading: generating.value,
|
|
273
|
+
disabled: !canGenerate.value,
|
|
274
|
+
onClick: handleGenerate
|
|
275
|
+
}, {
|
|
276
|
+
default: Vue.withCtx(() => [
|
|
277
|
+
Vue.createTextVNode(Vue.toDisplayString(generating.value ? "AI 正在生成,请稍候…" : "生成表单配置"), 1)
|
|
278
|
+
]),
|
|
279
|
+
_: 1
|
|
280
|
+
}, 8, ["loading", "disabled"]),
|
|
281
|
+
errorMessage.value ? (Vue.openBlock(), Vue.createBlock(_component_el_alert, {
|
|
282
|
+
key: 0,
|
|
283
|
+
class: "block",
|
|
284
|
+
type: "error",
|
|
285
|
+
closable: false,
|
|
286
|
+
title: errorMessage.value
|
|
287
|
+
}, null, 8, ["title"])) : Vue.createCommentVNode("", true),
|
|
288
|
+
applied.value ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_7, [
|
|
289
|
+
_cache[7] || (_cache[7] = Vue.createElementVNode("div", { class: "block-title" }, "本次已应用到表单", -1)),
|
|
290
|
+
Vue.createVNode(AiDiffTable.default, { model: diffResult.value }, null, 8, ["model"]),
|
|
291
|
+
_cache[8] || (_cache[8] = Vue.createElementVNode("div", { class: "undo-hint" }, " AI 改动已直接写入画布,不满意可点右下角「撤销本次 AI 改动」。 ", -1))
|
|
292
|
+
])) : Vue.createCommentVNode("", true)
|
|
293
|
+
])
|
|
294
|
+
]),
|
|
295
|
+
_: 1
|
|
296
|
+
}, 8, ["modelValue"]);
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
const AiFormDrawer = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-ae307597"]]);
|
|
301
|
+
exports.default = AiFormDrawer;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const PIPE_HEADER = "columnName | dataType | comment | example | required";
|
|
4
|
+
function normalizeFieldList(rawText) {
|
|
5
|
+
const text = String(rawText || "").trim();
|
|
6
|
+
if (!text) return "";
|
|
7
|
+
const fromDdl = parseDdl(text);
|
|
8
|
+
if (fromDdl) return renderPipe(fromDdl);
|
|
9
|
+
const fromEntity = parseJavaEntity(text);
|
|
10
|
+
if (fromEntity) return renderPipe(fromEntity);
|
|
11
|
+
return text;
|
|
12
|
+
}
|
|
13
|
+
function parseDdl(text) {
|
|
14
|
+
if (!/create\s+table/i.test(text)) return null;
|
|
15
|
+
const body = extractDdlBody(text);
|
|
16
|
+
if (!body) return null;
|
|
17
|
+
const lines = splitTopLevel(body);
|
|
18
|
+
const rows = [];
|
|
19
|
+
for (const line of lines) {
|
|
20
|
+
const row = parseDdlLine(line);
|
|
21
|
+
if (row) rows.push(row);
|
|
22
|
+
}
|
|
23
|
+
return rows.length ? rows : null;
|
|
24
|
+
}
|
|
25
|
+
function parseJavaEntity(text) {
|
|
26
|
+
if (!/private\s+[\w.<>\[\]]+\s+\w+\s*;/.test(text)) return null;
|
|
27
|
+
const rows = [];
|
|
28
|
+
const re = /(?:@\w*(?:\([^)]*\))?\s*)?private\s+([\w.]+(?:<[^>]*>)?(?:\[\])?)\s+(\w+)\s*;/g;
|
|
29
|
+
let match;
|
|
30
|
+
while ((match = re.exec(text)) !== null) {
|
|
31
|
+
const javaType = match[1];
|
|
32
|
+
const name = match[2];
|
|
33
|
+
const lineEnd = text.indexOf("\n", match.index);
|
|
34
|
+
const line = text.slice(match.index, lineEnd === -1 ? void 0 : lineEnd);
|
|
35
|
+
const comment = getApiModelProperty(line) || getTailComment(line) || splitCamel(name);
|
|
36
|
+
rows.push({
|
|
37
|
+
name,
|
|
38
|
+
dataType: javaType.replace(/^java\.lang\./, ""),
|
|
39
|
+
comment,
|
|
40
|
+
example: "",
|
|
41
|
+
required: false
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return rows.length ? rows : null;
|
|
45
|
+
}
|
|
46
|
+
function renderDataType(type, length) {
|
|
47
|
+
const t = String(type || "").trim();
|
|
48
|
+
if (!t) return "";
|
|
49
|
+
if (length && /char|text|varchar/i.test(t)) {
|
|
50
|
+
return `${t}(${length})`;
|
|
51
|
+
}
|
|
52
|
+
return t;
|
|
53
|
+
}
|
|
54
|
+
function renderPipe(rows) {
|
|
55
|
+
const lines = rows.map(
|
|
56
|
+
(r) => [r.name, r.dataType, r.comment, r.example, String(!!r.required)].join(" | ")
|
|
57
|
+
);
|
|
58
|
+
return [PIPE_HEADER, ...lines].join("\n");
|
|
59
|
+
}
|
|
60
|
+
function extractDdlBody(text) {
|
|
61
|
+
const start = text.indexOf("(");
|
|
62
|
+
if (start === -1) return null;
|
|
63
|
+
const end = text.lastIndexOf(")");
|
|
64
|
+
if (end <= start) return null;
|
|
65
|
+
return text.slice(start + 1, end);
|
|
66
|
+
}
|
|
67
|
+
function splitTopLevel(body) {
|
|
68
|
+
const out = [];
|
|
69
|
+
let depth = 0;
|
|
70
|
+
let buf = "";
|
|
71
|
+
let inQuote = false;
|
|
72
|
+
for (let i = 0; i < body.length; i++) {
|
|
73
|
+
const ch = body[i];
|
|
74
|
+
if (inQuote) {
|
|
75
|
+
buf += ch;
|
|
76
|
+
if (ch === "'" && body[i - 1] !== "\\") inQuote = false;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (ch === "'") {
|
|
80
|
+
inQuote = true;
|
|
81
|
+
buf += ch;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (ch === "(") depth++;
|
|
85
|
+
if (ch === ")") depth--;
|
|
86
|
+
if (ch === "," && depth === 0) {
|
|
87
|
+
out.push(buf);
|
|
88
|
+
buf = "";
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
buf += ch;
|
|
92
|
+
}
|
|
93
|
+
if (buf.trim()) out.push(buf);
|
|
94
|
+
return out.map((s) => s.trim()).filter(Boolean);
|
|
95
|
+
}
|
|
96
|
+
const CONSTRAINT_KEYS = /^(primary\s+key|unique|key|index|constraint|foreign\s+key|fulltext|check)\b/i;
|
|
97
|
+
function parseDdlLine(line) {
|
|
98
|
+
if (CONSTRAINT_KEYS.test(line)) return null;
|
|
99
|
+
const nameMatch = line.match(/^[`"]?([\w$]+)[`"]?\s+(.*)$/s);
|
|
100
|
+
if (!nameMatch) return null;
|
|
101
|
+
const name = nameMatch[1];
|
|
102
|
+
const rest = nameMatch[2];
|
|
103
|
+
const typeMatch = rest.match(/^([\w]+)\s*(?:\(\s*([^)]*)\s*\))?/);
|
|
104
|
+
if (!typeMatch) return null;
|
|
105
|
+
const dataType = typeMatch[1];
|
|
106
|
+
const length = (typeMatch[2] || "").split(",")[0].trim();
|
|
107
|
+
let comment = "";
|
|
108
|
+
const commentMatch = rest.match(/comment\s+['"]([^'"]*)['"]/i);
|
|
109
|
+
if (commentMatch) {
|
|
110
|
+
comment = commentMatch[1];
|
|
111
|
+
} else {
|
|
112
|
+
const tail = rest.match(/--\s*(.+)$/) || rest.match(/#\s*(.+)$/);
|
|
113
|
+
if (tail) comment = tail[1].trim();
|
|
114
|
+
}
|
|
115
|
+
const required = /\bnot\s+null\b/i.test(rest);
|
|
116
|
+
return {
|
|
117
|
+
name,
|
|
118
|
+
dataType: renderDataType(dataType, length),
|
|
119
|
+
comment: comment.trim(),
|
|
120
|
+
example: "",
|
|
121
|
+
required
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function getApiModelProperty(line) {
|
|
125
|
+
const m = line.match(/@\w*ApiModelProperty\w*\s*\(\s*(?:value\s*=\s*)?["']([^"']*)["']/);
|
|
126
|
+
return m ? m[1] : "";
|
|
127
|
+
}
|
|
128
|
+
function getTailComment(line) {
|
|
129
|
+
const m = line.match(/;\s*(?:\/\/\s*|\/\*\s*)(.+?)(?:\*\/)?\s*$/);
|
|
130
|
+
return m ? m[1].trim() : "";
|
|
131
|
+
}
|
|
132
|
+
function splitCamel(name) {
|
|
133
|
+
const parts = String(name).replace(/([a-z\d])([A-Z])/g, "$1 $2").split(/[\s_]+/).filter(Boolean);
|
|
134
|
+
return parts.join(" ");
|
|
135
|
+
}
|
|
136
|
+
exports.normalizeFieldList = normalizeFieldList;
|
|
137
|
+
exports.parseDdl = parseDdl;
|
|
138
|
+
exports.parseJavaEntity = parseJavaEntity;
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const constants = require("./constants.js");
|
|
4
|
+
function extractJsonBlock(text) {
|
|
5
|
+
const s = String(text || "");
|
|
6
|
+
const fence = s.match(/```(?:json)?\s*([\s\S]*?)```/);
|
|
7
|
+
if (fence) return fence[1].trim();
|
|
8
|
+
const first = s.indexOf("{");
|
|
9
|
+
const last = s.lastIndexOf("}");
|
|
10
|
+
if (first !== -1 && last > first) return s.slice(first, last + 1);
|
|
11
|
+
return s.trim();
|
|
12
|
+
}
|
|
13
|
+
function parseLooseJson(text) {
|
|
14
|
+
const cleaned = extractJsonBlock(text).replace(/,\s*([}\]])/g, "$1").replace(/\/\/[^\n]*/g, "").replace(/^\s*(\w+)\s*:/gm, '"$1":');
|
|
15
|
+
return JSON.parse(cleaned);
|
|
16
|
+
}
|
|
17
|
+
function parseAiResult(payload) {
|
|
18
|
+
const issues = [];
|
|
19
|
+
let rawJson = payload;
|
|
20
|
+
if (typeof payload === "string") {
|
|
21
|
+
try {
|
|
22
|
+
rawJson = parseLooseJson(payload);
|
|
23
|
+
} catch (e) {
|
|
24
|
+
return {
|
|
25
|
+
ok: false,
|
|
26
|
+
reason: "AI 返回内容不是合法 JSON,可能是输出被截断。请重试或缩小修改范围。",
|
|
27
|
+
issues: []
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (!rawJson || typeof rawJson !== "object") {
|
|
32
|
+
return { ok: false, reason: "AI 返回结果为空。", issues: [] };
|
|
33
|
+
}
|
|
34
|
+
const rawFields = Array.isArray(rawJson.fields) ? rawJson.fields : Array.isArray(rawJson.fieldsData) ? rawJson.fieldsData : null;
|
|
35
|
+
if (!rawFields || !rawFields.length) {
|
|
36
|
+
return {
|
|
37
|
+
ok: false,
|
|
38
|
+
reason: "AI 返回的 fields 为空或不合法。",
|
|
39
|
+
issues: []
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const fields = [];
|
|
43
|
+
const seenNames = /* @__PURE__ */ new Set();
|
|
44
|
+
rawFields.forEach((item, index) => {
|
|
45
|
+
const pos = `fields[${index}]`;
|
|
46
|
+
if (!item || typeof item !== "object") {
|
|
47
|
+
issues.push({ field: pos, level: "error", message: "字段不是对象,已跳过" });
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const fieldType = item.fieldType;
|
|
51
|
+
if (!fieldType) {
|
|
52
|
+
issues.push({ field: pos, level: "error", message: "缺少 fieldType,已跳过" });
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (!constants.AI_FIELD_TYPES[fieldType]) {
|
|
56
|
+
issues.push({
|
|
57
|
+
field: pos,
|
|
58
|
+
level: "error",
|
|
59
|
+
message: `不支持的控件类型「${fieldType}」,已从生成结果中剔除(如确实需要请手动添加)`
|
|
60
|
+
});
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const cleaned = pickAllowedProps(item, fieldType, pos, issues);
|
|
64
|
+
if (constants.LAYOUT_FIELD_TYPES.includes(fieldType)) {
|
|
65
|
+
if (!cleaned.label) cleaned.label = constants.AI_FIELD_TYPES[fieldType].label;
|
|
66
|
+
} else {
|
|
67
|
+
const name = String(cleaned.fieldName || "").trim();
|
|
68
|
+
if (!name) {
|
|
69
|
+
issues.push({
|
|
70
|
+
field: pos,
|
|
71
|
+
level: "error",
|
|
72
|
+
message: `(${cleaned.label || fieldType})缺少 fieldName,已跳过`
|
|
73
|
+
});
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) {
|
|
77
|
+
issues.push({
|
|
78
|
+
field: pos,
|
|
79
|
+
level: "error",
|
|
80
|
+
message: `fieldName「${name}」非法(只能包含字母、数字、下划线且不以数字开头),已跳过`
|
|
81
|
+
});
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (seenNames.has(name)) {
|
|
85
|
+
issues.push({
|
|
86
|
+
field: pos,
|
|
87
|
+
level: "error",
|
|
88
|
+
message: `fieldName「${name}」重复,已跳过重复项`
|
|
89
|
+
});
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
seenNames.add(name);
|
|
93
|
+
cleaned.fieldName = name;
|
|
94
|
+
}
|
|
95
|
+
if (!cleaned.label) cleaned.label = cleaned.fieldName || "";
|
|
96
|
+
validateEnums(cleaned, pos, issues);
|
|
97
|
+
fields.push(cleaned);
|
|
98
|
+
});
|
|
99
|
+
if (!fields.length) {
|
|
100
|
+
return {
|
|
101
|
+
ok: false,
|
|
102
|
+
reason: "解析后没有任何可用字段。",
|
|
103
|
+
issues
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
ok: true,
|
|
108
|
+
config: {
|
|
109
|
+
formConfig: sanitizeFormConfig(rawJson.formConfig || {}),
|
|
110
|
+
fields
|
|
111
|
+
},
|
|
112
|
+
issues
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function pickAllowedProps(item, fieldType, pos, issues) {
|
|
116
|
+
const allowed = constants.getAllowedProps(fieldType);
|
|
117
|
+
const out = { fieldType };
|
|
118
|
+
const dropped = [];
|
|
119
|
+
for (const key of Object.keys(item)) {
|
|
120
|
+
if (!allowed.includes(key)) {
|
|
121
|
+
if (key === "width" || key === "insertAfter") {
|
|
122
|
+
out[key] = item[key];
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
dropped.push(key);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
out[key] = item[key];
|
|
129
|
+
}
|
|
130
|
+
if (dropped.length) {
|
|
131
|
+
issues.push({
|
|
132
|
+
field: pos,
|
|
133
|
+
level: "warn",
|
|
134
|
+
message: `忽略了不支持的属性:${dropped.join("、")}`
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
function validateEnums(field, pos, issues) {
|
|
140
|
+
if (field.width && !constants.AI_WIDTH_MODES.includes(field.width)) {
|
|
141
|
+
issues.push({
|
|
142
|
+
field: pos,
|
|
143
|
+
level: "warn",
|
|
144
|
+
message: `width 取值「${field.width}」无效,已按跟随列数处理`
|
|
145
|
+
});
|
|
146
|
+
delete field.width;
|
|
147
|
+
}
|
|
148
|
+
if (field.displayMode && !constants.AI_DISPLAY_MODES.includes(field.displayMode)) {
|
|
149
|
+
issues.push({
|
|
150
|
+
field: pos,
|
|
151
|
+
level: "warn",
|
|
152
|
+
message: `displayMode 取值「${field.displayMode}」无效,已忽略`
|
|
153
|
+
});
|
|
154
|
+
delete field.displayMode;
|
|
155
|
+
}
|
|
156
|
+
if (field.validationType && !constants.AI_VALIDATION_TYPES.includes(field.validationType)) {
|
|
157
|
+
issues.push({
|
|
158
|
+
field: pos,
|
|
159
|
+
level: "warn",
|
|
160
|
+
message: `validationType 取值「${field.validationType}」无效,已忽略`
|
|
161
|
+
});
|
|
162
|
+
delete field.validationType;
|
|
163
|
+
}
|
|
164
|
+
if (field.format && !constants.AI_NUMBER_FORMATS.includes(field.format)) {
|
|
165
|
+
issues.push({
|
|
166
|
+
field: pos,
|
|
167
|
+
level: "warn",
|
|
168
|
+
message: `format 取值「${field.format}」无效,已忽略`
|
|
169
|
+
});
|
|
170
|
+
delete field.format;
|
|
171
|
+
}
|
|
172
|
+
if (field.maxLength !== void 0) {
|
|
173
|
+
const n = Number(field.maxLength);
|
|
174
|
+
if (!Number.isFinite(n) || n <= 0) {
|
|
175
|
+
issues.push({
|
|
176
|
+
field: pos,
|
|
177
|
+
level: "warn",
|
|
178
|
+
message: `maxLength 取值「${field.maxLength}」无效,已忽略`
|
|
179
|
+
});
|
|
180
|
+
delete field.maxLength;
|
|
181
|
+
} else {
|
|
182
|
+
field.maxLength = Math.floor(n);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (field.insertAfter !== void 0 && typeof field.insertAfter !== "string") {
|
|
186
|
+
delete field.insertAfter;
|
|
187
|
+
}
|
|
188
|
+
if (constants.OPTION_FIELD_TYPES.includes(field.fieldType)) {
|
|
189
|
+
const oc = field.optionConfig;
|
|
190
|
+
if (!oc || typeof oc !== "object" || !oc.optionSource) {
|
|
191
|
+
issues.push({
|
|
192
|
+
field: pos,
|
|
193
|
+
level: "error",
|
|
194
|
+
message: `选择类控件「${field.label || field.fieldName}」缺少 optionConfig.optionSource,已降级为 custom(请补齐选项)`
|
|
195
|
+
});
|
|
196
|
+
field.optionConfig = { optionSource: "custom", options: [] };
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (oc.optionSource === "static") {
|
|
200
|
+
issues.push({
|
|
201
|
+
field: pos,
|
|
202
|
+
level: "warn",
|
|
203
|
+
message: "optionSource 的 static 已自动纠正为 custom(属性面板不接受 static)"
|
|
204
|
+
});
|
|
205
|
+
oc.optionSource = "custom";
|
|
206
|
+
}
|
|
207
|
+
if (!["custom", "dataSource", "dictionary"].includes(oc.optionSource)) {
|
|
208
|
+
issues.push({
|
|
209
|
+
field: pos,
|
|
210
|
+
level: "error",
|
|
211
|
+
message: `optionSource 取值「${oc.optionSource}」无效,已降级为 custom`
|
|
212
|
+
});
|
|
213
|
+
field.optionConfig = { optionSource: "custom", options: [] };
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (oc.optionSource === "custom" && !Array.isArray(oc.options)) {
|
|
217
|
+
oc.options = [];
|
|
218
|
+
}
|
|
219
|
+
if (oc.optionSource === "custom" && oc.options && oc.options.length < 2) {
|
|
220
|
+
issues.push({
|
|
221
|
+
field: pos,
|
|
222
|
+
level: "warn",
|
|
223
|
+
message: `「${field.label || field.fieldName}」的 custom 选项少于 2 项,请手动补齐`
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function sanitizeFormConfig(raw) {
|
|
229
|
+
const out = {};
|
|
230
|
+
if (raw.columns !== void 0) {
|
|
231
|
+
const n = Number(raw.columns);
|
|
232
|
+
if (Number.isFinite(n) && n >= 1 && n <= 6) out.columns = Math.floor(n);
|
|
233
|
+
}
|
|
234
|
+
if (raw.labelWidth !== void 0) {
|
|
235
|
+
const n = Number(raw.labelWidth);
|
|
236
|
+
if (Number.isFinite(n) && n > 0) out.labelWidth = Math.floor(n);
|
|
237
|
+
}
|
|
238
|
+
if (typeof raw.labelPosition === "string" && ["right", "left", "top"].includes(raw.labelPosition)) {
|
|
239
|
+
out.labelPosition = raw.labelPosition;
|
|
240
|
+
}
|
|
241
|
+
return out;
|
|
242
|
+
}
|
|
243
|
+
exports.extractJsonBlock = extractJsonBlock;
|
|
244
|
+
exports.parseAiResult = parseAiResult;
|
|
245
|
+
exports.parseLooseJson = parseLooseJson;
|