@jzg223/design-runtime 0.0.0-stage → 0.0.1

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 (229) hide show
  1. package/CHANGELOG.md +176 -0
  2. package/README.md +275 -2
  3. package/dist/_virtual/_plugin-vue_export-helper.js +10 -0
  4. package/dist/api.js +149 -0
  5. package/dist/comb/design-comb.vue.js +7 -0
  6. package/dist/comb/design-comb2.vue.js +591 -0
  7. package/dist/compat.js +74 -0
  8. package/dist/components/ApiSwitch.vue.js +7 -0
  9. package/dist/components/ApiSwitch2.vue.js +98 -0
  10. package/dist/components/design-debug/dev-mode-toggle.vue.js +7 -0
  11. package/dist/components/design-debug/dev-mode-toggle2.vue.js +41 -0
  12. package/dist/components/design-debug/dev-mode.js +45 -0
  13. package/dist/components/design-debug/dev-state-button.vue.js +7 -0
  14. package/dist/components/design-debug/dev-state-button2.vue.js +447 -0
  15. package/dist/components/design-debug/expr-eval.js +81 -0
  16. package/dist/components/design-shared/host-api.js +47 -0
  17. package/dist/components/design-shared/popup-host.js +11 -0
  18. package/dist/components/design-table/design-table-inner.vue.js +7 -0
  19. package/dist/components/design-table/design-table-inner2.vue.js +39 -0
  20. package/dist/components/design-table/design-table.vue.js +7 -0
  21. package/dist/components/design-table/design-table2.vue.js +937 -0
  22. package/dist/components/design-table/row-actions/delete-action.vue.js +4 -0
  23. package/dist/components/design-table/row-actions/delete-action2.vue.js +42 -0
  24. package/dist/components/design-table/row-actions/edit-action.vue.js +4 -0
  25. package/dist/components/design-table/row-actions/edit-action2.vue.js +145 -0
  26. package/dist/components/design-table/row-actions/index.js +36 -0
  27. package/dist/components/design-table/row-actions/modal-comb-action.vue.js +4 -0
  28. package/dist/components/design-table/row-actions/modal-comb-action2.vue.js +66 -0
  29. package/dist/components/design-table/row-actions/modal-custom-action.vue.js +7 -0
  30. package/dist/components/design-table/row-actions/modal-custom-action2.vue.js +105 -0
  31. package/dist/components/design-table/row-actions/modal-form-action.vue.js +4 -0
  32. package/dist/components/design-table/row-actions/modal-form-action2.vue.js +82 -0
  33. package/dist/components/design-table/row-actions/modal-table-action.vue.js +4 -0
  34. package/dist/components/design-table/row-actions/modal-table-action2.vue.js +67 -0
  35. package/dist/components/design-table/row-actions/modal-tree-action.vue.js +4 -0
  36. package/dist/components/design-table/row-actions/modal-tree-action2.vue.js +70 -0
  37. package/dist/components/design-table/row-actions/navigate-comb-action.vue.js +4 -0
  38. package/dist/components/design-table/row-actions/navigate-comb-action2.vue.js +47 -0
  39. package/dist/components/design-table/row-actions/navigate-form-action.vue.js +4 -0
  40. package/dist/components/design-table/row-actions/navigate-form-action2.vue.js +47 -0
  41. package/dist/components/design-table/row-actions/navigate-table-action.vue.js +4 -0
  42. package/dist/components/design-table/row-actions/navigate-table-action2.vue.js +47 -0
  43. package/dist/components/design-table/row-actions/navigate-tree-action.vue.js +4 -0
  44. package/dist/components/design-table/row-actions/navigate-tree-action2.vue.js +47 -0
  45. package/dist/components/design-table/row-actions/other-action.vue.js +4 -0
  46. package/dist/components/design-table/row-actions/other-action2.vue.js +44 -0
  47. package/dist/components/design-tools/add-tool.vue.js +4 -0
  48. package/dist/components/design-tools/add-tool2.vue.js +136 -0
  49. package/dist/components/design-tools/command-executor.js +135 -0
  50. package/dist/components/design-tools/export-tool.vue.js +4 -0
  51. package/dist/components/design-tools/export-tool2.vue.js +46 -0
  52. package/dist/components/design-tools/import-tool.vue.js +4 -0
  53. package/dist/components/design-tools/import-tool2.vue.js +101 -0
  54. package/dist/components/design-tools/index.js +36 -0
  55. package/dist/components/design-tools/modal-comb-tool.vue.js +4 -0
  56. package/dist/components/design-tools/modal-comb-tool2.vue.js +56 -0
  57. package/dist/components/design-tools/modal-form-tool.vue.js +4 -0
  58. package/dist/components/design-tools/modal-form-tool2.vue.js +66 -0
  59. package/dist/components/design-tools/modal-hcm-tool.vue.js +7 -0
  60. package/dist/components/design-tools/modal-hcm-tool2.vue.js +85 -0
  61. package/dist/components/design-tools/modal-table-tool.vue.js +4 -0
  62. package/dist/components/design-tools/modal-table-tool2.vue.js +54 -0
  63. package/dist/components/design-tools/modal-tree-tool.vue.js +4 -0
  64. package/dist/components/design-tools/modal-tree-tool2.vue.js +57 -0
  65. package/dist/components/design-tools/navigate-comb-tool.vue.js +4 -0
  66. package/dist/components/design-tools/navigate-comb-tool2.vue.js +34 -0
  67. package/dist/components/design-tools/navigate-form-tool.vue.js +4 -0
  68. package/dist/components/design-tools/navigate-form-tool2.vue.js +34 -0
  69. package/dist/components/design-tools/navigate-table-tool.vue.js +4 -0
  70. package/dist/components/design-tools/navigate-table-tool2.vue.js +33 -0
  71. package/dist/components/design-tools/other-tool.vue.js +4 -0
  72. package/dist/components/design-tools/other-tool2.vue.js +34 -0
  73. package/dist/components/flow-status-cell/flow-status-cell.vue.js +7 -0
  74. package/dist/components/flow-status-cell/flow-status-cell2.vue.js +124 -0
  75. package/dist/flow.js +22 -0
  76. package/dist/form/cell-condition.js +122 -0
  77. package/dist/form/derived-express.js +34 -0
  78. package/dist/form/design-form-inner.vue.js +7 -0
  79. package/dist/form/design-form-inner2.vue.js +449 -0
  80. package/dist/form/design-form.vue.js +7 -0
  81. package/dist/form/design-form2.vue.js +681 -0
  82. package/dist/form/fields/checkbox-field.vue.js +88 -0
  83. package/dist/form/fields/checkbox-field2.vue.js +4 -0
  84. package/dist/form/fields/custom-field.vue.js +36 -0
  85. package/dist/form/fields/custom-field2.vue.js +4 -0
  86. package/dist/form/fields/date-field.vue.js +64 -0
  87. package/dist/form/fields/date-field2.vue.js +4 -0
  88. package/dist/form/fields/embedded-list-field.vue.js +7 -0
  89. package/dist/form/fields/embedded-list-field2.vue.js +437 -0
  90. package/dist/form/fields/file-field.vue.js +88 -0
  91. package/dist/form/fields/file-field2.vue.js +4 -0
  92. package/dist/form/fields/image-field.vue.js +90 -0
  93. package/dist/form/fields/image-field2.vue.js +4 -0
  94. package/dist/form/fields/index.js +106 -0
  95. package/dist/form/fields/month-field.vue.js +51 -0
  96. package/dist/form/fields/month-field2.vue.js +4 -0
  97. package/dist/form/fields/org-select-field.vue.js +7 -0
  98. package/dist/form/fields/org-select-field2.vue.js +187 -0
  99. package/dist/form/fields/orgs-select-field.vue.js +182 -0
  100. package/dist/form/fields/orgs-select-field2.vue.js +4 -0
  101. package/dist/form/fields/radio-field.vue.js +91 -0
  102. package/dist/form/fields/radio-field2.vue.js +4 -0
  103. package/dist/form/fields/select-field.vue.js +7 -0
  104. package/dist/form/fields/select-field2.vue.js +317 -0
  105. package/dist/form/fields/splitline-field.vue.js +7 -0
  106. package/dist/form/fields/splitline-field2.vue.js +50 -0
  107. package/dist/form/fields/switch-field.vue.js +32 -0
  108. package/dist/form/fields/switch-field2.vue.js +4 -0
  109. package/dist/form/fields/text-field.vue.js +78 -0
  110. package/dist/form/fields/text-field2.vue.js +4 -0
  111. package/dist/form/fields/time-field.vue.js +50 -0
  112. package/dist/form/fields/time-field2.vue.js +4 -0
  113. package/dist/form/fields/tree-field.vue.js +157 -0
  114. package/dist/form/fields/tree-field2.vue.js +4 -0
  115. package/dist/form/number-precision.js +18 -0
  116. package/dist/form/transformer.js +162 -0
  117. package/dist/host.js +76 -0
  118. package/dist/http.js +19 -0
  119. package/dist/index.js +166 -0
  120. package/dist/mapping.js +44 -0
  121. package/dist/org/dept-api.js +30 -0
  122. package/dist/org/dept-tree-source.js +53 -0
  123. package/dist/org/dept-tree.js +122 -0
  124. package/dist/registry.js +77 -0
  125. package/dist/search/design-search.vue.js +7 -0
  126. package/dist/search/design-search2.vue.js +232 -0
  127. package/dist/search/transformer.js +115 -0
  128. package/dist/style.css +1220 -0
  129. package/dist/table/data.js +18 -0
  130. package/dist/table/load-gate.js +19 -0
  131. package/dist/table/query-body.js +59 -0
  132. package/dist/table/query-dedupe.js +54 -0
  133. package/dist/table/query-search.js +9 -0
  134. package/dist/table/row-action-mapping.js +34 -0
  135. package/dist/table/transformer.js +328 -0
  136. package/dist/tree/design-tree.vue.js +7 -0
  137. package/dist/tree/design-tree2.vue.js +783 -0
  138. package/dist/types/api.d.ts +83 -0
  139. package/dist/types/comb/design-comb.vue.d.ts +38 -0
  140. package/dist/types/compat.d.ts +46 -0
  141. package/dist/types/components/ApiSwitch.vue.d.ts +31 -0
  142. package/dist/types/components/design-debug/dev-mode-toggle.vue.d.ts +2 -0
  143. package/dist/types/components/design-debug/dev-mode.d.ts +8 -0
  144. package/dist/types/components/design-debug/dev-state-button.vue.d.ts +55 -0
  145. package/dist/types/components/design-debug/expr-eval.d.ts +55 -0
  146. package/dist/types/components/design-shared/host-api.d.ts +60 -0
  147. package/dist/types/components/design-shared/popup-host.d.ts +13 -0
  148. package/dist/types/components/design-table/design-table-inner.vue.d.ts +19 -0
  149. package/dist/types/components/design-table/design-table.vue.d.ts +70 -0
  150. package/dist/types/components/design-table/row-actions/delete-action.vue.d.ts +12 -0
  151. package/dist/types/components/design-table/row-actions/edit-action.vue.d.ts +14 -0
  152. package/dist/types/components/design-table/row-actions/index.d.ts +25 -0
  153. package/dist/types/components/design-table/row-actions/modal-comb-action.vue.d.ts +10 -0
  154. package/dist/types/components/design-table/row-actions/modal-custom-action.vue.d.ts +15 -0
  155. package/dist/types/components/design-table/row-actions/modal-form-action.vue.d.ts +10 -0
  156. package/dist/types/components/design-table/row-actions/modal-table-action.vue.d.ts +10 -0
  157. package/dist/types/components/design-table/row-actions/modal-tree-action.vue.d.ts +10 -0
  158. package/dist/types/components/design-table/row-actions/navigate-comb-action.vue.d.ts +10 -0
  159. package/dist/types/components/design-table/row-actions/navigate-form-action.vue.d.ts +10 -0
  160. package/dist/types/components/design-table/row-actions/navigate-table-action.vue.d.ts +10 -0
  161. package/dist/types/components/design-table/row-actions/navigate-tree-action.vue.d.ts +10 -0
  162. package/dist/types/components/design-table/row-actions/other-action.vue.d.ts +14 -0
  163. package/dist/types/components/design-tools/add-tool.vue.d.ts +23 -0
  164. package/dist/types/components/design-tools/command-executor.d.ts +80 -0
  165. package/dist/types/components/design-tools/export-tool.vue.d.ts +9 -0
  166. package/dist/types/components/design-tools/import-tool.vue.d.ts +14 -0
  167. package/dist/types/components/design-tools/index.d.ts +23 -0
  168. package/dist/types/components/design-tools/modal-comb-tool.vue.d.ts +12 -0
  169. package/dist/types/components/design-tools/modal-form-tool.vue.d.ts +12 -0
  170. package/dist/types/components/design-tools/modal-hcm-tool.vue.d.ts +23 -0
  171. package/dist/types/components/design-tools/modal-table-tool.vue.d.ts +12 -0
  172. package/dist/types/components/design-tools/modal-tree-tool.vue.d.ts +12 -0
  173. package/dist/types/components/design-tools/navigate-comb-tool.vue.d.ts +12 -0
  174. package/dist/types/components/design-tools/navigate-form-tool.vue.d.ts +11 -0
  175. package/dist/types/components/design-tools/navigate-table-tool.vue.d.ts +12 -0
  176. package/dist/types/components/design-tools/other-tool.vue.d.ts +16 -0
  177. package/dist/types/components/flow-status-cell/flow-status-cell.vue.d.ts +14 -0
  178. package/dist/types/components/index.d.ts +33 -0
  179. package/dist/types/flow.d.ts +50 -0
  180. package/dist/types/form/cell-condition.d.ts +35 -0
  181. package/dist/types/form/derived-express.d.ts +28 -0
  182. package/dist/types/form/design-form-inner.vue.d.ts +55 -0
  183. package/dist/types/form/design-form.vue.d.ts +96 -0
  184. package/dist/types/form/fields/checkbox-field.vue.d.ts +14 -0
  185. package/dist/types/form/fields/custom-field.vue.d.ts +22 -0
  186. package/dist/types/form/fields/date-field.vue.d.ts +12 -0
  187. package/dist/types/form/fields/embedded-list-field.vue.d.ts +26 -0
  188. package/dist/types/form/fields/file-field.vue.d.ts +12 -0
  189. package/dist/types/form/fields/image-field.vue.d.ts +12 -0
  190. package/dist/types/form/fields/index.d.ts +34 -0
  191. package/dist/types/form/fields/month-field.vue.d.ts +12 -0
  192. package/dist/types/form/fields/org-select-field.vue.d.ts +14 -0
  193. package/dist/types/form/fields/orgs-select-field.vue.d.ts +12 -0
  194. package/dist/types/form/fields/radio-field.vue.d.ts +14 -0
  195. package/dist/types/form/fields/select-field.vue.d.ts +14 -0
  196. package/dist/types/form/fields/splitline-field.vue.d.ts +7 -0
  197. package/dist/types/form/fields/switch-field.vue.d.ts +12 -0
  198. package/dist/types/form/fields/text-field.vue.d.ts +12 -0
  199. package/dist/types/form/fields/time-field.vue.d.ts +12 -0
  200. package/dist/types/form/fields/tree-field.vue.d.ts +12 -0
  201. package/dist/types/form/number-precision.d.ts +15 -0
  202. package/dist/types/form/transformer.d.ts +27 -0
  203. package/dist/types/host.d.ts +182 -0
  204. package/dist/types/http.d.ts +59 -0
  205. package/dist/types/index.d.ts +41 -0
  206. package/dist/types/mapping.d.ts +39 -0
  207. package/dist/types/org/dept-api.d.ts +12 -0
  208. package/dist/types/org/dept-tree-source.d.ts +15 -0
  209. package/dist/types/org/dept-tree.d.ts +62 -0
  210. package/dist/types/registry.d.ts +79 -0
  211. package/dist/types/search/design-search.vue.d.ts +46 -0
  212. package/dist/types/search/transformer.d.ts +36 -0
  213. package/dist/types/table/data.d.ts +30 -0
  214. package/dist/types/table/index.d.ts +20 -0
  215. package/dist/types/table/load-gate.d.ts +24 -0
  216. package/dist/types/table/query-body.d.ts +46 -0
  217. package/dist/types/table/query-dedupe.d.ts +42 -0
  218. package/dist/types/table/query-search.d.ts +21 -0
  219. package/dist/types/table/row-action-mapping.d.ts +36 -0
  220. package/dist/types/table/transformer.d.ts +59 -0
  221. package/dist/types/tree/design-tree.vue.d.ts +33 -0
  222. package/dist/types/types.d.ts +525 -0
  223. package/dist/types/utils/default-value.d.ts +16 -0
  224. package/dist/types/utils/download.d.ts +9 -0
  225. package/dist/types/utils/popup-width.d.ts +21 -0
  226. package/dist/utils/default-value.js +38 -0
  227. package/dist/utils/download.js +19 -0
  228. package/dist/utils/popup-width.js +19 -0
  229. package/package.json +73 -4
@@ -0,0 +1,18 @@
1
+ import { requireHttp } from "../host.js";
2
+ import { buildTableDataBody } from "./query-body.js";
3
+ function fetchTableData(url, params) {
4
+ return requireHttp().post(
5
+ url,
6
+ buildTableDataBody(
7
+ params.pageNum,
8
+ params.pageSize,
9
+ params.search,
10
+ params.configParams,
11
+ params.envParams
12
+ ),
13
+ { signal: params.signal, silent: true }
14
+ );
15
+ }
16
+ export {
17
+ fetchTableData
18
+ };
@@ -0,0 +1,19 @@
1
+ function evaluateLoadGate(expression, scope) {
2
+ const express = (expression ?? "").trim();
3
+ if (!express) return { ok: true };
4
+ try {
5
+ const fn = new Function("params", "search", `return Boolean(${express});`);
6
+ const ok = fn(scope.params ?? {}, scope.search ?? {});
7
+ return { ok: Boolean(ok) };
8
+ } catch (err) {
9
+ const message = (err == null ? void 0 : err.message) ?? String(err);
10
+ console.warn(
11
+ `[design-runtime][table] 加载条件表达式执行失败(按「不加载」处理):${express}`,
12
+ message
13
+ );
14
+ return { error: message, ok: false };
15
+ }
16
+ }
17
+ export {
18
+ evaluateLoadGate
19
+ };
@@ -0,0 +1,59 @@
1
+ function buildTableDataBody(pageNum, pageSize, search, configParams, envParams) {
2
+ const runtime = { ...search ?? {} };
3
+ const conf = { ...configParams ?? {} };
4
+ const env = { ...envParams ?? {} };
5
+ for (const key of Object.keys(conf)) {
6
+ if (conf[key] === null || conf[key] === void 0) {
7
+ delete conf[key];
8
+ }
9
+ }
10
+ return {
11
+ pageNo: pageNum,
12
+ pageNum,
13
+ pageSize,
14
+ // search:只放查询条件(决定 WHERE)
15
+ search: { ...runtime },
16
+ // params:只放表达式 env(组件自身参数 + 列表「查询参数」,同名以配置为准)
17
+ params: { ...env, ...conf }
18
+ };
19
+ }
20
+ function parseConfigParams(raw) {
21
+ if (raw === null || raw === void 0) {
22
+ return {};
23
+ }
24
+ if (typeof raw === "object") {
25
+ if (Array.isArray(raw)) {
26
+ console.warn(
27
+ "[design-runtime][table] 列表「查询参数」必须是 JSON 对象,已忽略:",
28
+ raw
29
+ );
30
+ return {};
31
+ }
32
+ return { ...raw };
33
+ }
34
+ const text = String(raw).trim();
35
+ if (!text) {
36
+ return {};
37
+ }
38
+ try {
39
+ const parsed = JSON.parse(text);
40
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
41
+ return { ...parsed };
42
+ }
43
+ console.warn(
44
+ "[design-runtime][table] 列表「查询参数」必须是 JSON 对象,已忽略:",
45
+ text
46
+ );
47
+ } catch (error) {
48
+ console.warn(
49
+ "[design-runtime][table] 列表「查询参数」不是合法 JSON,已忽略:",
50
+ (error == null ? void 0 : error.message) ?? error,
51
+ text
52
+ );
53
+ }
54
+ return {};
55
+ }
56
+ export {
57
+ buildTableDataBody,
58
+ parseConfigParams
59
+ };
@@ -0,0 +1,54 @@
1
+ function createQueryDedupe(options = {}) {
2
+ const windowMs = options.windowMs ?? 1500;
3
+ const now = options.now ?? (() => Date.now());
4
+ let rebuiltAt = 0;
5
+ let inflight = null;
6
+ let last = null;
7
+ const stats = { fetched: 0, merged: 0, reused: 0 };
8
+ function isDedupeWindow(ts) {
9
+ return rebuiltAt > 0 && ts - rebuiltAt <= windowMs;
10
+ }
11
+ function markRebuild() {
12
+ rebuiltAt = now();
13
+ }
14
+ function reset() {
15
+ rebuiltAt = 0;
16
+ }
17
+ async function run(key, factory) {
18
+ const ts = now();
19
+ if (inflight && inflight.key === key) {
20
+ stats.merged += 1;
21
+ return inflight.promise;
22
+ }
23
+ if (isDedupeWindow(ts)) {
24
+ if (last && last.key === key && ts - last.at <= windowMs) {
25
+ stats.reused += 1;
26
+ rebuiltAt = 0;
27
+ return last.data;
28
+ }
29
+ }
30
+ const promise = factory();
31
+ inflight = { key, promise };
32
+ stats.fetched += 1;
33
+ try {
34
+ const data = await promise;
35
+ last = { at: now(), data, key };
36
+ rebuiltAt = 0;
37
+ return data;
38
+ } finally {
39
+ if (inflight && inflight.promise === promise) {
40
+ inflight = null;
41
+ }
42
+ }
43
+ }
44
+ return {
45
+ getStats: () => ({ ...stats }),
46
+ isDedupeWindow: () => isDedupeWindow(now()),
47
+ markRebuild,
48
+ reset,
49
+ run
50
+ };
51
+ }
52
+ export {
53
+ createQueryDedupe
54
+ };
@@ -0,0 +1,9 @@
1
+ function buildQuerySearch(pageSearch, formValues) {
2
+ return {
3
+ ...pageSearch ?? {},
4
+ ...formValues ?? {}
5
+ };
6
+ }
7
+ export {
8
+ buildQuerySearch
9
+ };
@@ -0,0 +1,34 @@
1
+ import { evaluateMappedExpress } from "../mapping.js";
2
+ function evaluateExpress(express, params, row) {
3
+ return evaluateMappedExpress(express, { params, row });
4
+ }
5
+ function buildCustomParams(mappings, params, row) {
6
+ const result = {};
7
+ if (!Array.isArray(mappings) || mappings.length === 0) {
8
+ return result;
9
+ }
10
+ for (const m of mappings) {
11
+ if (!(m == null ? void 0 : m.paramName)) continue;
12
+ const val = evaluateExpress(m.express, params, row);
13
+ if (val !== void 0) result[m.paramName] = val;
14
+ }
15
+ return result;
16
+ }
17
+ function buildNavigateQuery(mappings, params, row, _pfield) {
18
+ const result = {};
19
+ if (!Array.isArray(mappings) || mappings.length === 0) {
20
+ return result;
21
+ }
22
+ for (const m of mappings) {
23
+ if (m == null ? void 0 : m.paramName) {
24
+ const val = evaluateExpress(m.express, params, row);
25
+ if (val !== void 0) result[m.paramName] = String(val);
26
+ }
27
+ }
28
+ return result;
29
+ }
30
+ export {
31
+ buildCustomParams,
32
+ buildNavigateQuery,
33
+ evaluateExpress
34
+ };
@@ -0,0 +1,328 @@
1
+ import { h } from "vue";
2
+ import { Tag } from "antdv-next";
3
+ import { fetchTableData } from "./data.js";
4
+ import { parseConfigParams } from "./query-body.js";
5
+ let warnedMissingRenderDict = false;
6
+ function parseWidth(width) {
7
+ if (!width) return { minWidth: 80 };
8
+ const parts = width.split(":");
9
+ const result = {};
10
+ if (parts[0]) result.width = Number.parseInt(parts[0], 10);
11
+ if (parts[1]) result.minWidth = Number.parseInt(parts[1], 10);
12
+ if (parts[2]) result.maxWidth = Number.parseInt(parts[2], 10);
13
+ return result;
14
+ }
15
+ function isColumnHidden(column) {
16
+ const flag = column == null ? void 0 : column.isShow;
17
+ return flag === false || flag === 0 || flag === "0" || flag === "false";
18
+ }
19
+ function readValueExpress(editRaw) {
20
+ if (!editRaw) return "";
21
+ try {
22
+ const edit = typeof editRaw === "string" ? JSON.parse(editRaw) : editRaw;
23
+ const express = edit == null ? void 0 : edit.valueExpress;
24
+ return typeof express === "string" ? express.trim() : "";
25
+ } catch {
26
+ return "";
27
+ }
28
+ }
29
+ function readEdit(editRaw) {
30
+ if (!editRaw) return null;
31
+ try {
32
+ const edit = typeof editRaw === "string" ? JSON.parse(editRaw) : editRaw;
33
+ return edit && typeof edit === "object" ? edit : null;
34
+ } catch {
35
+ return null;
36
+ }
37
+ }
38
+ function transformColumn(column, host) {
39
+ var _a, _b;
40
+ if (column.type === "seNo") {
41
+ return { type: "seq", title: column.title || "#", width: 60 };
42
+ }
43
+ if (column.type === "dataSelect") {
44
+ return { type: "checkbox", width: 50 };
45
+ }
46
+ const { width, minWidth, maxWidth } = parseWidth(column.width);
47
+ const base = {
48
+ field: column.field,
49
+ minWidth: minWidth ?? width ?? 80,
50
+ title: column.title,
51
+ width
52
+ };
53
+ if (maxWidth) base.maxWidth = maxWidth;
54
+ if (column.fixed) base.fixed = column.fixed;
55
+ const editConfig = readEdit(column.edit);
56
+ const valueExpress = readValueExpress(column.edit);
57
+ if (valueExpress) {
58
+ const key = (column.name || column.field || "").trim();
59
+ if (!key) {
60
+ console.warn(
61
+ "[design-runtime][table] 值计算列没有列名(来源字段也空),已跳过:",
62
+ column.title,
63
+ valueExpress
64
+ );
65
+ return null;
66
+ }
67
+ return {
68
+ ...base,
69
+ // 数字列(2026-10-23):后端把格式化文本写回同一个 key,右对齐即可
70
+ ...(editConfig == null ? void 0 : editConfig.type) === "number" ? { align: "right" } : {},
71
+ field: key
72
+ };
73
+ }
74
+ if ((editConfig == null ? void 0 : editConfig.type) === "hcm") {
75
+ const comname = String(editConfig.comname ?? "").trim();
76
+ const key = (column.name || column.field || "").trim();
77
+ if (!key) {
78
+ console.warn(
79
+ "[design-runtime][table] 自定义列没有列名(来源字段也空),已跳过:",
80
+ column.title,
81
+ comname
82
+ );
83
+ return null;
84
+ }
85
+ const comp = (_a = host == null ? void 0 : host.resolveCustom) == null ? void 0 : _a.call(host, comname);
86
+ if (!comp) {
87
+ console.warn(
88
+ `[design-runtime][table] 自定义列「${column.title ?? key}」的组件 "${comname}" 没解析到,降级为纯文本`
89
+ );
90
+ }
91
+ base.field = key;
92
+ base.slots = {
93
+ default: ({ row }) => {
94
+ var _a2, _b2;
95
+ return comp ? h(comp, {
96
+ api: (_a2 = host == null ? void 0 : host.getApi) == null ? void 0 : _a2.call(host),
97
+ cell: column,
98
+ comname,
99
+ host: "table-cell",
100
+ params: ((_b2 = host == null ? void 0 : host.getParams) == null ? void 0 : _b2.call(host)) ?? {},
101
+ row,
102
+ value: row == null ? void 0 : row[key]
103
+ }) : (row == null ? void 0 : row[key]) ?? "";
104
+ }
105
+ };
106
+ return base;
107
+ }
108
+ const formater = column.formater;
109
+ const textKey = column.name || `${column.field}__text`;
110
+ if (formater === "action") {
111
+ base.slots = { default: "action" };
112
+ base.width = column.width ? Number.parseInt(column.width, 10) : "auto";
113
+ base.resizable = false;
114
+ return base;
115
+ }
116
+ if (formater == null ? void 0 : formater.startsWith("dict-")) {
117
+ const dictType = formater.split("-").slice(1).join("-");
118
+ base.slots = {
119
+ default: ({ row }) => {
120
+ const value = row[column.field];
121
+ if (host == null ? void 0 : host.renderDict) return host.renderDict(value, dictType);
122
+ if (!warnedMissingRenderDict) {
123
+ warnedMissingRenderDict = true;
124
+ console.warn(
125
+ `[design-runtime][table] 未注入 host.renderDict:字典列(如 "${dictType}")只能显示原值。请在 transformTableConfig 的 host 里传 renderDict(宿主用 #/utils/render 的 renderDict 即可)`
126
+ );
127
+ }
128
+ return value ?? "";
129
+ }
130
+ };
131
+ return base;
132
+ }
133
+ if (formater === "file") {
134
+ base.cellRender = {
135
+ name: "CellImage",
136
+ props: { width: 40, height: 40 }
137
+ };
138
+ return base;
139
+ }
140
+ if (formater) {
141
+ base.slots = { default: formater };
142
+ return base;
143
+ }
144
+ if (editConfig) {
145
+ try {
146
+ if (editConfig.type === "date") {
147
+ return base;
148
+ }
149
+ if (editConfig.type === "file" || editConfig.type === "fj") {
150
+ base.cellRender = {
151
+ name: "CellImage",
152
+ props: { width: 40, height: 40 }
153
+ };
154
+ return base;
155
+ }
156
+ if (editConfig.type === "image") {
157
+ base.cellRender = {
158
+ name: "CellImage",
159
+ props: { width: 40, height: 40 }
160
+ };
161
+ return base;
162
+ }
163
+ if ((_b = editConfig.dicts) == null ? void 0 : _b.length) {
164
+ base.field = column.name || column.field;
165
+ base.slots = {
166
+ default: ({ row }) => {
167
+ const text = row[textKey];
168
+ if (text !== void 0 && text !== null) return text;
169
+ const val = row[column.field];
170
+ const item = editConfig.dicts.find(
171
+ (d) => String(d.dictValue) === String(val)
172
+ );
173
+ return (item == null ? void 0 : item.dictLabel) ?? val ?? "";
174
+ }
175
+ };
176
+ return base;
177
+ }
178
+ if (editConfig.relationSet || editConfig.relationField || editConfig.querySql) {
179
+ base.field = column.name || column.field;
180
+ const sqlOnly = !!editConfig.querySql && !editConfig.relationSet && !editConfig.relationField;
181
+ base.slots = {
182
+ default: ({ row }) => {
183
+ const text = row[textKey];
184
+ if (text !== void 0 && text !== null) return text;
185
+ if (sqlOnly) return "";
186
+ const val = row[column.field];
187
+ return val === void 0 || val === null ? "" : val;
188
+ }
189
+ };
190
+ return base;
191
+ }
192
+ if (editConfig.type === "switch") {
193
+ base.slots = {
194
+ default: ({ row }) => {
195
+ const val = row[column.field];
196
+ return h(
197
+ Tag,
198
+ { color: val === "1" || val === 1 ? "green" : "red" },
199
+ { default: () => val === "1" || val === 1 ? "是" : "否" }
200
+ );
201
+ }
202
+ };
203
+ return base;
204
+ }
205
+ if (editConfig.type === "number") {
206
+ base.align = "right";
207
+ base.slots = {
208
+ default: ({ row }) => {
209
+ const text = row[textKey];
210
+ if (text !== void 0 && text !== null && text !== "") return text;
211
+ const val = row[column.field];
212
+ return val === void 0 || val === null ? "" : val;
213
+ }
214
+ };
215
+ return base;
216
+ }
217
+ } catch {
218
+ }
219
+ }
220
+ return base;
221
+ }
222
+ function formatSummary(value) {
223
+ const num = typeof value === "number" ? value : Number(value);
224
+ if (!Number.isFinite(num)) {
225
+ return String(value ?? "");
226
+ }
227
+ const isInteger = Number.isInteger(num);
228
+ return num.toLocaleString("zh-CN", {
229
+ maximumFractionDigits: isInteger ? 0 : 2,
230
+ minimumFractionDigits: isInteger ? 0 : 2
231
+ });
232
+ }
233
+ function transformTableConfig(config, tableHeight, host) {
234
+ const columns = config.columns ?? [];
235
+ const isPager = config.pager === 1;
236
+ const hasSearchForm = false;
237
+ const vxeColumns = columns.filter((c) => !isColumnHidden(c)).map((c) => transformColumn(c, host)).filter(Boolean);
238
+ const summaryFields = columns.map((c) => {
239
+ const edit = readEdit(c == null ? void 0 : c.edit);
240
+ const func = edit == null ? void 0 : edit.summary;
241
+ return typeof func === "string" && func.trim() ? String((c == null ? void 0 : c.field) ?? "") : "";
242
+ }).filter(Boolean);
243
+ const rowActions = config.rowActions ?? [];
244
+ if (rowActions.length > 0) {
245
+ const hasActionCol = vxeColumns.some(
246
+ (c) => {
247
+ var _a;
248
+ return ((_a = c.slots) == null ? void 0 : _a.default) === "action" || c.type === "action";
249
+ }
250
+ );
251
+ if (!hasActionCol) {
252
+ vxeColumns.push({
253
+ field: "_action",
254
+ title: "操作",
255
+ width: rowActions.length * 80 + 16,
256
+ fixed: "right",
257
+ resizable: false,
258
+ slots: { default: "action" }
259
+ });
260
+ }
261
+ }
262
+ const configParams = parseConfigParams(config.queryParams);
263
+ const gridOptions = {
264
+ columns: vxeColumns,
265
+ // 默认撑满容器并内部滚动(design-table 外层自适应链保证容器有确定高度);
266
+ // 传入数字(px) 时 vxe 走固定布局,正文/滚动条区域按容器分配,不会按内容撑高
267
+ height: tableHeight ?? "100%",
268
+ keepSource: true,
269
+ proxyConfig: {
270
+ ajax: {
271
+ query: async ({ page }, formValues = {}, envParams = {}) => {
272
+ var _a, _b;
273
+ const result = await fetchTableData(config.url, {
274
+ configParams,
275
+ envParams,
276
+ pageNum: page.currentPage,
277
+ pageSize: page.pageSize,
278
+ search: formValues
279
+ });
280
+ const runtimeTitle = result == null ? void 0 : result.runtimeTitle;
281
+ if (typeof runtimeTitle === "string" && runtimeTitle.trim()) {
282
+ (_a = host == null ? void 0 : host.onRuntimeTitle) == null ? void 0 : _a.call(host, runtimeTitle.trim());
283
+ }
284
+ (_b = host == null ? void 0 : host.onSummaries) == null ? void 0 : _b.call(host, (result == null ? void 0 : result.summaries) ?? {});
285
+ return result;
286
+ }
287
+ },
288
+ response: {
289
+ list: "records",
290
+ result: "records",
291
+ total: "total"
292
+ }
293
+ },
294
+ // 合计行(2026-10-22):有列配了合计才开 footer;数值来自响应里的 summaries(后端全量汇总)
295
+ ...summaryFields.length > 0 ? {
296
+ footerMethod: ({ columns: footerColumns }) => {
297
+ var _a;
298
+ const sums = ((_a = host == null ? void 0 : host.getSummaries) == null ? void 0 : _a.call(host)) ?? {};
299
+ const cells = (footerColumns ?? []).map((col) => {
300
+ const value = (col == null ? void 0 : col.field) ? sums[col.field] : void 0;
301
+ if (value === void 0 || value === null || value === "") {
302
+ return "";
303
+ }
304
+ return formatSummary(value);
305
+ });
306
+ const labelIndex = cells.findIndex((cell) => cell === "");
307
+ if (labelIndex >= 0) {
308
+ cells[labelIndex] = "合计";
309
+ }
310
+ return [cells];
311
+ },
312
+ showFooter: true
313
+ } : {},
314
+ pagerConfig: isPager ? {
315
+ pageSize: config.pagesize || 10,
316
+ pageSizes: [10, 20, 30, 50, 100]
317
+ } : { enabled: false },
318
+ rowConfig: {
319
+ isHover: true,
320
+ keyField: config.pfield ?? "id",
321
+ useKey: true
322
+ }
323
+ };
324
+ return { gridOptions, hasSearchForm, isPager };
325
+ }
326
+ export {
327
+ transformTableConfig
328
+ };
@@ -0,0 +1,7 @@
1
+ import _sfc_main from "./design-tree2.vue.js";
2
+ /* empty css */
3
+ import _export_sfc from "../_virtual/_plugin-vue_export-helper.js";
4
+ const DesignTree = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c106575a"]]);
5
+ export {
6
+ DesignTree as default
7
+ };