@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,184 @@
|
|
|
1
|
+
const AI_FIELD_TYPES = {
|
|
2
|
+
// 输入类
|
|
3
|
+
text: { label: "单行文本", group: "input", height: 1 },
|
|
4
|
+
textarea: { label: "多行文本", group: "input", height: 2 },
|
|
5
|
+
number: { label: "数字", group: "input", height: 1 },
|
|
6
|
+
date: { label: "日期时间", group: "date", height: 1 },
|
|
7
|
+
// 选择类
|
|
8
|
+
select: { label: "下拉单选", group: "select", height: 1 },
|
|
9
|
+
multipleSelection: { label: "下拉多选", group: "select", height: 1 },
|
|
10
|
+
radio: { label: "单选框", group: "select", height: 1 },
|
|
11
|
+
checkbox: { label: "多选框", group: "select", height: 1 },
|
|
12
|
+
switch: { label: "开关", group: "select", height: 1 },
|
|
13
|
+
// 自包含高级类(无需外部资源 id)
|
|
14
|
+
richText: { label: "富文本", group: "advanced", height: 2 },
|
|
15
|
+
area: { label: "区域选择", group: "advanced", height: 1 },
|
|
16
|
+
industry: { label: "行业选择", group: "advanced", height: 1 },
|
|
17
|
+
// 布局/展示类
|
|
18
|
+
subTitle: { label: "子标题", group: "layout", height: 1 },
|
|
19
|
+
h2: { label: "标题", group: "layout", height: 1 },
|
|
20
|
+
blank: { label: "空白占位", group: "layout", height: 1 },
|
|
21
|
+
divider: { label: "分割线", group: "layout", height: 1 }
|
|
22
|
+
};
|
|
23
|
+
const OPTION_FIELD_TYPES = [
|
|
24
|
+
"select",
|
|
25
|
+
"multipleSelection",
|
|
26
|
+
"radio",
|
|
27
|
+
"checkbox"
|
|
28
|
+
];
|
|
29
|
+
const LAYOUT_FIELD_TYPES = ["subTitle", "h2", "blank", "divider"];
|
|
30
|
+
const AI_COMMON_PROPS = [
|
|
31
|
+
"fieldType",
|
|
32
|
+
// 控件类型,必填
|
|
33
|
+
"label",
|
|
34
|
+
// 中文标题,必填
|
|
35
|
+
"fieldName",
|
|
36
|
+
// 英文字段名,非布局类必填
|
|
37
|
+
"required",
|
|
38
|
+
// 是否必填
|
|
39
|
+
"requiredMessage",
|
|
40
|
+
// 必填提示语
|
|
41
|
+
"placeholder",
|
|
42
|
+
// 输入提示
|
|
43
|
+
"tooltip",
|
|
44
|
+
// 字段说明
|
|
45
|
+
"defaultValue",
|
|
46
|
+
// 默认值
|
|
47
|
+
"disabled",
|
|
48
|
+
// 是否禁用
|
|
49
|
+
"displayMode",
|
|
50
|
+
// all | edit | query
|
|
51
|
+
"maxLength",
|
|
52
|
+
// 最大长度
|
|
53
|
+
"validationType",
|
|
54
|
+
// 校验类型
|
|
55
|
+
"validationMessage",
|
|
56
|
+
// 校验提示语
|
|
57
|
+
"width",
|
|
58
|
+
// half | full,布局档位,不落入 component
|
|
59
|
+
"insertAfter"
|
|
60
|
+
// 插入锚点(某个 fieldName 之后),不落入 component
|
|
61
|
+
];
|
|
62
|
+
const AI_PROPS_BY_TYPE = {
|
|
63
|
+
number: [
|
|
64
|
+
"format",
|
|
65
|
+
// number | yuan | wan | million | percentage | permillage | permillion
|
|
66
|
+
"hasDecimalPlaces",
|
|
67
|
+
"decimalPlaces",
|
|
68
|
+
"minValue",
|
|
69
|
+
"maxValue",
|
|
70
|
+
"prefix",
|
|
71
|
+
"suffix"
|
|
72
|
+
],
|
|
73
|
+
text: ["prefix", "suffix"],
|
|
74
|
+
textarea: ["prefix", "suffix"],
|
|
75
|
+
date: [
|
|
76
|
+
"dateType",
|
|
77
|
+
// date | week | month | year | datetime
|
|
78
|
+
"dateValueType",
|
|
79
|
+
// string | date | timestamp
|
|
80
|
+
"dateRange"
|
|
81
|
+
// "" | beforeToday | afterToday
|
|
82
|
+
],
|
|
83
|
+
select: ["optionStyle"],
|
|
84
|
+
multipleSelection: ["optionStyle"],
|
|
85
|
+
radio: ["optionStyle"],
|
|
86
|
+
checkbox: ["optionStyle"],
|
|
87
|
+
area: ["multiple", "showFullPath", "maxLevel"],
|
|
88
|
+
industry: ["multiple", "showFullPath", "maxLevel"],
|
|
89
|
+
h2: ["subLabel"]
|
|
90
|
+
};
|
|
91
|
+
const AI_OPTION_CONFIG_PROP = "optionConfig";
|
|
92
|
+
const AI_OPTION_SOURCES = ["custom", "dataSource", "dictionary"];
|
|
93
|
+
const AI_VALIDATION_TYPES = [
|
|
94
|
+
"none",
|
|
95
|
+
"idCard",
|
|
96
|
+
"creditCode",
|
|
97
|
+
"zipCode",
|
|
98
|
+
"fax",
|
|
99
|
+
"bankCard",
|
|
100
|
+
"email",
|
|
101
|
+
"mobile",
|
|
102
|
+
"phone",
|
|
103
|
+
"mobilePhone",
|
|
104
|
+
"regex",
|
|
105
|
+
"custom"
|
|
106
|
+
];
|
|
107
|
+
const AI_DISPLAY_MODES = ["all", "edit", "query"];
|
|
108
|
+
const AI_WIDTH_MODES = ["half", "full"];
|
|
109
|
+
const AI_NUMBER_FORMATS = [
|
|
110
|
+
"number",
|
|
111
|
+
"yuan",
|
|
112
|
+
"wan",
|
|
113
|
+
"million",
|
|
114
|
+
"percentage",
|
|
115
|
+
"permillage",
|
|
116
|
+
"permillion"
|
|
117
|
+
];
|
|
118
|
+
function getAllowedProps(fieldType) {
|
|
119
|
+
const extra = AI_PROPS_BY_TYPE[fieldType] || [];
|
|
120
|
+
const props = [...AI_COMMON_PROPS, ...extra];
|
|
121
|
+
if (OPTION_FIELD_TYPES.includes(fieldType)) {
|
|
122
|
+
props.push(AI_OPTION_CONFIG_PROP);
|
|
123
|
+
}
|
|
124
|
+
if (LAYOUT_FIELD_TYPES.includes(fieldType)) {
|
|
125
|
+
return props.filter(
|
|
126
|
+
(p) => ["fieldType", "label", "width", "insertAfter", "subLabel"].includes(p)
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
return props;
|
|
130
|
+
}
|
|
131
|
+
function getDefaultHeight(fieldType) {
|
|
132
|
+
var _a;
|
|
133
|
+
return ((_a = AI_FIELD_TYPES[fieldType]) == null ? void 0 : _a.height) || 1;
|
|
134
|
+
}
|
|
135
|
+
const PROP_LABELS = {
|
|
136
|
+
label: "标题",
|
|
137
|
+
fieldName: "字段名",
|
|
138
|
+
required: "必填",
|
|
139
|
+
requiredMessage: "必填提示",
|
|
140
|
+
placeholder: "输入提示",
|
|
141
|
+
tooltip: "字段说明",
|
|
142
|
+
defaultValue: "默认值",
|
|
143
|
+
disabled: "禁用",
|
|
144
|
+
displayMode: "显示场景",
|
|
145
|
+
maxLength: "最大长度",
|
|
146
|
+
validationType: "校验类型",
|
|
147
|
+
validationMessage: "校验提示",
|
|
148
|
+
format: "格式",
|
|
149
|
+
hasDecimalPlaces: "允许小数",
|
|
150
|
+
decimalPlaces: "小数位",
|
|
151
|
+
minValue: "最小值",
|
|
152
|
+
maxValue: "最大值",
|
|
153
|
+
prefix: "前缀",
|
|
154
|
+
suffix: "后缀",
|
|
155
|
+
dateType: "日期类型",
|
|
156
|
+
dateValueType: "日期值类型",
|
|
157
|
+
dateRange: "日期范围",
|
|
158
|
+
optionStyle: "选项样式",
|
|
159
|
+
optionConfig: "选项配置",
|
|
160
|
+
subLabel: "副标题",
|
|
161
|
+
multiple: "多选",
|
|
162
|
+
showFullPath: "显示全路径",
|
|
163
|
+
maxLevel: "最大层级"
|
|
164
|
+
};
|
|
165
|
+
function getPropLabel(prop) {
|
|
166
|
+
return PROP_LABELS[prop] || prop;
|
|
167
|
+
}
|
|
168
|
+
export {
|
|
169
|
+
AI_COMMON_PROPS,
|
|
170
|
+
AI_DISPLAY_MODES,
|
|
171
|
+
AI_FIELD_TYPES,
|
|
172
|
+
AI_NUMBER_FORMATS,
|
|
173
|
+
AI_OPTION_CONFIG_PROP,
|
|
174
|
+
AI_OPTION_SOURCES,
|
|
175
|
+
AI_PROPS_BY_TYPE,
|
|
176
|
+
AI_VALIDATION_TYPES,
|
|
177
|
+
AI_WIDTH_MODES,
|
|
178
|
+
LAYOUT_FIELD_TYPES,
|
|
179
|
+
OPTION_FIELD_TYPES,
|
|
180
|
+
PROP_LABELS,
|
|
181
|
+
getAllowedProps,
|
|
182
|
+
getDefaultHeight,
|
|
183
|
+
getPropLabel
|
|
184
|
+
};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { LAYOUT_FIELD_TYPES } from "./constants.mjs";
|
|
2
|
+
import { getVisibleLayoutItems } from "./compressConfig.mjs";
|
|
3
|
+
function diffAiFields(aiFields, editConfigData) {
|
|
4
|
+
const visibleItems = getVisibleLayoutItems(editConfigData);
|
|
5
|
+
const oldByName = /* @__PURE__ */ new Map();
|
|
6
|
+
const oldByLayoutKey = /* @__PURE__ */ new Map();
|
|
7
|
+
visibleItems.forEach((item) => {
|
|
8
|
+
const c = item.component;
|
|
9
|
+
if (LAYOUT_FIELD_TYPES.includes(c.fieldType)) {
|
|
10
|
+
oldByLayoutKey.set(`${c.label || ""}|${c.fieldType}`, item);
|
|
11
|
+
} else if (c.fieldName) {
|
|
12
|
+
oldByName.set(c.fieldName, item);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
const adds = [];
|
|
16
|
+
const modifies = [];
|
|
17
|
+
const matchedItems = /* @__PURE__ */ new Set();
|
|
18
|
+
const usedLayoutKeys = /* @__PURE__ */ new Set();
|
|
19
|
+
(aiFields || []).forEach((fi) => {
|
|
20
|
+
let oldItem = null;
|
|
21
|
+
let key = null;
|
|
22
|
+
if (LAYOUT_FIELD_TYPES.includes(fi.fieldType)) {
|
|
23
|
+
const lk = `${fi.label || ""}|${fi.fieldType}`;
|
|
24
|
+
oldItem = oldByLayoutKey.get(lk) || null;
|
|
25
|
+
if (oldItem && !usedLayoutKeys.has(lk)) {
|
|
26
|
+
usedLayoutKeys.add(lk);
|
|
27
|
+
key = lk;
|
|
28
|
+
} else {
|
|
29
|
+
oldItem = null;
|
|
30
|
+
}
|
|
31
|
+
} else if (fi.fieldName) {
|
|
32
|
+
key = fi.fieldName;
|
|
33
|
+
oldItem = oldByName.get(fi.fieldName) || null;
|
|
34
|
+
}
|
|
35
|
+
if (!oldItem) {
|
|
36
|
+
adds.push({
|
|
37
|
+
kind: "add",
|
|
38
|
+
key: key || `add_${adds.length}`,
|
|
39
|
+
fieldType: fi.fieldType,
|
|
40
|
+
label: fi.label || "",
|
|
41
|
+
fieldName: fi.fieldName || "",
|
|
42
|
+
width: fi.width || "",
|
|
43
|
+
insertAfter: fi.insertAfter || "",
|
|
44
|
+
payload: stripDirectives(fi),
|
|
45
|
+
selected: true
|
|
46
|
+
});
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
matchedItems.add(oldItem);
|
|
50
|
+
const changes = diffProps(fi, oldItem.component);
|
|
51
|
+
if (changes.length) {
|
|
52
|
+
modifies.push({
|
|
53
|
+
kind: "modify",
|
|
54
|
+
key,
|
|
55
|
+
fieldType: fi.fieldType,
|
|
56
|
+
label: fi.label || oldItem.component.label || "",
|
|
57
|
+
changes,
|
|
58
|
+
selected: true
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
const removes = visibleItems.filter((item) => !matchedItems.has(item)).map((item) => ({
|
|
63
|
+
kind: "remove",
|
|
64
|
+
key: item.component.fieldName || `remove_${item.id}`,
|
|
65
|
+
fieldType: item.component.fieldType,
|
|
66
|
+
label: item.component.label || item.component.fieldName || "",
|
|
67
|
+
selected: true,
|
|
68
|
+
item
|
|
69
|
+
}));
|
|
70
|
+
return {
|
|
71
|
+
adds,
|
|
72
|
+
removes,
|
|
73
|
+
modifies,
|
|
74
|
+
stats: {
|
|
75
|
+
add: adds.length,
|
|
76
|
+
remove: removes.length,
|
|
77
|
+
modify: modifies.length
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function stripDirectives(fi) {
|
|
82
|
+
const out = { ...fi };
|
|
83
|
+
delete out.width;
|
|
84
|
+
delete out.insertAfter;
|
|
85
|
+
return out;
|
|
86
|
+
}
|
|
87
|
+
function diffProps(aiField, oldComponent) {
|
|
88
|
+
const changes = [];
|
|
89
|
+
Object.keys(aiField).forEach((prop) => {
|
|
90
|
+
if (["fieldType", "fieldName", "width", "insertAfter"].includes(prop)) return;
|
|
91
|
+
const nv = aiField[prop];
|
|
92
|
+
const ov = oldComponent[prop];
|
|
93
|
+
if (isEqualValue(nv, ov)) return;
|
|
94
|
+
changes.push({
|
|
95
|
+
prop,
|
|
96
|
+
oldValue: readable(ov),
|
|
97
|
+
newValue: readable(nv),
|
|
98
|
+
selected: true
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
return changes;
|
|
102
|
+
}
|
|
103
|
+
function isEqualValue(a, b) {
|
|
104
|
+
if (a === b) return true;
|
|
105
|
+
if (a === void 0 || b === void 0) return false;
|
|
106
|
+
if (isEmptyish(a) && isEmptyish(b)) return true;
|
|
107
|
+
if (typeof a === "object" || typeof b === "object") {
|
|
108
|
+
try {
|
|
109
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
110
|
+
} catch (e) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return String(a) === String(b);
|
|
115
|
+
}
|
|
116
|
+
function isEmptyish(v) {
|
|
117
|
+
if (v === null || v === void 0) return true;
|
|
118
|
+
if (v === "") return true;
|
|
119
|
+
if (Array.isArray(v)) return v.length === 0;
|
|
120
|
+
if (typeof v === "object") return Object.keys(v).length === 0;
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
function readable(v) {
|
|
124
|
+
if (v === void 0) return "(空)";
|
|
125
|
+
if (v === null) return "(空)";
|
|
126
|
+
if (v === "") return "(空)";
|
|
127
|
+
if (typeof v === "boolean") return v ? "是" : "否";
|
|
128
|
+
if (typeof v === "object") {
|
|
129
|
+
try {
|
|
130
|
+
return JSON.stringify(v);
|
|
131
|
+
} catch (e) {
|
|
132
|
+
return String(v);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return String(v);
|
|
136
|
+
}
|
|
137
|
+
export {
|
|
138
|
+
diffAiFields,
|
|
139
|
+
diffProps
|
|
140
|
+
};
|
|
@@ -0,0 +1,301 @@
|
|
|
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 { computed, ref, watch, createBlock, openBlock, withCtx, createElementVNode, createVNode, createCommentVNode, createElementBlock, toDisplayString, withKeys, withModifiers, createTextVNode } from "vue";
|
|
11
|
+
import emitter from "../utils/eventBus.mjs";
|
|
12
|
+
import { getEditConfigData, setEditConfigData } from "../utils/common.mjs";
|
|
13
|
+
import AiDiffTable from "./AiDiffTable.vue.mjs";
|
|
14
|
+
import { buildAiInput } from "./compressConfig.mjs";
|
|
15
|
+
import { normalizeFieldList } from "./normalizeFieldList.mjs";
|
|
16
|
+
import { SYSTEM_PROMPT, buildUserPrompt } from "./prompt.mjs";
|
|
17
|
+
import { generateFormConfig } from "./api.mjs";
|
|
18
|
+
import { parseAiResult } from "./parseAiResult.mjs";
|
|
19
|
+
import { diffAiFields } from "./diff.mjs";
|
|
20
|
+
import { applyChanges } from "./apply.mjs";
|
|
21
|
+
/* empty css */
|
|
22
|
+
import _export_sfc from "../../../../_virtual/_plugin-vue_export-helper.mjs";
|
|
23
|
+
import { ElDrawer } from "../../../../node_modules/element-plus/es/components/drawer/index.mjs";
|
|
24
|
+
import { ElInput } from "../../../../node_modules/element-plus/es/components/input/index.mjs";
|
|
25
|
+
import { ElCollapse, ElCollapseItem } from "../../../../node_modules/element-plus/es/components/collapse/index.mjs";
|
|
26
|
+
import { ElButton } from "../../../../node_modules/element-plus/es/components/button/index.mjs";
|
|
27
|
+
import { ElAlert } from "../../../../node_modules/element-plus/es/components/alert/index.mjs";
|
|
28
|
+
import { ElMessage } from "../../../../node_modules/element-plus/es/components/message/index.mjs";
|
|
29
|
+
import cloneDeep from "../../../../node_modules/lodash-es/cloneDeep.mjs";
|
|
30
|
+
const _hoisted_1 = { class: "ai-form-drawer" };
|
|
31
|
+
const _hoisted_2 = { class: "ctx-bar" };
|
|
32
|
+
const _hoisted_3 = {
|
|
33
|
+
key: 0,
|
|
34
|
+
class: "dot"
|
|
35
|
+
};
|
|
36
|
+
const _hoisted_4 = { key: 1 };
|
|
37
|
+
const _hoisted_5 = { class: "block" };
|
|
38
|
+
const _hoisted_6 = { class: "block" };
|
|
39
|
+
const _hoisted_7 = {
|
|
40
|
+
key: 1,
|
|
41
|
+
class: "block"
|
|
42
|
+
};
|
|
43
|
+
const drawerSize = "600px";
|
|
44
|
+
const _sfc_main = {
|
|
45
|
+
__name: "index",
|
|
46
|
+
props: {
|
|
47
|
+
modelValue: { type: Boolean, default: false }
|
|
48
|
+
},
|
|
49
|
+
emits: ["update:modelValue"],
|
|
50
|
+
setup(__props, { emit: __emit }) {
|
|
51
|
+
const props = __props;
|
|
52
|
+
const emit = __emit;
|
|
53
|
+
const visible = computed({
|
|
54
|
+
get: () => props.modelValue,
|
|
55
|
+
set: (val) => emit("update:modelValue", val)
|
|
56
|
+
});
|
|
57
|
+
const requirement = ref("");
|
|
58
|
+
const fieldListRaw = ref("");
|
|
59
|
+
const generating = ref(false);
|
|
60
|
+
const errorMessage = ref("");
|
|
61
|
+
const diffResult = ref(null);
|
|
62
|
+
const aiFormConfig = ref({});
|
|
63
|
+
const applied = ref(false);
|
|
64
|
+
const lastSnapshot = ref(null);
|
|
65
|
+
const sessionId = ref(createSessionId());
|
|
66
|
+
const canGenerate = computed(() => requirement.value.trim().length > 0 && !generating.value);
|
|
67
|
+
watch(visible, (val) => {
|
|
68
|
+
if (!val) return;
|
|
69
|
+
sessionId.value = createSessionId();
|
|
70
|
+
applied.value = false;
|
|
71
|
+
diffResult.value = null;
|
|
72
|
+
lastSnapshot.value = null;
|
|
73
|
+
errorMessage.value = "";
|
|
74
|
+
});
|
|
75
|
+
const editConfig = computed(() => getEditConfigData() || {});
|
|
76
|
+
const fieldCount = computed(() => (editConfig.value.fieldsData || []).length);
|
|
77
|
+
const columns = computed(() => editConfig.value.columns ?? 2);
|
|
78
|
+
const dsCount = computed(() => (editConfig.value.dataSources || []).length);
|
|
79
|
+
const dictCount = computed(() => {
|
|
80
|
+
const list = editConfig.value.fieldsData || [];
|
|
81
|
+
const set = /* @__PURE__ */ new Set();
|
|
82
|
+
list.forEach((it) => {
|
|
83
|
+
var _a, _b;
|
|
84
|
+
const key = (_b = (_a = it == null ? void 0 : it.component) == null ? void 0 : _a.optionConfig) == null ? void 0 : _b.dictionaryValue;
|
|
85
|
+
if (key) set.add(key);
|
|
86
|
+
});
|
|
87
|
+
return set.size;
|
|
88
|
+
});
|
|
89
|
+
async function handleGenerate() {
|
|
90
|
+
if (!canGenerate.value) return;
|
|
91
|
+
errorMessage.value = "";
|
|
92
|
+
diffResult.value = null;
|
|
93
|
+
applied.value = false;
|
|
94
|
+
aiFormConfig.value = {};
|
|
95
|
+
generating.value = true;
|
|
96
|
+
try {
|
|
97
|
+
const cfg = getEditConfigData();
|
|
98
|
+
const aiInput = buildAiInput(cfg);
|
|
99
|
+
const fieldList = normalizeFieldList(fieldListRaw.value);
|
|
100
|
+
const payload = {
|
|
101
|
+
sessionId: sessionId.value,
|
|
102
|
+
scene: "formConfig",
|
|
103
|
+
systemPrompt: SYSTEM_PROMPT,
|
|
104
|
+
prompt: requirement.value.trim(),
|
|
105
|
+
currentConfig: aiInput.currentConfig,
|
|
106
|
+
dataSources: aiInput.dataSources,
|
|
107
|
+
dictionaries: aiInput.dictionaries,
|
|
108
|
+
fieldList,
|
|
109
|
+
history: []
|
|
110
|
+
};
|
|
111
|
+
payload.userPrompt = buildUserPrompt({
|
|
112
|
+
requirement: requirement.value.trim(),
|
|
113
|
+
currentConfig: aiInput.currentConfig,
|
|
114
|
+
dataSources: aiInput.dataSources,
|
|
115
|
+
dictionaries: aiInput.dictionaries,
|
|
116
|
+
fieldList,
|
|
117
|
+
history: []
|
|
118
|
+
});
|
|
119
|
+
const res = await generateFormConfig(payload);
|
|
120
|
+
const parsed = parseAiResult(res.json ?? res.raw);
|
|
121
|
+
if (!parsed.ok) {
|
|
122
|
+
errorMessage.value = parsed.reason || "生成失败,请调整描述后重试。";
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
aiFormConfig.value = parsed.config.formConfig || {};
|
|
126
|
+
const next = diffAiFields(parsed.config.fields, cfg);
|
|
127
|
+
const s = next.stats;
|
|
128
|
+
if (!s.add && !s.modify && !s.remove) {
|
|
129
|
+
diffResult.value = null;
|
|
130
|
+
ElMessage.info("AI 返回的配置与当前表单一致,没有需要应用的变更");
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
diffResult.value = next;
|
|
134
|
+
applied.value = true;
|
|
135
|
+
applyToCanvas(cfg);
|
|
136
|
+
ElMessage.success("AI 配置已应用到表单");
|
|
137
|
+
} catch (e) {
|
|
138
|
+
errorMessage.value = (e == null ? void 0 : e.message) || "请求失败,请稍后重试。";
|
|
139
|
+
} finally {
|
|
140
|
+
generating.value = false;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function applyToCanvas(cfg) {
|
|
144
|
+
const target = cfg || getEditConfigData();
|
|
145
|
+
const { fieldsData, formConfig } = applyChanges({
|
|
146
|
+
editConfigData: target,
|
|
147
|
+
diffResult: diffResult.value,
|
|
148
|
+
aiFormConfig: aiFormConfig.value
|
|
149
|
+
});
|
|
150
|
+
lastSnapshot.value = cloneDeep({
|
|
151
|
+
fieldsData: target.fieldsData || [],
|
|
152
|
+
columns: target.columns,
|
|
153
|
+
labelWidth: target.labelWidth,
|
|
154
|
+
labelPosition: target.labelPosition
|
|
155
|
+
});
|
|
156
|
+
target.fieldsData = fieldsData;
|
|
157
|
+
target.columns = formConfig.columns;
|
|
158
|
+
if (formConfig.labelWidth != null) target.labelWidth = formConfig.labelWidth;
|
|
159
|
+
if (formConfig.labelPosition) target.labelPosition = formConfig.labelPosition;
|
|
160
|
+
setEditConfigData(target);
|
|
161
|
+
emitter.emit("refreshFormFields");
|
|
162
|
+
}
|
|
163
|
+
function handleUndo() {
|
|
164
|
+
if (!lastSnapshot.value) return;
|
|
165
|
+
const snap = cloneDeep(lastSnapshot.value);
|
|
166
|
+
const cfg = getEditConfigData();
|
|
167
|
+
cfg.fieldsData = snap.fieldsData;
|
|
168
|
+
cfg.columns = snap.columns;
|
|
169
|
+
cfg.labelWidth = snap.labelWidth;
|
|
170
|
+
cfg.labelPosition = snap.labelPosition;
|
|
171
|
+
setEditConfigData(cfg);
|
|
172
|
+
emitter.emit("refreshFormFields");
|
|
173
|
+
lastSnapshot.value = null;
|
|
174
|
+
diffResult.value = null;
|
|
175
|
+
applied.value = false;
|
|
176
|
+
ElMessage.success("已撤销本次 AI 改动");
|
|
177
|
+
}
|
|
178
|
+
function createSessionId() {
|
|
179
|
+
return `formConfig_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
180
|
+
}
|
|
181
|
+
return (_ctx, _cache) => {
|
|
182
|
+
const _component_el_input = ElInput;
|
|
183
|
+
const _component_el_collapse_item = ElCollapseItem;
|
|
184
|
+
const _component_el_collapse = ElCollapse;
|
|
185
|
+
const _component_el_button = ElButton;
|
|
186
|
+
const _component_el_alert = ElAlert;
|
|
187
|
+
const _component_el_drawer = ElDrawer;
|
|
188
|
+
return openBlock(), createBlock(_component_el_drawer, {
|
|
189
|
+
modelValue: visible.value,
|
|
190
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => visible.value = $event),
|
|
191
|
+
title: "AI 表单助手",
|
|
192
|
+
direction: "rtl",
|
|
193
|
+
size: drawerSize,
|
|
194
|
+
"append-to-body": "",
|
|
195
|
+
"close-on-click-modal": false,
|
|
196
|
+
class: "ai-form-drawer-root"
|
|
197
|
+
}, {
|
|
198
|
+
footer: withCtx(() => [
|
|
199
|
+
createVNode(_component_el_button, {
|
|
200
|
+
onClick: _cache[2] || (_cache[2] = ($event) => visible.value = false)
|
|
201
|
+
}, {
|
|
202
|
+
default: withCtx(() => _cache[9] || (_cache[9] = [
|
|
203
|
+
createTextVNode("关闭")
|
|
204
|
+
])),
|
|
205
|
+
_: 1
|
|
206
|
+
}),
|
|
207
|
+
lastSnapshot.value ? (openBlock(), createBlock(_component_el_button, {
|
|
208
|
+
key: 0,
|
|
209
|
+
type: "warning",
|
|
210
|
+
plain: "",
|
|
211
|
+
disabled: generating.value,
|
|
212
|
+
onClick: handleUndo
|
|
213
|
+
}, {
|
|
214
|
+
default: withCtx(() => _cache[10] || (_cache[10] = [
|
|
215
|
+
createTextVNode(" 撤销本次 AI 改动 ")
|
|
216
|
+
])),
|
|
217
|
+
_: 1
|
|
218
|
+
}, 8, ["disabled"])) : createCommentVNode("", true)
|
|
219
|
+
]),
|
|
220
|
+
default: withCtx(() => [
|
|
221
|
+
createElementVNode("div", _hoisted_1, [
|
|
222
|
+
createElementVNode("div", _hoisted_2, [
|
|
223
|
+
createElementVNode("span", null, "当前表单:" + toDisplayString(fieldCount.value) + " 个字段 / " + toDisplayString(columns.value) + " 列", 1),
|
|
224
|
+
_cache[4] || (_cache[4] = createElementVNode("span", { class: "dot" }, "·", -1)),
|
|
225
|
+
createElementVNode("span", null, "数据源 " + toDisplayString(dsCount.value) + " 个", 1),
|
|
226
|
+
dictCount.value ? (openBlock(), createElementBlock("span", _hoisted_3, "·")) : createCommentVNode("", true),
|
|
227
|
+
dictCount.value ? (openBlock(), createElementBlock("span", _hoisted_4, "已知字典 " + toDisplayString(dictCount.value) + " 个", 1)) : createCommentVNode("", true)
|
|
228
|
+
]),
|
|
229
|
+
createElementVNode("div", _hoisted_5, [
|
|
230
|
+
_cache[5] || (_cache[5] = createElementVNode("div", { class: "block-title" }, "需求描述", -1)),
|
|
231
|
+
createVNode(_component_el_input, {
|
|
232
|
+
modelValue: requirement.value,
|
|
233
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => requirement.value = $event),
|
|
234
|
+
type: "textarea",
|
|
235
|
+
rows: 4,
|
|
236
|
+
resize: "none",
|
|
237
|
+
maxlength: "1000",
|
|
238
|
+
"show-word-limit": "",
|
|
239
|
+
placeholder: "描述你要生成的表单,或要对当前表单做什么修改。例如:新增一个出差申请表单,包含申请人、出差事由、起止日期、费用预算",
|
|
240
|
+
onKeydown: withKeys(withModifiers(handleGenerate, ["ctrl"]), ["enter"])
|
|
241
|
+
}, null, 8, ["modelValue", "onKeydown"])
|
|
242
|
+
]),
|
|
243
|
+
createElementVNode("div", _hoisted_6, [
|
|
244
|
+
createVNode(_component_el_collapse, null, {
|
|
245
|
+
default: withCtx(() => [
|
|
246
|
+
createVNode(_component_el_collapse_item, {
|
|
247
|
+
name: "fieldList",
|
|
248
|
+
title: "字段清单(可选)"
|
|
249
|
+
}, {
|
|
250
|
+
default: withCtx(() => [
|
|
251
|
+
_cache[6] || (_cache[6] = createElementVNode("div", { class: "hint" }, " 粘贴 CREATE TABLE 或 Java 实体类,AI 会优先采用其中的字段名、类型与注释。不填则由 AI 自行设计。 ", -1)),
|
|
252
|
+
createVNode(_component_el_input, {
|
|
253
|
+
modelValue: fieldListRaw.value,
|
|
254
|
+
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => fieldListRaw.value = $event),
|
|
255
|
+
type: "textarea",
|
|
256
|
+
rows: 6,
|
|
257
|
+
resize: "none",
|
|
258
|
+
placeholder: "例如:CREATE TABLE t_contract ( customer_name varchar(100) COMMENT '客户名称', amount decimal(18,2) COMMENT '合同金额' );"
|
|
259
|
+
}, null, 8, ["modelValue"])
|
|
260
|
+
]),
|
|
261
|
+
_: 1
|
|
262
|
+
})
|
|
263
|
+
]),
|
|
264
|
+
_: 1
|
|
265
|
+
})
|
|
266
|
+
]),
|
|
267
|
+
createVNode(_component_el_button, {
|
|
268
|
+
class: "gen-btn",
|
|
269
|
+
type: "primary",
|
|
270
|
+
loading: generating.value,
|
|
271
|
+
disabled: !canGenerate.value,
|
|
272
|
+
onClick: handleGenerate
|
|
273
|
+
}, {
|
|
274
|
+
default: withCtx(() => [
|
|
275
|
+
createTextVNode(toDisplayString(generating.value ? "AI 正在生成,请稍候…" : "生成表单配置"), 1)
|
|
276
|
+
]),
|
|
277
|
+
_: 1
|
|
278
|
+
}, 8, ["loading", "disabled"]),
|
|
279
|
+
errorMessage.value ? (openBlock(), createBlock(_component_el_alert, {
|
|
280
|
+
key: 0,
|
|
281
|
+
class: "block",
|
|
282
|
+
type: "error",
|
|
283
|
+
closable: false,
|
|
284
|
+
title: errorMessage.value
|
|
285
|
+
}, null, 8, ["title"])) : createCommentVNode("", true),
|
|
286
|
+
applied.value ? (openBlock(), createElementBlock("div", _hoisted_7, [
|
|
287
|
+
_cache[7] || (_cache[7] = createElementVNode("div", { class: "block-title" }, "本次已应用到表单", -1)),
|
|
288
|
+
createVNode(AiDiffTable, { model: diffResult.value }, null, 8, ["model"]),
|
|
289
|
+
_cache[8] || (_cache[8] = createElementVNode("div", { class: "undo-hint" }, " AI 改动已直接写入画布,不满意可点右下角「撤销本次 AI 改动」。 ", -1))
|
|
290
|
+
])) : createCommentVNode("", true)
|
|
291
|
+
])
|
|
292
|
+
]),
|
|
293
|
+
_: 1
|
|
294
|
+
}, 8, ["modelValue"]);
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
const AiFormDrawer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-ae307597"]]);
|
|
299
|
+
export {
|
|
300
|
+
AiFormDrawer as default
|
|
301
|
+
};
|