@fecp/designer 5.6.30 → 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.
Files changed (106) hide show
  1. package/es/_virtual/_commonjsHelpers.mjs +25 -0
  2. package/es/_virtual/index.mjs +4 -4
  3. package/es/_virtual/index2.mjs +2 -5
  4. package/es/_virtual/index3.mjs +5 -3
  5. package/es/_virtual/index4.mjs +5 -2
  6. package/es/_virtual/index5.mjs +3 -2
  7. package/es/_virtual/index6.mjs +4 -0
  8. package/es/_virtual/index7.mjs +4 -0
  9. package/es/config-dev.js +2 -0
  10. package/es/designer/package.json.mjs +1 -1
  11. package/es/designer/src/axios/config.mjs +10 -3
  12. package/es/designer/src/axios/crypto.mjs +1 -5
  13. package/es/designer/src/packages/aiForm/AiDiffTable.vue.mjs +152 -0
  14. package/es/designer/src/packages/aiForm/api.mjs +21 -0
  15. package/es/designer/src/packages/aiForm/apply.mjs +153 -0
  16. package/es/designer/src/packages/aiForm/compressConfig.mjs +69 -0
  17. package/es/designer/src/packages/aiForm/constants.mjs +184 -0
  18. package/es/designer/src/packages/aiForm/diff.mjs +140 -0
  19. package/es/designer/src/packages/aiForm/index.vue.mjs +301 -0
  20. package/es/designer/src/packages/aiForm/normalizeFieldList.mjs +138 -0
  21. package/es/designer/src/packages/aiForm/parseAiResult.mjs +245 -0
  22. package/es/designer/src/packages/aiForm/prompt.mjs +130 -0
  23. package/es/designer/src/packages/aiForm/useAiFormDrawer.mjs +16 -0
  24. package/es/designer/src/packages/dataSource/dataSource.vue.mjs +45 -30
  25. package/es/designer/src/packages/form/headerBtn.vue.mjs +4 -1
  26. package/es/designer/src/packages/form/index.vue.mjs +16 -2
  27. package/es/designer/src/packages/utils/datasource.mjs +14 -1
  28. package/es/designer.css +444 -153
  29. package/es/node_modules/@braintree/sanitize-url/dist/index.mjs +1 -1
  30. package/es/node_modules/diagram-js/lib/model/index.mjs +1 -1
  31. package/es/node_modules/element-plus/es/utils/vue/icon.mjs +1 -1
  32. package/es/node_modules/highlight.js/es/index.mjs +1 -1
  33. package/es/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-LMCZKHZV.mjs +1 -1
  34. package/es/node_modules/mermaid/dist/chunks/mermaid.core/chunk-32BRIVSS.mjs +1 -1
  35. package/es/node_modules/mermaid/dist/chunks/mermaid.core/chunk-ICXQ74PX.mjs +1 -1
  36. package/es/node_modules/mermaid/dist/chunks/mermaid.core/classDiagram-OUVF2IWQ.mjs +1 -1
  37. package/es/node_modules/mermaid/dist/chunks/mermaid.core/classDiagram-v2-EOCWNBFH.mjs +1 -1
  38. package/es/node_modules/mermaid/dist/chunks/mermaid.core/flowDiagram-23GEKE2U.mjs +1 -1
  39. package/es/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-NO4QXBWP.mjs +1 -1
  40. package/es/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-DBY2YBRQ.mjs +1 -1
  41. package/es/node_modules/mermaid/dist/chunks/mermaid.core/stateDiagram-2N3HPSRC.mjs +1 -1
  42. package/es/node_modules/mermaid/dist/chunks/mermaid.core/stateDiagram-v2-6OUMAXLB.mjs +1 -1
  43. package/es/node_modules/mermaid/dist/chunks/mermaid.core/swimlanesDiagram-G3AALYLV.mjs +1 -1
  44. package/es/node_modules/object-refs/index.mjs +1 -1
  45. package/es/packages/mobile/src/axios/config.mjs +8 -4
  46. package/es/packages/mobile/src/components/ai/MarkdownRenderer/MarkdownRenderer.vue.mjs +1 -1
  47. package/es/packages/mobile/src/components/custom/approvalBar/ApprovalBar.vue.mjs +53 -13
  48. package/es/packages/mobile/src/components/custom/approvalBar/FlowUserSelect.vue.mjs +215 -0
  49. package/es/packages/mobile/src/components/dataDisplay/cardList/CardList.vue.mjs +19 -15
  50. package/es/packages/mobile/src/utils/datasource.mjs +14 -1
  51. package/es/packages/mobile/src/utils/formatterUtil.mjs +24 -12
  52. package/es/packages/vue/src/components/forms/form/Form.vue.mjs +5 -7
  53. package/es/packages/vue/src/utils/datasource.mjs +14 -1
  54. package/lib/_virtual/_commonjsHelpers.js +25 -0
  55. package/lib/_virtual/index.js +4 -4
  56. package/lib/_virtual/index2.js +3 -6
  57. package/lib/_virtual/index3.js +6 -4
  58. package/lib/_virtual/index4.js +6 -3
  59. package/lib/_virtual/index5.js +3 -2
  60. package/lib/_virtual/index6.js +4 -0
  61. package/lib/_virtual/index7.js +4 -0
  62. package/lib/config-dev.js +2 -0
  63. package/lib/designer/package.json.js +1 -1
  64. package/lib/designer/src/axios/config.js +10 -3
  65. package/lib/designer/src/axios/crypto.js +0 -4
  66. package/lib/designer/src/packages/aiForm/AiDiffTable.vue.js +152 -0
  67. package/lib/designer/src/packages/aiForm/api.js +21 -0
  68. package/lib/designer/src/packages/aiForm/apply.js +153 -0
  69. package/lib/designer/src/packages/aiForm/compressConfig.js +69 -0
  70. package/lib/designer/src/packages/aiForm/constants.js +184 -0
  71. package/lib/designer/src/packages/aiForm/diff.js +140 -0
  72. package/lib/designer/src/packages/aiForm/index.vue.js +301 -0
  73. package/lib/designer/src/packages/aiForm/normalizeFieldList.js +138 -0
  74. package/lib/designer/src/packages/aiForm/parseAiResult.js +245 -0
  75. package/lib/designer/src/packages/aiForm/prompt.js +130 -0
  76. package/lib/designer/src/packages/aiForm/useAiFormDrawer.js +16 -0
  77. package/lib/designer/src/packages/dataSource/dataSource.vue.js +44 -29
  78. package/lib/designer/src/packages/form/headerBtn.vue.js +4 -1
  79. package/lib/designer/src/packages/form/index.vue.js +15 -1
  80. package/lib/designer/src/packages/utils/datasource.js +14 -1
  81. package/lib/designer.css +444 -153
  82. package/lib/node_modules/@braintree/sanitize-url/dist/index.js +1 -1
  83. package/lib/node_modules/diagram-js/lib/model/index.js +1 -1
  84. package/lib/node_modules/highlight.js/es/index.js +1 -1
  85. package/lib/node_modules/mermaid/dist/chunks/mermaid.core/c4Diagram-LMCZKHZV.js +1 -1
  86. package/lib/node_modules/mermaid/dist/chunks/mermaid.core/chunk-32BRIVSS.js +1 -1
  87. package/lib/node_modules/mermaid/dist/chunks/mermaid.core/chunk-ICXQ74PX.js +1 -1
  88. package/lib/node_modules/mermaid/dist/chunks/mermaid.core/classDiagram-OUVF2IWQ.js +1 -1
  89. package/lib/node_modules/mermaid/dist/chunks/mermaid.core/classDiagram-v2-EOCWNBFH.js +1 -1
  90. package/lib/node_modules/mermaid/dist/chunks/mermaid.core/flowDiagram-23GEKE2U.js +1 -1
  91. package/lib/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-NO4QXBWP.js +1 -1
  92. package/lib/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-DBY2YBRQ.js +1 -1
  93. package/lib/node_modules/mermaid/dist/chunks/mermaid.core/stateDiagram-2N3HPSRC.js +1 -1
  94. package/lib/node_modules/mermaid/dist/chunks/mermaid.core/stateDiagram-v2-6OUMAXLB.js +1 -1
  95. package/lib/node_modules/mermaid/dist/chunks/mermaid.core/swimlanesDiagram-G3AALYLV.js +1 -1
  96. package/lib/node_modules/object-refs/index.js +1 -1
  97. package/lib/packages/mobile/src/axios/config.js +8 -4
  98. package/lib/packages/mobile/src/components/ai/MarkdownRenderer/MarkdownRenderer.vue.js +1 -1
  99. package/lib/packages/mobile/src/components/custom/approvalBar/ApprovalBar.vue.js +52 -12
  100. package/lib/packages/mobile/src/components/custom/approvalBar/FlowUserSelect.vue.js +215 -0
  101. package/lib/packages/mobile/src/components/dataDisplay/cardList/CardList.vue.js +19 -15
  102. package/lib/packages/mobile/src/utils/datasource.js +14 -1
  103. package/lib/packages/mobile/src/utils/formatterUtil.js +24 -12
  104. package/lib/packages/vue/src/components/forms/form/Form.vue.js +4 -6
  105. package/lib/packages/vue/src/utils/datasource.js +14 -1
  106. package/package.json +1 -1
@@ -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;
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const constants = require("./constants.js");
4
+ require("vue");
5
+ const FIELD_TYPE_DOC = Object.entries(constants.AI_FIELD_TYPES).map(([type, meta]) => `${type}(${meta.label})`).join(" ");
6
+ const LAYOUT_TYPE_DOC = constants.LAYOUT_FIELD_TYPES.join(" / ");
7
+ const OPTION_TYPE_DOC = constants.OPTION_FIELD_TYPES.join(" / ");
8
+ const SYSTEM_PROMPT = `你是 FEC 表单设计器的配置助手。
9
+ 输入:一段需求指令 + 表单当前配置(可能是空的)+ 可用数据源 + 已知字典 + 可选字段清单。
10
+ 输出:应用指令之后的【完整表单配置】,且只能是唯一的 json 代码块。
11
+
12
+ ## 输出格式(严格遵守)
13
+ 只输出一个 \`\`\`json 代码块,不要输出任何解释文字、不要第二个代码块、不要注释、不要尾逗号。
14
+ {
15
+ "formConfig": {
16
+ "columns": 2,
17
+ "labelWidth": 120,
18
+ "labelPosition": "right"
19
+ },
20
+ "fields": [ Field, Field, ... ]
21
+ }
22
+ formConfig 中的三个字段:只有在确需调整时才输出,否则省略。
23
+
24
+ ## Field 通用字段
25
+ - "fieldType": 见下方白名单,必填
26
+ - "label": 中文标题,必填
27
+ - "fieldName": 英文字段名。非布局类控件必填;只能用字母、数字、下划线,且同一份配置内全局唯一
28
+ - "required": true / false
29
+ - "requiredMessage": 必填校验提示语
30
+ - "placeholder": 输入提示
31
+ - "tooltip": 字段说明
32
+ - "defaultValue": 默认值
33
+ - "disabled": true / false
34
+ - "displayMode": ${constants.AI_DISPLAY_MODES.join(" | ")}
35
+ - "maxLength": 整数,输入框最大长度
36
+ - "validationType": ${constants.AI_VALIDATION_TYPES.join(" | ")}
37
+ - "validationMessage": 校验不通过时的提示语
38
+ - "width": ${constants.AI_WIDTH_MODES.join(" | ")} —— 布局档位,决定该字段占多少栅格。省略则跟随表单列数
39
+ - "insertAfter": 某个已存在 fieldName —— 表示把本字段插到它之后。省略则追加到末尾
40
+
41
+ ## 属性最小化原则(极其重要)
42
+ 你必须输出完整的 fields 列表(这是底线),但每个字段内部【只写你确实要设置的属性】。
43
+ 未输出的属性 = 保持表单现状,不做改动。这条规则用于保护用户手动调整过的值。
44
+
45
+ 错误示范:把每个字段的 required / disabled / placeholder 全部重写一遍
46
+ → 会冲掉用户手动修改过的内容
47
+ 正确示范:只在需要变化时写 { "required": true }
48
+
49
+ ## 可用 fieldType 白名单
50
+ ${FIELD_TYPE_DOC}
51
+ 布局类控件(${LAYOUT_TYPE_DOC})不需要 fieldName 和 required。
52
+ 禁止使用 subForm / subTable / upload / cascader / userSelect / roleSelect / orgSelect / approvalHistory / document / contract。
53
+
54
+ ## 各类型专属字段(只有对应类型才能写)
55
+ - number: format(${constants.AI_NUMBER_FORMATS.join(" | ")}), hasDecimalPlaces, decimalPlaces, minValue, maxValue, prefix, suffix
56
+ - text / textarea: prefix, suffix
57
+ - date: dateType(date | week | month | year | datetime), dateValueType(string | date | timestamp), dateRange("" | beforeToday | afterToday)
58
+ - area / industry: multiple, showFullPath, maxLevel
59
+ - h2: subLabel
60
+
61
+ ## 选择类控件(${OPTION_TYPE_DOC})的 optionConfig
62
+ {
63
+ "optionSource": "${constants.AI_OPTION_SOURCES.join(" | ")}",
64
+ "options": [ { "label": "显示值", "value": "真实值" } ],
65
+ "dataSourceValue": "数据源 id",
66
+ "displayField": "显示字段名",
67
+ "valueField": "值字段名",
68
+ "dictionaryValue": "字典 keyName"
69
+ }
70
+ - 必须显式给出 optionSource,不允许省略。
71
+ - 禁止使用 "static" 这个值(属性面板不认)。
72
+ - 选择路径优先级:命中【已知字典】→ dictionary;命中【可用数据源】→ dataSource;都不命中 → custom(你按业务常识枚举选项)。
73
+ - 严禁臆造数据源 id 和字典 keyName。
74
+
75
+ ## 修改场景(当前配置非空时适用)
76
+ 你是在【已有表单上做增量修改】,不是在重建表单:
77
+ 1. 输出必须包含全部字段 —— 指令没要求改动的字段,必须原样保留:不得删除、不得改名、不得改写属性。
78
+ 2. 只有指令明确要求的改动才可以执行。
79
+ 3. 新增字段尽量放在语义相关的位置,并通过 insertAfter 表达。
80
+ 4. 若指令指代不明(例如"把那个字段删了"),选择最匹配的一个字段执行,并在 json 代码块之外写一行简短说明(这是唯一允许出现的文字)。`;
81
+ function buildUserPrompt(ctx) {
82
+ const {
83
+ requirement,
84
+ currentConfig,
85
+ dataSources = [],
86
+ dictionaries = [],
87
+ fieldList = "",
88
+ history = []
89
+ } = ctx || {};
90
+ const parts = [];
91
+ parts.push("【当前表单配置】");
92
+ parts.push(
93
+ currentConfig ? "```json\n" + safeStringify(currentConfig) + "\n```" : "(空表单,这是新建场景,请从零设计)"
94
+ );
95
+ parts.push("");
96
+ parts.push("【可用数据源】");
97
+ parts.push(renderDataSources(dataSources));
98
+ parts.push("");
99
+ parts.push("【已知字典】");
100
+ parts.push(renderDictionaries(dictionaries));
101
+ parts.push("");
102
+ parts.push("【字段清单】");
103
+ parts.push(fieldList ? fieldList : "(未提供字段清单,请根据需求自行设计合理的字段与命名)");
104
+ if (Array.isArray(history) && history.length) {
105
+ parts.push("");
106
+ parts.push("【上下文】");
107
+ parts.push(history.map((h) => `${h.role}:${h.content}`).join("\n"));
108
+ }
109
+ parts.push("");
110
+ parts.push("【本次指令】");
111
+ parts.push(requirement || "");
112
+ return parts.join("\n");
113
+ }
114
+ function renderDataSources(dataSources) {
115
+ if (!dataSources.length) return "未配置数据源(下拉类控件请一律使用 custom 静态选项)";
116
+ return dataSources.map((ds) => `id=${ds.id}, name=${ds.name || "-"}, url=${ds.url || "-"}`).join("\n");
117
+ }
118
+ function renderDictionaries(dictionaries) {
119
+ if (!dictionaries.length) return "未配置字典";
120
+ return dictionaries.join(" / ");
121
+ }
122
+ function safeStringify(obj) {
123
+ try {
124
+ return JSON.stringify(obj, null, 2);
125
+ } catch (e) {
126
+ return String(obj);
127
+ }
128
+ }
129
+ exports.SYSTEM_PROMPT = SYSTEM_PROMPT;
130
+ exports.buildUserPrompt = buildUserPrompt;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const Vue = require("vue");
4
+ const index = require("./index.vue.js");
5
+ function useAiFormDrawer() {
6
+ const aiFormDrawerVisible = Vue.ref(false);
7
+ const openAiFormDrawer = () => {
8
+ aiFormDrawerVisible.value = true;
9
+ };
10
+ return {
11
+ aiFormDrawerVisible,
12
+ openAiFormDrawer,
13
+ AiFormDrawer: index.default
14
+ };
15
+ }
16
+ exports.useAiFormDrawer = useAiFormDrawer;