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, {
|
41 | configurable: false,
|
42 | enumerable: true,
|
43 | get: getter
|
44 | /******/ });
|
45 | /******/ }
|
46 | /******/ };
|
47 | /******/
|
48 | /******/ // getDefaultExport function for compatibility with non-harmony modules
|
49 | /******/ __webpack_require__.n = function(module) {
|
50 | var getter = module && module.__esModule ?
|
51 | function getDefault() { return module['default']; } :
|
52 | function getModuleExports() { return module; };
|
53 | __webpack_require__.d(getter, 'a', getter);
|
54 | return getter;
|
55 | };
|
56 |
|
57 |
|
58 | __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
59 |
|
60 |
|
61 | __webpack_require__.p = "/dist/";
|
62 |
|
63 |
|
64 | return __webpack_require__(__webpack_require__.s = 159);
|
65 | })
|
66 |
|
67 | ({
|
68 |
|
69 | 0:
|
70 | (function(module, exports) {
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 | module.exports = function normalizeComponent (
|
79 | rawScriptExports,
|
80 | compiledTemplate,
|
81 | functionalTemplate,
|
82 | injectStyles,
|
83 | scopeId,
|
84 | moduleIdentifier /* server only */
|
85 | ) {
|
86 | var esModule
|
87 | var scriptExports = rawScriptExports = rawScriptExports || {}
|
88 |
|
89 |
|
90 | var type = typeof rawScriptExports.default
|
91 | if (type === 'object' || type === 'function') {
|
92 | esModule = rawScriptExports
|
93 | scriptExports = rawScriptExports.default
|
94 | }
|
95 |
|
96 |
|
97 | var options = typeof scriptExports === 'function'
|
98 | ? scriptExports.options
|
99 | : scriptExports
|
100 |
|
101 |
|
102 | if (compiledTemplate) {
|
103 | options.render = compiledTemplate.render
|
104 | options.staticRenderFns = compiledTemplate.staticRenderFns
|
105 | options._compiled = true
|
106 | }
|
107 |
|
108 |
|
109 | if (functionalTemplate) {
|
110 | options.functional = true
|
111 | }
|
112 |
|
113 |
|
114 | if (scopeId) {
|
115 | options._scopeId = scopeId
|
116 | }
|
117 |
|
118 | var hook
|
119 | if (moduleIdentifier) {
|
120 | hook = function (context) {
|
121 |
|
122 | context =
|
123 | context ||
|
124 | (this.$vnode && this.$vnode.ssrContext) ||
|
125 | (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext)
|
126 |
|
127 | if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
|
128 | context = __VUE_SSR_CONTEXT__
|
129 | }
|
130 |
|
131 | if (injectStyles) {
|
132 | injectStyles.call(this, context)
|
133 | }
|
134 |
|
135 | if (context && context._registeredComponents) {
|
136 | context._registeredComponents.add(moduleIdentifier)
|
137 | }
|
138 | }
|
139 |
|
140 |
|
141 | options._ssrRegister = hook
|
142 | } else if (injectStyles) {
|
143 | hook = injectStyles
|
144 | }
|
145 |
|
146 | if (hook) {
|
147 | var functional = options.functional
|
148 | var existing = functional
|
149 | ? options.render
|
150 | : options.beforeCreate
|
151 |
|
152 | if (!functional) {
|
153 |
|
154 | options.beforeCreate = existing
|
155 | ? [].concat(existing, hook)
|
156 | : [hook]
|
157 | } else {
|
158 |
|
159 |
|
160 | options._injectStyles = hook
|
161 |
|
162 | options.render = function renderWithStyleInjection (h, context) {
|
163 | hook.call(context)
|
164 | return existing(h, context)
|
165 | }
|
166 | }
|
167 | }
|
168 |
|
169 | return {
|
170 | esModule: esModule,
|
171 | exports: scriptExports,
|
172 | options: options
|
173 | }
|
174 | }
|
175 |
|
176 |
|
177 | }),
|
178 |
|
179 | 10:
|
180 | (function(module, exports) {
|
181 |
|
182 | module.exports = require("element-ui/lib/utils/clickoutside");
|
183 |
|
184 | }),
|
185 |
|
186 | 13:
|
187 | (function(module, exports) {
|
188 |
|
189 | module.exports = require("element-ui/lib/utils/popup");
|
190 |
|
191 | }),
|
192 |
|
193 | 14:
|
194 | (function(module, exports) {
|
195 |
|
196 | module.exports = require("throttle-debounce/debounce");
|
197 |
|
198 | }),
|
199 |
|
200 | 159:
|
201 | (function(module, exports, __webpack_require__) {
|
202 |
|
203 | "use strict";
|
204 |
|
205 |
|
206 | exports.__esModule = true;
|
207 |
|
208 | var _table = __webpack_require__(160);
|
209 |
|
210 | var _table2 = _interopRequireDefault(_table);
|
211 |
|
212 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
213 |
|
214 |
|
215 | _table2.default.install = function (Vue) {
|
216 | Vue.component(_table2.default.name, _table2.default);
|
217 | };
|
218 |
|
219 | exports.default = _table2.default;
|
220 |
|
221 | }),
|
222 |
|
223 | 16:
|
224 | (function(module, exports) {
|
225 |
|
226 | module.exports = require("element-ui/lib/checkbox");
|
227 |
|
228 | }),
|
229 |
|
230 | 160:
|
231 | (function(module, __webpack_exports__, __webpack_require__) {
|
232 |
|
233 | "use strict";
|
234 | Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
235 | var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_table_vue__ = __webpack_require__(161);
|
236 | var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_table_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_table_vue__);
|
237 | var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_4f98fcd1_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_table_vue__ = __webpack_require__(173);
|
238 | var normalizeComponent = __webpack_require__(0)
|
239 |
|
240 |
|
241 |
|
242 |
|
243 |
|
244 | var __vue_template_functional__ = false
|
245 |
|
246 | var __vue_styles__ = null
|
247 |
|
248 | var __vue_scopeId__ = null
|
249 |
|
250 | var __vue_module_identifier__ = null
|
251 | var Component = normalizeComponent(
|
252 | __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_table_vue___default.a,
|
253 | __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_4f98fcd1_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_table_vue__["a" ],
|
254 | __vue_template_functional__,
|
255 | __vue_styles__,
|
256 | __vue_scopeId__,
|
257 | __vue_module_identifier__
|
258 | )
|
259 |
|
260 | __webpack_exports__["default"] = (Component.exports);
|
261 |
|
262 |
|
263 | }),
|
264 |
|
265 | 161:
|
266 | (function(module, exports, __webpack_require__) {
|
267 |
|
268 | "use strict";
|
269 |
|
270 |
|
271 | exports.__esModule = true;
|
272 |
|
273 | var _checkbox = __webpack_require__(16);
|
274 |
|
275 | var _checkbox2 = _interopRequireDefault(_checkbox);
|
276 |
|
277 | var _debounce = __webpack_require__(14);
|
278 |
|
279 | var _debounce2 = _interopRequireDefault(_debounce);
|
280 |
|
281 | var _resizeEvent = __webpack_require__(18);
|
282 |
|
283 | var _mousewheel = __webpack_require__(162);
|
284 |
|
285 | var _mousewheel2 = _interopRequireDefault(_mousewheel);
|
286 |
|
287 | var _locale = __webpack_require__(5);
|
288 |
|
289 | var _locale2 = _interopRequireDefault(_locale);
|
290 |
|
291 | var _migrating = __webpack_require__(8);
|
292 |
|
293 | var _migrating2 = _interopRequireDefault(_migrating);
|
294 |
|
295 | var _tableStore = __webpack_require__(164);
|
296 |
|
297 | var _tableStore2 = _interopRequireDefault(_tableStore);
|
298 |
|
299 | var _tableLayout = __webpack_require__(165);
|
300 |
|
301 | var _tableLayout2 = _interopRequireDefault(_tableLayout);
|
302 |
|
303 | var _tableBody = __webpack_require__(166);
|
304 |
|
305 | var _tableBody2 = _interopRequireDefault(_tableBody);
|
306 |
|
307 | var _tableHeader = __webpack_require__(167);
|
308 |
|
309 | var _tableHeader2 = _interopRequireDefault(_tableHeader);
|
310 |
|
311 | var _tableFooter = __webpack_require__(172);
|
312 |
|
313 | var _tableFooter2 = _interopRequireDefault(_tableFooter);
|
314 |
|
315 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
316 |
|
317 | var tableIdSeed = 1;
|
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 |
|
337 |
|
338 |
|
339 |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 |
|
358 |
|
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 |
|
370 |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 |
|
376 |
|
377 |
|
378 |
|
379 |
|
380 |
|
381 |
|
382 |
|
383 |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 |
|
398 |
|
399 |
|
400 |
|
401 |
|
402 |
|
403 |
|
404 |
|
405 |
|
406 |
|
407 |
|
408 |
|
409 |
|
410 |
|
411 |
|
412 |
|
413 |
|
414 |
|
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 |
|
423 |
|
424 |
|
425 |
|
426 |
|
427 |
|
428 |
|
429 |
|
430 |
|
431 |
|
432 |
|
433 |
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 |
|
441 |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 |
|
452 |
|
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 |
|
461 |
|
462 |
|
463 |
|
464 |
|
465 |
|
466 |
|
467 |
|
468 |
|
469 |
|
470 |
|
471 |
|
472 |
|
473 |
|
474 |
|
475 |
|
476 |
|
477 |
|
478 |
|
479 |
|
480 |
|
481 |
|
482 |
|
483 |
|
484 |
|
485 |
|
486 |
|
487 |
|
488 |
|
489 |
|
490 |
|
491 |
|
492 |
|
493 |
|
494 |
|
495 |
|
496 |
|
497 |
|
498 |
|
499 |
|
500 |
|
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 |
|
508 |
|
509 |
|
510 |
|
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 |
|
517 |
|
518 |
|
519 |
|
520 |
|
521 |
|
522 |
|
523 |
|
524 |
|
525 |
|
526 |
|
527 |
|
528 |
|
529 |
|
530 |
|
531 |
|
532 | exports.default = {
|
533 | name: 'ElTable',
|
534 |
|
535 | mixins: [_locale2.default, _migrating2.default],
|
536 |
|
537 | directives: {
|
538 | Mousewheel: _mousewheel2.default
|
539 | },
|
540 |
|
541 | props: {
|
542 | data: {
|
543 | type: Array,
|
544 | default: function _default() {
|
545 | return [];
|
546 | }
|
547 | },
|
548 |
|
549 | size: String,
|
550 |
|
551 | width: [String, Number],
|
552 |
|
553 | height: [String, Number],
|
554 |
|
555 | maxHeight: [String, Number],
|
556 |
|
557 | fit: {
|
558 | type: Boolean,
|
559 | default: true
|
560 | },
|
561 |
|
562 | stripe: Boolean,
|
563 |
|
564 | border: Boolean,
|
565 |
|
566 | rowKey: [String, Function],
|
567 |
|
568 | context: {},
|
569 |
|
570 | showHeader: {
|
571 | type: Boolean,
|
572 | default: true
|
573 | },
|
574 |
|
575 | showSummary: Boolean,
|
576 |
|
577 | sumText: String,
|
578 |
|
579 | summaryMethod: Function,
|
580 |
|
581 | rowClassName: [String, Function],
|
582 |
|
583 | rowStyle: [Object, Function],
|
584 |
|
585 | cellClassName: [String, Function],
|
586 |
|
587 | cellStyle: [Object, Function],
|
588 |
|
589 | headerRowClassName: [String, Function],
|
590 |
|
591 | headerRowStyle: [Object, Function],
|
592 |
|
593 | headerCellClassName: [String, Function],
|
594 |
|
595 | headerCellStyle: [Object, Function],
|
596 |
|
597 | highlightCurrentRow: Boolean,
|
598 |
|
599 | currentRowKey: [String, Number],
|
600 |
|
601 | emptyText: String,
|
602 |
|
603 | expandRowKeys: Array,
|
604 |
|
605 | defaultExpandAll: Boolean,
|
606 |
|
607 | defaultSort: Object,
|
608 |
|
609 | tooltipEffect: String,
|
610 |
|
611 | spanMethod: Function,
|
612 |
|
613 | selectOnIndeterminate: {
|
614 | type: Boolean,
|
615 | default: true
|
616 | }
|
617 | },
|
618 |
|
619 | components: {
|
620 | TableHeader: _tableHeader2.default,
|
621 | TableFooter: _tableFooter2.default,
|
622 | TableBody: _tableBody2.default,
|
623 | ElCheckbox: _checkbox2.default
|
624 | },
|
625 |
|
626 | methods: {
|
627 | getMigratingConfig: function getMigratingConfig() {
|
628 | return {
|
629 | events: {
|
630 | expand: 'expand is renamed to expand-change'
|
631 | }
|
632 | };
|
633 | },
|
634 | setCurrentRow: function setCurrentRow(row) {
|
635 | this.store.commit('setCurrentRow', row);
|
636 | },
|
637 | toggleRowSelection: function toggleRowSelection(row, selected) {
|
638 | this.store.toggleRowSelection(row, selected);
|
639 | this.store.updateAllSelected();
|
640 | },
|
641 | toggleRowExpansion: function toggleRowExpansion(row, expanded) {
|
642 | this.store.toggleRowExpansion(row, expanded);
|
643 | },
|
644 | clearSelection: function clearSelection() {
|
645 | this.store.clearSelection();
|
646 | },
|
647 | clearFilter: function clearFilter() {
|
648 | this.store.clearFilter();
|
649 | },
|
650 | clearSort: function clearSort() {
|
651 | this.store.clearSort();
|
652 | },
|
653 | handleMouseLeave: function handleMouseLeave() {
|
654 | this.store.commit('setHoverRow', null);
|
655 | if (this.hoverState) this.hoverState = null;
|
656 | },
|
657 | updateScrollY: function updateScrollY() {
|
658 | this.layout.updateScrollY();
|
659 | this.layout.updateColumnsWidth();
|
660 | },
|
661 | handleFixedMousewheel: function handleFixedMousewheel(event, data) {
|
662 | var bodyWrapper = this.bodyWrapper;
|
663 | if (Math.abs(data.spinY) > 0) {
|
664 | var currentScrollTop = bodyWrapper.scrollTop;
|
665 | if (data.pixelY < 0 && currentScrollTop !== 0) {
|
666 | event.preventDefault();
|
667 | }
|
668 | if (data.pixelY > 0 && bodyWrapper.scrollHeight - bodyWrapper.clientHeight > currentScrollTop) {
|
669 | event.preventDefault();
|
670 | }
|
671 | bodyWrapper.scrollTop += Math.ceil(data.pixelY / 5);
|
672 | } else {
|
673 | bodyWrapper.scrollLeft += Math.ceil(data.pixelX / 5);
|
674 | }
|
675 | },
|
676 | handleHeaderFooterMousewheel: function handleHeaderFooterMousewheel(event, data) {
|
677 | var pixelX = data.pixelX,
|
678 | pixelY = data.pixelY;
|
679 |
|
680 | if (Math.abs(pixelX) >= Math.abs(pixelY)) {
|
681 | event.preventDefault();
|
682 | this.bodyWrapper.scrollLeft += data.pixelX / 5;
|
683 | }
|
684 | },
|
685 | bindEvents: function bindEvents() {
|
686 | var _$refs = this.$refs,
|
687 | headerWrapper = _$refs.headerWrapper,
|
688 | footerWrapper = _$refs.footerWrapper;
|
689 |
|
690 | var refs = this.$refs;
|
691 | var self = this;
|
692 |
|
693 | this.bodyWrapper.addEventListener('scroll', function () {
|
694 | if (headerWrapper) headerWrapper.scrollLeft = this.scrollLeft;
|
695 | if (footerWrapper) footerWrapper.scrollLeft = this.scrollLeft;
|
696 | if (refs.fixedBodyWrapper) refs.fixedBodyWrapper.scrollTop = this.scrollTop;
|
697 | if (refs.rightFixedBodyWrapper) refs.rightFixedBodyWrapper.scrollTop = this.scrollTop;
|
698 | var maxScrollLeftPosition = this.scrollWidth - this.offsetWidth - 1;
|
699 | var scrollLeft = this.scrollLeft;
|
700 | if (scrollLeft >= maxScrollLeftPosition) {
|
701 | self.scrollPosition = 'right';
|
702 | } else if (scrollLeft === 0) {
|
703 | self.scrollPosition = 'left';
|
704 | } else {
|
705 | self.scrollPosition = 'middle';
|
706 | }
|
707 | });
|
708 |
|
709 | if (this.fit) {
|
710 | (0, _resizeEvent.addResizeListener)(this.$el, this.resizeListener);
|
711 | }
|
712 | },
|
713 | resizeListener: function resizeListener() {
|
714 | if (!this.$ready) return;
|
715 | var shouldUpdateLayout = false;
|
716 | var el = this.$el;
|
717 | var _resizeState = this.resizeState,
|
718 | oldWidth = _resizeState.width,
|
719 | oldHeight = _resizeState.height;
|
720 |
|
721 |
|
722 | var width = el.offsetWidth;
|
723 | if (oldWidth !== width) {
|
724 | shouldUpdateLayout = true;
|
725 | }
|
726 |
|
727 | var height = el.offsetHeight;
|
728 | if ((this.height || this.shouldUpdateHeight) && oldHeight !== height) {
|
729 | shouldUpdateLayout = true;
|
730 | }
|
731 |
|
732 | if (shouldUpdateLayout) {
|
733 | this.resizeState.width = width;
|
734 | this.resizeState.height = height;
|
735 | this.doLayout();
|
736 | }
|
737 | },
|
738 | doLayout: function doLayout() {
|
739 | this.layout.updateColumnsWidth();
|
740 | if (this.shouldUpdateHeight) {
|
741 | this.layout.updateElsHeight();
|
742 | }
|
743 | },
|
744 | sort: function sort(prop, order) {
|
745 | this.store.commit('sort', { prop: prop, order: order });
|
746 | },
|
747 | toggleAllSelection: function toggleAllSelection() {
|
748 | this.store.commit('toggleAllSelection');
|
749 | }
|
750 | },
|
751 |
|
752 | created: function created() {
|
753 | var _this = this;
|
754 |
|
755 | this.tableId = 'el-table_' + tableIdSeed++;
|
756 | this.debouncedUpdateLayout = (0, _debounce2.default)(50, function () {
|
757 | return _this.doLayout();
|
758 | });
|
759 | },
|
760 |
|
761 |
|
762 | computed: {
|
763 | tableSize: function tableSize() {
|
764 | return this.size || (this.$ELEMENT || {}).size;
|
765 | },
|
766 | bodyWrapper: function bodyWrapper() {
|
767 | return this.$refs.bodyWrapper;
|
768 | },
|
769 | shouldUpdateHeight: function shouldUpdateHeight() {
|
770 | return this.height || this.maxHeight || this.fixedColumns.length > 0 || this.rightFixedColumns.length > 0;
|
771 | },
|
772 | selection: function selection() {
|
773 | return this.store.states.selection;
|
774 | },
|
775 | columns: function columns() {
|
776 | return this.store.states.columns;
|
777 | },
|
778 | tableData: function tableData() {
|
779 | return this.store.states.data;
|
780 | },
|
781 | fixedColumns: function fixedColumns() {
|
782 | return this.store.states.fixedColumns;
|
783 | },
|
784 | rightFixedColumns: function rightFixedColumns() {
|
785 | return this.store.states.rightFixedColumns;
|
786 | },
|
787 | bodyWidth: function bodyWidth() {
|
788 | var _layout = this.layout,
|
789 | bodyWidth = _layout.bodyWidth,
|
790 | scrollY = _layout.scrollY,
|
791 | gutterWidth = _layout.gutterWidth;
|
792 |
|
793 | return bodyWidth ? bodyWidth - (scrollY ? gutterWidth : 0) + 'px' : '';
|
794 | },
|
795 | bodyHeight: function bodyHeight() {
|
796 | if (this.height) {
|
797 | return {
|
798 | height: this.layout.bodyHeight ? this.layout.bodyHeight + 'px' : ''
|
799 | };
|
800 | } else if (this.maxHeight) {
|
801 | return {
|
802 | 'max-height': (this.showHeader ? this.maxHeight - this.layout.headerHeight - this.layout.footerHeight : this.maxHeight - this.layout.footerHeight) + 'px'
|
803 | };
|
804 | }
|
805 | return {};
|
806 | },
|
807 | fixedBodyHeight: function fixedBodyHeight() {
|
808 | if (this.height) {
|
809 | return {
|
810 | height: this.layout.fixedBodyHeight ? this.layout.fixedBodyHeight + 'px' : ''
|
811 | };
|
812 | } else if (this.maxHeight) {
|
813 | var maxHeight = this.layout.scrollX ? this.maxHeight - this.layout.gutterWidth : this.maxHeight;
|
814 |
|
815 | if (this.showHeader) {
|
816 | maxHeight -= this.layout.headerHeight;
|
817 | }
|
818 |
|
819 | maxHeight -= this.layout.footerHeight;
|
820 |
|
821 | return {
|
822 | 'max-height': maxHeight + 'px'
|
823 | };
|
824 | }
|
825 |
|
826 | return {};
|
827 | },
|
828 | fixedHeight: function fixedHeight() {
|
829 | if (this.maxHeight) {
|
830 | if (this.showSummary) {
|
831 | return {
|
832 | bottom: 0
|
833 | };
|
834 | }
|
835 | return {
|
836 | bottom: this.layout.scrollX && this.data.length ? this.layout.gutterWidth + 'px' : ''
|
837 | };
|
838 | } else {
|
839 | if (this.showSummary) {
|
840 | return {
|
841 | height: this.layout.tableHeight ? this.layout.tableHeight + 'px' : ''
|
842 | };
|
843 | }
|
844 | return {
|
845 | height: this.layout.viewportHeight ? this.layout.viewportHeight + 'px' : ''
|
846 | };
|
847 | }
|
848 | }
|
849 | },
|
850 |
|
851 | watch: {
|
852 | height: {
|
853 | immediate: true,
|
854 | handler: function handler(value) {
|
855 | this.layout.setHeight(value);
|
856 | }
|
857 | },
|
858 |
|
859 | maxHeight: {
|
860 | immediate: true,
|
861 | handler: function handler(value) {
|
862 | this.layout.setMaxHeight(value);
|
863 | }
|
864 | },
|
865 |
|
866 | currentRowKey: function currentRowKey(newVal) {
|
867 | this.store.setCurrentRowKey(newVal);
|
868 | },
|
869 |
|
870 |
|
871 | data: {
|
872 | immediate: true,
|
873 | handler: function handler(value) {
|
874 | var _this2 = this;
|
875 |
|
876 | this.store.commit('setData', value);
|
877 | if (this.$ready) {
|
878 | this.$nextTick(function () {
|
879 | _this2.doLayout();
|
880 | });
|
881 | }
|
882 | }
|
883 | },
|
884 |
|
885 | expandRowKeys: {
|
886 | immediate: true,
|
887 | handler: function handler(newVal) {
|
888 | if (newVal) {
|
889 | this.store.setExpandRowKeys(newVal);
|
890 | }
|
891 | }
|
892 | }
|
893 | },
|
894 |
|
895 | destroyed: function destroyed() {
|
896 | if (this.resizeListener) (0, _resizeEvent.removeResizeListener)(this.$el, this.resizeListener);
|
897 | },
|
898 | mounted: function mounted() {
|
899 | var _this3 = this;
|
900 |
|
901 | this.bindEvents();
|
902 | this.store.updateColumns();
|
903 | this.doLayout();
|
904 |
|
905 | this.resizeState = {
|
906 | width: this.$el.offsetWidth,
|
907 | height: this.$el.offsetHeight
|
908 | };
|
909 |
|
910 |
|
911 | this.store.states.columns.forEach(function (column) {
|
912 | if (column.filteredValue && column.filteredValue.length) {
|
913 | _this3.store.commit('filterChange', {
|
914 | column: column,
|
915 | values: column.filteredValue,
|
916 | silent: true
|
917 | });
|
918 | }
|
919 | });
|
920 |
|
921 | this.$ready = true;
|
922 | },
|
923 | data: function data() {
|
924 | var store = new _tableStore2.default(this, {
|
925 | rowKey: this.rowKey,
|
926 | defaultExpandAll: this.defaultExpandAll,
|
927 | selectOnIndeterminate: this.selectOnIndeterminate
|
928 | });
|
929 | var layout = new _tableLayout2.default({
|
930 | store: store,
|
931 | table: this,
|
932 | fit: this.fit,
|
933 | showHeader: this.showHeader
|
934 | });
|
935 | return {
|
936 | layout: layout,
|
937 | store: store,
|
938 | isHidden: false,
|
939 | renderExpanded: null,
|
940 | resizeProxyVisible: false,
|
941 | resizeState: {
|
942 | width: null,
|
943 | height: null
|
944 | },
|
945 |
|
946 | isGroup: false,
|
947 | scrollPosition: 'left'
|
948 | };
|
949 | }
|
950 | };
|
951 |
|
952 | }),
|
953 |
|
954 | 162:
|
955 | (function(module, exports, __webpack_require__) {
|
956 |
|
957 | "use strict";
|
958 |
|
959 |
|
960 | exports.__esModule = true;
|
961 |
|
962 | var _normalizeWheel = __webpack_require__(163);
|
963 |
|
964 | var _normalizeWheel2 = _interopRequireDefault(_normalizeWheel);
|
965 |
|
966 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
967 |
|
968 | var isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
969 |
|
970 | var mousewheel = function mousewheel(element, callback) {
|
971 | if (element && element.addEventListener) {
|
972 | element.addEventListener(isFirefox ? 'DOMMouseScroll' : 'mousewheel', function (event) {
|
973 | var normalized = (0, _normalizeWheel2.default)(event);
|
974 | callback && callback.apply(this, [event, normalized]);
|
975 | });
|
976 | }
|
977 | };
|
978 |
|
979 | exports.default = {
|
980 | bind: function bind(el, binding) {
|
981 | mousewheel(el, binding.value);
|
982 | }
|
983 | };
|
984 |
|
985 | }),
|
986 |
|
987 | 163:
|
988 | (function(module, exports) {
|
989 |
|
990 | module.exports = require("normalize-wheel");
|
991 |
|
992 | }),
|
993 |
|
994 | 164:
|
995 | (function(module, exports, __webpack_require__) {
|
996 |
|
997 | "use strict";
|
998 |
|
999 |
|
1000 | exports.__esModule = true;
|
1001 |
|
1002 | var _vue = __webpack_require__(4);
|
1003 |
|
1004 | var _vue2 = _interopRequireDefault(_vue);
|
1005 |
|
1006 | var _debounce = __webpack_require__(14);
|
1007 |
|
1008 | var _debounce2 = _interopRequireDefault(_debounce);
|
1009 |
|
1010 | var _merge = __webpack_require__(9);
|
1011 |
|
1012 | var _merge2 = _interopRequireDefault(_merge);
|
1013 |
|
1014 | var _dom = __webpack_require__(3);
|
1015 |
|
1016 | var _util = __webpack_require__(48);
|
1017 |
|
1018 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
1019 |
|
1020 | var sortData = function sortData(data, states) {
|
1021 | var sortingColumn = states.sortingColumn;
|
1022 | if (!sortingColumn || typeof sortingColumn.sortable === 'string') {
|
1023 | return data;
|
1024 | }
|
1025 | return (0, _util.orderBy)(data, states.sortProp, states.sortOrder, sortingColumn.sortMethod, sortingColumn.sortBy);
|
1026 | };
|
1027 |
|
1028 | var getKeysMap = function getKeysMap(array, rowKey) {
|
1029 | var arrayMap = {};
|
1030 | (array || []).forEach(function (row, index) {
|
1031 | arrayMap[(0, _util.getRowIdentity)(row, rowKey)] = { row: row, index: index };
|
1032 | });
|
1033 | return arrayMap;
|
1034 | };
|
1035 |
|
1036 | var toggleRowSelection = function toggleRowSelection(states, row, selected) {
|
1037 | var changed = false;
|
1038 | var selection = states.selection;
|
1039 | var index = selection.indexOf(row);
|
1040 | if (typeof selected === 'undefined') {
|
1041 | if (index === -1) {
|
1042 | selection.push(row);
|
1043 | changed = true;
|
1044 | } else {
|
1045 | selection.splice(index, 1);
|
1046 | changed = true;
|
1047 | }
|
1048 | } else {
|
1049 | if (selected && index === -1) {
|
1050 | selection.push(row);
|
1051 | changed = true;
|
1052 | } else if (!selected && index > -1) {
|
1053 | selection.splice(index, 1);
|
1054 | changed = true;
|
1055 | }
|
1056 | }
|
1057 |
|
1058 | return changed;
|
1059 | };
|
1060 |
|
1061 | var toggleRowExpansion = function toggleRowExpansion(states, row, expanded) {
|
1062 | var changed = false;
|
1063 | var expandRows = states.expandRows;
|
1064 | if (typeof expanded !== 'undefined') {
|
1065 | var index = expandRows.indexOf(row);
|
1066 | if (expanded) {
|
1067 | if (index === -1) {
|
1068 | expandRows.push(row);
|
1069 | changed = true;
|
1070 | }
|
1071 | } else {
|
1072 | if (index !== -1) {
|
1073 | expandRows.splice(index, 1);
|
1074 | changed = true;
|
1075 | }
|
1076 | }
|
1077 | } else {
|
1078 | var _index = expandRows.indexOf(row);
|
1079 | if (_index === -1) {
|
1080 | expandRows.push(row);
|
1081 | changed = true;
|
1082 | } else {
|
1083 | expandRows.splice(_index, 1);
|
1084 | changed = true;
|
1085 | }
|
1086 | }
|
1087 |
|
1088 | return changed;
|
1089 | };
|
1090 |
|
1091 | var TableStore = function TableStore(table) {
|
1092 | var initialState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
1093 |
|
1094 | if (!table) {
|
1095 | throw new Error('Table is required.');
|
1096 | }
|
1097 | this.table = table;
|
1098 |
|
1099 | this.states = {
|
1100 | rowKey: null,
|
1101 | _columns: [],
|
1102 | originColumns: [],
|
1103 | columns: [],
|
1104 | fixedColumns: [],
|
1105 | rightFixedColumns: [],
|
1106 | leafColumns: [],
|
1107 | fixedLeafColumns: [],
|
1108 | rightFixedLeafColumns: [],
|
1109 | leafColumnsLength: 0,
|
1110 | fixedLeafColumnsLength: 0,
|
1111 | rightFixedLeafColumnsLength: 0,
|
1112 | isComplex: false,
|
1113 | filteredData: null,
|
1114 | data: null,
|
1115 | sortingColumn: null,
|
1116 | sortProp: null,
|
1117 | sortOrder: null,
|
1118 | isAllSelected: false,
|
1119 | selection: [],
|
1120 | reserveSelection: false,
|
1121 | selectable: null,
|
1122 | currentRow: null,
|
1123 | hoverRow: null,
|
1124 | filters: {},
|
1125 | expandRows: [],
|
1126 | defaultExpandAll: false,
|
1127 | selectOnIndeterminate: false
|
1128 | };
|
1129 |
|
1130 | for (var prop in initialState) {
|
1131 | if (initialState.hasOwnProperty(prop) && this.states.hasOwnProperty(prop)) {
|
1132 | this.states[prop] = initialState[prop];
|
1133 | }
|
1134 | }
|
1135 | };
|
1136 |
|
1137 | TableStore.prototype.mutations = {
|
1138 | setData: function setData(states, data) {
|
1139 | var _this = this;
|
1140 |
|
1141 | var dataInstanceChanged = states._data !== data;
|
1142 | states._data = data;
|
1143 |
|
1144 | Object.keys(states.filters).forEach(function (columnId) {
|
1145 | var values = states.filters[columnId];
|
1146 | if (!values || values.length === 0) return;
|
1147 | var column = (0, _util.getColumnById)(_this.states, columnId);
|
1148 | if (column && column.filterMethod) {
|
1149 | data = data.filter(function (row) {
|
1150 | return values.some(function (value) {
|
1151 | return column.filterMethod.call(null, value, row, column);
|
1152 | });
|
1153 | });
|
1154 | }
|
1155 | });
|
1156 |
|
1157 | states.filteredData = data;
|
1158 | states.data = sortData(data || [], states);
|
1159 |
|
1160 | this.updateCurrentRow();
|
1161 |
|
1162 | var rowKey = states.rowKey;
|
1163 |
|
1164 | if (!states.reserveSelection) {
|
1165 | if (dataInstanceChanged) {
|
1166 | this.clearSelection();
|
1167 | } else {
|
1168 | this.cleanSelection();
|
1169 | }
|
1170 | this.updateAllSelected();
|
1171 | } else {
|
1172 | if (rowKey) {
|
1173 | (function () {
|
1174 | var selection = states.selection;
|
1175 | var selectedMap = getKeysMap(selection, rowKey);
|
1176 |
|
1177 | states.data.forEach(function (row) {
|
1178 | var rowId = (0, _util.getRowIdentity)(row, rowKey);
|
1179 | var rowInfo = selectedMap[rowId];
|
1180 | if (rowInfo) {
|
1181 | selection[rowInfo.index] = row;
|
1182 | }
|
1183 | });
|
1184 |
|
1185 | _this.updateAllSelected();
|
1186 | })();
|
1187 | } else {
|
1188 | console.warn('WARN: rowKey is required when reserve-selection is enabled.');
|
1189 | }
|
1190 | }
|
1191 |
|
1192 | var defaultExpandAll = states.defaultExpandAll;
|
1193 | if (defaultExpandAll) {
|
1194 | this.states.expandRows = (states.data || []).slice(0);
|
1195 | } else if (rowKey) {
|
1196 |
|
1197 | var ids = getKeysMap(this.states.expandRows, rowKey);
|
1198 | var expandRows = [];
|
1199 | for (var _iterator = states.data, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
1200 | var _ref;
|
1201 |
|
1202 | if (_isArray) {
|
1203 | if (_i >= _iterator.length) break;
|
1204 | _ref = _iterator[_i++];
|
1205 | } else {
|
1206 | _i = _iterator.next();
|
1207 | if (_i.done) break;
|
1208 | _ref = _i.value;
|
1209 | }
|
1210 |
|
1211 | var row = _ref;
|
1212 |
|
1213 | var rowId = (0, _util.getRowIdentity)(row, rowKey);
|
1214 | if (ids[rowId]) {
|
1215 | expandRows.push(row);
|
1216 | }
|
1217 | }
|
1218 | this.states.expandRows = expandRows;
|
1219 | } else {
|
1220 |
|
1221 | this.states.expandRows = [];
|
1222 | }
|
1223 |
|
1224 | _vue2.default.nextTick(function () {
|
1225 | return _this.table.updateScrollY();
|
1226 | });
|
1227 | },
|
1228 | changeSortCondition: function changeSortCondition(states, options) {
|
1229 | var _this2 = this;
|
1230 |
|
1231 | states.data = sortData(states.filteredData || states._data || [], states);
|
1232 |
|
1233 | var _table = this.table,
|
1234 | $el = _table.$el,
|
1235 | highlightCurrentRow = _table.highlightCurrentRow;
|
1236 |
|
1237 | if ($el && highlightCurrentRow) {
|
1238 | var data = states.data;
|
1239 | var tr = $el.querySelector('tbody').children;
|
1240 | var rows = [].filter.call(tr, function (row) {
|
1241 | return (0, _dom.hasClass)(row, 'el-table__row');
|
1242 | });
|
1243 | var row = rows[data.indexOf(states.currentRow)];
|
1244 |
|
1245 | [].forEach.call(rows, function (row) {
|
1246 | return (0, _dom.removeClass)(row, 'current-row');
|
1247 | });
|
1248 | (0, _dom.addClass)(row, 'current-row');
|
1249 | }
|
1250 |
|
1251 | if (!options || !options.silent) {
|
1252 | this.table.$emit('sort-change', {
|
1253 | column: this.states.sortingColumn,
|
1254 | prop: this.states.sortProp,
|
1255 | order: this.states.sortOrder
|
1256 | });
|
1257 | }
|
1258 |
|
1259 | _vue2.default.nextTick(function () {
|
1260 | return _this2.table.updateScrollY();
|
1261 | });
|
1262 | },
|
1263 | sort: function sort(states, options) {
|
1264 | var _this3 = this;
|
1265 |
|
1266 | var prop = options.prop,
|
1267 | order = options.order;
|
1268 |
|
1269 | if (prop) {
|
1270 | states.sortProp = prop;
|
1271 | states.sortOrder = order || 'ascending';
|
1272 | _vue2.default.nextTick(function () {
|
1273 | for (var i = 0, length = states.columns.length; i < length; i++) {
|
1274 | var column = states.columns[i];
|
1275 | if (column.property === states.sortProp) {
|
1276 | column.order = states.sortOrder;
|
1277 | states.sortingColumn = column;
|
1278 | break;
|
1279 | }
|
1280 | }
|
1281 |
|
1282 | if (states.sortingColumn) {
|
1283 | _this3.commit('changeSortCondition');
|
1284 | }
|
1285 | });
|
1286 | }
|
1287 | },
|
1288 | filterChange: function filterChange(states, options) {
|
1289 | var _this4 = this;
|
1290 |
|
1291 | var column = options.column,
|
1292 | values = options.values,
|
1293 | silent = options.silent;
|
1294 |
|
1295 | if (values && !Array.isArray(values)) {
|
1296 | values = [values];
|
1297 | }
|
1298 |
|
1299 | var prop = column.property;
|
1300 | var filters = {};
|
1301 |
|
1302 | if (prop) {
|
1303 | states.filters[column.id] = values;
|
1304 | filters[column.columnKey || column.id] = values;
|
1305 | }
|
1306 |
|
1307 | var data = states._data;
|
1308 |
|
1309 | Object.keys(states.filters).forEach(function (columnId) {
|
1310 | var values = states.filters[columnId];
|
1311 | if (!values || values.length === 0) return;
|
1312 | var column = (0, _util.getColumnById)(_this4.states, columnId);
|
1313 | if (column && column.filterMethod) {
|
1314 | data = data.filter(function (row) {
|
1315 | return values.some(function (value) {
|
1316 | return column.filterMethod.call(null, value, row, column);
|
1317 | });
|
1318 | });
|
1319 | }
|
1320 | });
|
1321 |
|
1322 | states.filteredData = data;
|
1323 | states.data = sortData(data, states);
|
1324 |
|
1325 | if (!silent) {
|
1326 | this.table.$emit('filter-change', filters);
|
1327 | }
|
1328 |
|
1329 | _vue2.default.nextTick(function () {
|
1330 | return _this4.table.updateScrollY();
|
1331 | });
|
1332 | },
|
1333 | insertColumn: function insertColumn(states, column, index, parent) {
|
1334 | var array = states._columns;
|
1335 | if (parent) {
|
1336 | array = parent.children;
|
1337 | if (!array) array = parent.children = [];
|
1338 | }
|
1339 |
|
1340 | if (typeof index !== 'undefined') {
|
1341 | array.splice(index, 0, column);
|
1342 | } else {
|
1343 | array.push(column);
|
1344 | }
|
1345 |
|
1346 | if (column.type === 'selection') {
|
1347 | states.selectable = column.selectable;
|
1348 | states.reserveSelection = column.reserveSelection;
|
1349 | }
|
1350 |
|
1351 | if (this.table.$ready) {
|
1352 | this.updateColumns();
|
1353 | this.scheduleLayout();
|
1354 | }
|
1355 | },
|
1356 | removeColumn: function removeColumn(states, column, parent) {
|
1357 | var array = states._columns;
|
1358 | if (parent) {
|
1359 | array = parent.children;
|
1360 | if (!array) array = parent.children = [];
|
1361 | }
|
1362 | if (array) {
|
1363 | array.splice(array.indexOf(column), 1);
|
1364 | }
|
1365 |
|
1366 | if (this.table.$ready) {
|
1367 | this.updateColumns();
|
1368 | this.scheduleLayout();
|
1369 | }
|
1370 | },
|
1371 | setHoverRow: function setHoverRow(states, row) {
|
1372 | states.hoverRow = row;
|
1373 | },
|
1374 | setCurrentRow: function setCurrentRow(states, row) {
|
1375 | var oldCurrentRow = states.currentRow;
|
1376 | states.currentRow = row;
|
1377 |
|
1378 | if (oldCurrentRow !== row) {
|
1379 | this.table.$emit('current-change', row, oldCurrentRow);
|
1380 | }
|
1381 | },
|
1382 | rowSelectedChanged: function rowSelectedChanged(states, row) {
|
1383 | var changed = toggleRowSelection(states, row);
|
1384 | var selection = states.selection;
|
1385 |
|
1386 | if (changed) {
|
1387 | var table = this.table;
|
1388 | table.$emit('selection-change', selection ? selection.slice() : []);
|
1389 | table.$emit('select', selection, row);
|
1390 | }
|
1391 |
|
1392 | this.updateAllSelected();
|
1393 | },
|
1394 |
|
1395 |
|
1396 | toggleAllSelection: (0, _debounce2.default)(10, function (states) {
|
1397 | var data = states.data || [];
|
1398 | if (data.length === 0) return;
|
1399 | var selection = this.states.selection;
|
1400 |
|
1401 |
|
1402 | var value = states.selectOnIndeterminate ? !states.isAllSelected : !(states.isAllSelected || selection.length);
|
1403 | var selectionChanged = false;
|
1404 |
|
1405 | data.forEach(function (item, index) {
|
1406 | if (states.selectable) {
|
1407 | if (states.selectable.call(null, item, index) && toggleRowSelection(states, item, value)) {
|
1408 | selectionChanged = true;
|
1409 | }
|
1410 | } else {
|
1411 | if (toggleRowSelection(states, item, value)) {
|
1412 | selectionChanged = true;
|
1413 | }
|
1414 | }
|
1415 | });
|
1416 |
|
1417 | var table = this.table;
|
1418 | if (selectionChanged) {
|
1419 | table.$emit('selection-change', selection ? selection.slice() : []);
|
1420 | }
|
1421 | table.$emit('select-all', selection);
|
1422 | states.isAllSelected = value;
|
1423 | })
|
1424 | };
|
1425 |
|
1426 | var doFlattenColumns = function doFlattenColumns(columns) {
|
1427 | var result = [];
|
1428 | columns.forEach(function (column) {
|
1429 | if (column.children) {
|
1430 | result.push.apply(result, doFlattenColumns(column.children));
|
1431 | } else {
|
1432 | result.push(column);
|
1433 | }
|
1434 | });
|
1435 | return result;
|
1436 | };
|
1437 |
|
1438 | TableStore.prototype.updateColumns = function () {
|
1439 | var states = this.states;
|
1440 | var _columns = states._columns || [];
|
1441 | states.fixedColumns = _columns.filter(function (column) {
|
1442 | return column.fixed === true || column.fixed === 'left';
|
1443 | });
|
1444 | states.rightFixedColumns = _columns.filter(function (column) {
|
1445 | return column.fixed === 'right';
|
1446 | });
|
1447 |
|
1448 | if (states.fixedColumns.length > 0 && _columns[0] && _columns[0].type === 'selection' && !_columns[0].fixed) {
|
1449 | _columns[0].fixed = true;
|
1450 | states.fixedColumns.unshift(_columns[0]);
|
1451 | }
|
1452 |
|
1453 | var notFixedColumns = _columns.filter(function (column) {
|
1454 | return !column.fixed;
|
1455 | });
|
1456 | states.originColumns = [].concat(states.fixedColumns).concat(notFixedColumns).concat(states.rightFixedColumns);
|
1457 |
|
1458 | var leafColumns = doFlattenColumns(notFixedColumns);
|
1459 | var fixedLeafColumns = doFlattenColumns(states.fixedColumns);
|
1460 | var rightFixedLeafColumns = doFlattenColumns(states.rightFixedColumns);
|
1461 |
|
1462 | states.leafColumnsLength = leafColumns.length;
|
1463 | states.fixedLeafColumnsLength = fixedLeafColumns.length;
|
1464 | states.rightFixedLeafColumnsLength = rightFixedLeafColumns.length;
|
1465 |
|
1466 | states.columns = [].concat(fixedLeafColumns).concat(leafColumns).concat(rightFixedLeafColumns);
|
1467 | states.isComplex = states.fixedColumns.length > 0 || states.rightFixedColumns.length > 0;
|
1468 | };
|
1469 |
|
1470 | TableStore.prototype.isSelected = function (row) {
|
1471 | return (this.states.selection || []).indexOf(row) > -1;
|
1472 | };
|
1473 |
|
1474 | TableStore.prototype.clearSelection = function () {
|
1475 | var states = this.states;
|
1476 | states.isAllSelected = false;
|
1477 | var oldSelection = states.selection;
|
1478 | if (states.selection.length) {
|
1479 | states.selection = [];
|
1480 | }
|
1481 | if (oldSelection.length > 0) {
|
1482 | this.table.$emit('selection-change', states.selection ? states.selection.slice() : []);
|
1483 | }
|
1484 | };
|
1485 |
|
1486 | TableStore.prototype.setExpandRowKeys = function (rowKeys) {
|
1487 | var expandRows = [];
|
1488 | var data = this.states.data;
|
1489 | var rowKey = this.states.rowKey;
|
1490 | if (!rowKey) throw new Error('[Table] prop row-key should not be empty.');
|
1491 | var keysMap = getKeysMap(data, rowKey);
|
1492 | rowKeys.forEach(function (key) {
|
1493 | var info = keysMap[key];
|
1494 | if (info) {
|
1495 | expandRows.push(info.row);
|
1496 | }
|
1497 | });
|
1498 |
|
1499 | this.states.expandRows = expandRows;
|
1500 | };
|
1501 |
|
1502 | TableStore.prototype.toggleRowSelection = function (row, selected) {
|
1503 | var changed = toggleRowSelection(this.states, row, selected);
|
1504 | if (changed) {
|
1505 | this.table.$emit('selection-change', this.states.selection ? this.states.selection.slice() : []);
|
1506 | }
|
1507 | };
|
1508 |
|
1509 | TableStore.prototype.toggleRowExpansion = function (row, expanded) {
|
1510 | var changed = toggleRowExpansion(this.states, row, expanded);
|
1511 | if (changed) {
|
1512 | this.table.$emit('expand-change', row, this.states.expandRows);
|
1513 | this.scheduleLayout();
|
1514 | }
|
1515 | };
|
1516 |
|
1517 | TableStore.prototype.isRowExpanded = function (row) {
|
1518 | var _states = this.states,
|
1519 | _states$expandRows = _states.expandRows,
|
1520 | expandRows = _states$expandRows === undefined ? [] : _states$expandRows,
|
1521 | rowKey = _states.rowKey;
|
1522 |
|
1523 | if (rowKey) {
|
1524 | var expandMap = getKeysMap(expandRows, rowKey);
|
1525 | return !!expandMap[(0, _util.getRowIdentity)(row, rowKey)];
|
1526 | }
|
1527 | return expandRows.indexOf(row) !== -1;
|
1528 | };
|
1529 |
|
1530 | TableStore.prototype.cleanSelection = function () {
|
1531 | var selection = this.states.selection || [];
|
1532 | var data = this.states.data;
|
1533 | var rowKey = this.states.rowKey;
|
1534 | var deleted = void 0;
|
1535 | if (rowKey) {
|
1536 | deleted = [];
|
1537 | var selectedMap = getKeysMap(selection, rowKey);
|
1538 | var dataMap = getKeysMap(data, rowKey);
|
1539 | for (var key in selectedMap) {
|
1540 | if (selectedMap.hasOwnProperty(key) && !dataMap[key]) {
|
1541 | deleted.push(selectedMap[key].row);
|
1542 | }
|
1543 | }
|
1544 | } else {
|
1545 | deleted = selection.filter(function (item) {
|
1546 | return data.indexOf(item) === -1;
|
1547 | });
|
1548 | }
|
1549 |
|
1550 | deleted.forEach(function (deletedItem) {
|
1551 | selection.splice(selection.indexOf(deletedItem), 1);
|
1552 | });
|
1553 |
|
1554 | if (deleted.length) {
|
1555 | this.table.$emit('selection-change', selection ? selection.slice() : []);
|
1556 | }
|
1557 | };
|
1558 |
|
1559 | TableStore.prototype.clearFilter = function () {
|
1560 | var states = this.states;
|
1561 | var _table$$refs = this.table.$refs,
|
1562 | tableHeader = _table$$refs.tableHeader,
|
1563 | fixedTableHeader = _table$$refs.fixedTableHeader,
|
1564 | rightFixedTableHeader = _table$$refs.rightFixedTableHeader;
|
1565 |
|
1566 | var panels = {};
|
1567 |
|
1568 | if (tableHeader) panels = (0, _merge2.default)(panels, tableHeader.filterPanels);
|
1569 | if (fixedTableHeader) panels = (0, _merge2.default)(panels, fixedTableHeader.filterPanels);
|
1570 | if (rightFixedTableHeader) panels = (0, _merge2.default)(panels, rightFixedTableHeader.filterPanels);
|
1571 |
|
1572 | var keys = Object.keys(panels);
|
1573 | if (!keys.length) return;
|
1574 |
|
1575 | keys.forEach(function (key) {
|
1576 | panels[key].filteredValue = [];
|
1577 | });
|
1578 |
|
1579 | states.filters = {};
|
1580 |
|
1581 | this.commit('filterChange', {
|
1582 | column: {},
|
1583 | values: [],
|
1584 | silent: true
|
1585 | });
|
1586 | };
|
1587 |
|
1588 | TableStore.prototype.clearSort = function () {
|
1589 | var states = this.states;
|
1590 | if (!states.sortingColumn) return;
|
1591 | states.sortingColumn.order = null;
|
1592 | states.sortProp = null;
|
1593 | states.sortOrder = null;
|
1594 |
|
1595 | this.commit('changeSortCondition', {
|
1596 | silent: true
|
1597 | });
|
1598 | };
|
1599 |
|
1600 | TableStore.prototype.updateAllSelected = function () {
|
1601 | var states = this.states;
|
1602 | var selection = states.selection,
|
1603 | rowKey = states.rowKey,
|
1604 | selectable = states.selectable,
|
1605 | data = states.data;
|
1606 |
|
1607 | if (!data || data.length === 0) {
|
1608 | states.isAllSelected = false;
|
1609 | return;
|
1610 | }
|
1611 |
|
1612 | var selectedMap = void 0;
|
1613 | if (rowKey) {
|
1614 | selectedMap = getKeysMap(states.selection, rowKey);
|
1615 | }
|
1616 |
|
1617 | var isSelected = function isSelected(row) {
|
1618 | if (selectedMap) {
|
1619 | return !!selectedMap[(0, _util.getRowIdentity)(row, rowKey)];
|
1620 | } else {
|
1621 | return selection.indexOf(row) !== -1;
|
1622 | }
|
1623 | };
|
1624 |
|
1625 | var isAllSelected = true;
|
1626 | var selectedCount = 0;
|
1627 | for (var i = 0, j = data.length; i < j; i++) {
|
1628 | var item = data[i];
|
1629 | var isRowSelectable = selectable && selectable.call(null, item, i);
|
1630 | if (!isSelected(item)) {
|
1631 | if (!selectable || isRowSelectable) {
|
1632 | isAllSelected = false;
|
1633 | break;
|
1634 | }
|
1635 | } else {
|
1636 | selectedCount++;
|
1637 | }
|
1638 | }
|
1639 |
|
1640 | if (selectedCount === 0) isAllSelected = false;
|
1641 |
|
1642 | states.isAllSelected = isAllSelected;
|
1643 | };
|
1644 |
|
1645 | TableStore.prototype.scheduleLayout = function (updateColumns) {
|
1646 | if (updateColumns) {
|
1647 | this.updateColumns();
|
1648 | }
|
1649 | this.table.debouncedUpdateLayout();
|
1650 | };
|
1651 |
|
1652 | TableStore.prototype.setCurrentRowKey = function (key) {
|
1653 | var states = this.states;
|
1654 | var rowKey = states.rowKey;
|
1655 | if (!rowKey) throw new Error('[Table] row-key should not be empty.');
|
1656 | var data = states.data || [];
|
1657 | var keysMap = getKeysMap(data, rowKey);
|
1658 | var info = keysMap[key];
|
1659 | states.currentRow = info ? info.row : null;
|
1660 | };
|
1661 |
|
1662 | TableStore.prototype.updateCurrentRow = function () {
|
1663 | var states = this.states;
|
1664 | var table = this.table;
|
1665 | var data = states.data || [];
|
1666 | var oldCurrentRow = states.currentRow;
|
1667 |
|
1668 | if (data.indexOf(oldCurrentRow) === -1) {
|
1669 | states.currentRow = null;
|
1670 |
|
1671 | if (states.currentRow !== oldCurrentRow) {
|
1672 | table.$emit('current-change', null, oldCurrentRow);
|
1673 | }
|
1674 | }
|
1675 | };
|
1676 |
|
1677 | TableStore.prototype.commit = function (name) {
|
1678 | var mutations = this.mutations;
|
1679 | if (mutations[name]) {
|
1680 | for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
1681 | args[_key - 1] = arguments[_key];
|
1682 | }
|
1683 |
|
1684 | mutations[name].apply(this, [this.states].concat(args));
|
1685 | } else {
|
1686 | throw new Error('Action not found: ' + name);
|
1687 | }
|
1688 | };
|
1689 |
|
1690 | exports.default = TableStore;
|
1691 |
|
1692 | }),
|
1693 |
|
1694 | 165:
|
1695 | (function(module, exports, __webpack_require__) {
|
1696 |
|
1697 | "use strict";
|
1698 |
|
1699 |
|
1700 | exports.__esModule = true;
|
1701 |
|
1702 | var _scrollbarWidth = __webpack_require__(38);
|
1703 |
|
1704 | var _scrollbarWidth2 = _interopRequireDefault(_scrollbarWidth);
|
1705 |
|
1706 | var _vue = __webpack_require__(4);
|
1707 |
|
1708 | var _vue2 = _interopRequireDefault(_vue);
|
1709 |
|
1710 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
1711 |
|
1712 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
1713 |
|
1714 | var TableLayout = function () {
|
1715 | function TableLayout(options) {
|
1716 | _classCallCheck(this, TableLayout);
|
1717 |
|
1718 | this.observers = [];
|
1719 | this.table = null;
|
1720 | this.store = null;
|
1721 | this.columns = null;
|
1722 | this.fit = true;
|
1723 | this.showHeader = true;
|
1724 |
|
1725 | this.height = null;
|
1726 | this.scrollX = false;
|
1727 | this.scrollY = false;
|
1728 | this.bodyWidth = null;
|
1729 | this.fixedWidth = null;
|
1730 | this.rightFixedWidth = null;
|
1731 | this.tableHeight = null;
|
1732 | this.headerHeight = 44;
|
1733 | this.appendHeight = 0;
|
1734 | this.footerHeight = 44;
|
1735 | this.viewportHeight = null;
|
1736 | this.bodyHeight = null;
|
1737 | this.fixedBodyHeight = null;
|
1738 | this.gutterWidth = (0, _scrollbarWidth2.default)();
|
1739 |
|
1740 | for (var name in options) {
|
1741 | if (options.hasOwnProperty(name)) {
|
1742 | this[name] = options[name];
|
1743 | }
|
1744 | }
|
1745 |
|
1746 | if (!this.table) {
|
1747 | throw new Error('table is required for Table Layout');
|
1748 | }
|
1749 | if (!this.store) {
|
1750 | throw new Error('store is required for Table Layout');
|
1751 | }
|
1752 | }
|
1753 |
|
1754 | TableLayout.prototype.updateScrollY = function updateScrollY() {
|
1755 | var height = this.height;
|
1756 | if (typeof height !== 'string' && typeof height !== 'number') return;
|
1757 | var bodyWrapper = this.table.bodyWrapper;
|
1758 | if (this.table.$el && bodyWrapper) {
|
1759 | var body = bodyWrapper.querySelector('.el-table__body');
|
1760 | this.scrollY = body.offsetHeight > this.bodyHeight;
|
1761 | }
|
1762 | };
|
1763 |
|
1764 | TableLayout.prototype.setHeight = function setHeight(value) {
|
1765 | var _this = this;
|
1766 |
|
1767 | var prop = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'height';
|
1768 |
|
1769 | if (_vue2.default.prototype.$isServer) return;
|
1770 | var el = this.table.$el;
|
1771 | if (typeof value === 'string' && /^\d+$/.test(value)) {
|
1772 | value = Number(value);
|
1773 | }
|
1774 | this.height = value;
|
1775 |
|
1776 | if (!el && (value || value === 0)) return _vue2.default.nextTick(function () {
|
1777 | return _this.setHeight(value, prop);
|
1778 | });
|
1779 |
|
1780 | if (typeof value === 'number') {
|
1781 | el.style[prop] = value + 'px';
|
1782 |
|
1783 | this.updateElsHeight();
|
1784 | } else if (typeof value === 'string') {
|
1785 | el.style[prop] = value;
|
1786 | this.updateElsHeight();
|
1787 | }
|
1788 | };
|
1789 |
|
1790 | TableLayout.prototype.setMaxHeight = function setMaxHeight(value) {
|
1791 | return this.setHeight(value, 'max-height');
|
1792 | };
|
1793 |
|
1794 | TableLayout.prototype.updateElsHeight = function updateElsHeight() {
|
1795 | var _this2 = this;
|
1796 |
|
1797 | if (!this.table.$ready) return _vue2.default.nextTick(function () {
|
1798 | return _this2.updateElsHeight();
|
1799 | });
|
1800 | var _table$$refs = this.table.$refs,
|
1801 | headerWrapper = _table$$refs.headerWrapper,
|
1802 | appendWrapper = _table$$refs.appendWrapper,
|
1803 | footerWrapper = _table$$refs.footerWrapper;
|
1804 |
|
1805 | this.appendHeight = appendWrapper ? appendWrapper.offsetHeight : 0;
|
1806 |
|
1807 | if (this.showHeader && !headerWrapper) return;
|
1808 | var headerHeight = this.headerHeight = !this.showHeader ? 0 : headerWrapper.offsetHeight;
|
1809 | if (this.showHeader && headerWrapper.offsetWidth > 0 && (this.table.columns || []).length > 0 && headerHeight < 2) {
|
1810 | return _vue2.default.nextTick(function () {
|
1811 | return _this2.updateElsHeight();
|
1812 | });
|
1813 | }
|
1814 | var tableHeight = this.tableHeight = this.table.$el.clientHeight;
|
1815 | if (this.height !== null && (!isNaN(this.height) || typeof this.height === 'string')) {
|
1816 | var footerHeight = this.footerHeight = footerWrapper ? footerWrapper.offsetHeight : 0;
|
1817 | this.bodyHeight = tableHeight - headerHeight - footerHeight + (footerWrapper ? 1 : 0);
|
1818 | }
|
1819 | this.fixedBodyHeight = this.scrollX ? this.bodyHeight - this.gutterWidth : this.bodyHeight;
|
1820 |
|
1821 | var noData = !this.table.data || this.table.data.length === 0;
|
1822 | this.viewportHeight = this.scrollX ? tableHeight - (noData ? 0 : this.gutterWidth) : tableHeight;
|
1823 |
|
1824 | this.updateScrollY();
|
1825 | this.notifyObservers('scrollable');
|
1826 | };
|
1827 |
|
1828 | TableLayout.prototype.getFlattenColumns = function getFlattenColumns() {
|
1829 | var flattenColumns = [];
|
1830 | var columns = this.table.columns;
|
1831 | columns.forEach(function (column) {
|
1832 | if (column.isColumnGroup) {
|
1833 | flattenColumns.push.apply(flattenColumns, column.columns);
|
1834 | } else {
|
1835 | flattenColumns.push(column);
|
1836 | }
|
1837 | });
|
1838 |
|
1839 | return flattenColumns;
|
1840 | };
|
1841 |
|
1842 | TableLayout.prototype.updateColumnsWidth = function updateColumnsWidth() {
|
1843 | if (_vue2.default.prototype.$isServer) return;
|
1844 | var fit = this.fit;
|
1845 | var bodyWidth = this.table.$el.clientWidth;
|
1846 | var bodyMinWidth = 0;
|
1847 |
|
1848 | var flattenColumns = this.getFlattenColumns();
|
1849 | var flexColumns = flattenColumns.filter(function (column) {
|
1850 | return typeof column.width !== 'number';
|
1851 | });
|
1852 |
|
1853 | flattenColumns.forEach(function (column) {
|
1854 |
|
1855 | if (typeof column.width === 'number' && column.realWidth) column.realWidth = null;
|
1856 | });
|
1857 |
|
1858 | if (flexColumns.length > 0 && fit) {
|
1859 | flattenColumns.forEach(function (column) {
|
1860 | bodyMinWidth += column.width || column.minWidth || 80;
|
1861 | });
|
1862 |
|
1863 | var scrollYWidth = this.scrollY ? this.gutterWidth : 0;
|
1864 |
|
1865 | if (bodyMinWidth <= bodyWidth - scrollYWidth) {
|
1866 |
|
1867 | this.scrollX = false;
|
1868 |
|
1869 | var totalFlexWidth = bodyWidth - scrollYWidth - bodyMinWidth;
|
1870 |
|
1871 | if (flexColumns.length === 1) {
|
1872 | flexColumns[0].realWidth = (flexColumns[0].minWidth || 80) + totalFlexWidth;
|
1873 | } else {
|
1874 | (function () {
|
1875 | var allColumnsWidth = flexColumns.reduce(function (prev, column) {
|
1876 | return prev + (column.minWidth || 80);
|
1877 | }, 0);
|
1878 | var flexWidthPerPixel = totalFlexWidth / allColumnsWidth;
|
1879 | var noneFirstWidth = 0;
|
1880 |
|
1881 | flexColumns.forEach(function (column, index) {
|
1882 | if (index === 0) return;
|
1883 | var flexWidth = Math.floor((column.minWidth || 80) * flexWidthPerPixel);
|
1884 | noneFirstWidth += flexWidth;
|
1885 | column.realWidth = (column.minWidth || 80) + flexWidth;
|
1886 | });
|
1887 |
|
1888 | flexColumns[0].realWidth = (flexColumns[0].minWidth || 80) + totalFlexWidth - noneFirstWidth;
|
1889 | })();
|
1890 | }
|
1891 | } else {
|
1892 |
|
1893 | this.scrollX = true;
|
1894 | flexColumns.forEach(function (column) {
|
1895 | column.realWidth = column.minWidth;
|
1896 | });
|
1897 | }
|
1898 |
|
1899 | this.bodyWidth = Math.max(bodyMinWidth, bodyWidth);
|
1900 | this.table.resizeState.width = this.bodyWidth;
|
1901 | } else {
|
1902 | flattenColumns.forEach(function (column) {
|
1903 | if (!column.width && !column.minWidth) {
|
1904 | column.realWidth = 80;
|
1905 | } else {
|
1906 | column.realWidth = column.width || column.minWidth;
|
1907 | }
|
1908 |
|
1909 | bodyMinWidth += column.realWidth;
|
1910 | });
|
1911 | this.scrollX = bodyMinWidth > bodyWidth;
|
1912 |
|
1913 | this.bodyWidth = bodyMinWidth;
|
1914 | }
|
1915 |
|
1916 | var fixedColumns = this.store.states.fixedColumns;
|
1917 |
|
1918 | if (fixedColumns.length > 0) {
|
1919 | var fixedWidth = 0;
|
1920 | fixedColumns.forEach(function (column) {
|
1921 | fixedWidth += column.realWidth || column.width;
|
1922 | });
|
1923 |
|
1924 | this.fixedWidth = fixedWidth;
|
1925 | }
|
1926 |
|
1927 | var rightFixedColumns = this.store.states.rightFixedColumns;
|
1928 | if (rightFixedColumns.length > 0) {
|
1929 | var rightFixedWidth = 0;
|
1930 | rightFixedColumns.forEach(function (column) {
|
1931 | rightFixedWidth += column.realWidth || column.width;
|
1932 | });
|
1933 |
|
1934 | this.rightFixedWidth = rightFixedWidth;
|
1935 | }
|
1936 |
|
1937 | this.notifyObservers('columns');
|
1938 | };
|
1939 |
|
1940 | TableLayout.prototype.addObserver = function addObserver(observer) {
|
1941 | this.observers.push(observer);
|
1942 | };
|
1943 |
|
1944 | TableLayout.prototype.removeObserver = function removeObserver(observer) {
|
1945 | var index = this.observers.indexOf(observer);
|
1946 | if (index !== -1) {
|
1947 | this.observers.splice(index, 1);
|
1948 | }
|
1949 | };
|
1950 |
|
1951 | TableLayout.prototype.notifyObservers = function notifyObservers(event) {
|
1952 | var _this3 = this;
|
1953 |
|
1954 | var observers = this.observers;
|
1955 | observers.forEach(function (observer) {
|
1956 | switch (event) {
|
1957 | case 'columns':
|
1958 | observer.onColumnsChange(_this3);
|
1959 | break;
|
1960 | case 'scrollable':
|
1961 | observer.onScrollableChange(_this3);
|
1962 | break;
|
1963 | default:
|
1964 | throw new Error('Table Layout don\'t have event ' + event + '.');
|
1965 | }
|
1966 | });
|
1967 | };
|
1968 |
|
1969 | return TableLayout;
|
1970 | }();
|
1971 |
|
1972 | exports.default = TableLayout;
|
1973 |
|
1974 | }),
|
1975 |
|
1976 | 166:
|
1977 | (function(module, exports, __webpack_require__) {
|
1978 |
|
1979 | "use strict";
|
1980 |
|
1981 |
|
1982 | exports.__esModule = true;
|
1983 |
|
1984 | 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; };
|
1985 |
|
1986 | var _util = __webpack_require__(48);
|
1987 |
|
1988 | var _dom = __webpack_require__(3);
|
1989 |
|
1990 | var _checkbox = __webpack_require__(16);
|
1991 |
|
1992 | var _checkbox2 = _interopRequireDefault(_checkbox);
|
1993 |
|
1994 | var _tooltip = __webpack_require__(22);
|
1995 |
|
1996 | var _tooltip2 = _interopRequireDefault(_tooltip);
|
1997 |
|
1998 | var _debounce = __webpack_require__(14);
|
1999 |
|
2000 | var _debounce2 = _interopRequireDefault(_debounce);
|
2001 |
|
2002 | var _layoutObserver = __webpack_require__(39);
|
2003 |
|
2004 | var _layoutObserver2 = _interopRequireDefault(_layoutObserver);
|
2005 |
|
2006 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
2007 |
|
2008 | exports.default = {
|
2009 | name: 'ElTableBody',
|
2010 |
|
2011 | mixins: [_layoutObserver2.default],
|
2012 |
|
2013 | components: {
|
2014 | ElCheckbox: _checkbox2.default,
|
2015 | ElTooltip: _tooltip2.default
|
2016 | },
|
2017 |
|
2018 | props: {
|
2019 | store: {
|
2020 | required: true
|
2021 | },
|
2022 | stripe: Boolean,
|
2023 | context: {},
|
2024 | rowClassName: [String, Function],
|
2025 | rowStyle: [Object, Function],
|
2026 | fixed: String,
|
2027 | highlight: Boolean
|
2028 | },
|
2029 |
|
2030 | render: function render(h) {
|
2031 | var _this = this;
|
2032 |
|
2033 | var columnsHidden = this.columns.map(function (column, index) {
|
2034 | return _this.isColumnHidden(index);
|
2035 | });
|
2036 | return h(
|
2037 | 'table',
|
2038 | {
|
2039 | 'class': 'el-table__body',
|
2040 | attrs: { cellspacing: '0',
|
2041 | cellpadding: '0',
|
2042 | border: '0' }
|
2043 | },
|
2044 | [h(
|
2045 | 'colgroup',
|
2046 | null,
|
2047 | [this._l(this.columns, function (column) {
|
2048 | return h(
|
2049 | 'col',
|
2050 | {
|
2051 | attrs: { name: column.id }
|
2052 | },
|
2053 | []
|
2054 | );
|
2055 | })]
|
2056 | ), h(
|
2057 | 'tbody',
|
2058 | null,
|
2059 | [this._l(this.data, function (row, $index) {
|
2060 | return [h(
|
2061 | 'tr',
|
2062 | {
|
2063 | style: _this.rowStyle ? _this.getRowStyle(row, $index) : null,
|
2064 | key: _this.table.rowKey ? _this.getKeyOfRow(row, $index) : $index,
|
2065 | on: {
|
2066 | 'dblclick': function dblclick($event) {
|
2067 | return _this.handleDoubleClick($event, row);
|
2068 | },
|
2069 | 'click': function click($event) {
|
2070 | return _this.handleClick($event, row);
|
2071 | },
|
2072 | 'contextmenu': function contextmenu($event) {
|
2073 | return _this.handleContextMenu($event, row);
|
2074 | },
|
2075 | 'mouseenter': function mouseenter(_) {
|
2076 | return _this.handleMouseEnter($index);
|
2077 | },
|
2078 | 'mouseleave': function mouseleave(_) {
|
2079 | return _this.handleMouseLeave();
|
2080 | }
|
2081 | },
|
2082 |
|
2083 | 'class': [_this.getRowClass(row, $index)] },
|
2084 | [_this._l(_this.columns, function (column, cellIndex) {
|
2085 | var _getSpan = _this.getSpan(row, column, $index, cellIndex),
|
2086 | rowspan = _getSpan.rowspan,
|
2087 | colspan = _getSpan.colspan;
|
2088 |
|
2089 | if (!rowspan || !colspan) {
|
2090 | return '';
|
2091 | } else {
|
2092 | return h(
|
2093 | 'td',
|
2094 | {
|
2095 | style: _this.getCellStyle($index, cellIndex, row, column),
|
2096 | 'class': _this.getCellClass($index, cellIndex, row, column),
|
2097 | attrs: { rowspan: rowspan,
|
2098 | colspan: colspan
|
2099 | },
|
2100 | on: {
|
2101 | 'mouseenter': function mouseenter($event) {
|
2102 | return _this.handleCellMouseEnter($event, row);
|
2103 | },
|
2104 | 'mouseleave': _this.handleCellMouseLeave
|
2105 | }
|
2106 | },
|
2107 | [column.renderCell.call(_this._renderProxy, h, {
|
2108 | row: row,
|
2109 | column: column,
|
2110 | $index: $index,
|
2111 | store: _this.store,
|
2112 | _self: _this.context || _this.table.$vnode.context
|
2113 | }, columnsHidden[cellIndex])]
|
2114 | );
|
2115 | }
|
2116 | })]
|
2117 | ), _this.store.isRowExpanded(row) ? h(
|
2118 | 'tr',
|
2119 | null,
|
2120 | [h(
|
2121 | 'td',
|
2122 | {
|
2123 | attrs: { colspan: _this.columns.length },
|
2124 | 'class': 'el-table__expanded-cell' },
|
2125 | [_this.table.renderExpanded ? _this.table.renderExpanded(h, { row: row, $index: $index, store: _this.store }) : '']
|
2126 | )]
|
2127 | ) : ''];
|
2128 | }).concat(h(
|
2129 | 'el-tooltip',
|
2130 | {
|
2131 | attrs: { effect: this.table.tooltipEffect, placement: 'top', content: this.tooltipContent },
|
2132 | ref: 'tooltip' },
|
2133 | []
|
2134 | ))]
|
2135 | )]
|
2136 | );
|
2137 | },
|
2138 |
|
2139 |
|
2140 | watch: {
|
2141 | 'store.states.hoverRow': function storeStatesHoverRow(newVal, oldVal) {
|
2142 | if (!this.store.states.isComplex) return;
|
2143 | var el = this.$el;
|
2144 | if (!el) return;
|
2145 | var tr = el.querySelector('tbody').children;
|
2146 | var rows = [].filter.call(tr, function (row) {
|
2147 | return (0, _dom.hasClass)(row, 'el-table__row');
|
2148 | });
|
2149 | var oldRow = rows[oldVal];
|
2150 | var newRow = rows[newVal];
|
2151 | if (oldRow) {
|
2152 | (0, _dom.removeClass)(oldRow, 'hover-row');
|
2153 | }
|
2154 | if (newRow) {
|
2155 | (0, _dom.addClass)(newRow, 'hover-row');
|
2156 | }
|
2157 | },
|
2158 | 'store.states.currentRow': function storeStatesCurrentRow(newVal, oldVal) {
|
2159 | if (!this.highlight) return;
|
2160 | var el = this.$el;
|
2161 | if (!el) return;
|
2162 | var data = this.store.states.data;
|
2163 | var tr = el.querySelector('tbody').children;
|
2164 | var rows = [].filter.call(tr, function (row) {
|
2165 | return (0, _dom.hasClass)(row, 'el-table__row');
|
2166 | });
|
2167 | var oldRow = rows[data.indexOf(oldVal)];
|
2168 | var newRow = rows[data.indexOf(newVal)];
|
2169 | if (oldRow) {
|
2170 | (0, _dom.removeClass)(oldRow, 'current-row');
|
2171 | } else {
|
2172 | [].forEach.call(rows, function (row) {
|
2173 | return (0, _dom.removeClass)(row, 'current-row');
|
2174 | });
|
2175 | }
|
2176 | if (newRow) {
|
2177 | (0, _dom.addClass)(newRow, 'current-row');
|
2178 | }
|
2179 | }
|
2180 | },
|
2181 |
|
2182 | computed: {
|
2183 | table: function table() {
|
2184 | return this.$parent;
|
2185 | },
|
2186 | data: function data() {
|
2187 | return this.store.states.data;
|
2188 | },
|
2189 | columnsCount: function columnsCount() {
|
2190 | return this.store.states.columns.length;
|
2191 | },
|
2192 | leftFixedLeafCount: function leftFixedLeafCount() {
|
2193 | return this.store.states.fixedLeafColumnsLength;
|
2194 | },
|
2195 | rightFixedLeafCount: function rightFixedLeafCount() {
|
2196 | return this.store.states.rightFixedLeafColumnsLength;
|
2197 | },
|
2198 | leftFixedCount: function leftFixedCount() {
|
2199 | return this.store.states.fixedColumns.length;
|
2200 | },
|
2201 | rightFixedCount: function rightFixedCount() {
|
2202 | return this.store.states.rightFixedColumns.length;
|
2203 | },
|
2204 | columns: function columns() {
|
2205 | return this.store.states.columns;
|
2206 | }
|
2207 | },
|
2208 |
|
2209 | data: function data() {
|
2210 | return {
|
2211 | tooltipContent: ''
|
2212 | };
|
2213 | },
|
2214 | created: function created() {
|
2215 | this.activateTooltip = (0, _debounce2.default)(50, function (tooltip) {
|
2216 | return tooltip.handleShowPopper();
|
2217 | });
|
2218 | },
|
2219 |
|
2220 |
|
2221 | methods: {
|
2222 | getKeyOfRow: function getKeyOfRow(row, index) {
|
2223 | var rowKey = this.table.rowKey;
|
2224 | if (rowKey) {
|
2225 | return (0, _util.getRowIdentity)(row, rowKey);
|
2226 | }
|
2227 | return index;
|
2228 | },
|
2229 | isColumnHidden: function isColumnHidden(index) {
|
2230 | if (this.fixed === true || this.fixed === 'left') {
|
2231 | return index >= this.leftFixedLeafCount;
|
2232 | } else if (this.fixed === 'right') {
|
2233 | return index < this.columnsCount - this.rightFixedLeafCount;
|
2234 | } else {
|
2235 | return index < this.leftFixedLeafCount || index >= this.columnsCount - this.rightFixedLeafCount;
|
2236 | }
|
2237 | },
|
2238 | getSpan: function getSpan(row, column, rowIndex, columnIndex) {
|
2239 | var rowspan = 1;
|
2240 | var colspan = 1;
|
2241 |
|
2242 | var fn = this.table.spanMethod;
|
2243 | if (typeof fn === 'function') {
|
2244 | var result = fn({
|
2245 | row: row,
|
2246 | column: column,
|
2247 | rowIndex: rowIndex,
|
2248 | columnIndex: columnIndex
|
2249 | });
|
2250 |
|
2251 | if (Array.isArray(result)) {
|
2252 | rowspan = result[0];
|
2253 | colspan = result[1];
|
2254 | } else if ((typeof result === 'undefined' ? 'undefined' : _typeof(result)) === 'object') {
|
2255 | rowspan = result.rowspan;
|
2256 | colspan = result.colspan;
|
2257 | }
|
2258 | }
|
2259 |
|
2260 | return {
|
2261 | rowspan: rowspan,
|
2262 | colspan: colspan
|
2263 | };
|
2264 | },
|
2265 | getRowStyle: function getRowStyle(row, rowIndex) {
|
2266 | var rowStyle = this.table.rowStyle;
|
2267 | if (typeof rowStyle === 'function') {
|
2268 | return rowStyle.call(null, {
|
2269 | row: row,
|
2270 | rowIndex: rowIndex
|
2271 | });
|
2272 | }
|
2273 | return rowStyle;
|
2274 | },
|
2275 | getRowClass: function getRowClass(row, rowIndex) {
|
2276 | var classes = ['el-table__row'];
|
2277 | if (this.table.highlightCurrentRow && row === this.store.states.currentRow) {
|
2278 | classes.push('current-row');
|
2279 | }
|
2280 |
|
2281 | if (this.stripe && rowIndex % 2 === 1) {
|
2282 | classes.push('el-table__row--striped');
|
2283 | }
|
2284 | var rowClassName = this.table.rowClassName;
|
2285 | if (typeof rowClassName === 'string') {
|
2286 | classes.push(rowClassName);
|
2287 | } else if (typeof rowClassName === 'function') {
|
2288 | classes.push(rowClassName.call(null, {
|
2289 | row: row,
|
2290 | rowIndex: rowIndex
|
2291 | }));
|
2292 | }
|
2293 |
|
2294 | if (this.store.states.expandRows.indexOf(row) > -1) {
|
2295 | classes.push('expanded');
|
2296 | }
|
2297 |
|
2298 | return classes.join(' ');
|
2299 | },
|
2300 | getCellStyle: function getCellStyle(rowIndex, columnIndex, row, column) {
|
2301 | var cellStyle = this.table.cellStyle;
|
2302 | if (typeof cellStyle === 'function') {
|
2303 | return cellStyle.call(null, {
|
2304 | rowIndex: rowIndex,
|
2305 | columnIndex: columnIndex,
|
2306 | row: row,
|
2307 | column: column
|
2308 | });
|
2309 | }
|
2310 | return cellStyle;
|
2311 | },
|
2312 | getCellClass: function getCellClass(rowIndex, columnIndex, row, column) {
|
2313 | var classes = [column.id, column.align, column.className];
|
2314 |
|
2315 | if (this.isColumnHidden(columnIndex)) {
|
2316 | classes.push('is-hidden');
|
2317 | }
|
2318 |
|
2319 | var cellClassName = this.table.cellClassName;
|
2320 | if (typeof cellClassName === 'string') {
|
2321 | classes.push(cellClassName);
|
2322 | } else if (typeof cellClassName === 'function') {
|
2323 | classes.push(cellClassName.call(null, {
|
2324 | rowIndex: rowIndex,
|
2325 | columnIndex: columnIndex,
|
2326 | row: row,
|
2327 | column: column
|
2328 | }));
|
2329 | }
|
2330 |
|
2331 | return classes.join(' ');
|
2332 | },
|
2333 | handleCellMouseEnter: function handleCellMouseEnter(event, row) {
|
2334 | var table = this.table;
|
2335 | var cell = (0, _util.getCell)(event);
|
2336 |
|
2337 | if (cell) {
|
2338 | var column = (0, _util.getColumnByCell)(table, cell);
|
2339 | var hoverState = table.hoverState = { cell: cell, column: column, row: row };
|
2340 | table.$emit('cell-mouse-enter', hoverState.row, hoverState.column, hoverState.cell, event);
|
2341 | }
|
2342 |
|
2343 |
|
2344 | var cellChild = event.target.querySelector('.cell');
|
2345 | if (!(0, _dom.hasClass)(cellChild, 'el-tooltip')) {
|
2346 | return;
|
2347 | }
|
2348 |
|
2349 |
|
2350 | var range = document.createRange();
|
2351 | range.setStart(cellChild, 0);
|
2352 | range.setEnd(cellChild, cellChild.childNodes.length);
|
2353 | var rangeWidth = range.getBoundingClientRect().width;
|
2354 | var padding = (parseInt((0, _dom.getStyle)(cellChild, 'paddingLeft'), 10) || 0) + (parseInt((0, _dom.getStyle)(cellChild, 'paddingRight'), 10) || 0);
|
2355 | if ((rangeWidth + padding > cellChild.offsetWidth || cellChild.scrollWidth > cellChild.offsetWidth) && this.$refs.tooltip) {
|
2356 | var tooltip = this.$refs.tooltip;
|
2357 |
|
2358 | this.tooltipContent = cell.textContent || cell.innerText;
|
2359 | tooltip.referenceElm = cell;
|
2360 | tooltip.$refs.popper && (tooltip.$refs.popper.style.display = 'none');
|
2361 | tooltip.doDestroy();
|
2362 | tooltip.setExpectedState(true);
|
2363 | this.activateTooltip(tooltip);
|
2364 | }
|
2365 | },
|
2366 | handleCellMouseLeave: function handleCellMouseLeave(event) {
|
2367 | var tooltip = this.$refs.tooltip;
|
2368 | if (tooltip) {
|
2369 | tooltip.setExpectedState(false);
|
2370 | tooltip.handleClosePopper();
|
2371 | }
|
2372 | var cell = (0, _util.getCell)(event);
|
2373 | if (!cell) return;
|
2374 |
|
2375 | var oldHoverState = this.table.hoverState || {};
|
2376 | this.table.$emit('cell-mouse-leave', oldHoverState.row, oldHoverState.column, oldHoverState.cell, event);
|
2377 | },
|
2378 | handleMouseEnter: function handleMouseEnter(index) {
|
2379 | this.store.commit('setHoverRow', index);
|
2380 | },
|
2381 | handleMouseLeave: function handleMouseLeave() {
|
2382 | this.store.commit('setHoverRow', null);
|
2383 | },
|
2384 | handleContextMenu: function handleContextMenu(event, row) {
|
2385 | this.handleEvent(event, row, 'contextmenu');
|
2386 | },
|
2387 | handleDoubleClick: function handleDoubleClick(event, row) {
|
2388 | this.handleEvent(event, row, 'dblclick');
|
2389 | },
|
2390 | handleClick: function handleClick(event, row) {
|
2391 | this.store.commit('setCurrentRow', row);
|
2392 | this.handleEvent(event, row, 'click');
|
2393 | },
|
2394 | handleEvent: function handleEvent(event, row, name) {
|
2395 | var table = this.table;
|
2396 | var cell = (0, _util.getCell)(event);
|
2397 | var column = void 0;
|
2398 | if (cell) {
|
2399 | column = (0, _util.getColumnByCell)(table, cell);
|
2400 | if (column) {
|
2401 | table.$emit('cell-' + name, row, column, cell, event);
|
2402 | }
|
2403 | }
|
2404 | table.$emit('row-' + name, row, event, column);
|
2405 | },
|
2406 | handleExpandClick: function handleExpandClick(row, e) {
|
2407 | e.stopPropagation();
|
2408 | this.store.toggleRowExpansion(row);
|
2409 | }
|
2410 | }
|
2411 | };
|
2412 |
|
2413 | }),
|
2414 |
|
2415 | 167:
|
2416 | (function(module, exports, __webpack_require__) {
|
2417 |
|
2418 | "use strict";
|
2419 |
|
2420 |
|
2421 | exports.__esModule = true;
|
2422 |
|
2423 | var _dom = __webpack_require__(3);
|
2424 |
|
2425 | var _checkbox = __webpack_require__(16);
|
2426 |
|
2427 | var _checkbox2 = _interopRequireDefault(_checkbox);
|
2428 |
|
2429 | var _tag = __webpack_require__(25);
|
2430 |
|
2431 | var _tag2 = _interopRequireDefault(_tag);
|
2432 |
|
2433 | var _vue = __webpack_require__(4);
|
2434 |
|
2435 | var _vue2 = _interopRequireDefault(_vue);
|
2436 |
|
2437 | var _filterPanel = __webpack_require__(168);
|
2438 |
|
2439 | var _filterPanel2 = _interopRequireDefault(_filterPanel);
|
2440 |
|
2441 | var _layoutObserver = __webpack_require__(39);
|
2442 |
|
2443 | var _layoutObserver2 = _interopRequireDefault(_layoutObserver);
|
2444 |
|
2445 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
2446 |
|
2447 | var getAllColumns = function getAllColumns(columns) {
|
2448 | var result = [];
|
2449 | columns.forEach(function (column) {
|
2450 | if (column.children) {
|
2451 | result.push(column);
|
2452 | result.push.apply(result, getAllColumns(column.children));
|
2453 | } else {
|
2454 | result.push(column);
|
2455 | }
|
2456 | });
|
2457 | return result;
|
2458 | };
|
2459 |
|
2460 | var convertToRows = function convertToRows(originColumns) {
|
2461 | var maxLevel = 1;
|
2462 | var traverse = function traverse(column, parent) {
|
2463 | if (parent) {
|
2464 | column.level = parent.level + 1;
|
2465 | if (maxLevel < column.level) {
|
2466 | maxLevel = column.level;
|
2467 | }
|
2468 | }
|
2469 | if (column.children) {
|
2470 | var colSpan = 0;
|
2471 | column.children.forEach(function (subColumn) {
|
2472 | traverse(subColumn, column);
|
2473 | colSpan += subColumn.colSpan;
|
2474 | });
|
2475 | column.colSpan = colSpan;
|
2476 | } else {
|
2477 | column.colSpan = 1;
|
2478 | }
|
2479 | };
|
2480 |
|
2481 | originColumns.forEach(function (column) {
|
2482 | column.level = 1;
|
2483 | traverse(column);
|
2484 | });
|
2485 |
|
2486 | var rows = [];
|
2487 | for (var i = 0; i < maxLevel; i++) {
|
2488 | rows.push([]);
|
2489 | }
|
2490 |
|
2491 | var allColumns = getAllColumns(originColumns);
|
2492 |
|
2493 | allColumns.forEach(function (column) {
|
2494 | if (!column.children) {
|
2495 | column.rowSpan = maxLevel - column.level + 1;
|
2496 | } else {
|
2497 | column.rowSpan = 1;
|
2498 | }
|
2499 | rows[column.level - 1].push(column);
|
2500 | });
|
2501 |
|
2502 | return rows;
|
2503 | };
|
2504 |
|
2505 | exports.default = {
|
2506 | name: 'ElTableHeader',
|
2507 |
|
2508 | mixins: [_layoutObserver2.default],
|
2509 |
|
2510 | render: function render(h) {
|
2511 | var _this = this;
|
2512 |
|
2513 | var originColumns = this.store.states.originColumns;
|
2514 | var columnRows = convertToRows(originColumns, this.columns);
|
2515 |
|
2516 | var isGroup = columnRows.length > 1;
|
2517 | if (isGroup) this.$parent.isGroup = true;
|
2518 | return h(
|
2519 | 'table',
|
2520 | {
|
2521 | 'class': 'el-table__header',
|
2522 | attrs: { cellspacing: '0',
|
2523 | cellpadding: '0',
|
2524 | border: '0' }
|
2525 | },
|
2526 | [h(
|
2527 | 'colgroup',
|
2528 | null,
|
2529 | [this._l(this.columns, function (column) {
|
2530 | return h(
|
2531 | 'col',
|
2532 | {
|
2533 | attrs: { name: column.id }
|
2534 | },
|
2535 | []
|
2536 | );
|
2537 | }), this.hasGutter ? h(
|
2538 | 'col',
|
2539 | {
|
2540 | attrs: { name: 'gutter' }
|
2541 | },
|
2542 | []
|
2543 | ) : '']
|
2544 | ), h(
|
2545 | 'thead',
|
2546 | { 'class': [{ 'is-group': isGroup, 'has-gutter': this.hasGutter }] },
|
2547 | [this._l(columnRows, function (columns, rowIndex) {
|
2548 | return h(
|
2549 | 'tr',
|
2550 | {
|
2551 | style: _this.getHeaderRowStyle(rowIndex),
|
2552 | 'class': _this.getHeaderRowClass(rowIndex)
|
2553 | },
|
2554 | [_this._l(columns, function (column, cellIndex) {
|
2555 | return h(
|
2556 | 'th',
|
2557 | {
|
2558 | attrs: {
|
2559 | colspan: column.colSpan,
|
2560 | rowspan: column.rowSpan
|
2561 | },
|
2562 | on: {
|
2563 | 'mousemove': function mousemove($event) {
|
2564 | return _this.handleMouseMove($event, column);
|
2565 | },
|
2566 | 'mouseout': _this.handleMouseOut,
|
2567 | 'mousedown': function mousedown($event) {
|
2568 | return _this.handleMouseDown($event, column);
|
2569 | },
|
2570 | 'click': function click($event) {
|
2571 | return _this.handleHeaderClick($event, column);
|
2572 | },
|
2573 | 'contextmenu': function contextmenu($event) {
|
2574 | return _this.handleHeaderContextMenu($event, column);
|
2575 | }
|
2576 | },
|
2577 |
|
2578 | style: _this.getHeaderCellStyle(rowIndex, cellIndex, columns, column),
|
2579 | 'class': _this.getHeaderCellClass(rowIndex, cellIndex, columns, column) },
|
2580 | [h(
|
2581 | 'div',
|
2582 | { 'class': ['cell', column.filteredValue && column.filteredValue.length > 0 ? 'highlight' : '', column.labelClassName] },
|
2583 | [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(
|
2584 | 'span',
|
2585 | { 'class': 'caret-wrapper', on: {
|
2586 | 'click': function click($event) {
|
2587 | return _this.handleSortClick($event, column);
|
2588 | }
|
2589 | }
|
2590 | },
|
2591 | [h(
|
2592 | 'i',
|
2593 | { 'class': 'sort-caret ascending', on: {
|
2594 | 'click': function click($event) {
|
2595 | return _this.handleSortClick($event, column, 'ascending');
|
2596 | }
|
2597 | }
|
2598 | },
|
2599 | []
|
2600 | ), h(
|
2601 | 'i',
|
2602 | { 'class': 'sort-caret descending', on: {
|
2603 | 'click': function click($event) {
|
2604 | return _this.handleSortClick($event, column, 'descending');
|
2605 | }
|
2606 | }
|
2607 | },
|
2608 | []
|
2609 | )]
|
2610 | ) : '', column.filterable ? h(
|
2611 | 'span',
|
2612 | { 'class': 'el-table__column-filter-trigger', on: {
|
2613 | 'click': function click($event) {
|
2614 | return _this.handleFilterClick($event, column);
|
2615 | }
|
2616 | }
|
2617 | },
|
2618 | [h(
|
2619 | 'i',
|
2620 | { 'class': ['el-icon-arrow-down', column.filterOpened ? 'el-icon-arrow-up' : ''] },
|
2621 | []
|
2622 | )]
|
2623 | ) : '']
|
2624 | )]
|
2625 | );
|
2626 | }), _this.hasGutter ? h(
|
2627 | 'th',
|
2628 | { 'class': 'gutter' },
|
2629 | []
|
2630 | ) : '']
|
2631 | );
|
2632 | })]
|
2633 | )]
|
2634 | );
|
2635 | },
|
2636 |
|
2637 |
|
2638 | props: {
|
2639 | fixed: String,
|
2640 | store: {
|
2641 | required: true
|
2642 | },
|
2643 | border: Boolean,
|
2644 | defaultSort: {
|
2645 | type: Object,
|
2646 | default: function _default() {
|
2647 | return {
|
2648 | prop: '',
|
2649 | order: ''
|
2650 | };
|
2651 | }
|
2652 | }
|
2653 | },
|
2654 |
|
2655 | components: {
|
2656 | ElCheckbox: _checkbox2.default,
|
2657 | ElTag: _tag2.default
|
2658 | },
|
2659 |
|
2660 | computed: {
|
2661 | table: function table() {
|
2662 | return this.$parent;
|
2663 | },
|
2664 | isAllSelected: function isAllSelected() {
|
2665 | return this.store.states.isAllSelected;
|
2666 | },
|
2667 | columnsCount: function columnsCount() {
|
2668 | return this.store.states.columns.length;
|
2669 | },
|
2670 | leftFixedCount: function leftFixedCount() {
|
2671 | return this.store.states.fixedColumns.length;
|
2672 | },
|
2673 | rightFixedCount: function rightFixedCount() {
|
2674 | return this.store.states.rightFixedColumns.length;
|
2675 | },
|
2676 | leftFixedLeafCount: function leftFixedLeafCount() {
|
2677 | return this.store.states.fixedLeafColumnsLength;
|
2678 | },
|
2679 | rightFixedLeafCount: function rightFixedLeafCount() {
|
2680 | return this.store.states.rightFixedLeafColumnsLength;
|
2681 | },
|
2682 | columns: function columns() {
|
2683 | return this.store.states.columns;
|
2684 | },
|
2685 | hasGutter: function hasGutter() {
|
2686 | return !this.fixed && this.tableLayout.gutterWidth;
|
2687 | }
|
2688 | },
|
2689 |
|
2690 | created: function created() {
|
2691 | this.filterPanels = {};
|
2692 | },
|
2693 | mounted: function mounted() {
|
2694 | var _defaultSort = this.defaultSort,
|
2695 | prop = _defaultSort.prop,
|
2696 | order = _defaultSort.order;
|
2697 |
|
2698 | this.store.commit('sort', { prop: prop, order: order });
|
2699 | },
|
2700 | beforeDestroy: function beforeDestroy() {
|
2701 | var panels = this.filterPanels;
|
2702 | for (var prop in panels) {
|
2703 | if (panels.hasOwnProperty(prop) && panels[prop]) {
|
2704 | panels[prop].$destroy(true);
|
2705 | }
|
2706 | }
|
2707 | },
|
2708 |
|
2709 |
|
2710 | methods: {
|
2711 | isCellHidden: function isCellHidden(index, columns) {
|
2712 | var start = 0;
|
2713 | for (var i = 0; i < index; i++) {
|
2714 | start += columns[i].colSpan;
|
2715 | }
|
2716 | var after = start + columns[index].colSpan - 1;
|
2717 | if (this.fixed === true || this.fixed === 'left') {
|
2718 | return after >= this.leftFixedLeafCount;
|
2719 | } else if (this.fixed === 'right') {
|
2720 | return start < this.columnsCount - this.rightFixedLeafCount;
|
2721 | } else {
|
2722 | return after < this.leftFixedLeafCount || start >= this.columnsCount - this.rightFixedLeafCount;
|
2723 | }
|
2724 | },
|
2725 | getHeaderRowStyle: function getHeaderRowStyle(rowIndex) {
|
2726 | var headerRowStyle = this.table.headerRowStyle;
|
2727 | if (typeof headerRowStyle === 'function') {
|
2728 | return headerRowStyle.call(null, { rowIndex: rowIndex });
|
2729 | }
|
2730 | return headerRowStyle;
|
2731 | },
|
2732 | getHeaderRowClass: function getHeaderRowClass(rowIndex) {
|
2733 | var classes = [];
|
2734 |
|
2735 | var headerRowClassName = this.table.headerRowClassName;
|
2736 | if (typeof headerRowClassName === 'string') {
|
2737 | classes.push(headerRowClassName);
|
2738 | } else if (typeof headerRowClassName === 'function') {
|
2739 | classes.push(headerRowClassName.call(null, { rowIndex: rowIndex }));
|
2740 | }
|
2741 |
|
2742 | return classes.join(' ');
|
2743 | },
|
2744 | getHeaderCellStyle: function getHeaderCellStyle(rowIndex, columnIndex, row, column) {
|
2745 | var headerCellStyle = this.table.headerCellStyle;
|
2746 | if (typeof headerCellStyle === 'function') {
|
2747 | return headerCellStyle.call(null, {
|
2748 | rowIndex: rowIndex,
|
2749 | columnIndex: columnIndex,
|
2750 | row: row,
|
2751 | column: column
|
2752 | });
|
2753 | }
|
2754 | return headerCellStyle;
|
2755 | },
|
2756 | getHeaderCellClass: function getHeaderCellClass(rowIndex, columnIndex, row, column) {
|
2757 | var classes = [column.id, column.order, column.headerAlign, column.className, column.labelClassName];
|
2758 |
|
2759 | if (rowIndex === 0 && this.isCellHidden(columnIndex, row)) {
|
2760 | classes.push('is-hidden');
|
2761 | }
|
2762 |
|
2763 | if (!column.children) {
|
2764 | classes.push('is-leaf');
|
2765 | }
|
2766 |
|
2767 | if (column.sortable) {
|
2768 | classes.push('is-sortable');
|
2769 | }
|
2770 |
|
2771 | var headerCellClassName = this.table.headerCellClassName;
|
2772 | if (typeof headerCellClassName === 'string') {
|
2773 | classes.push(headerCellClassName);
|
2774 | } else if (typeof headerCellClassName === 'function') {
|
2775 | classes.push(headerCellClassName.call(null, {
|
2776 | rowIndex: rowIndex,
|
2777 | columnIndex: columnIndex,
|
2778 | row: row,
|
2779 | column: column
|
2780 | }));
|
2781 | }
|
2782 |
|
2783 | return classes.join(' ');
|
2784 | },
|
2785 | toggleAllSelection: function toggleAllSelection() {
|
2786 | this.store.commit('toggleAllSelection');
|
2787 | },
|
2788 | handleFilterClick: function handleFilterClick(event, column) {
|
2789 | event.stopPropagation();
|
2790 | var target = event.target;
|
2791 | var cell = target.tagName === 'TH' ? target : target.parentNode;
|
2792 | cell = cell.querySelector('.el-table__column-filter-trigger') || cell;
|
2793 | var table = this.$parent;
|
2794 |
|
2795 | var filterPanel = this.filterPanels[column.id];
|
2796 |
|
2797 | if (filterPanel && column.filterOpened) {
|
2798 | filterPanel.showPopper = false;
|
2799 | return;
|
2800 | }
|
2801 |
|
2802 | if (!filterPanel) {
|
2803 | filterPanel = new _vue2.default(_filterPanel2.default);
|
2804 | this.filterPanels[column.id] = filterPanel;
|
2805 | if (column.filterPlacement) {
|
2806 | filterPanel.placement = column.filterPlacement;
|
2807 | }
|
2808 | filterPanel.table = table;
|
2809 | filterPanel.cell = cell;
|
2810 | filterPanel.column = column;
|
2811 | !this.$isServer && filterPanel.$mount(document.createElement('div'));
|
2812 | }
|
2813 |
|
2814 | setTimeout(function () {
|
2815 | filterPanel.showPopper = true;
|
2816 | }, 16);
|
2817 | },
|
2818 | handleHeaderClick: function handleHeaderClick(event, column) {
|
2819 | if (!column.filters && column.sortable) {
|
2820 | this.handleSortClick(event, column);
|
2821 | } else if (column.filterable && !column.sortable) {
|
2822 | this.handleFilterClick(event, column);
|
2823 | }
|
2824 |
|
2825 | this.$parent.$emit('header-click', column, event);
|
2826 | },
|
2827 | handleHeaderContextMenu: function handleHeaderContextMenu(event, column) {
|
2828 | this.$parent.$emit('header-contextmenu', column, event);
|
2829 | },
|
2830 | handleMouseDown: function handleMouseDown(event, column) {
|
2831 | var _this2 = this;
|
2832 |
|
2833 | if (this.$isServer) return;
|
2834 | if (column.children && column.children.length > 0) return;
|
2835 |
|
2836 | if (this.draggingColumn && this.border) {
|
2837 | (function () {
|
2838 | _this2.dragging = true;
|
2839 |
|
2840 | _this2.$parent.resizeProxyVisible = true;
|
2841 |
|
2842 | var table = _this2.$parent;
|
2843 | var tableEl = table.$el;
|
2844 | var tableLeft = tableEl.getBoundingClientRect().left;
|
2845 | var columnEl = _this2.$el.querySelector('th.' + column.id);
|
2846 | var columnRect = columnEl.getBoundingClientRect();
|
2847 | var minLeft = columnRect.left - tableLeft + 30;
|
2848 |
|
2849 | (0, _dom.addClass)(columnEl, 'noclick');
|
2850 |
|
2851 | _this2.dragState = {
|
2852 | startMouseLeft: event.clientX,
|
2853 | startLeft: columnRect.right - tableLeft,
|
2854 | startColumnLeft: columnRect.left - tableLeft,
|
2855 | tableLeft: tableLeft
|
2856 | };
|
2857 |
|
2858 | var resizeProxy = table.$refs.resizeProxy;
|
2859 | resizeProxy.style.left = _this2.dragState.startLeft + 'px';
|
2860 |
|
2861 | document.onselectstart = function () {
|
2862 | return false;
|
2863 | };
|
2864 | document.ondragstart = function () {
|
2865 | return false;
|
2866 | };
|
2867 |
|
2868 | var handleMouseMove = function handleMouseMove(event) {
|
2869 | var deltaLeft = event.clientX - _this2.dragState.startMouseLeft;
|
2870 | var proxyLeft = _this2.dragState.startLeft + deltaLeft;
|
2871 |
|
2872 | resizeProxy.style.left = Math.max(minLeft, proxyLeft) + 'px';
|
2873 | };
|
2874 |
|
2875 | var handleMouseUp = function handleMouseUp() {
|
2876 | if (_this2.dragging) {
|
2877 | var _dragState = _this2.dragState,
|
2878 | startColumnLeft = _dragState.startColumnLeft,
|
2879 | startLeft = _dragState.startLeft;
|
2880 |
|
2881 | var finalLeft = parseInt(resizeProxy.style.left, 10);
|
2882 | var columnWidth = finalLeft - startColumnLeft;
|
2883 | column.width = column.realWidth = columnWidth;
|
2884 | table.$emit('header-dragend', column.width, startLeft - startColumnLeft, column, event);
|
2885 |
|
2886 | _this2.store.scheduleLayout();
|
2887 |
|
2888 | document.body.style.cursor = '';
|
2889 | _this2.dragging = false;
|
2890 | _this2.draggingColumn = null;
|
2891 | _this2.dragState = {};
|
2892 |
|
2893 | table.resizeProxyVisible = false;
|
2894 | }
|
2895 |
|
2896 | document.removeEventListener('mousemove', handleMouseMove);
|
2897 | document.removeEventListener('mouseup', handleMouseUp);
|
2898 | document.onselectstart = null;
|
2899 | document.ondragstart = null;
|
2900 |
|
2901 | setTimeout(function () {
|
2902 | (0, _dom.removeClass)(columnEl, 'noclick');
|
2903 | }, 0);
|
2904 | };
|
2905 |
|
2906 | document.addEventListener('mousemove', handleMouseMove);
|
2907 | document.addEventListener('mouseup', handleMouseUp);
|
2908 | })();
|
2909 | }
|
2910 | },
|
2911 | handleMouseMove: function handleMouseMove(event, column) {
|
2912 | if (column.children && column.children.length > 0) return;
|
2913 | var target = event.target;
|
2914 | while (target && target.tagName !== 'TH') {
|
2915 | target = target.parentNode;
|
2916 | }
|
2917 |
|
2918 | if (!column || !column.resizable) return;
|
2919 |
|
2920 | if (!this.dragging && this.border) {
|
2921 | var rect = target.getBoundingClientRect();
|
2922 |
|
2923 | var bodyStyle = document.body.style;
|
2924 | if (rect.width > 12 && rect.right - event.pageX < 8) {
|
2925 | bodyStyle.cursor = 'col-resize';
|
2926 | if ((0, _dom.hasClass)(target, 'is-sortable')) {
|
2927 | target.style.cursor = 'col-resize';
|
2928 | }
|
2929 | this.draggingColumn = column;
|
2930 | } else if (!this.dragging) {
|
2931 | bodyStyle.cursor = '';
|
2932 | if ((0, _dom.hasClass)(target, 'is-sortable')) {
|
2933 | target.style.cursor = 'pointer';
|
2934 | }
|
2935 | this.draggingColumn = null;
|
2936 | }
|
2937 | }
|
2938 | },
|
2939 | handleMouseOut: function handleMouseOut() {
|
2940 | if (this.$isServer) return;
|
2941 | document.body.style.cursor = '';
|
2942 | },
|
2943 | toggleOrder: function toggleOrder(_ref) {
|
2944 | var order = _ref.order,
|
2945 | sortOrders = _ref.sortOrders;
|
2946 |
|
2947 | if (order === '') return sortOrders[0];
|
2948 | var index = sortOrders.indexOf(order || null);
|
2949 | return sortOrders[index > sortOrders.length - 2 ? 0 : index + 1];
|
2950 | },
|
2951 | handleSortClick: function handleSortClick(event, column, givenOrder) {
|
2952 | event.stopPropagation();
|
2953 | var order = givenOrder || this.toggleOrder(column);
|
2954 |
|
2955 | var target = event.target;
|
2956 | while (target && target.tagName !== 'TH') {
|
2957 | target = target.parentNode;
|
2958 | }
|
2959 |
|
2960 | if (target && target.tagName === 'TH') {
|
2961 | if ((0, _dom.hasClass)(target, 'noclick')) {
|
2962 | (0, _dom.removeClass)(target, 'noclick');
|
2963 | return;
|
2964 | }
|
2965 | }
|
2966 |
|
2967 | if (!column.sortable) return;
|
2968 |
|
2969 | var states = this.store.states;
|
2970 | var sortProp = states.sortProp;
|
2971 | var sortOrder = void 0;
|
2972 | var sortingColumn = states.sortingColumn;
|
2973 |
|
2974 | if (sortingColumn !== column || sortingColumn === column && sortingColumn.order === null) {
|
2975 | if (sortingColumn) {
|
2976 | sortingColumn.order = null;
|
2977 | }
|
2978 | states.sortingColumn = column;
|
2979 | sortProp = column.property;
|
2980 | }
|
2981 |
|
2982 | if (!order) {
|
2983 | sortOrder = column.order = null;
|
2984 | states.sortingColumn = null;
|
2985 | sortProp = null;
|
2986 | } else {
|
2987 | sortOrder = column.order = order;
|
2988 | }
|
2989 |
|
2990 | states.sortProp = sortProp;
|
2991 | states.sortOrder = sortOrder;
|
2992 |
|
2993 | this.store.commit('changeSortCondition');
|
2994 | }
|
2995 | },
|
2996 |
|
2997 | data: function data() {
|
2998 | return {
|
2999 | draggingColumn: null,
|
3000 | dragging: false,
|
3001 | dragState: {}
|
3002 | };
|
3003 | }
|
3004 | };
|
3005 |
|
3006 | }),
|
3007 |
|
3008 | 168:
|
3009 | (function(module, __webpack_exports__, __webpack_require__) {
|
3010 |
|
3011 | "use strict";
|
3012 | Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
3013 | var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_filter_panel_vue__ = __webpack_require__(169);
|
3014 | var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_filter_panel_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_filter_panel_vue__);
|
3015 | var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_784f4ebc_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_filter_panel_vue__ = __webpack_require__(171);
|
3016 | var normalizeComponent = __webpack_require__(0)
|
3017 |
|
3018 |
|
3019 |
|
3020 |
|
3021 |
|
3022 | var __vue_template_functional__ = false
|
3023 |
|
3024 | var __vue_styles__ = null
|
3025 |
|
3026 | var __vue_scopeId__ = null
|
3027 |
|
3028 | var __vue_module_identifier__ = null
|
3029 | var Component = normalizeComponent(
|
3030 | __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_filter_panel_vue___default.a,
|
3031 | __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_784f4ebc_hasScoped_false_preserveWhitespace_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_filter_panel_vue__["a" ],
|
3032 | __vue_template_functional__,
|
3033 | __vue_styles__,
|
3034 | __vue_scopeId__,
|
3035 | __vue_module_identifier__
|
3036 | )
|
3037 |
|
3038 | __webpack_exports__["default"] = (Component.exports);
|
3039 |
|
3040 |
|
3041 | }),
|
3042 |
|
3043 | 169:
|
3044 | (function(module, exports, __webpack_require__) {
|
3045 |
|
3046 | "use strict";
|
3047 |
|
3048 |
|
3049 | exports.__esModule = true;
|
3050 |
|
3051 | var _vuePopper = __webpack_require__(7);
|
3052 |
|
3053 | var _vuePopper2 = _interopRequireDefault(_vuePopper);
|
3054 |
|
3055 | var _popup = __webpack_require__(13);
|
3056 |
|
3057 | var _locale = __webpack_require__(5);
|
3058 |
|
3059 | var _locale2 = _interopRequireDefault(_locale);
|
3060 |
|
3061 | var _clickoutside = __webpack_require__(10);
|
3062 |
|
3063 | var _clickoutside2 = _interopRequireDefault(_clickoutside);
|
3064 |
|
3065 | var _dropdown = __webpack_require__(170);
|
3066 |
|
3067 | var _dropdown2 = _interopRequireDefault(_dropdown);
|
3068 |
|
3069 | var _checkbox = __webpack_require__(16);
|
3070 |
|
3071 | var _checkbox2 = _interopRequireDefault(_checkbox);
|
3072 |
|
3073 | var _checkboxGroup = __webpack_require__(40);
|
3074 |
|
3075 | var _checkboxGroup2 = _interopRequireDefault(_checkboxGroup);
|
3076 |
|
3077 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
3078 |
|
3079 | exports.default = {
|
3080 | name: 'ElTableFilterPanel',
|
3081 |
|
3082 | mixins: [_vuePopper2.default, _locale2.default],
|
3083 |
|
3084 | directives: {
|
3085 | Clickoutside: _clickoutside2.default
|
3086 | },
|
3087 |
|
3088 | components: {
|
3089 | ElCheckbox: _checkbox2.default,
|
3090 | ElCheckboxGroup: _checkboxGroup2.default
|
3091 | },
|
3092 |
|
3093 | props: {
|
3094 | placement: {
|
3095 | type: String,
|
3096 | default: 'bottom-end'
|
3097 | }
|
3098 | },
|
3099 |
|
3100 | customRender: function customRender(h) {
|
3101 | return h(
|
3102 | 'div',
|
3103 | { 'class': 'el-table-filter' },
|
3104 | [h(
|
3105 | 'div',
|
3106 | { 'class': 'el-table-filter__content' },
|
3107 | []
|
3108 | ), h(
|
3109 | 'div',
|
3110 | { 'class': 'el-table-filter__bottom' },
|
3111 | [h(
|
3112 | 'button',
|
3113 | {
|
3114 | on: {
|
3115 | 'click': this.handleConfirm
|
3116 | }
|
3117 | },
|
3118 | [this.t('el.table.confirmFilter')]
|
3119 | ), h(
|
3120 | 'button',
|
3121 | {
|
3122 | on: {
|
3123 | 'click': this.handleReset
|
3124 | }
|
3125 | },
|
3126 | [this.t('el.table.resetFilter')]
|
3127 | )]
|
3128 | )]
|
3129 | );
|
3130 | },
|
3131 |
|
3132 |
|
3133 | methods: {
|
3134 | isActive: function isActive(filter) {
|
3135 | return filter.value === this.filterValue;
|
3136 | },
|
3137 | handleOutsideClick: function handleOutsideClick() {
|
3138 | var _this = this;
|
3139 |
|
3140 | setTimeout(function () {
|
3141 | _this.showPopper = false;
|
3142 | }, 16);
|
3143 | },
|
3144 | handleConfirm: function handleConfirm() {
|
3145 | this.confirmFilter(this.filteredValue);
|
3146 | this.handleOutsideClick();
|
3147 | },
|
3148 | handleReset: function handleReset() {
|
3149 | this.filteredValue = [];
|
3150 | this.confirmFilter(this.filteredValue);
|
3151 | this.handleOutsideClick();
|
3152 | },
|
3153 | handleSelect: function handleSelect(filterValue) {
|
3154 | this.filterValue = filterValue;
|
3155 |
|
3156 | if (typeof filterValue !== 'undefined' && filterValue !== null) {
|
3157 | this.confirmFilter(this.filteredValue);
|
3158 | } else {
|
3159 | this.confirmFilter([]);
|
3160 | }
|
3161 |
|
3162 | this.handleOutsideClick();
|
3163 | },
|
3164 | confirmFilter: function confirmFilter(filteredValue) {
|
3165 | this.table.store.commit('filterChange', {
|
3166 | column: this.column,
|
3167 | values: filteredValue
|
3168 | });
|
3169 | this.table.store.updateAllSelected();
|
3170 | }
|
3171 | },
|
3172 |
|
3173 | data: function data() {
|
3174 | return {
|
3175 | table: null,
|
3176 | cell: null,
|
3177 | column: null
|
3178 | };
|
3179 | },
|
3180 |
|
3181 |
|
3182 | computed: {
|
3183 | filters: function filters() {
|
3184 | return this.column && this.column.filters;
|
3185 | },
|
3186 |
|
3187 |
|
3188 | filterValue: {
|
3189 | get: function get() {
|
3190 | return (this.column.filteredValue || [])[0];
|
3191 | },
|
3192 | set: function set(value) {
|
3193 | if (this.filteredValue) {
|
3194 | if (typeof value !== 'undefined' && value !== null) {
|
3195 | this.filteredValue.splice(0, 1, value);
|
3196 | } else {
|
3197 | this.filteredValue.splice(0, 1);
|
3198 | }
|
3199 | }
|
3200 | }
|
3201 | },
|
3202 |
|
3203 | filteredValue: {
|
3204 | get: function get() {
|
3205 | if (this.column) {
|
3206 | return this.column.filteredValue || [];
|
3207 | }
|
3208 | return [];
|
3209 | },
|
3210 | set: function set(value) {
|
3211 | if (this.column) {
|
3212 | this.column.filteredValue = value;
|
3213 | }
|
3214 | }
|
3215 | },
|
3216 |
|
3217 | multiple: function multiple() {
|
3218 | if (this.column) {
|
3219 | return this.column.filterMultiple;
|
3220 | }
|
3221 | return true;
|
3222 | }
|
3223 | },
|
3224 |
|
3225 | mounted: function mounted() {
|
3226 | var _this2 = this;
|
3227 |
|
3228 | this.popperElm = this.$el;
|
3229 | this.referenceElm = this.cell;
|
3230 | this.table.bodyWrapper.addEventListener('scroll', function () {
|
3231 | _this2.updatePopper();
|
3232 | });
|
3233 |
|
3234 | this.$watch('showPopper', function (value) {
|
3235 | if (_this2.column) _this2.column.filterOpened = value;
|
3236 | if (value) {
|
3237 | _dropdown2.default.open(_this2);
|
3238 | } else {
|
3239 | _dropdown2.default.close(_this2);
|
3240 | }
|
3241 | });
|
3242 | },
|
3243 |
|
3244 | watch: {
|
3245 | showPopper: function showPopper(val) {
|
3246 | if (val === true && parseInt(this.popperJS._popper.style.zIndex, 10) < _popup.PopupManager.zIndex) {
|
3247 | this.popperJS._popper.style.zIndex = _popup.PopupManager.nextZIndex();
|
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 |
|
3290 |
|
3291 |
|
3292 |
|
3293 |
|
3294 |
|
3295 |
|
3296 | }),
|
3297 |
|
3298 | 170:
|
3299 | (function(module, exports, __webpack_require__) {
|
3300 |
|
3301 | "use strict";
|
3302 |
|
3303 |
|
3304 | exports.__esModule = true;
|
3305 |
|
3306 | var _vue = __webpack_require__(4);
|
3307 |
|
3308 | var _vue2 = _interopRequireDefault(_vue);
|
3309 |
|
3310 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
3311 |
|
3312 | var dropdowns = [];
|
3313 |
|
3314 | !_vue2.default.prototype.$isServer && document.addEventListener('click', function (event) {
|
3315 | dropdowns.forEach(function (dropdown) {
|
3316 | var target = event.target;
|
3317 | if (!dropdown || !dropdown.$el) return;
|
3318 | if (target === dropdown.$el || dropdown.$el.contains(target)) {
|
3319 | return;
|
3320 | }
|
3321 | dropdown.handleOutsideClick && dropdown.handleOutsideClick(event);
|
3322 | });
|
3323 | });
|
3324 |
|
3325 | exports.default = {
|
3326 | open: function open(instance) {
|
3327 | if (instance) {
|
3328 | dropdowns.push(instance);
|
3329 | }
|
3330 | },
|
3331 | close: function close(instance) {
|
3332 | var index = dropdowns.indexOf(instance);
|
3333 | if (index !== -1) {
|
3334 | dropdowns.splice(instance, 1);
|
3335 | }
|
3336 | }
|
3337 | };
|
3338 |
|
3339 | }),
|
3340 |
|
3341 | 171:
|
3342 | (function(module, __webpack_exports__, __webpack_require__) {
|
3343 |
|
3344 | "use strict";
|
3345 | var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('transition',{attrs:{"name":"el-zoom-in-top"}},[(_vm.multiple)?_c('div',{directives:[{name:"clickoutside",rawName:"v-clickoutside",value:(_vm.handleOutsideClick),expression:"handleOutsideClick"},{name:"show",rawName:"v-show",value:(_vm.showPopper),expression:"showPopper"}],staticClass:"el-table-filter"},[_c('div',{staticClass:"el-table-filter__content"},[_c('el-scrollbar',{attrs:{"wrap-class":"el-table-filter__wrap"}},[_c('el-checkbox-group',{staticClass:"el-table-filter__checkbox-group",model:{value:(_vm.filteredValue),callback:function ($$v) {_vm.filteredValue=$$v},expression:"filteredValue"}},_vm._l((_vm.filters),function(filter){return _c('el-checkbox',{key:filter.value,attrs:{"label":filter.value}},[_vm._v(_vm._s(filter.text))])}))],1)],1),_c('div',{staticClass:"el-table-filter__bottom"},[_c('button',{class:{ 'is-disabled': _vm.filteredValue.length === 0 },attrs:{"disabled":_vm.filteredValue.length === 0},on:{"click":_vm.handleConfirm}},[_vm._v(_vm._s(_vm.t('el.table.confirmFilter')))]),_c('button',{on:{"click":_vm.handleReset}},[_vm._v(_vm._s(_vm.t('el.table.resetFilter')))])])]):_c('div',{directives:[{name:"clickoutside",rawName:"v-clickoutside",value:(_vm.handleOutsideClick),expression:"handleOutsideClick"},{name:"show",rawName:"v-show",value:(_vm.showPopper),expression:"showPopper"}],staticClass:"el-table-filter"},[_c('ul',{staticClass:"el-table-filter__list"},[_c('li',{staticClass:"el-table-filter__list-item",class:{ 'is-active': _vm.filterValue === undefined || _vm.filterValue === null },on:{"click":function($event){_vm.handleSelect(null)}}},[_vm._v(_vm._s(_vm.t('el.table.clearFilter')))]),_vm._l((_vm.filters),function(filter){return _c('li',{key:filter.value,staticClass:"el-table-filter__list-item",class:{ 'is-active': _vm.isActive(filter) },attrs:{"label":filter.value},on:{"click":function($event){_vm.handleSelect(filter.value)}}},[_vm._v(_vm._s(filter.text))])})],2)])])}
|
3346 | var staticRenderFns = []
|
3347 | var esExports = { render: render, staticRenderFns: staticRenderFns }
|
3348 | __webpack_exports__["a"] = (esExports);
|
3349 |
|
3350 | }),
|
3351 |
|
3352 | 172:
|
3353 | (function(module, exports, __webpack_require__) {
|
3354 |
|
3355 | "use strict";
|
3356 |
|
3357 |
|
3358 | exports.__esModule = true;
|
3359 |
|
3360 | var _layoutObserver = __webpack_require__(39);
|
3361 |
|
3362 | var _layoutObserver2 = _interopRequireDefault(_layoutObserver);
|
3363 |
|
3364 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
3365 |
|
3366 | exports.default = {
|
3367 | name: 'ElTableFooter',
|
3368 |
|
3369 | mixins: [_layoutObserver2.default],
|
3370 |
|
3371 | render: function render(h) {
|
3372 | var _this = this;
|
3373 |
|
3374 | var sums = [];
|
3375 | if (this.summaryMethod) {
|
3376 | sums = this.summaryMethod({ columns: this.columns, data: this.store.states.data });
|
3377 | } else {
|
3378 | this.columns.forEach(function (column, index) {
|
3379 | if (index === 0) {
|
3380 | sums[index] = _this.sumText;
|
3381 | return;
|
3382 | }
|
3383 | var values = _this.store.states.data.map(function (item) {
|
3384 | return Number(item[column.property]);
|
3385 | });
|
3386 | var precisions = [];
|
3387 | var notNumber = true;
|
3388 | values.forEach(function (value) {
|
3389 | if (!isNaN(value)) {
|
3390 | notNumber = false;
|
3391 | var decimal = ('' + value).split('.')[1];
|
3392 | precisions.push(decimal ? decimal.length : 0);
|
3393 | }
|
3394 | });
|
3395 | var precision = Math.max.apply(null, precisions);
|
3396 | if (!notNumber) {
|
3397 | sums[index] = values.reduce(function (prev, curr) {
|
3398 | var value = Number(curr);
|
3399 | if (!isNaN(value)) {
|
3400 | return parseFloat((prev + curr).toFixed(Math.min(precision, 20)));
|
3401 | } else {
|
3402 | return prev;
|
3403 | }
|
3404 | }, 0);
|
3405 | } else {
|
3406 | sums[index] = '';
|
3407 | }
|
3408 | });
|
3409 | }
|
3410 |
|
3411 | return h(
|
3412 | 'table',
|
3413 | {
|
3414 | 'class': 'el-table__footer',
|
3415 | attrs: { cellspacing: '0',
|
3416 | cellpadding: '0',
|
3417 | border: '0' }
|
3418 | },
|
3419 | [h(
|
3420 | 'colgroup',
|
3421 | null,
|
3422 | [this._l(this.columns, function (column) {
|
3423 | return h(
|
3424 | 'col',
|
3425 | {
|
3426 | attrs: { name: column.id }
|
3427 | },
|
3428 | []
|
3429 | );
|
3430 | }), this.hasGutter ? h(
|
3431 | 'col',
|
3432 | {
|
3433 | attrs: { name: 'gutter' }
|
3434 | },
|
3435 | []
|
3436 | ) : '']
|
3437 | ), h(
|
3438 | 'tbody',
|
3439 | { 'class': [{ 'has-gutter': this.hasGutter }] },
|
3440 | [h(
|
3441 | 'tr',
|
3442 | null,
|
3443 | [this._l(this.columns, function (column, cellIndex) {
|
3444 | return h(
|
3445 | 'td',
|
3446 | {
|
3447 | attrs: {
|
3448 | colspan: column.colSpan,
|
3449 | rowspan: column.rowSpan
|
3450 | },
|
3451 | 'class': [column.id, column.headerAlign, column.className || '', _this.isCellHidden(cellIndex, _this.columns) ? 'is-hidden' : '', !column.children ? 'is-leaf' : '', column.labelClassName] },
|
3452 | [h(
|
3453 | 'div',
|
3454 | { 'class': ['cell', column.labelClassName] },
|
3455 | [sums[cellIndex]]
|
3456 | )]
|
3457 | );
|
3458 | }), this.hasGutter ? h(
|
3459 | 'th',
|
3460 | { 'class': 'gutter' },
|
3461 | []
|
3462 | ) : '']
|
3463 | )]
|
3464 | )]
|
3465 | );
|
3466 | },
|
3467 |
|
3468 |
|
3469 | props: {
|
3470 | fixed: String,
|
3471 | store: {
|
3472 | required: true
|
3473 | },
|
3474 | summaryMethod: Function,
|
3475 | sumText: String,
|
3476 | border: Boolean,
|
3477 | defaultSort: {
|
3478 | type: Object,
|
3479 | default: function _default() {
|
3480 | return {
|
3481 | prop: '',
|
3482 | order: ''
|
3483 | };
|
3484 | }
|
3485 | }
|
3486 | },
|
3487 |
|
3488 | computed: {
|
3489 | table: function table() {
|
3490 | return this.$parent;
|
3491 | },
|
3492 | isAllSelected: function isAllSelected() {
|
3493 | return this.store.states.isAllSelected;
|
3494 | },
|
3495 | columnsCount: function columnsCount() {
|
3496 | return this.store.states.columns.length;
|
3497 | },
|
3498 | leftFixedCount: function leftFixedCount() {
|
3499 | return this.store.states.fixedColumns.length;
|
3500 | },
|
3501 | rightFixedCount: function rightFixedCount() {
|
3502 | return this.store.states.rightFixedColumns.length;
|
3503 | },
|
3504 | columns: function columns() {
|
3505 | return this.store.states.columns;
|
3506 | },
|
3507 | hasGutter: function hasGutter() {
|
3508 | return !this.fixed && this.tableLayout.gutterWidth;
|
3509 | }
|
3510 | },
|
3511 |
|
3512 | methods: {
|
3513 | isCellHidden: function isCellHidden(index, columns) {
|
3514 | if (this.fixed === true || this.fixed === 'left') {
|
3515 | return index >= this.leftFixedCount;
|
3516 | } else if (this.fixed === 'right') {
|
3517 | var before = 0;
|
3518 | for (var i = 0; i < index; i++) {
|
3519 | before += columns[i].colSpan;
|
3520 | }
|
3521 | return before < this.columnsCount - this.rightFixedCount;
|
3522 | } else {
|
3523 | return index < this.leftFixedCount || index >= this.columnsCount - this.rightFixedCount;
|
3524 | }
|
3525 | }
|
3526 | }
|
3527 | };
|
3528 |
|
3529 | }),
|
3530 |
|
3531 | 173:
|
3532 | (function(module, __webpack_exports__, __webpack_require__) {
|
3533 |
|
3534 | "use strict";
|
3535 | var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"el-table",class:[{
|
3536 | 'el-table--fit': _vm.fit,
|
3537 | 'el-table--striped': _vm.stripe,
|
3538 | 'el-table--border': _vm.border || _vm.isGroup,
|
3539 | 'el-table--hidden': _vm.isHidden,
|
3540 | 'el-table--group': _vm.isGroup,
|
3541 | 'el-table--fluid-height': _vm.maxHeight,
|
3542 | 'el-table--scrollable-x': _vm.layout.scrollX,
|
3543 | 'el-table--scrollable-y': _vm.layout.scrollY,
|
3544 | 'el-table--enable-row-hover': !_vm.store.states.isComplex,
|
3545 | 'el-table--enable-row-transition': (_vm.store.states.data || []).length !== 0 && (_vm.store.states.data || []).length < 100
|
3546 | }, _vm.tableSize ? ("el-table--" + _vm.tableSize) : ''],on:{"mouseleave":function($event){_vm.handleMouseLeave($event)}}},[_c('div',{ref:"hiddenColumns",staticClass:"hidden-columns"},[_vm._t("default")],2),(_vm.showHeader)?_c('div',{directives:[{name:"mousewheel",rawName:"v-mousewheel",value:(_vm.handleHeaderFooterMousewheel),expression:"handleHeaderFooterMousewheel"}],ref:"headerWrapper",staticClass:"el-table__header-wrapper"},[_c('table-header',{ref:"tableHeader",style:({
|
3547 | width: _vm.layout.bodyWidth ? _vm.layout.bodyWidth + 'px' : ''
|
3548 | }),attrs:{"store":_vm.store,"border":_vm.border,"default-sort":_vm.defaultSort}})],1):_vm._e(),_c('div',{ref:"bodyWrapper",staticClass:"el-table__body-wrapper",class:[_vm.layout.scrollX ? ("is-scrolling-" + _vm.scrollPosition) : 'is-scrolling-none'],style:([_vm.bodyHeight])},[_c('table-body',{style:({
|
3549 | width: _vm.bodyWidth
|
3550 | }),attrs:{"context":_vm.context,"store":_vm.store,"stripe":_vm.stripe,"row-class-name":_vm.rowClassName,"row-style":_vm.rowStyle,"highlight":_vm.highlightCurrentRow}}),(!_vm.data || _vm.data.length === 0)?_c('div',{ref:"emptyBlock",staticClass:"el-table__empty-block",style:({
|
3551 | width: _vm.bodyWidth
|
3552 | })},[_c('span',{staticClass:"el-table__empty-text"},[_vm._t("empty",[_vm._v(_vm._s(_vm.emptyText || _vm.t('el.table.emptyText')))])],2)]):_vm._e(),(_vm.$slots.append)?_c('div',{ref:"appendWrapper",staticClass:"el-table__append-wrapper"},[_vm._t("append")],2):_vm._e()],1),(_vm.showSummary)?_c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.data && _vm.data.length > 0),expression:"data && data.length > 0"},{name:"mousewheel",rawName:"v-mousewheel",value:(_vm.handleHeaderFooterMousewheel),expression:"handleHeaderFooterMousewheel"}],ref:"footerWrapper",staticClass:"el-table__footer-wrapper"},[_c('table-footer',{style:({
|
3553 | width: _vm.layout.bodyWidth ? _vm.layout.bodyWidth + 'px' : ''
|
3554 | }),attrs:{"store":_vm.store,"border":_vm.border,"sum-text":_vm.sumText || _vm.t('el.table.sumText'),"summary-method":_vm.summaryMethod,"default-sort":_vm.defaultSort}})],1):_vm._e(),(_vm.fixedColumns.length > 0)?_c('div',{directives:[{name:"mousewheel",rawName:"v-mousewheel",value:(_vm.handleFixedMousewheel),expression:"handleFixedMousewheel"}],ref:"fixedWrapper",staticClass:"el-table__fixed",style:([{
|
3555 | width: _vm.layout.fixedWidth ? _vm.layout.fixedWidth + 'px' : ''
|
3556 | },
|
3557 | _vm.fixedHeight])},[(_vm.showHeader)?_c('div',{ref:"fixedHeaderWrapper",staticClass:"el-table__fixed-header-wrapper"},[_c('table-header',{ref:"fixedTableHeader",style:({
|
3558 | width: _vm.bodyWidth
|
3559 | }),attrs:{"fixed":"left","border":_vm.border,"store":_vm.store}})],1):_vm._e(),_c('div',{ref:"fixedBodyWrapper",staticClass:"el-table__fixed-body-wrapper",style:([{
|
3560 | top: _vm.layout.headerHeight + 'px'
|
3561 | },
|
3562 | _vm.fixedBodyHeight])},[_c('table-body',{style:({
|
3563 | width: _vm.bodyWidth
|
3564 | }),attrs:{"fixed":"left","store":_vm.store,"stripe":_vm.stripe,"highlight":_vm.highlightCurrentRow,"row-class-name":_vm.rowClassName,"row-style":_vm.rowStyle}}),(_vm.$slots.append)?_c('div',{staticClass:"el-table__append-gutter",style:({
|
3565 | height: _vm.layout.appendHeight + 'px'
|
3566 | })}):_vm._e()],1),(_vm.showSummary)?_c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.data && _vm.data.length > 0),expression:"data && data.length > 0"}],ref:"fixedFooterWrapper",staticClass:"el-table__fixed-footer-wrapper"},[_c('table-footer',{style:({
|
3567 | width: _vm.bodyWidth
|
3568 | }),attrs:{"fixed":"left","border":_vm.border,"sum-text":_vm.sumText || _vm.t('el.table.sumText'),"summary-method":_vm.summaryMethod,"store":_vm.store}})],1):_vm._e()]):_vm._e(),(_vm.rightFixedColumns.length > 0)?_c('div',{directives:[{name:"mousewheel",rawName:"v-mousewheel",value:(_vm.handleFixedMousewheel),expression:"handleFixedMousewheel"}],ref:"rightFixedWrapper",staticClass:"el-table__fixed-right",style:([{
|
3569 | width: _vm.layout.rightFixedWidth ? _vm.layout.rightFixedWidth + 'px' : '',
|
3570 | right: _vm.layout.scrollY ? (_vm.border ? _vm.layout.gutterWidth : (_vm.layout.gutterWidth || 0)) + 'px' : ''
|
3571 | },
|
3572 | _vm.fixedHeight])},[(_vm.showHeader)?_c('div',{ref:"rightFixedHeaderWrapper",staticClass:"el-table__fixed-header-wrapper"},[_c('table-header',{ref:"rightFixedTableHeader",style:({
|
3573 | width: _vm.bodyWidth
|
3574 | }),attrs:{"fixed":"right","border":_vm.border,"store":_vm.store}})],1):_vm._e(),_c('div',{ref:"rightFixedBodyWrapper",staticClass:"el-table__fixed-body-wrapper",style:([{
|
3575 | top: _vm.layout.headerHeight + 'px'
|
3576 | },
|
3577 | _vm.fixedBodyHeight])},[_c('table-body',{style:({
|
3578 | width: _vm.bodyWidth
|
3579 | }),attrs:{"fixed":"right","store":_vm.store,"stripe":_vm.stripe,"row-class-name":_vm.rowClassName,"row-style":_vm.rowStyle,"highlight":_vm.highlightCurrentRow}})],1),(_vm.showSummary)?_c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.data && _vm.data.length > 0),expression:"data && data.length > 0"}],ref:"rightFixedFooterWrapper",staticClass:"el-table__fixed-footer-wrapper"},[_c('table-footer',{style:({
|
3580 | width: _vm.bodyWidth
|
3581 | }),attrs:{"fixed":"right","border":_vm.border,"sum-text":_vm.sumText || _vm.t('el.table.sumText'),"summary-method":_vm.summaryMethod,"store":_vm.store}})],1):_vm._e()]):_vm._e(),(_vm.rightFixedColumns.length > 0)?_c('div',{ref:"rightFixedPatch",staticClass:"el-table__fixed-right-patch",style:({
|
3582 | width: _vm.layout.scrollY ? _vm.layout.gutterWidth + 'px' : '0',
|
3583 | height: _vm.layout.headerHeight + 'px'
|
3584 | })}):_vm._e(),_c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.resizeProxyVisible),expression:"resizeProxyVisible"}],ref:"resizeProxy",staticClass:"el-table__column-resize-proxy"})])}
|
3585 | var staticRenderFns = []
|
3586 | var esExports = { render: render, staticRenderFns: staticRenderFns }
|
3587 | __webpack_exports__["a"] = (esExports);
|
3588 |
|
3589 | }),
|
3590 |
|
3591 | 18:
|
3592 | (function(module, exports) {
|
3593 |
|
3594 | module.exports = require("element-ui/lib/utils/resize-event");
|
3595 |
|
3596 | }),
|
3597 |
|
3598 | 2:
|
3599 | (function(module, exports) {
|
3600 |
|
3601 | module.exports = require("element-ui/lib/utils/util");
|
3602 |
|
3603 | }),
|
3604 |
|
3605 | 22:
|
3606 | (function(module, exports) {
|
3607 |
|
3608 | module.exports = require("element-ui/lib/tooltip");
|
3609 |
|
3610 | }),
|
3611 |
|
3612 | 25:
|
3613 | (function(module, exports) {
|
3614 |
|
3615 | module.exports = require("element-ui/lib/tag");
|
3616 |
|
3617 | }),
|
3618 |
|
3619 | 3:
|
3620 | (function(module, exports) {
|
3621 |
|
3622 | module.exports = require("element-ui/lib/utils/dom");
|
3623 |
|
3624 | }),
|
3625 |
|
3626 | 38:
|
3627 | (function(module, exports) {
|
3628 |
|
3629 | module.exports = require("element-ui/lib/utils/scrollbar-width");
|
3630 |
|
3631 | }),
|
3632 |
|
3633 | 39:
|
3634 | (function(module, exports, __webpack_require__) {
|
3635 |
|
3636 | "use strict";
|
3637 |
|
3638 |
|
3639 | exports.__esModule = true;
|
3640 | exports.default = {
|
3641 | created: function created() {
|
3642 | this.tableLayout.addObserver(this);
|
3643 | },
|
3644 | destroyed: function destroyed() {
|
3645 | this.tableLayout.removeObserver(this);
|
3646 | },
|
3647 |
|
3648 |
|
3649 | computed: {
|
3650 | tableLayout: function tableLayout() {
|
3651 | var layout = this.layout;
|
3652 | if (!layout && this.table) {
|
3653 | layout = this.table.layout;
|
3654 | }
|
3655 | if (!layout) {
|
3656 | throw new Error('Can not find table layout.');
|
3657 | }
|
3658 | return layout;
|
3659 | }
|
3660 | },
|
3661 |
|
3662 | mounted: function mounted() {
|
3663 | this.onColumnsChange(this.tableLayout);
|
3664 | this.onScrollableChange(this.tableLayout);
|
3665 | },
|
3666 | updated: function updated() {
|
3667 | if (this.__updated__) return;
|
3668 | this.onColumnsChange(this.tableLayout);
|
3669 | this.onScrollableChange(this.tableLayout);
|
3670 | this.__updated__ = true;
|
3671 | },
|
3672 |
|
3673 |
|
3674 | methods: {
|
3675 | onColumnsChange: function onColumnsChange() {
|
3676 | var cols = this.$el.querySelectorAll('colgroup > col');
|
3677 | if (!cols.length) return;
|
3678 | var flattenColumns = this.tableLayout.getFlattenColumns();
|
3679 | var columnsMap = {};
|
3680 | flattenColumns.forEach(function (column) {
|
3681 | columnsMap[column.id] = column;
|
3682 | });
|
3683 | for (var i = 0, j = cols.length; i < j; i++) {
|
3684 | var col = cols[i];
|
3685 | var name = col.getAttribute('name');
|
3686 | var column = columnsMap[name];
|
3687 | if (column) {
|
3688 | col.setAttribute('width', column.realWidth || column.width);
|
3689 | }
|
3690 | }
|
3691 | },
|
3692 | onScrollableChange: function onScrollableChange(layout) {
|
3693 | var cols = this.$el.querySelectorAll('colgroup > col[name=gutter]');
|
3694 | for (var i = 0, j = cols.length; i < j; i++) {
|
3695 | var col = cols[i];
|
3696 | col.setAttribute('width', layout.scrollY ? layout.gutterWidth : '0');
|
3697 | }
|
3698 | var ths = this.$el.querySelectorAll('th.gutter');
|
3699 | for (var _i = 0, _j = ths.length; _i < _j; _i++) {
|
3700 | var th = ths[_i];
|
3701 | th.style.width = layout.scrollY ? layout.gutterWidth + 'px' : '0';
|
3702 | th.style.display = layout.scrollY ? '' : 'none';
|
3703 | }
|
3704 | }
|
3705 | }
|
3706 | };
|
3707 |
|
3708 | }),
|
3709 |
|
3710 | 4:
|
3711 | (function(module, exports) {
|
3712 |
|
3713 | module.exports = require("vue");
|
3714 |
|
3715 | }),
|
3716 |
|
3717 | 40:
|
3718 | (function(module, exports) {
|
3719 |
|
3720 | module.exports = require("element-ui/lib/checkbox-group");
|
3721 |
|
3722 | }),
|
3723 |
|
3724 | 48:
|
3725 | (function(module, exports, __webpack_require__) {
|
3726 |
|
3727 | "use strict";
|
3728 |
|
3729 |
|
3730 | exports.__esModule = true;
|
3731 | exports.getRowIdentity = exports.getColumnByCell = exports.getColumnById = exports.orderBy = exports.getCell = undefined;
|
3732 |
|
3733 | 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; };
|
3734 |
|
3735 | var _util = __webpack_require__(2);
|
3736 |
|
3737 | var getCell = exports.getCell = function getCell(event) {
|
3738 | var cell = event.target;
|
3739 |
|
3740 | while (cell && cell.tagName.toUpperCase() !== 'HTML') {
|
3741 | if (cell.tagName.toUpperCase() === 'TD') {
|
3742 | return cell;
|
3743 | }
|
3744 | cell = cell.parentNode;
|
3745 | }
|
3746 |
|
3747 | return null;
|
3748 | };
|
3749 |
|
3750 | var isObject = function isObject(obj) {
|
3751 | return obj !== null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object';
|
3752 | };
|
3753 |
|
3754 | var orderBy = exports.orderBy = function orderBy(array, sortKey, reverse, sortMethod, sortBy) {
|
3755 | if (!sortKey && !sortMethod && (!sortBy || Array.isArray(sortBy) && !sortBy.length)) {
|
3756 | return array;
|
3757 | }
|
3758 | if (typeof reverse === 'string') {
|
3759 | reverse = reverse === 'descending' ? -1 : 1;
|
3760 | } else {
|
3761 | reverse = reverse && reverse < 0 ? -1 : 1;
|
3762 | }
|
3763 | var getKey = sortMethod ? null : function (value, index) {
|
3764 | if (sortBy) {
|
3765 | if (!Array.isArray(sortBy)) {
|
3766 | sortBy = [sortBy];
|
3767 | }
|
3768 | return sortBy.map(function (by) {
|
3769 | if (typeof by === 'string') {
|
3770 | return (0, _util.getValueByPath)(value, by);
|
3771 | } else {
|
3772 | return by(value, index, array);
|
3773 | }
|
3774 | });
|
3775 | }
|
3776 | if (sortKey !== '$key') {
|
3777 | if (isObject(value) && '$value' in value) value = value.$value;
|
3778 | }
|
3779 | return [isObject(value) ? (0, _util.getValueByPath)(value, sortKey) : value];
|
3780 | };
|
3781 | var compare = function compare(a, b) {
|
3782 | if (sortMethod) {
|
3783 | return sortMethod(a.value, b.value);
|
3784 | }
|
3785 | for (var i = 0, len = a.key.length; i < len; i++) {
|
3786 | if (a.key[i] < b.key[i]) {
|
3787 | return -1;
|
3788 | }
|
3789 | if (a.key[i] > b.key[i]) {
|
3790 | return 1;
|
3791 | }
|
3792 | }
|
3793 | return 0;
|
3794 | };
|
3795 | return array.map(function (value, index) {
|
3796 | return {
|
3797 | value: value,
|
3798 | index: index,
|
3799 | key: getKey ? getKey(value, index) : null
|
3800 | };
|
3801 | }).sort(function (a, b) {
|
3802 | var order = compare(a, b);
|
3803 | if (!order) {
|
3804 |
|
3805 | order = a.index - b.index;
|
3806 | }
|
3807 | return order * reverse;
|
3808 | }).map(function (item) {
|
3809 | return item.value;
|
3810 | });
|
3811 | };
|
3812 |
|
3813 | var getColumnById = exports.getColumnById = function getColumnById(table, columnId) {
|
3814 | var column = null;
|
3815 | table.columns.forEach(function (item) {
|
3816 | if (item.id === columnId) {
|
3817 | column = item;
|
3818 | }
|
3819 | });
|
3820 | return column;
|
3821 | };
|
3822 |
|
3823 | var getColumnByCell = exports.getColumnByCell = function getColumnByCell(table, cell) {
|
3824 | var matches = (cell.className || '').match(/el-table_[^\s]+/gm);
|
3825 | if (matches) {
|
3826 | return getColumnById(table, matches[0]);
|
3827 | }
|
3828 | return null;
|
3829 | };
|
3830 |
|
3831 | var getRowIdentity = exports.getRowIdentity = function getRowIdentity(row, rowKey) {
|
3832 | if (!row) throw new Error('row is required when get row identity');
|
3833 | if (typeof rowKey === 'string') {
|
3834 | if (rowKey.indexOf('.') < 0) {
|
3835 | return row[rowKey];
|
3836 | }
|
3837 | var key = rowKey.split('.');
|
3838 | var current = row;
|
3839 | for (var i = 0; i < key.length; i++) {
|
3840 | current = current[key[i]];
|
3841 | }
|
3842 | return current;
|
3843 | } else if (typeof rowKey === 'function') {
|
3844 | return rowKey.call(null, row);
|
3845 | }
|
3846 | };
|
3847 |
|
3848 | }),
|
3849 |
|
3850 | 5:
|
3851 | (function(module, exports) {
|
3852 |
|
3853 | module.exports = require("element-ui/lib/mixins/locale");
|
3854 |
|
3855 | }),
|
3856 |
|
3857 | 7:
|
3858 | (function(module, exports) {
|
3859 |
|
3860 | module.exports = require("element-ui/lib/utils/vue-popper");
|
3861 |
|
3862 | }),
|
3863 |
|
3864 | 8:
|
3865 | (function(module, exports) {
|
3866 |
|
3867 | module.exports = require("element-ui/lib/mixins/migrating");
|
3868 |
|
3869 | }),
|
3870 |
|
3871 | 9:
|
3872 | (function(module, exports) {
|
3873 |
|
3874 | module.exports = require("element-ui/lib/utils/merge");
|
3875 |
|
3876 | })
|
3877 |
|
3878 | }); |
\ | No newline at end of file |