@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,449 @@
1
+ import { defineComponent, reactive, watch, computed, provide, openBlock, createElementBlock, createElementVNode, Fragment, renderList, normalizeStyle, normalizeClass, withDirectives, createBlock, resolveDynamicComponent, unref, createTextVNode, toDisplayString, withCtx, createCommentVNode, vShow } from "vue";
2
+ import { Tooltip } from "antdv-next";
3
+ import { resolveDefaultValue } from "../utils/default-value.js";
4
+ import { buildHostApi } from "../components/design-shared/host-api.js";
5
+ import { resolveCellComponent } from "./fields/index.js";
6
+ import EmbeddedListField from "./fields/embedded-list-field.vue.js";
7
+ import { buildConditionScope, evalCellCondition, computeConditionDebug, isConditionHidden } from "./cell-condition.js";
8
+ import { computeDerivedFills } from "./derived-express.js";
9
+ const _hoisted_1 = { class: "design-form-table-wrapper" };
10
+ const _hoisted_2 = {
11
+ key: 0,
12
+ class: "form-table"
13
+ };
14
+ const _hoisted_3 = ["rowspan", "colspan", "title"];
15
+ const _hoisted_4 = {
16
+ key: 0,
17
+ class: "cell-cond-body"
18
+ };
19
+ const _hoisted_5 = {
20
+ key: 2,
21
+ class: "cell-text"
22
+ };
23
+ const _hoisted_6 = {
24
+ key: 3,
25
+ class: "field-cell"
26
+ };
27
+ const _hoisted_7 = {
28
+ key: 1,
29
+ class: "form-table-empty"
30
+ };
31
+ const _sfc_main = /* @__PURE__ */ defineComponent({
32
+ ...{ name: "DesignFormInner" },
33
+ __name: "design-form-inner",
34
+ props: {
35
+ gridConfig: { default: void 0 },
36
+ labelWidth: { default: 150 },
37
+ source: { default: void 0 },
38
+ pfield: { default: "id" },
39
+ extraParams: { default: () => ({}) },
40
+ category: { default: "" }
41
+ },
42
+ emits: ["data-change", "derived-change", "condition-change"],
43
+ setup(__props, { expose: __expose, emit: __emit }) {
44
+ const props = __props;
45
+ const fieldHostApi = buildHostApi();
46
+ const emit = __emit;
47
+ const formData = reactive({});
48
+ const derivedValues = reactive({});
49
+ function initFormData() {
50
+ var _a, _b;
51
+ const cells = ((_a = props.gridConfig) == null ? void 0 : _a.cells) ?? [];
52
+ for (const cell of cells) {
53
+ if (!cell.name) continue;
54
+ if (!(cell.name in formData)) {
55
+ const dv = resolveDefaultValue(cell);
56
+ formData[cell.name] = dv === void 0 ? void 0 : dv;
57
+ }
58
+ }
59
+ const derived = ((_b = props.gridConfig) == null ? void 0 : _b.derivedFieldList) ?? [];
60
+ for (const d of derived) {
61
+ if (d.name && !(d.name in derivedValues)) {
62
+ derivedValues[d.name] = void 0;
63
+ }
64
+ }
65
+ }
66
+ initFormData();
67
+ const cellByName = /* @__PURE__ */ new Map();
68
+ function buildCellMap() {
69
+ var _a;
70
+ cellByName.clear();
71
+ for (const cell of ((_a = props.gridConfig) == null ? void 0 : _a.cells) ?? []) {
72
+ if (cell.name) cellByName.set(cell.name, cell);
73
+ }
74
+ }
75
+ watch(() => props.gridConfig, () => buildCellMap(), { immediate: true });
76
+ const NON_OPTION_TYPES = /* @__PURE__ */ new Set([
77
+ "text",
78
+ "date",
79
+ "time",
80
+ "switch",
81
+ "file",
82
+ "image",
83
+ "fj",
84
+ "json",
85
+ "color",
86
+ "area",
87
+ "my"
88
+ ]);
89
+ function setFieldValue(name, val) {
90
+ var _a;
91
+ formData[name] = val;
92
+ const cell = cellByName.get(name);
93
+ if (((_a = cell == null ? void 0 : cell.deriveTo) == null ? void 0 : _a.length) && NON_OPTION_TYPES.has(cell.type ?? "")) {
94
+ const derived = {};
95
+ for (const dt of cell.deriveTo) {
96
+ derived[dt.field] = val;
97
+ }
98
+ applyDerived(derived);
99
+ }
100
+ }
101
+ function applyDerived(values) {
102
+ Object.assign(derivedValues, values);
103
+ }
104
+ let applyingDerivedExpr = false;
105
+ function applyDerivedExpressions() {
106
+ var _a;
107
+ if (applyingDerivedExpr) return;
108
+ applyingDerivedExpr = true;
109
+ try {
110
+ for (const fill of computeDerivedFills((_a = props.gridConfig) == null ? void 0 : _a.cells, formData, derivedValues)) {
111
+ setFieldValue(fill.name, fill.value);
112
+ }
113
+ } finally {
114
+ applyingDerivedExpr = false;
115
+ }
116
+ }
117
+ watch(derivedValues, () => applyDerivedExpressions(), { deep: true });
118
+ const conditionScope = computed(
119
+ () => buildConditionScope(derivedValues)
120
+ );
121
+ const conditionMap = computed(() => {
122
+ var _a, _b, _c;
123
+ const map = /* @__PURE__ */ new Map();
124
+ for (const cell of ((_a = props.gridConfig) == null ? void 0 : _a.cells) ?? []) {
125
+ if (!((_b = cell == null ? void 0 : cell.vif) == null ? void 0 : _b.trim()) && !((_c = cell == null ? void 0 : cell.vshow) == null ? void 0 : _c.trim())) continue;
126
+ map.set(`${cell.row}-${cell.col}`, evalCellCondition(cell, conditionScope.value));
127
+ }
128
+ return map;
129
+ });
130
+ const CONDITION_PASS = { render: true, show: true };
131
+ function cellCondition(cell) {
132
+ return conditionMap.value.get(`${cell.row}-${cell.col}`) ?? CONDITION_PASS;
133
+ }
134
+ function isCellHidden(cell) {
135
+ return isConditionHidden(cellCondition(cell));
136
+ }
137
+ function cellHiddenTip(cell) {
138
+ const result = cellCondition(cell);
139
+ const parts = [];
140
+ if (!result.render && cell.vif) parts.push(`渲染条件不满足:${cell.vif}`);
141
+ if (!result.show && cell.vshow) parts.push(`显示条件不满足:${cell.vshow}`);
142
+ if (result.error) parts.push(`表达式求值异常(已按不隐藏处理):${result.error}`);
143
+ return `${parts.length > 0 ? parts.join(";") : "条件不满足"}(本格隐藏,占位保留)`;
144
+ }
145
+ const conditionDebugItems = computed(
146
+ () => {
147
+ var _a;
148
+ return computeConditionDebug((_a = props.gridConfig) == null ? void 0 : _a.cells, conditionScope.value);
149
+ }
150
+ );
151
+ watch(
152
+ conditionDebugItems,
153
+ (items) => {
154
+ emit("condition-change", { scope: { ...conditionScope.value }, items });
155
+ },
156
+ { immediate: true }
157
+ );
158
+ const PICK_LOCK_TYPES = /* @__PURE__ */ new Set([
159
+ "select",
160
+ "radio",
161
+ "checkbox",
162
+ "switch",
163
+ "date",
164
+ "time",
165
+ "tree",
166
+ "org-select",
167
+ "orgs-select"
168
+ ]);
169
+ function hasValue(val) {
170
+ return val !== void 0 && val !== null && val !== "";
171
+ }
172
+ const editing = computed(() => {
173
+ const src = props.source;
174
+ if (!src) return false;
175
+ const pk = props.pfield || "id";
176
+ return hasValue(src[pk]);
177
+ });
178
+ function isCellDisabled(cell) {
179
+ if (cell.readonly === "2") return true;
180
+ if (cell.readonly !== "1") return false;
181
+ const name = cell.name;
182
+ if (!name) return false;
183
+ const val = formData[name] ?? derivedValues[name];
184
+ if (PICK_LOCK_TYPES.has(cell.type ?? "")) {
185
+ return hasValue(val);
186
+ }
187
+ return editing.value;
188
+ }
189
+ watch(
190
+ derivedValues,
191
+ (dv) => {
192
+ emit("derived-change", { ...dv });
193
+ },
194
+ { deep: true }
195
+ );
196
+ provide("derivedValues", derivedValues);
197
+ provide("formData", formData);
198
+ const masterSnapshot = computed(() => ({ ...derivedValues, ...formData }));
199
+ watch(
200
+ () => props.source,
201
+ (newVal) => {
202
+ if (newVal) {
203
+ for (const key of Object.keys(newVal)) {
204
+ setFieldValue(key, newVal[key]);
205
+ }
206
+ }
207
+ },
208
+ { immediate: true }
209
+ );
210
+ watch(
211
+ () => ({ ...formData }),
212
+ (values) => {
213
+ emit("data-change", { ...values });
214
+ },
215
+ { deep: true }
216
+ );
217
+ function getSubmitValues() {
218
+ var _a;
219
+ const derived = ((_a = props.gridConfig) == null ? void 0 : _a.derivedFieldList) ?? [];
220
+ const persist = {};
221
+ for (const d of derived) {
222
+ if (d.name && d.persist !== false) {
223
+ persist[d.name] = derivedValues[d.name];
224
+ }
225
+ }
226
+ return { ...formData, ...persist };
227
+ }
228
+ const formApi = {
229
+ getValues: getSubmitValues,
230
+ setValues: (values) => {
231
+ for (const key of Object.keys(values)) {
232
+ setFieldValue(key, values[key]);
233
+ }
234
+ },
235
+ resetForm: () => {
236
+ var _a, _b;
237
+ const cells = ((_a = props.gridConfig) == null ? void 0 : _a.cells) ?? [];
238
+ for (const cell of cells) {
239
+ if (cell.name) formData[cell.name] = void 0;
240
+ }
241
+ const derived = ((_b = props.gridConfig) == null ? void 0 : _b.derivedFieldList) ?? [];
242
+ for (const d of derived) {
243
+ if (d.name) derivedValues[d.name] = void 0;
244
+ }
245
+ },
246
+ form: { values: formData },
247
+ /** 派生字段值空间(开发模式调试用) */
248
+ derivedValues
249
+ };
250
+ __expose({ formApi, isCellHidden });
251
+ function buildTable() {
252
+ var _a, _b, _c, _d;
253
+ const config = props.gridConfig;
254
+ if (!config || config.cells.length === 0) {
255
+ return { colWidths: [], rowHeights: [], rows: [] };
256
+ }
257
+ const { cells, totalRow, totalCol, colWidths, rowHeights: rh } = config;
258
+ const cellMap = /* @__PURE__ */ new Map();
259
+ for (const c of cells) {
260
+ let colSpan = c.mergeColCount || ((_a = c.style) == null ? void 0 : _a.mergeColCount) || 1;
261
+ const rowSpan = c.mergeRowCount || ((_b = c.style) == null ? void 0 : _b.mergeRowCount) || 1;
262
+ if (c.type === "splitline" && !c.mergeColCount && !((_c = c.style) == null ? void 0 : _c.mergeColCount)) {
263
+ colSpan = totalCol;
264
+ }
265
+ if (c.type === "embedded-list" && !c.mergeColCount && !((_d = c.style) == null ? void 0 : _d.mergeColCount)) {
266
+ colSpan = Math.max(1, totalCol - (c.col || 0));
267
+ }
268
+ cellMap.set(`${c.row}-${c.col}`, { ...c, colSpan, rowSpan });
269
+ }
270
+ const occupied = /* @__PURE__ */ new Set();
271
+ const rows = [];
272
+ for (let r = 0; r < totalRow; r++) {
273
+ const row = [];
274
+ for (let col = 0; col < totalCol; col++) {
275
+ if (occupied.has(`${r}-${col}`)) continue;
276
+ const cell = cellMap.get(`${r}-${col}`);
277
+ if (cell) {
278
+ for (let dr = 0; dr < cell.rowSpan; dr++) {
279
+ for (let dc = 0; dc < cell.colSpan; dc++) {
280
+ if (dr === 0 && dc === 0) continue;
281
+ occupied.add(`${r + dr}-${col + dc}`);
282
+ }
283
+ }
284
+ row.push(cell);
285
+ } else {
286
+ row.push({
287
+ row: r,
288
+ col,
289
+ title: "",
290
+ colSpan: 1,
291
+ rowSpan: 1
292
+ });
293
+ }
294
+ }
295
+ if (row.length > 0) rows.push(row);
296
+ }
297
+ return { colWidths, rowHeights: rh, rows };
298
+ }
299
+ const tableData = reactive(buildTable());
300
+ watch(
301
+ () => props.gridConfig,
302
+ () => {
303
+ const data = buildTable();
304
+ tableData.colWidths = data.colWidths;
305
+ tableData.rowHeights = data.rowHeights;
306
+ tableData.rows = data.rows;
307
+ }
308
+ );
309
+ function tdStyle(cell) {
310
+ const style = {};
311
+ const s = cell.style;
312
+ if (!s) return style;
313
+ if (s.fontColor) style.color = s.fontColor;
314
+ if (s.fontSize) style.fontSize = `${s.fontSize}px`;
315
+ if (s.fontFamily) style.fontFamily = s.fontFamily;
316
+ if (s.bold) style.fontWeight = "bold";
317
+ if (s.italic) style.fontStyle = "italic";
318
+ if (s.underline) style.textDecoration = "underline";
319
+ if (s.strikethrough) style.textDecoration = "line-through";
320
+ if (s.bgColor) style.backgroundColor = s.bgColor;
321
+ const border = s.border;
322
+ if (border) {
323
+ if (border.t) style.borderTop = `${border.t.s}px solid ${border.t.cl.rgb}`;
324
+ if (border.r)
325
+ style.borderRight = `${border.r.s}px solid ${border.r.cl.rgb}`;
326
+ if (border.b)
327
+ style.borderBottom = `${border.b.s}px solid ${border.b.cl.rgb}`;
328
+ if (border.l) style.borderLeft = `${border.l.s}px solid ${border.l.cl.rgb}`;
329
+ }
330
+ return style;
331
+ }
332
+ function tdClass(cell) {
333
+ if (cell.type === "splitline") return "form-td-splitline";
334
+ if (cell.type === "embedded-list") return "form-td-embedded-list";
335
+ if (!cell.name) return "form-td-label";
336
+ return "form-td-field";
337
+ }
338
+ function getRowStyle(row, ri) {
339
+ const hasEmbedded = row.some((c) => c.type === "embedded-list");
340
+ if (hasEmbedded) return {};
341
+ const h = tableData.rowHeights[ri];
342
+ return h ? { height: `${h}px` } : {};
343
+ }
344
+ return (_ctx, _cache) => {
345
+ return openBlock(), createElementBlock("div", _hoisted_1, [
346
+ tableData.rows.length > 0 ? (openBlock(), createElementBlock("table", _hoisted_2, [
347
+ createElementVNode("colgroup", null, [
348
+ (openBlock(true), createElementBlock(Fragment, null, renderList(tableData.colWidths, (w, i) => {
349
+ return openBlock(), createElementBlock("col", {
350
+ key: i,
351
+ style: normalizeStyle({ width: w + "px" })
352
+ }, null, 4);
353
+ }), 128))
354
+ ]),
355
+ createElementVNode("tbody", null, [
356
+ (openBlock(true), createElementBlock(Fragment, null, renderList(tableData.rows, (row, ri) => {
357
+ return openBlock(), createElementBlock("tr", {
358
+ key: ri,
359
+ style: normalizeStyle(getRowStyle(row, ri))
360
+ }, [
361
+ (openBlock(true), createElementBlock(Fragment, null, renderList(row, (cell, ci) => {
362
+ return openBlock(), createElementBlock("td", {
363
+ key: ci,
364
+ rowspan: cell.rowSpan || 1,
365
+ colspan: cell.colSpan || 1,
366
+ style: normalizeStyle(tdStyle(cell)),
367
+ class: normalizeClass([
368
+ tdClass(cell),
369
+ { "form-td-required": cell.isneed === "1" && !isCellHidden(cell) }
370
+ ]),
371
+ title: cell.title || void 0
372
+ }, [
373
+ cellCondition(cell).render ? withDirectives((openBlock(), createElementBlock("div", _hoisted_4, [
374
+ cell.type === "splitline" ? (openBlock(), createBlock(resolveDynamicComponent(unref(resolveCellComponent)(cell)), {
375
+ key: 0,
376
+ cell
377
+ }, null, 8, ["cell"])) : cell.type === "embedded-list" ? (openBlock(), createBlock(EmbeddedListField, {
378
+ key: 1,
379
+ cell,
380
+ master: masterSnapshot.value,
381
+ pfield: __props.pfield,
382
+ "extra-params": __props.extraParams,
383
+ category: __props.category
384
+ }, null, 8, ["cell", "master", "pfield", "extra-params", "category"])) : !cell.name ? (openBlock(), createElementBlock("span", _hoisted_5, [
385
+ createTextVNode(toDisplayString(cell.title) + " ", 1),
386
+ cell.remark ? (openBlock(), createBlock(unref(Tooltip), {
387
+ key: 0,
388
+ title: cell.remark,
389
+ placement: "top",
390
+ "overlay-style": { maxWidth: "320px" }
391
+ }, {
392
+ default: withCtx(() => [..._cache[0] || (_cache[0] = [
393
+ createElementVNode("span", { class: "cell-remark" }, "?", -1)
394
+ ])]),
395
+ _: 1
396
+ }, 8, ["title"])) : createCommentVNode("", true)
397
+ ])) : (openBlock(), createElementBlock("div", _hoisted_6, [
398
+ (openBlock(), createBlock(resolveDynamicComponent(unref(resolveCellComponent)(cell)), {
399
+ "model-value": cell.name ? formData[cell.name] ?? derivedValues[cell.name] : void 0,
400
+ cell,
401
+ disabled: isCellDisabled(cell),
402
+ api: unref(fieldHostApi),
403
+ comname: cell.comname,
404
+ host: "form",
405
+ params: __props.extraParams,
406
+ "onUpdate:modelValue": (val) => {
407
+ if (cell.name) setFieldValue(cell.name, val);
408
+ },
409
+ "onUpdate:derived": applyDerived
410
+ }, null, 40, ["model-value", "cell", "disabled", "api", "comname", "params", "onUpdate:modelValue"])),
411
+ cell.remark ? (openBlock(), createBlock(unref(Tooltip), {
412
+ key: 0,
413
+ title: cell.remark,
414
+ placement: "top",
415
+ "overlay-style": { maxWidth: "320px" }
416
+ }, {
417
+ default: withCtx(() => [..._cache[1] || (_cache[1] = [
418
+ createElementVNode("span", { class: "cell-remark" }, "?", -1)
419
+ ])]),
420
+ _: 1
421
+ }, 8, ["title"])) : createCommentVNode("", true)
422
+ ]))
423
+ ], 512)), [
424
+ [vShow, cellCondition(cell).show]
425
+ ]) : createCommentVNode("", true),
426
+ isCellHidden(cell) ? (openBlock(), createBlock(unref(Tooltip), {
427
+ key: 1,
428
+ title: cellHiddenTip(cell),
429
+ placement: "top",
430
+ "overlay-style": { maxWidth: "320px" }
431
+ }, {
432
+ default: withCtx(() => [..._cache[2] || (_cache[2] = [
433
+ createElementVNode("span", { class: "cell-cond-hidden" }, "无需编辑", -1)
434
+ ])]),
435
+ _: 1
436
+ }, 8, ["title"])) : createCommentVNode("", true)
437
+ ], 14, _hoisted_3);
438
+ }), 128))
439
+ ], 4);
440
+ }), 128))
441
+ ])
442
+ ])) : (openBlock(), createElementBlock("div", _hoisted_7, "暂无表单配置"))
443
+ ]);
444
+ };
445
+ }
446
+ });
447
+ export {
448
+ _sfc_main as default
449
+ };
@@ -0,0 +1,7 @@
1
+ import _sfc_main from "./design-form2.vue.js";
2
+ /* empty css */
3
+ import _export_sfc from "../_virtual/_plugin-vue_export-helper.js";
4
+ const DesignForm = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-b3ade916"]]);
5
+ export {
6
+ DesignForm as default
7
+ };