UNPKG

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