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 = 56);
|
86 | })
|
87 |
|
88 | ([
|
89 |
|
90 | (function(module, __webpack_exports__, __webpack_require__) {
|
91 |
|
92 | "use strict";
|
93 | __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; });
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 | function normalizeComponent (
|
101 | scriptExports,
|
102 | render,
|
103 | staticRenderFns,
|
104 | functionalTemplate,
|
105 | injectStyles,
|
106 | scopeId,
|
107 | moduleIdentifier, /* server only */
|
108 | shadowMode /* vue-cli only */
|
109 | ) {
|
110 |
|
111 | var options = typeof scriptExports === 'function'
|
112 | ? scriptExports.options
|
113 | : scriptExports
|
114 |
|
115 |
|
116 | if (render) {
|
117 | options.render = render
|
118 | options.staticRenderFns = staticRenderFns
|
119 | options._compiled = true
|
120 | }
|
121 |
|
122 |
|
123 | if (functionalTemplate) {
|
124 | options.functional = true
|
125 | }
|
126 |
|
127 |
|
128 | if (scopeId) {
|
129 | options._scopeId = 'data-v-' + scopeId
|
130 | }
|
131 |
|
132 | var hook
|
133 | if (moduleIdentifier) {
|
134 | hook = function (context) {
|
135 |
|
136 | context =
|
137 | context ||
|
138 | (this.$vnode && this.$vnode.ssrContext) ||
|
139 | (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext)
|
140 |
|
141 | if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
|
142 | context = __VUE_SSR_CONTEXT__
|
143 | }
|
144 |
|
145 | if (injectStyles) {
|
146 | injectStyles.call(this, context)
|
147 | }
|
148 |
|
149 | if (context && context._registeredComponents) {
|
150 | context._registeredComponents.add(moduleIdentifier)
|
151 | }
|
152 | }
|
153 |
|
154 |
|
155 | options._ssrRegister = hook
|
156 | } else if (injectStyles) {
|
157 | hook = shadowMode
|
158 | ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
|
159 | : injectStyles
|
160 | }
|
161 |
|
162 | if (hook) {
|
163 | if (options.functional) {
|
164 |
|
165 |
|
166 | options._injectStyles = hook
|
167 |
|
168 | var originalRender = options.render
|
169 | options.render = function renderWithStyleInjection (h, context) {
|
170 | hook.call(context)
|
171 | return originalRender(h, context)
|
172 | }
|
173 | } else {
|
174 |
|
175 | var existing = options.beforeCreate
|
176 | options.beforeCreate = existing
|
177 | ? [].concat(existing, hook)
|
178 | : [hook]
|
179 | }
|
180 | }
|
181 |
|
182 | return {
|
183 | exports: scriptExports,
|
184 | options: options
|
185 | }
|
186 | }
|
187 |
|
188 |
|
189 | }),
|
190 | ,
|
191 |
|
192 | (function(module, exports) {
|
193 |
|
194 | module.exports = require("element-ui/lib/utils/dom");
|
195 |
|
196 | }),
|
197 |
|
198 | (function(module, exports) {
|
199 |
|
200 | module.exports = require("element-ui/lib/utils/util");
|
201 |
|
202 | }),
|
203 | ,
|
204 |
|
205 | (function(module, exports) {
|
206 |
|
207 | module.exports = require("element-ui/lib/utils/vue-popper");
|
208 |
|
209 | }),
|
210 |
|
211 | (function(module, exports) {
|
212 |
|
213 | module.exports = require("element-ui/lib/mixins/locale");
|
214 |
|
215 | }),
|
216 |
|
217 | (function(module, exports) {
|
218 |
|
219 | module.exports = require("vue");
|
220 |
|
221 | }),
|
222 |
|
223 | (function(module, __webpack_exports__, __webpack_require__) {
|
224 |
|
225 | "use strict";
|
226 | __webpack_require__.d(__webpack_exports__, "b", function() { return getCell; });
|
227 | __webpack_require__.d(__webpack_exports__, "i", function() { return orderBy; });
|
228 | __webpack_require__.d(__webpack_exports__, "d", function() { return getColumnById; });
|
229 | __webpack_require__.d(__webpack_exports__, "e", function() { return getColumnByKey; });
|
230 | __webpack_require__.d(__webpack_exports__, "c", function() { return getColumnByCell; });
|
231 | __webpack_require__.d(__webpack_exports__, "g", function() { return getRowIdentity; });
|
232 | __webpack_require__.d(__webpack_exports__, "f", function() { return getKeysMap; });
|
233 | __webpack_require__.d(__webpack_exports__, "h", function() { return mergeOptions; });
|
234 | __webpack_require__.d(__webpack_exports__, "l", function() { return parseWidth; });
|
235 | __webpack_require__.d(__webpack_exports__, "k", function() { return parseMinWidth; });
|
236 | __webpack_require__.d(__webpack_exports__, "j", function() { return parseHeight; });
|
237 | __webpack_require__.d(__webpack_exports__, "a", function() { return compose; });
|
238 | __webpack_require__.d(__webpack_exports__, "m", function() { return toggleRowStatus; });
|
239 | __webpack_require__.d(__webpack_exports__, "n", function() { return walkTreeNode; });
|
240 | var element_ui_src_utils_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
|
241 | var element_ui_src_utils_util__WEBPACK_IMPORTED_MODULE_0___default = __webpack_require__.n(element_ui_src_utils_util__WEBPACK_IMPORTED_MODULE_0__);
|
242 | 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; };
|
243 |
|
244 |
|
245 |
|
246 | var getCell = function getCell(event) {
|
247 | var cell = event.target;
|
248 |
|
249 | while (cell && cell.tagName.toUpperCase() !== 'HTML') {
|
250 | if (cell.tagName.toUpperCase() === 'TD') {
|
251 | return cell;
|
252 | }
|
253 | cell = cell.parentNode;
|
254 | }
|
255 |
|
256 | return null;
|
257 | };
|
258 |
|
259 | var isObject = function isObject(obj) {
|
260 | return obj !== null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object';
|
261 | };
|
262 |
|
263 | var orderBy = function orderBy(array, sortKey, reverse, sortMethod, sortBy) {
|
264 | if (!sortKey && !sortMethod && (!sortBy || Array.isArray(sortBy) && !sortBy.length)) {
|
265 | return array;
|
266 | }
|
267 | if (typeof reverse === 'string') {
|
268 | reverse = reverse === 'descending' ? -1 : 1;
|
269 | } else {
|
270 | reverse = reverse && reverse < 0 ? -1 : 1;
|
271 | }
|
272 | var getKey = sortMethod ? null : function (value, index) {
|
273 | if (sortBy) {
|
274 | if (!Array.isArray(sortBy)) {
|
275 | sortBy = [sortBy];
|
276 | }
|
277 | return sortBy.map(function (by) {
|
278 | if (typeof by === 'string') {
|
279 | return Object(element_ui_src_utils_util__WEBPACK_IMPORTED_MODULE_0__["getValueByPath"])(value, by);
|
280 | } else {
|
281 | return by(value, index, array);
|
282 | }
|
283 | });
|
284 | }
|
285 | if (sortKey !== '$key') {
|
286 | if (isObject(value) && '$value' in value) value = value.$value;
|
287 | }
|
288 | return [isObject(value) ? Object(element_ui_src_utils_util__WEBPACK_IMPORTED_MODULE_0__["getValueByPath"])(value, sortKey) : value];
|
289 | };
|
290 | var compare = function compare(a, b) {
|
291 | if (sortMethod) {
|
292 | return sortMethod(a.value, b.value);
|
293 | }
|
294 | for (var i = 0, len = a.key.length; i < len; i++) {
|
295 | if (a.key[i] < b.key[i]) {
|
296 | return -1;
|
297 | }
|
298 | if (a.key[i] > b.key[i]) {
|
299 | return 1;
|
300 | }
|
301 | }
|
302 | return 0;
|
303 | };
|
304 | return array.map(function (value, index) {
|
305 | return {
|
306 | value: value,
|
307 | index: index,
|
308 | key: getKey ? getKey(value, index) : null
|
309 | };
|
310 | }).sort(function (a, b) {
|
311 | var order = compare(a, b);
|
312 | if (!order) {
|
313 |
|
314 | order = a.index - b.index;
|
315 | }
|
316 | return order * reverse;
|
317 | }).map(function (item) {
|
318 | return item.value;
|
319 | });
|
320 | };
|
321 |
|
322 | var getColumnById = function getColumnById(table, columnId) {
|
323 | var column = null;
|
324 | table.columns.forEach(function (item) {
|
325 | if (item.id === columnId) {
|
326 | column = item;
|
327 | }
|
328 | });
|
329 | return column;
|
330 | };
|
331 |
|
332 | var getColumnByKey = function getColumnByKey(table, columnKey) {
|
333 | var column = null;
|
334 | for (var i = 0; i < table.columns.length; i++) {
|
335 | var item = table.columns[i];
|
336 | if (item.columnKey === columnKey) {
|
337 | column = item;
|
338 | break;
|
339 | }
|
340 | }
|
341 | return column;
|
342 | };
|
343 |
|
344 | var getColumnByCell = function getColumnByCell(table, cell) {
|
345 | var matches = (cell.className || '').match(/el-table_[^\s]+/gm);
|
346 | if (matches) {
|
347 | return getColumnById(table, matches[0]);
|
348 | }
|
349 | return null;
|
350 | };
|
351 |
|
352 | var getRowIdentity = function getRowIdentity(row, rowKey) {
|
353 | if (!row) throw new Error('row is required when get row identity');
|
354 | if (typeof rowKey === 'string') {
|
355 | if (rowKey.indexOf('.') < 0) {
|
356 | return row[rowKey];
|
357 | }
|
358 | var key = rowKey.split('.');
|
359 | var current = row;
|
360 | for (var i = 0; i < key.length; i++) {
|
361 | current = current[key[i]];
|
362 | }
|
363 | return current;
|
364 | } else if (typeof rowKey === 'function') {
|
365 | return rowKey.call(null, row);
|
366 | }
|
367 | };
|
368 |
|
369 | var getKeysMap = function getKeysMap(array, rowKey) {
|
370 | var arrayMap = {};
|
371 | (array || []).forEach(function (row, index) {
|
372 | arrayMap[getRowIdentity(row, rowKey)] = { row: row, index: index };
|
373 | });
|
374 | return arrayMap;
|
375 | };
|
376 |
|
377 | function hasOwn(obj, key) {
|
378 | return Object.prototype.hasOwnProperty.call(obj, key);
|
379 | }
|
380 |
|
381 | function mergeOptions(defaults, config) {
|
382 | var options = {};
|
383 | var key = void 0;
|
384 | for (key in defaults) {
|
385 | options[key] = defaults[key];
|
386 | }
|
387 | for (key in config) {
|
388 | if (hasOwn(config, key)) {
|
389 | var value = config[key];
|
390 | if (typeof value !== 'undefined') {
|
391 | options[key] = value;
|
392 | }
|
393 | }
|
394 | }
|
395 | return options;
|
396 | }
|
397 |
|
398 | function parseWidth(width) {
|
399 | if (width !== undefined) {
|
400 | width = parseInt(width, 10);
|
401 | if (isNaN(width)) {
|
402 | width = null;
|
403 | }
|
404 | }
|
405 | return width;
|
406 | }
|
407 |
|
408 | function parseMinWidth(minWidth) {
|
409 | if (typeof minWidth !== 'undefined') {
|
410 | minWidth = parseWidth(minWidth);
|
411 | if (isNaN(minWidth)) {
|
412 | minWidth = 80;
|
413 | }
|
414 | }
|
415 | return minWidth;
|
416 | };
|
417 |
|
418 | function parseHeight(height) {
|
419 | if (typeof height === 'number') {
|
420 | return height;
|
421 | }
|
422 | if (typeof height === 'string') {
|
423 | if (/^\d+(?:px)?$/.test(height)) {
|
424 | return parseInt(height, 10);
|
425 | } else {
|
426 | return height;
|
427 | }
|
428 | }
|
429 | return null;
|
430 | }
|
431 |
|
432 |
|
433 | function compose() {
|
434 | for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) {
|
435 | funcs[_key] = arguments[_key];
|
436 | }
|
437 |
|
438 | if (funcs.length === 0) {
|
439 | return function (arg) {
|
440 | return arg;
|
441 | };
|
442 | }
|
443 | if (funcs.length === 1) {
|
444 | return funcs[0];
|
445 | }
|
446 | return funcs.reduce(function (a, b) {
|
447 | return function () {
|
448 | return a(b.apply(undefined, arguments));
|
449 | };
|
450 | });
|
451 | }
|
452 |
|
453 | function toggleRowStatus(statusArr, row, newVal) {
|
454 | var changed = false;
|
455 | var index = statusArr.indexOf(row);
|
456 | var included = index !== -1;
|
457 |
|
458 | var addRow = function addRow() {
|
459 | statusArr.push(row);
|
460 | changed = true;
|
461 | };
|
462 | var removeRow = function removeRow() {
|
463 | statusArr.splice(index, 1);
|
464 | changed = true;
|
465 | };
|
466 |
|
467 | if (typeof newVal === 'boolean') {
|
468 | if (newVal && !included) {
|
469 | addRow();
|
470 | } else if (!newVal && included) {
|
471 | removeRow();
|
472 | }
|
473 | } else {
|
474 | if (included) {
|
475 | removeRow();
|
476 | } else {
|
477 | addRow();
|
478 | }
|
479 | }
|
480 | return changed;
|
481 | }
|
482 |
|
483 | function walkTreeNode(root, cb) {
|
484 | var childrenKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'children';
|
485 | var lazyKey = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'hasChildren';
|
486 |
|
487 | var isNil = function isNil(array) {
|
488 | return !(Array.isArray(array) && array.length);
|
489 | };
|
490 |
|
491 | function _walker(parent, children, level) {
|
492 | cb(parent, children, level);
|
493 | children.forEach(function (item) {
|
494 | if (item[lazyKey]) {
|
495 | cb(item, null, level + 1);
|
496 | return;
|
497 | }
|
498 | var children = item[childrenKey];
|
499 | if (!isNil(children)) {
|
500 | _walker(item, children, level + 1);
|
501 | }
|
502 | });
|
503 | }
|
504 |
|
505 | root.forEach(function (item) {
|
506 | if (item[lazyKey]) {
|
507 | cb(item, null, 0);
|
508 | return;
|
509 | }
|
510 | var children = item[childrenKey];
|
511 | if (!isNil(children)) {
|
512 | _walker(item, children, 0);
|
513 | }
|
514 | });
|
515 | }
|
516 |
|
517 | }),
|
518 |
|
519 | (function(module, exports) {
|
520 |
|
521 | module.exports = require("element-ui/lib/utils/merge");
|
522 |
|
523 | }),
|
524 | ,
|
525 |
|
526 | (function(module, exports) {
|
527 |
|
528 | module.exports = require("element-ui/lib/mixins/migrating");
|
529 |
|
530 | }),
|
531 |
|
532 | (function(module, exports) {
|
533 |
|
534 | module.exports = require("element-ui/lib/utils/clickoutside");
|
535 |
|
536 | }),
|
537 | ,
|
538 |
|
539 | (function(module, exports) {
|
540 |
|
541 | module.exports = require("element-ui/lib/scrollbar");
|
542 |
|
543 | }),
|
544 |
|
545 | (function(module, exports) {
|
546 |
|
547 | module.exports = require("element-ui/lib/utils/popup");
|
548 |
|
549 | }),
|
550 |
|
551 | (function(module, exports) {
|
552 |
|
553 | module.exports = require("element-ui/lib/utils/resize-event");
|
554 |
|
555 | }),
|
556 |
|
557 | (function(module, exports) {
|
558 |
|
559 | module.exports = require("throttle-debounce/debounce");
|
560 |
|
561 | }),
|
562 |
|
563 | (function(module, exports) {
|
564 |
|
565 | module.exports = require("element-ui/lib/checkbox");
|
566 |
|
567 | }),
|
568 | ,
|
569 | ,
|
570 | ,
|
571 | ,
|
572 | ,
|
573 | ,
|
574 | ,
|
575 | ,
|
576 | ,
|
577 | ,
|
578 |
|
579 | (function(module, exports) {
|
580 |
|
581 | module.exports = require("element-ui/lib/tooltip");
|
582 |
|
583 | }),
|
584 | ,
|
585 | ,
|
586 | ,
|
587 | ,
|
588 | ,
|
589 | ,
|
590 | ,
|
591 | ,
|
592 |
|
593 | (function(module, exports) {
|
594 |
|
595 | module.exports = require("element-ui/lib/utils/scrollbar-width");
|
596 |
|
597 | }),
|
598 |
|
599 | (function(module, exports) {
|
600 |
|
601 | module.exports = require("element-ui/lib/checkbox-group");
|
602 |
|
603 | }),
|
604 | ,
|
605 | ,
|
606 | ,
|
607 |
|
608 | (function(module, exports) {
|
609 |
|
610 | module.exports = require("throttle-debounce");
|
611 |
|
612 | }),
|
613 | ,
|
614 | ,
|
615 |
|
616 | (function(module, exports) {
|
617 |
|
618 | module.exports = require("normalize-wheel");
|
619 |
|
620 | }),
|
621 | ,
|
622 | ,
|
623 | ,
|
624 | ,
|
625 | ,
|
626 | ,
|
627 | ,
|
628 | ,
|
629 | ,
|
630 |
|
631 | (function(module, __webpack_exports__, __webpack_require__) {
|
632 |
|
633 | "use strict";
|
634 | __webpack_require__.r(__webpack_exports__);
|
635 |
|
636 |
|
637 | var render = function() {
|
638 | var _vm = this
|
639 | var _h = _vm.$createElement
|
640 | var _c = _vm._self._c || _h
|
641 | return _c(
|
642 | "div",
|
643 | {
|
644 | staticClass: "el-table",
|
645 | class: [
|
646 | {
|
647 | "el-table--fit": _vm.fit,
|
648 | "el-table--striped": _vm.stripe,
|
649 | "el-table--border": _vm.border || _vm.isGroup,
|
650 | "el-table--hidden": _vm.isHidden,
|
651 | "el-table--group": _vm.isGroup,
|
652 | "el-table--fluid-height": _vm.maxHeight,
|
653 | "el-table--scrollable-x": _vm.layout.scrollX,
|
654 | "el-table--scrollable-y": _vm.layout.scrollY,
|
655 | "el-table--enable-row-hover": !_vm.store.states.isComplex,
|
656 | "el-table--enable-row-transition":
|
657 | (_vm.store.states.data || []).length !== 0 &&
|
658 | (_vm.store.states.data || []).length < 100
|
659 | },
|
660 | _vm.tableSize ? "el-table--" + _vm.tableSize : ""
|
661 | ],
|
662 | on: {
|
663 | mouseleave: function($event) {
|
664 | _vm.handleMouseLeave($event)
|
665 | }
|
666 | }
|
667 | },
|
668 | [
|
669 | _c(
|
670 | "div",
|
671 | { ref: "hiddenColumns", staticClass: "hidden-columns" },
|
672 | [_vm._t("default")],
|
673 | 2
|
674 | ),
|
675 | _vm.showHeader
|
676 | ? _c(
|
677 | "div",
|
678 | {
|
679 | directives: [
|
680 | {
|
681 | name: "mousewheel",
|
682 | rawName: "v-mousewheel",
|
683 | value: _vm.handleHeaderFooterMousewheel,
|
684 | expression: "handleHeaderFooterMousewheel"
|
685 | }
|
686 | ],
|
687 | ref: "headerWrapper",
|
688 | staticClass: "el-table__header-wrapper"
|
689 | },
|
690 | [
|
691 | _c("table-header", {
|
692 | ref: "tableHeader",
|
693 | style: {
|
694 | width: _vm.layout.bodyWidth ? _vm.layout.bodyWidth + "px" : ""
|
695 | },
|
696 | attrs: {
|
697 | store: _vm.store,
|
698 | border: _vm.border,
|
699 | "default-sort": _vm.defaultSort
|
700 | }
|
701 | })
|
702 | ],
|
703 | 1
|
704 | )
|
705 | : _vm._e(),
|
706 | _c(
|
707 | "div",
|
708 | {
|
709 | ref: "bodyWrapper",
|
710 | staticClass: "el-table__body-wrapper",
|
711 | class: [
|
712 | _vm.layout.scrollX
|
713 | ? "is-scrolling-" + _vm.scrollPosition
|
714 | : "is-scrolling-none"
|
715 | ],
|
716 | style: [_vm.bodyHeight]
|
717 | },
|
718 | [
|
719 | _c("table-body", {
|
720 | style: {
|
721 | width: _vm.bodyWidth
|
722 | },
|
723 | attrs: {
|
724 | context: _vm.context,
|
725 | store: _vm.store,
|
726 | stripe: _vm.stripe,
|
727 | "row-class-name": _vm.rowClassName,
|
728 | "row-style": _vm.rowStyle,
|
729 | highlight: _vm.highlightCurrentRow
|
730 | }
|
731 | }),
|
732 | !_vm.data || _vm.data.length === 0
|
733 | ? _c(
|
734 | "div",
|
735 | {
|
736 | ref: "emptyBlock",
|
737 | staticClass: "el-table__empty-block",
|
738 | style: _vm.emptyBlockStyle
|
739 | },
|
740 | [
|
741 | _c(
|
742 | "span",
|
743 | { staticClass: "el-table__empty-text" },
|
744 | [
|
745 | _vm._t("empty", [
|
746 | _vm._v(
|
747 | _vm._s(_vm.emptyText || _vm.t("el.table.emptyText"))
|
748 | )
|
749 | ])
|
750 | ],
|
751 | 2
|
752 | )
|
753 | ]
|
754 | )
|
755 | : _vm._e(),
|
756 | _vm.$slots.append
|
757 | ? _c(
|
758 | "div",
|
759 | {
|
760 | ref: "appendWrapper",
|
761 | staticClass: "el-table__append-wrapper"
|
762 | },
|
763 | [_vm._t("append")],
|
764 | 2
|
765 | )
|
766 | : _vm._e()
|
767 | ],
|
768 | 1
|
769 | ),
|
770 | _vm.showSummary
|
771 | ? _c(
|
772 | "div",
|
773 | {
|
774 | directives: [
|
775 | {
|
776 | name: "show",
|
777 | rawName: "v-show",
|
778 | value: _vm.data && _vm.data.length > 0,
|
779 | expression: "data && data.length > 0"
|
780 | },
|
781 | {
|
782 | name: "mousewheel",
|
783 | rawName: "v-mousewheel",
|
784 | value: _vm.handleHeaderFooterMousewheel,
|
785 | expression: "handleHeaderFooterMousewheel"
|
786 | }
|
787 | ],
|
788 | ref: "footerWrapper",
|
789 | staticClass: "el-table__footer-wrapper"
|
790 | },
|
791 | [
|
792 | _c("table-footer", {
|
793 | style: {
|
794 | width: _vm.layout.bodyWidth ? _vm.layout.bodyWidth + "px" : ""
|
795 | },
|
796 | attrs: {
|
797 | store: _vm.store,
|
798 | border: _vm.border,
|
799 | "sum-text": _vm.sumText || _vm.t("el.table.sumText"),
|
800 | "summary-method": _vm.summaryMethod,
|
801 | "default-sort": _vm.defaultSort
|
802 | }
|
803 | })
|
804 | ],
|
805 | 1
|
806 | )
|
807 | : _vm._e(),
|
808 | _vm.fixedColumns.length > 0
|
809 | ? _c(
|
810 | "div",
|
811 | {
|
812 | directives: [
|
813 | {
|
814 | name: "mousewheel",
|
815 | rawName: "v-mousewheel",
|
816 | value: _vm.handleFixedMousewheel,
|
817 | expression: "handleFixedMousewheel"
|
818 | }
|
819 | ],
|
820 | ref: "fixedWrapper",
|
821 | staticClass: "el-table__fixed",
|
822 | style: [
|
823 | {
|
824 | width: _vm.layout.fixedWidth
|
825 | ? _vm.layout.fixedWidth + "px"
|
826 | : ""
|
827 | },
|
828 | _vm.fixedHeight
|
829 | ]
|
830 | },
|
831 | [
|
832 | _vm.showHeader
|
833 | ? _c(
|
834 | "div",
|
835 | {
|
836 | ref: "fixedHeaderWrapper",
|
837 | staticClass: "el-table__fixed-header-wrapper"
|
838 | },
|
839 | [
|
840 | _c("table-header", {
|
841 | ref: "fixedTableHeader",
|
842 | style: {
|
843 | width: _vm.bodyWidth
|
844 | },
|
845 | attrs: {
|
846 | fixed: "left",
|
847 | border: _vm.border,
|
848 | store: _vm.store
|
849 | }
|
850 | })
|
851 | ],
|
852 | 1
|
853 | )
|
854 | : _vm._e(),
|
855 | _c(
|
856 | "div",
|
857 | {
|
858 | ref: "fixedBodyWrapper",
|
859 | staticClass: "el-table__fixed-body-wrapper",
|
860 | style: [
|
861 | {
|
862 | top: _vm.layout.headerHeight + "px"
|
863 | },
|
864 | _vm.fixedBodyHeight
|
865 | ]
|
866 | },
|
867 | [
|
868 | _c("table-body", {
|
869 | style: {
|
870 | width: _vm.bodyWidth
|
871 | },
|
872 | attrs: {
|
873 | fixed: "left",
|
874 | store: _vm.store,
|
875 | stripe: _vm.stripe,
|
876 | highlight: _vm.highlightCurrentRow,
|
877 | "row-class-name": _vm.rowClassName,
|
878 | "row-style": _vm.rowStyle
|
879 | }
|
880 | }),
|
881 | _vm.$slots.append
|
882 | ? _c("div", {
|
883 | staticClass: "el-table__append-gutter",
|
884 | style: { height: _vm.layout.appendHeight + "px" }
|
885 | })
|
886 | : _vm._e()
|
887 | ],
|
888 | 1
|
889 | ),
|
890 | _vm.showSummary
|
891 | ? _c(
|
892 | "div",
|
893 | {
|
894 | directives: [
|
895 | {
|
896 | name: "show",
|
897 | rawName: "v-show",
|
898 | value: _vm.data && _vm.data.length > 0,
|
899 | expression: "data && data.length > 0"
|
900 | }
|
901 | ],
|
902 | ref: "fixedFooterWrapper",
|
903 | staticClass: "el-table__fixed-footer-wrapper"
|
904 | },
|
905 | [
|
906 | _c("table-footer", {
|
907 | style: {
|
908 | width: _vm.bodyWidth
|
909 | },
|
910 | attrs: {
|
911 | fixed: "left",
|
912 | border: _vm.border,
|
913 | "sum-text": _vm.sumText || _vm.t("el.table.sumText"),
|
914 | "summary-method": _vm.summaryMethod,
|
915 | store: _vm.store
|
916 | }
|
917 | })
|
918 | ],
|
919 | 1
|
920 | )
|
921 | : _vm._e()
|
922 | ]
|
923 | )
|
924 | : _vm._e(),
|
925 | _vm.rightFixedColumns.length > 0
|
926 | ? _c(
|
927 | "div",
|
928 | {
|
929 | directives: [
|
930 | {
|
931 | name: "mousewheel",
|
932 | rawName: "v-mousewheel",
|
933 | value: _vm.handleFixedMousewheel,
|
934 | expression: "handleFixedMousewheel"
|
935 | }
|
936 | ],
|
937 | ref: "rightFixedWrapper",
|
938 | staticClass: "el-table__fixed-right",
|
939 | style: [
|
940 | {
|
941 | width: _vm.layout.rightFixedWidth
|
942 | ? _vm.layout.rightFixedWidth + "px"
|
943 | : "",
|
944 | right: _vm.layout.scrollY
|
945 | ? (_vm.border
|
946 | ? _vm.layout.gutterWidth
|
947 | : _vm.layout.gutterWidth || 0) + "px"
|
948 | : ""
|
949 | },
|
950 | _vm.fixedHeight
|
951 | ]
|
952 | },
|
953 | [
|
954 | _vm.showHeader
|
955 | ? _c(
|
956 | "div",
|
957 | {
|
958 | ref: "rightFixedHeaderWrapper",
|
959 | staticClass: "el-table__fixed-header-wrapper"
|
960 | },
|
961 | [
|
962 | _c("table-header", {
|
963 | ref: "rightFixedTableHeader",
|
964 | style: {
|
965 | width: _vm.bodyWidth
|
966 | },
|
967 | attrs: {
|
968 | fixed: "right",
|
969 | border: _vm.border,
|
970 | store: _vm.store
|
971 | }
|
972 | })
|
973 | ],
|
974 | 1
|
975 | )
|
976 | : _vm._e(),
|
977 | _c(
|
978 | "div",
|
979 | {
|
980 | ref: "rightFixedBodyWrapper",
|
981 | staticClass: "el-table__fixed-body-wrapper",
|
982 | style: [
|
983 | {
|
984 | top: _vm.layout.headerHeight + "px"
|
985 | },
|
986 | _vm.fixedBodyHeight
|
987 | ]
|
988 | },
|
989 | [
|
990 | _c("table-body", {
|
991 | style: {
|
992 | width: _vm.bodyWidth
|
993 | },
|
994 | attrs: {
|
995 | fixed: "right",
|
996 | store: _vm.store,
|
997 | stripe: _vm.stripe,
|
998 | "row-class-name": _vm.rowClassName,
|
999 | "row-style": _vm.rowStyle,
|
1000 | highlight: _vm.highlightCurrentRow
|
1001 | }
|
1002 | }),
|
1003 | _vm.$slots.append
|
1004 | ? _c("div", {
|
1005 | staticClass: "el-table__append-gutter",
|
1006 | style: { height: _vm.layout.appendHeight + "px" }
|
1007 | })
|
1008 | : _vm._e()
|
1009 | ],
|
1010 | 1
|
1011 | ),
|
1012 | _vm.showSummary
|
1013 | ? _c(
|
1014 | "div",
|
1015 | {
|
1016 | directives: [
|
1017 | {
|
1018 | name: "show",
|
1019 | rawName: "v-show",
|
1020 | value: _vm.data && _vm.data.length > 0,
|
1021 | expression: "data && data.length > 0"
|
1022 | }
|
1023 | ],
|
1024 | ref: "rightFixedFooterWrapper",
|
1025 | staticClass: "el-table__fixed-footer-wrapper"
|
1026 | },
|
1027 | [
|
1028 | _c("table-footer", {
|
1029 | style: {
|
1030 | width: _vm.bodyWidth
|
1031 | },
|
1032 | attrs: {
|
1033 | fixed: "right",
|
1034 | border: _vm.border,
|
1035 | "sum-text": _vm.sumText || _vm.t("el.table.sumText"),
|
1036 | "summary-method": _vm.summaryMethod,
|
1037 | store: _vm.store
|
1038 | }
|
1039 | })
|
1040 | ],
|
1041 | 1
|
1042 | )
|
1043 | : _vm._e()
|
1044 | ]
|
1045 | )
|
1046 | : _vm._e(),
|
1047 | _vm.rightFixedColumns.length > 0
|
1048 | ? _c("div", {
|
1049 | ref: "rightFixedPatch",
|
1050 | staticClass: "el-table__fixed-right-patch",
|
1051 | style: {
|
1052 | width: _vm.layout.scrollY ? _vm.layout.gutterWidth + "px" : "0",
|
1053 | height: _vm.layout.headerHeight + "px"
|
1054 | }
|
1055 | })
|
1056 | : _vm._e(),
|
1057 | _c("div", {
|
1058 | directives: [
|
1059 | {
|
1060 | name: "show",
|
1061 | rawName: "v-show",
|
1062 | value: _vm.resizeProxyVisible,
|
1063 | expression: "resizeProxyVisible"
|
1064 | }
|
1065 | ],
|
1066 | ref: "resizeProxy",
|
1067 | staticClass: "el-table__column-resize-proxy"
|
1068 | })
|
1069 | ]
|
1070 | )
|
1071 | }
|
1072 | var staticRenderFns = []
|
1073 | render._withStripped = true
|
1074 |
|
1075 |
|
1076 |
|
1077 |
|
1078 |
|
1079 | var checkbox_ = __webpack_require__(18);
|
1080 | var checkbox_default = __webpack_require__.n(checkbox_);
|
1081 |
|
1082 |
|
1083 | var external_throttle_debounce_ = __webpack_require__(43);
|
1084 |
|
1085 |
|
1086 | var resize_event_ = __webpack_require__(16);
|
1087 |
|
1088 |
|
1089 | var external_normalize_wheel_ = __webpack_require__(46);
|
1090 | var external_normalize_wheel_default = __webpack_require__.n(external_normalize_wheel_);
|
1091 |
|
1092 |
|
1093 |
|
1094 |
|
1095 | var isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
1096 |
|
1097 | var mousewheel_mousewheel = function mousewheel(element, callback) {
|
1098 | if (element && element.addEventListener) {
|
1099 | element.addEventListener(isFirefox ? 'DOMMouseScroll' : 'mousewheel', function (event) {
|
1100 | var normalized = external_normalize_wheel_default()(event);
|
1101 | callback && callback.apply(this, [event, normalized]);
|
1102 | });
|
1103 | }
|
1104 | };
|
1105 |
|
1106 | var directives_mousewheel = ({
|
1107 | bind: function bind(el, binding) {
|
1108 | mousewheel_mousewheel(el, binding.value);
|
1109 | }
|
1110 | });
|
1111 |
|
1112 | var locale_ = __webpack_require__(6);
|
1113 | var locale_default = __webpack_require__.n(locale_);
|
1114 |
|
1115 |
|
1116 | var migrating_ = __webpack_require__(11);
|
1117 | var migrating_default = __webpack_require__.n(migrating_);
|
1118 |
|
1119 |
|
1120 | var external_vue_ = __webpack_require__(7);
|
1121 | var external_vue_default = __webpack_require__.n(external_vue_);
|
1122 |
|
1123 |
|
1124 | var merge_ = __webpack_require__(9);
|
1125 | var merge_default = __webpack_require__.n(merge_);
|
1126 |
|
1127 |
|
1128 | var util = __webpack_require__(8);
|
1129 |
|
1130 |
|
1131 |
|
1132 |
|
1133 | var expand = ({
|
1134 | data: function data() {
|
1135 | return {
|
1136 | states: {
|
1137 | defaultExpandAll: false,
|
1138 | expandRows: []
|
1139 | }
|
1140 | };
|
1141 | },
|
1142 |
|
1143 |
|
1144 | methods: {
|
1145 | updateExpandRows: function updateExpandRows() {
|
1146 | var _states = this.states,
|
1147 | _states$data = _states.data,
|
1148 | data = _states$data === undefined ? [] : _states$data,
|
1149 | rowKey = _states.rowKey,
|
1150 | defaultExpandAll = _states.defaultExpandAll,
|
1151 | expandRows = _states.expandRows;
|
1152 |
|
1153 | if (defaultExpandAll) {
|
1154 | this.states.expandRows = data.slice();
|
1155 | } else if (rowKey) {
|
1156 |
|
1157 | var expandRowsMap = Object(util["f" ])(expandRows, rowKey);
|
1158 | this.states.expandRows = data.reduce(function (prev, row) {
|
1159 | var rowId = Object(util["g" ])(row, rowKey);
|
1160 | var rowInfo = expandRowsMap[rowId];
|
1161 | if (rowInfo) {
|
1162 | prev.push(row);
|
1163 | }
|
1164 | return prev;
|
1165 | }, []);
|
1166 | } else {
|
1167 | this.states.expandRows = [];
|
1168 | }
|
1169 | },
|
1170 | toggleRowExpansion: function toggleRowExpansion(row, expanded) {
|
1171 | var changed = Object(util["m" ])(this.states.expandRows, row, expanded);
|
1172 | if (changed) {
|
1173 | this.table.$emit('expand-change', row, this.states.expandRows.slice());
|
1174 | this.scheduleLayout();
|
1175 | }
|
1176 | },
|
1177 | setExpandRowKeys: function setExpandRowKeys(rowKeys) {
|
1178 | this.assertRowKey();
|
1179 |
|
1180 | var _states2 = this.states,
|
1181 | data = _states2.data,
|
1182 | rowKey = _states2.rowKey;
|
1183 |
|
1184 | var keysMap = Object(util["f" ])(data, rowKey);
|
1185 | this.states.expandRows = rowKeys.reduce(function (prev, cur) {
|
1186 | var info = keysMap[cur];
|
1187 | if (info) {
|
1188 | prev.push(info.row);
|
1189 | }
|
1190 | return prev;
|
1191 | }, []);
|
1192 | },
|
1193 | isRowExpanded: function isRowExpanded(row) {
|
1194 | var _states3 = this.states,
|
1195 | _states3$expandRows = _states3.expandRows,
|
1196 | expandRows = _states3$expandRows === undefined ? [] : _states3$expandRows,
|
1197 | rowKey = _states3.rowKey;
|
1198 |
|
1199 | if (rowKey) {
|
1200 | var expandMap = Object(util["f" ])(expandRows, rowKey);
|
1201 | return !!expandMap[Object(util["g" ])(row, rowKey)];
|
1202 | }
|
1203 | return expandRows.indexOf(row) !== -1;
|
1204 | }
|
1205 | }
|
1206 | });
|
1207 |
|
1208 | var util_ = __webpack_require__(3);
|
1209 |
|
1210 |
|
1211 |
|
1212 |
|
1213 |
|
1214 | var current = ({
|
1215 | data: function data() {
|
1216 | return {
|
1217 | states: {
|
1218 |
|
1219 |
|
1220 | _currentRowKey: null,
|
1221 | currentRow: null
|
1222 | }
|
1223 | };
|
1224 | },
|
1225 |
|
1226 |
|
1227 | methods: {
|
1228 | setCurrentRowKey: function setCurrentRowKey(key) {
|
1229 | this.assertRowKey();
|
1230 | this.states._currentRowKey = key;
|
1231 | this.setCurrentRowByKey(key);
|
1232 | },
|
1233 | restoreCurrentRowKey: function restoreCurrentRowKey() {
|
1234 | this.states._currentRowKey = null;
|
1235 | },
|
1236 | setCurrentRowByKey: function setCurrentRowByKey(key) {
|
1237 | var states = this.states;
|
1238 | var _states$data = states.data,
|
1239 | data = _states$data === undefined ? [] : _states$data,
|
1240 | rowKey = states.rowKey;
|
1241 |
|
1242 | var currentRow = null;
|
1243 | if (rowKey) {
|
1244 | currentRow = Object(util_["arrayFind"])(data, function (item) {
|
1245 | return Object(util["g" ])(item, rowKey) === key;
|
1246 | });
|
1247 | }
|
1248 | states.currentRow = currentRow;
|
1249 | },
|
1250 | updateCurrentRow: function updateCurrentRow(currentRow) {
|
1251 | var states = this.states,
|
1252 | table = this.table;
|
1253 |
|
1254 | var oldCurrentRow = states.currentRow;
|
1255 | if (currentRow && currentRow !== oldCurrentRow) {
|
1256 | states.currentRow = currentRow;
|
1257 | table.$emit('current-change', currentRow, oldCurrentRow);
|
1258 | return;
|
1259 | }
|
1260 | if (!currentRow && oldCurrentRow) {
|
1261 | states.currentRow = null;
|
1262 | table.$emit('current-change', null, oldCurrentRow);
|
1263 | }
|
1264 | },
|
1265 | updateCurrentRowData: function updateCurrentRowData() {
|
1266 | var states = this.states,
|
1267 | table = this.table;
|
1268 | var rowKey = states.rowKey,
|
1269 | _currentRowKey = states._currentRowKey;
|
1270 |
|
1271 |
|
1272 | var data = states.data || [];
|
1273 | var oldCurrentRow = states.currentRow;
|
1274 |
|
1275 |
|
1276 | if (data.indexOf(oldCurrentRow) === -1 && oldCurrentRow) {
|
1277 | if (rowKey) {
|
1278 | var currentRowKey = Object(util["g" ])(oldCurrentRow, rowKey);
|
1279 | this.setCurrentRowByKey(currentRowKey);
|
1280 | } else {
|
1281 | states.currentRow = null;
|
1282 | }
|
1283 | if (states.currentRow === null) {
|
1284 | table.$emit('current-change', null, oldCurrentRow);
|
1285 | }
|
1286 | } else if (_currentRowKey) {
|
1287 |
|
1288 | this.setCurrentRowByKey(_currentRowKey);
|
1289 | this.restoreCurrentRowKey();
|
1290 | }
|
1291 | }
|
1292 | }
|
1293 | });
|
1294 |
|
1295 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
1296 |
|
1297 |
|
1298 |
|
1299 | var tree = ({
|
1300 | data: function data() {
|
1301 | return {
|
1302 | states: {
|
1303 |
|
1304 |
|
1305 |
|
1306 | expandRowKeys: [],
|
1307 | treeData: {},
|
1308 | indent: 16,
|
1309 | lazy: false,
|
1310 | lazyTreeNodeMap: {},
|
1311 | lazyColumnIdentifier: 'hasChildren',
|
1312 | childrenColumnName: 'children'
|
1313 | }
|
1314 | };
|
1315 | },
|
1316 |
|
1317 |
|
1318 | computed: {
|
1319 |
|
1320 |
|
1321 |
|
1322 | normalizedData: function normalizedData() {
|
1323 | if (!this.states.rowKey) return {};
|
1324 | var data = this.states.data || [];
|
1325 | return this.normalize(data);
|
1326 | },
|
1327 |
|
1328 |
|
1329 |
|
1330 | normalizedLazyNode: function normalizedLazyNode() {
|
1331 | var _states = this.states,
|
1332 | rowKey = _states.rowKey,
|
1333 | lazyTreeNodeMap = _states.lazyTreeNodeMap,
|
1334 | lazyColumnIdentifier = _states.lazyColumnIdentifier;
|
1335 |
|
1336 | var keys = Object.keys(lazyTreeNodeMap);
|
1337 | var res = {};
|
1338 | if (!keys.length) return res;
|
1339 | keys.forEach(function (key) {
|
1340 | if (lazyTreeNodeMap[key].length) {
|
1341 | var item = { children: [] };
|
1342 | lazyTreeNodeMap[key].forEach(function (row) {
|
1343 | var currentRowKey = Object(util["g" ])(row, rowKey);
|
1344 | item.children.push(currentRowKey);
|
1345 | if (row[lazyColumnIdentifier] && !res[currentRowKey]) {
|
1346 | res[currentRowKey] = { children: [] };
|
1347 | }
|
1348 | });
|
1349 | res[key] = item;
|
1350 | }
|
1351 | });
|
1352 | return res;
|
1353 | }
|
1354 | },
|
1355 |
|
1356 | watch: {
|
1357 | normalizedData: 'updateTreeData',
|
1358 | normalizedLazyNode: 'updateTreeData'
|
1359 | },
|
1360 |
|
1361 | methods: {
|
1362 | normalize: function normalize(data) {
|
1363 | var _states2 = this.states,
|
1364 | childrenColumnName = _states2.childrenColumnName,
|
1365 | lazyColumnIdentifier = _states2.lazyColumnIdentifier,
|
1366 | rowKey = _states2.rowKey,
|
1367 | lazy = _states2.lazy;
|
1368 |
|
1369 | var res = {};
|
1370 | Object(util["n" ])(data, function (parent, children, level) {
|
1371 | var parentId = Object(util["g" ])(parent, rowKey);
|
1372 | if (Array.isArray(children)) {
|
1373 | res[parentId] = {
|
1374 | children: children.map(function (row) {
|
1375 | return Object(util["g" ])(row, rowKey);
|
1376 | }),
|
1377 | level: level
|
1378 | };
|
1379 | } else if (lazy) {
|
1380 |
|
1381 | res[parentId] = {
|
1382 | children: [],
|
1383 | lazy: true,
|
1384 | level: level
|
1385 | };
|
1386 | }
|
1387 | }, childrenColumnName, lazyColumnIdentifier);
|
1388 | return res;
|
1389 | },
|
1390 | updateTreeData: function updateTreeData() {
|
1391 | var nested = this.normalizedData;
|
1392 | var normalizedLazyNode = this.normalizedLazyNode;
|
1393 | var keys = Object.keys(nested);
|
1394 | var newTreeData = {};
|
1395 | if (keys.length) {
|
1396 | var _states3 = this.states,
|
1397 | oldTreeData = _states3.treeData,
|
1398 | defaultExpandAll = _states3.defaultExpandAll,
|
1399 | expandRowKeys = _states3.expandRowKeys,
|
1400 | lazy = _states3.lazy;
|
1401 |
|
1402 | var rootLazyRowKeys = [];
|
1403 | var getExpanded = function getExpanded(oldValue, key) {
|
1404 | var included = defaultExpandAll || expandRowKeys && expandRowKeys.indexOf(key) !== -1;
|
1405 | return !!(oldValue && oldValue.expanded || included);
|
1406 | };
|
1407 |
|
1408 | keys.forEach(function (key) {
|
1409 | var oldValue = oldTreeData[key];
|
1410 | var newValue = _extends({}, nested[key]);
|
1411 | newValue.expanded = getExpanded(oldValue, key);
|
1412 | if (newValue.lazy) {
|
1413 | var _ref = oldValue || {},
|
1414 | _ref$loaded = _ref.loaded,
|
1415 | loaded = _ref$loaded === undefined ? false : _ref$loaded,
|
1416 | _ref$loading = _ref.loading,
|
1417 | loading = _ref$loading === undefined ? false : _ref$loading;
|
1418 |
|
1419 | newValue.loaded = !!loaded;
|
1420 | newValue.loading = !!loading;
|
1421 | rootLazyRowKeys.push(key);
|
1422 | }
|
1423 | newTreeData[key] = newValue;
|
1424 | });
|
1425 |
|
1426 | var lazyKeys = Object.keys(normalizedLazyNode);
|
1427 | if (lazy && lazyKeys.length && rootLazyRowKeys.length) {
|
1428 | lazyKeys.forEach(function (key) {
|
1429 | var oldValue = oldTreeData[key];
|
1430 | var lazyNodeChildren = normalizedLazyNode[key].children;
|
1431 | if (rootLazyRowKeys.indexOf(key) !== -1) {
|
1432 |
|
1433 | if (newTreeData[key].children.length !== 0) {
|
1434 | throw new Error('[ElTable]children must be an empty array.');
|
1435 | }
|
1436 | newTreeData[key].children = lazyNodeChildren;
|
1437 | } else {
|
1438 | var _ref2 = oldValue || {},
|
1439 | _ref2$loaded = _ref2.loaded,
|
1440 | loaded = _ref2$loaded === undefined ? false : _ref2$loaded,
|
1441 | _ref2$loading = _ref2.loading,
|
1442 | loading = _ref2$loading === undefined ? false : _ref2$loading;
|
1443 |
|
1444 | newTreeData[key] = {
|
1445 | lazy: true,
|
1446 | loaded: !!loaded,
|
1447 | loading: !!loading,
|
1448 | expanded: getExpanded(oldValue, key),
|
1449 | children: lazyNodeChildren,
|
1450 | level: ''
|
1451 | };
|
1452 | }
|
1453 | });
|
1454 | }
|
1455 | }
|
1456 | this.states.treeData = newTreeData;
|
1457 | this.updateTableScrollY();
|
1458 | },
|
1459 | updateTreeExpandKeys: function updateTreeExpandKeys(value) {
|
1460 | this.states.expandRowKeys = value;
|
1461 | this.updateTreeData();
|
1462 | },
|
1463 | toggleTreeExpansion: function toggleTreeExpansion(row, expanded) {
|
1464 | this.assertRowKey();
|
1465 |
|
1466 | var _states4 = this.states,
|
1467 | rowKey = _states4.rowKey,
|
1468 | treeData = _states4.treeData;
|
1469 |
|
1470 | var id = Object(util["g" ])(row, rowKey);
|
1471 | var data = id && treeData[id];
|
1472 | if (id && data && 'expanded' in data) {
|
1473 | var oldExpanded = data.expanded;
|
1474 | expanded = typeof expanded === 'undefined' ? !data.expanded : expanded;
|
1475 | treeData[id].expanded = expanded;
|
1476 | if (oldExpanded !== expanded) {
|
1477 | this.table.$emit('expand-change', row, expanded);
|
1478 | }
|
1479 | this.updateTableScrollY();
|
1480 | }
|
1481 | },
|
1482 | loadOrToggle: function loadOrToggle(row) {
|
1483 | this.assertRowKey();
|
1484 | var _states5 = this.states,
|
1485 | lazy = _states5.lazy,
|
1486 | treeData = _states5.treeData,
|
1487 | rowKey = _states5.rowKey;
|
1488 |
|
1489 | var id = Object(util["g" ])(row, rowKey);
|
1490 | var data = treeData[id];
|
1491 | if (lazy && data && 'loaded' in data && !data.loaded) {
|
1492 | this.loadData(row, id, data);
|
1493 | } else {
|
1494 | this.toggleTreeExpansion(row);
|
1495 | }
|
1496 | },
|
1497 | loadData: function loadData(row, key, treeNode) {
|
1498 | var _this = this;
|
1499 |
|
1500 | var load = this.table.load;
|
1501 | var _states6 = this.states,
|
1502 | lazyTreeNodeMap = _states6.lazyTreeNodeMap,
|
1503 | treeData = _states6.treeData;
|
1504 |
|
1505 | if (load && !treeData[key].loaded) {
|
1506 | treeData[key].loading = true;
|
1507 | load(row, treeNode, function (data) {
|
1508 | if (!Array.isArray(data)) {
|
1509 | throw new Error('[ElTable] data must be an array');
|
1510 | }
|
1511 | treeData[key].loading = false;
|
1512 | treeData[key].loaded = true;
|
1513 | treeData[key].expanded = true;
|
1514 | if (data.length) {
|
1515 | _this.$set(lazyTreeNodeMap, key, data);
|
1516 | }
|
1517 | _this.table.$emit('expand-change', row, true);
|
1518 | });
|
1519 | }
|
1520 | }
|
1521 | }
|
1522 | });
|
1523 | // CONCATENATED MODULE: ./packages/table/src/store/watcher.js
|
1524 |
|
1525 |
|
1526 |
|
1527 |
|
1528 |
|
1529 |
|
1530 |
|
1531 | var watcher_sortData = function sortData(data, states) {
|
1532 | var sortingColumn = states.sortingColumn;
|
1533 | if (!sortingColumn || typeof sortingColumn.sortable === 'string') {
|
1534 | return data;
|
1535 | }
|
1536 | return Object(util["i" ])(data, states.sortProp, states.sortOrder, sortingColumn.sortMethod, sortingColumn.sortBy);
|
1537 | };
|
1538 |
|
1539 | var doFlattenColumns = function doFlattenColumns(columns) {
|
1540 | var result = [];
|
1541 | columns.forEach(function (column) {
|
1542 | if (column.children) {
|
1543 | result.push.apply(result, doFlattenColumns(column.children));
|
1544 | } else {
|
1545 | result.push(column);
|
1546 | }
|
1547 | });
|
1548 | return result;
|
1549 | };
|
1550 |
|
1551 | var watcher = (external_vue_default.a.extend({
|
1552 | data: function data() {
|
1553 | return {
|
1554 | states: {
|
1555 |
|
1556 | rowKey: null,
|
1557 |
|
1558 |
|
1559 | data: [],
|
1560 |
|
1561 |
|
1562 | isComplex: false,
|
1563 |
|
1564 |
|
1565 | _columns: [],
|
1566 | originColumns: [],
|
1567 | columns: [],
|
1568 | fixedColumns: [],
|
1569 | rightFixedColumns: [],
|
1570 | leafColumns: [],
|
1571 | fixedLeafColumns: [],
|
1572 | rightFixedLeafColumns: [],
|
1573 | leafColumnsLength: 0,
|
1574 | fixedLeafColumnsLength: 0,
|
1575 | rightFixedLeafColumnsLength: 0,
|
1576 |
|
1577 |
|
1578 | isAllSelected: false,
|
1579 | selection: [],
|
1580 | reserveSelection: false,
|
1581 | selectOnIndeterminate: false,
|
1582 | selectable: null,
|
1583 |
|
1584 |
|
1585 | filters: {},
|
1586 | filteredData: null,
|
1587 |
|
1588 |
|
1589 | sortingColumn: null,
|
1590 | sortProp: null,
|
1591 | sortOrder: null,
|
1592 |
|
1593 | hoverRow: null
|
1594 | }
|
1595 | };
|
1596 | },
|
1597 |
|
1598 |
|
1599 | mixins: [expand, current, tree],
|
1600 |
|
1601 | methods: {
|
1602 |
|
1603 | assertRowKey: function assertRowKey() {
|
1604 | var rowKey = this.states.rowKey;
|
1605 | if (!rowKey) throw new Error('[ElTable] prop row-key is required');
|
1606 | },
|
1607 |
|
1608 |
|
1609 |
|
1610 | updateColumns: function updateColumns() {
|
1611 | var states = this.states;
|
1612 | var _columns = states._columns || [];
|
1613 | states.fixedColumns = _columns.filter(function (column) {
|
1614 | return column.fixed === true || column.fixed === 'left';
|
1615 | });
|
1616 | states.rightFixedColumns = _columns.filter(function (column) {
|
1617 | return column.fixed === 'right';
|
1618 | });
|
1619 |
|
1620 | if (states.fixedColumns.length > 0 && _columns[0] && _columns[0].type === 'selection' && !_columns[0].fixed) {
|
1621 | _columns[0].fixed = true;
|
1622 | states.fixedColumns.unshift(_columns[0]);
|
1623 | }
|
1624 |
|
1625 | var notFixedColumns = _columns.filter(function (column) {
|
1626 | return !column.fixed;
|
1627 | });
|
1628 | states.originColumns = [].concat(states.fixedColumns).concat(notFixedColumns).concat(states.rightFixedColumns);
|
1629 |
|
1630 | var leafColumns = doFlattenColumns(notFixedColumns);
|
1631 | var fixedLeafColumns = doFlattenColumns(states.fixedColumns);
|
1632 | var rightFixedLeafColumns = doFlattenColumns(states.rightFixedColumns);
|
1633 |
|
1634 | states.leafColumnsLength = leafColumns.length;
|
1635 | states.fixedLeafColumnsLength = fixedLeafColumns.length;
|
1636 | states.rightFixedLeafColumnsLength = rightFixedLeafColumns.length;
|
1637 |
|
1638 | states.columns = [].concat(fixedLeafColumns).concat(leafColumns).concat(rightFixedLeafColumns);
|
1639 | states.isComplex = states.fixedColumns.length > 0 || states.rightFixedColumns.length > 0;
|
1640 | },
|
1641 |
|
1642 |
|
1643 |
|
1644 | scheduleLayout: function scheduleLayout(needUpdateColumns) {
|
1645 | if (needUpdateColumns) {
|
1646 | this.updateColumns();
|
1647 | }
|
1648 | this.table.debouncedUpdateLayout();
|
1649 | },
|
1650 |
|
1651 |
|
1652 |
|
1653 | isSelected: function isSelected(row) {
|
1654 | var _states$selection = this.states.selection,
|
1655 | selection = _states$selection === undefined ? [] : _states$selection;
|
1656 |
|
1657 | return selection.indexOf(row) > -1;
|
1658 | },
|
1659 | clearSelection: function clearSelection() {
|
1660 | var states = this.states;
|
1661 | states.isAllSelected = false;
|
1662 | var oldSelection = states.selection;
|
1663 | if (oldSelection.length) {
|
1664 | states.selection = [];
|
1665 | this.table.$emit('selection-change', []);
|
1666 | }
|
1667 | },
|
1668 | cleanSelection: function cleanSelection() {
|
1669 | var states = this.states;
|
1670 | var data = states.data,
|
1671 | rowKey = states.rowKey,
|
1672 | selection = states.selection;
|
1673 |
|
1674 | var deleted = void 0;
|
1675 | if (rowKey) {
|
1676 | deleted = [];
|
1677 | var selectedMap = Object(util["f" ])(selection, rowKey);
|
1678 | var dataMap = Object(util["f" ])(data, rowKey);
|
1679 | for (var key in selectedMap) {
|
1680 | if (selectedMap.hasOwnProperty(key) && !dataMap[key]) {
|
1681 | deleted.push(selectedMap[key].row);
|
1682 | }
|
1683 | }
|
1684 | } else {
|
1685 | deleted = selection.filter(function (item) {
|
1686 | return data.indexOf(item) === -1;
|
1687 | });
|
1688 | }
|
1689 | if (deleted.length) {
|
1690 | var newSelection = selection.filter(function (item) {
|
1691 | return deleted.indexOf(item) === -1;
|
1692 | });
|
1693 | states.selection = newSelection;
|
1694 | this.table.$emit('selection-change', newSelection.slice());
|
1695 | }
|
1696 | },
|
1697 | toggleRowSelection: function toggleRowSelection(row, selected) {
|
1698 | var emitChange = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
1699 |
|
1700 | var changed = Object(util["m" ])(this.states.selection, row, selected);
|
1701 | if (changed) {
|
1702 | var newSelection = (this.states.selection || []).slice();
|
1703 |
|
1704 | if (emitChange) {
|
1705 | this.table.$emit('select', newSelection, row);
|
1706 | }
|
1707 | this.table.$emit('selection-change', newSelection);
|
1708 | }
|
1709 | },
|
1710 | _toggleAllSelection: function _toggleAllSelection() {
|
1711 | var states = this.states;
|
1712 | var _states$data = states.data,
|
1713 | data = _states$data === undefined ? [] : _states$data,
|
1714 | selection = states.selection;
|
1715 |
|
1716 |
|
1717 |
|
1718 | var value = states.selectOnIndeterminate ? !states.isAllSelected : !(states.isAllSelected || selection.length);
|
1719 | states.isAllSelected = value;
|
1720 |
|
1721 | var selectionChanged = false;
|
1722 | data.forEach(function (row, index) {
|
1723 | if (states.selectable) {
|
1724 | if (states.selectable.call(null, row, index) && Object(util["m" ])(selection, row, value)) {
|
1725 | selectionChanged = true;
|
1726 | }
|
1727 | } else {
|
1728 | if (Object(util["m" ])(selection, row, value)) {
|
1729 | selectionChanged = true;
|
1730 | }
|
1731 | }
|
1732 | });
|
1733 |
|
1734 | if (selectionChanged) {
|
1735 | this.table.$emit('selection-change', selection ? selection.slice() : []);
|
1736 | }
|
1737 | this.table.$emit('select-all', selection);
|
1738 | },
|
1739 | updateSelectionByRowKey: function updateSelectionByRowKey() {
|
1740 | var states = this.states;
|
1741 | var selection = states.selection,
|
1742 | rowKey = states.rowKey,
|
1743 | data = states.data;
|
1744 |
|
1745 | var selectedMap = Object(util["f" ])(selection, rowKey);
|
1746 | data.forEach(function (row) {
|
1747 | var rowId = Object(util["g" ])(row, rowKey);
|
1748 | var rowInfo = selectedMap[rowId];
|
1749 | if (rowInfo) {
|
1750 | selection[rowInfo.index] = row;
|
1751 | }
|
1752 | });
|
1753 | },
|
1754 | updateAllSelected: function updateAllSelected() {
|
1755 | var states = this.states;
|
1756 | var selection = states.selection,
|
1757 | rowKey = states.rowKey,
|
1758 | selectable = states.selectable;
|
1759 |
|
1760 |
|
1761 | var data = states.data || [];
|
1762 | if (data.length === 0) {
|
1763 | states.isAllSelected = false;
|
1764 | return;
|
1765 | }
|
1766 |
|
1767 | var selectedMap = void 0;
|
1768 | if (rowKey) {
|
1769 | selectedMap = Object(util["f" ])(selection, rowKey);
|
1770 | }
|
1771 | var isSelected = function isSelected(row) {
|
1772 | if (selectedMap) {
|
1773 | return !!selectedMap[Object(util["g" ])(row, rowKey)];
|
1774 | } else {
|
1775 | return selection.indexOf(row) !== -1;
|
1776 | }
|
1777 | };
|
1778 | var isAllSelected = true;
|
1779 | var selectedCount = 0;
|
1780 | for (var i = 0, j = data.length; i < j; i++) {
|
1781 | var item = data[i];
|
1782 | var isRowSelectable = selectable && selectable.call(null, item, i);
|
1783 | if (!isSelected(item)) {
|
1784 | if (!selectable || isRowSelectable) {
|
1785 | isAllSelected = false;
|
1786 | break;
|
1787 | }
|
1788 | } else {
|
1789 | selectedCount++;
|
1790 | }
|
1791 | }
|
1792 |
|
1793 | if (selectedCount === 0) isAllSelected = false;
|
1794 | states.isAllSelected = isAllSelected;
|
1795 | },
|
1796 |
|
1797 |
|
1798 |
|
1799 | updateFilters: function updateFilters(columns, values) {
|
1800 | if (!Array.isArray(columns)) {
|
1801 | columns = [columns];
|
1802 | }
|
1803 | var states = this.states;
|
1804 | var filters = {};
|
1805 | columns.forEach(function (col) {
|
1806 | states.filters[col.id] = values;
|
1807 | filters[col.columnKey || col.id] = values;
|
1808 | });
|
1809 |
|
1810 | return filters;
|
1811 | },
|
1812 | updateSort: function updateSort(column, prop, order) {
|
1813 | if (this.states.sortingColumn && this.states.sortingColumn !== column) {
|
1814 | this.states.sortingColumn.order = null;
|
1815 | }
|
1816 | this.states.sortingColumn = column;
|
1817 | this.states.sortProp = prop;
|
1818 | this.states.sortOrder = order;
|
1819 | },
|
1820 | execFilter: function execFilter() {
|
1821 | var _this = this;
|
1822 |
|
1823 | var states = this.states;
|
1824 | var _data = states._data,
|
1825 | filters = states.filters;
|
1826 |
|
1827 | var data = _data;
|
1828 |
|
1829 | Object.keys(filters).forEach(function (columnId) {
|
1830 | var values = states.filters[columnId];
|
1831 | if (!values || values.length === 0) return;
|
1832 | var column = Object(util["d" ])(_this.states, columnId);
|
1833 | if (column && column.filterMethod) {
|
1834 | data = data.filter(function (row) {
|
1835 | return values.some(function (value) {
|
1836 | return column.filterMethod.call(null, value, row, column);
|
1837 | });
|
1838 | });
|
1839 | }
|
1840 | });
|
1841 |
|
1842 | states.filteredData = data;
|
1843 | },
|
1844 | execSort: function execSort() {
|
1845 | var states = this.states;
|
1846 | states.data = watcher_sortData(states.filteredData, states);
|
1847 | },
|
1848 |
|
1849 |
|
1850 |
|
1851 | execQuery: function execQuery(ignore) {
|
1852 | if (!(ignore && ignore.filter)) {
|
1853 | this.execFilter();
|
1854 | }
|
1855 | this.execSort();
|
1856 | },
|
1857 | clearFilter: function clearFilter(columnKeys) {
|
1858 | var states = this.states;
|
1859 | var _table$$refs = this.table.$refs,
|
1860 | tableHeader = _table$$refs.tableHeader,
|
1861 | fixedTableHeader = _table$$refs.fixedTableHeader,
|
1862 | rightFixedTableHeader = _table$$refs.rightFixedTableHeader;
|
1863 |
|
1864 |
|
1865 | var panels = {};
|
1866 | if (tableHeader) panels = merge_default()(panels, tableHeader.filterPanels);
|
1867 | if (fixedTableHeader) panels = merge_default()(panels, fixedTableHeader.filterPanels);
|
1868 | if (rightFixedTableHeader) panels = merge_default()(panels, rightFixedTableHeader.filterPanels);
|
1869 |
|
1870 | var keys = Object.keys(panels);
|
1871 | if (!keys.length) return;
|
1872 |
|
1873 | if (typeof columnKeys === 'string') {
|
1874 | columnKeys = [columnKeys];
|
1875 | }
|
1876 |
|
1877 | if (Array.isArray(columnKeys)) {
|
1878 | var columns = columnKeys.map(function (key) {
|
1879 | return Object(util["e" ])(states, key);
|
1880 | });
|
1881 | keys.forEach(function (key) {
|
1882 | var column = columns.find(function (col) {
|
1883 | return col.id === key;
|
1884 | });
|
1885 | if (column) {
|
1886 |
|
1887 | panels[key].filteredValue = [];
|
1888 | }
|
1889 | });
|
1890 | this.commit('filterChange', {
|
1891 | column: columns,
|
1892 | values: [],
|
1893 | silent: true,
|
1894 | multi: true
|
1895 | });
|
1896 | } else {
|
1897 | keys.forEach(function (key) {
|
1898 |
|
1899 | panels[key].filteredValue = [];
|
1900 | });
|
1901 |
|
1902 | states.filters = {};
|
1903 | this.commit('filterChange', {
|
1904 | column: {},
|
1905 | values: [],
|
1906 | silent: true
|
1907 | });
|
1908 | }
|
1909 | },
|
1910 | clearSort: function clearSort() {
|
1911 | var states = this.states;
|
1912 | if (!states.sortingColumn) return;
|
1913 |
|
1914 | this.updateSort(null, null, null);
|
1915 | this.commit('changeSortCondition', {
|
1916 | silent: true
|
1917 | });
|
1918 | },
|
1919 |
|
1920 |
|
1921 |
|
1922 | setExpandRowKeysAdapter: function setExpandRowKeysAdapter(val) {
|
1923 |
|
1924 | this.setExpandRowKeys(val);
|
1925 | this.updateTreeExpandKeys(val);
|
1926 | },
|
1927 |
|
1928 |
|
1929 |
|
1930 | toggleRowExpansionAdapter: function toggleRowExpansionAdapter(row, expanded) {
|
1931 | var hasExpandColumn = this.states.columns.some(function (_ref) {
|
1932 | var type = _ref.type;
|
1933 | return type === 'expand';
|
1934 | });
|
1935 | if (hasExpandColumn) {
|
1936 | this.toggleRowExpansion(row, expanded);
|
1937 | } else {
|
1938 | this.toggleTreeExpansion(row, expanded);
|
1939 | }
|
1940 | }
|
1941 | }
|
1942 | }));
|
1943 |
|
1944 |
|
1945 |
|
1946 |
|
1947 |
|
1948 | watcher.prototype.mutations = {
|
1949 | setData: function setData(states, data) {
|
1950 | var dataInstanceChanged = states._data !== data;
|
1951 | states._data = data;
|
1952 |
|
1953 | this.execQuery();
|
1954 |
|
1955 |
|
1956 | this.updateCurrentRowData();
|
1957 | this.updateExpandRows();
|
1958 | if (states.reserveSelection) {
|
1959 | this.assertRowKey();
|
1960 | this.updateSelectionByRowKey();
|
1961 | } else {
|
1962 | if (dataInstanceChanged) {
|
1963 | this.clearSelection();
|
1964 | } else {
|
1965 | this.cleanSelection();
|
1966 | }
|
1967 | }
|
1968 | this.updateAllSelected();
|
1969 |
|
1970 | this.updateTableScrollY();
|
1971 | },
|
1972 | insertColumn: function insertColumn(states, column, index, parent) {
|
1973 | var array = states._columns;
|
1974 | if (parent) {
|
1975 | array = parent.children;
|
1976 | if (!array) array = parent.children = [];
|
1977 | }
|
1978 |
|
1979 | if (typeof index !== 'undefined') {
|
1980 | array.splice(index, 0, column);
|
1981 | } else {
|
1982 | array.push(column);
|
1983 | }
|
1984 |
|
1985 | if (column.type === 'selection') {
|
1986 | states.selectable = column.selectable;
|
1987 | states.reserveSelection = column.reserveSelection;
|
1988 | }
|
1989 |
|
1990 | if (this.table.$ready) {
|
1991 | this.updateColumns();
|
1992 | this.scheduleLayout();
|
1993 | }
|
1994 | },
|
1995 | removeColumn: function removeColumn(states, column, parent) {
|
1996 | var array = states._columns;
|
1997 | if (parent) {
|
1998 | array = parent.children;
|
1999 | if (!array) array = parent.children = [];
|
2000 | }
|
2001 | if (array) {
|
2002 | array.splice(array.indexOf(column), 1);
|
2003 | }
|
2004 |
|
2005 | if (this.table.$ready) {
|
2006 | this.updateColumns();
|
2007 | this.scheduleLayout();
|
2008 | }
|
2009 | },
|
2010 | sort: function sort(states, options) {
|
2011 | var prop = options.prop,
|
2012 | order = options.order,
|
2013 | init = options.init;
|
2014 |
|
2015 | if (prop) {
|
2016 | var column = Object(util_["arrayFind"])(states.columns, function (column) {
|
2017 | return column.property === prop;
|
2018 | });
|
2019 | if (column) {
|
2020 | column.order = order;
|
2021 | this.updateSort(column, prop, order);
|
2022 | this.commit('changeSortCondition', { init: init });
|
2023 | }
|
2024 | }
|
2025 | },
|
2026 | changeSortCondition: function changeSortCondition(states, options) {
|
2027 |
|
2028 | var column = states.sortingColumn,
|
2029 | prop = states.sortProp,
|
2030 | order = states.sortOrder;
|
2031 |
|
2032 | if (order === null) {
|
2033 | states.sortingColumn = null;
|
2034 | states.sortProp = null;
|
2035 | }
|
2036 | var ingore = { filter: true };
|
2037 | this.execQuery(ingore);
|
2038 |
|
2039 | if (!options || !(options.silent || options.init)) {
|
2040 | this.table.$emit('sort-change', {
|
2041 | column: column,
|
2042 | prop: prop,
|
2043 | order: order
|
2044 | });
|
2045 | }
|
2046 |
|
2047 | this.updateTableScrollY();
|
2048 | },
|
2049 | filterChange: function filterChange(states, options) {
|
2050 | var column = options.column,
|
2051 | values = options.values,
|
2052 | silent = options.silent;
|
2053 |
|
2054 | var newFilters = this.updateFilters(column, values);
|
2055 |
|
2056 | this.execQuery();
|
2057 |
|
2058 | if (!silent) {
|
2059 | this.table.$emit('filter-change', newFilters);
|
2060 | }
|
2061 |
|
2062 | this.updateTableScrollY();
|
2063 | },
|
2064 | toggleAllSelection: function toggleAllSelection() {
|
2065 | this.toggleAllSelection();
|
2066 | },
|
2067 | rowSelectedChanged: function rowSelectedChanged(states, row) {
|
2068 | this.toggleRowSelection(row);
|
2069 | this.updateAllSelected();
|
2070 | },
|
2071 | setHoverRow: function setHoverRow(states, row) {
|
2072 | states.hoverRow = row;
|
2073 | },
|
2074 | setCurrentRow: function setCurrentRow(states, row) {
|
2075 | this.updateCurrentRow(row);
|
2076 | }
|
2077 | };
|
2078 |
|
2079 | watcher.prototype.commit = function (name) {
|
2080 | var mutations = this.mutations;
|
2081 | if (mutations[name]) {
|
2082 | for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
2083 | args[_key - 1] = arguments[_key];
|
2084 | }
|
2085 |
|
2086 | mutations[name].apply(this, [this.states].concat(args));
|
2087 | } else {
|
2088 | throw new Error('Action not found: ' + name);
|
2089 | }
|
2090 | };
|
2091 |
|
2092 | watcher.prototype.updateTableScrollY = function () {
|
2093 | external_vue_default.a.nextTick(this.table.updateScrollY);
|
2094 | };
|
2095 |
|
2096 | var src_store = (watcher);
|
2097 |
|
2098 | var debounce_ = __webpack_require__(17);
|
2099 | var debounce_default = __webpack_require__.n(debounce_);
|
2100 |
|
2101 |
|
2102 |
|
2103 |
|
2104 |
|
2105 | function createStore(table) {
|
2106 | var initialState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
2107 |
|
2108 | if (!table) {
|
2109 | throw new Error('Table is required.');
|
2110 | }
|
2111 |
|
2112 | var store = new src_store();
|
2113 | store.table = table;
|
2114 |
|
2115 |
|
2116 | store.toggleAllSelection = debounce_default()(10, store._toggleAllSelection);
|
2117 | Object.keys(initialState).forEach(function (key) {
|
2118 | store.states[key] = initialState[key];
|
2119 | });
|
2120 | return store;
|
2121 | }
|
2122 |
|
2123 | function mapStates(mapper) {
|
2124 | var res = {};
|
2125 | Object.keys(mapper).forEach(function (key) {
|
2126 | var value = mapper[key];
|
2127 | var fn = void 0;
|
2128 | if (typeof value === 'string') {
|
2129 | fn = function fn() {
|
2130 | return this.store.states[value];
|
2131 | };
|
2132 | } else if (typeof value === 'function') {
|
2133 | fn = function fn() {
|
2134 | return value.call(this, this.store.states);
|
2135 | };
|
2136 | } else {
|
2137 | console.error('invalid value type');
|
2138 | }
|
2139 | if (fn) {
|
2140 | res[key] = fn;
|
2141 | }
|
2142 | });
|
2143 | return res;
|
2144 | };
|
2145 |
|
2146 | var scrollbar_width_ = __webpack_require__(38);
|
2147 | var scrollbar_width_default = __webpack_require__.n(scrollbar_width_);
|
2148 |
|
2149 |
|
2150 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
2151 |
|
2152 |
|
2153 |
|
2154 |
|
2155 |
|
2156 | var table_layout_TableLayout = function () {
|
2157 | function TableLayout(options) {
|
2158 | _classCallCheck(this, TableLayout);
|
2159 |
|
2160 | this.observers = [];
|
2161 | this.table = null;
|
2162 | this.store = null;
|
2163 | this.columns = null;
|
2164 | this.fit = true;
|
2165 | this.showHeader = true;
|
2166 |
|
2167 | this.height = null;
|
2168 | this.scrollX = false;
|
2169 | this.scrollY = false;
|
2170 | this.bodyWidth = null;
|
2171 | this.fixedWidth = null;
|
2172 | this.rightFixedWidth = null;
|
2173 | this.tableHeight = null;
|
2174 | this.headerHeight = 44;
|
2175 | this.appendHeight = 0;
|
2176 | this.footerHeight = 44;
|
2177 | this.viewportHeight = null;
|
2178 | this.bodyHeight = null;
|
2179 | this.fixedBodyHeight = null;
|
2180 | this.gutterWidth = scrollbar_width_default()();
|
2181 |
|
2182 | for (var name in options) {
|
2183 | if (options.hasOwnProperty(name)) {
|
2184 | this[name] = options[name];
|
2185 | }
|
2186 | }
|
2187 |
|
2188 | if (!this.table) {
|
2189 | throw new Error('table is required for Table Layout');
|
2190 | }
|
2191 | if (!this.store) {
|
2192 | throw new Error('store is required for Table Layout');
|
2193 | }
|
2194 | }
|
2195 |
|
2196 | TableLayout.prototype.updateScrollY = function updateScrollY() {
|
2197 | var height = this.height;
|
2198 | if (height === null) return false;
|
2199 | var bodyWrapper = this.table.bodyWrapper;
|
2200 | if (this.table.$el && bodyWrapper) {
|
2201 | var body = bodyWrapper.querySelector('.el-table__body');
|
2202 | var prevScrollY = this.scrollY;
|
2203 | var scrollY = body.offsetHeight > this.bodyHeight;
|
2204 | this.scrollY = scrollY;
|
2205 | return prevScrollY !== scrollY;
|
2206 | }
|
2207 | return false;
|
2208 | };
|
2209 |
|
2210 | TableLayout.prototype.setHeight = function setHeight(value) {
|
2211 | var _this = this;
|
2212 |
|
2213 | var prop = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'height';
|
2214 |
|
2215 | if (external_vue_default.a.prototype.$isServer) return;
|
2216 | var el = this.table.$el;
|
2217 | value = Object(util["j" ])(value);
|
2218 | this.height = value;
|
2219 |
|
2220 | if (!el && (value || value === 0)) return external_vue_default.a.nextTick(function () {
|
2221 | return _this.setHeight(value, prop);
|
2222 | });
|
2223 |
|
2224 | if (typeof value === 'number') {
|
2225 | el.style[prop] = value + 'px';
|
2226 | this.updateElsHeight();
|
2227 | } else if (typeof value === 'string') {
|
2228 | el.style[prop] = value;
|
2229 | this.updateElsHeight();
|
2230 | }
|
2231 | };
|
2232 |
|
2233 | TableLayout.prototype.setMaxHeight = function setMaxHeight(value) {
|
2234 | this.setHeight(value, 'max-height');
|
2235 | };
|
2236 |
|
2237 | TableLayout.prototype.getFlattenColumns = function getFlattenColumns() {
|
2238 | var flattenColumns = [];
|
2239 | var columns = this.table.columns;
|
2240 | columns.forEach(function (column) {
|
2241 | if (column.isColumnGroup) {
|
2242 | flattenColumns.push.apply(flattenColumns, column.columns);
|
2243 | } else {
|
2244 | flattenColumns.push(column);
|
2245 | }
|
2246 | });
|
2247 |
|
2248 | return flattenColumns;
|
2249 | };
|
2250 |
|
2251 | TableLayout.prototype.updateElsHeight = function updateElsHeight() {
|
2252 | var _this2 = this;
|
2253 |
|
2254 | if (!this.table.$ready) return external_vue_default.a.nextTick(function () {
|
2255 | return _this2.updateElsHeight();
|
2256 | });
|
2257 | var _table$$refs = this.table.$refs,
|
2258 | headerWrapper = _table$$refs.headerWrapper,
|
2259 | appendWrapper = _table$$refs.appendWrapper,
|
2260 | footerWrapper = _table$$refs.footerWrapper;
|
2261 |
|
2262 | this.appendHeight = appendWrapper ? appendWrapper.offsetHeight : 0;
|
2263 |
|
2264 | if (this.showHeader && !headerWrapper) return;
|
2265 |
|
2266 |
|
2267 | var headerTrElm = headerWrapper ? headerWrapper.querySelector('.el-table__header tr') : null;
|
2268 | var noneHeader = this.headerDisplayNone(headerTrElm);
|
2269 |
|
2270 | var headerHeight = this.headerHeight = !this.showHeader ? 0 : headerWrapper.offsetHeight;
|
2271 | if (this.showHeader && !noneHeader && headerWrapper.offsetWidth > 0 && (this.table.columns || []).length > 0 && headerHeight < 2) {
|
2272 | return external_vue_default.a.nextTick(function () {
|
2273 | return _this2.updateElsHeight();
|
2274 | });
|
2275 | }
|
2276 | var tableHeight = this.tableHeight = this.table.$el.clientHeight;
|
2277 | var footerHeight = this.footerHeight = footerWrapper ? footerWrapper.offsetHeight : 0;
|
2278 | if (this.height !== null) {
|
2279 | this.bodyHeight = tableHeight - headerHeight - footerHeight + (footerWrapper ? 1 : 0);
|
2280 | }
|
2281 | this.fixedBodyHeight = this.scrollX ? this.bodyHeight - this.gutterWidth : this.bodyHeight;
|
2282 |
|
2283 | var noData = !(this.store.states.data && this.store.states.data.length);
|
2284 | this.viewportHeight = this.scrollX ? tableHeight - (noData ? 0 : this.gutterWidth) : tableHeight;
|
2285 |
|
2286 | this.updateScrollY();
|
2287 | this.notifyObservers('scrollable');
|
2288 | };
|
2289 |
|
2290 | TableLayout.prototype.headerDisplayNone = function headerDisplayNone(elm) {
|
2291 | if (!elm) return true;
|
2292 | var headerChild = elm;
|
2293 | while (headerChild.tagName !== 'DIV') {
|
2294 | if (getComputedStyle(headerChild).display === 'none') {
|
2295 | return true;
|
2296 | }
|
2297 | headerChild = headerChild.parentElement;
|
2298 | }
|
2299 | return false;
|
2300 | };
|
2301 |
|
2302 | TableLayout.prototype.updateColumnsWidth = function updateColumnsWidth() {
|
2303 | if (external_vue_default.a.prototype.$isServer) return;
|
2304 | var fit = this.fit;
|
2305 | var bodyWidth = this.table.$el.clientWidth;
|
2306 | var bodyMinWidth = 0;
|
2307 |
|
2308 | var flattenColumns = this.getFlattenColumns();
|
2309 | var flexColumns = flattenColumns.filter(function (column) {
|
2310 | return typeof column.width !== 'number';
|
2311 | });
|
2312 |
|
2313 | flattenColumns.forEach(function (column) {
|
2314 |
|
2315 | if (typeof column.width === 'number' && column.realWidth) column.realWidth = null;
|
2316 | });
|
2317 |
|
2318 | if (flexColumns.length > 0 && fit) {
|
2319 | flattenColumns.forEach(function (column) {
|
2320 | bodyMinWidth += column.width || column.minWidth || 80;
|
2321 | });
|
2322 |
|
2323 | var scrollYWidth = this.scrollY ? this.gutterWidth : 0;
|
2324 |
|
2325 | if (bodyMinWidth <= bodyWidth - scrollYWidth) {
|
2326 |
|
2327 | this.scrollX = false;
|
2328 |
|
2329 | var totalFlexWidth = bodyWidth - scrollYWidth - bodyMinWidth;
|
2330 |
|
2331 | if (flexColumns.length === 1) {
|
2332 | flexColumns[0].realWidth = (flexColumns[0].minWidth || 80) + totalFlexWidth;
|
2333 | } else {
|
2334 | var allColumnsWidth = flexColumns.reduce(function (prev, column) {
|
2335 | return prev + (column.minWidth || 80);
|
2336 | }, 0);
|
2337 | var flexWidthPerPixel = totalFlexWidth / allColumnsWidth;
|
2338 | var noneFirstWidth = 0;
|
2339 |
|
2340 | flexColumns.forEach(function (column, index) {
|
2341 | if (index === 0) return;
|
2342 | var flexWidth = Math.floor((column.minWidth || 80) * flexWidthPerPixel);
|
2343 | noneFirstWidth += flexWidth;
|
2344 | column.realWidth = (column.minWidth || 80) + flexWidth;
|
2345 | });
|
2346 |
|
2347 | flexColumns[0].realWidth = (flexColumns[0].minWidth || 80) + totalFlexWidth - noneFirstWidth;
|
2348 | }
|
2349 | } else {
|
2350 |
|
2351 | this.scrollX = true;
|
2352 | flexColumns.forEach(function (column) {
|
2353 | column.realWidth = column.minWidth;
|
2354 | });
|
2355 | }
|
2356 |
|
2357 | this.bodyWidth = Math.max(bodyMinWidth, bodyWidth);
|
2358 | this.table.resizeState.width = this.bodyWidth;
|
2359 | } else {
|
2360 | flattenColumns.forEach(function (column) {
|
2361 | if (!column.width && !column.minWidth) {
|
2362 | column.realWidth = 80;
|
2363 | } else {
|
2364 | column.realWidth = column.width || column.minWidth;
|
2365 | }
|
2366 |
|
2367 | bodyMinWidth += column.realWidth;
|
2368 | });
|
2369 | this.scrollX = bodyMinWidth > bodyWidth;
|
2370 |
|
2371 | this.bodyWidth = bodyMinWidth;
|
2372 | }
|
2373 |
|
2374 | var fixedColumns = this.store.states.fixedColumns;
|
2375 |
|
2376 | if (fixedColumns.length > 0) {
|
2377 | var fixedWidth = 0;
|
2378 | fixedColumns.forEach(function (column) {
|
2379 | fixedWidth += column.realWidth || column.width;
|
2380 | });
|
2381 |
|
2382 | this.fixedWidth = fixedWidth;
|
2383 | }
|
2384 |
|
2385 | var rightFixedColumns = this.store.states.rightFixedColumns;
|
2386 | if (rightFixedColumns.length > 0) {
|
2387 | var rightFixedWidth = 0;
|
2388 | rightFixedColumns.forEach(function (column) {
|
2389 | rightFixedWidth += column.realWidth || column.width;
|
2390 | });
|
2391 |
|
2392 | this.rightFixedWidth = rightFixedWidth;
|
2393 | }
|
2394 |
|
2395 | this.notifyObservers('columns');
|
2396 | };
|
2397 |
|
2398 | TableLayout.prototype.addObserver = function addObserver(observer) {
|
2399 | this.observers.push(observer);
|
2400 | };
|
2401 |
|
2402 | TableLayout.prototype.removeObserver = function removeObserver(observer) {
|
2403 | var index = this.observers.indexOf(observer);
|
2404 | if (index !== -1) {
|
2405 | this.observers.splice(index, 1);
|
2406 | }
|
2407 | };
|
2408 |
|
2409 | TableLayout.prototype.notifyObservers = function notifyObservers(event) {
|
2410 | var _this3 = this;
|
2411 |
|
2412 | var observers = this.observers;
|
2413 | observers.forEach(function (observer) {
|
2414 | switch (event) {
|
2415 | case 'columns':
|
2416 | observer.onColumnsChange(_this3);
|
2417 | break;
|
2418 | case 'scrollable':
|
2419 | observer.onScrollableChange(_this3);
|
2420 | break;
|
2421 | default:
|
2422 | throw new Error('Table Layout don\'t have event ' + event + '.');
|
2423 | }
|
2424 | });
|
2425 | };
|
2426 |
|
2427 | return TableLayout;
|
2428 | }();
|
2429 |
|
2430 | var table_layout = (table_layout_TableLayout);
|
2431 |
|
2432 | var dom_ = __webpack_require__(2);
|
2433 |
|
2434 |
|
2435 | var tooltip_ = __webpack_require__(29);
|
2436 | var tooltip_default = __webpack_require__.n(tooltip_);
|
2437 |
|
2438 |
|
2439 | var layout_observer = ({
|
2440 | created: function created() {
|
2441 | this.tableLayout.addObserver(this);
|
2442 | },
|
2443 | destroyed: function destroyed() {
|
2444 | this.tableLayout.removeObserver(this);
|
2445 | },
|
2446 |
|
2447 |
|
2448 | computed: {
|
2449 | tableLayout: function tableLayout() {
|
2450 | var layout = this.layout;
|
2451 | if (!layout && this.table) {
|
2452 | layout = this.table.layout;
|
2453 | }
|
2454 | if (!layout) {
|
2455 | throw new Error('Can not find table layout.');
|
2456 | }
|
2457 | return layout;
|
2458 | }
|
2459 | },
|
2460 |
|
2461 | mounted: function mounted() {
|
2462 | this.onColumnsChange(this.tableLayout);
|
2463 | this.onScrollableChange(this.tableLayout);
|
2464 | },
|
2465 | updated: function updated() {
|
2466 | if (this.__updated__) return;
|
2467 | this.onColumnsChange(this.tableLayout);
|
2468 | this.onScrollableChange(this.tableLayout);
|
2469 | this.__updated__ = true;
|
2470 | },
|
2471 |
|
2472 |
|
2473 | methods: {
|
2474 | onColumnsChange: function onColumnsChange(layout) {
|
2475 | var cols = this.$el.querySelectorAll('colgroup > col');
|
2476 | if (!cols.length) return;
|
2477 | var flattenColumns = layout.getFlattenColumns();
|
2478 | var columnsMap = {};
|
2479 | flattenColumns.forEach(function (column) {
|
2480 | columnsMap[column.id] = column;
|
2481 | });
|
2482 | for (var i = 0, j = cols.length; i < j; i++) {
|
2483 | var col = cols[i];
|
2484 | var name = col.getAttribute('name');
|
2485 | var column = columnsMap[name];
|
2486 | if (column) {
|
2487 | col.setAttribute('width', column.realWidth || column.width);
|
2488 | }
|
2489 | }
|
2490 | },
|
2491 | onScrollableChange: function onScrollableChange(layout) {
|
2492 | var cols = this.$el.querySelectorAll('colgroup > col[name=gutter]');
|
2493 | for (var i = 0, j = cols.length; i < j; i++) {
|
2494 | var col = cols[i];
|
2495 | col.setAttribute('width', layout.scrollY ? layout.gutterWidth : '0');
|
2496 | }
|
2497 | var ths = this.$el.querySelectorAll('th.gutter');
|
2498 | for (var _i = 0, _j = ths.length; _i < _j; _i++) {
|
2499 | var th = ths[_i];
|
2500 | th.style.width = layout.scrollY ? layout.gutterWidth + 'px' : '0';
|
2501 | th.style.display = layout.scrollY ? '' : 'none';
|
2502 | }
|
2503 | }
|
2504 | }
|
2505 | });
|
2506 |
|
2507 | 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; };
|
2508 |
|
2509 | var table_body_extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
2510 |
|
2511 |
|
2512 |
|
2513 |
|
2514 |
|
2515 |
|
2516 |
|
2517 |
|
2518 |
|
2519 |
|
2520 | var table_body = ({
|
2521 | name: 'ElTableBody',
|
2522 |
|
2523 | mixins: [layout_observer],
|
2524 |
|
2525 | components: {
|
2526 | ElCheckbox: checkbox_default.a,
|
2527 | ElTooltip: tooltip_default.a
|
2528 | },
|
2529 |
|
2530 | props: {
|
2531 | store: {
|
2532 | required: true
|
2533 | },
|
2534 | stripe: Boolean,
|
2535 | context: {},
|
2536 | rowClassName: [String, Function],
|
2537 | rowStyle: [Object, Function],
|
2538 | fixed: String,
|
2539 | highlight: Boolean
|
2540 | },
|
2541 |
|
2542 | render: function render(h) {
|
2543 | var _this = this;
|
2544 |
|
2545 | var data = this.data || [];
|
2546 | return h(
|
2547 | 'table',
|
2548 | {
|
2549 | 'class': 'el-table__body',
|
2550 | attrs: { cellspacing: '0',
|
2551 | cellpadding: '0',
|
2552 | border: '0' }
|
2553 | },
|
2554 | [h('colgroup', [this.columns.map(function (column) {
|
2555 | return h('col', {
|
2556 | attrs: { name: column.id },
|
2557 | key: column.id });
|
2558 | })]), h('tbody', [data.reduce(function (acc, row) {
|
2559 | return acc.concat(_this.wrappedRowRender(row, acc.length));
|
2560 | }, []), h('el-tooltip', {
|
2561 | attrs: { effect: this.table.tooltipEffect, placement: 'top', content: this.tooltipContent },
|
2562 | ref: 'tooltip' })])]
|
2563 | );
|
2564 | },
|
2565 |
|
2566 |
|
2567 | computed: table_body_extends({
|
2568 | table: function table() {
|
2569 | return this.$parent;
|
2570 | }
|
2571 | }, mapStates({
|
2572 | data: 'data',
|
2573 | columns: 'columns',
|
2574 | treeIndent: 'indent',
|
2575 | leftFixedLeafCount: 'fixedLeafColumnsLength',
|
2576 | rightFixedLeafCount: 'rightFixedLeafColumnsLength',
|
2577 | columnsCount: function columnsCount(states) {
|
2578 | return states.columns.length;
|
2579 | },
|
2580 | leftFixedCount: function leftFixedCount(states) {
|
2581 | return states.fixedColumns.length;
|
2582 | },
|
2583 | rightFixedCount: function rightFixedCount(states) {
|
2584 | return states.rightFixedColumns.length;
|
2585 | },
|
2586 | hasExpandColumn: function hasExpandColumn(states) {
|
2587 | return states.columns.some(function (_ref) {
|
2588 | var type = _ref.type;
|
2589 | return type === 'expand';
|
2590 | });
|
2591 | }
|
2592 | }), {
|
2593 | firstDefaultColumnIndex: function firstDefaultColumnIndex() {
|
2594 | return Object(util_["arrayFindIndex"])(this.columns, function (_ref2) {
|
2595 | var type = _ref2.type;
|
2596 | return type === 'default';
|
2597 | });
|
2598 | }
|
2599 | }),
|
2600 |
|
2601 | watch: {
|
2602 |
|
2603 |
|
2604 | 'store.states.hoverRow': function storeStatesHoverRow(newVal, oldVal) {
|
2605 | var _this2 = this;
|
2606 |
|
2607 | if (!this.store.states.isComplex || this.$isServer) return;
|
2608 | var raf = window.requestAnimationFrame;
|
2609 | if (!raf) {
|
2610 | raf = function raf(fn) {
|
2611 | return setTimeout(fn, 16);
|
2612 | };
|
2613 | }
|
2614 | raf(function () {
|
2615 | var rows = _this2.$el.querySelectorAll('.el-table__row');
|
2616 | var oldRow = rows[oldVal];
|
2617 | var newRow = rows[newVal];
|
2618 | if (oldRow) {
|
2619 | Object(dom_["removeClass"])(oldRow, 'hover-row');
|
2620 | }
|
2621 | if (newRow) {
|
2622 | Object(dom_["addClass"])(newRow, 'hover-row');
|
2623 | }
|
2624 | });
|
2625 | }
|
2626 | },
|
2627 |
|
2628 | data: function data() {
|
2629 | return {
|
2630 | tooltipContent: ''
|
2631 | };
|
2632 | },
|
2633 | created: function created() {
|
2634 | this.activateTooltip = debounce_default()(50, function (tooltip) {
|
2635 | return tooltip.handleShowPopper();
|
2636 | });
|
2637 | },
|
2638 |
|
2639 |
|
2640 | methods: {
|
2641 | getKeyOfRow: function getKeyOfRow(row, index) {
|
2642 | var rowKey = this.table.rowKey;
|
2643 | if (rowKey) {
|
2644 | return Object(util["g" ])(row, rowKey);
|
2645 | }
|
2646 | return index;
|
2647 | },
|
2648 | isColumnHidden: function isColumnHidden(index) {
|
2649 | if (this.fixed === true || this.fixed === 'left') {
|
2650 | return index >= this.leftFixedLeafCount;
|
2651 | } else if (this.fixed === 'right') {
|
2652 | return index < this.columnsCount - this.rightFixedLeafCount;
|
2653 | } else {
|
2654 | return index < this.leftFixedLeafCount || index >= this.columnsCount - this.rightFixedLeafCount;
|
2655 | }
|
2656 | },
|
2657 | getSpan: function getSpan(row, column, rowIndex, columnIndex) {
|
2658 | var rowspan = 1;
|
2659 | var colspan = 1;
|
2660 | var fn = this.table.spanMethod;
|
2661 | if (typeof fn === 'function') {
|
2662 | var result = fn({
|
2663 | row: row,
|
2664 | column: column,
|
2665 | rowIndex: rowIndex,
|
2666 | columnIndex: columnIndex
|
2667 | });
|
2668 | if (Array.isArray(result)) {
|
2669 | rowspan = result[0];
|
2670 | colspan = result[1];
|
2671 | } else if ((typeof result === 'undefined' ? 'undefined' : _typeof(result)) === 'object') {
|
2672 | rowspan = result.rowspan;
|
2673 | colspan = result.colspan;
|
2674 | }
|
2675 | }
|
2676 | return { rowspan: rowspan, colspan: colspan };
|
2677 | },
|
2678 | getRowStyle: function getRowStyle(row, rowIndex) {
|
2679 | var rowStyle = this.table.rowStyle;
|
2680 | if (typeof rowStyle === 'function') {
|
2681 | return rowStyle.call(null, {
|
2682 | row: row,
|
2683 | rowIndex: rowIndex
|
2684 | });
|
2685 | }
|
2686 | return rowStyle || null;
|
2687 | },
|
2688 | getRowClass: function getRowClass(row, rowIndex) {
|
2689 | var classes = ['el-table__row'];
|
2690 | if (this.table.highlightCurrentRow && row === this.store.states.currentRow) {
|
2691 | classes.push('current-row');
|
2692 | }
|
2693 |
|
2694 | if (this.stripe && rowIndex % 2 === 1) {
|
2695 | classes.push('el-table__row--striped');
|
2696 | }
|
2697 | var rowClassName = this.table.rowClassName;
|
2698 | if (typeof rowClassName === 'string') {
|
2699 | classes.push(rowClassName);
|
2700 | } else if (typeof rowClassName === 'function') {
|
2701 | classes.push(rowClassName.call(null, {
|
2702 | row: row,
|
2703 | rowIndex: rowIndex
|
2704 | }));
|
2705 | }
|
2706 |
|
2707 | if (this.store.states.expandRows.indexOf(row) > -1) {
|
2708 | classes.push('expanded');
|
2709 | }
|
2710 |
|
2711 | return classes;
|
2712 | },
|
2713 | getCellStyle: function getCellStyle(rowIndex, columnIndex, row, column) {
|
2714 | var cellStyle = this.table.cellStyle;
|
2715 | if (typeof cellStyle === 'function') {
|
2716 | return cellStyle.call(null, {
|
2717 | rowIndex: rowIndex,
|
2718 | columnIndex: columnIndex,
|
2719 | row: row,
|
2720 | column: column
|
2721 | });
|
2722 | }
|
2723 | return cellStyle;
|
2724 | },
|
2725 | getCellClass: function getCellClass(rowIndex, columnIndex, row, column) {
|
2726 | var classes = [column.id, column.align, column.className];
|
2727 |
|
2728 | if (this.isColumnHidden(columnIndex)) {
|
2729 | classes.push('is-hidden');
|
2730 | }
|
2731 |
|
2732 | var cellClassName = this.table.cellClassName;
|
2733 | if (typeof cellClassName === 'string') {
|
2734 | classes.push(cellClassName);
|
2735 | } else if (typeof cellClassName === 'function') {
|
2736 | classes.push(cellClassName.call(null, {
|
2737 | rowIndex: rowIndex,
|
2738 | columnIndex: columnIndex,
|
2739 | row: row,
|
2740 | column: column
|
2741 | }));
|
2742 | }
|
2743 |
|
2744 | return classes.join(' ');
|
2745 | },
|
2746 | getColspanRealWidth: function getColspanRealWidth(columns, colspan, index) {
|
2747 | if (colspan < 1) {
|
2748 | return columns[index].realWidth;
|
2749 | }
|
2750 | var widthArr = columns.map(function (_ref3) {
|
2751 | var realWidth = _ref3.realWidth;
|
2752 | return realWidth;
|
2753 | }).slice(index, index + colspan);
|
2754 | return widthArr.reduce(function (acc, width) {
|
2755 | return acc + width;
|
2756 | }, -1);
|
2757 | },
|
2758 | handleCellMouseEnter: function handleCellMouseEnter(event, row) {
|
2759 | var table = this.table;
|
2760 | var cell = Object(util["b" ])(event);
|
2761 |
|
2762 | if (cell) {
|
2763 | var column = Object(util["c" ])(table, cell);
|
2764 | var hoverState = table.hoverState = { cell: cell, column: column, row: row };
|
2765 | table.$emit('cell-mouse-enter', hoverState.row, hoverState.column, hoverState.cell, event);
|
2766 | }
|
2767 |
|
2768 |
|
2769 | var cellChild = event.target.querySelector('.cell');
|
2770 | if (!(Object(dom_["hasClass"])(cellChild, 'el-tooltip') && cellChild.childNodes.length)) {
|
2771 | return;
|
2772 | }
|
2773 |
|
2774 |
|
2775 | var range = document.createRange();
|
2776 | range.setStart(cellChild, 0);
|
2777 | range.setEnd(cellChild, cellChild.childNodes.length);
|
2778 | var rangeWidth = range.getBoundingClientRect().width;
|
2779 | var padding = (parseInt(Object(dom_["getStyle"])(cellChild, 'paddingLeft'), 10) || 0) + (parseInt(Object(dom_["getStyle"])(cellChild, 'paddingRight'), 10) || 0);
|
2780 | if ((rangeWidth + padding > cellChild.offsetWidth || cellChild.scrollWidth > cellChild.offsetWidth) && this.$refs.tooltip) {
|
2781 | var tooltip = this.$refs.tooltip;
|
2782 |
|
2783 | this.tooltipContent = cell.innerText || cell.textContent;
|
2784 | tooltip.referenceElm = cell;
|
2785 | tooltip.$refs.popper && (tooltip.$refs.popper.style.display = 'none');
|
2786 | tooltip.doDestroy();
|
2787 | tooltip.setExpectedState(true);
|
2788 | this.activateTooltip(tooltip);
|
2789 | }
|
2790 | },
|
2791 | handleCellMouseLeave: function handleCellMouseLeave(event) {
|
2792 | var tooltip = this.$refs.tooltip;
|
2793 | if (tooltip) {
|
2794 | tooltip.setExpectedState(false);
|
2795 | tooltip.handleClosePopper();
|
2796 | }
|
2797 | var cell = Object(util["b" ])(event);
|
2798 | if (!cell) return;
|
2799 |
|
2800 | var oldHoverState = this.table.hoverState || {};
|
2801 | this.table.$emit('cell-mouse-leave', oldHoverState.row, oldHoverState.column, oldHoverState.cell, event);
|
2802 | },
|
2803 |
|
2804 |
|
2805 | handleMouseEnter: debounce_default()(30, function (index) {
|
2806 | this.store.commit('setHoverRow', index);
|
2807 | }),
|
2808 |
|
2809 | handleMouseLeave: debounce_default()(30, function () {
|
2810 | this.store.commit('setHoverRow', null);
|
2811 | }),
|
2812 |
|
2813 | handleContextMenu: function handleContextMenu(event, row) {
|
2814 | this.handleEvent(event, row, 'contextmenu');
|
2815 | },
|
2816 | handleDoubleClick: function handleDoubleClick(event, row) {
|
2817 | this.handleEvent(event, row, 'dblclick');
|
2818 | },
|
2819 | handleClick: function handleClick(event, row) {
|
2820 | this.store.commit('setCurrentRow', row);
|
2821 | this.handleEvent(event, row, 'click');
|
2822 | },
|
2823 | handleEvent: function handleEvent(event, row, name) {
|
2824 | var table = this.table;
|
2825 | var cell = Object(util["b" ])(event);
|
2826 | var column = void 0;
|
2827 | if (cell) {
|
2828 | column = Object(util["c" ])(table, cell);
|
2829 | if (column) {
|
2830 | table.$emit('cell-' + name, row, column, cell, event);
|
2831 | }
|
2832 | }
|
2833 | table.$emit('row-' + name, row, column, event);
|
2834 | },
|
2835 | rowRender: function rowRender(row, $index, treeRowData) {
|
2836 | var _this3 = this;
|
2837 |
|
2838 | var h = this.$createElement;
|
2839 | var treeIndent = this.treeIndent,
|
2840 | columns = this.columns,
|
2841 | firstDefaultColumnIndex = this.firstDefaultColumnIndex;
|
2842 |
|
2843 | var columnsHidden = columns.map(function (column, index) {
|
2844 | return _this3.isColumnHidden(index);
|
2845 | });
|
2846 | var rowClasses = this.getRowClass(row, $index);
|
2847 | var display = true;
|
2848 | if (treeRowData) {
|
2849 | rowClasses.push('el-table__row--level-' + treeRowData.level);
|
2850 | display = treeRowData.display;
|
2851 | }
|
2852 |
|
2853 |
|
2854 | var displayStyle = display ? null : {
|
2855 | display: 'none'
|
2856 | };
|
2857 | return h(
|
2858 | 'tr',
|
2859 | {
|
2860 | style: [displayStyle, this.getRowStyle(row, $index)],
|
2861 | 'class': rowClasses,
|
2862 | key: this.getKeyOfRow(row, $index),
|
2863 | on: {
|
2864 | 'dblclick': function dblclick($event) {
|
2865 | return _this3.handleDoubleClick($event, row);
|
2866 | },
|
2867 | 'click': function click($event) {
|
2868 | return _this3.handleClick($event, row);
|
2869 | },
|
2870 | 'contextmenu': function contextmenu($event) {
|
2871 | return _this3.handleContextMenu($event, row);
|
2872 | },
|
2873 | 'mouseenter': function mouseenter(_) {
|
2874 | return _this3.handleMouseEnter($index);
|
2875 | },
|
2876 | 'mouseleave': this.handleMouseLeave
|
2877 | }
|
2878 | },
|
2879 | [columns.map(function (column, cellIndex) {
|
2880 | var _getSpan = _this3.getSpan(row, column, $index, cellIndex),
|
2881 | rowspan = _getSpan.rowspan,
|
2882 | colspan = _getSpan.colspan;
|
2883 |
|
2884 | if (!rowspan || !colspan) {
|
2885 | return null;
|
2886 | }
|
2887 | var columnData = table_body_extends({}, column);
|
2888 | columnData.realWidth = _this3.getColspanRealWidth(columns, colspan, cellIndex);
|
2889 | var data = {
|
2890 | store: _this3.store,
|
2891 | _self: _this3.context || _this3.table.$vnode.context,
|
2892 | column: columnData,
|
2893 | row: row,
|
2894 | $index: $index
|
2895 | };
|
2896 | if (cellIndex === firstDefaultColumnIndex && treeRowData) {
|
2897 | data.treeNode = {
|
2898 | indent: treeRowData.level * treeIndent,
|
2899 | level: treeRowData.level
|
2900 | };
|
2901 | if (typeof treeRowData.expanded === 'boolean') {
|
2902 | data.treeNode.expanded = treeRowData.expanded;
|
2903 |
|
2904 | if ('loading' in treeRowData) {
|
2905 | data.treeNode.loading = treeRowData.loading;
|
2906 | }
|
2907 | if ('noLazyChildren' in treeRowData) {
|
2908 | data.treeNode.noLazyChildren = treeRowData.noLazyChildren;
|
2909 | }
|
2910 | }
|
2911 | }
|
2912 | return h(
|
2913 | 'td',
|
2914 | {
|
2915 | style: _this3.getCellStyle($index, cellIndex, row, column),
|
2916 | 'class': _this3.getCellClass($index, cellIndex, row, column),
|
2917 | attrs: { rowspan: rowspan,
|
2918 | colspan: colspan
|
2919 | },
|
2920 | on: {
|
2921 | 'mouseenter': function mouseenter($event) {
|
2922 | return _this3.handleCellMouseEnter($event, row);
|
2923 | },
|
2924 | 'mouseleave': _this3.handleCellMouseLeave
|
2925 | }
|
2926 | },
|
2927 | [column.renderCell.call(_this3._renderProxy, _this3.$createElement, data, columnsHidden[cellIndex])]
|
2928 | );
|
2929 | })]
|
2930 | );
|
2931 | },
|
2932 | wrappedRowRender: function wrappedRowRender(row, $index) {
|
2933 | var _this4 = this;
|
2934 |
|
2935 | var h = this.$createElement;
|
2936 |
|
2937 | var store = this.store;
|
2938 | var isRowExpanded = store.isRowExpanded,
|
2939 | assertRowKey = store.assertRowKey;
|
2940 | var _store$states = store.states,
|
2941 | treeData = _store$states.treeData,
|
2942 | lazyTreeNodeMap = _store$states.lazyTreeNodeMap,
|
2943 | childrenColumnName = _store$states.childrenColumnName,
|
2944 | rowKey = _store$states.rowKey;
|
2945 |
|
2946 | if (this.hasExpandColumn && isRowExpanded(row)) {
|
2947 | var renderExpanded = this.table.renderExpanded;
|
2948 | var tr = this.rowRender(row, $index);
|
2949 | if (!renderExpanded) {
|
2950 | console.error('[Element Error]renderExpanded is required.');
|
2951 | return tr;
|
2952 | }
|
2953 |
|
2954 | return [[tr, h(
|
2955 | 'tr',
|
2956 | { key: 'expanded-row__' + tr.key },
|
2957 | [h(
|
2958 | 'td',
|
2959 | {
|
2960 | attrs: { colspan: this.columnsCount },
|
2961 | 'class': 'el-table__expanded-cell' },
|
2962 | [renderExpanded(this.$createElement, { row: row, $index: $index, store: this.store })]
|
2963 | )]
|
2964 | )]];
|
2965 | } else if (Object.keys(treeData).length) {
|
2966 | assertRowKey();
|
2967 |
|
2968 |
|
2969 | var key = Object(util["g" ])(row, rowKey);
|
2970 | var cur = treeData[key];
|
2971 | var treeRowData = null;
|
2972 | if (cur) {
|
2973 | treeRowData = {
|
2974 | expanded: cur.expanded,
|
2975 | level: cur.level,
|
2976 | display: true
|
2977 | };
|
2978 | if (typeof cur.lazy === 'boolean') {
|
2979 | if (typeof cur.loaded === 'boolean' && cur.loaded) {
|
2980 | treeRowData.noLazyChildren = !(cur.children && cur.children.length);
|
2981 | }
|
2982 | treeRowData.loading = cur.loading;
|
2983 | }
|
2984 | }
|
2985 | var tmp = [this.rowRender(row, $index, treeRowData)];
|
2986 |
|
2987 | if (cur) {
|
2988 |
|
2989 | var i = 0;
|
2990 | var traverse = function traverse(children, parent) {
|
2991 | if (!(children && children.length && parent)) return;
|
2992 | children.forEach(function (node) {
|
2993 |
|
2994 | var innerTreeRowData = {
|
2995 | display: parent.display && parent.expanded,
|
2996 | level: parent.level + 1
|
2997 | };
|
2998 | var childKey = Object(util["g" ])(node, rowKey);
|
2999 | if (childKey === undefined || childKey === null) {
|
3000 | throw new Error('for nested data item, row-key is required.');
|
3001 | }
|
3002 | cur = table_body_extends({}, treeData[childKey]);
|
3003 |
|
3004 |
|
3005 |
|
3006 | if (cur) {
|
3007 | innerTreeRowData.expanded = cur.expanded;
|
3008 |
|
3009 | cur.level = cur.level || innerTreeRowData.level;
|
3010 | cur.display = !!(cur.expanded && innerTreeRowData.display);
|
3011 | if (typeof cur.lazy === 'boolean') {
|
3012 | if (typeof cur.loaded === 'boolean' && cur.loaded) {
|
3013 | innerTreeRowData.noLazyChildren = !(cur.children && cur.children.length);
|
3014 | }
|
3015 | innerTreeRowData.loading = cur.loading;
|
3016 | }
|
3017 | }
|
3018 | i++;
|
3019 | tmp.push(_this4.rowRender(node, $index + i, innerTreeRowData));
|
3020 | if (cur) {
|
3021 | var _nodes = lazyTreeNodeMap[childKey] || node[childrenColumnName];
|
3022 | traverse(_nodes, cur);
|
3023 | }
|
3024 | });
|
3025 | };
|
3026 |
|
3027 | cur.display = true;
|
3028 | var nodes = lazyTreeNodeMap[key] || row[childrenColumnName];
|
3029 | traverse(nodes, cur);
|
3030 | }
|
3031 | return tmp;
|
3032 | } else {
|
3033 | return this.rowRender(row, $index);
|
3034 | }
|
3035 | }
|
3036 | }
|
3037 | });
|
3038 |
|
3039 | var filter_panelvue_type_template_id_7f2c919f_render = function() {
|
3040 | var _vm = this
|
3041 | var _h = _vm.$createElement
|
3042 | var _c = _vm._self._c || _h
|
3043 | return _c("transition", { attrs: { name: "el-zoom-in-top" } }, [
|
3044 | _vm.multiple
|
3045 | ? _c(
|
3046 | "div",
|
3047 | {
|
3048 | directives: [
|
3049 | {
|
3050 | name: "clickoutside",
|
3051 | rawName: "v-clickoutside",
|
3052 | value: _vm.handleOutsideClick,
|
3053 | expression: "handleOutsideClick"
|
3054 | },
|
3055 | {
|
3056 | name: "show",
|
3057 | rawName: "v-show",
|
3058 | value: _vm.showPopper,
|
3059 | expression: "showPopper"
|
3060 | }
|
3061 | ],
|
3062 | staticClass: "el-table-filter"
|
3063 | },
|
3064 | [
|
3065 | _c(
|
3066 | "div",
|
3067 | { staticClass: "el-table-filter__content" },
|
3068 | [
|
3069 | _c(
|
3070 | "el-scrollbar",
|
3071 | { attrs: { "wrap-class": "el-table-filter__wrap" } },
|
3072 | [
|
3073 | _c(
|
3074 | "el-checkbox-group",
|
3075 | {
|
3076 | staticClass: "el-table-filter__checkbox-group",
|
3077 | model: {
|
3078 | value: _vm.filteredValue,
|
3079 | callback: function($$v) {
|
3080 | _vm.filteredValue = $$v
|
3081 | },
|
3082 | expression: "filteredValue"
|
3083 | }
|
3084 | },
|
3085 | _vm._l(_vm.filters, function(filter) {
|
3086 | return _c(
|
3087 | "el-checkbox",
|
3088 | { key: filter.value, attrs: { label: filter.value } },
|
3089 | [_vm._v(_vm._s(filter.text))]
|
3090 | )
|
3091 | }),
|
3092 | 1
|
3093 | )
|
3094 | ],
|
3095 | 1
|
3096 | )
|
3097 | ],
|
3098 | 1
|
3099 | ),
|
3100 | _c("div", { staticClass: "el-table-filter__bottom" }, [
|
3101 | _c(
|
3102 | "button",
|
3103 | {
|
3104 | class: { "is-disabled": _vm.filteredValue.length === 0 },
|
3105 | attrs: { disabled: _vm.filteredValue.length === 0 },
|
3106 | on: { click: _vm.handleConfirm }
|
3107 | },
|
3108 | [_vm._v(_vm._s(_vm.t("el.table.confirmFilter")))]
|
3109 | ),
|
3110 | _c("button", { on: { click: _vm.handleReset } }, [
|
3111 | _vm._v(_vm._s(_vm.t("el.table.resetFilter")))
|
3112 | ])
|
3113 | ])
|
3114 | ]
|
3115 | )
|
3116 | : _c(
|
3117 | "div",
|
3118 | {
|
3119 | directives: [
|
3120 | {
|
3121 | name: "clickoutside",
|
3122 | rawName: "v-clickoutside",
|
3123 | value: _vm.handleOutsideClick,
|
3124 | expression: "handleOutsideClick"
|
3125 | },
|
3126 | {
|
3127 | name: "show",
|
3128 | rawName: "v-show",
|
3129 | value: _vm.showPopper,
|
3130 | expression: "showPopper"
|
3131 | }
|
3132 | ],
|
3133 | staticClass: "el-table-filter"
|
3134 | },
|
3135 | [
|
3136 | _c(
|
3137 | "ul",
|
3138 | { staticClass: "el-table-filter__list" },
|
3139 | [
|
3140 | _c(
|
3141 | "li",
|
3142 | {
|
3143 | staticClass: "el-table-filter__list-item",
|
3144 | class: {
|
3145 | "is-active":
|
3146 | _vm.filterValue === undefined ||
|
3147 | _vm.filterValue === null
|
3148 | },
|
3149 | on: {
|
3150 | click: function($event) {
|
3151 | _vm.handleSelect(null)
|
3152 | }
|
3153 | }
|
3154 | },
|
3155 | [_vm._v(_vm._s(_vm.t("el.table.clearFilter")))]
|
3156 | ),
|
3157 | _vm._l(_vm.filters, function(filter) {
|
3158 | return _c(
|
3159 | "li",
|
3160 | {
|
3161 | key: filter.value,
|
3162 | staticClass: "el-table-filter__list-item",
|
3163 | class: { "is-active": _vm.isActive(filter) },
|
3164 | attrs: { label: filter.value },
|
3165 | on: {
|
3166 | click: function($event) {
|
3167 | _vm.handleSelect(filter.value)
|
3168 | }
|
3169 | }
|
3170 | },
|
3171 | [_vm._v(_vm._s(filter.text))]
|
3172 | )
|
3173 | })
|
3174 | ],
|
3175 | 2
|
3176 | )
|
3177 | ]
|
3178 | )
|
3179 | ])
|
3180 | }
|
3181 | var filter_panelvue_type_template_id_7f2c919f_staticRenderFns = []
|
3182 | filter_panelvue_type_template_id_7f2c919f_render._withStripped = true
|
3183 |
|
3184 |
|
3185 |
|
3186 |
|
3187 |
|
3188 | var vue_popper_ = __webpack_require__(5);
|
3189 | var vue_popper_default = __webpack_require__.n(vue_popper_);
|
3190 |
|
3191 |
|
3192 | var popup_ = __webpack_require__(15);
|
3193 |
|
3194 |
|
3195 | var clickoutside_ = __webpack_require__(12);
|
3196 | var clickoutside_default = __webpack_require__.n(clickoutside_);
|
3197 |
|
3198 |
|
3199 |
|
3200 | var dropdowns = [];
|
3201 |
|
3202 | !external_vue_default.a.prototype.$isServer && document.addEventListener('click', function (event) {
|
3203 | dropdowns.forEach(function (dropdown) {
|
3204 | var target = event.target;
|
3205 | if (!dropdown || !dropdown.$el) return;
|
3206 | if (target === dropdown.$el || dropdown.$el.contains(target)) {
|
3207 | return;
|
3208 | }
|
3209 | dropdown.handleOutsideClick && dropdown.handleOutsideClick(event);
|
3210 | });
|
3211 | });
|
3212 |
|
3213 | var dropdown = ({
|
3214 | open: function open(instance) {
|
3215 | if (instance) {
|
3216 | dropdowns.push(instance);
|
3217 | }
|
3218 | },
|
3219 | close: function close(instance) {
|
3220 | var index = dropdowns.indexOf(instance);
|
3221 | if (index !== -1) {
|
3222 | dropdowns.splice(instance, 1);
|
3223 | }
|
3224 | }
|
3225 | });
|
3226 |
|
3227 | var checkbox_group_ = __webpack_require__(39);
|
3228 | var checkbox_group_default = __webpack_require__.n(checkbox_group_);
|
3229 |
|
3230 |
|
3231 | var scrollbar_ = __webpack_require__(14);
|
3232 | var scrollbar_default = __webpack_require__.n(scrollbar_);
|
3233 |
|
3234 |
|
3235 |
|
3236 |
|
3237 |
|
3238 |
|
3239 |
|
3240 |
|
3241 |
|
3242 |
|
3243 |
|
3244 |
|
3245 |
|
3246 |
|
3247 |
|
3248 |
|
3249 |
|
3250 |
|
3251 |
|
3252 |
|
3253 |
|
3254 |
|
3255 |
|
3256 |
|
3257 |
|
3258 |
|
3259 |
|
3260 |
|
3261 |
|
3262 |
|
3263 |
|
3264 |
|
3265 |
|
3266 |
|
3267 |
|
3268 |
|
3269 |
|
3270 |
|
3271 |
|
3272 |
|
3273 |
|
3274 |
|
3275 |
|
3276 |
|
3277 |
|
3278 |
|
3279 |
|
3280 |
|
3281 |
|
3282 |
|
3283 |
|
3284 |
|
3285 |
|
3286 |
|
3287 |
|
3288 |
|
3289 | var filter_panelvue_type_script_lang_js_ = ({
|
3290 | name: 'ElTableFilterPanel',
|
3291 |
|
3292 | mixins: [vue_popper_default.a, locale_default.a],
|
3293 |
|
3294 | directives: {
|
3295 | Clickoutside: clickoutside_default.a
|
3296 | },
|
3297 |
|
3298 | components: {
|
3299 | ElCheckbox: checkbox_default.a,
|
3300 | ElCheckboxGroup: checkbox_group_default.a,
|
3301 | ElScrollbar: scrollbar_default.a
|
3302 | },
|
3303 |
|
3304 | props: {
|
3305 | placement: {
|
3306 | type: String,
|
3307 | default: 'bottom-end'
|
3308 | }
|
3309 | },
|
3310 |
|
3311 | methods: {
|
3312 | isActive: function isActive(filter) {
|
3313 | return filter.value === this.filterValue;
|
3314 | },
|
3315 | handleOutsideClick: function handleOutsideClick() {
|
3316 | var _this = this;
|
3317 |
|
3318 | setTimeout(function () {
|
3319 | _this.showPopper = false;
|
3320 | }, 16);
|
3321 | },
|
3322 | handleConfirm: function handleConfirm() {
|
3323 | this.confirmFilter(this.filteredValue);
|
3324 | this.handleOutsideClick();
|
3325 | },
|
3326 | handleReset: function handleReset() {
|
3327 | this.filteredValue = [];
|
3328 | this.confirmFilter(this.filteredValue);
|
3329 | this.handleOutsideClick();
|
3330 | },
|
3331 | handleSelect: function handleSelect(filterValue) {
|
3332 | this.filterValue = filterValue;
|
3333 |
|
3334 | if (typeof filterValue !== 'undefined' && filterValue !== null) {
|
3335 | this.confirmFilter(this.filteredValue);
|
3336 | } else {
|
3337 | this.confirmFilter([]);
|
3338 | }
|
3339 |
|
3340 | this.handleOutsideClick();
|
3341 | },
|
3342 | confirmFilter: function confirmFilter(filteredValue) {
|
3343 | this.table.store.commit('filterChange', {
|
3344 | column: this.column,
|
3345 | values: filteredValue
|
3346 | });
|
3347 | this.table.store.updateAllSelected();
|
3348 | }
|
3349 | },
|
3350 |
|
3351 | data: function data() {
|
3352 | return {
|
3353 | table: null,
|
3354 | cell: null,
|
3355 | column: null
|
3356 | };
|
3357 | },
|
3358 |
|
3359 |
|
3360 | computed: {
|
3361 | filters: function filters() {
|
3362 | return this.column && this.column.filters;
|
3363 | },
|
3364 |
|
3365 |
|
3366 | filterValue: {
|
3367 | get: function get() {
|
3368 | return (this.column.filteredValue || [])[0];
|
3369 | },
|
3370 | set: function set(value) {
|
3371 | if (this.filteredValue) {
|
3372 | if (typeof value !== 'undefined' && value !== null) {
|
3373 | this.filteredValue.splice(0, 1, value);
|
3374 | } else {
|
3375 | this.filteredValue.splice(0, 1);
|
3376 | }
|
3377 | }
|
3378 | }
|
3379 | },
|
3380 |
|
3381 | filteredValue: {
|
3382 | get: function get() {
|
3383 | if (this.column) {
|
3384 | return this.column.filteredValue || [];
|
3385 | }
|
3386 | return [];
|
3387 | },
|
3388 | set: function set(value) {
|
3389 | if (this.column) {
|
3390 | this.column.filteredValue = value;
|
3391 | }
|
3392 | }
|
3393 | },
|
3394 |
|
3395 | multiple: function multiple() {
|
3396 | if (this.column) {
|
3397 | return this.column.filterMultiple;
|
3398 | }
|
3399 | return true;
|
3400 | }
|
3401 | },
|
3402 |
|
3403 | mounted: function mounted() {
|
3404 | var _this2 = this;
|
3405 |
|
3406 | this.popperElm = this.$el;
|
3407 | this.referenceElm = this.cell;
|
3408 | this.table.bodyWrapper.addEventListener('scroll', function () {
|
3409 | _this2.updatePopper();
|
3410 | });
|
3411 |
|
3412 | this.$watch('showPopper', function (value) {
|
3413 | if (_this2.column) _this2.column.filterOpened = value;
|
3414 | if (value) {
|
3415 | dropdown.open(_this2);
|
3416 | } else {
|
3417 | dropdown.close(_this2);
|
3418 | }
|
3419 | });
|
3420 | },
|
3421 |
|
3422 | watch: {
|
3423 | showPopper: function showPopper(val) {
|
3424 | if (val === true && parseInt(this.popperJS._popper.style.zIndex, 10) < popup_["PopupManager"].zIndex) {
|
3425 | this.popperJS._popper.style.zIndex = popup_["PopupManager"].nextZIndex();
|
3426 | }
|
3427 | }
|
3428 | }
|
3429 | });
|
3430 |
|
3431 | var src_filter_panelvue_type_script_lang_js_ = (filter_panelvue_type_script_lang_js_);
|
3432 |
|
3433 | var componentNormalizer = __webpack_require__(0);
|
3434 |
|
3435 |
|
3436 |
|
3437 |
|
3438 |
|
3439 |
|
3440 |
|
3441 |
|
3442 |
|
3443 | var component = Object(componentNormalizer["a" ])(
|
3444 | src_filter_panelvue_type_script_lang_js_,
|
3445 | filter_panelvue_type_template_id_7f2c919f_render,
|
3446 | filter_panelvue_type_template_id_7f2c919f_staticRenderFns,
|
3447 | false,
|
3448 | null,
|
3449 | null,
|
3450 | null
|
3451 |
|
3452 | )
|
3453 |
|
3454 |
|
3455 | if (false) { var api; }
|
3456 | component.options.__file = "packages/table/src/filter-panel.vue"
|
3457 | var filter_panel = (component.exports);
|
3458 |
|
3459 | var table_header_extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
3460 |
|
3461 |
|
3462 |
|
3463 |
|
3464 |
|
3465 |
|
3466 |
|
3467 |
|
3468 | var getAllColumns = function getAllColumns(columns) {
|
3469 | var result = [];
|
3470 | columns.forEach(function (column) {
|
3471 | if (column.children) {
|
3472 | result.push(column);
|
3473 | result.push.apply(result, getAllColumns(column.children));
|
3474 | } else {
|
3475 | result.push(column);
|
3476 | }
|
3477 | });
|
3478 | return result;
|
3479 | };
|
3480 |
|
3481 | var convertToRows = function convertToRows(originColumns) {
|
3482 | var maxLevel = 1;
|
3483 | var traverse = function traverse(column, parent) {
|
3484 | if (parent) {
|
3485 | column.level = parent.level + 1;
|
3486 | if (maxLevel < column.level) {
|
3487 | maxLevel = column.level;
|
3488 | }
|
3489 | }
|
3490 | if (column.children) {
|
3491 | var colSpan = 0;
|
3492 | column.children.forEach(function (subColumn) {
|
3493 | traverse(subColumn, column);
|
3494 | colSpan += subColumn.colSpan;
|
3495 | });
|
3496 | column.colSpan = colSpan;
|
3497 | } else {
|
3498 | column.colSpan = 1;
|
3499 | }
|
3500 | };
|
3501 |
|
3502 | originColumns.forEach(function (column) {
|
3503 | column.level = 1;
|
3504 | traverse(column);
|
3505 | });
|
3506 |
|
3507 | var rows = [];
|
3508 | for (var i = 0; i < maxLevel; i++) {
|
3509 | rows.push([]);
|
3510 | }
|
3511 |
|
3512 | var allColumns = getAllColumns(originColumns);
|
3513 |
|
3514 | allColumns.forEach(function (column) {
|
3515 | if (!column.children) {
|
3516 | column.rowSpan = maxLevel - column.level + 1;
|
3517 | } else {
|
3518 | column.rowSpan = 1;
|
3519 | }
|
3520 | rows[column.level - 1].push(column);
|
3521 | });
|
3522 |
|
3523 | return rows;
|
3524 | };
|
3525 |
|
3526 | var table_header = ({
|
3527 | name: 'ElTableHeader',
|
3528 |
|
3529 | mixins: [layout_observer],
|
3530 |
|
3531 | render: function render(h) {
|
3532 | var _this = this;
|
3533 |
|
3534 | var originColumns = this.store.states.originColumns;
|
3535 | var columnRows = convertToRows(originColumns, this.columns);
|
3536 |
|
3537 | var isGroup = columnRows.length > 1;
|
3538 | if (isGroup) this.$parent.isGroup = true;
|
3539 | return h(
|
3540 | 'table',
|
3541 | {
|
3542 | 'class': 'el-table__header',
|
3543 | attrs: { cellspacing: '0',
|
3544 | cellpadding: '0',
|
3545 | border: '0' }
|
3546 | },
|
3547 | [h('colgroup', [this.columns.map(function (column) {
|
3548 | return h('col', {
|
3549 | attrs: { name: column.id },
|
3550 | key: column.id });
|
3551 | }), this.hasGutter ? h('col', {
|
3552 | attrs: { name: 'gutter' }
|
3553 | }) : '']), h(
|
3554 | 'thead',
|
3555 | { 'class': [{ 'is-group': isGroup, 'has-gutter': this.hasGutter }] },
|
3556 | [this._l(columnRows, function (columns, rowIndex) {
|
3557 | return h(
|
3558 | 'tr',
|
3559 | {
|
3560 | style: _this.getHeaderRowStyle(rowIndex),
|
3561 | 'class': _this.getHeaderRowClass(rowIndex)
|
3562 | },
|
3563 | [columns.map(function (column, cellIndex) {
|
3564 | return h(
|
3565 | 'th',
|
3566 | {
|
3567 | attrs: {
|
3568 | colspan: column.colSpan,
|
3569 | rowspan: column.rowSpan
|
3570 | },
|
3571 | on: {
|
3572 | 'mousemove': function mousemove($event) {
|
3573 | return _this.handleMouseMove($event, column);
|
3574 | },
|
3575 | 'mouseout': _this.handleMouseOut,
|
3576 | 'mousedown': function mousedown($event) {
|
3577 | return _this.handleMouseDown($event, column);
|
3578 | },
|
3579 | 'click': function click($event) {
|
3580 | return _this.handleHeaderClick($event, column);
|
3581 | },
|
3582 | 'contextmenu': function contextmenu($event) {
|
3583 | return _this.handleHeaderContextMenu($event, column);
|
3584 | }
|
3585 | },
|
3586 |
|
3587 | style: _this.getHeaderCellStyle(rowIndex, cellIndex, columns, column),
|
3588 | 'class': _this.getHeaderCellClass(rowIndex, cellIndex, columns, column),
|
3589 | key: column.id },
|
3590 | [h(
|
3591 | 'div',
|
3592 | { 'class': ['cell', column.filteredValue && column.filteredValue.length > 0 ? 'highlight' : '', column.labelClassName] },
|
3593 | [column.renderHeader ? column.renderHeader.call(_this._renderProxy, h, { column: column, $index: cellIndex, store: _this.store, _self: _this.$parent.$vnode.context }) : column.label, column.sortable ? h(
|
3594 | 'span',
|
3595 | {
|
3596 | 'class': 'caret-wrapper',
|
3597 | on: {
|
3598 | 'click': function click($event) {
|
3599 | return _this.handleSortClick($event, column);
|
3600 | }
|
3601 | }
|
3602 | },
|
3603 | [h('i', { 'class': 'sort-caret ascending',
|
3604 | on: {
|
3605 | 'click': function click($event) {
|
3606 | return _this.handleSortClick($event, column, 'ascending');
|
3607 | }
|
3608 | }
|
3609 | }), h('i', { 'class': 'sort-caret descending',
|
3610 | on: {
|
3611 | 'click': function click($event) {
|
3612 | return _this.handleSortClick($event, column, 'descending');
|
3613 | }
|
3614 | }
|
3615 | })]
|
3616 | ) : '', column.filterable ? h(
|
3617 | 'span',
|
3618 | {
|
3619 | 'class': 'el-table__column-filter-trigger',
|
3620 | on: {
|
3621 | 'click': function click($event) {
|
3622 | return _this.handleFilterClick($event, column);
|
3623 | }
|
3624 | }
|
3625 | },
|
3626 | [h('i', { 'class': ['el-icon-arrow-down', column.filterOpened ? 'el-icon-arrow-up' : ''] })]
|
3627 | ) : '']
|
3628 | )]
|
3629 | );
|
3630 | }), _this.hasGutter ? h('th', { 'class': 'gutter' }) : '']
|
3631 | );
|
3632 | })]
|
3633 | )]
|
3634 | );
|
3635 | },
|
3636 |
|
3637 |
|
3638 | props: {
|
3639 | fixed: String,
|
3640 | store: {
|
3641 | required: true
|
3642 | },
|
3643 | border: Boolean,
|
3644 | defaultSort: {
|
3645 | type: Object,
|
3646 | default: function _default() {
|
3647 | return {
|
3648 | prop: '',
|
3649 | order: ''
|
3650 | };
|
3651 | }
|
3652 | }
|
3653 | },
|
3654 |
|
3655 | components: {
|
3656 | ElCheckbox: checkbox_default.a
|
3657 | },
|
3658 |
|
3659 | computed: table_header_extends({
|
3660 | table: function table() {
|
3661 | return this.$parent;
|
3662 | },
|
3663 | hasGutter: function hasGutter() {
|
3664 | return !this.fixed && this.tableLayout.gutterWidth;
|
3665 | }
|
3666 | }, mapStates({
|
3667 | columns: 'columns',
|
3668 | isAllSelected: 'isAllSelected',
|
3669 | leftFixedLeafCount: 'fixedLeafColumnsLength',
|
3670 | rightFixedLeafCount: 'rightFixedLeafColumnsLength',
|
3671 | columnsCount: function columnsCount(states) {
|
3672 | return states.columns.length;
|
3673 | },
|
3674 | leftFixedCount: function leftFixedCount(states) {
|
3675 | return states.fixedColumns.length;
|
3676 | },
|
3677 | rightFixedCount: function rightFixedCount(states) {
|
3678 | return states.rightFixedColumns.length;
|
3679 | }
|
3680 | })),
|
3681 |
|
3682 | created: function created() {
|
3683 | this.filterPanels = {};
|
3684 | },
|
3685 | mounted: function mounted() {
|
3686 | var _this2 = this;
|
3687 |
|
3688 |
|
3689 | this.$nextTick(function () {
|
3690 | var _defaultSort = _this2.defaultSort,
|
3691 | prop = _defaultSort.prop,
|
3692 | order = _defaultSort.order;
|
3693 |
|
3694 | var init = true;
|
3695 | _this2.store.commit('sort', { prop: prop, order: order, init: init });
|
3696 | });
|
3697 | },
|
3698 | beforeDestroy: function beforeDestroy() {
|
3699 | var panels = this.filterPanels;
|
3700 | for (var prop in panels) {
|
3701 | if (panels.hasOwnProperty(prop) && panels[prop]) {
|
3702 | panels[prop].$destroy(true);
|
3703 | }
|
3704 | }
|
3705 | },
|
3706 |
|
3707 |
|
3708 | methods: {
|
3709 | isCellHidden: function isCellHidden(index, columns) {
|
3710 | var start = 0;
|
3711 | for (var i = 0; i < index; i++) {
|
3712 | start += columns[i].colSpan;
|
3713 | }
|
3714 | var after = start + columns[index].colSpan - 1;
|
3715 | if (this.fixed === true || this.fixed === 'left') {
|
3716 | return after >= this.leftFixedLeafCount;
|
3717 | } else if (this.fixed === 'right') {
|
3718 | return start < this.columnsCount - this.rightFixedLeafCount;
|
3719 | } else {
|
3720 | return after < this.leftFixedLeafCount || start >= this.columnsCount - this.rightFixedLeafCount;
|
3721 | }
|
3722 | },
|
3723 | getHeaderRowStyle: function getHeaderRowStyle(rowIndex) {
|
3724 | var headerRowStyle = this.table.headerRowStyle;
|
3725 | if (typeof headerRowStyle === 'function') {
|
3726 | return headerRowStyle.call(null, { rowIndex: rowIndex });
|
3727 | }
|
3728 | return headerRowStyle;
|
3729 | },
|
3730 | getHeaderRowClass: function getHeaderRowClass(rowIndex) {
|
3731 | var classes = [];
|
3732 |
|
3733 | var headerRowClassName = this.table.headerRowClassName;
|
3734 | if (typeof headerRowClassName === 'string') {
|
3735 | classes.push(headerRowClassName);
|
3736 | } else if (typeof headerRowClassName === 'function') {
|
3737 | classes.push(headerRowClassName.call(null, { rowIndex: rowIndex }));
|
3738 | }
|
3739 |
|
3740 | return classes.join(' ');
|
3741 | },
|
3742 | getHeaderCellStyle: function getHeaderCellStyle(rowIndex, columnIndex, row, column) {
|
3743 | var headerCellStyle = this.table.headerCellStyle;
|
3744 | if (typeof headerCellStyle === 'function') {
|
3745 | return headerCellStyle.call(null, {
|
3746 | rowIndex: rowIndex,
|
3747 | columnIndex: columnIndex,
|
3748 | row: row,
|
3749 | column: column
|
3750 | });
|
3751 | }
|
3752 | return headerCellStyle;
|
3753 | },
|
3754 | getHeaderCellClass: function getHeaderCellClass(rowIndex, columnIndex, row, column) {
|
3755 | var classes = [column.id, column.order, column.headerAlign, column.className, column.labelClassName];
|
3756 |
|
3757 | if (rowIndex === 0 && this.isCellHidden(columnIndex, row)) {
|
3758 | classes.push('is-hidden');
|
3759 | }
|
3760 |
|
3761 | if (!column.children) {
|
3762 | classes.push('is-leaf');
|
3763 | }
|
3764 |
|
3765 | if (column.sortable) {
|
3766 | classes.push('is-sortable');
|
3767 | }
|
3768 |
|
3769 | var headerCellClassName = this.table.headerCellClassName;
|
3770 | if (typeof headerCellClassName === 'string') {
|
3771 | classes.push(headerCellClassName);
|
3772 | } else if (typeof headerCellClassName === 'function') {
|
3773 | classes.push(headerCellClassName.call(null, {
|
3774 | rowIndex: rowIndex,
|
3775 | columnIndex: columnIndex,
|
3776 | row: row,
|
3777 | column: column
|
3778 | }));
|
3779 | }
|
3780 |
|
3781 | return classes.join(' ');
|
3782 | },
|
3783 | toggleAllSelection: function toggleAllSelection(event) {
|
3784 | event.stopPropagation();
|
3785 | this.store.commit('toggleAllSelection');
|
3786 | },
|
3787 | handleFilterClick: function handleFilterClick(event, column) {
|
3788 | event.stopPropagation();
|
3789 | var target = event.target;
|
3790 | var cell = target.tagName === 'TH' ? target : target.parentNode;
|
3791 | if (Object(dom_["hasClass"])(cell, 'noclick')) return;
|
3792 | cell = cell.querySelector('.el-table__column-filter-trigger') || cell;
|
3793 | var table = this.$parent;
|
3794 |
|
3795 | var filterPanel = this.filterPanels[column.id];
|
3796 |
|
3797 | if (filterPanel && column.filterOpened) {
|
3798 | filterPanel.showPopper = false;
|
3799 | return;
|
3800 | }
|
3801 |
|
3802 | if (!filterPanel) {
|
3803 | filterPanel = new external_vue_default.a(filter_panel);
|
3804 | this.filterPanels[column.id] = filterPanel;
|
3805 | if (column.filterPlacement) {
|
3806 | filterPanel.placement = column.filterPlacement;
|
3807 | }
|
3808 | filterPanel.table = table;
|
3809 | filterPanel.cell = cell;
|
3810 | filterPanel.column = column;
|
3811 | !this.$isServer && filterPanel.$mount(document.createElement('div'));
|
3812 | }
|
3813 |
|
3814 | setTimeout(function () {
|
3815 | filterPanel.showPopper = true;
|
3816 | }, 16);
|
3817 | },
|
3818 | handleHeaderClick: function handleHeaderClick(event, column) {
|
3819 | if (!column.filters && column.sortable) {
|
3820 | this.handleSortClick(event, column);
|
3821 | } else if (column.filterable && !column.sortable) {
|
3822 | this.handleFilterClick(event, column);
|
3823 | }
|
3824 |
|
3825 | this.$parent.$emit('header-click', column, event);
|
3826 | },
|
3827 | handleHeaderContextMenu: function handleHeaderContextMenu(event, column) {
|
3828 | this.$parent.$emit('header-contextmenu', column, event);
|
3829 | },
|
3830 | handleMouseDown: function handleMouseDown(event, column) {
|
3831 | var _this3 = this;
|
3832 |
|
3833 | if (this.$isServer) return;
|
3834 | if (column.children && column.children.length > 0) return;
|
3835 |
|
3836 | if (this.draggingColumn && this.border) {
|
3837 | this.dragging = true;
|
3838 |
|
3839 | this.$parent.resizeProxyVisible = true;
|
3840 |
|
3841 | var table = this.$parent;
|
3842 | var tableEl = table.$el;
|
3843 | var tableLeft = tableEl.getBoundingClientRect().left;
|
3844 | var columnEl = this.$el.querySelector('th.' + column.id);
|
3845 | var columnRect = columnEl.getBoundingClientRect();
|
3846 | var minLeft = columnRect.left - tableLeft + 30;
|
3847 |
|
3848 | Object(dom_["addClass"])(columnEl, 'noclick');
|
3849 |
|
3850 | this.dragState = {
|
3851 | startMouseLeft: event.clientX,
|
3852 | startLeft: columnRect.right - tableLeft,
|
3853 | startColumnLeft: columnRect.left - tableLeft,
|
3854 | tableLeft: tableLeft
|
3855 | };
|
3856 |
|
3857 | var resizeProxy = table.$refs.resizeProxy;
|
3858 | resizeProxy.style.left = this.dragState.startLeft + 'px';
|
3859 |
|
3860 | document.onselectstart = function () {
|
3861 | return false;
|
3862 | };
|
3863 | document.ondragstart = function () {
|
3864 | return false;
|
3865 | };
|
3866 |
|
3867 | var handleMouseMove = function handleMouseMove(event) {
|
3868 | var deltaLeft = event.clientX - _this3.dragState.startMouseLeft;
|
3869 | var proxyLeft = _this3.dragState.startLeft + deltaLeft;
|
3870 |
|
3871 | resizeProxy.style.left = Math.max(minLeft, proxyLeft) + 'px';
|
3872 | };
|
3873 |
|
3874 | var handleMouseUp = function handleMouseUp() {
|
3875 | if (_this3.dragging) {
|
3876 | var _dragState = _this3.dragState,
|
3877 | startColumnLeft = _dragState.startColumnLeft,
|
3878 | startLeft = _dragState.startLeft;
|
3879 |
|
3880 | var finalLeft = parseInt(resizeProxy.style.left, 10);
|
3881 | var columnWidth = finalLeft - startColumnLeft;
|
3882 | column.width = column.realWidth = columnWidth;
|
3883 | table.$emit('header-dragend', column.width, startLeft - startColumnLeft, column, event);
|
3884 |
|
3885 | _this3.store.scheduleLayout();
|
3886 |
|
3887 | document.body.style.cursor = '';
|
3888 | _this3.dragging = false;
|
3889 | _this3.draggingColumn = null;
|
3890 | _this3.dragState = {};
|
3891 |
|
3892 | table.resizeProxyVisible = false;
|
3893 | }
|
3894 |
|
3895 | document.removeEventListener('mousemove', handleMouseMove);
|
3896 | document.removeEventListener('mouseup', handleMouseUp);
|
3897 | document.onselectstart = null;
|
3898 | document.ondragstart = null;
|
3899 |
|
3900 | setTimeout(function () {
|
3901 | Object(dom_["removeClass"])(columnEl, 'noclick');
|
3902 | }, 0);
|
3903 | };
|
3904 |
|
3905 | document.addEventListener('mousemove', handleMouseMove);
|
3906 | document.addEventListener('mouseup', handleMouseUp);
|
3907 | }
|
3908 | },
|
3909 | handleMouseMove: function handleMouseMove(event, column) {
|
3910 | if (column.children && column.children.length > 0) return;
|
3911 | var target = event.target;
|
3912 | while (target && target.tagName !== 'TH') {
|
3913 | target = target.parentNode;
|
3914 | }
|
3915 |
|
3916 | if (!column || !column.resizable) return;
|
3917 |
|
3918 | if (!this.dragging && this.border) {
|
3919 | var rect = target.getBoundingClientRect();
|
3920 |
|
3921 | var bodyStyle = document.body.style;
|
3922 | if (rect.width > 12 && rect.right - event.pageX < 8) {
|
3923 | bodyStyle.cursor = 'col-resize';
|
3924 | if (Object(dom_["hasClass"])(target, 'is-sortable')) {
|
3925 | target.style.cursor = 'col-resize';
|
3926 | }
|
3927 | this.draggingColumn = column;
|
3928 | } else if (!this.dragging) {
|
3929 | bodyStyle.cursor = '';
|
3930 | if (Object(dom_["hasClass"])(target, 'is-sortable')) {
|
3931 | target.style.cursor = 'pointer';
|
3932 | }
|
3933 | this.draggingColumn = null;
|
3934 | }
|
3935 | }
|
3936 | },
|
3937 | handleMouseOut: function handleMouseOut() {
|
3938 | if (this.$isServer) return;
|
3939 | document.body.style.cursor = '';
|
3940 | },
|
3941 | toggleOrder: function toggleOrder(_ref) {
|
3942 | var order = _ref.order,
|
3943 | sortOrders = _ref.sortOrders;
|
3944 |
|
3945 | if (order === '') return sortOrders[0];
|
3946 | var index = sortOrders.indexOf(order || null);
|
3947 | return sortOrders[index > sortOrders.length - 2 ? 0 : index + 1];
|
3948 | },
|
3949 | handleSortClick: function handleSortClick(event, column, givenOrder) {
|
3950 | event.stopPropagation();
|
3951 | var order = column.order === givenOrder ? null : givenOrder || this.toggleOrder(column);
|
3952 |
|
3953 | var target = event.target;
|
3954 | while (target && target.tagName !== 'TH') {
|
3955 | target = target.parentNode;
|
3956 | }
|
3957 |
|
3958 | if (target && target.tagName === 'TH') {
|
3959 | if (Object(dom_["hasClass"])(target, 'noclick')) {
|
3960 | Object(dom_["removeClass"])(target, 'noclick');
|
3961 | return;
|
3962 | }
|
3963 | }
|
3964 |
|
3965 | if (!column.sortable) return;
|
3966 |
|
3967 | var states = this.store.states;
|
3968 | var sortProp = states.sortProp;
|
3969 | var sortOrder = void 0;
|
3970 | var sortingColumn = states.sortingColumn;
|
3971 |
|
3972 | if (sortingColumn !== column || sortingColumn === column && sortingColumn.order === null) {
|
3973 | if (sortingColumn) {
|
3974 | sortingColumn.order = null;
|
3975 | }
|
3976 | states.sortingColumn = column;
|
3977 | sortProp = column.property;
|
3978 | }
|
3979 |
|
3980 | if (!order) {
|
3981 | sortOrder = column.order = null;
|
3982 | } else {
|
3983 | sortOrder = column.order = order;
|
3984 | }
|
3985 |
|
3986 | states.sortProp = sortProp;
|
3987 | states.sortOrder = sortOrder;
|
3988 |
|
3989 | this.store.commit('changeSortCondition');
|
3990 | }
|
3991 | },
|
3992 |
|
3993 | data: function data() {
|
3994 | return {
|
3995 | draggingColumn: null,
|
3996 | dragging: false,
|
3997 | dragState: {}
|
3998 | };
|
3999 | }
|
4000 | });
|
4001 |
|
4002 | var table_footer_extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
4003 |
|
4004 |
|
4005 |
|
4006 |
|
4007 | var table_footer = ({
|
4008 | name: 'ElTableFooter',
|
4009 |
|
4010 | mixins: [layout_observer],
|
4011 |
|
4012 | render: function render(h) {
|
4013 | var _this = this;
|
4014 |
|
4015 | var sums = [];
|
4016 | if (this.summaryMethod) {
|
4017 | sums = this.summaryMethod({ columns: this.columns, data: this.store.states.data });
|
4018 | } else {
|
4019 | this.columns.forEach(function (column, index) {
|
4020 | if (index === 0) {
|
4021 | sums[index] = _this.sumText;
|
4022 | return;
|
4023 | }
|
4024 | var values = _this.store.states.data.map(function (item) {
|
4025 | return Number(item[column.property]);
|
4026 | });
|
4027 | var precisions = [];
|
4028 | var notNumber = true;
|
4029 | values.forEach(function (value) {
|
4030 | if (!isNaN(value)) {
|
4031 | notNumber = false;
|
4032 | var decimal = ('' + value).split('.')[1];
|
4033 | precisions.push(decimal ? decimal.length : 0);
|
4034 | }
|
4035 | });
|
4036 | var precision = Math.max.apply(null, precisions);
|
4037 | if (!notNumber) {
|
4038 | sums[index] = values.reduce(function (prev, curr) {
|
4039 | var value = Number(curr);
|
4040 | if (!isNaN(value)) {
|
4041 | return parseFloat((prev + curr).toFixed(Math.min(precision, 20)));
|
4042 | } else {
|
4043 | return prev;
|
4044 | }
|
4045 | }, 0);
|
4046 | } else {
|
4047 | sums[index] = '';
|
4048 | }
|
4049 | });
|
4050 | }
|
4051 |
|
4052 | return h(
|
4053 | 'table',
|
4054 | {
|
4055 | 'class': 'el-table__footer',
|
4056 | attrs: { cellspacing: '0',
|
4057 | cellpadding: '0',
|
4058 | border: '0' }
|
4059 | },
|
4060 | [h('colgroup', [this.columns.map(function (column) {
|
4061 | return h('col', {
|
4062 | attrs: { name: column.id },
|
4063 | key: column.id });
|
4064 | }), this.hasGutter ? h('col', {
|
4065 | attrs: { name: 'gutter' }
|
4066 | }) : '']), h(
|
4067 | 'tbody',
|
4068 | { 'class': [{ 'has-gutter': this.hasGutter }] },
|
4069 | [h('tr', [this.columns.map(function (column, cellIndex) {
|
4070 | return h(
|
4071 | 'td',
|
4072 | {
|
4073 | key: cellIndex,
|
4074 | attrs: { colspan: column.colSpan,
|
4075 | rowspan: column.rowSpan
|
4076 | },
|
4077 | 'class': _this.getRowClasses(column, cellIndex) },
|
4078 | [h(
|
4079 | 'div',
|
4080 | { 'class': ['cell', column.labelClassName] },
|
4081 | [sums[cellIndex]]
|
4082 | )]
|
4083 | );
|
4084 | }), this.hasGutter ? h('th', { 'class': 'gutter' }) : ''])]
|
4085 | )]
|
4086 | );
|
4087 | },
|
4088 |
|
4089 |
|
4090 | props: {
|
4091 | fixed: String,
|
4092 | store: {
|
4093 | required: true
|
4094 | },
|
4095 | summaryMethod: Function,
|
4096 | sumText: String,
|
4097 | border: Boolean,
|
4098 | defaultSort: {
|
4099 | type: Object,
|
4100 | default: function _default() {
|
4101 | return {
|
4102 | prop: '',
|
4103 | order: ''
|
4104 | };
|
4105 | }
|
4106 | }
|
4107 | },
|
4108 |
|
4109 | computed: table_footer_extends({
|
4110 | table: function table() {
|
4111 | return this.$parent;
|
4112 | },
|
4113 | hasGutter: function hasGutter() {
|
4114 | return !this.fixed && this.tableLayout.gutterWidth;
|
4115 | }
|
4116 | }, mapStates({
|
4117 | columns: 'columns',
|
4118 | isAllSelected: 'isAllSelected',
|
4119 | leftFixedLeafCount: 'fixedLeafColumnsLength',
|
4120 | rightFixedLeafCount: 'rightFixedLeafColumnsLength',
|
4121 | columnsCount: function columnsCount(states) {
|
4122 | return states.columns.length;
|
4123 | },
|
4124 | leftFixedCount: function leftFixedCount(states) {
|
4125 | return states.fixedColumns.length;
|
4126 | },
|
4127 | rightFixedCount: function rightFixedCount(states) {
|
4128 | return states.rightFixedColumns.length;
|
4129 | }
|
4130 | })),
|
4131 |
|
4132 | methods: {
|
4133 | isCellHidden: function isCellHidden(index, columns, column) {
|
4134 | if (this.fixed === true || this.fixed === 'left') {
|
4135 | return index >= this.leftFixedLeafCount;
|
4136 | } else if (this.fixed === 'right') {
|
4137 | var before = 0;
|
4138 | for (var i = 0; i < index; i++) {
|
4139 | before += columns[i].colSpan;
|
4140 | }
|
4141 | return before < this.columnsCount - this.rightFixedLeafCount;
|
4142 | } else if (!this.fixed && column.fixed) {
|
4143 |
|
4144 | return true;
|
4145 | } else {
|
4146 | return index < this.leftFixedCount || index >= this.columnsCount - this.rightFixedCount;
|
4147 | }
|
4148 | },
|
4149 | getRowClasses: function getRowClasses(column, cellIndex) {
|
4150 | var classes = [column.id, column.align, column.labelClassName];
|
4151 | if (column.className) {
|
4152 | classes.push(column.className);
|
4153 | }
|
4154 | if (this.isCellHidden(cellIndex, this.columns, column)) {
|
4155 | classes.push('is-hidden');
|
4156 | }
|
4157 | if (!column.children) {
|
4158 | classes.push('is-leaf');
|
4159 | }
|
4160 | return classes;
|
4161 | }
|
4162 | }
|
4163 | });
|
4164 |
|
4165 | var tablevue_type_script_lang_js_extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
4166 |
|
4167 |
|
4168 |
|
4169 |
|
4170 |
|
4171 |
|
4172 |
|
4173 |
|
4174 |
|
4175 |
|
4176 |
|
4177 |
|
4178 |
|
4179 |
|
4180 |
|
4181 |
|
4182 |
|
4183 |
|
4184 |
|
4185 |
|
4186 |
|
4187 |
|
4188 |
|
4189 |
|
4190 |
|
4191 |
|
4192 |
|
4193 |
|
4194 |
|
4195 |
|
4196 |
|
4197 |
|
4198 |
|
4199 |
|
4200 |
|
4201 |
|
4202 |
|
4203 |
|
4204 |
|
4205 |
|
4206 |
|
4207 |
|
4208 |
|
4209 |
|
4210 |
|
4211 |
|
4212 |
|
4213 |
|
4214 |
|
4215 |
|
4216 |
|
4217 |
|
4218 |
|
4219 |
|
4220 |
|
4221 |
|
4222 |
|
4223 |
|
4224 |
|
4225 |
|
4226 |
|
4227 |
|
4228 |
|
4229 |
|
4230 |
|
4231 |
|
4232 |
|
4233 |
|
4234 |
|
4235 |
|
4236 |
|
4237 |
|
4238 |
|
4239 |
|
4240 |
|
4241 |
|
4242 |
|
4243 |
|
4244 |
|
4245 |
|
4246 |
|
4247 |
|
4248 |
|
4249 |
|
4250 |
|
4251 |
|
4252 |
|
4253 |
|
4254 |
|
4255 |
|
4256 |
|
4257 |
|
4258 |
|
4259 |
|
4260 |
|
4261 |
|
4262 |
|
4263 |
|
4264 |
|
4265 |
|
4266 |
|
4267 |
|
4268 |
|
4269 |
|
4270 |
|
4271 |
|
4272 |
|
4273 |
|
4274 |
|
4275 |
|
4276 |
|
4277 |
|
4278 |
|
4279 |
|
4280 |
|
4281 |
|
4282 |
|
4283 |
|
4284 |
|
4285 |
|
4286 |
|
4287 |
|
4288 |
|
4289 |
|
4290 |
|
4291 |
|
4292 |
|
4293 |
|
4294 |
|
4295 |
|
4296 |
|
4297 |
|
4298 |
|
4299 |
|
4300 |
|
4301 |
|
4302 |
|
4303 |
|
4304 |
|
4305 |
|
4306 |
|
4307 |
|
4308 |
|
4309 |
|
4310 |
|
4311 |
|
4312 |
|
4313 |
|
4314 |
|
4315 |
|
4316 |
|
4317 |
|
4318 |
|
4319 |
|
4320 |
|
4321 |
|
4322 |
|
4323 |
|
4324 |
|
4325 |
|
4326 |
|
4327 |
|
4328 |
|
4329 |
|
4330 |
|
4331 |
|
4332 |
|
4333 |
|
4334 |
|
4335 |
|
4336 |
|
4337 |
|
4338 |
|
4339 |
|
4340 |
|
4341 |
|
4342 |
|
4343 |
|
4344 |
|
4345 |
|
4346 |
|
4347 |
|
4348 |
|
4349 |
|
4350 |
|
4351 |
|
4352 |
|
4353 |
|
4354 |
|
4355 |
|
4356 |
|
4357 |
|
4358 |
|
4359 |
|
4360 |
|
4361 |
|
4362 |
|
4363 |
|
4364 |
|
4365 |
|
4366 |
|
4367 |
|
4368 |
|
4369 |
|
4370 |
|
4371 |
|
4372 |
|
4373 |
|
4374 |
|
4375 |
|
4376 |
|
4377 |
|
4378 |
|
4379 |
|
4380 |
|
4381 |
|
4382 |
|
4383 |
|
4384 |
|
4385 |
|
4386 |
|
4387 |
|
4388 |
|
4389 |
|
4390 |
|
4391 |
|
4392 |
|
4393 |
|
4394 |
|
4395 | var tableIdSeed = 1;
|
4396 |
|
4397 | var tablevue_type_script_lang_js_ = ({
|
4398 | name: 'ElTable',
|
4399 |
|
4400 | mixins: [locale_default.a, migrating_default.a],
|
4401 |
|
4402 | directives: {
|
4403 | Mousewheel: directives_mousewheel
|
4404 | },
|
4405 |
|
4406 | props: {
|
4407 | data: {
|
4408 | type: Array,
|
4409 | default: function _default() {
|
4410 | return [];
|
4411 | }
|
4412 | },
|
4413 |
|
4414 | size: String,
|
4415 |
|
4416 | width: [String, Number],
|
4417 |
|
4418 | height: [String, Number],
|
4419 |
|
4420 | maxHeight: [String, Number],
|
4421 |
|
4422 | fit: {
|
4423 | type: Boolean,
|
4424 | default: true
|
4425 | },
|
4426 |
|
4427 | stripe: Boolean,
|
4428 |
|
4429 | border: Boolean,
|
4430 |
|
4431 | rowKey: [String, Function],
|
4432 |
|
4433 | context: {},
|
4434 |
|
4435 | showHeader: {
|
4436 | type: Boolean,
|
4437 | default: true
|
4438 | },
|
4439 |
|
4440 | showSummary: Boolean,
|
4441 |
|
4442 | sumText: String,
|
4443 |
|
4444 | summaryMethod: Function,
|
4445 |
|
4446 | rowClassName: [String, Function],
|
4447 |
|
4448 | rowStyle: [Object, Function],
|
4449 |
|
4450 | cellClassName: [String, Function],
|
4451 |
|
4452 | cellStyle: [Object, Function],
|
4453 |
|
4454 | headerRowClassName: [String, Function],
|
4455 |
|
4456 | headerRowStyle: [Object, Function],
|
4457 |
|
4458 | headerCellClassName: [String, Function],
|
4459 |
|
4460 | headerCellStyle: [Object, Function],
|
4461 |
|
4462 | highlightCurrentRow: Boolean,
|
4463 |
|
4464 | currentRowKey: [String, Number],
|
4465 |
|
4466 | emptyText: String,
|
4467 |
|
4468 | expandRowKeys: Array,
|
4469 |
|
4470 | defaultExpandAll: Boolean,
|
4471 |
|
4472 | defaultSort: Object,
|
4473 |
|
4474 | tooltipEffect: String,
|
4475 |
|
4476 | spanMethod: Function,
|
4477 |
|
4478 | selectOnIndeterminate: {
|
4479 | type: Boolean,
|
4480 | default: true
|
4481 | },
|
4482 |
|
4483 | indent: {
|
4484 | type: Number,
|
4485 | default: 16
|
4486 | },
|
4487 |
|
4488 | treeProps: {
|
4489 | type: Object,
|
4490 | default: function _default() {
|
4491 | return {
|
4492 | hasChildren: 'hasChildren',
|
4493 | children: 'children'
|
4494 | };
|
4495 | }
|
4496 | },
|
4497 |
|
4498 | lazy: Boolean,
|
4499 |
|
4500 | load: Function
|
4501 | },
|
4502 |
|
4503 | components: {
|
4504 | TableHeader: table_header,
|
4505 | TableFooter: table_footer,
|
4506 | TableBody: table_body,
|
4507 | ElCheckbox: checkbox_default.a
|
4508 | },
|
4509 |
|
4510 | methods: {
|
4511 | getMigratingConfig: function getMigratingConfig() {
|
4512 | return {
|
4513 | events: {
|
4514 | expand: 'expand is renamed to expand-change'
|
4515 | }
|
4516 | };
|
4517 | },
|
4518 | setCurrentRow: function setCurrentRow(row) {
|
4519 | this.store.commit('setCurrentRow', row);
|
4520 | },
|
4521 | toggleRowSelection: function toggleRowSelection(row, selected) {
|
4522 | this.store.toggleRowSelection(row, selected, false);
|
4523 | this.store.updateAllSelected();
|
4524 | },
|
4525 | toggleRowExpansion: function toggleRowExpansion(row, expanded) {
|
4526 | this.store.toggleRowExpansionAdapter(row, expanded);
|
4527 | },
|
4528 | clearSelection: function clearSelection() {
|
4529 | this.store.clearSelection();
|
4530 | },
|
4531 | clearFilter: function clearFilter(columnKeys) {
|
4532 | this.store.clearFilter(columnKeys);
|
4533 | },
|
4534 | clearSort: function clearSort() {
|
4535 | this.store.clearSort();
|
4536 | },
|
4537 | handleMouseLeave: function handleMouseLeave() {
|
4538 | this.store.commit('setHoverRow', null);
|
4539 | if (this.hoverState) this.hoverState = null;
|
4540 | },
|
4541 | updateScrollY: function updateScrollY() {
|
4542 | var changed = this.layout.updateScrollY();
|
4543 | if (changed) {
|
4544 | this.layout.notifyObservers('scrollable');
|
4545 | this.layout.updateColumnsWidth();
|
4546 | }
|
4547 | },
|
4548 | handleFixedMousewheel: function handleFixedMousewheel(event, data) {
|
4549 | var bodyWrapper = this.bodyWrapper;
|
4550 | if (Math.abs(data.spinY) > 0) {
|
4551 | var currentScrollTop = bodyWrapper.scrollTop;
|
4552 | if (data.pixelY < 0 && currentScrollTop !== 0) {
|
4553 | event.preventDefault();
|
4554 | }
|
4555 | if (data.pixelY > 0 && bodyWrapper.scrollHeight - bodyWrapper.clientHeight > currentScrollTop) {
|
4556 | event.preventDefault();
|
4557 | }
|
4558 | bodyWrapper.scrollTop += Math.ceil(data.pixelY / 5);
|
4559 | } else {
|
4560 | bodyWrapper.scrollLeft += Math.ceil(data.pixelX / 5);
|
4561 | }
|
4562 | },
|
4563 | handleHeaderFooterMousewheel: function handleHeaderFooterMousewheel(event, data) {
|
4564 | var pixelX = data.pixelX,
|
4565 | pixelY = data.pixelY;
|
4566 |
|
4567 | if (Math.abs(pixelX) >= Math.abs(pixelY)) {
|
4568 | this.bodyWrapper.scrollLeft += data.pixelX / 5;
|
4569 | }
|
4570 | },
|
4571 |
|
4572 |
|
4573 |
|
4574 | syncPostion: Object(external_throttle_debounce_["throttle"])(20, function () {
|
4575 | var _bodyWrapper = this.bodyWrapper,
|
4576 | scrollLeft = _bodyWrapper.scrollLeft,
|
4577 | scrollTop = _bodyWrapper.scrollTop,
|
4578 | offsetWidth = _bodyWrapper.offsetWidth,
|
4579 | scrollWidth = _bodyWrapper.scrollWidth;
|
4580 | var _$refs = this.$refs,
|
4581 | headerWrapper = _$refs.headerWrapper,
|
4582 | footerWrapper = _$refs.footerWrapper,
|
4583 | fixedBodyWrapper = _$refs.fixedBodyWrapper,
|
4584 | rightFixedBodyWrapper = _$refs.rightFixedBodyWrapper;
|
4585 |
|
4586 | if (headerWrapper) headerWrapper.scrollLeft = scrollLeft;
|
4587 | if (footerWrapper) footerWrapper.scrollLeft = scrollLeft;
|
4588 | if (fixedBodyWrapper) fixedBodyWrapper.scrollTop = scrollTop;
|
4589 | if (rightFixedBodyWrapper) rightFixedBodyWrapper.scrollTop = scrollTop;
|
4590 | var maxScrollLeftPosition = scrollWidth - offsetWidth - 1;
|
4591 | if (scrollLeft >= maxScrollLeftPosition) {
|
4592 | this.scrollPosition = 'right';
|
4593 | } else if (scrollLeft === 0) {
|
4594 | this.scrollPosition = 'left';
|
4595 | } else {
|
4596 | this.scrollPosition = 'middle';
|
4597 | }
|
4598 | }),
|
4599 |
|
4600 | bindEvents: function bindEvents() {
|
4601 | this.bodyWrapper.addEventListener('scroll', this.syncPostion, { passive: true });
|
4602 | if (this.fit) {
|
4603 | Object(resize_event_["addResizeListener"])(this.$el, this.resizeListener);
|
4604 | }
|
4605 | },
|
4606 | unbindEvents: function unbindEvents() {
|
4607 | this.bodyWrapper.removeEventListener('scroll', this.syncPostion, { passive: true });
|
4608 | if (this.fit) {
|
4609 | Object(resize_event_["removeResizeListener"])(this.$el, this.resizeListener);
|
4610 | }
|
4611 | },
|
4612 | resizeListener: function resizeListener() {
|
4613 | if (!this.$ready) return;
|
4614 | var shouldUpdateLayout = false;
|
4615 | var el = this.$el;
|
4616 | var _resizeState = this.resizeState,
|
4617 | oldWidth = _resizeState.width,
|
4618 | oldHeight = _resizeState.height;
|
4619 |
|
4620 |
|
4621 | var width = el.offsetWidth;
|
4622 | if (oldWidth !== width) {
|
4623 | shouldUpdateLayout = true;
|
4624 | }
|
4625 |
|
4626 | var height = el.offsetHeight;
|
4627 | if ((this.height || this.shouldUpdateHeight) && oldHeight !== height) {
|
4628 | shouldUpdateLayout = true;
|
4629 | }
|
4630 |
|
4631 | if (shouldUpdateLayout) {
|
4632 | this.resizeState.width = width;
|
4633 | this.resizeState.height = height;
|
4634 | this.doLayout();
|
4635 | }
|
4636 | },
|
4637 | doLayout: function doLayout() {
|
4638 | if (this.shouldUpdateHeight) {
|
4639 | this.layout.updateElsHeight();
|
4640 | }
|
4641 | this.layout.updateColumnsWidth();
|
4642 | },
|
4643 | sort: function sort(prop, order) {
|
4644 | this.store.commit('sort', { prop: prop, order: order });
|
4645 | },
|
4646 | toggleAllSelection: function toggleAllSelection() {
|
4647 | this.store.commit('toggleAllSelection');
|
4648 | }
|
4649 | },
|
4650 |
|
4651 | computed: tablevue_type_script_lang_js_extends({
|
4652 | tableSize: function tableSize() {
|
4653 | return this.size || (this.$ELEMENT || {}).size;
|
4654 | },
|
4655 | bodyWrapper: function bodyWrapper() {
|
4656 | return this.$refs.bodyWrapper;
|
4657 | },
|
4658 | shouldUpdateHeight: function shouldUpdateHeight() {
|
4659 | return this.height || this.maxHeight || this.fixedColumns.length > 0 || this.rightFixedColumns.length > 0;
|
4660 | },
|
4661 | bodyWidth: function bodyWidth() {
|
4662 | var _layout = this.layout,
|
4663 | bodyWidth = _layout.bodyWidth,
|
4664 | scrollY = _layout.scrollY,
|
4665 | gutterWidth = _layout.gutterWidth;
|
4666 |
|
4667 | return bodyWidth ? bodyWidth - (scrollY ? gutterWidth : 0) + 'px' : '';
|
4668 | },
|
4669 | bodyHeight: function bodyHeight() {
|
4670 | var _layout2 = this.layout,
|
4671 | _layout2$headerHeight = _layout2.headerHeight,
|
4672 | headerHeight = _layout2$headerHeight === undefined ? 0 : _layout2$headerHeight,
|
4673 | bodyHeight = _layout2.bodyHeight,
|
4674 | _layout2$footerHeight = _layout2.footerHeight,
|
4675 | footerHeight = _layout2$footerHeight === undefined ? 0 : _layout2$footerHeight;
|
4676 |
|
4677 | if (this.height) {
|
4678 | return {
|
4679 | height: bodyHeight ? bodyHeight + 'px' : ''
|
4680 | };
|
4681 | } else if (this.maxHeight) {
|
4682 | var maxHeight = Object(util["j" ])(this.maxHeight);
|
4683 | if (typeof maxHeight === 'number') {
|
4684 | return {
|
4685 | 'max-height': maxHeight - footerHeight - (this.showHeader ? headerHeight : 0) + 'px'
|
4686 | };
|
4687 | }
|
4688 | }
|
4689 | return {};
|
4690 | },
|
4691 | fixedBodyHeight: function fixedBodyHeight() {
|
4692 | if (this.height) {
|
4693 | return {
|
4694 | height: this.layout.fixedBodyHeight ? this.layout.fixedBodyHeight + 'px' : ''
|
4695 | };
|
4696 | } else if (this.maxHeight) {
|
4697 | var maxHeight = Object(util["j" ])(this.maxHeight);
|
4698 | if (typeof maxHeight === 'number') {
|
4699 | maxHeight = this.layout.scrollX ? maxHeight - this.layout.gutterWidth : maxHeight;
|
4700 | if (this.showHeader) {
|
4701 | maxHeight -= this.layout.headerHeight;
|
4702 | }
|
4703 | maxHeight -= this.layout.footerHeight;
|
4704 | return {
|
4705 | 'max-height': maxHeight + 'px'
|
4706 | };
|
4707 | }
|
4708 | }
|
4709 | return {};
|
4710 | },
|
4711 | fixedHeight: function fixedHeight() {
|
4712 | if (this.maxHeight) {
|
4713 | if (this.showSummary) {
|
4714 | return {
|
4715 | bottom: 0
|
4716 | };
|
4717 | }
|
4718 | return {
|
4719 | bottom: this.layout.scrollX && this.data.length ? this.layout.gutterWidth + 'px' : ''
|
4720 | };
|
4721 | } else {
|
4722 | if (this.showSummary) {
|
4723 | return {
|
4724 | height: this.layout.tableHeight ? this.layout.tableHeight + 'px' : ''
|
4725 | };
|
4726 | }
|
4727 | return {
|
4728 | height: this.layout.viewportHeight ? this.layout.viewportHeight + 'px' : ''
|
4729 | };
|
4730 | }
|
4731 | },
|
4732 | emptyBlockStyle: function emptyBlockStyle() {
|
4733 | if (this.data && this.data.length) return null;
|
4734 | var height = '100%';
|
4735 | if (this.layout.appendHeight) {
|
4736 | height = 'calc(100% - ' + this.layout.appendHeight + 'px)';
|
4737 | }
|
4738 | return {
|
4739 | width: this.bodyWidth,
|
4740 | height: height
|
4741 | };
|
4742 | }
|
4743 | }, mapStates({
|
4744 | selection: 'selection',
|
4745 | columns: 'columns',
|
4746 | tableData: 'data',
|
4747 | fixedColumns: 'fixedColumns',
|
4748 | rightFixedColumns: 'rightFixedColumns'
|
4749 | })),
|
4750 |
|
4751 | watch: {
|
4752 | height: {
|
4753 | immediate: true,
|
4754 | handler: function handler(value) {
|
4755 | this.layout.setHeight(value);
|
4756 | }
|
4757 | },
|
4758 |
|
4759 | maxHeight: {
|
4760 | immediate: true,
|
4761 | handler: function handler(value) {
|
4762 | this.layout.setMaxHeight(value);
|
4763 | }
|
4764 | },
|
4765 |
|
4766 | currentRowKey: {
|
4767 | immediate: true,
|
4768 | handler: function handler(value) {
|
4769 | if (!this.rowKey) return;
|
4770 | this.store.setCurrentRowKey(value);
|
4771 | }
|
4772 | },
|
4773 |
|
4774 | data: {
|
4775 | immediate: true,
|
4776 | handler: function handler(value) {
|
4777 | this.store.commit('setData', value);
|
4778 | }
|
4779 | },
|
4780 |
|
4781 | expandRowKeys: {
|
4782 | immediate: true,
|
4783 | handler: function handler(newVal) {
|
4784 | if (newVal) {
|
4785 | this.store.setExpandRowKeysAdapter(newVal);
|
4786 | }
|
4787 | }
|
4788 | }
|
4789 | },
|
4790 |
|
4791 | created: function created() {
|
4792 | var _this = this;
|
4793 |
|
4794 | this.tableId = 'el-table_' + tableIdSeed++;
|
4795 | this.debouncedUpdateLayout = Object(external_throttle_debounce_["debounce"])(50, function () {
|
4796 | return _this.doLayout();
|
4797 | });
|
4798 | },
|
4799 | mounted: function mounted() {
|
4800 | var _this2 = this;
|
4801 |
|
4802 | this.bindEvents();
|
4803 | this.store.updateColumns();
|
4804 | this.doLayout();
|
4805 |
|
4806 | this.resizeState = {
|
4807 | width: this.$el.offsetWidth,
|
4808 | height: this.$el.offsetHeight
|
4809 | };
|
4810 |
|
4811 |
|
4812 | this.store.states.columns.forEach(function (column) {
|
4813 | if (column.filteredValue && column.filteredValue.length) {
|
4814 | _this2.store.commit('filterChange', {
|
4815 | column: column,
|
4816 | values: column.filteredValue,
|
4817 | silent: true
|
4818 | });
|
4819 | }
|
4820 | });
|
4821 |
|
4822 | this.$ready = true;
|
4823 | },
|
4824 | destroyed: function destroyed() {
|
4825 | this.unbindEvents();
|
4826 | },
|
4827 | data: function data() {
|
4828 | var _treeProps = this.treeProps,
|
4829 | _treeProps$hasChildre = _treeProps.hasChildren,
|
4830 | hasChildren = _treeProps$hasChildre === undefined ? 'hasChildren' : _treeProps$hasChildre,
|
4831 | _treeProps$children = _treeProps.children,
|
4832 | children = _treeProps$children === undefined ? 'children' : _treeProps$children;
|
4833 |
|
4834 | this.store = createStore(this, {
|
4835 | rowKey: this.rowKey,
|
4836 | defaultExpandAll: this.defaultExpandAll,
|
4837 | selectOnIndeterminate: this.selectOnIndeterminate,
|
4838 |
|
4839 | indent: this.indent,
|
4840 | lazy: this.lazy,
|
4841 | lazyColumnIdentifier: hasChildren,
|
4842 | childrenColumnName: children
|
4843 | });
|
4844 | var layout = new table_layout({
|
4845 | store: this.store,
|
4846 | table: this,
|
4847 | fit: this.fit,
|
4848 | showHeader: this.showHeader
|
4849 | });
|
4850 | return {
|
4851 | layout: layout,
|
4852 | isHidden: false,
|
4853 | renderExpanded: null,
|
4854 | resizeProxyVisible: false,
|
4855 | resizeState: {
|
4856 | width: null,
|
4857 | height: null
|
4858 | },
|
4859 |
|
4860 | isGroup: false,
|
4861 | scrollPosition: 'left'
|
4862 | };
|
4863 | }
|
4864 | });
|
4865 |
|
4866 | var src_tablevue_type_script_lang_js_ = (tablevue_type_script_lang_js_);
|
4867 |
|
4868 |
|
4869 |
|
4870 |
|
4871 |
|
4872 |
|
4873 |
|
4874 |
|
4875 | var table_component = Object(componentNormalizer["a" ])(
|
4876 | src_tablevue_type_script_lang_js_,
|
4877 | render,
|
4878 | staticRenderFns,
|
4879 | false,
|
4880 | null,
|
4881 | null,
|
4882 | null
|
4883 |
|
4884 | )
|
4885 |
|
4886 |
|
4887 | if (false) { var table_api; }
|
4888 | table_component.options.__file = "packages/table/src/table.vue"
|
4889 | var src_table = (table_component.exports);
|
4890 |
|
4891 |
|
4892 |
|
4893 |
|
4894 | src_table.install = function (Vue) {
|
4895 | Vue.component(src_table.name, src_table);
|
4896 | };
|
4897 |
|
4898 | var packages_table = __webpack_exports__["default"] = (src_table);
|
4899 |
|
4900 | })
|
4901 | ]); |
\ | No newline at end of file |