@web-utils/form-ui 1.0.0-beta32 → 1.0.0-beta34
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.
- package/chunks/{Cby3mvvZ.mjs → 6whKG2aW.mjs} +4 -2
- package/chunks/B0QAMGEk.mjs +149 -0
- package/chunks/{C4bM8miy.mjs → BINk6iM9.mjs} +4 -3
- package/chunks/{Cc3EJjbV.mjs → BMybeJeX.mjs} +2 -2
- package/chunks/{BgDYHgyH.mjs → BOnjsuaF.mjs} +4 -1
- package/chunks/BQvDsDYm.mjs +199 -0
- package/chunks/BRCCvDXx.mjs +339 -0
- package/chunks/BX-cVxlK.mjs +102 -0
- package/chunks/{B99alfW4.mjs → BnDWAjBA.mjs} +2 -2
- package/chunks/BrhuWxfn.mjs +168 -0
- package/chunks/{bnRb5PUB.mjs → Bsff-xFB.mjs} +7 -5
- package/chunks/{Cy-4nmyC.mjs → Bx4hMd0g.mjs} +6 -4
- package/chunks/{BmZieBZW.mjs → ByS9PiXt.mjs} +4 -2
- package/chunks/{C9J3j0PX.mjs → C5jtjhYS.mjs} +2 -0
- package/chunks/CK4RBjb4.mjs +660 -0
- package/chunks/{CsfgUCe9.mjs → CMMPk7_3.mjs} +1 -1
- package/chunks/{C44-CFi-.mjs → CO4Fyzj-.mjs} +13 -4
- package/chunks/{Cgl-hCE5.mjs → COdSAAp_.mjs} +2 -2
- package/chunks/CRf0wnBc.mjs +181 -0
- package/chunks/{Ci1XxmdE.mjs → CYgTbmSw.mjs} +5 -3
- package/chunks/{4ZuVpQf6.mjs → CnAEuI_c.mjs} +1 -1
- package/chunks/DPO-hveW.mjs +233 -0
- package/chunks/{C3a15Ful.mjs → DSJFPBdn.mjs} +4 -2
- package/chunks/{D1EOkWJ7.mjs → DfMmYJVy.mjs} +2 -2
- package/chunks/{Dt6gY213.mjs → Dlemc_K8.mjs} +8 -5
- package/chunks/{DazglPJZ.mjs → DukJJ_BZ.mjs} +3 -1
- package/chunks/KZeDzvm6.mjs +115 -0
- package/chunks/{CugRu2Ka.mjs → PRSE4n97.mjs} +5 -3
- package/chunks/{D1G2MMMx.mjs → b5HOxD60.mjs} +13 -4
- package/chunks/{BV_P9a8o.mjs → bTej_00x.mjs} +4 -2
- package/chunks/{JhyiXnbd.mjs → ierlNKc4.mjs} +10 -4
- package/editable-tree/index.d.ts +254 -0
- package/editable-tree/index.mjs +2 -0
- package/editable-tree/style.css +1 -0
- package/element-dialog/index.d.ts +6 -6
- package/element-dialog/index.mjs +1 -1
- package/form-cascader/index.d.ts +5 -5
- package/form-cascader/index.mjs +1 -1
- package/form-check-box-group/index.d.ts +78 -7
- package/form-check-box-group/index.mjs +1 -1
- package/form-check-box-group/style.css +1 -0
- package/form-checkbox/index.d.ts +4 -2
- package/form-checkbox/index.mjs +1 -1
- package/form-date-picker/index.d.ts +63 -11
- package/form-date-picker/index.mjs +1 -1
- package/form-holder/index.mjs +1 -1
- package/form-image/index.mjs +1 -1
- package/form-input/index.d.ts +3 -3
- package/form-input/index.mjs +1 -1
- package/form-input-cron-expression/index.mjs +1 -1
- package/form-input-email/index.d.ts +3 -3
- package/form-input-email/index.mjs +1 -1
- package/form-input-id-card/index.d.ts +3 -3
- package/form-input-id-card/index.mjs +1 -1
- package/form-input-number/index.d.ts +5 -3
- package/form-input-number/index.mjs +1 -1
- package/form-input-phone-number/index.d.ts +3 -3
- package/form-input-phone-number/index.mjs +1 -1
- package/form-item-group/index.d.ts +0 -2
- package/form-item-group/index.mjs +1 -1
- package/form-item-group/style.css +1 -1
- package/form-item-x/index.mjs +1 -1
- package/form-item-x/style.css +1 -1
- package/form-radio-group/index.d.ts +91 -4
- package/form-radio-group/index.mjs +1 -1
- package/form-rate/index.mjs +1 -1
- package/form-row/index.mjs +1 -1
- package/form-select/index.d.ts +82 -10
- package/form-select/index.mjs +1 -1
- package/form-slider/index.d.ts +2 -2
- package/form-slider/index.mjs +1 -1
- package/form-switch/index.d.ts +4 -4
- package/form-switch/index.mjs +1 -1
- package/form-text/index.mjs +1 -1
- package/helper/dictionary.mjs +7 -7
- package/iframe-window/index.mjs +1 -1
- package/index.d.ts +2 -1
- package/index.mjs +47 -46
- package/month-calendar/index.d.ts +1 -1
- package/package.json +1 -1
- package/pageable-table/index.d.ts +4 -4
- package/pageable-table/index.mjs +1 -1
- package/resize-observer/index.mjs +1 -1
- package/table-column/index.d.ts +4 -4
- package/table-column/index.mjs +1 -1
- package/table-column-def/index.mjs +1 -1
- package/table-view/index.d.ts +340 -1
- package/table-view/index.mjs +458 -6
- package/table-view/style.css +1 -0
- package/toolbar/index.mjs +1 -1
- package/toolbar-button/index.d.ts +136 -24
- package/toolbar-button/index.mjs +1 -1
- package/vue-cron/index.mjs +1 -1
- package/web-types.json +1 -1
- package/x-input-tag/index.mjs +6 -1
- package/year-calendar/index.mjs +1 -1
- package/chunks/BQ77eAb3.mjs +0 -71
- package/chunks/Br4i8stg.mjs +0 -222
- package/chunks/DO8dVGef.mjs +0 -98
- package/chunks/DtAYXPvz.mjs +0 -108
- package/chunks/S64sNmuR.mjs +0 -226
- package/chunks/dM-icPM8.mjs +0 -107
- package/chunks/pxFLMMUm.mjs +0 -110
- package/chunks/q1SlJP1y.mjs +0 -171
- /package/chunks/{CkFapoKt.mjs → B1MSrc6f.mjs} +0 -0
- /package/chunks/{BV_N8p9t.mjs → DiE4GJtU.mjs} +0 -0
|
@@ -0,0 +1,660 @@
|
|
|
1
|
+
import { d as e, t, u as n } from "./BX-cVxlK.mjs";
|
|
2
|
+
import { t as r } from "./BrhuWxfn.mjs";
|
|
3
|
+
import { t as i } from "./B1MSrc6f.mjs";
|
|
4
|
+
import { computePosition as a, delay as o, fastClone as s, findTreeChildren as c, hasOwn as l, isFunction as u, isNotEmpty as d, isPlainObject as f, isUndefined as p, isVerticalScrollbarVisible as m, patch as h, scrollbarWidth as g } from "@web-utils/core";
|
|
5
|
+
import { Fragment as _, createBlock as v, createCommentVNode as y, createElementBlock as b, createElementVNode as x, createTextVNode as S, createVNode as C, mergeProps as w, normalizeClass as T, normalizeStyle as E, openBlock as D, renderSlot as O, toDisplayString as k, toHandlers as A, vShow as j, withCtx as M, withDirectives as N, withModifiers as P } from "vue";
|
|
6
|
+
import { ElMessageBox as F } from "element-plus";
|
|
7
|
+
import { cloneDeep as I } from "@web-utils/integrations/lodash";
|
|
8
|
+
import { ElInput as L, ElPopconfirm as R, ElTree as z } from "element-plus/es";
|
|
9
|
+
import "element-plus/es/components/base/style/css";
|
|
10
|
+
import "element-plus/es/components/tree/style/css";
|
|
11
|
+
import "element-plus/es/components/input/style/css";
|
|
12
|
+
import "element-plus/es/components/popconfirm/style/css";
|
|
13
|
+
import { addResizeListener as B, removeResizeListener as V } from "@web-utils/integrations/resize";
|
|
14
|
+
//#region src/components/form/props/tree.ts
|
|
15
|
+
var H = {
|
|
16
|
+
label: {
|
|
17
|
+
type: String,
|
|
18
|
+
default: "书签"
|
|
19
|
+
},
|
|
20
|
+
addRootNodeLabel: String,
|
|
21
|
+
defaultExpandedKeys: {
|
|
22
|
+
type: Array,
|
|
23
|
+
default: () => []
|
|
24
|
+
},
|
|
25
|
+
newNodeBuilder: {
|
|
26
|
+
type: Function,
|
|
27
|
+
default: (e, t) => ({
|
|
28
|
+
name: e,
|
|
29
|
+
parentId: t.id
|
|
30
|
+
})
|
|
31
|
+
},
|
|
32
|
+
contextMenu: Boolean,
|
|
33
|
+
lazy: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: !0
|
|
36
|
+
},
|
|
37
|
+
expandFirstNode: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: !0
|
|
40
|
+
},
|
|
41
|
+
readonly: Boolean,
|
|
42
|
+
saveApi: Function,
|
|
43
|
+
updateApi: Function,
|
|
44
|
+
deleteApi: Function,
|
|
45
|
+
fetchApi: Function,
|
|
46
|
+
customRootNode: [Object, Function],
|
|
47
|
+
rootNode: Object,
|
|
48
|
+
contextMenuIcon: Boolean,
|
|
49
|
+
contextMenuInline: Boolean,
|
|
50
|
+
treeProps: {
|
|
51
|
+
type: Object,
|
|
52
|
+
default: () => ({
|
|
53
|
+
children: "children",
|
|
54
|
+
label: "name",
|
|
55
|
+
isLeaf: (e) => l(e, "hasChildren") ? !e.hasChildren : l(e, "hasChild") ? !e.hasChild : l(e, "children") && e.children ? e.children.length === 0 : !0
|
|
56
|
+
})
|
|
57
|
+
},
|
|
58
|
+
menuLabel: {
|
|
59
|
+
type: Object,
|
|
60
|
+
default: () => ({
|
|
61
|
+
appendPeer: "添加同级节点",
|
|
62
|
+
appendChild: "添加",
|
|
63
|
+
removeNode: "删除",
|
|
64
|
+
editNode: "修改"
|
|
65
|
+
})
|
|
66
|
+
},
|
|
67
|
+
icon: {
|
|
68
|
+
type: [Function, Boolean],
|
|
69
|
+
default: (e, t) => "el-icon-collection-tag"
|
|
70
|
+
},
|
|
71
|
+
confirmButton: {
|
|
72
|
+
type: Boolean,
|
|
73
|
+
default: !0
|
|
74
|
+
},
|
|
75
|
+
addRootNodeButtonStyle: {
|
|
76
|
+
type: String,
|
|
77
|
+
default: "top"
|
|
78
|
+
},
|
|
79
|
+
reserveExpandKey: Boolean,
|
|
80
|
+
nodeKey: {
|
|
81
|
+
type: String,
|
|
82
|
+
default: "id"
|
|
83
|
+
},
|
|
84
|
+
defaultExpandAll: Boolean
|
|
85
|
+
}, U = { icon: !0 }, W = (e) => U[e] !== !0, G = {
|
|
86
|
+
name: "EditableTree",
|
|
87
|
+
props: { ...H },
|
|
88
|
+
emits: {
|
|
89
|
+
"remove-new-node": null,
|
|
90
|
+
"node-loaded": null,
|
|
91
|
+
"root-node-loaded": null,
|
|
92
|
+
"node-deleted": null,
|
|
93
|
+
"node-updated": null,
|
|
94
|
+
"node-added": null,
|
|
95
|
+
"on-node-click": null,
|
|
96
|
+
"add-root-node": null,
|
|
97
|
+
"create-new-node": null
|
|
98
|
+
},
|
|
99
|
+
data() {
|
|
100
|
+
return {
|
|
101
|
+
loading: !1,
|
|
102
|
+
showMenu: !1,
|
|
103
|
+
empty: !0,
|
|
104
|
+
expandedKeys: this.lazy ? [] : this.defaultExpandedKeys,
|
|
105
|
+
treeData: [],
|
|
106
|
+
curNode: {},
|
|
107
|
+
curData: {},
|
|
108
|
+
position: {},
|
|
109
|
+
text: "",
|
|
110
|
+
right: 4,
|
|
111
|
+
treeKey: Date.now()
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
computed: {
|
|
115
|
+
defaultOptions() {
|
|
116
|
+
return {
|
|
117
|
+
confirmButtonText: "确定",
|
|
118
|
+
cancelButtonText: "取消",
|
|
119
|
+
closeOnClickModal: !1,
|
|
120
|
+
modal: !0,
|
|
121
|
+
inputErrorMessage: `${this.label}名不能为空!`,
|
|
122
|
+
inputPlaceholder: `请输入${this.label}名...`,
|
|
123
|
+
inputValidator: (e) => e != null && e.trim().length > 0
|
|
124
|
+
};
|
|
125
|
+
},
|
|
126
|
+
innerTreeData() {
|
|
127
|
+
var e;
|
|
128
|
+
return (e = this.$attrs.data) != null && e.length ? this.$attrs.data : this.treeData;
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
watch: { defaultExpandedKeys: {
|
|
132
|
+
immediate: !0,
|
|
133
|
+
handler(e) {
|
|
134
|
+
this.expandedKeys = [...e];
|
|
135
|
+
}
|
|
136
|
+
} },
|
|
137
|
+
setup(t) {
|
|
138
|
+
return {
|
|
139
|
+
autoBind: n(t, { predicate: W }),
|
|
140
|
+
listeners: e({ removeOn: !0 })
|
|
141
|
+
};
|
|
142
|
+
},
|
|
143
|
+
created() {
|
|
144
|
+
this.tryFetch();
|
|
145
|
+
},
|
|
146
|
+
mounted() {
|
|
147
|
+
B(this.$refs.tree.$el, this.resize), B(this.$refs.treeWrapper, this.resize);
|
|
148
|
+
},
|
|
149
|
+
beforeUnmount() {
|
|
150
|
+
V(this.$refs.tree.$el, this.resize), V(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
|
+
m(this.$refs.treeWrapper) ? this.right = 4 + g : 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 = a(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
|
+
f(i) && (i = [i]), i = i || [];
|
|
180
|
+
let a = [];
|
|
181
|
+
if (this.empty = i.length === 0, f(this.customRootNode)) {
|
|
182
|
+
let e = I(this.customRootNode);
|
|
183
|
+
e[this.treeProps.children || "children"] = i, a = [e];
|
|
184
|
+
} else if (u(this.customRootNode)) {
|
|
185
|
+
let e = this.customRootNode(i);
|
|
186
|
+
e[this.treeProps.children || "children"] = i, a = f(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, f(this.customRootNode)) {
|
|
201
|
+
let e = I(this.customRootNode);
|
|
202
|
+
e[this.treeProps.children || "children"] = o, o = [e], t(o);
|
|
203
|
+
} else if (u(this.customRootNode)) {
|
|
204
|
+
let e = this.customRootNode(o);
|
|
205
|
+
e[this.treeProps.children || "children"] = o, o = f(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 && (p(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], p(t.edit), t.edit = !0, await this.$nextTick(), this.$refs.labelTxt.focus()) : await F.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 F.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 F.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 && h(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 || !d(this.text)) {
|
|
366
|
+
this.clear();
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
p(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 = s(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(), (p(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 o(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 c(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
|
+
}, K = { class: "editable-tree" }, q = {
|
|
438
|
+
ref: "treeWrapper",
|
|
439
|
+
class: "et-tree-wrapper"
|
|
440
|
+
}, J = {
|
|
441
|
+
key: 0,
|
|
442
|
+
style: { "padding-left": "24px" }
|
|
443
|
+
}, Y = ["data-id"], X = {
|
|
444
|
+
class: "node-label flex-row flex-item ellipsis-1",
|
|
445
|
+
style: { overflow: "hidden" }
|
|
446
|
+
}, Z = {
|
|
447
|
+
class: "flex-item-relative",
|
|
448
|
+
style: { height: "21px" }
|
|
449
|
+
}, Q = ["title"], $ = {
|
|
450
|
+
key: 0,
|
|
451
|
+
class: "handle-actions"
|
|
452
|
+
}, ee = {
|
|
453
|
+
key: 1,
|
|
454
|
+
class: "handle-actions",
|
|
455
|
+
style: { display: "inline-block" }
|
|
456
|
+
}, te = ["data-id"], ne = { class: "menu-list" };
|
|
457
|
+
function re(e, t, n, i, a, o) {
|
|
458
|
+
let s = r, c = R, l = L, u = z;
|
|
459
|
+
return D(), b("div", K, [!e.readonly && e.addRootNodeButtonStyle === "top-right" ? (D(), v(s, {
|
|
460
|
+
key: 0,
|
|
461
|
+
type: "primary",
|
|
462
|
+
style: E([{
|
|
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] = P((t) => e.$emit("add-root-node"), ["stop"]))
|
|
471
|
+
}, null, 8, ["style"])) : y("v-if", !0), x("div", q, [
|
|
472
|
+
!e.readonly && e.addRootNodeButtonStyle === "top" ? (D(), b("div", J, [C(s, {
|
|
473
|
+
disabled: a.loading,
|
|
474
|
+
type: "text",
|
|
475
|
+
onClick: o.appendRootNode
|
|
476
|
+
}, {
|
|
477
|
+
default: M(() => [t[8] || (t[8] = x("i", { class: "el-icon-lx-add" }, null, -1)), S(" " + k(e.addRootNodeLabel ? e.addRootNodeLabel : `添加${e.label}`), 1)]),
|
|
478
|
+
_: 1
|
|
479
|
+
}, 8, ["disabled", "onClick"])])) : y("v-if", !0),
|
|
480
|
+
(D(), v(u, w(i.autoBind, {
|
|
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
|
+
}, A(i.listeners), {
|
|
494
|
+
onNodeClick: o.nodeClick,
|
|
495
|
+
onNodeContextmenu: o.showContextMenu,
|
|
496
|
+
onNodeExpand: o.addExpandKey,
|
|
497
|
+
onNodeCollapse: o.removeExpandKey
|
|
498
|
+
}), {
|
|
499
|
+
default: M(({ node: n, data: r }) => [O(e.$slots, "default", {
|
|
500
|
+
node: n,
|
|
501
|
+
data: r
|
|
502
|
+
}, () => [y("非编辑模式"), r.edit ? (D(), b(_, { key: 1 }, [y("编辑模式"), x("span", {
|
|
503
|
+
"data-id": r.id,
|
|
504
|
+
class: "custom-tree-node flex-row flex-item",
|
|
505
|
+
style: { overflow: "hidden" }
|
|
506
|
+
}, [
|
|
507
|
+
e.icon ? (D(), b("i", {
|
|
508
|
+
key: 0,
|
|
509
|
+
class: T([r.loading ? "el-icon-loading" : "el-icon-edit-outline", "node-icon flex-not-shrink"])
|
|
510
|
+
}, null, 2)) : y("v-if", !0),
|
|
511
|
+
C(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] = P(() => {}, ["stop"]))
|
|
520
|
+
}, null, 8, [
|
|
521
|
+
"modelValue",
|
|
522
|
+
"placeholder",
|
|
523
|
+
"onKeyup",
|
|
524
|
+
"onBlur"
|
|
525
|
+
]),
|
|
526
|
+
e.confirmButton ? (D(), b(_, { key: 1 }, [N(C(s, {
|
|
527
|
+
class: "flex-not-shrink",
|
|
528
|
+
type: "text",
|
|
529
|
+
onClick: P((e) => o.onConfirm(n, r), ["stop"])
|
|
530
|
+
}, {
|
|
531
|
+
default: M(() => [...t[13] || (t[13] = [S(" 确定 ", -1)])]),
|
|
532
|
+
_: 1
|
|
533
|
+
}, 8, ["onClick"]), [[j, !r.loading]]), N(C(s, {
|
|
534
|
+
class: "flex-not-shrink",
|
|
535
|
+
type: "text",
|
|
536
|
+
onClick: P((e) => o.onCancel(n, r), ["stop"])
|
|
537
|
+
}, {
|
|
538
|
+
default: M(() => [...t[14] || (t[14] = [S(" 取消 ", -1)])]),
|
|
539
|
+
_: 1
|
|
540
|
+
}, 8, ["onClick"]), [[j, !r.loading]])], 64)) : y("v-if", !0)
|
|
541
|
+
], 8, te)], 64)) : (D(), b("span", {
|
|
542
|
+
key: 0,
|
|
543
|
+
"data-id": r.id,
|
|
544
|
+
class: "custom-tree-node"
|
|
545
|
+
}, [
|
|
546
|
+
x("span", X, [
|
|
547
|
+
e.icon ? (D(), b("i", {
|
|
548
|
+
key: 0,
|
|
549
|
+
class: T([r.loading ? "el-icon-loading" : e.icon(r, n), "node-icon"])
|
|
550
|
+
}, null, 2)) : y("v-if", !0),
|
|
551
|
+
x("span", Z, [x("span", {
|
|
552
|
+
class: "ellipsis-1 absolute-box et-tree-label",
|
|
553
|
+
title: n.label
|
|
554
|
+
}, [O(e.$slots, "label", {
|
|
555
|
+
data: r,
|
|
556
|
+
node: n
|
|
557
|
+
}, () => [S(k(n.label), 1)])], 8, Q)]),
|
|
558
|
+
O(e.$slots, "label-suffix", {
|
|
559
|
+
node: n,
|
|
560
|
+
data: r
|
|
561
|
+
})
|
|
562
|
+
]),
|
|
563
|
+
!e.contextMenu && !e.readonly ? N((D(), b("span", $, [
|
|
564
|
+
C(s, {
|
|
565
|
+
type: "text",
|
|
566
|
+
onClick: P((e) => o.appendChildNode(n, r), ["stop"])
|
|
567
|
+
}, {
|
|
568
|
+
default: M(() => [...t[9] || (t[9] = [S("添加", -1)])]),
|
|
569
|
+
_: 1
|
|
570
|
+
}, 8, ["onClick"]),
|
|
571
|
+
C(s, {
|
|
572
|
+
type: "text",
|
|
573
|
+
onClick: P((e) => o.editNode(n, r), ["stop"])
|
|
574
|
+
}, {
|
|
575
|
+
default: M(() => [...t[10] || (t[10] = [S("修改", -1)])]),
|
|
576
|
+
_: 1
|
|
577
|
+
}, 8, ["onClick"]),
|
|
578
|
+
C(c, {
|
|
579
|
+
class: "pop-confirm",
|
|
580
|
+
"icon-color": "red",
|
|
581
|
+
title: "你确定要删除吗?",
|
|
582
|
+
onConfirm: (e) => o.removeNode(n, r)
|
|
583
|
+
}, {
|
|
584
|
+
reference: M(() => [N(C(s, {
|
|
585
|
+
style: { "margin-left": "4px" },
|
|
586
|
+
type: "text",
|
|
587
|
+
onClick: t[1] || (t[1] = P(() => {}, ["stop"]))
|
|
588
|
+
}, {
|
|
589
|
+
default: M(() => [...t[11] || (t[11] = [S(" 删除 ", -1)])]),
|
|
590
|
+
_: 1
|
|
591
|
+
}, 512), [[j, n.isLeaf]])]),
|
|
592
|
+
_: 2
|
|
593
|
+
}, 1032, ["onConfirm"])
|
|
594
|
+
], 512)), [[j, !r.loading && !a.loading]]) : y("v-if", !0),
|
|
595
|
+
e.contextMenuIcon && e.contextMenu && !e.readonly ? N((D(), b("span", ee, [C(s, {
|
|
596
|
+
style: { padding: "6px 10px 0" },
|
|
597
|
+
type: "text",
|
|
598
|
+
onClick: P((e) => o.showContextMenu(e, r, n), ["stop"])
|
|
599
|
+
}, {
|
|
600
|
+
default: M(() => [...t[12] || (t[12] = [S(" . . . ", -1)])]),
|
|
601
|
+
_: 1
|
|
602
|
+
}, 8, ["onClick"])], 512)), [[j, !r.loading && !a.loading]]) : y("v-if", !0)
|
|
603
|
+
], 8, Y))])]),
|
|
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 ? N((D(), b("div", {
|
|
619
|
+
key: 1,
|
|
620
|
+
ref: "contextMenu",
|
|
621
|
+
style: E(a.position),
|
|
622
|
+
class: "menu"
|
|
623
|
+
}, [x("ul", ne, [O(e.$slots, "context-menu", {
|
|
624
|
+
curNode: a.curNode,
|
|
625
|
+
curData: a.curData
|
|
626
|
+
}, () => [
|
|
627
|
+
N(x("li", {
|
|
628
|
+
class: "menu-item",
|
|
629
|
+
onClick: t[4] || (t[4] = (e) => o.appendPeerNode(a.curNode, a.curData))
|
|
630
|
+
}, [t[15] || (t[15] = x("i", {
|
|
631
|
+
class: "menu-item-icon el-icon-lx-add",
|
|
632
|
+
style: { color: "#228b22" }
|
|
633
|
+
}, null, -1)), S(" " + k(e.menuLabel.appendPeer), 1)], 512), [[j, a.curData.id > -1]]),
|
|
634
|
+
x("li", {
|
|
635
|
+
class: "menu-item",
|
|
636
|
+
onClick: t[5] || (t[5] = (e) => o.appendChildNode(a.curNode, a.curData))
|
|
637
|
+
}, [t[16] || (t[16] = x("i", {
|
|
638
|
+
class: "menu-item-icon el-icon-lx-add",
|
|
639
|
+
style: { color: "#228b22" }
|
|
640
|
+
}, null, -1)), S(" " + k(e.menuLabel.appendChild), 1)]),
|
|
641
|
+
N(x("li", {
|
|
642
|
+
class: "menu-item",
|
|
643
|
+
onClick: t[6] || (t[6] = (e) => o.editNode(a.curNode, a.curData))
|
|
644
|
+
}, [t[17] || (t[17] = x("i", {
|
|
645
|
+
class: "menu-item-icon el-icon-edit-outline",
|
|
646
|
+
style: { color: "#ffa500" }
|
|
647
|
+
}, null, -1)), S(" " + k(e.menuLabel.editNode), 1)], 512), [[j, a.curData.id > -1]]),
|
|
648
|
+
N(x("li", {
|
|
649
|
+
class: "menu-item",
|
|
650
|
+
onClick: t[7] || (t[7] = (e) => o.removeNodeModal(a.curNode, a.curData))
|
|
651
|
+
}, [t[18] || (t[18] = x("i", {
|
|
652
|
+
class: "menu-item-icon el-icon-delete",
|
|
653
|
+
style: { color: "#f00" }
|
|
654
|
+
}, null, -1)), S(" " + k(e.menuLabel.removeNode), 1)], 512), [[j, a.curNode.isLeaf]])
|
|
655
|
+
])])], 4)), [[j, a.showMenu]]) : y("v-if", !0)
|
|
656
|
+
], 512)]);
|
|
657
|
+
}
|
|
658
|
+
var ie = /* @__PURE__ */ i(G, [["render", re]]);
|
|
659
|
+
//#endregion
|
|
660
|
+
export { ie as t };
|