@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,88 @@
1
+ import { defineComponent, computed, watch, openBlock, createBlock, unref } from "vue";
2
+ import { CheckboxGroup } from "antdv-next";
3
+ const _sfc_main = /* @__PURE__ */ defineComponent({
4
+ __name: "checkbox-field",
5
+ props: {
6
+ cell: {},
7
+ disabled: { type: Boolean },
8
+ modelValue: {}
9
+ },
10
+ emits: ["update:modelValue", "update:derived"],
11
+ setup(__props, { emit: __emit }) {
12
+ const props = __props;
13
+ const emit = __emit;
14
+ function parseOptions() {
15
+ var _a;
16
+ if ((_a = props.cell.dicts) == null ? void 0 : _a.length) {
17
+ return props.cell.dicts.map((d) => ({
18
+ // 合并 select_sql 整行数据,树形/其它字段可直接取用(label/value 优先)
19
+ ...d.data || {},
20
+ label: d.dictLabel,
21
+ value: d.dictValue
22
+ }));
23
+ }
24
+ if (!props.cell.select_options) return [];
25
+ return props.cell.select_options.split("\n").map((line) => {
26
+ const [val, ...labelParts] = line.split("|");
27
+ return {
28
+ label: (labelParts.join("|") || val || "").trim(),
29
+ value: (val || "").trim()
30
+ };
31
+ }).filter((opt) => opt.value);
32
+ }
33
+ const options = computed(() => parseOptions());
34
+ const value = computed({
35
+ get: () => {
36
+ const v = props.modelValue;
37
+ if (!v) return [];
38
+ if (Array.isArray(v)) return v;
39
+ try {
40
+ const parsed = JSON.parse(v);
41
+ return Array.isArray(parsed) ? parsed : [];
42
+ } catch {
43
+ return [];
44
+ }
45
+ },
46
+ set: (val) => emit("update:modelValue", val)
47
+ });
48
+ function emitDerived() {
49
+ var _a, _b;
50
+ const deriveTo = props.cell.deriveTo;
51
+ if (!(deriveTo == null ? void 0 : deriveTo.length)) return;
52
+ const vals = value.value;
53
+ const items = (props.cell.dicts || []).filter(
54
+ (d) => vals.some((x) => String(x) === String(d.dictValue))
55
+ );
56
+ const derived = {};
57
+ let has = false;
58
+ for (const dt of deriveTo) {
59
+ let v;
60
+ if (vals.length === 0) {
61
+ v = null;
62
+ } else if (dt.source === "value") {
63
+ v = vals.join(",");
64
+ } else if (dt.source === "label") {
65
+ v = items.map((i) => i.dictLabel).join(",");
66
+ } else {
67
+ v = (_b = (_a = items[0]) == null ? void 0 : _a.data) == null ? void 0 : _b[dt.source];
68
+ }
69
+ if (v === void 0) continue;
70
+ derived[dt.field] = v;
71
+ has = true;
72
+ }
73
+ if (has) emit("update:derived", derived);
74
+ }
75
+ watch(() => value.value, emitDerived, { immediate: true });
76
+ return (_ctx, _cache) => {
77
+ return openBlock(), createBlock(unref(CheckboxGroup), {
78
+ value: value.value,
79
+ "onUpdate:value": _cache[0] || (_cache[0] = ($event) => value.value = $event),
80
+ options: options.value,
81
+ disabled: props.disabled
82
+ }, null, 8, ["value", "options", "disabled"]);
83
+ };
84
+ }
85
+ });
86
+ export {
87
+ _sfc_main as default
88
+ };
@@ -0,0 +1,4 @@
1
+ import _sfc_main from "./checkbox-field.vue.js";
2
+ export {
3
+ _sfc_main as default
4
+ };
@@ -0,0 +1,36 @@
1
+ import { defineComponent, computed, openBlock, createBlock, unref } from "vue";
2
+ import { Input } from "antdv-next";
3
+ const _sfc_main = /* @__PURE__ */ defineComponent({
4
+ __name: "custom-field",
5
+ props: {
6
+ cell: { default: () => ({}) },
7
+ disabled: { type: Boolean },
8
+ modelValue: {}
9
+ },
10
+ emits: ["update:modelValue"],
11
+ setup(__props, { emit: __emit }) {
12
+ const props = __props;
13
+ const emit = __emit;
14
+ const value = computed({
15
+ get: () => props.modelValue,
16
+ set: (val) => emit("update:modelValue", val)
17
+ });
18
+ const placeholder = computed(() => {
19
+ const cell = props.cell ?? {};
20
+ const comname = cell.comname ? `(组件名 ${cell.comname})` : "";
21
+ return `未知字段类型${comname}: ${cell.type || "unknown"}`;
22
+ });
23
+ return (_ctx, _cache) => {
24
+ return openBlock(), createBlock(unref(Input), {
25
+ value: value.value,
26
+ "onUpdate:value": _cache[0] || (_cache[0] = ($event) => value.value = $event),
27
+ disabled: true,
28
+ placeholder: placeholder.value,
29
+ style: { "width": "100%", "color": "#999" }
30
+ }, null, 8, ["value", "placeholder"]);
31
+ };
32
+ }
33
+ });
34
+ export {
35
+ _sfc_main as default
36
+ };
@@ -0,0 +1,4 @@
1
+ import _sfc_main from "./custom-field.vue.js";
2
+ export {
3
+ _sfc_main as default
4
+ };
@@ -0,0 +1,64 @@
1
+ import { defineComponent, computed, watch, openBlock, createBlock, unref } from "vue";
2
+ import dayjs from "dayjs";
3
+ import { DateMonthPicker, DatePicker } from "antdv-next";
4
+ const _sfc_main = /* @__PURE__ */ defineComponent({
5
+ __name: "date-field",
6
+ props: {
7
+ cell: {},
8
+ disabled: { type: Boolean },
9
+ modelValue: {}
10
+ },
11
+ emits: ["update:modelValue"],
12
+ setup(__props, { emit: __emit }) {
13
+ const props = __props;
14
+ const emit = __emit;
15
+ const dateFormat = computed(() => props.cell.dateType || "YYYY-MM-DD");
16
+ watch(
17
+ () => props.modelValue,
18
+ (val) => {
19
+ if (typeof val === "string" && val.includes("T") && dayjs(val).isValid()) {
20
+ const normalized = dayjs(val).format(dateFormat.value);
21
+ if (normalized !== val) {
22
+ emit("update:modelValue", normalized);
23
+ }
24
+ }
25
+ },
26
+ { immediate: true }
27
+ );
28
+ const value = computed({
29
+ get: () => props.modelValue,
30
+ set: (val) => emit("update:modelValue", val)
31
+ });
32
+ const isDisabled = computed(
33
+ () => props.disabled || props.cell.readonly === "2"
34
+ );
35
+ const isMonth = computed(() => {
36
+ const dt = props.cell.dateType;
37
+ return dt && !dt.toLowerCase().includes("dd");
38
+ });
39
+ return (_ctx, _cache) => {
40
+ return isMonth.value ? (openBlock(), createBlock(unref(DateMonthPicker), {
41
+ key: 0,
42
+ value: value.value,
43
+ "onUpdate:value": _cache[0] || (_cache[0] = ($event) => value.value = $event),
44
+ disabled: isDisabled.value,
45
+ "value-format": __props.cell.dateType,
46
+ format: __props.cell.dateType,
47
+ placeholder: "请选择月份",
48
+ style: { "width": "100%" }
49
+ }, null, 8, ["value", "disabled", "value-format", "format"])) : (openBlock(), createBlock(unref(DatePicker), {
50
+ key: 1,
51
+ value: value.value,
52
+ "onUpdate:value": _cache[1] || (_cache[1] = ($event) => value.value = $event),
53
+ disabled: isDisabled.value,
54
+ "value-format": dateFormat.value,
55
+ format: dateFormat.value,
56
+ placeholder: "请选择日期",
57
+ style: { "width": "100%" }
58
+ }, null, 8, ["value", "disabled", "value-format", "format"]));
59
+ };
60
+ }
61
+ });
62
+ export {
63
+ _sfc_main as default
64
+ };
@@ -0,0 +1,4 @@
1
+ import _sfc_main from "./date-field.vue.js";
2
+ export {
3
+ _sfc_main as default
4
+ };
@@ -0,0 +1,7 @@
1
+ import _sfc_main from "./embedded-list-field2.vue.js";
2
+ /* empty css */
3
+ import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
4
+ const EmbeddedListField = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-0524a510"]]);
5
+ export {
6
+ EmbeddedListField as default
7
+ };
@@ -0,0 +1,437 @@
1
+ import { defineComponent, useCssVars, computed, ref, watch, openBlock, createElementBlock, createElementVNode, toDisplayString, createBlock, unref, withCtx, Fragment, renderList, resolveDynamicComponent, createTextVNode, createCommentVNode, createVNode, createSlots, nextTick } from "vue";
2
+ import { MoreOutlined, ExportOutlined, InboxOutlined, DownloadOutlined, PlusOutlined } from "@antdv-next/icons";
3
+ import { Space, Button, Spin, Alert } from "antdv-next";
4
+ import { fetchTableConfig } from "../../api.js";
5
+ import { requireVxeGrid, requireHttp } from "../../host.js";
6
+ import { platformMessage } from "../../components/design-shared/host-api.js";
7
+ import { resolveRowActionComponent } from "../../components/design-table/row-actions/index.js";
8
+ import { resolveToolComponent } from "../../components/design-tools/index.js";
9
+ import { evaluateMappedExpress } from "../../mapping.js";
10
+ import { transformTableConfig } from "../../table/transformer.js";
11
+ const _hoisted_1 = { class: "embed-list" };
12
+ const _hoisted_2 = { class: "embed-list__head" };
13
+ const _hoisted_3 = ["title"];
14
+ const _hoisted_4 = {
15
+ key: 1,
16
+ class: "embed-list__tip"
17
+ };
18
+ const _hoisted_5 = {
19
+ key: 0,
20
+ class: "embed-list__loading"
21
+ };
22
+ const _hoisted_6 = {
23
+ key: 1,
24
+ class: "embed-list__error"
25
+ };
26
+ const _hoisted_7 = {
27
+ key: 2,
28
+ class: "embed-list__error"
29
+ };
30
+ const _hoisted_8 = {
31
+ key: 3,
32
+ class: "embed-list__body"
33
+ };
34
+ const _hoisted_9 = {
35
+ key: 4,
36
+ class: "embed-list__error"
37
+ };
38
+ const _sfc_main = /* @__PURE__ */ defineComponent({
39
+ ...{ name: "EmbeddedListField" },
40
+ __name: "embedded-list-field",
41
+ props: {
42
+ cell: {},
43
+ master: { default: () => ({}) },
44
+ pfield: { default: "id" },
45
+ extraParams: { default: () => ({}) },
46
+ category: { default: "" }
47
+ },
48
+ emits: ["row-command", "tool-command"],
49
+ setup(__props, { emit: __emit }) {
50
+ useCssVars((_ctx) => ({
51
+ "v09d39f07": `${listHeight.value}px`
52
+ }));
53
+ const props = __props;
54
+ const emit = __emit;
55
+ const embeddedList = computed(() => {
56
+ var _a;
57
+ return ((_a = props.cell) == null ? void 0 : _a.embeddedList) ?? {};
58
+ });
59
+ const listModule = computed(() => embeddedList.value.module || props.category || "");
60
+ const listName = computed(() => embeddedList.value.name || "");
61
+ const listIdentity = computed(() => `${listModule.value}/${listName.value}`);
62
+ const headerTitle = computed(() => {
63
+ var _a;
64
+ return ((_a = props.cell) == null ? void 0 : _a.title) || embeddedList.value.title || listName.value || "内嵌列表";
65
+ });
66
+ const listHeight = computed(() => {
67
+ var _a;
68
+ const h = Number((_a = props.cell) == null ? void 0 : _a.embeddedHeight);
69
+ return Number.isFinite(h) && h > 0 ? h : 300;
70
+ });
71
+ const masterId = computed(() => {
72
+ var _a;
73
+ return (_a = props.master) == null ? void 0 : _a[props.pfield];
74
+ });
75
+ const active = computed(() => {
76
+ const id = masterId.value;
77
+ return id !== void 0 && id !== null && id !== "";
78
+ });
79
+ const relationParams = computed(() => {
80
+ var _a;
81
+ const result = {};
82
+ const mappings = ((_a = props.cell) == null ? void 0 : _a.mappings) ?? [];
83
+ if (!Array.isArray(mappings)) return result;
84
+ const scope = { data: props.master ?? {}, params: props.extraParams ?? {} };
85
+ for (const m of mappings) {
86
+ if (!(m == null ? void 0 : m.paramName)) continue;
87
+ const val = evaluateMappedExpress(m.express, scope);
88
+ if (val === void 0 || val === null || val === "") continue;
89
+ result[m.paramName] = val;
90
+ }
91
+ return result;
92
+ });
93
+ const relationParamsJson = computed(() => JSON.stringify(relationParams.value));
94
+ const paramsRef = ref({});
95
+ watch(
96
+ () => relationParams.value,
97
+ (val) => {
98
+ paramsRef.value = val ?? {};
99
+ },
100
+ { immediate: true }
101
+ );
102
+ const listConfig = ref(null);
103
+ const listLoading = ref(false);
104
+ const listError = ref(null);
105
+ const loadedIdentity = ref("");
106
+ function listReady() {
107
+ return loadedIdentity.value === listIdentity.value && !!listConfig.value;
108
+ }
109
+ async function ensureConfig() {
110
+ const moduleName = listModule.value;
111
+ const name = listName.value;
112
+ if (!moduleName || !name) {
113
+ loadedIdentity.value = "";
114
+ listConfig.value = null;
115
+ listError.value = null;
116
+ return;
117
+ }
118
+ if (listReady()) return;
119
+ listLoading.value = true;
120
+ listError.value = null;
121
+ loadedIdentity.value = "";
122
+ listConfig.value = null;
123
+ try {
124
+ const resp = await fetchTableConfig(moduleName, name);
125
+ listConfig.value = resp;
126
+ loadedIdentity.value = `${moduleName}/${name}`;
127
+ } catch (err) {
128
+ const msg = (err == null ? void 0 : err.message) ?? "";
129
+ if (msg.includes("未发现")) {
130
+ listConfig.value = null;
131
+ } else {
132
+ listError.value = msg || "加载列表配置失败";
133
+ listConfig.value = null;
134
+ }
135
+ } finally {
136
+ listLoading.value = false;
137
+ }
138
+ }
139
+ watch(
140
+ () => [listModule.value, listName.value],
141
+ () => {
142
+ void ensureConfig();
143
+ },
144
+ { immediate: true }
145
+ );
146
+ let pendingRefresh = null;
147
+ function gridInProxyMode() {
148
+ var _a, _b;
149
+ return !!((_b = (_a = gridApi == null ? void 0 : gridApi.grid) == null ? void 0 : _a.proxyConfig) == null ? void 0 : _b.ajax);
150
+ }
151
+ function flushPendingRefresh() {
152
+ const mode = pendingRefresh;
153
+ pendingRefresh = null;
154
+ if (mode === "remount") {
155
+ gridKey.value += 1;
156
+ } else if (mode === "query") {
157
+ gridReadyReload();
158
+ }
159
+ }
160
+ function scheduleGridRemount() {
161
+ if (pendingRefresh) {
162
+ pendingRefresh = "remount";
163
+ return;
164
+ }
165
+ pendingRefresh = "remount";
166
+ nextTick(flushPendingRefresh);
167
+ }
168
+ function requestListRefresh() {
169
+ if (!active.value || !listReady()) return;
170
+ if (pendingRefresh) {
171
+ if (pendingRefresh === "remount" || !gridInProxyMode()) {
172
+ pendingRefresh = "remount";
173
+ }
174
+ return;
175
+ }
176
+ pendingRefresh = gridInProxyMode() ? "query" : "remount";
177
+ nextTick(flushPendingRefresh);
178
+ }
179
+ function gridReadyReload() {
180
+ var _a;
181
+ const api = gridApi;
182
+ if ((_a = api == null ? void 0 : api.grid) == null ? void 0 : _a.commitProxy) {
183
+ void api.query();
184
+ }
185
+ }
186
+ watch(
187
+ () => active.value,
188
+ (val, oldVal) => {
189
+ if (val === oldVal || !listReady()) return;
190
+ if (val) {
191
+ requestListRefresh();
192
+ } else {
193
+ pendingRefresh = null;
194
+ scheduleGridRemount();
195
+ }
196
+ }
197
+ );
198
+ watch(
199
+ () => relationParamsJson.value,
200
+ () => {
201
+ requestListRefresh();
202
+ }
203
+ );
204
+ const gridOptions = computed(() => {
205
+ var _a, _b, _c;
206
+ const cfg = listConfig.value;
207
+ if (!cfg) return {};
208
+ const result = transformTableConfig(cfg, listHeight.value);
209
+ const g = result.gridOptions;
210
+ if (active.value) {
211
+ const originalQuery = (_b = (_a = g.proxyConfig) == null ? void 0 : _a.ajax) == null ? void 0 : _b.query;
212
+ if (originalQuery) {
213
+ g.proxyConfig = {
214
+ ...g.proxyConfig,
215
+ ajax: {
216
+ ...(_c = g.proxyConfig) == null ? void 0 : _c.ajax,
217
+ query: async (page, formValues = {}) => {
218
+ const mapped = paramsRef.value || {};
219
+ return originalQuery(page, { ...formValues, ...mapped }, mapped);
220
+ }
221
+ }
222
+ };
223
+ }
224
+ } else {
225
+ g.data = [];
226
+ g.proxyConfig = void 0;
227
+ }
228
+ g.pagerConfig = {
229
+ enabled: false,
230
+ pageSize: Math.max(Number(cfg.pagesize) || 10, 200)
231
+ };
232
+ g.toolbarConfig = { custom: false, zoom: false, refresh: false };
233
+ return g;
234
+ });
235
+ const [Grid, gridApi] = requireVxeGrid()({ gridOptions: {} });
236
+ const gridKey = ref(0);
237
+ watch(
238
+ () => listConfig.value,
239
+ (val, oldVal) => {
240
+ if (val === oldVal) return;
241
+ pendingRefresh = null;
242
+ gridKey.value += 1;
243
+ }
244
+ );
245
+ const parsedTools = computed(() => {
246
+ var _a;
247
+ return ((_a = listConfig.value) == null ? void 0 : _a.toolBars) ?? [];
248
+ });
249
+ const toolLabelMap = {
250
+ add: "新增",
251
+ export: "导出",
252
+ import: "导入",
253
+ "modal-combo": "弹窗组合视图",
254
+ "modal-form": "弹窗表单",
255
+ "modal-table": "弹窗列表",
256
+ "modal-tree": "弹窗树形视图",
257
+ "navigate-combo": "跳转组合视图",
258
+ "navigate-form": "跳转表单",
259
+ "navigate-table": "跳转表格",
260
+ other: "其他"
261
+ };
262
+ function getToolLabel(tool) {
263
+ return tool.title || tool.label || toolLabelMap[tool.type ?? ""] || tool.type || "";
264
+ }
265
+ const toolIconMap = {
266
+ add: PlusOutlined,
267
+ export: DownloadOutlined,
268
+ import: InboxOutlined,
269
+ "navigate-form": ExportOutlined,
270
+ "navigate-table": ExportOutlined,
271
+ "navigate-combo": ExportOutlined,
272
+ other: MoreOutlined
273
+ };
274
+ function toolIcon(tool) {
275
+ return toolIconMap[tool.type ?? ""] || PlusOutlined;
276
+ }
277
+ const toolRefs = ref({});
278
+ function setToolRef(idx) {
279
+ return (el) => {
280
+ toolRefs.value[idx] = el;
281
+ };
282
+ }
283
+ function handleToolClick(_tool, idx) {
284
+ var _a;
285
+ const inst = toolRefs.value[idx];
286
+ (_a = inst == null ? void 0 : inst.trigger) == null ? void 0 : _a.call(inst);
287
+ }
288
+ function handleToolSaved() {
289
+ gridReadyReload();
290
+ }
291
+ function handleToolImported() {
292
+ gridReadyReload();
293
+ }
294
+ function handleToolCommand(tool) {
295
+ emit("tool-command", tool);
296
+ }
297
+ const parsedActions = computed(() => {
298
+ var _a;
299
+ return ((_a = listConfig.value) == null ? void 0 : _a.rowActions) ?? [];
300
+ });
301
+ const listPfield = computed(() => {
302
+ var _a;
303
+ return ((_a = listConfig.value) == null ? void 0 : _a.pfield) || "id";
304
+ });
305
+ const hasAutoActions = computed(() => {
306
+ var _a;
307
+ const columns = (_a = gridOptions.value) == null ? void 0 : _a.columns;
308
+ return Array.isArray(columns) ? columns.some((c) => {
309
+ var _a2;
310
+ return ((_a2 = c.slots) == null ? void 0 : _a2.default) === "action";
311
+ }) : false;
312
+ });
313
+ function handleRowSaved() {
314
+ gridReadyReload();
315
+ }
316
+ function handleRowDeleted(row) {
317
+ var _a;
318
+ const url = (_a = listConfig.value) == null ? void 0 : _a.deleteUrl;
319
+ if (!url) {
320
+ platformMessage().error("列表未配置「删除地址」");
321
+ return;
322
+ }
323
+ requireHttp().post(url, { id: row[listPfield.value] }).then(() => gridReadyReload()).catch((err) => {
324
+ console.error("[embedded-list] 删除失败:", (err == null ? void 0 : err.message) ?? err);
325
+ });
326
+ }
327
+ function handleRowCommand(action, row) {
328
+ emit("row-command", action, row);
329
+ }
330
+ const tipText = computed(() => {
331
+ if (!active.value) {
332
+ return listName.value ? "" : "请先在表单设计中选择内嵌列表";
333
+ }
334
+ if (!listName.value) return "未配置内嵌列表";
335
+ if (listError.value) return listError.value;
336
+ return "";
337
+ });
338
+ return (_ctx, _cache) => {
339
+ return openBlock(), createElementBlock("div", _hoisted_1, [
340
+ createElementVNode("div", _hoisted_2, [
341
+ createElementVNode("span", {
342
+ class: "embed-list__title",
343
+ title: headerTitle.value
344
+ }, toDisplayString(headerTitle.value), 9, _hoisted_3),
345
+ active.value && parsedTools.value.length > 0 && !listError.value ? (openBlock(), createBlock(unref(Space), {
346
+ key: 0,
347
+ class: "embed-list__tools",
348
+ size: "small"
349
+ }, {
350
+ default: withCtx(() => [
351
+ (openBlock(true), createElementBlock(Fragment, null, renderList(parsedTools.value, (tool, idx) => {
352
+ return openBlock(), createBlock(unref(Button), {
353
+ key: "tool" + idx,
354
+ shape: "round",
355
+ onClick: ($event) => handleToolClick(tool, idx)
356
+ }, {
357
+ default: withCtx(() => [
358
+ (openBlock(), createBlock(resolveDynamicComponent(toolIcon(tool)))),
359
+ createTextVNode(" " + toDisplayString(getToolLabel(tool)), 1)
360
+ ]),
361
+ _: 2
362
+ }, 1032, ["onClick"]);
363
+ }), 128))
364
+ ]),
365
+ _: 1
366
+ })) : createCommentVNode("", true),
367
+ tipText.value && !active.value ? (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(tipText.value), 1)) : createCommentVNode("", true)
368
+ ]),
369
+ listLoading.value ? (openBlock(), createElementBlock("div", _hoisted_5, [
370
+ createVNode(unref(Spin), { size: "small" })
371
+ ])) : listError.value ? (openBlock(), createElementBlock("div", _hoisted_6, [
372
+ createVNode(unref(Alert), {
373
+ message: listError.value,
374
+ type: "error",
375
+ "show-icon": ""
376
+ }, null, 8, ["message"])
377
+ ])) : !listName.value ? (openBlock(), createElementBlock("div", _hoisted_7, [
378
+ createVNode(unref(Alert), {
379
+ message: "未配置内嵌列表:请到表单设计中选择本模块的一个列表",
380
+ type: "warning",
381
+ "show-icon": ""
382
+ })
383
+ ])) : listConfig.value ? (openBlock(), createElementBlock("div", _hoisted_8, [
384
+ (openBlock(), createBlock(unref(Grid), {
385
+ key: gridKey.value,
386
+ "grid-options": gridOptions.value,
387
+ separator: false,
388
+ class: "embed-list__grid"
389
+ }, createSlots({ _: 2 }, [
390
+ hasAutoActions.value ? {
391
+ name: "action",
392
+ fn: withCtx(({ row }) => [
393
+ (openBlock(true), createElementBlock(Fragment, null, renderList(parsedActions.value, (action) => {
394
+ return openBlock(), createBlock(resolveDynamicComponent(unref(resolveRowActionComponent)(action.type)), {
395
+ key: action.type,
396
+ action,
397
+ row,
398
+ category: __props.category,
399
+ pfield: __props.pfield,
400
+ "grid-api": unref(gridApi),
401
+ onDeleted: handleRowDeleted,
402
+ onSaved: handleRowSaved,
403
+ onCommand: handleRowCommand
404
+ }, null, 40, ["action", "row", "category", "pfield", "grid-api"]);
405
+ }), 128))
406
+ ]),
407
+ key: "0"
408
+ } : void 0
409
+ ]), 1032, ["grid-options"]))
410
+ ])) : (openBlock(), createElementBlock("div", _hoisted_9, [
411
+ createVNode(unref(Alert), {
412
+ message: "所选列表配置不存在或尚未发布,请到构建端确认列表名称",
413
+ type: "warning",
414
+ "show-icon": ""
415
+ })
416
+ ])),
417
+ active.value && listConfig.value && !listLoading.value ? (openBlock(true), createElementBlock(Fragment, { key: 5 }, renderList(parsedTools.value, (tool, idx) => {
418
+ return openBlock(), createBlock(resolveDynamicComponent(unref(resolveToolComponent)(tool.type)), {
419
+ key: "drawer-" + idx,
420
+ ref_for: true,
421
+ ref: setToolRef(idx),
422
+ tool,
423
+ category: __props.category,
424
+ pfield: __props.pfield,
425
+ "grid-api": unref(gridApi),
426
+ onSaved: handleToolSaved,
427
+ onImported: handleToolImported,
428
+ onCommand: handleToolCommand
429
+ }, null, 40, ["tool", "category", "pfield", "grid-api"]);
430
+ }), 128)) : createCommentVNode("", true)
431
+ ]);
432
+ };
433
+ }
434
+ });
435
+ export {
436
+ _sfc_main as default
437
+ };