@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
@@ -2,7 +2,32 @@ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof win
2
2
  function getDefaultExportFromCjs(x) {
3
3
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
4
4
  }
5
+ function getAugmentedNamespace(n) {
6
+ if (n.__esModule) return n;
7
+ var f = n.default;
8
+ if (typeof f == "function") {
9
+ var a = function a2() {
10
+ if (this instanceof a2) {
11
+ return Reflect.construct(f, arguments, this.constructor);
12
+ }
13
+ return f.apply(this, arguments);
14
+ };
15
+ a.prototype = f.prototype;
16
+ } else a = {};
17
+ Object.defineProperty(a, "__esModule", { value: true });
18
+ Object.keys(n).forEach(function(k) {
19
+ var d = Object.getOwnPropertyDescriptor(n, k);
20
+ Object.defineProperty(a, k, d.get ? d : {
21
+ enumerable: true,
22
+ get: function() {
23
+ return n[k];
24
+ }
25
+ });
26
+ });
27
+ return a;
28
+ }
5
29
  export {
6
30
  commonjsGlobal,
31
+ getAugmentedNamespace,
7
32
  getDefaultExportFromCjs
8
33
  };
@@ -1,7 +1,7 @@
1
1
  import { getDefaultExportFromCjs } from "./_commonjsHelpers.mjs";
2
- import { __require as requireLib } from "../node_modules/highlight.js/lib/index.mjs";
3
- var libExports = /* @__PURE__ */ requireLib();
4
- const HighlightJS = /* @__PURE__ */ getDefaultExportFromCjs(libExports);
2
+ import { __require as requireCryptoJs } from "../node_modules/crypto-js/index.mjs";
3
+ var cryptoJsExports = requireCryptoJs();
4
+ const CryptoJS = /* @__PURE__ */ getDefaultExportFromCjs(cryptoJsExports);
5
5
  export {
6
- HighlightJS as default
6
+ CryptoJS as default
7
7
  };
@@ -1,7 +1,4 @@
1
- import { getDefaultExportFromCjs } from "./_commonjsHelpers.mjs";
2
- import { __require as requireObjectRefs } from "../node_modules/object-refs/index.mjs";
3
- var objectRefsExports = requireObjectRefs();
4
- const Refs = /* @__PURE__ */ getDefaultExportFromCjs(objectRefsExports);
1
+ var cryptoJs = { exports: {} };
5
2
  export {
6
- Refs as default
3
+ cryptoJs as __module
7
4
  };
@@ -1,5 +1,7 @@
1
- import { __require as requireDist } from "../node_modules/@braintree/sanitize-url/dist/index.mjs";
2
- var distExports = requireDist();
1
+ import { getDefaultExportFromCjs } from "./_commonjsHelpers.mjs";
2
+ import { __require as requireLib } from "../node_modules/highlight.js/lib/index.mjs";
3
+ var libExports = /* @__PURE__ */ requireLib();
4
+ const HighlightJS = /* @__PURE__ */ getDefaultExportFromCjs(libExports);
3
5
  export {
4
- distExports as d
6
+ HighlightJS as default
5
7
  };
@@ -1,4 +1,7 @@
1
- var objectRefs = { exports: {} };
1
+ import { getDefaultExportFromCjs } from "./_commonjsHelpers.mjs";
2
+ import { __require as requireObjectRefs } from "../node_modules/object-refs/index.mjs";
3
+ var objectRefsExports = requireObjectRefs();
4
+ const Refs = /* @__PURE__ */ getDefaultExportFromCjs(objectRefsExports);
2
5
  export {
3
- objectRefs as __module
6
+ Refs as default
4
7
  };
@@ -1,4 +1,5 @@
1
- var dist = {};
1
+ import { __require as requireDist } from "../node_modules/@braintree/sanitize-url/dist/index.mjs";
2
+ var distExports = requireDist();
2
3
  export {
3
- dist as __exports
4
+ distExports as d
4
5
  };
@@ -0,0 +1,4 @@
1
+ var objectRefs = { exports: {} };
2
+ export {
3
+ objectRefs as __module
4
+ };
@@ -0,0 +1,4 @@
1
+ var dist = {};
2
+ export {
3
+ dist as __exports
4
+ };
package/es/config-dev.js CHANGED
@@ -31,6 +31,8 @@ var config = {
31
31
  msg: "base-server", // 消息服务
32
32
  rule: "rule-server", //规则引擎
33
33
  link: "link-server", //elink
34
+ // 外部 HTTP 服务:配置成完整地址后,数据源的"服务名称"下拉即可选择,请求时不再拼接 "/"
35
+ // extApi: "http://192.168.110.28:61091",
34
36
  },
35
37
  };
36
38
 
@@ -1,4 +1,4 @@
1
- const version = "5.6.30";
1
+ const version = "5.6.31";
2
2
  const packageJson = {
3
3
  version
4
4
  };
@@ -16,16 +16,19 @@ const service = axios.create({
16
16
  baseURL: envConfig.api_base_url,
17
17
  timeout: envConfig.api_timeout
18
18
  });
19
+ const isExternalUrl = (url) => /^https?:\/\//i.test(url || "");
19
20
  service.interceptors.request.use(
20
21
  (config) => {
21
22
  removePending(config);
22
23
  addPending(config);
23
- if (config.url != "/login") {
24
+ if (!isExternalUrl(config.url) && config.url != "/login") {
24
25
  config.headers.token = window.$store.getters.token;
25
26
  config.headers.refreshToken = window.$store.getters.refreshToken;
26
27
  }
27
- config.headers.crypto = envConfig.data_crypto || false;
28
- config.headers.sig = envConfig.data_verify_sign || false;
28
+ if (!isExternalUrl(config.url)) {
29
+ config.headers.crypto = envConfig.data_crypto || false;
30
+ config.headers.sig = envConfig.data_verify_sign || false;
31
+ }
29
32
  return config;
30
33
  },
31
34
  (error) => {
@@ -34,7 +37,11 @@ service.interceptors.request.use(
34
37
  );
35
38
  service.interceptors.response.use(
36
39
  (response) => {
40
+ var _a;
37
41
  removePending(response.config);
42
+ if (isExternalUrl((_a = response.config) == null ? void 0 : _a.url)) {
43
+ return response.data;
44
+ }
38
45
  const refreshToken = response.headers["refresh-token"];
39
46
  const token = response.headers["token"];
40
47
  if (token && refreshToken) {
@@ -29,10 +29,6 @@ const aes = {
29
29
  en: (data) => getAesString(data, KP.key, KP.iv),
30
30
  de: (data) => getDAesString(data, KP.key, KP.iv)
31
31
  };
32
- const sha256 = (data) => {
33
- return CryptoJS.SHA256(data).toString(CryptoJS.enc.Hex);
34
- };
35
32
  export {
36
- aes,
37
- sha256
33
+ aes
38
34
  };
@@ -0,0 +1,152 @@
1
+ import "../../../../node_modules/element-plus/es/index.mjs";
2
+ /* empty css */
3
+ /* empty css */
4
+ import { ref, computed, watch, createElementBlock, openBlock, createElementVNode, createCommentVNode, Fragment, renderList, normalizeClass, toDisplayString, unref, createVNode, withCtx, createTextVNode } from "vue";
5
+ import { AI_FIELD_TYPES, getPropLabel } from "./constants.mjs";
6
+ /* empty css */
7
+ import _export_sfc from "../../../../_virtual/_plugin-vue_export-helper.mjs";
8
+ import { ElLink } from "../../../../node_modules/element-plus/es/components/link/index.mjs";
9
+ const _hoisted_1 = {
10
+ key: 0,
11
+ class: "ai-diff-empty"
12
+ };
13
+ const _hoisted_2 = {
14
+ key: 1,
15
+ class: "ai-diff"
16
+ };
17
+ const _hoisted_3 = { class: "diff-body" };
18
+ const _hoisted_4 = { class: "sign" };
19
+ const _hoisted_5 = { class: "group-name" };
20
+ const _hoisted_6 = { class: "count" };
21
+ const _hoisted_7 = { class: "diff-list" };
22
+ const _hoisted_8 = { class: "row" };
23
+ const _hoisted_9 = { class: "name" };
24
+ const _hoisted_10 = { class: "extra" };
25
+ const _hoisted_11 = {
26
+ key: 0,
27
+ class: "change-list"
28
+ };
29
+ const _hoisted_12 = { class: "change-prop" };
30
+ const _hoisted_13 = ["title"];
31
+ const _hoisted_14 = ["title"];
32
+ const _hoisted_15 = {
33
+ key: 0,
34
+ class: "more-tip"
35
+ };
36
+ const _hoisted_16 = {
37
+ key: 0,
38
+ class: "diff-more"
39
+ };
40
+ const LIMIT = 8;
41
+ const _sfc_main = {
42
+ __name: "AiDiffTable",
43
+ props: {
44
+ model: { type: Object, default: () => null }
45
+ },
46
+ setup(__props) {
47
+ const props = __props;
48
+ const GROUPS = [
49
+ { kind: "add", name: "新增", sign: "+", key: "adds" },
50
+ { kind: "modify", name: "修改", sign: "~", key: "modifies" },
51
+ { kind: "remove", name: "删除", sign: "-", key: "removes" }
52
+ ];
53
+ const showAll = ref(false);
54
+ const allGroups = computed(
55
+ () => GROUPS.map((g) => {
56
+ var _a;
57
+ const list = ((_a = props.model) == null ? void 0 : _a[g.key]) || [];
58
+ return { ...g, list, total: list.length };
59
+ }).filter((g) => g.total > 0)
60
+ );
61
+ const total = computed(() => allGroups.value.reduce((n, g) => n + g.total, 0));
62
+ const overflow = computed(() => total.value > LIMIT);
63
+ const hasAny = computed(() => allGroups.value.length > 0);
64
+ const groups = computed(() => {
65
+ if (showAll.value) return allGroups.value;
66
+ let remain = LIMIT;
67
+ return allGroups.value.map((g) => {
68
+ const slice = g.list.slice(0, Math.max(0, remain));
69
+ remain -= slice.length;
70
+ return { ...g, list: slice, hidden: g.total - slice.length };
71
+ });
72
+ });
73
+ watch(
74
+ () => props.model,
75
+ () => {
76
+ showAll.value = false;
77
+ }
78
+ );
79
+ const nameOf = (it) => (it == null ? void 0 : it.label) || (it == null ? void 0 : it.fieldName) || "(未命名)";
80
+ const typeOf = (t) => {
81
+ var _a;
82
+ return ((_a = AI_FIELD_TYPES[t]) == null ? void 0 : _a.label) || t || "";
83
+ };
84
+ const textOf = (v) => v === void 0 || v === null || v === "" ? "(空)" : String(v);
85
+ return (_ctx, _cache) => {
86
+ const _component_el_link = ElLink;
87
+ return !hasAny.value ? (openBlock(), createElementBlock("div", _hoisted_1, "本次没有产生变更")) : (openBlock(), createElementBlock("div", _hoisted_2, [
88
+ createElementVNode("div", _hoisted_3, [
89
+ (openBlock(true), createElementBlock(Fragment, null, renderList(groups.value, (g) => {
90
+ return openBlock(), createElementBlock("div", {
91
+ key: g.kind,
92
+ class: "diff-group"
93
+ }, [
94
+ createElementVNode("div", {
95
+ class: normalizeClass(["group-head", g.kind])
96
+ }, [
97
+ createElementVNode("span", _hoisted_4, toDisplayString(g.sign), 1),
98
+ createElementVNode("span", _hoisted_5, toDisplayString(g.name), 1),
99
+ createElementVNode("span", _hoisted_6, toDisplayString(g.total), 1)
100
+ ], 2),
101
+ createElementVNode("ul", _hoisted_7, [
102
+ (openBlock(true), createElementBlock(Fragment, null, renderList(g.list, (it, i) => {
103
+ return openBlock(), createElementBlock("li", {
104
+ key: `${g.kind}-${i}`
105
+ }, [
106
+ createElementVNode("div", _hoisted_8, [
107
+ createElementVNode("span", _hoisted_9, toDisplayString(nameOf(it)), 1),
108
+ createElementVNode("span", _hoisted_10, toDisplayString(typeOf(it.fieldType)), 1)
109
+ ]),
110
+ g.kind === "modify" ? (openBlock(), createElementBlock("ul", _hoisted_11, [
111
+ (openBlock(true), createElementBlock(Fragment, null, renderList(it.changes, (c, ci) => {
112
+ return openBlock(), createElementBlock("li", { key: ci }, [
113
+ createElementVNode("span", _hoisted_12, toDisplayString(unref(getPropLabel)(c.prop)), 1),
114
+ createElementVNode("span", {
115
+ class: "val old",
116
+ title: textOf(c.oldValue)
117
+ }, toDisplayString(textOf(c.oldValue)), 9, _hoisted_13),
118
+ _cache[1] || (_cache[1] = createElementVNode("span", { class: "arrow" }, "→", -1)),
119
+ createElementVNode("span", {
120
+ class: "val new",
121
+ title: textOf(c.newValue)
122
+ }, toDisplayString(textOf(c.newValue)), 9, _hoisted_14)
123
+ ]);
124
+ }), 128))
125
+ ])) : createCommentVNode("", true)
126
+ ]);
127
+ }), 128)),
128
+ g.hidden ? (openBlock(), createElementBlock("li", _hoisted_15, "…另有 " + toDisplayString(g.hidden) + " 项", 1)) : createCommentVNode("", true)
129
+ ])
130
+ ]);
131
+ }), 128))
132
+ ]),
133
+ overflow.value ? (openBlock(), createElementBlock("div", _hoisted_16, [
134
+ createVNode(_component_el_link, {
135
+ type: "primary",
136
+ underline: false,
137
+ onClick: _cache[0] || (_cache[0] = ($event) => showAll.value = !showAll.value)
138
+ }, {
139
+ default: withCtx(() => [
140
+ createTextVNode(toDisplayString(showAll.value ? "收起" : `展开全部(共 ${total.value} 项)`), 1)
141
+ ]),
142
+ _: 1
143
+ })
144
+ ])) : createCommentVNode("", true)
145
+ ]));
146
+ };
147
+ }
148
+ };
149
+ const AiDiffTable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-582082a6"]]);
150
+ export {
151
+ AiDiffTable as default
152
+ };
@@ -0,0 +1,21 @@
1
+ var _a, _b;
2
+ import service from "../../axios/config.mjs";
3
+ import envConfig from "../../utils/env.mjs";
4
+ const SERVER_PREFIX = ((_b = (_a = envConfig) == null ? void 0 : _a.servers) == null ? void 0 : _b.base) || "base-server";
5
+ const FORM_CONFIG_GEN_API = `/${SERVER_PREFIX}/formConfig/generate`;
6
+ const GEN_TIMEOUT = 18e4;
7
+ async function generateFormConfig(params) {
8
+ const data = await service.post(FORM_CONFIG_GEN_API, params, {
9
+ timeout: GEN_TIMEOUT
10
+ });
11
+ const raw = (data == null ? void 0 : data.raw) ?? "";
12
+ const json = (data == null ? void 0 : data.json) ?? null;
13
+ if (!json && !raw.includes("```")) {
14
+ throw new Error(raw || "AI 未返回有效内容,请稍后重试");
15
+ }
16
+ return { raw, json };
17
+ }
18
+ export {
19
+ FORM_CONFIG_GEN_API,
20
+ generateFormConfig
21
+ };
@@ -0,0 +1,153 @@
1
+ import components from "../form/aside/index.mjs";
2
+ import { getDefaultHeight, LAYOUT_FIELD_TYPES } from "./constants.mjs";
3
+ import cloneDeep from "../../../../node_modules/lodash-es/cloneDeep.mjs";
4
+ function getWidgetTemplate(fieldType) {
5
+ const found = findDefinition(fieldType);
6
+ if (!found) return { fieldType };
7
+ const tpl = cloneDeep(found);
8
+ if (LAYOUT_FIELD_TYPES.includes(fieldType)) {
9
+ delete tpl.fieldName;
10
+ }
11
+ delete tpl.label;
12
+ return tpl;
13
+ }
14
+ function findDefinition(fieldType) {
15
+ let result = null;
16
+ (components || []).some((group) => {
17
+ return (group.children || []).some((child) => {
18
+ if (child.fieldType === fieldType) {
19
+ result = child;
20
+ return true;
21
+ }
22
+ return false;
23
+ });
24
+ });
25
+ return result;
26
+ }
27
+ function buildLayoutItem(payload, opts) {
28
+ const { columns, index, position, width } = opts;
29
+ const id = String(Date.now()) + String(index).padStart(3, "0");
30
+ const component = {
31
+ ...getWidgetTemplate(payload.fieldType),
32
+ id,
33
+ type: "widgets",
34
+ ...payload
35
+ };
36
+ const x = (position == null ? void 0 : position.x) ?? 0;
37
+ const y = (position == null ? void 0 : position.y) ?? 0;
38
+ const w = payload.width === "full" ? columns : 1;
39
+ return {
40
+ x,
41
+ y,
42
+ w,
43
+ h: getDefaultHeight(payload.fieldType),
44
+ i: id,
45
+ moved: false,
46
+ isResizable: true,
47
+ component,
48
+ id
49
+ };
50
+ }
51
+ function applyChanges(params) {
52
+ const { editConfigData, diffResult, aiFormConfig = {} } = params;
53
+ const oldColumns = (editConfigData == null ? void 0 : editConfigData.columns) ?? 2;
54
+ const newColumns = Number.isFinite(aiFormConfig == null ? void 0 : aiFormConfig.columns) ? aiFormConfig.columns : oldColumns;
55
+ const originals = (editConfigData == null ? void 0 : editConfigData.fieldsData) || [];
56
+ const removedSet = /* @__PURE__ */ new Set();
57
+ (diffResult.removes || []).forEach((r) => {
58
+ if (r.selected) removedSet.add(r.item);
59
+ });
60
+ const surviving = originals.filter((item) => !(item && item.component && item.hidden !== true && removedSet.has(item))).map((item) => ({
61
+ item: cloneDeep(item)
62
+ }));
63
+ const modifyMap = /* @__PURE__ */ new Map();
64
+ (diffResult.modifies || []).forEach((m) => {
65
+ if (!m.selected) return;
66
+ modifyMap.set(m.key, m);
67
+ });
68
+ surviving.forEach(({ item }) => {
69
+ item.w = clampWidth(item.w, newColumns);
70
+ const c = item.component;
71
+ if (!c) return;
72
+ const key = c.fieldName || `${c.label || ""}|${c.fieldType}`;
73
+ const mod = modifyMap.get(key);
74
+ if (!mod) return;
75
+ mod.changes.forEach((ch) => {
76
+ if (!ch.selected) return;
77
+ c[ch.prop] = ch.newValue;
78
+ });
79
+ });
80
+ const maxY = originals.reduce((acc, it) => Math.max(acc, (it == null ? void 0 : it.y) || 0), 0);
81
+ const result = [];
82
+ const pendingAdds = (diffResult.adds || []).filter((a) => a.selected);
83
+ const anchorOnAdd = /* @__PURE__ */ new Map();
84
+ pendingAdds.forEach((a) => {
85
+ const anchorKey = a.insertAfter || "";
86
+ if (!anchorOnAdd.has(anchorKey)) anchorOnAdd.set(anchorKey, []);
87
+ anchorOnAdd.get(anchorKey).push(a);
88
+ });
89
+ const widthOf = (a) => a.width === "full" ? newColumns : 1;
90
+ let seq = 0;
91
+ surviving.forEach(({ item }) => {
92
+ result.push(item);
93
+ const c = item.component;
94
+ const key = c == null ? void 0 : c.fieldName;
95
+ if (!key) return;
96
+ const list = anchorOnAdd.get(key);
97
+ if (!list) return;
98
+ let cx = (item.x || 0) + (item.w || 1);
99
+ let cy = item.y || 0;
100
+ list.forEach((a) => {
101
+ if (cx + widthOf(a) > newColumns) {
102
+ cx = 0;
103
+ cy += 1;
104
+ }
105
+ result.push(
106
+ buildLayoutItem(a.payload, {
107
+ columns: newColumns,
108
+ index: seq++,
109
+ position: { x: cx, y: cy }
110
+ })
111
+ );
112
+ cx += widthOf(a);
113
+ });
114
+ anchorOnAdd.delete(key);
115
+ });
116
+ let tailX = 0;
117
+ let tailY = maxY + 1;
118
+ anchorOnAdd.forEach((list) => {
119
+ list.forEach((a) => {
120
+ if (tailX + widthOf(a) > newColumns) {
121
+ tailX = 0;
122
+ tailY += 1;
123
+ }
124
+ result.push(
125
+ buildLayoutItem(a.payload, {
126
+ columns: newColumns,
127
+ index: seq++,
128
+ position: { x: tailX, y: tailY },
129
+ width: a.width
130
+ })
131
+ );
132
+ tailX += widthOf(a);
133
+ });
134
+ });
135
+ return {
136
+ fieldsData: result,
137
+ formConfig: {
138
+ columns: newColumns,
139
+ ...Number.isFinite(aiFormConfig == null ? void 0 : aiFormConfig.labelWidth) ? { labelWidth: aiFormConfig.labelWidth } : {},
140
+ ...(aiFormConfig == null ? void 0 : aiFormConfig.labelPosition) ? { labelPosition: aiFormConfig.labelPosition } : {}
141
+ }
142
+ };
143
+ }
144
+ function clampWidth(w, columns) {
145
+ const n = Number(w);
146
+ if (!Number.isFinite(n) || n <= 0) return 1;
147
+ return Math.min(Math.floor(n), columns);
148
+ }
149
+ export {
150
+ applyChanges,
151
+ buildLayoutItem,
152
+ getWidgetTemplate
153
+ };
@@ -0,0 +1,69 @@
1
+ import { AI_FIELD_TYPES, getAllowedProps } from "./constants.mjs";
2
+ function extractDataSources(editConfigData) {
3
+ const list = editConfigData == null ? void 0 : editConfigData.dataSources;
4
+ if (!Array.isArray(list) || !list.length) return [];
5
+ return list.map((ds) => ({
6
+ id: ds.id,
7
+ name: ds.name || "",
8
+ url: ds.url || ""
9
+ }));
10
+ }
11
+ function extractDictionaries(editConfigData) {
12
+ const fields = (editConfigData == null ? void 0 : editConfigData.fieldsData) || [];
13
+ const set = /* @__PURE__ */ new Set();
14
+ fields.forEach((item) => {
15
+ var _a, _b;
16
+ const key = (_b = (_a = item == null ? void 0 : item.component) == null ? void 0 : _a.optionConfig) == null ? void 0 : _b.dictionaryValue;
17
+ if (key) set.add(key);
18
+ });
19
+ return [...set];
20
+ }
21
+ function getVisibleLayoutItems(editConfigData) {
22
+ const fields = (editConfigData == null ? void 0 : editConfigData.fieldsData) || [];
23
+ return fields.filter((item) => item && item.component && item.hidden !== true).sort((a, b) => {
24
+ if (a.y !== b.y) return (a.y || 0) - (b.y || 0);
25
+ return (a.x || 0) - (b.x || 0);
26
+ });
27
+ }
28
+ function compressComponent(component) {
29
+ const fieldType = component.fieldType;
30
+ const result = {};
31
+ if (!AI_FIELD_TYPES[fieldType]) {
32
+ return { fieldType, label: component.label || "", _unsupported: true };
33
+ }
34
+ const allowed = getAllowedProps(fieldType);
35
+ for (const key of allowed) {
36
+ if (component[key] !== void 0) {
37
+ result[key] = component[key];
38
+ }
39
+ }
40
+ return result;
41
+ }
42
+ function compressFormConfig(editConfigData) {
43
+ if (!editConfigData) return null;
44
+ const items = getVisibleLayoutItems(editConfigData);
45
+ if (!items.length) return null;
46
+ const fields = items.map((item) => compressComponent(item.component));
47
+ return {
48
+ columns: editConfigData.columns ?? 2,
49
+ labelWidth: editConfigData.labelWidth ?? 120,
50
+ labelPosition: editConfigData.labelPosition ?? "right",
51
+ fields
52
+ };
53
+ }
54
+ function buildAiInput(editConfigData, opts = {}) {
55
+ const { includeCurrentConfig = true } = opts;
56
+ return {
57
+ currentConfig: includeCurrentConfig ? compressFormConfig(editConfigData) : null,
58
+ dataSources: extractDataSources(editConfigData),
59
+ dictionaries: extractDictionaries(editConfigData)
60
+ };
61
+ }
62
+ export {
63
+ buildAiInput,
64
+ compressComponent,
65
+ compressFormConfig,
66
+ extractDataSources,
67
+ extractDictionaries,
68
+ getVisibleLayoutItems
69
+ };