1 | module.exports =
|
2 | (function(modules) {
|
3 |
|
4 | var installedModules = {};
|
5 |
|
6 |
|
7 | function __webpack_require__(moduleId) {
|
8 |
|
9 |
|
10 | if(installedModules[moduleId]) {
|
11 | return installedModules[moduleId].exports;
|
12 | }
|
13 |
|
14 | var module = installedModules[moduleId] = {
|
15 | i: moduleId,
|
16 | l: false,
|
17 | exports: {}
|
18 | };
|
19 |
|
20 |
|
21 | modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
22 |
|
23 |
|
24 | module.l = true;
|
25 |
|
26 |
|
27 | return module.exports;
|
28 | }
|
29 |
|
30 |
|
31 |
|
32 | __webpack_require__.m = modules;
|
33 |
|
34 |
|
35 | __webpack_require__.c = installedModules;
|
36 |
|
37 |
|
38 | __webpack_require__.d = function(exports, name, getter) {
|
39 | if(!__webpack_require__.o(exports, name)) {
|
40 | Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
41 | }
|
42 | };
|
43 |
|
44 |
|
45 | __webpack_require__.r = function(exports) {
|
46 | if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
47 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
48 | }
|
49 | Object.defineProperty(exports, '__esModule', { value: true });
|
50 | };
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 | __webpack_require__.t = function(value, mode) {
|
58 | if(mode & 1) value = __webpack_require__(value);
|
59 | if(mode & 8) return value;
|
60 | if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
61 | var ns = Object.create(null);
|
62 | __webpack_require__.r(ns);
|
63 | Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
64 | if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
65 | return ns;
|
66 | };
|
67 |
|
68 |
|
69 | __webpack_require__.n = function(module) {
|
70 | var getter = module && module.__esModule ?
|
71 | function getDefault() { return module['default']; } :
|
72 | function getModuleExports() { return module; };
|
73 | __webpack_require__.d(getter, 'a', getter);
|
74 | return getter;
|
75 | };
|
76 |
|
77 |
|
78 | __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
79 |
|
80 |
|
81 | __webpack_require__.p = "/dist/";
|
82 |
|
83 |
|
84 |
|
85 | return __webpack_require__(__webpack_require__.s = 58);
|
86 | })
|
87 |
|
88 | ({
|
89 |
|
90 | 0:
|
91 | (function(module, __webpack_exports__, __webpack_require__) {
|
92 |
|
93 | "use strict";
|
94 | __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; });
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 | function normalizeComponent (
|
102 | scriptExports,
|
103 | render,
|
104 | staticRenderFns,
|
105 | functionalTemplate,
|
106 | injectStyles,
|
107 | scopeId,
|
108 | moduleIdentifier, /* server only */
|
109 | shadowMode /* vue-cli only */
|
110 | ) {
|
111 |
|
112 | var options = typeof scriptExports === 'function'
|
113 | ? scriptExports.options
|
114 | : scriptExports
|
115 |
|
116 |
|
117 | if (render) {
|
118 | options.render = render
|
119 | options.staticRenderFns = staticRenderFns
|
120 | options._compiled = true
|
121 | }
|
122 |
|
123 |
|
124 | if (functionalTemplate) {
|
125 | options.functional = true
|
126 | }
|
127 |
|
128 |
|
129 | if (scopeId) {
|
130 | options._scopeId = 'data-v-' + scopeId
|
131 | }
|
132 |
|
133 | var hook
|
134 | if (moduleIdentifier) {
|
135 | hook = function (context) {
|
136 |
|
137 | context =
|
138 | context ||
|
139 | (this.$vnode && this.$vnode.ssrContext) ||
|
140 | (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext)
|
141 |
|
142 | if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
|
143 | context = __VUE_SSR_CONTEXT__
|
144 | }
|
145 |
|
146 | if (injectStyles) {
|
147 | injectStyles.call(this, context)
|
148 | }
|
149 |
|
150 | if (context && context._registeredComponents) {
|
151 | context._registeredComponents.add(moduleIdentifier)
|
152 | }
|
153 | }
|
154 |
|
155 |
|
156 | options._ssrRegister = hook
|
157 | } else if (injectStyles) {
|
158 | hook = shadowMode
|
159 | ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
|
160 | : injectStyles
|
161 | }
|
162 |
|
163 | if (hook) {
|
164 | if (options.functional) {
|
165 |
|
166 |
|
167 | options._injectStyles = hook
|
168 |
|
169 | var originalRender = options.render
|
170 | options.render = function renderWithStyleInjection (h, context) {
|
171 | hook.call(context)
|
172 | return originalRender(h, context)
|
173 | }
|
174 | } else {
|
175 |
|
176 | var existing = options.beforeCreate
|
177 | options.beforeCreate = existing
|
178 | ? [].concat(existing, hook)
|
179 | : [hook]
|
180 | }
|
181 | }
|
182 |
|
183 | return {
|
184 | exports: scriptExports,
|
185 | options: options
|
186 | }
|
187 | }
|
188 |
|
189 |
|
190 | }),
|
191 |
|
192 | 18:
|
193 | (function(module, exports) {
|
194 |
|
195 | module.exports = require("element-ui/lib/checkbox");
|
196 |
|
197 | }),
|
198 |
|
199 | 19:
|
200 | (function(module, exports) {
|
201 |
|
202 | module.exports = require("element-ui/lib/locale");
|
203 |
|
204 | }),
|
205 |
|
206 | 2:
|
207 | (function(module, exports) {
|
208 |
|
209 | module.exports = require("element-ui/lib/utils/dom");
|
210 |
|
211 | }),
|
212 |
|
213 | 28:
|
214 | (function(module, exports) {
|
215 |
|
216 | module.exports = require("element-ui/lib/transitions/collapse-transition");
|
217 |
|
218 | }),
|
219 |
|
220 | 3:
|
221 | (function(module, exports) {
|
222 |
|
223 | module.exports = require("element-ui/lib/utils/util");
|
224 |
|
225 | }),
|
226 |
|
227 | 4:
|
228 | (function(module, exports) {
|
229 |
|
230 | module.exports = require("element-ui/lib/mixins/emitter");
|
231 |
|
232 | }),
|
233 |
|
234 | 58:
|
235 | (function(module, __webpack_exports__, __webpack_require__) {
|
236 |
|
237 | "use strict";
|
238 | __webpack_require__.r(__webpack_exports__);
|
239 |
|
240 |
|
241 | var render = function() {
|
242 | var _vm = this
|
243 | var _h = _vm.$createElement
|
244 | var _c = _vm._self._c || _h
|
245 | return _c(
|
246 | "div",
|
247 | {
|
248 | staticClass: "el-tree",
|
249 | class: {
|
250 | "el-tree--highlight-current": _vm.highlightCurrent,
|
251 | "is-dragging": !!_vm.dragState.draggingNode,
|
252 | "is-drop-not-allow": !_vm.dragState.allowDrop,
|
253 | "is-drop-inner": _vm.dragState.dropType === "inner"
|
254 | },
|
255 | attrs: { role: "tree" }
|
256 | },
|
257 | [
|
258 | _vm._l(_vm.root.childNodes, function(child) {
|
259 | return _c("el-tree-node", {
|
260 | key: _vm.getNodeKey(child),
|
261 | attrs: {
|
262 | node: child,
|
263 | props: _vm.props,
|
264 | "render-after-expand": _vm.renderAfterExpand,
|
265 | "show-checkbox": _vm.showCheckbox,
|
266 | "render-content": _vm.renderContent
|
267 | },
|
268 | on: { "node-expand": _vm.handleNodeExpand }
|
269 | })
|
270 | }),
|
271 | _vm.isEmpty
|
272 | ? _c("div", { staticClass: "el-tree__empty-block" }, [
|
273 | _c("span", { staticClass: "el-tree__empty-text" }, [
|
274 | _vm._v(_vm._s(_vm.emptyText))
|
275 | ])
|
276 | ])
|
277 | : _vm._e(),
|
278 | _c("div", {
|
279 | directives: [
|
280 | {
|
281 | name: "show",
|
282 | rawName: "v-show",
|
283 | value: _vm.dragState.showDropIndicator,
|
284 | expression: "dragState.showDropIndicator"
|
285 | }
|
286 | ],
|
287 | ref: "dropIndicator",
|
288 | staticClass: "el-tree__drop-indicator"
|
289 | })
|
290 | ],
|
291 | 2
|
292 | )
|
293 | }
|
294 | var staticRenderFns = []
|
295 | render._withStripped = true
|
296 |
|
297 |
|
298 |
|
299 |
|
300 |
|
301 | var merge_ = __webpack_require__(9);
|
302 | var merge_default = __webpack_require__.n(merge_);
|
303 |
|
304 |
|
305 | var NODE_KEY = '$treeNodeId';
|
306 |
|
307 | var markNodeData = function markNodeData(node, data) {
|
308 | if (!data || data[NODE_KEY]) return;
|
309 | Object.defineProperty(data, NODE_KEY, {
|
310 | value: node.id,
|
311 | enumerable: false,
|
312 | configurable: false,
|
313 | writable: false
|
314 | });
|
315 | };
|
316 |
|
317 | var util_getNodeKey = function getNodeKey(key, data) {
|
318 | if (!key) return data[NODE_KEY];
|
319 | return data[key];
|
320 | };
|
321 |
|
322 | var findNearestComponent = function findNearestComponent(element, componentName) {
|
323 | var target = element;
|
324 | while (target && target.tagName !== 'BODY') {
|
325 | if (target.__vue__ && target.__vue__.$options.name === componentName) {
|
326 | return target.__vue__;
|
327 | }
|
328 | target = target.parentNode;
|
329 | }
|
330 | return null;
|
331 | };
|
332 |
|
333 | var util_ = __webpack_require__(3);
|
334 |
|
335 |
|
336 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
337 |
|
338 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
339 |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 | var getChildState = function getChildState(node) {
|
345 | var all = true;
|
346 | var none = true;
|
347 | var allWithoutDisable = true;
|
348 | for (var i = 0, j = node.length; i < j; i++) {
|
349 | var n = node[i];
|
350 | if (n.checked !== true || n.indeterminate) {
|
351 | all = false;
|
352 | if (!n.disabled) {
|
353 | allWithoutDisable = false;
|
354 | }
|
355 | }
|
356 | if (n.checked !== false || n.indeterminate) {
|
357 | none = false;
|
358 | }
|
359 | }
|
360 |
|
361 | return { all: all, none: none, allWithoutDisable: allWithoutDisable, half: !all && !none };
|
362 | };
|
363 |
|
364 | var reInitChecked = function reInitChecked(node) {
|
365 | if (node.childNodes.length === 0) return;
|
366 |
|
367 | var _getChildState = getChildState(node.childNodes),
|
368 | all = _getChildState.all,
|
369 | none = _getChildState.none,
|
370 | half = _getChildState.half;
|
371 |
|
372 | if (all) {
|
373 | node.checked = true;
|
374 | node.indeterminate = false;
|
375 | } else if (half) {
|
376 | node.checked = false;
|
377 | node.indeterminate = true;
|
378 | } else if (none) {
|
379 | node.checked = false;
|
380 | node.indeterminate = false;
|
381 | }
|
382 |
|
383 | var parent = node.parent;
|
384 | if (!parent || parent.level === 0) return;
|
385 |
|
386 | if (!node.store.checkStrictly) {
|
387 | reInitChecked(parent);
|
388 | }
|
389 | };
|
390 |
|
391 | var getPropertyFromData = function getPropertyFromData(node, prop) {
|
392 | var props = node.store.props;
|
393 | var data = node.data || {};
|
394 | var config = props[prop];
|
395 |
|
396 | if (typeof config === 'function') {
|
397 | return config(data, node);
|
398 | } else if (typeof config === 'string') {
|
399 | return data[config];
|
400 | } else if (typeof config === 'undefined') {
|
401 | var dataProp = data[prop];
|
402 | return dataProp === undefined ? '' : dataProp;
|
403 | }
|
404 | };
|
405 |
|
406 | var nodeIdSeed = 0;
|
407 |
|
408 | var node_Node = function () {
|
409 | function Node(options) {
|
410 | _classCallCheck(this, Node);
|
411 |
|
412 | this.id = nodeIdSeed++;
|
413 | this.text = null;
|
414 | this.checked = false;
|
415 | this.indeterminate = false;
|
416 | this.data = null;
|
417 | this.expanded = false;
|
418 | this.parent = null;
|
419 | this.visible = true;
|
420 | this.isCurrent = false;
|
421 |
|
422 | for (var name in options) {
|
423 | if (options.hasOwnProperty(name)) {
|
424 | this[name] = options[name];
|
425 | }
|
426 | }
|
427 |
|
428 |
|
429 | this.level = 0;
|
430 | this.loaded = false;
|
431 | this.childNodes = [];
|
432 | this.loading = false;
|
433 |
|
434 | if (this.parent) {
|
435 | this.level = this.parent.level + 1;
|
436 | }
|
437 |
|
438 | var store = this.store;
|
439 | if (!store) {
|
440 | throw new Error('[Node]store is required!');
|
441 | }
|
442 | store.registerNode(this);
|
443 |
|
444 | var props = store.props;
|
445 | if (props && typeof props.isLeaf !== 'undefined') {
|
446 | var isLeaf = getPropertyFromData(this, 'isLeaf');
|
447 | if (typeof isLeaf === 'boolean') {
|
448 | this.isLeafByUser = isLeaf;
|
449 | }
|
450 | }
|
451 |
|
452 | if (store.lazy !== true && this.data) {
|
453 | this.setData(this.data);
|
454 |
|
455 | if (store.defaultExpandAll) {
|
456 | this.expanded = true;
|
457 | }
|
458 | } else if (this.level > 0 && store.lazy && store.defaultExpandAll) {
|
459 | this.expand();
|
460 | }
|
461 | if (!Array.isArray(this.data)) {
|
462 | markNodeData(this, this.data);
|
463 | }
|
464 | if (!this.data) return;
|
465 | var defaultExpandedKeys = store.defaultExpandedKeys;
|
466 | var key = store.key;
|
467 | if (key && defaultExpandedKeys && defaultExpandedKeys.indexOf(this.key) !== -1) {
|
468 | this.expand(null, store.autoExpandParent);
|
469 | }
|
470 |
|
471 | if (key && store.currentNodeKey !== undefined && this.key === store.currentNodeKey) {
|
472 | store.currentNode = this;
|
473 | store.currentNode.isCurrent = true;
|
474 | }
|
475 |
|
476 | if (store.lazy) {
|
477 | store._initDefaultCheckedNode(this);
|
478 | }
|
479 |
|
480 | this.updateLeafState();
|
481 | }
|
482 |
|
483 | Node.prototype.setData = function setData(data) {
|
484 | if (!Array.isArray(data)) {
|
485 | markNodeData(this, data);
|
486 | }
|
487 |
|
488 | this.data = data;
|
489 | this.childNodes = [];
|
490 |
|
491 | var children = void 0;
|
492 | if (this.level === 0 && this.data instanceof Array) {
|
493 | children = this.data;
|
494 | } else {
|
495 | children = getPropertyFromData(this, 'children') || [];
|
496 | }
|
497 |
|
498 | for (var i = 0, j = children.length; i < j; i++) {
|
499 | this.insertChild({ data: children[i] });
|
500 | }
|
501 | };
|
502 |
|
503 | Node.prototype.contains = function contains(target) {
|
504 | var deep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
505 |
|
506 | var walk = function walk(parent) {
|
507 | var children = parent.childNodes || [];
|
508 | var result = false;
|
509 | for (var i = 0, j = children.length; i < j; i++) {
|
510 | var child = children[i];
|
511 | if (child === target || deep && walk(child)) {
|
512 | result = true;
|
513 | break;
|
514 | }
|
515 | }
|
516 | return result;
|
517 | };
|
518 |
|
519 | return walk(this);
|
520 | };
|
521 |
|
522 | Node.prototype.remove = function remove() {
|
523 | var parent = this.parent;
|
524 | if (parent) {
|
525 | parent.removeChild(this);
|
526 | }
|
527 | };
|
528 |
|
529 | Node.prototype.insertChild = function insertChild(child, index, batch) {
|
530 | if (!child) throw new Error('insertChild error: child is required.');
|
531 |
|
532 | if (!(child instanceof Node)) {
|
533 | if (!batch) {
|
534 | var children = this.getChildren(true);
|
535 | if (children.indexOf(child.data) === -1) {
|
536 | if (typeof index === 'undefined' || index < 0) {
|
537 | children.push(child.data);
|
538 | } else {
|
539 | children.splice(index, 0, child.data);
|
540 | }
|
541 | }
|
542 | }
|
543 | merge_default()(child, {
|
544 | parent: this,
|
545 | store: this.store
|
546 | });
|
547 | child = new Node(child);
|
548 | }
|
549 |
|
550 | child.level = this.level + 1;
|
551 |
|
552 | if (typeof index === 'undefined' || index < 0) {
|
553 | this.childNodes.push(child);
|
554 | } else {
|
555 | this.childNodes.splice(index, 0, child);
|
556 | }
|
557 |
|
558 | this.updateLeafState();
|
559 | };
|
560 |
|
561 | Node.prototype.insertBefore = function insertBefore(child, ref) {
|
562 | var index = void 0;
|
563 | if (ref) {
|
564 | index = this.childNodes.indexOf(ref);
|
565 | }
|
566 | this.insertChild(child, index);
|
567 | };
|
568 |
|
569 | Node.prototype.insertAfter = function insertAfter(child, ref) {
|
570 | var index = void 0;
|
571 | if (ref) {
|
572 | index = this.childNodes.indexOf(ref);
|
573 | if (index !== -1) index += 1;
|
574 | }
|
575 | this.insertChild(child, index);
|
576 | };
|
577 |
|
578 | Node.prototype.removeChild = function removeChild(child) {
|
579 | var children = this.getChildren() || [];
|
580 | var dataIndex = children.indexOf(child.data);
|
581 | if (dataIndex > -1) {
|
582 | children.splice(dataIndex, 1);
|
583 | }
|
584 |
|
585 | var index = this.childNodes.indexOf(child);
|
586 |
|
587 | if (index > -1) {
|
588 | this.store && this.store.deregisterNode(child);
|
589 | child.parent = null;
|
590 | this.childNodes.splice(index, 1);
|
591 | }
|
592 |
|
593 | this.updateLeafState();
|
594 | };
|
595 |
|
596 | Node.prototype.removeChildByData = function removeChildByData(data) {
|
597 | var targetNode = null;
|
598 |
|
599 | for (var i = 0; i < this.childNodes.length; i++) {
|
600 | if (this.childNodes[i].data === data) {
|
601 | targetNode = this.childNodes[i];
|
602 | break;
|
603 | }
|
604 | }
|
605 |
|
606 | if (targetNode) {
|
607 | this.removeChild(targetNode);
|
608 | }
|
609 | };
|
610 |
|
611 | Node.prototype.expand = function expand(callback, expandParent) {
|
612 | var _this = this;
|
613 |
|
614 | var done = function done() {
|
615 | if (expandParent) {
|
616 | var parent = _this.parent;
|
617 | while (parent.level > 0) {
|
618 | parent.expanded = true;
|
619 | parent = parent.parent;
|
620 | }
|
621 | }
|
622 | _this.expanded = true;
|
623 | if (callback) callback();
|
624 | };
|
625 |
|
626 | if (this.shouldLoadData()) {
|
627 | this.loadData(function (data) {
|
628 | if (data instanceof Array) {
|
629 | if (_this.checked) {
|
630 | _this.setChecked(true, true);
|
631 | } else if (!_this.store.checkStrictly) {
|
632 | reInitChecked(_this);
|
633 | }
|
634 | done();
|
635 | }
|
636 | });
|
637 | } else {
|
638 | done();
|
639 | }
|
640 | };
|
641 |
|
642 | Node.prototype.doCreateChildren = function doCreateChildren(array) {
|
643 | var _this2 = this;
|
644 |
|
645 | var defaultProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
646 |
|
647 | array.forEach(function (item) {
|
648 | _this2.insertChild(merge_default()({ data: item }, defaultProps), undefined, true);
|
649 | });
|
650 | };
|
651 |
|
652 | Node.prototype.collapse = function collapse() {
|
653 | this.expanded = false;
|
654 | };
|
655 |
|
656 | Node.prototype.shouldLoadData = function shouldLoadData() {
|
657 | return this.store.lazy === true && this.store.load && !this.loaded;
|
658 | };
|
659 |
|
660 | Node.prototype.updateLeafState = function updateLeafState() {
|
661 | if (this.store.lazy === true && this.loaded !== true && typeof this.isLeafByUser !== 'undefined') {
|
662 | this.isLeaf = this.isLeafByUser;
|
663 | return;
|
664 | }
|
665 | var childNodes = this.childNodes;
|
666 | if (!this.store.lazy || this.store.lazy === true && this.loaded === true) {
|
667 | this.isLeaf = !childNodes || childNodes.length === 0;
|
668 | return;
|
669 | }
|
670 | this.isLeaf = false;
|
671 | };
|
672 |
|
673 | Node.prototype.setChecked = function setChecked(value, deep, recursion, passValue) {
|
674 | var _this3 = this;
|
675 |
|
676 | this.indeterminate = value === 'half';
|
677 | this.checked = value === true;
|
678 |
|
679 | if (this.store.checkStrictly) return;
|
680 |
|
681 | if (!(this.shouldLoadData() && !this.store.checkDescendants)) {
|
682 | var _getChildState2 = getChildState(this.childNodes),
|
683 | all = _getChildState2.all,
|
684 | allWithoutDisable = _getChildState2.allWithoutDisable;
|
685 |
|
686 | if (!this.isLeaf && !all && allWithoutDisable) {
|
687 | this.checked = false;
|
688 | value = false;
|
689 | }
|
690 |
|
691 | var handleDescendants = function handleDescendants() {
|
692 | if (deep) {
|
693 | var childNodes = _this3.childNodes;
|
694 | for (var i = 0, j = childNodes.length; i < j; i++) {
|
695 | var child = childNodes[i];
|
696 | passValue = passValue || value !== false;
|
697 | var isCheck = child.disabled ? child.checked : passValue;
|
698 | child.setChecked(isCheck, deep, true, passValue);
|
699 | }
|
700 |
|
701 | var _getChildState3 = getChildState(childNodes),
|
702 | half = _getChildState3.half,
|
703 | _all = _getChildState3.all;
|
704 |
|
705 | if (!_all) {
|
706 | _this3.checked = _all;
|
707 | _this3.indeterminate = half;
|
708 | }
|
709 | }
|
710 | };
|
711 |
|
712 | if (this.shouldLoadData()) {
|
713 |
|
714 | this.loadData(function () {
|
715 | handleDescendants();
|
716 | reInitChecked(_this3);
|
717 | }, {
|
718 | checked: value !== false
|
719 | });
|
720 | return;
|
721 | } else {
|
722 | handleDescendants();
|
723 | }
|
724 | }
|
725 |
|
726 | var parent = this.parent;
|
727 | if (!parent || parent.level === 0) return;
|
728 |
|
729 | if (!recursion) {
|
730 | reInitChecked(parent);
|
731 | }
|
732 | };
|
733 |
|
734 | Node.prototype.getChildren = function getChildren() {
|
735 | var forceInit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
736 |
|
737 | if (this.level === 0) return this.data;
|
738 | var data = this.data;
|
739 | if (!data) return null;
|
740 |
|
741 | var props = this.store.props;
|
742 | var children = 'children';
|
743 | if (props) {
|
744 | children = props.children || 'children';
|
745 | }
|
746 |
|
747 | if (data[children] === undefined) {
|
748 | data[children] = null;
|
749 | }
|
750 |
|
751 | if (forceInit && !data[children]) {
|
752 | data[children] = [];
|
753 | }
|
754 |
|
755 | return data[children];
|
756 | };
|
757 |
|
758 | Node.prototype.updateChildren = function updateChildren() {
|
759 | var _this4 = this;
|
760 |
|
761 | var newData = this.getChildren() || [];
|
762 | var oldData = this.childNodes.map(function (node) {
|
763 | return node.data;
|
764 | });
|
765 |
|
766 | var newDataMap = {};
|
767 | var newNodes = [];
|
768 |
|
769 | newData.forEach(function (item, index) {
|
770 | var key = item[NODE_KEY];
|
771 | var isNodeExists = !!key && Object(util_["arrayFindIndex"])(oldData, function (data) {
|
772 | return data[NODE_KEY] === key;
|
773 | }) >= 0;
|
774 | if (isNodeExists) {
|
775 | newDataMap[key] = { index: index, data: item };
|
776 | } else {
|
777 | newNodes.push({ index: index, data: item });
|
778 | }
|
779 | });
|
780 |
|
781 | if (!this.store.lazy) {
|
782 | oldData.forEach(function (item) {
|
783 | if (!newDataMap[item[NODE_KEY]]) _this4.removeChildByData(item);
|
784 | });
|
785 | }
|
786 |
|
787 | newNodes.forEach(function (_ref) {
|
788 | var index = _ref.index,
|
789 | data = _ref.data;
|
790 |
|
791 | _this4.insertChild({ data: data }, index);
|
792 | });
|
793 |
|
794 | this.updateLeafState();
|
795 | };
|
796 |
|
797 | Node.prototype.loadData = function loadData(callback) {
|
798 | var _this5 = this;
|
799 |
|
800 | var defaultProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
801 |
|
802 | if (this.store.lazy === true && this.store.load && !this.loaded && (!this.loading || Object.keys(defaultProps).length)) {
|
803 | this.loading = true;
|
804 |
|
805 | var resolve = function resolve(children) {
|
806 | _this5.loaded = true;
|
807 | _this5.loading = false;
|
808 | _this5.childNodes = [];
|
809 |
|
810 | _this5.doCreateChildren(children, defaultProps);
|
811 |
|
812 | _this5.updateLeafState();
|
813 | if (callback) {
|
814 | callback.call(_this5, children);
|
815 | }
|
816 | };
|
817 |
|
818 | this.store.load(this, resolve);
|
819 | } else {
|
820 | if (callback) {
|
821 | callback.call(this);
|
822 | }
|
823 | }
|
824 | };
|
825 |
|
826 | _createClass(Node, [{
|
827 | key: 'label',
|
828 | get: function get() {
|
829 | return getPropertyFromData(this, 'label');
|
830 | }
|
831 | }, {
|
832 | key: 'key',
|
833 | get: function get() {
|
834 | var nodeKey = this.store.key;
|
835 | if (this.data) return this.data[nodeKey];
|
836 | return null;
|
837 | }
|
838 | }, {
|
839 | key: 'disabled',
|
840 | get: function get() {
|
841 | return getPropertyFromData(this, 'disabled');
|
842 | }
|
843 | }, {
|
844 | key: 'nextSibling',
|
845 | get: function get() {
|
846 | var parent = this.parent;
|
847 | if (parent) {
|
848 | var index = parent.childNodes.indexOf(this);
|
849 | if (index > -1) {
|
850 | return parent.childNodes[index + 1];
|
851 | }
|
852 | }
|
853 | return null;
|
854 | }
|
855 | }, {
|
856 | key: 'previousSibling',
|
857 | get: function get() {
|
858 | var parent = this.parent;
|
859 | if (parent) {
|
860 | var index = parent.childNodes.indexOf(this);
|
861 | if (index > -1) {
|
862 | return index > 0 ? parent.childNodes[index - 1] : null;
|
863 | }
|
864 | }
|
865 | return null;
|
866 | }
|
867 | }]);
|
868 |
|
869 | return Node;
|
870 | }();
|
871 |
|
872 | var model_node = (node_Node);
|
873 |
|
874 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
875 |
|
876 | function tree_store_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
877 |
|
878 |
|
879 |
|
880 |
|
881 | var tree_store_TreeStore = function () {
|
882 | function TreeStore(options) {
|
883 | var _this = this;
|
884 |
|
885 | tree_store_classCallCheck(this, TreeStore);
|
886 |
|
887 | this.currentNode = null;
|
888 | this.currentNodeKey = null;
|
889 |
|
890 | for (var option in options) {
|
891 | if (options.hasOwnProperty(option)) {
|
892 | this[option] = options[option];
|
893 | }
|
894 | }
|
895 |
|
896 | this.nodesMap = {};
|
897 |
|
898 | this.root = new model_node({
|
899 | data: this.data,
|
900 | store: this
|
901 | });
|
902 |
|
903 | if (this.lazy && this.load) {
|
904 | var loadFn = this.load;
|
905 | loadFn(this.root, function (data) {
|
906 | _this.root.doCreateChildren(data);
|
907 | _this._initDefaultCheckedNodes();
|
908 | });
|
909 | } else {
|
910 | this._initDefaultCheckedNodes();
|
911 | }
|
912 | }
|
913 |
|
914 | TreeStore.prototype.filter = function filter(value) {
|
915 | var filterNodeMethod = this.filterNodeMethod;
|
916 | var lazy = this.lazy;
|
917 | var traverse = function traverse(node) {
|
918 | var childNodes = node.root ? node.root.childNodes : node.childNodes;
|
919 |
|
920 | childNodes.forEach(function (child) {
|
921 | child.visible = filterNodeMethod.call(child, value, child.data, child);
|
922 |
|
923 | traverse(child);
|
924 | });
|
925 |
|
926 | if (!node.visible && childNodes.length) {
|
927 | var allHidden = true;
|
928 | allHidden = !childNodes.some(function (child) {
|
929 | return child.visible;
|
930 | });
|
931 |
|
932 | if (node.root) {
|
933 | node.root.visible = allHidden === false;
|
934 | } else {
|
935 | node.visible = allHidden === false;
|
936 | }
|
937 | }
|
938 | if (!value) return;
|
939 |
|
940 | if (node.visible && !node.isLeaf && !lazy) node.expand();
|
941 | };
|
942 |
|
943 | traverse(this);
|
944 | };
|
945 |
|
946 | TreeStore.prototype.setData = function setData(newVal) {
|
947 | var instanceChanged = newVal !== this.root.data;
|
948 | if (instanceChanged) {
|
949 | this.root.setData(newVal);
|
950 | this._initDefaultCheckedNodes();
|
951 | } else {
|
952 | this.root.updateChildren();
|
953 | }
|
954 | };
|
955 |
|
956 | TreeStore.prototype.getNode = function getNode(data) {
|
957 | if (data instanceof model_node) return data;
|
958 | var key = (typeof data === 'undefined' ? 'undefined' : _typeof(data)) !== 'object' ? data : util_getNodeKey(this.key, data);
|
959 | return this.nodesMap[key] || null;
|
960 | };
|
961 |
|
962 | TreeStore.prototype.insertBefore = function insertBefore(data, refData) {
|
963 | var refNode = this.getNode(refData);
|
964 | refNode.parent.insertBefore({ data: data }, refNode);
|
965 | };
|
966 |
|
967 | TreeStore.prototype.insertAfter = function insertAfter(data, refData) {
|
968 | var refNode = this.getNode(refData);
|
969 | refNode.parent.insertAfter({ data: data }, refNode);
|
970 | };
|
971 |
|
972 | TreeStore.prototype.remove = function remove(data) {
|
973 | var node = this.getNode(data);
|
974 |
|
975 | if (node && node.parent) {
|
976 | if (node === this.currentNode) {
|
977 | this.currentNode = null;
|
978 | }
|
979 | node.parent.removeChild(node);
|
980 | }
|
981 | };
|
982 |
|
983 | TreeStore.prototype.append = function append(data, parentData) {
|
984 | var parentNode = parentData ? this.getNode(parentData) : this.root;
|
985 |
|
986 | if (parentNode) {
|
987 | parentNode.insertChild({ data: data });
|
988 | }
|
989 | };
|
990 |
|
991 | TreeStore.prototype._initDefaultCheckedNodes = function _initDefaultCheckedNodes() {
|
992 | var _this2 = this;
|
993 |
|
994 | var defaultCheckedKeys = this.defaultCheckedKeys || [];
|
995 | var nodesMap = this.nodesMap;
|
996 |
|
997 | defaultCheckedKeys.forEach(function (checkedKey) {
|
998 | var node = nodesMap[checkedKey];
|
999 |
|
1000 | if (node) {
|
1001 | node.setChecked(true, !_this2.checkStrictly);
|
1002 | }
|
1003 | });
|
1004 | };
|
1005 |
|
1006 | TreeStore.prototype._initDefaultCheckedNode = function _initDefaultCheckedNode(node) {
|
1007 | var defaultCheckedKeys = this.defaultCheckedKeys || [];
|
1008 |
|
1009 | if (defaultCheckedKeys.indexOf(node.key) !== -1) {
|
1010 | node.setChecked(true, !this.checkStrictly);
|
1011 | }
|
1012 | };
|
1013 |
|
1014 | TreeStore.prototype.setDefaultCheckedKey = function setDefaultCheckedKey(newVal) {
|
1015 | if (newVal !== this.defaultCheckedKeys) {
|
1016 | this.defaultCheckedKeys = newVal;
|
1017 | this._initDefaultCheckedNodes();
|
1018 | }
|
1019 | };
|
1020 |
|
1021 | TreeStore.prototype.registerNode = function registerNode(node) {
|
1022 | var key = this.key;
|
1023 | if (!key || !node || !node.data) return;
|
1024 |
|
1025 | var nodeKey = node.key;
|
1026 | if (nodeKey !== undefined) this.nodesMap[node.key] = node;
|
1027 | };
|
1028 |
|
1029 | TreeStore.prototype.deregisterNode = function deregisterNode(node) {
|
1030 | var _this3 = this;
|
1031 |
|
1032 | var key = this.key;
|
1033 | if (!key || !node || !node.data) return;
|
1034 |
|
1035 | node.childNodes.forEach(function (child) {
|
1036 | _this3.deregisterNode(child);
|
1037 | });
|
1038 |
|
1039 | delete this.nodesMap[node.key];
|
1040 | };
|
1041 |
|
1042 | TreeStore.prototype.getCheckedNodes = function getCheckedNodes() {
|
1043 | var leafOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
1044 | var includeHalfChecked = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
1045 |
|
1046 | var checkedNodes = [];
|
1047 | var traverse = function traverse(node) {
|
1048 | var childNodes = node.root ? node.root.childNodes : node.childNodes;
|
1049 |
|
1050 | childNodes.forEach(function (child) {
|
1051 | if ((child.checked || includeHalfChecked && child.indeterminate) && (!leafOnly || leafOnly && child.isLeaf)) {
|
1052 | checkedNodes.push(child.data);
|
1053 | }
|
1054 |
|
1055 | traverse(child);
|
1056 | });
|
1057 | };
|
1058 |
|
1059 | traverse(this);
|
1060 |
|
1061 | return checkedNodes;
|
1062 | };
|
1063 |
|
1064 | TreeStore.prototype.getCheckedKeys = function getCheckedKeys() {
|
1065 | var _this4 = this;
|
1066 |
|
1067 | var leafOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
1068 |
|
1069 | return this.getCheckedNodes(leafOnly).map(function (data) {
|
1070 | return (data || {})[_this4.key];
|
1071 | });
|
1072 | };
|
1073 |
|
1074 | TreeStore.prototype.getHalfCheckedNodes = function getHalfCheckedNodes() {
|
1075 | var nodes = [];
|
1076 | var traverse = function traverse(node) {
|
1077 | var childNodes = node.root ? node.root.childNodes : node.childNodes;
|
1078 |
|
1079 | childNodes.forEach(function (child) {
|
1080 | if (child.indeterminate) {
|
1081 | nodes.push(child.data);
|
1082 | }
|
1083 |
|
1084 | traverse(child);
|
1085 | });
|
1086 | };
|
1087 |
|
1088 | traverse(this);
|
1089 |
|
1090 | return nodes;
|
1091 | };
|
1092 |
|
1093 | TreeStore.prototype.getHalfCheckedKeys = function getHalfCheckedKeys() {
|
1094 | var _this5 = this;
|
1095 |
|
1096 | return this.getHalfCheckedNodes().map(function (data) {
|
1097 | return (data || {})[_this5.key];
|
1098 | });
|
1099 | };
|
1100 |
|
1101 | TreeStore.prototype._getAllNodes = function _getAllNodes() {
|
1102 | var allNodes = [];
|
1103 | var nodesMap = this.nodesMap;
|
1104 | for (var nodeKey in nodesMap) {
|
1105 | if (nodesMap.hasOwnProperty(nodeKey)) {
|
1106 | allNodes.push(nodesMap[nodeKey]);
|
1107 | }
|
1108 | }
|
1109 |
|
1110 | return allNodes;
|
1111 | };
|
1112 |
|
1113 | TreeStore.prototype.updateChildren = function updateChildren(key, data) {
|
1114 | var node = this.nodesMap[key];
|
1115 | if (!node) return;
|
1116 | var childNodes = node.childNodes;
|
1117 | for (var i = childNodes.length - 1; i >= 0; i--) {
|
1118 | var child = childNodes[i];
|
1119 | this.remove(child.data);
|
1120 | }
|
1121 | for (var _i = 0, j = data.length; _i < j; _i++) {
|
1122 | var _child = data[_i];
|
1123 | this.append(_child, node.data);
|
1124 | }
|
1125 | };
|
1126 |
|
1127 | TreeStore.prototype._setCheckedKeys = function _setCheckedKeys(key) {
|
1128 | var leafOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
1129 | var checkedKeys = arguments[2];
|
1130 |
|
1131 | var allNodes = this._getAllNodes().sort(function (a, b) {
|
1132 | return b.level - a.level;
|
1133 | });
|
1134 | var cache = Object.create(null);
|
1135 | var keys = Object.keys(checkedKeys);
|
1136 | allNodes.forEach(function (node) {
|
1137 | return node.setChecked(false, false);
|
1138 | });
|
1139 | for (var i = 0, j = allNodes.length; i < j; i++) {
|
1140 | var node = allNodes[i];
|
1141 | var nodeKey = node.data[key].toString();
|
1142 | var checked = keys.indexOf(nodeKey) > -1;
|
1143 | if (!checked) {
|
1144 | if (node.checked && !cache[nodeKey]) {
|
1145 | node.setChecked(false, false);
|
1146 | }
|
1147 | continue;
|
1148 | }
|
1149 |
|
1150 | var parent = node.parent;
|
1151 | while (parent && parent.level > 0) {
|
1152 | cache[parent.data[key]] = true;
|
1153 | parent = parent.parent;
|
1154 | }
|
1155 |
|
1156 | if (node.isLeaf || this.checkStrictly) {
|
1157 | node.setChecked(true, false);
|
1158 | continue;
|
1159 | }
|
1160 | node.setChecked(true, true);
|
1161 |
|
1162 | if (leafOnly) {
|
1163 | (function () {
|
1164 | node.setChecked(false, false);
|
1165 | var traverse = function traverse(node) {
|
1166 | var childNodes = node.childNodes;
|
1167 | childNodes.forEach(function (child) {
|
1168 | if (!child.isLeaf) {
|
1169 | child.setChecked(false, false);
|
1170 | }
|
1171 | traverse(child);
|
1172 | });
|
1173 | };
|
1174 | traverse(node);
|
1175 | })();
|
1176 | }
|
1177 | }
|
1178 | };
|
1179 |
|
1180 | TreeStore.prototype.setCheckedNodes = function setCheckedNodes(array) {
|
1181 | var leafOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
1182 |
|
1183 | var key = this.key;
|
1184 | var checkedKeys = {};
|
1185 | array.forEach(function (item) {
|
1186 | checkedKeys[(item || {})[key]] = true;
|
1187 | });
|
1188 |
|
1189 | this._setCheckedKeys(key, leafOnly, checkedKeys);
|
1190 | };
|
1191 |
|
1192 | TreeStore.prototype.setCheckedKeys = function setCheckedKeys(keys) {
|
1193 | var leafOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
1194 |
|
1195 | this.defaultCheckedKeys = keys;
|
1196 | var key = this.key;
|
1197 | var checkedKeys = {};
|
1198 | keys.forEach(function (key) {
|
1199 | checkedKeys[key] = true;
|
1200 | });
|
1201 |
|
1202 | this._setCheckedKeys(key, leafOnly, checkedKeys);
|
1203 | };
|
1204 |
|
1205 | TreeStore.prototype.setDefaultExpandedKeys = function setDefaultExpandedKeys(keys) {
|
1206 | var _this6 = this;
|
1207 |
|
1208 | keys = keys || [];
|
1209 | this.defaultExpandedKeys = keys;
|
1210 |
|
1211 | keys.forEach(function (key) {
|
1212 | var node = _this6.getNode(key);
|
1213 | if (node) node.expand(null, _this6.autoExpandParent);
|
1214 | });
|
1215 | };
|
1216 |
|
1217 | TreeStore.prototype.setChecked = function setChecked(data, checked, deep) {
|
1218 | var node = this.getNode(data);
|
1219 |
|
1220 | if (node) {
|
1221 | node.setChecked(!!checked, deep);
|
1222 | }
|
1223 | };
|
1224 |
|
1225 | TreeStore.prototype.getCurrentNode = function getCurrentNode() {
|
1226 | return this.currentNode;
|
1227 | };
|
1228 |
|
1229 | TreeStore.prototype.setCurrentNode = function setCurrentNode(currentNode) {
|
1230 | var prevCurrentNode = this.currentNode;
|
1231 | if (prevCurrentNode) {
|
1232 | prevCurrentNode.isCurrent = false;
|
1233 | }
|
1234 | this.currentNode = currentNode;
|
1235 | this.currentNode.isCurrent = true;
|
1236 | };
|
1237 |
|
1238 | TreeStore.prototype.setUserCurrentNode = function setUserCurrentNode(node) {
|
1239 | var key = node[this.key];
|
1240 | var currNode = this.nodesMap[key];
|
1241 | this.setCurrentNode(currNode);
|
1242 | };
|
1243 |
|
1244 | TreeStore.prototype.setCurrentNodeKey = function setCurrentNodeKey(key) {
|
1245 | if (key === null || key === undefined) {
|
1246 | this.currentNode && (this.currentNode.isCurrent = false);
|
1247 | this.currentNode = null;
|
1248 | return;
|
1249 | }
|
1250 | var node = this.getNode(key);
|
1251 | if (node) {
|
1252 | this.setCurrentNode(node);
|
1253 | }
|
1254 | };
|
1255 |
|
1256 | return TreeStore;
|
1257 | }();
|
1258 |
|
1259 | var tree_store = (tree_store_TreeStore);
|
1260 | ;
|
1261 |
|
1262 | var tree_nodevue_type_template_id_3ba3ef0e_render = function() {
|
1263 | var this$1 = this
|
1264 | var _vm = this
|
1265 | var _h = _vm.$createElement
|
1266 | var _c = _vm._self._c || _h
|
1267 | return _c(
|
1268 | "div",
|
1269 | {
|
1270 | directives: [
|
1271 | {
|
1272 | name: "show",
|
1273 | rawName: "v-show",
|
1274 | value: _vm.node.visible,
|
1275 | expression: "node.visible"
|
1276 | }
|
1277 | ],
|
1278 | ref: "node",
|
1279 | staticClass: "el-tree-node",
|
1280 | class: {
|
1281 | "is-expanded": _vm.expanded,
|
1282 | "is-current": _vm.node.isCurrent,
|
1283 | "is-hidden": !_vm.node.visible,
|
1284 | "is-focusable": !_vm.node.disabled,
|
1285 | "is-checked": !_vm.node.disabled && _vm.node.checked
|
1286 | },
|
1287 | attrs: {
|
1288 | role: "treeitem",
|
1289 | tabindex: "-1",
|
1290 | "aria-expanded": _vm.expanded,
|
1291 | "aria-disabled": _vm.node.disabled,
|
1292 | "aria-checked": _vm.node.checked,
|
1293 | draggable: _vm.tree.draggable
|
1294 | },
|
1295 | on: {
|
1296 | click: function($event) {
|
1297 | $event.stopPropagation()
|
1298 | return _vm.handleClick($event)
|
1299 | },
|
1300 | contextmenu: function($event) {
|
1301 | return this$1.handleContextMenu($event)
|
1302 | },
|
1303 | dragstart: function($event) {
|
1304 | $event.stopPropagation()
|
1305 | return _vm.handleDragStart($event)
|
1306 | },
|
1307 | dragover: function($event) {
|
1308 | $event.stopPropagation()
|
1309 | return _vm.handleDragOver($event)
|
1310 | },
|
1311 | dragend: function($event) {
|
1312 | $event.stopPropagation()
|
1313 | return _vm.handleDragEnd($event)
|
1314 | },
|
1315 | drop: function($event) {
|
1316 | $event.stopPropagation()
|
1317 | return _vm.handleDrop($event)
|
1318 | }
|
1319 | }
|
1320 | },
|
1321 | [
|
1322 | _c(
|
1323 | "div",
|
1324 | {
|
1325 | staticClass: "el-tree-node__content",
|
1326 | style: {
|
1327 | "padding-left": (_vm.node.level - 1) * _vm.tree.indent + "px"
|
1328 | }
|
1329 | },
|
1330 | [
|
1331 | _c("span", {
|
1332 | class: [
|
1333 | {
|
1334 | "is-leaf": _vm.node.isLeaf,
|
1335 | expanded: !_vm.node.isLeaf && _vm.expanded
|
1336 | },
|
1337 | "el-tree-node__expand-icon",
|
1338 | _vm.tree.iconClass ? _vm.tree.iconClass : "el-icon-caret-right"
|
1339 | ],
|
1340 | on: {
|
1341 | click: function($event) {
|
1342 | $event.stopPropagation()
|
1343 | return _vm.handleExpandIconClick($event)
|
1344 | }
|
1345 | }
|
1346 | }),
|
1347 | _vm.showCheckbox
|
1348 | ? _c("el-checkbox", {
|
1349 | attrs: {
|
1350 | indeterminate: _vm.node.indeterminate,
|
1351 | disabled: !!_vm.node.disabled
|
1352 | },
|
1353 | on: { change: _vm.handleCheckChange },
|
1354 | nativeOn: {
|
1355 | click: function($event) {
|
1356 | $event.stopPropagation()
|
1357 | }
|
1358 | },
|
1359 | model: {
|
1360 | value: _vm.node.checked,
|
1361 | callback: function($$v) {
|
1362 | _vm.$set(_vm.node, "checked", $$v)
|
1363 | },
|
1364 | expression: "node.checked"
|
1365 | }
|
1366 | })
|
1367 | : _vm._e(),
|
1368 | _vm.node.loading
|
1369 | ? _c("span", {
|
1370 | staticClass: "el-tree-node__loading-icon el-icon-loading"
|
1371 | })
|
1372 | : _vm._e(),
|
1373 | _c("node-content", { attrs: { node: _vm.node } })
|
1374 | ],
|
1375 | 1
|
1376 | ),
|
1377 | _c("el-collapse-transition", [
|
1378 | !_vm.renderAfterExpand || _vm.childNodeRendered
|
1379 | ? _c(
|
1380 | "div",
|
1381 | {
|
1382 | directives: [
|
1383 | {
|
1384 | name: "show",
|
1385 | rawName: "v-show",
|
1386 | value: _vm.expanded,
|
1387 | expression: "expanded"
|
1388 | }
|
1389 | ],
|
1390 | staticClass: "el-tree-node__children",
|
1391 | attrs: { role: "group", "aria-expanded": _vm.expanded }
|
1392 | },
|
1393 | _vm._l(_vm.node.childNodes, function(child) {
|
1394 | return _c("el-tree-node", {
|
1395 | key: _vm.getNodeKey(child),
|
1396 | attrs: {
|
1397 | "render-content": _vm.renderContent,
|
1398 | "render-after-expand": _vm.renderAfterExpand,
|
1399 | "show-checkbox": _vm.showCheckbox,
|
1400 | node: child
|
1401 | },
|
1402 | on: { "node-expand": _vm.handleChildNodeExpand }
|
1403 | })
|
1404 | }),
|
1405 | 1
|
1406 | )
|
1407 | : _vm._e()
|
1408 | ])
|
1409 | ],
|
1410 | 1
|
1411 | )
|
1412 | }
|
1413 | var tree_nodevue_type_template_id_3ba3ef0e_staticRenderFns = []
|
1414 | tree_nodevue_type_template_id_3ba3ef0e_render._withStripped = true
|
1415 |
|
1416 |
|
1417 |
|
1418 |
|
1419 |
|
1420 | var collapse_transition_ = __webpack_require__(28);
|
1421 | var collapse_transition_default = __webpack_require__.n(collapse_transition_);
|
1422 |
|
1423 |
|
1424 | var checkbox_ = __webpack_require__(18);
|
1425 | var checkbox_default = __webpack_require__.n(checkbox_);
|
1426 |
|
1427 |
|
1428 | var emitter_ = __webpack_require__(4);
|
1429 | var emitter_default = __webpack_require__.n(emitter_);
|
1430 |
|
1431 |
|
1432 |
|
1433 |
|
1434 |
|
1435 |
|
1436 |
|
1437 |
|
1438 |
|
1439 |
|
1440 |
|
1441 |
|
1442 |
|
1443 |
|
1444 |
|
1445 |
|
1446 |
|
1447 |
|
1448 |
|
1449 |
|
1450 |
|
1451 |
|
1452 |
|
1453 |
|
1454 |
|
1455 |
|
1456 |
|
1457 |
|
1458 |
|
1459 |
|
1460 |
|
1461 |
|
1462 |
|
1463 |
|
1464 |
|
1465 |
|
1466 |
|
1467 |
|
1468 |
|
1469 |
|
1470 |
|
1471 |
|
1472 |
|
1473 |
|
1474 |
|
1475 |
|
1476 |
|
1477 |
|
1478 |
|
1479 |
|
1480 |
|
1481 |
|
1482 |
|
1483 |
|
1484 |
|
1485 |
|
1486 |
|
1487 |
|
1488 |
|
1489 |
|
1490 |
|
1491 |
|
1492 |
|
1493 |
|
1494 |
|
1495 |
|
1496 |
|
1497 |
|
1498 |
|
1499 |
|
1500 |
|
1501 |
|
1502 |
|
1503 |
|
1504 |
|
1505 |
|
1506 |
|
1507 |
|
1508 |
|
1509 |
|
1510 |
|
1511 | var tree_nodevue_type_script_lang_js_ = ({
|
1512 | name: 'ElTreeNode',
|
1513 |
|
1514 | componentName: 'ElTreeNode',
|
1515 |
|
1516 | mixins: [emitter_default.a],
|
1517 |
|
1518 | props: {
|
1519 | node: {
|
1520 | default: function _default() {
|
1521 | return {};
|
1522 | }
|
1523 | },
|
1524 | props: {},
|
1525 | renderContent: Function,
|
1526 | renderAfterExpand: {
|
1527 | type: Boolean,
|
1528 | default: true
|
1529 | },
|
1530 | showCheckbox: {
|
1531 | type: Boolean,
|
1532 | default: false
|
1533 | }
|
1534 | },
|
1535 |
|
1536 | components: {
|
1537 | ElCollapseTransition: collapse_transition_default.a,
|
1538 | ElCheckbox: checkbox_default.a,
|
1539 | NodeContent: {
|
1540 | props: {
|
1541 | node: {
|
1542 | required: true
|
1543 | }
|
1544 | },
|
1545 | render: function render(h) {
|
1546 | var parent = this.$parent;
|
1547 | var tree = parent.tree;
|
1548 | var node = this.node;
|
1549 | var data = node.data,
|
1550 | store = node.store;
|
1551 |
|
1552 | return parent.renderContent ? parent.renderContent.call(parent._renderProxy, h, { _self: tree.$vnode.context, node: node, data: data, store: store }) : tree.$scopedSlots.default ? tree.$scopedSlots.default({ node: node, data: data }) : h(
|
1553 | 'span',
|
1554 | { 'class': 'el-tree-node__label' },
|
1555 | [node.label]
|
1556 | );
|
1557 | }
|
1558 | }
|
1559 | },
|
1560 |
|
1561 | data: function data() {
|
1562 | return {
|
1563 | tree: null,
|
1564 | expanded: false,
|
1565 | childNodeRendered: false,
|
1566 | oldChecked: null,
|
1567 | oldIndeterminate: null
|
1568 | };
|
1569 | },
|
1570 |
|
1571 |
|
1572 | watch: {
|
1573 | 'node.indeterminate': function nodeIndeterminate(val) {
|
1574 | this.handleSelectChange(this.node.checked, val);
|
1575 | },
|
1576 | 'node.checked': function nodeChecked(val) {
|
1577 | this.handleSelectChange(val, this.node.indeterminate);
|
1578 | },
|
1579 | 'node.expanded': function nodeExpanded(val) {
|
1580 | var _this = this;
|
1581 |
|
1582 | this.$nextTick(function () {
|
1583 | return _this.expanded = val;
|
1584 | });
|
1585 | if (val) {
|
1586 | this.childNodeRendered = true;
|
1587 | }
|
1588 | }
|
1589 | },
|
1590 |
|
1591 | methods: {
|
1592 | getNodeKey: function getNodeKey(node) {
|
1593 | return util_getNodeKey(this.tree.nodeKey, node.data);
|
1594 | },
|
1595 | handleSelectChange: function handleSelectChange(checked, indeterminate) {
|
1596 | if (this.oldChecked !== checked && this.oldIndeterminate !== indeterminate) {
|
1597 | this.tree.$emit('check-change', this.node.data, checked, indeterminate);
|
1598 | }
|
1599 | this.oldChecked = checked;
|
1600 | this.indeterminate = indeterminate;
|
1601 | },
|
1602 | handleClick: function handleClick() {
|
1603 | var store = this.tree.store;
|
1604 | store.setCurrentNode(this.node);
|
1605 | this.tree.$emit('current-change', store.currentNode ? store.currentNode.data : null, store.currentNode);
|
1606 | this.tree.currentNode = this;
|
1607 | if (this.tree.expandOnClickNode) {
|
1608 | this.handleExpandIconClick();
|
1609 | }
|
1610 | if (this.tree.checkOnClickNode && !this.node.disabled) {
|
1611 | this.handleCheckChange(null, {
|
1612 | target: { checked: !this.node.checked }
|
1613 | });
|
1614 | }
|
1615 | this.tree.$emit('node-click', this.node.data, this.node, this);
|
1616 | },
|
1617 | handleContextMenu: function handleContextMenu(event) {
|
1618 | if (this.tree._events['node-contextmenu'] && this.tree._events['node-contextmenu'].length > 0) {
|
1619 | event.stopPropagation();
|
1620 | event.preventDefault();
|
1621 | }
|
1622 | this.tree.$emit('node-contextmenu', event, this.node.data, this.node, this);
|
1623 | },
|
1624 | handleExpandIconClick: function handleExpandIconClick() {
|
1625 | if (this.node.isLeaf) return;
|
1626 | if (this.expanded) {
|
1627 | this.tree.$emit('node-collapse', this.node.data, this.node, this);
|
1628 | this.node.collapse();
|
1629 | } else {
|
1630 | this.node.expand();
|
1631 | this.$emit('node-expand', this.node.data, this.node, this);
|
1632 | }
|
1633 | },
|
1634 | handleCheckChange: function handleCheckChange(value, ev) {
|
1635 | var _this2 = this;
|
1636 |
|
1637 | this.node.setChecked(ev.target.checked, !this.tree.checkStrictly);
|
1638 | this.$nextTick(function () {
|
1639 | var store = _this2.tree.store;
|
1640 | _this2.tree.$emit('check', _this2.node.data, {
|
1641 | checkedNodes: store.getCheckedNodes(),
|
1642 | checkedKeys: store.getCheckedKeys(),
|
1643 | halfCheckedNodes: store.getHalfCheckedNodes(),
|
1644 | halfCheckedKeys: store.getHalfCheckedKeys()
|
1645 | });
|
1646 | });
|
1647 | },
|
1648 | handleChildNodeExpand: function handleChildNodeExpand(nodeData, node, instance) {
|
1649 | this.broadcast('ElTreeNode', 'tree-node-expand', node);
|
1650 | this.tree.$emit('node-expand', nodeData, node, instance);
|
1651 | },
|
1652 | handleDragStart: function handleDragStart(event) {
|
1653 | if (!this.tree.draggable) return;
|
1654 | this.tree.$emit('tree-node-drag-start', event, this);
|
1655 | },
|
1656 | handleDragOver: function handleDragOver(event) {
|
1657 | if (!this.tree.draggable) return;
|
1658 | this.tree.$emit('tree-node-drag-over', event, this);
|
1659 | event.preventDefault();
|
1660 | },
|
1661 | handleDrop: function handleDrop(event) {
|
1662 | event.preventDefault();
|
1663 | },
|
1664 | handleDragEnd: function handleDragEnd(event) {
|
1665 | if (!this.tree.draggable) return;
|
1666 | this.tree.$emit('tree-node-drag-end', event, this);
|
1667 | }
|
1668 | },
|
1669 |
|
1670 | created: function created() {
|
1671 | var _this3 = this;
|
1672 |
|
1673 | var parent = this.$parent;
|
1674 |
|
1675 | if (parent.isTree) {
|
1676 | this.tree = parent;
|
1677 | } else {
|
1678 | this.tree = parent.tree;
|
1679 | }
|
1680 |
|
1681 | var tree = this.tree;
|
1682 | if (!tree) {
|
1683 | console.warn('Can not find node\'s tree.');
|
1684 | }
|
1685 |
|
1686 | var props = tree.props || {};
|
1687 | var childrenKey = props['children'] || 'children';
|
1688 |
|
1689 | this.$watch('node.data.' + childrenKey, function () {
|
1690 | _this3.node.updateChildren();
|
1691 | });
|
1692 |
|
1693 | if (this.node.expanded) {
|
1694 | this.expanded = true;
|
1695 | this.childNodeRendered = true;
|
1696 | }
|
1697 |
|
1698 | if (this.tree.accordion) {
|
1699 | this.$on('tree-node-expand', function (node) {
|
1700 | if (_this3.node !== node) {
|
1701 | _this3.node.collapse();
|
1702 | }
|
1703 | });
|
1704 | }
|
1705 | }
|
1706 | });
|
1707 |
|
1708 | var src_tree_nodevue_type_script_lang_js_ = (tree_nodevue_type_script_lang_js_);
|
1709 |
|
1710 | var componentNormalizer = __webpack_require__(0);
|
1711 |
|
1712 |
|
1713 |
|
1714 |
|
1715 |
|
1716 |
|
1717 |
|
1718 |
|
1719 |
|
1720 | var component = Object(componentNormalizer["a" ])(
|
1721 | src_tree_nodevue_type_script_lang_js_,
|
1722 | tree_nodevue_type_template_id_3ba3ef0e_render,
|
1723 | tree_nodevue_type_template_id_3ba3ef0e_staticRenderFns,
|
1724 | false,
|
1725 | null,
|
1726 | null,
|
1727 | null
|
1728 |
|
1729 | )
|
1730 |
|
1731 |
|
1732 | if (false) { var api; }
|
1733 | component.options.__file = "packages/tree/src/tree-node.vue"
|
1734 | var tree_node = (component.exports);
|
1735 |
|
1736 | var locale_ = __webpack_require__(19);
|
1737 |
|
1738 |
|
1739 | var dom_ = __webpack_require__(2);
|
1740 |
|
1741 |
|
1742 |
|
1743 |
|
1744 |
|
1745 |
|
1746 |
|
1747 |
|
1748 |
|
1749 |
|
1750 |
|
1751 |
|
1752 |
|
1753 |
|
1754 |
|
1755 |
|
1756 |
|
1757 |
|
1758 |
|
1759 |
|
1760 |
|
1761 |
|
1762 |
|
1763 |
|
1764 |
|
1765 |
|
1766 |
|
1767 |
|
1768 |
|
1769 |
|
1770 |
|
1771 |
|
1772 |
|
1773 |
|
1774 |
|
1775 |
|
1776 |
|
1777 |
|
1778 |
|
1779 |
|
1780 |
|
1781 |
|
1782 | var treevue_type_script_lang_js_ = ({
|
1783 | name: 'ElTree',
|
1784 |
|
1785 | mixins: [emitter_default.a],
|
1786 |
|
1787 | components: {
|
1788 | ElTreeNode: tree_node
|
1789 | },
|
1790 |
|
1791 | data: function data() {
|
1792 | return {
|
1793 | store: null,
|
1794 | root: null,
|
1795 | currentNode: null,
|
1796 | treeItems: null,
|
1797 | checkboxItems: [],
|
1798 | dragState: {
|
1799 | showDropIndicator: false,
|
1800 | draggingNode: null,
|
1801 | dropNode: null,
|
1802 | allowDrop: true
|
1803 | }
|
1804 | };
|
1805 | },
|
1806 |
|
1807 |
|
1808 | props: {
|
1809 | data: {
|
1810 | type: Array
|
1811 | },
|
1812 | emptyText: {
|
1813 | type: String,
|
1814 | default: function _default() {
|
1815 | return Object(locale_["t"])('el.tree.emptyText');
|
1816 | }
|
1817 | },
|
1818 | renderAfterExpand: {
|
1819 | type: Boolean,
|
1820 | default: true
|
1821 | },
|
1822 | nodeKey: String,
|
1823 | checkStrictly: Boolean,
|
1824 | defaultExpandAll: Boolean,
|
1825 | expandOnClickNode: {
|
1826 | type: Boolean,
|
1827 | default: true
|
1828 | },
|
1829 | checkOnClickNode: Boolean,
|
1830 | checkDescendants: {
|
1831 | type: Boolean,
|
1832 | default: false
|
1833 | },
|
1834 | autoExpandParent: {
|
1835 | type: Boolean,
|
1836 | default: true
|
1837 | },
|
1838 | defaultCheckedKeys: Array,
|
1839 | defaultExpandedKeys: Array,
|
1840 | currentNodeKey: [String, Number],
|
1841 | renderContent: Function,
|
1842 | showCheckbox: {
|
1843 | type: Boolean,
|
1844 | default: false
|
1845 | },
|
1846 | draggable: {
|
1847 | type: Boolean,
|
1848 | default: false
|
1849 | },
|
1850 | allowDrag: Function,
|
1851 | allowDrop: Function,
|
1852 | props: {
|
1853 | default: function _default() {
|
1854 | return {
|
1855 | children: 'children',
|
1856 | label: 'label',
|
1857 | disabled: 'disabled'
|
1858 | };
|
1859 | }
|
1860 | },
|
1861 | lazy: {
|
1862 | type: Boolean,
|
1863 | default: false
|
1864 | },
|
1865 | highlightCurrent: Boolean,
|
1866 | load: Function,
|
1867 | filterNodeMethod: Function,
|
1868 | accordion: Boolean,
|
1869 | indent: {
|
1870 | type: Number,
|
1871 | default: 18
|
1872 | },
|
1873 | iconClass: String
|
1874 | },
|
1875 |
|
1876 | computed: {
|
1877 | children: {
|
1878 | set: function set(value) {
|
1879 | this.data = value;
|
1880 | },
|
1881 | get: function get() {
|
1882 | return this.data;
|
1883 | }
|
1884 | },
|
1885 |
|
1886 | treeItemArray: function treeItemArray() {
|
1887 | return Array.prototype.slice.call(this.treeItems);
|
1888 | },
|
1889 | isEmpty: function isEmpty() {
|
1890 | var childNodes = this.root.childNodes;
|
1891 |
|
1892 | return !childNodes || childNodes.length === 0 || childNodes.every(function (_ref) {
|
1893 | var visible = _ref.visible;
|
1894 | return !visible;
|
1895 | });
|
1896 | }
|
1897 | },
|
1898 |
|
1899 | watch: {
|
1900 | defaultCheckedKeys: function defaultCheckedKeys(newVal) {
|
1901 | this.store.setDefaultCheckedKey(newVal);
|
1902 | },
|
1903 | defaultExpandedKeys: function defaultExpandedKeys(newVal) {
|
1904 | this.store.defaultExpandedKeys = newVal;
|
1905 | this.store.setDefaultExpandedKeys(newVal);
|
1906 | },
|
1907 | data: function data(newVal) {
|
1908 | this.store.setData(newVal);
|
1909 | },
|
1910 | checkboxItems: function checkboxItems(val) {
|
1911 | Array.prototype.forEach.call(val, function (checkbox) {
|
1912 | checkbox.setAttribute('tabindex', -1);
|
1913 | });
|
1914 | },
|
1915 | checkStrictly: function checkStrictly(newVal) {
|
1916 | this.store.checkStrictly = newVal;
|
1917 | }
|
1918 | },
|
1919 |
|
1920 | methods: {
|
1921 | filter: function filter(value) {
|
1922 | if (!this.filterNodeMethod) throw new Error('[Tree] filterNodeMethod is required when filter');
|
1923 | this.store.filter(value);
|
1924 | },
|
1925 | getNodeKey: function getNodeKey(node) {
|
1926 | return util_getNodeKey(this.nodeKey, node.data);
|
1927 | },
|
1928 | getNodePath: function getNodePath(data) {
|
1929 | if (!this.nodeKey) throw new Error('[Tree] nodeKey is required in getNodePath');
|
1930 | var node = this.store.getNode(data);
|
1931 | if (!node) return [];
|
1932 | var path = [node.data];
|
1933 | var parent = node.parent;
|
1934 | while (parent && parent !== this.root) {
|
1935 | path.push(parent.data);
|
1936 | parent = parent.parent;
|
1937 | }
|
1938 | return path.reverse();
|
1939 | },
|
1940 | getCheckedNodes: function getCheckedNodes(leafOnly, includeHalfChecked) {
|
1941 | return this.store.getCheckedNodes(leafOnly, includeHalfChecked);
|
1942 | },
|
1943 | getCheckedKeys: function getCheckedKeys(leafOnly) {
|
1944 | return this.store.getCheckedKeys(leafOnly);
|
1945 | },
|
1946 | getCurrentNode: function getCurrentNode() {
|
1947 | var currentNode = this.store.getCurrentNode();
|
1948 | return currentNode ? currentNode.data : null;
|
1949 | },
|
1950 | getCurrentKey: function getCurrentKey() {
|
1951 | if (!this.nodeKey) throw new Error('[Tree] nodeKey is required in getCurrentKey');
|
1952 | var currentNode = this.getCurrentNode();
|
1953 | return currentNode ? currentNode[this.nodeKey] : null;
|
1954 | },
|
1955 | setCheckedNodes: function setCheckedNodes(nodes, leafOnly) {
|
1956 | if (!this.nodeKey) throw new Error('[Tree] nodeKey is required in setCheckedNodes');
|
1957 | this.store.setCheckedNodes(nodes, leafOnly);
|
1958 | },
|
1959 | setCheckedKeys: function setCheckedKeys(keys, leafOnly) {
|
1960 | if (!this.nodeKey) throw new Error('[Tree] nodeKey is required in setCheckedKeys');
|
1961 | this.store.setCheckedKeys(keys, leafOnly);
|
1962 | },
|
1963 | setChecked: function setChecked(data, checked, deep) {
|
1964 | this.store.setChecked(data, checked, deep);
|
1965 | },
|
1966 | getHalfCheckedNodes: function getHalfCheckedNodes() {
|
1967 | return this.store.getHalfCheckedNodes();
|
1968 | },
|
1969 | getHalfCheckedKeys: function getHalfCheckedKeys() {
|
1970 | return this.store.getHalfCheckedKeys();
|
1971 | },
|
1972 | setCurrentNode: function setCurrentNode(node) {
|
1973 | if (!this.nodeKey) throw new Error('[Tree] nodeKey is required in setCurrentNode');
|
1974 | this.store.setUserCurrentNode(node);
|
1975 | },
|
1976 | setCurrentKey: function setCurrentKey(key) {
|
1977 | if (!this.nodeKey) throw new Error('[Tree] nodeKey is required in setCurrentKey');
|
1978 | this.store.setCurrentNodeKey(key);
|
1979 | },
|
1980 | getNode: function getNode(data) {
|
1981 | return this.store.getNode(data);
|
1982 | },
|
1983 | remove: function remove(data) {
|
1984 | this.store.remove(data);
|
1985 | },
|
1986 | append: function append(data, parentNode) {
|
1987 | this.store.append(data, parentNode);
|
1988 | },
|
1989 | insertBefore: function insertBefore(data, refNode) {
|
1990 | this.store.insertBefore(data, refNode);
|
1991 | },
|
1992 | insertAfter: function insertAfter(data, refNode) {
|
1993 | this.store.insertAfter(data, refNode);
|
1994 | },
|
1995 | handleNodeExpand: function handleNodeExpand(nodeData, node, instance) {
|
1996 | this.broadcast('ElTreeNode', 'tree-node-expand', node);
|
1997 | this.$emit('node-expand', nodeData, node, instance);
|
1998 | },
|
1999 | updateKeyChildren: function updateKeyChildren(key, data) {
|
2000 | if (!this.nodeKey) throw new Error('[Tree] nodeKey is required in updateKeyChild');
|
2001 | this.store.updateChildren(key, data);
|
2002 | },
|
2003 | initTabIndex: function initTabIndex() {
|
2004 | this.treeItems = this.$el.querySelectorAll('.is-focusable[role=treeitem]');
|
2005 | this.checkboxItems = this.$el.querySelectorAll('input[type=checkbox]');
|
2006 | var checkedItem = this.$el.querySelectorAll('.is-checked[role=treeitem]');
|
2007 | if (checkedItem.length) {
|
2008 | checkedItem[0].setAttribute('tabindex', 0);
|
2009 | return;
|
2010 | }
|
2011 | this.treeItems[0] && this.treeItems[0].setAttribute('tabindex', 0);
|
2012 | },
|
2013 | handleKeydown: function handleKeydown(ev) {
|
2014 | var currentItem = ev.target;
|
2015 | if (currentItem.className.indexOf('el-tree-node') === -1) return;
|
2016 | var keyCode = ev.keyCode;
|
2017 | this.treeItems = this.$el.querySelectorAll('.is-focusable[role=treeitem]');
|
2018 | var currentIndex = this.treeItemArray.indexOf(currentItem);
|
2019 | var nextIndex = void 0;
|
2020 | if ([38, 40].indexOf(keyCode) > -1) {
|
2021 |
|
2022 | ev.preventDefault();
|
2023 | if (keyCode === 38) {
|
2024 |
|
2025 | nextIndex = currentIndex !== 0 ? currentIndex - 1 : 0;
|
2026 | } else {
|
2027 | nextIndex = currentIndex < this.treeItemArray.length - 1 ? currentIndex + 1 : 0;
|
2028 | }
|
2029 | this.treeItemArray[nextIndex].focus();
|
2030 | }
|
2031 | if ([37, 39].indexOf(keyCode) > -1) {
|
2032 |
|
2033 | ev.preventDefault();
|
2034 | currentItem.click();
|
2035 | }
|
2036 | var hasInput = currentItem.querySelector('[type="checkbox"]');
|
2037 | if ([13, 32].indexOf(keyCode) > -1 && hasInput) {
|
2038 |
|
2039 | ev.preventDefault();
|
2040 | hasInput.click();
|
2041 | }
|
2042 | }
|
2043 | },
|
2044 |
|
2045 | created: function created() {
|
2046 | var _this = this;
|
2047 |
|
2048 | this.isTree = true;
|
2049 |
|
2050 | this.store = new tree_store({
|
2051 | key: this.nodeKey,
|
2052 | data: this.data,
|
2053 | lazy: this.lazy,
|
2054 | props: this.props,
|
2055 | load: this.load,
|
2056 | currentNodeKey: this.currentNodeKey,
|
2057 | checkStrictly: this.checkStrictly,
|
2058 | checkDescendants: this.checkDescendants,
|
2059 | defaultCheckedKeys: this.defaultCheckedKeys,
|
2060 | defaultExpandedKeys: this.defaultExpandedKeys,
|
2061 | autoExpandParent: this.autoExpandParent,
|
2062 | defaultExpandAll: this.defaultExpandAll,
|
2063 | filterNodeMethod: this.filterNodeMethod
|
2064 | });
|
2065 |
|
2066 | this.root = this.store.root;
|
2067 |
|
2068 | var dragState = this.dragState;
|
2069 | this.$on('tree-node-drag-start', function (event, treeNode) {
|
2070 | if (typeof _this.allowDrag === 'function' && !_this.allowDrag(treeNode.node)) {
|
2071 | event.preventDefault();
|
2072 | return false;
|
2073 | }
|
2074 | event.dataTransfer.effectAllowed = 'move';
|
2075 |
|
2076 |
|
2077 | try {
|
2078 |
|
2079 |
|
2080 | event.dataTransfer.setData('text/plain', '');
|
2081 | } catch (e) {}
|
2082 | dragState.draggingNode = treeNode;
|
2083 | _this.$emit('node-drag-start', treeNode.node, event);
|
2084 | });
|
2085 |
|
2086 | this.$on('tree-node-drag-over', function (event, treeNode) {
|
2087 | var dropNode = findNearestComponent(event.target, 'ElTreeNode');
|
2088 | var oldDropNode = dragState.dropNode;
|
2089 | if (oldDropNode && oldDropNode !== dropNode) {
|
2090 | Object(dom_["removeClass"])(oldDropNode.$el, 'is-drop-inner');
|
2091 | }
|
2092 | var draggingNode = dragState.draggingNode;
|
2093 | if (!draggingNode || !dropNode) return;
|
2094 |
|
2095 | var dropPrev = true;
|
2096 | var dropInner = true;
|
2097 | var dropNext = true;
|
2098 | var userAllowDropInner = true;
|
2099 | if (typeof _this.allowDrop === 'function') {
|
2100 | dropPrev = _this.allowDrop(draggingNode.node, dropNode.node, 'prev');
|
2101 | userAllowDropInner = dropInner = _this.allowDrop(draggingNode.node, dropNode.node, 'inner');
|
2102 | dropNext = _this.allowDrop(draggingNode.node, dropNode.node, 'next');
|
2103 | }
|
2104 | event.dataTransfer.dropEffect = dropInner ? 'move' : 'none';
|
2105 | if ((dropPrev || dropInner || dropNext) && oldDropNode !== dropNode) {
|
2106 | if (oldDropNode) {
|
2107 | _this.$emit('node-drag-leave', draggingNode.node, oldDropNode.node, event);
|
2108 | }
|
2109 | _this.$emit('node-drag-enter', draggingNode.node, dropNode.node, event);
|
2110 | }
|
2111 |
|
2112 | if (dropPrev || dropInner || dropNext) {
|
2113 | dragState.dropNode = dropNode;
|
2114 | }
|
2115 |
|
2116 | if (dropNode.node.nextSibling === draggingNode.node) {
|
2117 | dropNext = false;
|
2118 | }
|
2119 | if (dropNode.node.previousSibling === draggingNode.node) {
|
2120 | dropPrev = false;
|
2121 | }
|
2122 | if (dropNode.node.contains(draggingNode.node, false)) {
|
2123 | dropInner = false;
|
2124 | }
|
2125 | if (draggingNode.node === dropNode.node || draggingNode.node.contains(dropNode.node)) {
|
2126 | dropPrev = false;
|
2127 | dropInner = false;
|
2128 | dropNext = false;
|
2129 | }
|
2130 |
|
2131 | var targetPosition = dropNode.$el.getBoundingClientRect();
|
2132 | var treePosition = _this.$el.getBoundingClientRect();
|
2133 |
|
2134 | var dropType = void 0;
|
2135 | var prevPercent = dropPrev ? dropInner ? 0.25 : dropNext ? 0.45 : 1 : -1;
|
2136 | var nextPercent = dropNext ? dropInner ? 0.75 : dropPrev ? 0.55 : 0 : 1;
|
2137 |
|
2138 | var indicatorTop = -9999;
|
2139 | var distance = event.clientY - targetPosition.top;
|
2140 | if (distance < targetPosition.height * prevPercent) {
|
2141 | dropType = 'before';
|
2142 | } else if (distance > targetPosition.height * nextPercent) {
|
2143 | dropType = 'after';
|
2144 | } else if (dropInner) {
|
2145 | dropType = 'inner';
|
2146 | } else {
|
2147 | dropType = 'none';
|
2148 | }
|
2149 |
|
2150 | var iconPosition = dropNode.$el.querySelector('.el-tree-node__expand-icon').getBoundingClientRect();
|
2151 | var dropIndicator = _this.$refs.dropIndicator;
|
2152 | if (dropType === 'before') {
|
2153 | indicatorTop = iconPosition.top - treePosition.top;
|
2154 | } else if (dropType === 'after') {
|
2155 | indicatorTop = iconPosition.bottom - treePosition.top;
|
2156 | }
|
2157 | dropIndicator.style.top = indicatorTop + 'px';
|
2158 | dropIndicator.style.left = iconPosition.right - treePosition.left + 'px';
|
2159 |
|
2160 | if (dropType === 'inner') {
|
2161 | Object(dom_["addClass"])(dropNode.$el, 'is-drop-inner');
|
2162 | } else {
|
2163 | Object(dom_["removeClass"])(dropNode.$el, 'is-drop-inner');
|
2164 | }
|
2165 |
|
2166 | dragState.showDropIndicator = dropType === 'before' || dropType === 'after';
|
2167 | dragState.allowDrop = dragState.showDropIndicator || userAllowDropInner;
|
2168 | dragState.dropType = dropType;
|
2169 | _this.$emit('node-drag-over', draggingNode.node, dropNode.node, event);
|
2170 | });
|
2171 |
|
2172 | this.$on('tree-node-drag-end', function (event) {
|
2173 | var draggingNode = dragState.draggingNode,
|
2174 | dropType = dragState.dropType,
|
2175 | dropNode = dragState.dropNode;
|
2176 |
|
2177 | event.preventDefault();
|
2178 | event.dataTransfer.dropEffect = 'move';
|
2179 |
|
2180 | if (draggingNode && dropNode) {
|
2181 | var draggingNodeCopy = { data: draggingNode.node.data };
|
2182 | if (dropType !== 'none') {
|
2183 | draggingNode.node.remove();
|
2184 | }
|
2185 | if (dropType === 'before') {
|
2186 | dropNode.node.parent.insertBefore(draggingNodeCopy, dropNode.node);
|
2187 | } else if (dropType === 'after') {
|
2188 | dropNode.node.parent.insertAfter(draggingNodeCopy, dropNode.node);
|
2189 | } else if (dropType === 'inner') {
|
2190 | dropNode.node.insertChild(draggingNodeCopy);
|
2191 | }
|
2192 | if (dropType !== 'none') {
|
2193 | _this.store.registerNode(draggingNodeCopy);
|
2194 | }
|
2195 |
|
2196 | Object(dom_["removeClass"])(dropNode.$el, 'is-drop-inner');
|
2197 |
|
2198 | _this.$emit('node-drag-end', draggingNode.node, dropNode.node, dropType, event);
|
2199 | if (dropType !== 'none') {
|
2200 | _this.$emit('node-drop', draggingNode.node, dropNode.node, dropType, event);
|
2201 | }
|
2202 | }
|
2203 | if (draggingNode && !dropNode) {
|
2204 | _this.$emit('node-drag-end', draggingNode.node, null, dropType, event);
|
2205 | }
|
2206 |
|
2207 | dragState.showDropIndicator = false;
|
2208 | dragState.draggingNode = null;
|
2209 | dragState.dropNode = null;
|
2210 | dragState.allowDrop = true;
|
2211 | });
|
2212 | },
|
2213 | mounted: function mounted() {
|
2214 | this.initTabIndex();
|
2215 | this.$el.addEventListener('keydown', this.handleKeydown);
|
2216 | },
|
2217 | updated: function updated() {
|
2218 | this.treeItems = this.$el.querySelectorAll('[role=treeitem]');
|
2219 | this.checkboxItems = this.$el.querySelectorAll('input[type=checkbox]');
|
2220 | }
|
2221 | });
|
2222 |
|
2223 | var src_treevue_type_script_lang_js_ = (treevue_type_script_lang_js_);
|
2224 |
|
2225 |
|
2226 |
|
2227 |
|
2228 |
|
2229 |
|
2230 |
|
2231 |
|
2232 | var tree_component = Object(componentNormalizer["a" ])(
|
2233 | src_treevue_type_script_lang_js_,
|
2234 | render,
|
2235 | staticRenderFns,
|
2236 | false,
|
2237 | null,
|
2238 | null,
|
2239 | null
|
2240 |
|
2241 | )
|
2242 |
|
2243 |
|
2244 | if (false) { var tree_api; }
|
2245 | tree_component.options.__file = "packages/tree/src/tree.vue"
|
2246 | var tree = (tree_component.exports);
|
2247 |
|
2248 |
|
2249 |
|
2250 |
|
2251 | tree.install = function (Vue) {
|
2252 | Vue.component(tree.name, tree);
|
2253 | };
|
2254 |
|
2255 | var packages_tree = __webpack_exports__["default"] = (tree);
|
2256 |
|
2257 | }),
|
2258 |
|
2259 | 9:
|
2260 | (function(module, exports) {
|
2261 |
|
2262 | module.exports = require("element-ui/lib/utils/merge");
|
2263 |
|
2264 | })
|
2265 |
|
2266 | }); |
\ | No newline at end of file |