@web-utils/form-ui 1.0.0-beta56 → 1.0.0-beta58

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 (153) hide show
  1. package/chunks/-qKZw-3p2.mjs +23 -0
  2. package/chunks/{CauzhVSa2.mjs → 4-vc_q1t.mjs} +12 -12
  3. package/chunks/{Bq62m7IR2.mjs → 4C611CU2.mjs} +11 -11
  4. package/chunks/{gLPy4Sus.mjs → 8P-OAGbj.mjs} +1 -1
  5. package/chunks/B2PuSZ_F.mjs +35 -0
  6. package/chunks/B6B-rhhB.mjs +37 -0
  7. package/chunks/{C7Mak2La.mjs → BHT38Us-.mjs} +7 -6
  8. package/chunks/BWoKh6f6.mjs +66 -0
  9. package/chunks/{Dt_s96gL2.mjs → BXrA0SYn2.mjs} +2 -2
  10. package/chunks/BZ0v5mka.mjs +30 -0
  11. package/chunks/{5KomemiE2.mjs → BlmtfUfl2.mjs} +29 -29
  12. package/chunks/CE1uX9hJ.mjs +95 -0
  13. package/chunks/CGnOR2gn.mjs +59 -0
  14. package/chunks/CJ1-f8sg.mjs +30 -0
  15. package/chunks/{B3A-CnYr.mjs → CSnlDCNV.mjs} +5 -5
  16. package/chunks/CdzoVG6J.mjs +47 -0
  17. package/chunks/{BZTAuJxn2.mjs → CqoMZ9Wo2.mjs} +1 -1
  18. package/chunks/CrQmTHMA.mjs +105 -0
  19. package/chunks/Crh2RUrS.mjs +106 -0
  20. package/chunks/DBUJ7Bva.mjs +56 -0
  21. package/chunks/DB_UKPay.mjs +27 -0
  22. package/chunks/{BvKUeniN.mjs → DEC2O0q-.mjs} +46 -44
  23. package/chunks/{BoJgSMkL.mjs → DUhF8YOY.mjs} +2 -2
  24. package/chunks/{g8MIBMw92.mjs → Dqq8z1t4.mjs} +13 -13
  25. package/chunks/Du1PslcN.mjs +28 -0
  26. package/chunks/{Dluor05A.mjs → DyEYDv4B.mjs} +7 -6
  27. package/chunks/EAJCsX8W.mjs +32 -0
  28. package/chunks/ZFJ73RWd2.mjs +29 -0
  29. package/chunks/{D2B9Y3oT.mjs → fmIV_kHp.mjs} +2 -2
  30. package/chunks/h5488Kii.mjs +27 -0
  31. package/chunks/k3cC9SGC.mjs +27 -0
  32. package/chunks/{7GmKqdbC.mjs → usyXQe35.mjs} +1 -1
  33. package/chunks/{BpCiVuKL.mjs → v3wbYL_-.mjs} +7 -6
  34. package/chunks/vd9nXj8B.mjs +59 -0
  35. package/confirm-button/index.mjs +1 -1
  36. package/confirmable/index.mjs +1 -1
  37. package/editable-tree/index.mjs +591 -2
  38. package/element-dialog/index.mjs +1 -1
  39. package/element-resize-observer/index.mjs +1 -1
  40. package/form-cascader/index.mjs +1 -1
  41. package/form-checkbox/index.mjs +1 -1
  42. package/form-checkbox-group/index.mjs +1 -1
  43. package/form-date-picker/index.mjs +1 -1
  44. package/form-holder/index.mjs +1 -1
  45. package/form-image/index.mjs +1 -1
  46. package/form-input/index.mjs +1 -1
  47. package/form-input-cron-expression/index.mjs +1 -1
  48. package/form-input-email/index.mjs +1 -1
  49. package/form-input-id-card/index.mjs +1 -1
  50. package/form-input-number/index.mjs +1 -1
  51. package/form-input-phone-number/index.mjs +1 -1
  52. package/form-input-tag/index.mjs +1 -1
  53. package/form-input-time/index.mjs +1 -1
  54. package/form-item-group/index.mjs +1 -1
  55. package/form-item-x/index.mjs +1 -1
  56. package/form-radio-group/index.mjs +1 -1
  57. package/form-rate/index.mjs +1 -1
  58. package/form-row/index.mjs +1 -1
  59. package/form-select/index.mjs +1 -1
  60. package/form-slider/index.mjs +1 -1
  61. package/form-switch/index.mjs +1 -1
  62. package/form-table/index.mjs +1 -1
  63. package/form-table-plus/index.mjs +1 -1
  64. package/form-text/index.mjs +1 -1
  65. package/form-textarea/index.mjs +1 -1
  66. package/form-time-select/index.mjs +1 -1
  67. package/helper/dictionary.mjs +1 -1
  68. package/helper/form-item.d.ts +1 -1
  69. package/helper/form-item.mjs +27 -2
  70. package/helper/input.mjs +1 -1
  71. package/iframe-window/index.mjs +1 -1
  72. package/index.mjs +37 -37
  73. package/package.json +1 -1
  74. package/pageable-table/index.mjs +1 -1
  75. package/props/cascader.d.ts +326 -0
  76. package/{chunks/Czz_49pC.mjs → props/cascader.mjs} +8 -58
  77. package/props/checkbox-group.d.ts +213 -0
  78. package/props/checkbox-group.mjs +83 -0
  79. package/props/checkbox.d.ts +202 -0
  80. package/props/checkbox.mjs +71 -0
  81. package/props/col.d.ts +74 -0
  82. package/props/col.mjs +32 -0
  83. package/props/common.d.ts +114 -0
  84. package/props/common.mjs +18 -0
  85. package/props/date.d.ts +339 -0
  86. package/props/date.mjs +145 -0
  87. package/props/form-item.d.ts +144 -0
  88. package/props/form-item.mjs +73 -0
  89. package/props/form.d.ts +157 -0
  90. package/props/form.mjs +89 -0
  91. package/props/image.d.ts +102 -0
  92. package/props/image.mjs +10 -0
  93. package/props/input-cron.d.ts +102 -0
  94. package/props/input-cron.mjs +16 -0
  95. package/props/input-number.d.ts +216 -0
  96. package/props/input-number.mjs +72 -0
  97. package/props/input-tag.d.ts +123 -0
  98. package/props/input-tag.mjs +33 -0
  99. package/props/input.d.ts +299 -0
  100. package/props/input.mjs +97 -0
  101. package/props/radio-group.d.ts +205 -0
  102. package/props/radio-group.mjs +84 -0
  103. package/props/rate.d.ts +211 -0
  104. package/{chunks/D0kIhzQo.mjs → props/rate.mjs} +7 -28
  105. package/props/select.d.ts +450 -0
  106. package/props/select.mjs +218 -0
  107. package/props/slide.d.ts +235 -0
  108. package/{chunks/DZrQmH9Y.mjs → props/slide.mjs} +7 -28
  109. package/props/switch.d.ts +229 -0
  110. package/{chunks/ecpQ-ODX.mjs → props/switch.mjs} +7 -33
  111. package/props/text.d.ts +127 -0
  112. package/props/text.mjs +22 -0
  113. package/props/textarea.d.ts +266 -0
  114. package/{chunks/CNK4mfga.mjs → props/textarea.mjs} +19 -31
  115. package/props/time-select.d.ts +216 -0
  116. package/props/time-select.mjs +67 -0
  117. package/props/time.d.ts +304 -0
  118. package/{chunks/C3MF_-bN.mjs → props/time.mjs} +8 -39
  119. package/props/tree.d.ts +76 -0
  120. package/props/tree.mjs +75 -0
  121. package/sub-table/index.mjs +1 -1
  122. package/sub-table-plus/index.mjs +1 -1
  123. package/table-column/index.mjs +1 -1
  124. package/table-column-def/index.mjs +1 -1
  125. package/table-view/index.mjs +13 -13
  126. package/toolbar/index.mjs +1 -1
  127. package/toolbar-button/index.mjs +1 -1
  128. package/vue-cron/index.mjs +1 -1
  129. package/web-types.json +1 -1
  130. package/x-input-tag/index.mjs +2 -2
  131. package/year-calendar/index.mjs +1 -1
  132. package/chunks/6GcIyEQV.mjs +0 -95
  133. package/chunks/8c9TEVNY.mjs +0 -36
  134. package/chunks/AAZfNtly.mjs +0 -119
  135. package/chunks/BKlMENhV.mjs +0 -57
  136. package/chunks/BNVYEWWW.mjs +0 -57
  137. package/chunks/BTuzBfTA.mjs +0 -141
  138. package/chunks/C6Dq9Dgb.mjs +0 -17
  139. package/chunks/C6u76g6o.mjs +0 -158
  140. package/chunks/CLO5X9Lb.mjs +0 -176
  141. package/chunks/CdoiMj7L2.mjs +0 -39
  142. package/chunks/DTVTvvq-.mjs +0 -189
  143. package/chunks/DWE67l1f.mjs +0 -317
  144. package/chunks/DWMePN6q.mjs +0 -660
  145. package/chunks/D_L1p3vm2.mjs +0 -90
  146. package/chunks/Dy_5vPdP.mjs +0 -101
  147. package/chunks/Goee5Y-H.mjs +0 -198
  148. /package/chunks/{BlxLaWcU.mjs → 6av50rJm.mjs} +0 -0
  149. /package/chunks/{CkOD-_VV.mjs → B1MSrc6f.mjs} +0 -0
  150. /package/chunks/{BNqVEHk_.mjs → C-0zqLII.mjs} +0 -0
  151. /package/chunks/{xq_LR6R2.mjs → CI1ehQi5.mjs} +0 -0
  152. /package/chunks/{DcTVYqeJ.mjs → DuOxL6xh.mjs} +0 -0
  153. /package/chunks/{CXsoKP22.mjs → mekxD3ef.mjs} +0 -0
@@ -1,660 +0,0 @@
1
- import { d as e, t } from "./DcTVYqeJ.mjs";
2
- import { t as n } from "./7GmKqdbC.mjs";
3
- import { t as r } from "./CkOD-_VV.mjs";
4
- import { computePosition as i, delay as a, fastClone as o, findTreeChildren as s, hasOwn as c, isFunction as l, isNotEmpty as u, isPlainObject as d, isUndefined as f, isVerticalScrollbarVisible as p, patch as m, scrollbarWidth as h } from "@web-utils/core";
5
- import { Fragment as g, createBlock as _, createCommentVNode as v, createElementBlock as y, createElementVNode as b, createTextVNode as x, createVNode as S, mergeProps as C, normalizeClass as w, normalizeStyle as T, openBlock as E, renderSlot as D, toDisplayString as O, toHandlers as k, vShow as A, withCtx as j, withDirectives as M, withModifiers as N } from "vue";
6
- import { ElMessageBox as P } from "element-plus";
7
- import { cloneDeep as F } from "@web-utils/integrations/lodash";
8
- import { ElInput as I, ElPopconfirm as L, ElTree as R } from "element-plus/es";
9
- import { addResizeListener as z, removeResizeListener as B } from "@web-utils/integrations/resize";
10
- //#region src/components/form/props/tree.ts
11
- var V = {
12
- label: {
13
- type: String,
14
- default: "书签"
15
- },
16
- addRootNodeLabel: String,
17
- defaultExpandedKeys: {
18
- type: Array,
19
- default: () => []
20
- },
21
- newNodeBuilder: {
22
- type: Function,
23
- default: (e, t) => ({
24
- name: e,
25
- parentId: t.id
26
- })
27
- },
28
- contextMenu: Boolean,
29
- lazy: {
30
- type: Boolean,
31
- default: !0
32
- },
33
- expandFirstNode: {
34
- type: Boolean,
35
- default: !0
36
- },
37
- readonly: Boolean,
38
- saveApi: Function,
39
- updateApi: Function,
40
- deleteApi: Function,
41
- fetchApi: Function,
42
- customRootNode: [Object, Function],
43
- rootNode: Object,
44
- contextMenuIcon: Boolean,
45
- contextMenuInline: Boolean,
46
- treeProps: {
47
- type: Object,
48
- default: () => ({
49
- children: "children",
50
- label: "name",
51
- isLeaf: (e) => c(e, "hasChildren") ? !e.hasChildren : c(e, "hasChild") ? !e.hasChild : c(e, "children") && e.children ? e.children.length === 0 : !0
52
- })
53
- },
54
- menuLabel: {
55
- type: Object,
56
- default: () => ({
57
- appendPeer: "添加同级节点",
58
- appendChild: "添加",
59
- removeNode: "删除",
60
- editNode: "修改"
61
- })
62
- },
63
- icon: {
64
- type: [Function, Boolean],
65
- default: (e, t) => "el-icon-collection-tag"
66
- },
67
- confirmButton: {
68
- type: Boolean,
69
- default: !0
70
- },
71
- addRootNodeButtonStyle: {
72
- type: String,
73
- default: "top"
74
- },
75
- reserveExpandKey: Boolean,
76
- nodeKey: {
77
- type: String,
78
- default: "id"
79
- },
80
- defaultExpandAll: Boolean
81
- }, H = { icon: !0 }, U = (e) => H[e] !== !0, W = {
82
- name: "EditableTree",
83
- props: { ...V },
84
- emits: {
85
- "remove-new-node": null,
86
- "node-loaded": null,
87
- "root-node-loaded": null,
88
- "node-deleted": null,
89
- "node-updated": null,
90
- "node-added": null,
91
- "on-node-click": null,
92
- "add-root-node": null,
93
- "create-new-node": null
94
- },
95
- data() {
96
- return {
97
- loading: !1,
98
- showMenu: !1,
99
- empty: !0,
100
- expandedKeys: this.lazy ? [] : this.defaultExpandedKeys,
101
- treeData: [],
102
- curNode: {},
103
- curData: {},
104
- position: {},
105
- text: "",
106
- right: 4,
107
- treeKey: Date.now()
108
- };
109
- },
110
- computed: {
111
- defaultOptions() {
112
- return {
113
- confirmButtonText: "确定",
114
- cancelButtonText: "取消",
115
- closeOnClickModal: !1,
116
- modal: !0,
117
- inputErrorMessage: `${this.label}名不能为空!`,
118
- inputPlaceholder: `请输入${this.label}名...`,
119
- inputValidator: (e) => e != null && e.trim().length > 0
120
- };
121
- },
122
- innerTreeData() {
123
- var e;
124
- return (e = this.$attrs.data) != null && e.length ? this.$attrs.data : this.treeData;
125
- }
126
- },
127
- watch: { defaultExpandedKeys: {
128
- immediate: !0,
129
- handler(e) {
130
- this.expandedKeys = [...e];
131
- }
132
- } },
133
- setup(t) {
134
- let { autoBindProps: n, listeners: r } = e(t, {
135
- predicate: U,
136
- removeOn: !0
137
- });
138
- return {
139
- autoBindProps: n,
140
- listeners: r
141
- };
142
- },
143
- created() {
144
- this.tryFetch();
145
- },
146
- mounted() {
147
- z(this.$refs.tree.$el, this.resize), z(this.$refs.treeWrapper, this.resize);
148
- },
149
- beforeUnmount() {
150
- B(this.$refs.tree.$el, this.resize), B(this.$refs.treeWrapper, this.resize);
151
- },
152
- methods: {
153
- addExpandKey(e) {
154
- this.reserveExpandKey && this.expandedKeys.push(e[this.nodeKey]);
155
- },
156
- removeExpandKey(e) {
157
- this.reserveExpandKey && (this.expandedKeys = this.expandedKeys.filter((t) => t !== e[this.nodeKey]));
158
- },
159
- resize() {
160
- p(this.$refs.treeWrapper) ? this.right = 4 + h : this.right = 4;
161
- },
162
- async showContextMenu(e, t, n) {
163
- t.contextmenu === !1 || t.id === -1 || t.id === 0 || t.edit === !0 || this.readonly || this.contextMenu && (this.curNode = n, this.curData = t, this.showMenu = !0, this.$refs.tree.setCurrentKey(t.id), await this.$nextTick(), this.position = i(e, this.$refs.contextMenu), window.addEventListener("click", this.hideContextMenu));
164
- },
165
- hideContextMenu() {
166
- this.showMenu = !1, window.removeEventListener("click", this.hideContextMenu);
167
- },
168
- async tryFetch() {
169
- if (this.lazy === !1 && this.fetchApi) {
170
- var e;
171
- let r;
172
- try {
173
- var t;
174
- r = await this.fetchApi(((t = this.rootNode) == null ? void 0 : t.id) ?? -1, {});
175
- } catch {
176
- return;
177
- }
178
- let i = r.data.data;
179
- d(i) && (i = [i]), i = i || [];
180
- let a = [];
181
- if (this.empty = i.length === 0, d(this.customRootNode)) {
182
- let e = F(this.customRootNode);
183
- e[this.treeProps.children || "children"] = i, a = [e];
184
- } else if (l(this.customRootNode)) {
185
- let e = this.customRootNode(i);
186
- e[this.treeProps.children || "children"] = i, a = d(e) ? [e] : e;
187
- } else a = i;
188
- if ((e = this.defaultExpandedKeys) != null && e.length) this.expandedKeys = [...this.defaultExpandedKeys];
189
- else if (this.expandFirstNode) {
190
- var n;
191
- this.expandedKeys = [(n = a[0]) == null ? void 0 : n.id];
192
- }
193
- this.treeData = a, await this.$nextTick(), this.$emit("node-loaded", a);
194
- }
195
- },
196
- async loadNode(e, t) {
197
- if (e.level === 0) {
198
- var n, r;
199
- let o = (await this.fetchApi(((n = this.rootNode) == null ? void 0 : n.id) ?? -1, e)).data.data;
200
- if (this.empty = o.length === 0, d(this.customRootNode)) {
201
- let e = F(this.customRootNode);
202
- e[this.treeProps.children || "children"] = o, o = [e], t(o);
203
- } else if (l(this.customRootNode)) {
204
- let e = this.customRootNode(o);
205
- e[this.treeProps.children || "children"] = o, o = d(e) ? [e] : e;
206
- } else t(o);
207
- if (await this.$nextTick(), this.$emit("root-node-loaded", o), (r = this.defaultExpandedKeys) != null && r.length) {
208
- var i;
209
- this.expandedKeys = [(i = o[0]) == null ? void 0 : i.id, ...this.defaultExpandedKeys];
210
- } else if (this.expandFirstNode) {
211
- var a;
212
- this.expandedKeys = [(a = o[0]) == null ? void 0 : a.id];
213
- }
214
- } else {
215
- if (e.leaf || e.data.isTempNode) return t([]);
216
- let n = (await this.fetchApi(e.data.id, e)).data.data;
217
- t(n), await this.$nextTick(), this.$emit("node-loaded", n);
218
- }
219
- },
220
- clear() {
221
- this.cancelEdit(), this.removeNewNode();
222
- },
223
- clearChecked() {
224
- this.$refs.tree.setCheckedKeys([]);
225
- },
226
- removeNewNode() {
227
- this.newChild && this.newChild.id === -1 && (this.$refs.tree.remove(this.newChild), this.$emit("remove-new-node"));
228
- },
229
- cancelEdit() {
230
- this.editData && (f(this.editData.edit) ? this.editData.edit = !0 : this.editData.edit = !1);
231
- },
232
- async editNode(e, t) {
233
- !this.contextMenu || this.contextMenuIcon || this.contextMenuInline ? (this.clear(), this.editData = t, this.text = t[this.treeProps.label], f(t.edit), t.edit = !0, await this.$nextTick(), this.$refs.labelTxt.focus()) : await P.prompt(`请输入新的${this.label}名:`, {
234
- ...this.defaultOptions,
235
- inputValue: t[this.treeProps.label],
236
- beforeClose: async (e, t, n) => {
237
- if (e === "confirm") {
238
- try {
239
- t.confirmButtonLoading = !0, t.confirmButtonText = "处理中...", this.text = t.inputValue, await this.onConfirm(this.curNode, this.curData), n();
240
- } catch {
241
- t.confirmButtonText = "确定";
242
- }
243
- t.confirmButtonLoading = !1;
244
- } else n();
245
- }
246
- }).catch((e) => e);
247
- },
248
- async appendRootNode() {
249
- this.text = "", !this.contextMenu || this.contextMenuIcon || this.contextMenuInline ? (this.clear(), this.createNewChild(void 0), this.$refs.tree.root.insertChild({ data: this.newChild }, void 0, !0), await this.scrollIntoView(!0)) : await P.prompt(`请输入${this.label}名:`, {
250
- ...this.defaultOptions,
251
- beforeClose: async (e, n, r) => {
252
- if (e === "confirm") {
253
- try {
254
- this.createNewChild(-1), n.confirmButtonLoading = !0, n.confirmButtonText = "处理中...";
255
- let e = await this.saveApi(this.newNodeBuilder(n.inputValue, { id: -1 }));
256
- this.newChild[this.treeProps.label] = n.inputValue, this.newChild.edit = !1, t(this.newChild, e.data), this.$refs.tree.root.insertChild({ data: this.newChild }, void 0, !0), await this.locateView(), r();
257
- } catch {
258
- n.confirmButtonText = "确定";
259
- }
260
- n.confirmButtonLoading = !1;
261
- } else r();
262
- }
263
- }).catch((e) => e);
264
- },
265
- appendChildNode(e) {
266
- this.text = "";
267
- let n = e.expanded;
268
- e.expand(async () => {
269
- !this.contextMenu || this.contextMenuIcon || this.contextMenuInline ? (this.clear(), this.createNewChild(e.data.id), this.$refs.tree.append(this.newChild, e), await this.scrollIntoView(n)) : await P.prompt(`请输入${this.label}名:`, {
270
- ...this.defaultOptions,
271
- beforeClose: async (n, r, i) => {
272
- if (n === "confirm") {
273
- try {
274
- this.createNewChild(e.data.id), r.confirmButtonLoading = !0, r.confirmButtonText = "处理中...";
275
- let n = await this.saveApi(this.newNodeBuilder(r.inputValue, e.data));
276
- this.newChild[this.treeProps.label] = r.inputValue, this.newChild.edit = !1, t(this.newChild, n.data), this.$refs.tree.append(this.newChild, e), await this.locateView(), i();
277
- } catch {
278
- r.confirmButtonText = "确定";
279
- }
280
- r.confirmButtonLoading = !1;
281
- } else i();
282
- }
283
- });
284
- });
285
- },
286
- appendChildNodeWithData(e, t, n) {
287
- this.text = "";
288
- let r = e.expanded;
289
- e.expand(async () => {
290
- this.clear(), this.newChild = {
291
- id: -1,
292
- parentId: t,
293
- [this.treeProps.label]: n,
294
- edit: !1,
295
- isTempNode: !0,
296
- hasChildren: !1
297
- }, this.$refs.tree.append(this.newChild, e), await this.scrollIntoView(r);
298
- });
299
- },
300
- appendPeerNode(e) {
301
- e.parent && e.parent.level !== 0 ? this.appendChildNode(e.parent) : this.appendRootNode();
302
- },
303
- async addRootNode(e) {
304
- this.$refs.tree.remove(e), await this.$nextTick(), this.$refs.tree.root.insertChild({ data: e }, void 0, !0);
305
- },
306
- async addChildNode(e) {
307
- this.curNode && this.curNode.level !== 0 ? this.curNode.expand(async () => {
308
- this.$refs.tree.remove(e), await this.$nextTick(), this.$refs.tree.append(e, this.curNode);
309
- }) : await this.addRootNode(e);
310
- },
311
- async addPeerNode(e) {
312
- this.curNode && this.curNode.parent && this.curNode.parent.level !== 0 ? this.curNode.parent.expand(async () => {
313
- this.$refs.tree.remove(e), await this.$nextTick(), this.$refs.tree.append(e, this.curNode.parent);
314
- }) : await this.addRootNode(e);
315
- },
316
- updateNode(e) {
317
- let t = this.$refs.tree.getNode(e);
318
- t && m(t.data, e, !0);
319
- },
320
- setCurrentKey(e) {
321
- var t;
322
- (t = this.$refs.tree) == null || t.setCurrentKey(e);
323
- },
324
- createNewChild(e) {
325
- this.newChild = {
326
- id: -1,
327
- parentId: e,
328
- [this.treeProps.label]: "",
329
- edit: !0,
330
- isTempNode: !0,
331
- hasChildren: !1
332
- }, this.$emit("create-new-node", this.newChild);
333
- },
334
- async removeNodeModal(e) {
335
- await this.$confirm(`你确定要删除${this.label}[<span class="break-word" style="color: orange">${e.data[this.treeProps.label]}</span>]吗?`, "系统提示", {
336
- type: "warning",
337
- modal: !0,
338
- dangerouslyUseHTMLString: !0,
339
- iconClass: "el-icon-question",
340
- closeOnClickModal: !1,
341
- confirmButtonClass: "el-button--danger",
342
- cancelButtonClass: "el-button--primary is-plain",
343
- beforeClose: async (t, n, r) => {
344
- if (t === "confirm") {
345
- try {
346
- n.confirmButtonLoading = !0, n.confirmButtonText = "删除...";
347
- let t = e.parent, i = await this.deleteApi(e.data.id);
348
- i.code === 0 ? (this.$message.success("删除成功!"), this.$refs.tree.remove(e), this.$emit("node-deleted", t, e.data), r()) : this.$message.error(i.message);
349
- } catch {}
350
- n.confirmButtonText = "确定", n.confirmButtonLoading = !1;
351
- } else r();
352
- }
353
- }).catch((e) => e);
354
- },
355
- async removeNode(e) {
356
- try {
357
- let t = e.parent;
358
- if (this.deleteApi) {
359
- let n = await this.deleteApi(e.data.id);
360
- n.code === 0 ? (this.$message.success("删除成功!"), this.$refs.tree.remove(e), this.$emit("node-deleted", t, e.data)) : this.$message.error(n.message);
361
- } else this.$refs.tree.remove(e);
362
- } catch {}
363
- },
364
- async onConfirm(e, n) {
365
- if (n[this.treeProps.label] === this.text || !u(this.text)) {
366
- this.clear();
367
- return;
368
- }
369
- f(n.loading), n.loading = !0;
370
- try {
371
- if (this.loading = !0, n.id === -1) {
372
- let r = await this.saveApi(this.newNodeBuilder(this.text, e.parent.data || { id: -1 })), i = o(n);
373
- t(n, {
374
- ...r.data,
375
- isTempNode: !1
376
- }), this.$emit("node-added", n, i, e), this.registerNode(e);
377
- } else await this.updateApi({
378
- ...n,
379
- [this.treeProps.label]: this.text
380
- });
381
- n[this.treeProps.label] = this.text, n.edit = !1, this.$emit("node-updated", n, e), this.text = "";
382
- } catch {}
383
- n.loading = !1, this.loading = !1;
384
- },
385
- onCancel(e, t) {
386
- t.id === -1 ? this.$refs.tree.remove(e) : t.edit = !1, this.text = "";
387
- },
388
- nodeClick(e, t, n) {
389
- this.hideContextMenu(), (f(e.loading) || !e.loading) && (this.curNode = t, this.curData = e, this.$emit("on-node-click", e, t, n));
390
- },
391
- getCurrentNode() {
392
- return this.$refs.tree.getCurrentNode();
393
- },
394
- async locateView() {
395
- await this.$nextTick();
396
- let e = this.$el.querySelector(`[data-id="${this.newChild.id}"]`);
397
- e && e.scrollIntoView();
398
- },
399
- async scrollIntoView(e) {
400
- var t;
401
- await this.$nextTick(), e || await a(300), (t = this.$refs) == null || (t = t.labelTxt) == null || t.focus();
402
- },
403
- inputKeyup(e, t, n) {
404
- e.keyCode === 13 && this.onConfirm(t, n), e.keyCode === 27 && this.clear();
405
- },
406
- inputBlur(e, t, n) {
407
- this.confirmButton || this.onConfirm(t, n);
408
- },
409
- getCheckedKeys() {
410
- return this.$refs.tree.getCheckedKeys();
411
- },
412
- setCheckedKeys(e) {
413
- this.$refs.tree.setCheckedKeys(e);
414
- },
415
- getCheckedNodes() {
416
- return this.$refs.tree.getCheckedNodes();
417
- },
418
- setCheckedNodes(e) {
419
- this.$refs.tree.setCheckedNodes(e);
420
- },
421
- getNode(e) {
422
- return this.$refs.tree.getNode(e);
423
- },
424
- getRootNode() {
425
- return this.$refs.tree.root;
426
- },
427
- findTreeNode(e) {
428
- return s(this.$refs.tree.root.childNodes, (t) => t.data === e || t.data.id === e, "childNodes");
429
- },
430
- registerNode(e) {
431
- e.store.registerNode(e), delete e.store.nodesMap[-1];
432
- },
433
- async reloadTree() {
434
- this.lazy ? this.treeKey = Date.now() : await this.tryFetch();
435
- }
436
- }
437
- }, G = { class: "editable-tree" }, K = {
438
- ref: "treeWrapper",
439
- class: "et-tree-wrapper"
440
- }, q = {
441
- key: 0,
442
- style: { "padding-left": "24px" }
443
- }, J = ["data-id"], Y = {
444
- class: "node-label flex-row flex-item ellipsis-1",
445
- style: { overflow: "hidden" }
446
- }, X = {
447
- class: "flex-item-relative",
448
- style: { height: "21px" }
449
- }, Z = ["title"], Q = {
450
- key: 0,
451
- class: "handle-actions"
452
- }, $ = {
453
- key: 1,
454
- class: "handle-actions",
455
- style: { display: "inline-block" }
456
- }, ee = ["data-id"], te = { class: "menu-list" };
457
- function ne(e, t, r, i, a, o) {
458
- let s = n, c = L, l = I, u = R;
459
- return E(), y("div", G, [!e.readonly && e.addRootNodeButtonStyle === "top-right" ? (E(), _(s, {
460
- key: 0,
461
- type: "primary",
462
- style: T([{
463
- position: "absolute",
464
- top: "4px",
465
- "z-index": "1"
466
- }, { right: `${a.right}px` }]),
467
- icon: "el-icon-plus",
468
- circle: "",
469
- plain: "",
470
- onClick: t[0] || (t[0] = N((t) => e.$emit("add-root-node"), ["stop"]))
471
- }, null, 8, ["style"])) : v("v-if", !0), b("div", K, [
472
- !e.readonly && e.addRootNodeButtonStyle === "top" ? (E(), y("div", q, [S(s, {
473
- disabled: a.loading,
474
- type: "text",
475
- onClick: o.appendRootNode
476
- }, {
477
- default: j(() => [t[8] || (t[8] = b("i", { class: "el-icon-lx-add" }, null, -1)), x(" " + O(e.addRootNodeLabel ? e.addRootNodeLabel : `添加${e.label}`), 1)]),
478
- _: 1
479
- }, 8, ["disabled", "onClick"])])) : v("v-if", !0),
480
- (E(), _(u, C(i.autoBindProps, {
481
- key: a.treeKey,
482
- ref: "tree",
483
- "default-expand-all": e.defaultExpandAll,
484
- class: "flex-item",
485
- "default-expanded-keys": a.expandedKeys,
486
- "expand-on-click-node": !1,
487
- "highlight-current": "",
488
- load: o.loadNode,
489
- data: o.innerTreeData,
490
- props: e.treeProps,
491
- lazy: e.lazy,
492
- "node-key": e.nodeKey
493
- }, k(i.listeners), {
494
- onNodeClick: o.nodeClick,
495
- onNodeContextmenu: o.showContextMenu,
496
- onNodeExpand: o.addExpandKey,
497
- onNodeCollapse: o.removeExpandKey
498
- }), {
499
- default: j(({ node: n, data: r }) => [D(e.$slots, "default", {
500
- node: n,
501
- data: r
502
- }, () => [v("非编辑模式"), r.edit ? (E(), y(g, { key: 1 }, [v("编辑模式"), b("span", {
503
- "data-id": r.id,
504
- class: "custom-tree-node flex-row flex-item",
505
- style: { overflow: "hidden" }
506
- }, [
507
- e.icon ? (E(), y("i", {
508
- key: 0,
509
- class: w([r.loading ? "el-icon-loading" : "el-icon-edit-outline", "node-icon flex-not-shrink"])
510
- }, null, 2)) : v("v-if", !0),
511
- S(l, {
512
- ref: "labelTxt",
513
- modelValue: a.text,
514
- "onUpdate:modelValue": t[2] || (t[2] = (e) => a.text = e),
515
- class: "node-input flex-item",
516
- placeholder: o.defaultOptions.inputPlaceholder,
517
- onKeyup: (e) => o.inputKeyup(e, n, r),
518
- onBlur: (e) => o.inputBlur(e, n, r),
519
- onClick: t[3] || (t[3] = N(() => {}, ["stop"]))
520
- }, null, 8, [
521
- "modelValue",
522
- "placeholder",
523
- "onKeyup",
524
- "onBlur"
525
- ]),
526
- e.confirmButton ? (E(), y(g, { key: 1 }, [M(S(s, {
527
- class: "flex-not-shrink",
528
- type: "text",
529
- onClick: N((e) => o.onConfirm(n, r), ["stop"])
530
- }, {
531
- default: j(() => [...t[13] || (t[13] = [x(" 确定 ", -1)])]),
532
- _: 1
533
- }, 8, ["onClick"]), [[A, !r.loading]]), M(S(s, {
534
- class: "flex-not-shrink",
535
- type: "text",
536
- onClick: N((e) => o.onCancel(n, r), ["stop"])
537
- }, {
538
- default: j(() => [...t[14] || (t[14] = [x(" 取消 ", -1)])]),
539
- _: 1
540
- }, 8, ["onClick"]), [[A, !r.loading]])], 64)) : v("v-if", !0)
541
- ], 8, ee)], 64)) : (E(), y("span", {
542
- key: 0,
543
- "data-id": r.id,
544
- class: "custom-tree-node"
545
- }, [
546
- b("span", Y, [
547
- e.icon ? (E(), y("i", {
548
- key: 0,
549
- class: w([r.loading ? "el-icon-loading" : e.icon(r, n), "node-icon"])
550
- }, null, 2)) : v("v-if", !0),
551
- b("span", X, [b("span", {
552
- class: "ellipsis-1 absolute-box et-tree-label",
553
- title: n.label
554
- }, [D(e.$slots, "label", {
555
- data: r,
556
- node: n
557
- }, () => [x(O(n.label), 1)])], 8, Z)]),
558
- D(e.$slots, "label-suffix", {
559
- node: n,
560
- data: r
561
- })
562
- ]),
563
- !e.contextMenu && !e.readonly ? M((E(), y("span", Q, [
564
- S(s, {
565
- type: "text",
566
- onClick: N((e) => o.appendChildNode(n, r), ["stop"])
567
- }, {
568
- default: j(() => [...t[9] || (t[9] = [x("添加", -1)])]),
569
- _: 1
570
- }, 8, ["onClick"]),
571
- S(s, {
572
- type: "text",
573
- onClick: N((e) => o.editNode(n, r), ["stop"])
574
- }, {
575
- default: j(() => [...t[10] || (t[10] = [x("修改", -1)])]),
576
- _: 1
577
- }, 8, ["onClick"]),
578
- S(c, {
579
- class: "pop-confirm",
580
- "icon-color": "red",
581
- title: "你确定要删除吗?",
582
- onConfirm: (e) => o.removeNode(n, r)
583
- }, {
584
- reference: j(() => [M(S(s, {
585
- style: { "margin-left": "4px" },
586
- type: "text",
587
- onClick: t[1] || (t[1] = N(() => {}, ["stop"]))
588
- }, {
589
- default: j(() => [...t[11] || (t[11] = [x(" 删除 ", -1)])]),
590
- _: 1
591
- }, 512), [[A, n.isLeaf]])]),
592
- _: 2
593
- }, 1032, ["onConfirm"])
594
- ], 512)), [[A, !r.loading && !a.loading]]) : v("v-if", !0),
595
- e.contextMenuIcon && e.contextMenu && !e.readonly ? M((E(), y("span", $, [S(s, {
596
- style: { padding: "6px 10px 0" },
597
- type: "text",
598
- onClick: N((e) => o.showContextMenu(e, r, n), ["stop"])
599
- }, {
600
- default: j(() => [...t[12] || (t[12] = [x(" . . . ", -1)])]),
601
- _: 1
602
- }, 8, ["onClick"])], 512)), [[A, !r.loading && !a.loading]]) : v("v-if", !0)
603
- ], 8, J))])]),
604
- _: 3
605
- }, 16, [
606
- "default-expand-all",
607
- "default-expanded-keys",
608
- "load",
609
- "data",
610
- "props",
611
- "lazy",
612
- "node-key",
613
- "onNodeClick",
614
- "onNodeContextmenu",
615
- "onNodeExpand",
616
- "onNodeCollapse"
617
- ])),
618
- e.contextMenu && !e.readonly ? M((E(), y("div", {
619
- key: 1,
620
- ref: "contextMenu",
621
- style: T(a.position),
622
- class: "menu"
623
- }, [b("ul", te, [D(e.$slots, "context-menu", {
624
- curNode: a.curNode,
625
- curData: a.curData
626
- }, () => [
627
- M(b("li", {
628
- class: "menu-item",
629
- onClick: t[4] || (t[4] = (e) => o.appendPeerNode(a.curNode, a.curData))
630
- }, [t[15] || (t[15] = b("i", {
631
- class: "menu-item-icon el-icon-lx-add",
632
- style: { color: "#228b22" }
633
- }, null, -1)), x(" " + O(e.menuLabel.appendPeer), 1)], 512), [[A, a.curData.id > -1]]),
634
- b("li", {
635
- class: "menu-item",
636
- onClick: t[5] || (t[5] = (e) => o.appendChildNode(a.curNode, a.curData))
637
- }, [t[16] || (t[16] = b("i", {
638
- class: "menu-item-icon el-icon-lx-add",
639
- style: { color: "#228b22" }
640
- }, null, -1)), x(" " + O(e.menuLabel.appendChild), 1)]),
641
- M(b("li", {
642
- class: "menu-item",
643
- onClick: t[6] || (t[6] = (e) => o.editNode(a.curNode, a.curData))
644
- }, [t[17] || (t[17] = b("i", {
645
- class: "menu-item-icon el-icon-edit-outline",
646
- style: { color: "#ffa500" }
647
- }, null, -1)), x(" " + O(e.menuLabel.editNode), 1)], 512), [[A, a.curData.id > -1]]),
648
- M(b("li", {
649
- class: "menu-item",
650
- onClick: t[7] || (t[7] = (e) => o.removeNodeModal(a.curNode, a.curData))
651
- }, [t[18] || (t[18] = b("i", {
652
- class: "menu-item-icon el-icon-delete",
653
- style: { color: "#f00" }
654
- }, null, -1)), x(" " + O(e.menuLabel.removeNode), 1)], 512), [[A, a.curNode.isLeaf]])
655
- ])])], 4)), [[A, a.showMenu]]) : v("v-if", !0)
656
- ], 512)]);
657
- }
658
- var re = /* @__PURE__ */ r(W, [["render", ne]]);
659
- //#endregion
660
- export { re as t };