@web-utils/component 2.0.10 → 2.0.12

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 (172) hide show
  1. package/dist/chunks/3d28cc08.js +57 -0
  2. package/dist/chunks/{41a066be.js → 44b78389.js} +8 -8
  3. package/dist/chunks/5d33812d.js +147 -0
  4. package/dist/chunks/{61ad06b2.js → 822300f3.js} +3 -3
  5. package/dist/chunks/9d848bf6.js +99 -0
  6. package/dist/chunks/a0bb327b.js +96 -0
  7. package/dist/chunks/a8891d2c.js +30 -0
  8. package/dist/chunks/c69d5628.js +248 -0
  9. package/dist/chunks/de9fe802.js +24 -0
  10. package/dist/chunks/{5a78e0db.js → e1939731.js} +6 -5
  11. package/dist/components/address-input/index.js +56 -43
  12. package/dist/components/address-input/style.css +15 -1
  13. package/dist/components/aside-menu/index.js +36 -30
  14. package/dist/components/aside-menu/style.css +9 -1
  15. package/dist/components/awesome-button/index.js +35 -32
  16. package/dist/components/base.css +66 -1
  17. package/dist/components/capsule-tab/index.js +33 -27
  18. package/dist/components/capsule-tab/style.css +32 -1
  19. package/dist/components/chunk-file-uploader/index.js +88 -54
  20. package/dist/components/chunk-file-uploader/style.css +4 -1
  21. package/dist/components/chunk-file-uploader-button/index.js +31 -25
  22. package/dist/components/chunk-file-uploader-button/style.css +17 -1
  23. package/dist/components/chunk-file-uploader-drop/index.js +42 -28
  24. package/dist/components/chunk-file-uploader-drop/style.css +12 -1
  25. package/dist/components/chunk-file-uploader-file/index.js +212 -134
  26. package/dist/components/chunk-file-uploader-file/style.css +125 -1
  27. package/dist/components/chunk-file-uploader-files/index.js +34 -28
  28. package/dist/components/chunk-file-uploader-files/style.css +9 -1
  29. package/dist/components/chunk-file-uploader-list/index.js +35 -29
  30. package/dist/components/chunk-file-uploader-list/style.css +9 -1
  31. package/dist/components/chunk-file-uploader-un-support/index.js +38 -30
  32. package/dist/components/chunk-file-uploader-un-support/style.css +6 -1
  33. package/dist/components/code-mirror-editor/index.js +181 -153
  34. package/dist/components/code-mirror-editor/style.css +17 -1
  35. package/dist/components/color-picker/index.js +68 -49
  36. package/dist/components/confirm-button/index.js +21 -19
  37. package/dist/components/confirmable/index.js +19 -18
  38. package/dist/components/context-menu/index.js +130 -108
  39. package/dist/components/context-menu/style.css +88 -1
  40. package/dist/components/custom-scrollbar/index.js +67 -49
  41. package/dist/components/data-table-picker/index.js +81 -62
  42. package/dist/components/dynamic-table/index.js +113 -89
  43. package/dist/components/dynamic-table/style.css +30 -1
  44. package/dist/components/e-charts/index.js +201 -120
  45. package/dist/components/e-charts/style.css +10 -1
  46. package/dist/components/editable-progress/index.js +93 -60
  47. package/dist/components/editable-progress/style.css +37 -1
  48. package/dist/components/editable-tree/index.js +638 -423
  49. package/dist/components/editable-tree/style.css +82 -1
  50. package/dist/components/egd-collapse/index.js +46 -33
  51. package/dist/components/egd-collapse-item/index.js +76 -60
  52. package/dist/components/element-dialog/index.js +147 -95
  53. package/dist/components/element-dialog/style.css +102 -1
  54. package/dist/components/empty-view/index.js +34 -28
  55. package/dist/components/empty-view/style.css +17 -1
  56. package/dist/components/error-view/index.js +32 -26
  57. package/dist/components/error-view/style.css +17 -1
  58. package/dist/components/flex-column/index.js +40 -25
  59. package/dist/components/flex-item/index.js +57 -29
  60. package/dist/components/flex-row/index.js +40 -25
  61. package/dist/components/flex-scroller/index.js +32 -26
  62. package/dist/components/flex-scroller/style.css +20 -1
  63. package/dist/components/form-button/index.js +38 -34
  64. package/dist/components/form-cascader/index.js +81 -71
  65. package/dist/components/form-checkbox-group/index.js +113 -88
  66. package/dist/components/form-checkbox-group/style.css +51 -1
  67. package/dist/components/form-date-picker/index.js +132 -70
  68. package/dist/components/form-holder/index.js +39 -32
  69. package/dist/components/form-input/index.js +62 -56
  70. package/dist/components/form-input-email/index.js +60 -48
  71. package/dist/components/form-input-id-card/index.js +59 -53
  72. package/dist/components/form-input-number/index.js +68 -61
  73. package/dist/components/form-input-number/style.css +12 -1
  74. package/dist/components/form-input-phone-number/index.js +55 -49
  75. package/dist/components/form-input-time/index.js +59 -53
  76. package/dist/components/form-item/index.js +123 -80
  77. package/dist/components/form-item/style.css +11 -1
  78. package/dist/components/form-item-config-provider/index.js +26 -25
  79. package/dist/components/form-item-group/index.js +111 -85
  80. package/dist/components/form-item-group/style.css +30 -1
  81. package/dist/components/form-radio-group/index.js +104 -85
  82. package/dist/components/form-radio-group/style.css +53 -1
  83. package/dist/components/form-select/index.js +91 -76
  84. package/dist/components/form-switch/index.js +57 -51
  85. package/dist/components/form-textarea/index.js +57 -51
  86. package/dist/components/form-view/index.js +232 -165
  87. package/dist/components/form-view/style.css +158 -1
  88. package/dist/components/guide-steps/index.js +58 -44
  89. package/dist/components/guide-steps/style.css +34 -1
  90. package/dist/components/icon-card/index.js +35 -29
  91. package/dist/components/icon-card/style.css +56 -1
  92. package/dist/components/iframe-window/index.js +35 -29
  93. package/dist/components/iframe-window/style.css +20 -1
  94. package/dist/components/image-viewer/index.js +66 -48
  95. package/dist/components/image-viewer/style.css +21 -1
  96. package/dist/components/input-number/index.js +193 -127
  97. package/dist/components/input-number/style.css +15 -1
  98. package/dist/components/input-number-range/index.js +57 -45
  99. package/dist/components/input-number-range/style.css +12 -1
  100. package/dist/components/j-s-x-component/index.js +4 -4
  101. package/dist/components/keep-view-alive/index.js +120 -73
  102. package/dist/components/loading-view/index.js +32 -26
  103. package/dist/components/loading-view/style.css +17 -1
  104. package/dist/components/nav-bar/index.js +37 -27
  105. package/dist/components/nav-bar/style.css +17 -1
  106. package/dist/components/not-implement/index.js +31 -23
  107. package/dist/components/not-implement/style.css +15 -1
  108. package/dist/components/page/index.js +28 -22
  109. package/dist/components/page/style.css +12 -1
  110. package/dist/components/page-header/index.js +36 -30
  111. package/dist/components/page-header/style.css +14 -1
  112. package/dist/components/page-index/index.js +83 -62
  113. package/dist/components/page-index/style.css +23 -1
  114. package/dist/components/page-index-top/index.js +68 -53
  115. package/dist/components/page-skeleton/index.js +37 -31
  116. package/dist/components/page-skeleton/style.css +23 -1
  117. package/dist/components/page-skeleton-new/index.js +48 -42
  118. package/dist/components/page-skeleton-new/style.css +42 -1
  119. package/dist/components/pageable-table/index.js +253 -186
  120. package/dist/components/pageable-table/style.css +72 -1
  121. package/dist/components/pageable-view/index.js +199 -129
  122. package/dist/components/pageable-view/style.css +69 -1
  123. package/dist/components/photo-swipe/index.js +151 -110
  124. package/dist/components/photo-swipe/style.css +20 -1
  125. package/dist/components/resize-observer/index.js +68 -34
  126. package/dist/components/resize-observer/style.css +31 -1
  127. package/dist/components/search-popover/index.js +211 -153
  128. package/dist/components/search-popover/style.css +93 -1
  129. package/dist/components/sign-panel/index.js +142 -92
  130. package/dist/components/sign-panel/style.css +97 -1
  131. package/dist/components/split-pane/index.js +162 -101
  132. package/dist/components/split-pane/style.css +100 -1
  133. package/dist/components/stateful/index.js +34 -31
  134. package/dist/components/stateful/style.css +33 -1
  135. package/dist/components/static-pageable-table/index.js +44 -37
  136. package/dist/components/static-pageable-table/style.css +9 -1
  137. package/dist/components/swiper/index.js +150 -85
  138. package/dist/components/swiper/style.css +43 -1
  139. package/dist/components/tab/index.js +72 -54
  140. package/dist/components/tab/style.css +122 -1
  141. package/dist/components/tab-item/index.js +35 -30
  142. package/dist/components/table-column/index.js +32 -30
  143. package/dist/components/table-view/index.js +227 -156
  144. package/dist/components/table-view/style.css +95 -1
  145. package/dist/components/tag-render/index.js +58 -44
  146. package/dist/components/tag-render/style.css +33 -1
  147. package/dist/components/tinymce-editor/index.js +95 -79
  148. package/dist/components/tinymce-editor/style.css +43 -1
  149. package/dist/components/tinymce-wrapper/index.js +121 -92
  150. package/dist/components/tinymce-wrapper/style.css +36 -1
  151. package/dist/components/toolbar/index.js +84 -63
  152. package/dist/components/toolbar/style.css +39 -1
  153. package/dist/components/toolbar-button/index.js +48 -41
  154. package/dist/components/toolbar-button/style.css +21 -1
  155. package/dist/components/trigger/index.js +36 -29
  156. package/dist/components/vue-tags-input/index.js +308 -188
  157. package/dist/components/vue-tags-input/style.css +682 -1
  158. package/dist/components/watermark/index.js +37 -25
  159. package/dist/components/watermark/style.css +11 -1
  160. package/dist/components/x-dialog/index.js +93 -67
  161. package/dist/components/x-dialog/style.css +15 -1
  162. package/dist/index.css +1105 -193
  163. package/dist/index.es.js +7242 -4789
  164. package/package.json +2 -2
  165. package/web-types.json +1 -1
  166. package/dist/chunks/3a79781b.js +0 -75
  167. package/dist/chunks/5d4282fb.js +0 -30
  168. package/dist/chunks/76680a03.js +0 -24
  169. package/dist/chunks/8c0142e0.js +0 -81
  170. package/dist/chunks/97652d86.js +0 -26
  171. package/dist/chunks/b4acd3a6.js +0 -126
  172. package/dist/chunks/f71045fc.js +0 -184
@@ -1,355 +1,365 @@
1
- import { hasOwn as d, addResizeListener as h, removeResizeListener as u, isVerticalScrollbarVisible as x, scrollbarWidth as w, computePosition as N, isPlainObject as r, cloneDeep as p, isFunction as f, isUndefined as l, isNotEmpty as C, fastClone as v, delay as g, findTreeChildren as $ } from "@web-utils/core";
2
- import { a as b, b as _, c } from "../../chunks/f71045fc.js";
3
- import { n as k } from "../../chunks/5d4282fb.js";
4
- var B = function() {
5
- var e = this, t = e.$createElement, i = e._self._c || t;
6
- return i("div", {
1
+ import { hasOwn, addResizeListener, removeResizeListener, isVerticalScrollbarVisible, scrollbarWidth, computePosition, isPlainObject, cloneDeep, isFunction, isUndefined, isNotEmpty, fastClone, delay, findTreeChildren } from "@web-utils/core";
2
+ import { a as filterTreeProperties, b as filterTreeEvents, c as assignReactiveProperties } from "../../chunks/c69d5628.js";
3
+ import { n as normalizeComponent } from "../../chunks/3d28cc08.js";
4
+ var render = function() {
5
+ var _vm = this;
6
+ var _h = _vm.$createElement;
7
+ var _c = _vm._self._c || _h;
8
+ return _c("div", {
7
9
  staticClass: "editable-tree"
8
- }, [!e.readonly && e.addRootNodeButtonStyle === "top-right" ? i("ElButton", {
10
+ }, [!_vm.readonly && _vm.addRootNodeButtonStyle === "top-right" ? _c("ElButton", {
9
11
  staticStyle: {
10
- position: "absolute",
11
- top: "4px",
12
+ "position": "absolute",
13
+ "top": "4px",
12
14
  "z-index": "1"
13
15
  },
14
16
  style: {
15
- right: `${e.right}px`
17
+ right: `${_vm.right}px`
16
18
  },
17
19
  attrs: {
18
- type: "primary",
19
- size: "mini",
20
- icon: "el-icon-plus",
21
- circle: "",
22
- plain: ""
20
+ "type": "primary",
21
+ "size": "mini",
22
+ "icon": "el-icon-plus",
23
+ "circle": "",
24
+ "plain": ""
23
25
  },
24
26
  on: {
25
- click: function(a) {
26
- return a.stopPropagation(), e.$emit("add-root-node");
27
+ "click": function($event) {
28
+ $event.stopPropagation();
29
+ return _vm.$emit("add-root-node");
27
30
  }
28
31
  }
29
- }) : e._e(), i("div", {
32
+ }) : _vm._e(), _c("div", {
30
33
  ref: "treeWrapper",
31
34
  staticClass: "et-tree-wrapper"
32
- }, [!e.readonly && e.addRootNodeButtonStyle === "top" ? i("div", {
35
+ }, [!_vm.readonly && _vm.addRootNodeButtonStyle === "top" ? _c("div", {
33
36
  staticStyle: {
34
37
  "padding-left": "24px"
35
38
  }
36
- }, [i("ElButton", {
39
+ }, [_c("ElButton", {
37
40
  attrs: {
38
- disabled: e.loading,
39
- size: "mini",
40
- type: "text"
41
+ "disabled": _vm.loading,
42
+ "size": "mini",
43
+ "type": "text"
41
44
  },
42
45
  on: {
43
- click: e.appendRootNode
46
+ "click": _vm.appendRootNode
44
47
  }
45
- }, [i("i", {
48
+ }, [_c("i", {
46
49
  staticClass: "el-icon-lx-add"
47
- }), e._v(" " + e._s(e.addRootNodeLabel ? e.addRootNodeLabel : `添加${e.label}`) + " ")])], 1) : e._e(), i("ElTree", e._g(e._b({
48
- key: e.treeKey,
50
+ }), _vm._v(" " + _vm._s(_vm.addRootNodeLabel ? _vm.addRootNodeLabel : `添加${_vm.label}`) + " ")])], 1) : _vm._e(), _c("ElTree", _vm._g(_vm._b({
51
+ key: _vm.treeKey,
49
52
  ref: "tree",
50
53
  staticClass: "flex-item",
51
54
  attrs: {
52
- "default-expanded-keys": e.expandedKeys,
53
- "expand-on-click-node": !1,
55
+ "default-expanded-keys": _vm.expandedKeys,
56
+ "expand-on-click-node": false,
54
57
  "highlight-current": "",
55
- load: e.loadNode,
56
- data: e.innerTreeData,
57
- props: e.treeProps,
58
- lazy: e.lazy,
59
- "node-key": e.nodeKey
58
+ "load": _vm.loadNode,
59
+ "data": _vm.innerTreeData,
60
+ "props": _vm.treeProps,
61
+ "lazy": _vm.lazy,
62
+ "node-key": _vm.nodeKey
60
63
  },
61
64
  on: {
62
- "node-click": e.nodeClick,
63
- "node-contextmenu": e.showContextMenu,
64
- "node-expand": e.addExpandKey,
65
- "node-collapse": e.removeExpandKey
65
+ "node-click": _vm.nodeClick,
66
+ "node-contextmenu": _vm.showContextMenu,
67
+ "node-expand": _vm.addExpandKey,
68
+ "node-collapse": _vm.removeExpandKey
66
69
  },
67
- scopedSlots: e._u([{
70
+ scopedSlots: _vm._u([{
68
71
  key: "default",
69
- fn: function(a) {
70
- var o = a.node, s = a.data;
71
- return [e._t("default", function() {
72
- return [s.edit ? [i("span", {
73
- staticClass: "custom-tree-node flex-row flex-item oh",
74
- attrs: {
75
- "data-id": s.id
76
- }
77
- }, [e.icon ? i("i", {
78
- staticClass: "node-icon shrink-0",
79
- class: s.loading ? "el-icon-loading" : "el-icon-edit-outline"
80
- }) : e._e(), i("ElInput", {
81
- ref: "labelTxt",
82
- staticClass: "node-input flex-item",
83
- attrs: {
84
- size: "mini",
85
- placeholder: e.defaultOptions.inputPlaceholder
86
- },
87
- on: {
88
- blur: function(n) {
89
- return e.inputBlur(n, o, s);
90
- }
91
- },
92
- nativeOn: {
93
- keyup: function(n) {
94
- return function(y) {
95
- return e.inputKeyup(y, o, s);
96
- }.apply(null, arguments);
97
- },
98
- click: function(n) {
99
- n.stopPropagation();
100
- }
101
- },
102
- model: {
103
- value: e.text,
104
- callback: function(n) {
105
- e.text = n;
106
- },
107
- expression: "text"
108
- }
109
- }), e.confirmButton ? [i("ElButton", {
110
- directives: [{
111
- name: "show",
112
- rawName: "v-show",
113
- value: !s.loading,
114
- expression: "!data.loading"
115
- }],
116
- staticClass: "shrink-0",
117
- attrs: {
118
- size: "mini",
119
- type: "text"
120
- },
121
- on: {
122
- click: function(n) {
123
- return n.stopPropagation(), e.onConfirm(o, s);
124
- }
125
- }
126
- }, [e._v("确定")]), i("ElButton", {
127
- directives: [{
128
- name: "show",
129
- rawName: "v-show",
130
- value: !s.loading,
131
- expression: "!data.loading"
132
- }],
133
- staticClass: "shrink-0",
134
- attrs: {
135
- size: "mini",
136
- type: "text"
137
- },
138
- on: {
139
- click: function(n) {
140
- return n.stopPropagation(), e.onCancel(o, s);
141
- }
142
- }
143
- }, [e._v("取消")])] : e._e()], 2)] : [i("span", {
72
+ fn: function(_ref) {
73
+ var node = _ref.node, data = _ref.data;
74
+ return [_vm._t("default", function() {
75
+ return [!data.edit ? [_c("span", {
144
76
  staticClass: "custom-tree-node",
145
77
  attrs: {
146
- "data-id": s.id
78
+ "data-id": data.id
147
79
  }
148
- }, [i("span", {
80
+ }, [_c("span", {
149
81
  staticClass: "node-label flex-row flex-item oh ellipsis-1"
150
- }, [e.icon ? i("i", {
82
+ }, [_vm.icon ? _c("i", {
151
83
  staticClass: "node-icon",
152
- class: s.loading ? "el-icon-loading" : e.icon(s, o)
153
- }) : e._e(), i("span", {
84
+ class: data.loading ? "el-icon-loading" : _vm.icon(data, node)
85
+ }) : _vm._e(), _c("span", {
154
86
  staticClass: "flex-item-relative",
155
87
  staticStyle: {
156
- height: "21px"
88
+ "height": "21px"
157
89
  }
158
- }, [i("span", {
90
+ }, [_c("span", {
159
91
  staticClass: "ellipsis-1 absolute-box et-tree-label",
160
92
  attrs: {
161
- title: o.label
93
+ "title": node.label
162
94
  }
163
- }, [e._t("label", function() {
164
- return [e._v(e._s(o.label))];
95
+ }, [_vm._t("label", function() {
96
+ return [_vm._v(_vm._s(node.label))];
165
97
  }, {
166
- data: s,
167
- node: o
168
- })], 2)]), e._t("label-suffix", null, {
169
- node: o,
170
- data: s
171
- })], 2), !e.contextMenu && !e.readonly ? i("span", {
98
+ "data": data,
99
+ "node": node
100
+ })], 2)]), _vm._t("label-suffix", null, {
101
+ "node": node,
102
+ "data": data
103
+ })], 2), !_vm.contextMenu && !_vm.readonly ? _c("span", {
172
104
  directives: [{
173
105
  name: "show",
174
106
  rawName: "v-show",
175
- value: !s.loading && !e.loading,
107
+ value: !data.loading && !_vm.loading,
176
108
  expression: "!data.loading && !loading"
177
109
  }],
178
110
  staticClass: "handle-actions"
179
- }, [i("ElButton", {
111
+ }, [_c("ElButton", {
180
112
  attrs: {
181
- size: "mini",
182
- type: "text"
113
+ "size": "mini",
114
+ "type": "text"
183
115
  },
184
116
  on: {
185
- click: function(n) {
186
- return n.stopPropagation(), e.appendChildNode(o, s);
117
+ "click": function($event) {
118
+ $event.stopPropagation();
119
+ return _vm.appendChildNode(node, data);
187
120
  }
188
121
  }
189
- }, [e._v("添加")]), i("ElButton", {
122
+ }, [_vm._v("添加")]), _c("ElButton", {
190
123
  attrs: {
191
- size: "mini",
192
- type: "text"
124
+ "size": "mini",
125
+ "type": "text"
193
126
  },
194
127
  on: {
195
- click: function(n) {
196
- return n.stopPropagation(), e.editNode(o, s);
128
+ "click": function($event) {
129
+ $event.stopPropagation();
130
+ return _vm.editNode(node, data);
197
131
  }
198
132
  }
199
- }, [e._v("修改")]), i("ElPopconfirm", {
133
+ }, [_vm._v("修改")]), _c("ElPopconfirm", {
200
134
  staticClass: "pop-confirm",
201
135
  attrs: {
202
136
  "icon-color": "red",
203
- title: "你确定要删除吗?"
137
+ "title": "你确定要删除吗?"
204
138
  },
205
139
  on: {
206
- confirm: function(n) {
207
- return e.removeNode(o, s);
140
+ "confirm": function($event) {
141
+ return _vm.removeNode(node, data);
208
142
  }
209
143
  },
210
- scopedSlots: e._u([{
144
+ scopedSlots: _vm._u([{
211
145
  key: "reference",
212
146
  fn: function() {
213
- return [i("ElButton", {
147
+ return [_c("ElButton", {
214
148
  directives: [{
215
149
  name: "show",
216
150
  rawName: "v-show",
217
- value: o.isLeaf,
151
+ value: node.isLeaf,
218
152
  expression: "node.isLeaf"
219
153
  }],
220
154
  staticStyle: {
221
155
  "margin-left": "4px"
222
156
  },
223
157
  attrs: {
224
- size: "mini",
225
- type: "text"
158
+ "size": "mini",
159
+ "type": "text"
226
160
  },
227
161
  on: {
228
- click: function(n) {
229
- n.stopPropagation();
162
+ "click": function($event) {
163
+ $event.stopPropagation();
230
164
  }
231
165
  }
232
- }, [e._v("删除")])];
166
+ }, [_vm._v("删除")])];
233
167
  },
234
- proxy: !0
235
- }], null, !0)
236
- })], 1) : e._e(), e.contextMenuIcon && e.contextMenu && !e.readonly ? i("span", {
168
+ proxy: true
169
+ }], null, true)
170
+ })], 1) : _vm._e(), _vm.contextMenuIcon && _vm.contextMenu && !_vm.readonly ? _c("span", {
237
171
  directives: [{
238
172
  name: "show",
239
173
  rawName: "v-show",
240
- value: !s.loading && !e.loading,
174
+ value: !data.loading && !_vm.loading,
241
175
  expression: "!data.loading && !loading"
242
176
  }],
243
177
  staticClass: "handle-actions",
244
178
  staticStyle: {
245
- display: "inline-block"
179
+ "display": "inline-block"
246
180
  }
247
- }, [i("ElButton", {
181
+ }, [_c("ElButton", {
248
182
  staticStyle: {
249
- padding: "6px 10px 0"
183
+ "padding": "6px 10px 0"
250
184
  },
251
185
  attrs: {
252
- size: "mini",
253
- type: "text"
186
+ "size": "mini",
187
+ "type": "text"
254
188
  },
255
189
  on: {
256
- click: function(n) {
257
- return n.stopPropagation(), e.showContextMenu(n, s, o);
190
+ "click": function($event) {
191
+ $event.stopPropagation();
192
+ return _vm.showContextMenu($event, data, node);
258
193
  }
259
194
  }
260
- }, [e._v(". . .")])], 1) : e._e()])]];
195
+ }, [_vm._v(". . .")])], 1) : _vm._e()])] : [_c("span", {
196
+ staticClass: "custom-tree-node flex-row flex-item oh",
197
+ attrs: {
198
+ "data-id": data.id
199
+ }
200
+ }, [_vm.icon ? _c("i", {
201
+ staticClass: "node-icon shrink-0",
202
+ class: data.loading ? "el-icon-loading" : "el-icon-edit-outline"
203
+ }) : _vm._e(), _c("ElInput", {
204
+ ref: "labelTxt",
205
+ staticClass: "node-input flex-item",
206
+ attrs: {
207
+ "size": "mini",
208
+ "placeholder": _vm.defaultOptions.inputPlaceholder
209
+ },
210
+ on: {
211
+ "blur": function(event) {
212
+ return _vm.inputBlur(event, node, data);
213
+ }
214
+ },
215
+ nativeOn: {
216
+ "keyup": function($event) {
217
+ return function(event) {
218
+ return _vm.inputKeyup(event, node, data);
219
+ }.apply(null, arguments);
220
+ },
221
+ "click": function($event) {
222
+ $event.stopPropagation();
223
+ }
224
+ },
225
+ model: {
226
+ value: _vm.text,
227
+ callback: function($$v) {
228
+ _vm.text = $$v;
229
+ },
230
+ expression: "text"
231
+ }
232
+ }), _vm.confirmButton ? [_c("ElButton", {
233
+ directives: [{
234
+ name: "show",
235
+ rawName: "v-show",
236
+ value: !data.loading,
237
+ expression: "!data.loading"
238
+ }],
239
+ staticClass: "shrink-0",
240
+ attrs: {
241
+ "size": "mini",
242
+ "type": "text"
243
+ },
244
+ on: {
245
+ "click": function($event) {
246
+ $event.stopPropagation();
247
+ return _vm.onConfirm(node, data);
248
+ }
249
+ }
250
+ }, [_vm._v("确定")]), _c("ElButton", {
251
+ directives: [{
252
+ name: "show",
253
+ rawName: "v-show",
254
+ value: !data.loading,
255
+ expression: "!data.loading"
256
+ }],
257
+ staticClass: "shrink-0",
258
+ attrs: {
259
+ "size": "mini",
260
+ "type": "text"
261
+ },
262
+ on: {
263
+ "click": function($event) {
264
+ $event.stopPropagation();
265
+ return _vm.onCancel(node, data);
266
+ }
267
+ }
268
+ }, [_vm._v("取消")])] : _vm._e()], 2)]];
261
269
  }, {
262
- node: o,
263
- data: s
270
+ "node": node,
271
+ "data": data
264
272
  })];
265
273
  }
266
- }], null, !0)
267
- }, "ElTree", e.filterTreeProperties(e.$attrs), !1), e.filterTreeEvents(e.$listeners))), e.contextMenu && !e.readonly ? i("div", {
274
+ }], null, true)
275
+ }, "ElTree", _vm.filterTreeProperties(_vm.$attrs), false), _vm.filterTreeEvents(_vm.$listeners))), _vm.contextMenu && !_vm.readonly ? _c("div", {
268
276
  directives: [{
269
277
  name: "show",
270
278
  rawName: "v-show",
271
- value: e.showMenu,
279
+ value: _vm.showMenu,
272
280
  expression: "showMenu"
273
281
  }],
274
282
  ref: "contextMenu",
275
283
  staticClass: "menu",
276
- style: e.position
277
- }, [i("ul", {
284
+ style: _vm.position
285
+ }, [_c("ul", {
278
286
  staticClass: "menu-list"
279
- }, [e._t("context-menu", function() {
280
- return [i("li", {
287
+ }, [_vm._t("context-menu", function() {
288
+ return [_c("li", {
281
289
  directives: [{
282
290
  name: "show",
283
291
  rawName: "v-show",
284
- value: e.curData.id > -1,
292
+ value: _vm.curData.id > -1,
285
293
  expression: "curData.id > -1"
286
294
  }],
287
295
  staticClass: "menu-item",
288
296
  on: {
289
- click: function(a) {
290
- return e.appendPeerNode(e.curNode, e.curData);
297
+ "click": function($event) {
298
+ return _vm.appendPeerNode(_vm.curNode, _vm.curData);
291
299
  }
292
300
  }
293
- }, [i("i", {
301
+ }, [_c("i", {
294
302
  staticClass: "menu-item-icon el-icon-lx-add",
295
303
  staticStyle: {
296
- color: "#228b22"
304
+ "color": "#228b22"
297
305
  }
298
- }), e._v(e._s(e.menuLabel.appendPeer) + " ")]), i("li", {
306
+ }), _vm._v(_vm._s(_vm.menuLabel.appendPeer) + " ")]), _c("li", {
299
307
  staticClass: "menu-item",
300
308
  on: {
301
- click: function(a) {
302
- return e.appendChildNode(e.curNode, e.curData);
309
+ "click": function($event) {
310
+ return _vm.appendChildNode(_vm.curNode, _vm.curData);
303
311
  }
304
312
  }
305
- }, [i("i", {
313
+ }, [_c("i", {
306
314
  staticClass: "menu-item-icon el-icon-lx-add",
307
315
  staticStyle: {
308
- color: "#228b22"
316
+ "color": "#228b22"
309
317
  }
310
- }), e._v(e._s(e.menuLabel.appendChild) + " ")]), i("li", {
318
+ }), _vm._v(_vm._s(_vm.menuLabel.appendChild) + " ")]), _c("li", {
311
319
  directives: [{
312
320
  name: "show",
313
321
  rawName: "v-show",
314
- value: e.curData.id > -1,
322
+ value: _vm.curData.id > -1,
315
323
  expression: "curData.id > -1"
316
324
  }],
317
325
  staticClass: "menu-item",
318
326
  on: {
319
- click: function(a) {
320
- return e.editNode(e.curNode, e.curData);
327
+ "click": function($event) {
328
+ return _vm.editNode(_vm.curNode, _vm.curData);
321
329
  }
322
330
  }
323
- }, [i("i", {
331
+ }, [_c("i", {
324
332
  staticClass: "menu-item-icon el-icon-edit-outline",
325
333
  staticStyle: {
326
- color: "#ffa500"
334
+ "color": "#ffa500"
327
335
  }
328
- }), e._v(e._s(e.menuLabel.editNode) + " ")]), i("li", {
336
+ }), _vm._v(_vm._s(_vm.menuLabel.editNode) + " ")]), _c("li", {
329
337
  directives: [{
330
338
  name: "show",
331
339
  rawName: "v-show",
332
- value: e.curNode.isLeaf,
340
+ value: _vm.curNode.isLeaf,
333
341
  expression: "curNode.isLeaf"
334
342
  }],
335
343
  staticClass: "menu-item",
336
344
  on: {
337
- click: function(a) {
338
- return e.removeNodeModal(e.curNode, e.curData);
345
+ "click": function($event) {
346
+ return _vm.removeNodeModal(_vm.curNode, _vm.curData);
339
347
  }
340
348
  }
341
- }, [i("i", {
349
+ }, [_c("i", {
342
350
  staticClass: "menu-item-icon el-icon-delete",
343
351
  staticStyle: {
344
- color: "#f00"
352
+ "color": "#f00"
345
353
  }
346
- }), e._v(e._s(e.menuLabel.removeNode) + " ")])];
354
+ }), _vm._v(_vm._s(_vm.menuLabel.removeNode) + " ")])];
347
355
  }, {
348
- curNode: e.curNode,
349
- curData: e.curData
350
- })], 2)]) : e._e()], 1)], 1);
351
- }, T = [];
352
- const M = {
356
+ "curNode": _vm.curNode,
357
+ "curData": _vm.curData
358
+ })], 2)]) : _vm._e()], 1)], 1);
359
+ };
360
+ var staticRenderFns = [];
361
+ const EditableTree_vue_vue_type_style_index_0_lang = "";
362
+ const __vue2_script = {
353
363
  name: "EditableTree",
354
364
  props: {
355
365
  label: {
@@ -365,19 +375,21 @@ const M = {
365
375
  },
366
376
  newNodeBuilder: {
367
377
  type: Function,
368
- default: (e, t) => ({
369
- name: e,
370
- parentId: t.id
371
- })
378
+ default: (name, parent) => {
379
+ return {
380
+ name,
381
+ parentId: parent.id
382
+ };
383
+ }
372
384
  },
373
385
  contextMenu: Boolean,
374
386
  lazy: {
375
387
  type: Boolean,
376
- default: !0
388
+ default: true
377
389
  },
378
390
  expandFirstNode: {
379
391
  type: Boolean,
380
- default: !0
392
+ default: true
381
393
  },
382
394
  readonly: Boolean,
383
395
  saveApi: {
@@ -405,11 +417,23 @@ const M = {
405
417
  contextMenuInline: Boolean,
406
418
  treeProps: {
407
419
  type: Object,
408
- default: () => ({
409
- children: "children",
410
- label: "name",
411
- isLeaf: (e) => d(e, "hasChildren") ? !e.hasChildren : d(e, "hasChild") ? !e.hasChild : d(e, "children") && e.children ? e.children.length === 0 : !0
412
- })
420
+ default: () => {
421
+ return {
422
+ children: "children",
423
+ label: "name",
424
+ isLeaf: (data) => {
425
+ if (hasOwn(data, "hasChildren")) {
426
+ return !data.hasChildren;
427
+ } else if (hasOwn(data, "hasChild")) {
428
+ return !data.hasChild;
429
+ } else if (hasOwn(data, "children") && data.children) {
430
+ return data.children.length === 0;
431
+ } else {
432
+ return true;
433
+ }
434
+ }
435
+ };
436
+ }
413
437
  },
414
438
  menuLabel: {
415
439
  type: Object,
@@ -422,11 +446,13 @@ const M = {
422
446
  },
423
447
  icon: {
424
448
  type: [Function, Boolean],
425
- default: () => "el-icon-collection-tag"
449
+ default: () => {
450
+ return "el-icon-collection-tag";
451
+ }
426
452
  },
427
453
  confirmButton: {
428
454
  type: Boolean,
429
- default: !0
455
+ default: true
430
456
  },
431
457
  addRootNodeButtonStyle: {
432
458
  type: String,
@@ -440,9 +466,9 @@ const M = {
440
466
  },
441
467
  data() {
442
468
  return {
443
- loading: !1,
444
- showMenu: !1,
445
- empty: !0,
469
+ loading: false,
470
+ showMenu: false,
471
+ empty: true,
446
472
  expandedKeys: this.lazy ? [] : this.defaultExpandedKeys,
447
473
  treeData: [],
448
474
  curNode: {},
@@ -458,23 +484,23 @@ const M = {
458
484
  return {
459
485
  confirmButtonText: "确定",
460
486
  cancelButtonText: "取消",
461
- closeOnClickModal: !1,
462
- modal: !0,
487
+ closeOnClickModal: false,
488
+ modal: true,
463
489
  inputErrorMessage: `${this.label}名不能为空!`,
464
490
  inputPlaceholder: `请输入${this.label}名...`,
465
- inputValidator: (e) => e != null && e.trim().length > 0
491
+ inputValidator: (value) => value != null && value.trim().length > 0
466
492
  };
467
493
  },
468
494
  innerTreeData() {
469
- var e;
470
- return (e = this.$attrs.data) != null && e.length ? this.$attrs.data : this.treeData;
495
+ var _a;
496
+ return ((_a = this.$attrs.data) == null ? void 0 : _a.length) ? this.$attrs.data : this.treeData;
471
497
  }
472
498
  },
473
499
  watch: {
474
500
  defaultExpandedKeys: {
475
- immediate: !0,
476
- handler(e) {
477
- this.expandedKeys = [...e];
501
+ immediate: true,
502
+ handler(newVal) {
503
+ this.expandedKeys = [...newVal];
478
504
  }
479
505
  }
480
506
  },
@@ -482,308 +508,497 @@ const M = {
482
508
  this.tryFetch();
483
509
  },
484
510
  mounted() {
485
- h(this.$refs.tree.$el, this.resize), h(this.$refs.treeWrapper, this.resize);
511
+ addResizeListener(this.$refs.tree.$el, this.resize);
512
+ addResizeListener(this.$refs.treeWrapper, this.resize);
486
513
  },
487
514
  beforeDestroy() {
488
- u(this.$refs.tree.$el, this.resize), u(this.$refs.treeWrapper, this.resize);
515
+ removeResizeListener(this.$refs.tree.$el, this.resize);
516
+ removeResizeListener(this.$refs.treeWrapper, this.resize);
489
517
  },
490
518
  methods: {
491
- filterTreeProperties: b,
492
- filterTreeEvents: _,
493
- addExpandKey(e) {
494
- this.reserveExpandKey && this.expandedKeys.push(e[this.nodeKey]);
519
+ filterTreeProperties,
520
+ filterTreeEvents,
521
+ addExpandKey(data) {
522
+ if (this.reserveExpandKey) {
523
+ this.expandedKeys.push(data[this.nodeKey]);
524
+ }
495
525
  },
496
- removeExpandKey(e) {
497
- this.reserveExpandKey && (this.expandedKeys = this.expandedKeys.filter((t) => t !== e[this.nodeKey]));
526
+ removeExpandKey(data) {
527
+ if (this.reserveExpandKey) {
528
+ this.expandedKeys = this.expandedKeys.filter((key) => key !== data[this.nodeKey]);
529
+ }
498
530
  },
499
531
  resize() {
500
- x(this.$refs.treeWrapper) ? this.right = 4 + w : this.right = 4;
532
+ if (isVerticalScrollbarVisible(this.$refs.treeWrapper)) {
533
+ this.right = 4 + scrollbarWidth;
534
+ } else {
535
+ this.right = 4;
536
+ }
501
537
  },
502
- async showContextMenu(e, t, i) {
503
- t.contextmenu === !1 || t.id === -1 || t.id === 0 || t.edit === !0 || this.contextMenu && (this.curNode = i, this.curData = t, this.showMenu = !0, this.$refs.tree.setCurrentKey(t.id), await this.$nextTick(), this.position = N(e, this.$refs.contextMenu), window.addEventListener("click", this.hideContextMenu));
538
+ async showContextMenu(event, data, node) {
539
+ if (data.contextmenu === false || data.id === -1 || data.id === 0 || data.edit === true) {
540
+ return;
541
+ }
542
+ if (this.contextMenu) {
543
+ this.curNode = node;
544
+ this.curData = data;
545
+ this.showMenu = true;
546
+ this.$refs.tree.setCurrentKey(data.id);
547
+ await this.$nextTick();
548
+ this.position = computePosition(event, this.$refs.contextMenu);
549
+ window.addEventListener("click", this.hideContextMenu);
550
+ }
504
551
  },
505
552
  hideContextMenu() {
506
- this.showMenu = !1, window.removeEventListener("click", this.hideContextMenu);
553
+ this.showMenu = false;
554
+ window.removeEventListener("click", this.hideContextMenu);
507
555
  },
508
556
  async tryFetch() {
509
- var e;
510
- if (this.lazy === !1 && this.fetchApi) {
511
- const t = await this.fetchApi(((e = this.rootNode) == null ? void 0 : e.id) ?? -1, {});
512
- if (r(t.data) && (t.data = [t.data]), t.data = t.data || [], this.empty = t.data.length === 0, r(this.customRootNode)) {
513
- const i = p(this.customRootNode);
514
- i[this.treeProps.children || "children"] = t.data, this.treeData = [i];
515
- } else if (f(this.customRootNode)) {
516
- const i = this.customRootNode(t.data);
517
- i[this.treeProps.children || "children"] = t.data, this.treeData = r(i) ? [i] : i;
518
- } else
519
- this.treeData = t.data;
520
- }
521
- },
522
- async loadNode(e, t) {
523
- var i, a, o;
524
- if (e.level === 0) {
525
- const s = await this.fetchApi(((i = this.rootNode) == null ? void 0 : i.id) ?? -1, e);
526
- if (this.empty = s.data.length === 0, r(this.customRootNode)) {
527
- const n = p(this.customRootNode);
528
- n[this.treeProps.children || "children"] = s.data, t([n]);
529
- } else if (f(this.customRootNode)) {
530
- const n = this.customRootNode(s.data);
531
- n[this.treeProps.children || "children"] = s.data, this.treeData = r(n) ? [n] : n;
532
- } else
533
- t(s.data);
534
- await this.$nextTick(), this.$emit("root-node-loaded", s.data), this.defaultExpandedKeys ? this.expandedKeys = [(a = s == null ? void 0 : s.data[0]) == null ? void 0 : a.id, ...this.defaultExpandedKeys] : this.expandFirstNode && (this.expandedKeys = [(o = s == null ? void 0 : s.data[0]) == null ? void 0 : o.id]);
557
+ var _a;
558
+ if (this.lazy === false && this.fetchApi) {
559
+ const res = await this.fetchApi(((_a = this.rootNode) == null ? void 0 : _a.id) ?? -1, {});
560
+ if (isPlainObject(res.data)) {
561
+ res.data = [res.data];
562
+ }
563
+ res.data = res.data || [];
564
+ this.empty = res.data.length === 0;
565
+ if (isPlainObject(this.customRootNode)) {
566
+ const data = cloneDeep(this.customRootNode);
567
+ data[this.treeProps.children || "children"] = res.data;
568
+ this.treeData = [data];
569
+ } else if (isFunction(this.customRootNode)) {
570
+ const data = this.customRootNode(res.data);
571
+ data[this.treeProps.children || "children"] = res.data;
572
+ this.treeData = isPlainObject(data) ? [data] : data;
573
+ } else {
574
+ this.treeData = res.data;
575
+ }
576
+ }
577
+ },
578
+ async loadNode(node, resolve) {
579
+ var _a, _b, _c;
580
+ if (node.level === 0) {
581
+ const res = await this.fetchApi(((_a = this.rootNode) == null ? void 0 : _a.id) ?? -1, node);
582
+ this.empty = res.data.length === 0;
583
+ if (isPlainObject(this.customRootNode)) {
584
+ const data = cloneDeep(this.customRootNode);
585
+ data[this.treeProps.children || "children"] = res.data;
586
+ resolve([data]);
587
+ } else if (isFunction(this.customRootNode)) {
588
+ const data = this.customRootNode(res.data);
589
+ data[this.treeProps.children || "children"] = res.data;
590
+ this.treeData = isPlainObject(data) ? [data] : data;
591
+ } else {
592
+ resolve(res.data);
593
+ }
594
+ await this.$nextTick();
595
+ this.$emit("root-node-loaded", res.data);
596
+ if (this.defaultExpandedKeys) {
597
+ this.expandedKeys = [(_b = res == null ? void 0 : res.data[0]) == null ? void 0 : _b.id, ...this.defaultExpandedKeys];
598
+ } else {
599
+ if (this.expandFirstNode) {
600
+ this.expandedKeys = [(_c = res == null ? void 0 : res.data[0]) == null ? void 0 : _c.id];
601
+ }
602
+ }
535
603
  } else {
536
- if (e.leaf || e.data.isTempNode)
537
- return t([]);
538
- const s = await this.fetchApi(e.data.id, e);
539
- t(s.data), await this.$nextTick(), this.$emit("node-loaded", s.data);
604
+ if (node.leaf || node.data.isTempNode) {
605
+ return resolve([]);
606
+ }
607
+ const res = await this.fetchApi(node.data.id, node);
608
+ resolve(res.data);
609
+ await this.$nextTick();
610
+ this.$emit("node-loaded", res.data);
540
611
  }
541
612
  },
542
613
  clear() {
543
- this.cancelEdit(), this.removeNewNode();
614
+ this.cancelEdit();
615
+ this.removeNewNode();
544
616
  },
545
617
  clearChecked() {
546
618
  this.$refs.tree.setCheckedKeys([]);
547
619
  },
548
620
  removeNewNode() {
549
- this.newChild && this.newChild.id === -1 && (console.log(this.newChild), this.$refs.tree.remove(this.newChild), this.$emit("remove-new-node"));
621
+ if (this.newChild && this.newChild.id === -1) {
622
+ console.log(this.newChild);
623
+ this.$refs.tree.remove(this.newChild);
624
+ this.$emit("remove-new-node");
625
+ }
550
626
  },
551
627
  cancelEdit() {
552
- this.editData && (l(this.editData.edit) ? this.$set(this.editData, "edit", !0) : this.editData.edit = !1);
553
- },
554
- async editNode(e, t) {
555
- !this.contextMenu || this.contextMenuIcon || this.contextMenuInline ? (this.clear(), this.editData = t, this.text = t[this.treeProps.label], l(t.edit) ? this.$set(t, "edit", !0) : t.edit = !0, await this.$nextTick(), this.$refs.labelTxt.focus()) : await this.$prompt(`请输入新的${this.label}名:`, {
556
- ...this.defaultOptions,
557
- inputValue: t[this.treeProps.label],
558
- beforeClose: async (i, a, o) => {
559
- if (i === "confirm") {
560
- try {
561
- a.confirmButtonLoading = !0, a.confirmButtonText = "处理中...", this.text = a.inputValue, await this.onConfirm(this.curNode, this.curData), o();
562
- } catch {
563
- a.confirmButtonText = "确定";
564
- }
565
- a.confirmButtonLoading = !1;
566
- } else
567
- o();
628
+ if (this.editData) {
629
+ if (isUndefined(this.editData.edit)) {
630
+ this.$set(this.editData, "edit", true);
631
+ } else {
632
+ this.editData.edit = false;
568
633
  }
569
- }).catch((i) => i);
634
+ }
570
635
  },
571
- async appendRootNode() {
572
- 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 this.$prompt(`请输入${this.label}名:`, {
573
- ...this.defaultOptions,
574
- beforeClose: async (e, t, i) => {
575
- if (e === "confirm") {
576
- try {
577
- this.createNewChild(-1), t.confirmButtonLoading = !0, t.confirmButtonText = "处理中...";
578
- const a = await this.saveApi(this.newNodeBuilder(t.inputValue, { id: -1 }));
579
- this.newChild[this.treeProps.label] = t.inputValue, this.newChild.edit = !1, c(this.newChild, a.data), this.$refs.tree.root.insertChild({ data: this.newChild }, void 0, !0), await this.locateView(), i();
580
- } catch {
581
- t.confirmButtonText = "确定";
582
- }
583
- t.confirmButtonLoading = !1;
584
- } else
585
- i();
636
+ async editNode(node, data) {
637
+ if (!this.contextMenu || this.contextMenuIcon || this.contextMenuInline) {
638
+ this.clear();
639
+ this.editData = data;
640
+ this.text = data[this.treeProps.label];
641
+ if (isUndefined(data.edit)) {
642
+ this.$set(data, "edit", true);
643
+ } else {
644
+ data.edit = true;
586
645
  }
587
- }).catch((e) => e);
646
+ await this.$nextTick();
647
+ this.$refs.labelTxt.focus();
648
+ } else {
649
+ await this.$prompt(`请输入新的${this.label}名:`, {
650
+ ...this.defaultOptions,
651
+ inputValue: data[this.treeProps.label],
652
+ beforeClose: async (action, instance, done) => {
653
+ if (action === "confirm") {
654
+ try {
655
+ instance.confirmButtonLoading = true;
656
+ instance.confirmButtonText = "处理中...";
657
+ this.text = instance.inputValue;
658
+ await this.onConfirm(this.curNode, this.curData);
659
+ done();
660
+ } catch (e) {
661
+ instance.confirmButtonText = "确定";
662
+ }
663
+ instance.confirmButtonLoading = false;
664
+ } else {
665
+ done();
666
+ }
667
+ }
668
+ }).catch((_) => _);
669
+ }
588
670
  },
589
- appendChildNode(e) {
671
+ async appendRootNode() {
590
672
  this.text = "";
591
- const t = e.expanded;
592
- e.expand(async () => {
593
- !this.contextMenu || this.contextMenuIcon || this.contextMenuInline ? (this.clear(), this.createNewChild(e.data.id), this.$refs.tree.append(this.newChild, e), await this.scrollIntoView(t)) : await this.$prompt(`请输入${this.label}名:`, {
673
+ if (!this.contextMenu || this.contextMenuIcon || this.contextMenuInline) {
674
+ this.clear();
675
+ this.createNewChild(void 0);
676
+ this.$refs.tree.root.insertChild({ data: this.newChild }, void 0, true);
677
+ await this.scrollIntoView(true);
678
+ } else {
679
+ await this.$prompt(`请输入${this.label}名:`, {
594
680
  ...this.defaultOptions,
595
- beforeClose: async (i, a, o) => {
596
- if (i === "confirm") {
681
+ beforeClose: async (action, instance, done) => {
682
+ if (action === "confirm") {
597
683
  try {
598
- this.createNewChild(e.data.id), a.confirmButtonLoading = !0, a.confirmButtonText = "处理中...";
599
- const s = await this.saveApi(this.newNodeBuilder(a.inputValue, e.data));
600
- this.newChild[this.treeProps.label] = a.inputValue, this.newChild.edit = !1, c(this.newChild, s.data), this.$refs.tree.append(this.newChild, e), await this.locateView(), o();
601
- } catch {
602
- a.confirmButtonText = "确定";
684
+ this.createNewChild(-1);
685
+ instance.confirmButtonLoading = true;
686
+ instance.confirmButtonText = "处理中...";
687
+ const res = await this.saveApi(this.newNodeBuilder(instance.inputValue, { id: -1 }));
688
+ this.newChild[this.treeProps.label] = instance.inputValue;
689
+ this.newChild.edit = false;
690
+ assignReactiveProperties(this.newChild, res.data);
691
+ this.$refs.tree.root.insertChild({ data: this.newChild }, void 0, true);
692
+ await this.locateView();
693
+ done();
694
+ } catch (e) {
695
+ instance.confirmButtonText = "确定";
603
696
  }
604
- a.confirmButtonLoading = !1;
605
- } else
606
- o();
697
+ instance.confirmButtonLoading = false;
698
+ } else {
699
+ done();
700
+ }
607
701
  }
608
- }).catch((i) => i);
702
+ }).catch((_) => _);
703
+ }
704
+ },
705
+ appendChildNode(node) {
706
+ this.text = "";
707
+ const expanded = node.expanded;
708
+ node.expand(async () => {
709
+ if (!this.contextMenu || this.contextMenuIcon || this.contextMenuInline) {
710
+ this.clear();
711
+ this.createNewChild(node.data.id);
712
+ this.$refs.tree.append(this.newChild, node);
713
+ await this.scrollIntoView(expanded);
714
+ } else {
715
+ await this.$prompt(`请输入${this.label}名:`, {
716
+ ...this.defaultOptions,
717
+ beforeClose: async (action, instance, done) => {
718
+ if (action === "confirm") {
719
+ try {
720
+ this.createNewChild(node.data.id);
721
+ instance.confirmButtonLoading = true;
722
+ instance.confirmButtonText = "处理中...";
723
+ const res = await this.saveApi(this.newNodeBuilder(instance.inputValue, node.data));
724
+ this.newChild[this.treeProps.label] = instance.inputValue;
725
+ this.newChild.edit = false;
726
+ assignReactiveProperties(this.newChild, res.data);
727
+ this.$refs.tree.append(this.newChild, node);
728
+ await this.locateView();
729
+ done();
730
+ } catch (e) {
731
+ instance.confirmButtonText = "确定";
732
+ }
733
+ instance.confirmButtonLoading = false;
734
+ } else {
735
+ done();
736
+ }
737
+ }
738
+ }).catch((_) => _);
739
+ }
609
740
  });
610
741
  },
611
- appendChildNodeWithData(e, t, i) {
742
+ appendChildNodeWithData(node, parentId, label) {
612
743
  this.text = "";
613
- const a = e.expanded;
614
- e.expand(async () => {
615
- this.clear(), this.newChild = {
744
+ const expanded = node.expanded;
745
+ node.expand(async () => {
746
+ this.clear();
747
+ this.newChild = {
616
748
  id: -1,
617
- parentId: t,
618
- [this.treeProps.label]: i,
619
- edit: !1,
620
- isTempNode: !0,
621
- hasChildren: !1
622
- }, this.$refs.tree.append(this.newChild, e), await this.scrollIntoView(a);
749
+ parentId,
750
+ [this.treeProps.label]: label,
751
+ edit: false,
752
+ isTempNode: true,
753
+ hasChildren: false
754
+ };
755
+ this.$refs.tree.append(this.newChild, node);
756
+ await this.scrollIntoView(expanded);
623
757
  });
624
758
  },
625
- appendPeerNode(e) {
626
- e.parent && e.parent.level !== 0 ? this.appendChildNode(e.parent) : this.appendRootNode();
627
- },
628
- async addRootNode(e) {
629
- this.$refs.tree.remove(e), await this.$nextTick(), this.$refs.tree.root.insertChild({ data: e }, void 0, !0);
759
+ appendPeerNode(node) {
760
+ if (node.parent && node.parent.level !== 0) {
761
+ this.appendChildNode(node.parent);
762
+ } else {
763
+ this.appendRootNode();
764
+ }
630
765
  },
631
- async addChildNode(e) {
632
- this.curNode && this.curNode.level !== 0 ? this.curNode.expand(async () => {
633
- this.$refs.tree.remove(e), await this.$nextTick(), this.$refs.tree.append(e, this.curNode);
634
- }) : await this.addRootNode(e);
766
+ async addRootNode(data) {
767
+ this.$refs.tree.remove(data);
768
+ await this.$nextTick();
769
+ this.$refs.tree.root.insertChild({ data }, void 0, true);
770
+ },
771
+ async addChildNode(data) {
772
+ if (this.curNode && this.curNode.level !== 0) {
773
+ this.curNode.expand(async () => {
774
+ this.$refs.tree.remove(data);
775
+ await this.$nextTick();
776
+ this.$refs.tree.append(data, this.curNode);
777
+ });
778
+ } else {
779
+ await this.addRootNode(data);
780
+ }
635
781
  },
636
- async addPeerNode(e) {
637
- this.curNode && this.curNode.parent && this.curNode.parent.level !== 0 ? this.curNode.parent.expand(async () => {
638
- this.$refs.tree.remove(e), await this.$nextTick(), this.$refs.tree.append(e, this.curNode.parent);
639
- }) : await this.addRootNode(e);
782
+ async addPeerNode(data) {
783
+ if (this.curNode && this.curNode.parent && this.curNode.parent.level !== 0) {
784
+ this.curNode.parent.expand(async () => {
785
+ this.$refs.tree.remove(data);
786
+ await this.$nextTick();
787
+ this.$refs.tree.append(data, this.curNode.parent);
788
+ });
789
+ } else {
790
+ await this.addRootNode(data);
791
+ }
640
792
  },
641
- updateNode(e) {
642
- const t = this.$refs.tree.getNode(e);
643
- t && (t.data = e);
793
+ updateNode(data) {
794
+ const node = this.$refs.tree.getNode(data);
795
+ node && (node.data = data);
644
796
  },
645
- setCurrentKey(e) {
646
- this.$refs.tree && this.$refs.tree.setCurrentKey(e);
797
+ setCurrentKey(key) {
798
+ this.$refs.tree && this.$refs.tree.setCurrentKey(key);
647
799
  },
648
- createNewChild(e) {
800
+ createNewChild(parentId) {
649
801
  this.newChild = {
650
802
  id: -1,
651
- parentId: e,
803
+ parentId,
652
804
  [this.treeProps.label]: "",
653
- edit: !0,
654
- isTempNode: !0,
655
- hasChildren: !1
656
- }, this.$emit("create-new-node", this.newChild);
805
+ edit: true,
806
+ isTempNode: true,
807
+ hasChildren: false
808
+ };
809
+ this.$emit("create-new-node", this.newChild);
657
810
  },
658
- async removeNodeModal(e) {
811
+ async removeNodeModal(node) {
659
812
  await this.$confirm(
660
- `你确定要删除${this.label}[<span class="break-word" style="color: orange">${e.data[this.treeProps.label]}</span>]吗?`,
813
+ `你确定要删除${this.label}[<span class="break-word" style="color: orange">${node.data[this.treeProps.label]}</span>]吗?`,
661
814
  "系统提示",
662
815
  {
663
816
  type: "warning",
664
- modal: !0,
665
- dangerouslyUseHTMLString: !0,
817
+ modal: true,
818
+ dangerouslyUseHTMLString: true,
666
819
  iconClass: "el-icon-question",
667
- closeOnClickModal: !1,
820
+ closeOnClickModal: false,
668
821
  confirmButtonClass: "el-button--danger",
669
822
  cancelButtonClass: "el-button--primary is-plain",
670
- beforeClose: async (t, i, a) => {
671
- if (t === "confirm") {
823
+ beforeClose: async (action, instance, done) => {
824
+ if (action === "confirm") {
672
825
  try {
673
- i.confirmButtonLoading = !0, i.confirmButtonText = "删除...";
674
- const o = e.parent, s = await this.deleteApi(e.data.id);
675
- s.code === 0 ? (this.$message.success("删除成功!"), this.$refs.tree.remove(e), this.$emit("node-deleted", o, e.data), a()) : this.$message.error(s.message);
676
- } catch {
826
+ instance.confirmButtonLoading = true;
827
+ instance.confirmButtonText = "删除...";
828
+ const parentNode = node.parent;
829
+ const res = await this.deleteApi(node.data.id);
830
+ if (res.code === 0) {
831
+ this.$message.success("删除成功!");
832
+ this.$refs.tree.remove(node);
833
+ this.$emit("node-deleted", parentNode, node.data);
834
+ done();
835
+ } else {
836
+ this.$message.error(res.message);
837
+ }
838
+ } catch (_) {
677
839
  }
678
- i.confirmButtonText = "确定", i.confirmButtonLoading = !1;
679
- } else
680
- a();
840
+ instance.confirmButtonText = "确定";
841
+ instance.confirmButtonLoading = false;
842
+ } else {
843
+ done();
844
+ }
681
845
  }
682
846
  }
683
- ).catch((t) => t);
847
+ ).catch((_) => _);
684
848
  },
685
- async removeNode(e) {
849
+ async removeNode(node) {
686
850
  try {
687
- const t = e.parent;
851
+ const parentNode = node.parent;
688
852
  if (this.deleteApi) {
689
- const i = await this.deleteApi(e.data.id);
690
- i.code === 0 ? (this.$message.success("删除成功!"), this.$refs.tree.remove(e), this.$emit("node-deleted", t, e.data)) : this.$message.error(i.message);
691
- } else
692
- this.$refs.tree.remove(e);
693
- } catch {
853
+ const res = await this.deleteApi(node.data.id);
854
+ if (res.code === 0) {
855
+ this.$message.success("删除成功!");
856
+ this.$refs.tree.remove(node);
857
+ this.$emit("node-deleted", parentNode, node.data);
858
+ } else {
859
+ this.$message.error(res.message);
860
+ }
861
+ } else {
862
+ this.$refs.tree.remove(node);
863
+ }
864
+ } catch (e) {
694
865
  }
695
866
  },
696
- async onConfirm(e, t) {
697
- if (t[this.treeProps.label] === this.text || !C(this.text)) {
867
+ async onConfirm(node, data) {
868
+ if (data[this.treeProps.label] === this.text || !isNotEmpty(this.text)) {
698
869
  this.clear();
699
870
  return;
700
871
  }
701
- l(t.loading) ? this.$set(t, "loading", !0) : t.loading = !0;
872
+ if (isUndefined(data.loading)) {
873
+ this.$set(data, "loading", true);
874
+ } else {
875
+ data.loading = true;
876
+ }
702
877
  try {
703
- if (this.loading = !0, t.id === -1) {
704
- const i = await this.saveApi(this.newNodeBuilder(this.text, e.parent.data || { id: -1 })), a = v(t);
705
- c(t, { ...i.data, isTempNode: !1 }), this.$emit("node-added", t, a, e), this.registerNode(e);
706
- } else
707
- await this.updateApi({ ...t, [this.treeProps.label]: this.text });
708
- t[this.treeProps.label] = this.text, t.edit = !1, this.$emit("node-updated", t, e), this.text = "";
709
- } catch {
878
+ this.loading = true;
879
+ if (data.id === -1) {
880
+ const res = await this.saveApi(this.newNodeBuilder(this.text, node.parent.data || { id: -1 }));
881
+ const old = fastClone(data);
882
+ assignReactiveProperties(data, { ...res.data, isTempNode: false });
883
+ this.$emit("node-added", data, old, node);
884
+ this.registerNode(node);
885
+ } else {
886
+ await this.updateApi({ ...data, [this.treeProps.label]: this.text });
887
+ }
888
+ data[this.treeProps.label] = this.text;
889
+ data.edit = false;
890
+ this.$emit("node-updated", data, node);
891
+ this.text = "";
892
+ } catch (e) {
710
893
  }
711
- t.loading = !1, this.loading = !1;
894
+ data.loading = false;
895
+ this.loading = false;
712
896
  },
713
- onCancel(e, t) {
714
- t.id === -1 ? this.$refs.tree.remove(e) : t.edit = !1, this.text = "";
897
+ onCancel(node, data) {
898
+ if (data.id === -1) {
899
+ this.$refs.tree.remove(node);
900
+ } else {
901
+ data.edit = false;
902
+ }
903
+ this.text = "";
715
904
  },
716
- nodeClick(e, t, i) {
717
- this.hideContextMenu(), (l(e.loading) || !e.loading) && (this.curNode = t, this.curData = e, this.$emit("on-node-click", e, t, i));
905
+ nodeClick(data, node, tree) {
906
+ this.hideContextMenu();
907
+ if (isUndefined(data.loading) || !data.loading) {
908
+ this.curNode = node;
909
+ this.curData = data;
910
+ this.$emit("on-node-click", data, node, tree);
911
+ }
718
912
  },
719
913
  getCurrentNode() {
720
914
  return this.$refs.tree.getCurrentNode();
721
915
  },
722
916
  async locateView() {
723
917
  await this.$nextTick();
724
- const e = this.$el.querySelector(`[data-id="${this.newChild.id}"]`);
725
- e && e.scrollIntoView();
918
+ const el = this.$el.querySelector(`[data-id="${this.newChild.id}"]`);
919
+ if (el) {
920
+ el.scrollIntoView();
921
+ }
726
922
  },
727
- async scrollIntoView(e) {
728
- var t, i;
729
- await this.$nextTick(), e || await g(300), (i = (t = this.$refs) == null ? void 0 : t.labelTxt) == null || i.focus();
923
+ async scrollIntoView(expanded) {
924
+ var _a, _b;
925
+ await this.$nextTick();
926
+ if (!expanded) {
927
+ await delay(300);
928
+ }
929
+ (_b = (_a = this.$refs) == null ? void 0 : _a.labelTxt) == null ? void 0 : _b.focus();
730
930
  },
731
- inputKeyup(e, t, i) {
732
- e.keyCode === 13 && this.onConfirm(t, i), e.keyCode === 27 && this.clear();
931
+ inputKeyup(event, node, data) {
932
+ if (event.keyCode === 13) {
933
+ this.onConfirm(node, data);
934
+ }
935
+ if (event.keyCode === 27) {
936
+ this.clear();
937
+ }
733
938
  },
734
- inputBlur(e, t, i) {
735
- this.confirmButton || this.onConfirm(t, i);
939
+ inputBlur(event, node, data) {
940
+ if (this.confirmButton) {
941
+ return;
942
+ }
943
+ this.onConfirm(node, data);
736
944
  },
737
945
  getCheckedKeys() {
738
946
  return this.$refs.tree.getCheckedKeys();
739
947
  },
740
- setCheckedKeys(e) {
741
- this.$refs.tree.setCheckedKeys(e);
948
+ setCheckedKeys(keys) {
949
+ this.$refs.tree.setCheckedKeys(keys);
742
950
  },
743
951
  getCheckedNodes() {
744
952
  return this.$refs.tree.getCheckedNodes();
745
953
  },
746
- setCheckedNodes(e) {
747
- this.$refs.tree.setCheckedNodes(e);
954
+ setCheckedNodes(nodes) {
955
+ this.$refs.tree.setCheckedNodes(nodes);
748
956
  },
749
- getNode(e) {
750
- return this.$refs.tree.getNode(e);
957
+ getNode(data) {
958
+ return this.$refs.tree.getNode(data);
751
959
  },
752
960
  getRootNode() {
753
961
  return this.$refs.tree.root;
754
962
  },
755
- findTreeNode(e) {
756
- return $(
963
+ findTreeNode(data) {
964
+ return findTreeChildren(
757
965
  this.$refs.tree.root.childNodes,
758
- (t) => t.data === e || t.data.id === e,
966
+ (node) => node.data === data || node.data.id === data,
759
967
  "childNodes"
760
968
  );
761
969
  },
762
- registerNode(e) {
763
- e.store.registerNode(e), delete e.store.nodesMap[-1];
970
+ registerNode(node) {
971
+ node.store.registerNode(node);
972
+ delete node.store.nodesMap[-1];
764
973
  },
765
974
  async reloadTree() {
766
- this.lazy ? this.treeKey = Date.now() : await this.tryFetch();
975
+ if (this.lazy) {
976
+ this.treeKey = Date.now();
977
+ } else {
978
+ await this.tryFetch();
979
+ }
767
980
  }
768
981
  }
769
- }, m = {};
770
- var K = /* @__PURE__ */ k(
771
- M,
772
- B,
773
- T,
774
- !1,
775
- P,
982
+ };
983
+ const __cssModules = {};
984
+ var __component__ = /* @__PURE__ */ normalizeComponent(
985
+ __vue2_script,
986
+ render,
987
+ staticRenderFns,
988
+ false,
989
+ __vue2_injectStyles,
776
990
  null,
777
991
  null,
778
992
  null
779
993
  );
780
- function P(e) {
781
- for (let t in m)
782
- this[t] = m[t];
994
+ function __vue2_injectStyles(context) {
995
+ for (let o in __cssModules) {
996
+ this[o] = __cssModules[o];
997
+ }
783
998
  }
784
- const R = /* @__PURE__ */ function() {
785
- return K.exports;
999
+ const EditableTree = /* @__PURE__ */ function() {
1000
+ return __component__.exports;
786
1001
  }();
787
1002
  export {
788
- R as default
1003
+ EditableTree as default
789
1004
  };