UNPKG

16.5 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, {
41/******/ configurable: false,
42/******/ enumerable: true,
43/******/ get: getter
44/******/ });
45/******/ }
46/******/ };
47/******/
48/******/ // getDefaultExport function for compatibility with non-harmony modules
49/******/ __webpack_require__.n = function(module) {
50/******/ var getter = module && module.__esModule ?
51/******/ function getDefault() { return module['default']; } :
52/******/ function getModuleExports() { return module; };
53/******/ __webpack_require__.d(getter, 'a', getter);
54/******/ return getter;
55/******/ };
56/******/
57/******/ // Object.prototype.hasOwnProperty.call
58/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
59/******/
60/******/ // __webpack_public_path__
61/******/ __webpack_require__.p = "/dist/";
62/******/
63/******/ // Load entry module and return exports
64/******/ return __webpack_require__(__webpack_require__.s = 174);
65/******/ })
66/************************************************************************/
67/******/ ({
68
69/***/ 16:
70/***/ (function(module, exports) {
71
72module.exports = require("element-ui/lib/checkbox");
73
74/***/ }),
75
76/***/ 174:
77/***/ (function(module, exports, __webpack_require__) {
78
79"use strict";
80
81
82exports.__esModule = true;
83
84var _tableColumn = __webpack_require__(175);
85
86var _tableColumn2 = _interopRequireDefault(_tableColumn);
87
88function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
89
90/* istanbul ignore next */
91_tableColumn2.default.install = function (Vue) {
92 Vue.component(_tableColumn2.default.name, _tableColumn2.default);
93};
94
95exports.default = _tableColumn2.default;
96
97/***/ }),
98
99/***/ 175:
100/***/ (function(module, exports, __webpack_require__) {
101
102"use strict";
103
104
105exports.__esModule = true;
106
107var _checkbox = __webpack_require__(16);
108
109var _checkbox2 = _interopRequireDefault(_checkbox);
110
111var _tag = __webpack_require__(25);
112
113var _tag2 = _interopRequireDefault(_tag);
114
115var _merge = __webpack_require__(9);
116
117var _merge2 = _interopRequireDefault(_merge);
118
119var _util = __webpack_require__(2);
120
121function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
122
123var columnIdSeed = 1;
124
125var defaults = {
126 default: {
127 order: ''
128 },
129 selection: {
130 width: 48,
131 minWidth: 48,
132 realWidth: 48,
133 order: '',
134 className: 'el-table-column--selection'
135 },
136 expand: {
137 width: 48,
138 minWidth: 48,
139 realWidth: 48,
140 order: ''
141 },
142 index: {
143 width: 48,
144 minWidth: 48,
145 realWidth: 48,
146 order: ''
147 }
148};
149
150var forced = {
151 selection: {
152 renderHeader: function renderHeader(h, _ref) {
153 var store = _ref.store;
154
155 return h(
156 'el-checkbox',
157 {
158 attrs: {
159 disabled: store.states.data && store.states.data.length === 0,
160 indeterminate: store.states.selection.length > 0 && !this.isAllSelected,
161
162 value: this.isAllSelected },
163 nativeOn: {
164 'click': this.toggleAllSelection
165 }
166 },
167 []
168 );
169 },
170 renderCell: function renderCell(h, _ref2) {
171 var row = _ref2.row,
172 column = _ref2.column,
173 store = _ref2.store,
174 $index = _ref2.$index;
175
176 return h(
177 'el-checkbox',
178 {
179 nativeOn: {
180 'click': function click(event) {
181 return event.stopPropagation();
182 }
183 },
184 attrs: {
185 value: store.isSelected(row),
186 disabled: column.selectable ? !column.selectable.call(null, row, $index) : false
187 },
188 on: {
189 'input': function input() {
190 store.commit('rowSelectedChanged', row);
191 }
192 }
193 },
194 []
195 );
196 },
197 sortable: false,
198 resizable: false
199 },
200 index: {
201 renderHeader: function renderHeader(h, _ref3) {
202 var column = _ref3.column;
203
204 return column.label || '#';
205 },
206 renderCell: function renderCell(h, _ref4) {
207 var $index = _ref4.$index,
208 column = _ref4.column;
209
210 var i = $index + 1;
211 var index = column.index;
212
213 if (typeof index === 'number') {
214 i = $index + index;
215 } else if (typeof index === 'function') {
216 i = index($index);
217 }
218
219 return h(
220 'div',
221 null,
222 [i]
223 );
224 },
225 sortable: false
226 },
227 expand: {
228 renderHeader: function renderHeader(h, _ref5) {
229 var column = _ref5.column;
230
231 return column.label || '';
232 },
233 renderCell: function renderCell(h, _ref6, proxy) {
234 var row = _ref6.row,
235 store = _ref6.store;
236
237 var expanded = store.states.expandRows.indexOf(row) > -1;
238 return h(
239 'div',
240 { 'class': 'el-table__expand-icon ' + (expanded ? 'el-table__expand-icon--expanded' : ''),
241 on: {
242 'click': function click(e) {
243 return proxy.handleExpandClick(row, e);
244 }
245 }
246 },
247 [h(
248 'i',
249 { 'class': 'el-icon el-icon-arrow-right' },
250 []
251 )]
252 );
253 },
254 sortable: false,
255 resizable: false,
256 className: 'el-table__expand-column'
257 }
258};
259
260var getDefaultColumn = function getDefaultColumn(type, options) {
261 var column = {};
262
263 (0, _merge2.default)(column, defaults[type || 'default']);
264
265 for (var name in options) {
266 if (options.hasOwnProperty(name)) {
267 var value = options[name];
268 if (typeof value !== 'undefined') {
269 column[name] = value;
270 }
271 }
272 }
273
274 if (!column.minWidth) {
275 column.minWidth = 80;
276 }
277
278 column.realWidth = column.width === undefined ? column.minWidth : column.width;
279
280 return column;
281};
282
283var DEFAULT_RENDER_CELL = function DEFAULT_RENDER_CELL(h, _ref7) {
284 var row = _ref7.row,
285 column = _ref7.column,
286 $index = _ref7.$index;
287
288 var property = column.property;
289 var value = property && (0, _util.getPropByPath)(row, property).v;
290 if (column && column.formatter) {
291 return column.formatter(row, column, value, $index);
292 }
293 return value;
294};
295
296var parseWidth = function parseWidth(width) {
297 if (width !== undefined) {
298 width = parseInt(width, 10);
299 if (isNaN(width)) {
300 width = null;
301 }
302 }
303 return width;
304};
305
306var parseMinWidth = function parseMinWidth(minWidth) {
307 if (minWidth !== undefined) {
308 minWidth = parseInt(minWidth, 10);
309 if (isNaN(minWidth)) {
310 minWidth = 80;
311 }
312 }
313 return minWidth;
314};
315
316exports.default = {
317 name: 'ElTableColumn',
318
319 props: {
320 type: {
321 type: String,
322 default: 'default'
323 },
324 label: String,
325 className: String,
326 labelClassName: String,
327 property: String,
328 prop: String,
329 width: {},
330 minWidth: {},
331 renderHeader: Function,
332 sortable: {
333 type: [String, Boolean],
334 default: false
335 },
336 sortMethod: Function,
337 sortBy: [String, Function, Array],
338 resizable: {
339 type: Boolean,
340 default: true
341 },
342 context: {},
343 columnKey: String,
344 align: String,
345 headerAlign: String,
346 showTooltipWhenOverflow: Boolean,
347 showOverflowTooltip: Boolean,
348 fixed: [Boolean, String],
349 formatter: Function,
350 selectable: Function,
351 reserveSelection: Boolean,
352 filterMethod: Function,
353 filteredValue: Array,
354 filters: Array,
355 filterPlacement: String,
356 filterMultiple: {
357 type: Boolean,
358 default: true
359 },
360 index: [Number, Function],
361 sortOrders: {
362 type: Array,
363 default: function _default() {
364 return ['ascending', 'descending', null];
365 },
366 validator: function validator(val) {
367 return val.every(function (order) {
368 return ['ascending', 'descending', null].indexOf(order) > -1;
369 });
370 }
371 }
372 },
373
374 data: function data() {
375 return {
376 isSubColumn: false,
377 columns: []
378 };
379 },
380 beforeCreate: function beforeCreate() {
381 this.row = {};
382 this.column = {};
383 this.$index = 0;
384 },
385
386
387 components: {
388 ElCheckbox: _checkbox2.default,
389 ElTag: _tag2.default
390 },
391
392 computed: {
393 owner: function owner() {
394 var parent = this.$parent;
395 while (parent && !parent.tableId) {
396 parent = parent.$parent;
397 }
398 return parent;
399 },
400 columnOrTableParent: function columnOrTableParent() {
401 var parent = this.$parent;
402 while (parent && !parent.tableId && !parent.columnId) {
403 parent = parent.$parent;
404 }
405 return parent;
406 }
407 },
408
409 created: function created() {
410 var _this = this;
411
412 this.customRender = this.$options.render;
413 this.$options.render = function (h) {
414 return h('div', _this.$slots.default);
415 };
416
417 var parent = this.columnOrTableParent;
418 var owner = this.owner;
419 this.isSubColumn = owner !== parent;
420 this.columnId = (parent.tableId || parent.columnId) + '_column_' + columnIdSeed++;
421
422 var type = this.type;
423
424 var width = parseWidth(this.width);
425 var minWidth = parseMinWidth(this.minWidth);
426
427 var isColumnGroup = false;
428
429 var column = getDefaultColumn(type, {
430 id: this.columnId,
431 columnKey: this.columnKey,
432 label: this.label,
433 className: this.className,
434 labelClassName: this.labelClassName,
435 property: this.prop || this.property,
436 type: type,
437 renderCell: null,
438 renderHeader: this.renderHeader,
439 minWidth: minWidth,
440 width: width,
441 isColumnGroup: isColumnGroup,
442 context: this.context,
443 align: this.align ? 'is-' + this.align : null,
444 headerAlign: this.headerAlign ? 'is-' + this.headerAlign : this.align ? 'is-' + this.align : null,
445 sortable: this.sortable === '' ? true : this.sortable,
446 sortMethod: this.sortMethod,
447 sortBy: this.sortBy,
448 resizable: this.resizable,
449 showOverflowTooltip: this.showOverflowTooltip || this.showTooltipWhenOverflow,
450 formatter: this.formatter,
451 selectable: this.selectable,
452 reserveSelection: this.reserveSelection,
453 fixed: this.fixed === '' ? true : this.fixed,
454 filterMethod: this.filterMethod,
455 filters: this.filters,
456 filterable: this.filters || this.filterMethod,
457 filterMultiple: this.filterMultiple,
458 filterOpened: false,
459 filteredValue: this.filteredValue || [],
460 filterPlacement: this.filterPlacement || '',
461 index: this.index,
462 sortOrders: this.sortOrders
463 });
464
465 var source = forced[type] || {};
466 for (var prop in source) {
467 if (source.hasOwnProperty(prop)) {
468 var value = source[prop];
469 if (value !== undefined) {
470 column[prop] = prop === 'className' ? column[prop] + ' ' + value : value;
471 }
472 }
473 }
474
475 this.columnConfig = column;
476
477 var renderCell = column.renderCell;
478 var _self = this;
479
480 if (type === 'expand') {
481 owner.renderExpanded = function (h, data) {
482 return _self.$scopedSlots.default ? _self.$scopedSlots.default(data) : _self.$slots.default;
483 };
484
485 column.renderCell = function (h, data) {
486 return h(
487 'div',
488 { 'class': 'cell' },
489 [renderCell(h, data, this._renderProxy)]
490 );
491 };
492
493 return;
494 }
495
496 column.renderCell = function (h, data) {
497 if (_self.$scopedSlots.default) {
498 renderCell = function renderCell() {
499 return _self.$scopedSlots.default(data);
500 };
501 }
502
503 if (!renderCell) {
504 renderCell = DEFAULT_RENDER_CELL;
505 }
506
507 return _self.showOverflowTooltip || _self.showTooltipWhenOverflow ? h(
508 'div',
509 { 'class': 'cell el-tooltip', style: { width: (data.column.realWidth || data.column.width) - 1 + 'px' } },
510 [renderCell(h, data)]
511 ) : h(
512 'div',
513 { 'class': 'cell' },
514 [renderCell(h, data)]
515 );
516 };
517 },
518 destroyed: function destroyed() {
519 if (!this.$parent) return;
520 var parent = this.$parent;
521 this.owner.store.commit('removeColumn', this.columnConfig, this.isSubColumn ? parent.columnConfig : null);
522 },
523
524
525 watch: {
526 label: function label(newVal) {
527 if (this.columnConfig) {
528 this.columnConfig.label = newVal;
529 }
530 },
531 prop: function prop(newVal) {
532 if (this.columnConfig) {
533 this.columnConfig.property = newVal;
534 }
535 },
536 property: function property(newVal) {
537 if (this.columnConfig) {
538 this.columnConfig.property = newVal;
539 }
540 },
541 filters: function filters(newVal) {
542 if (this.columnConfig) {
543 this.columnConfig.filters = newVal;
544 }
545 },
546 filterMultiple: function filterMultiple(newVal) {
547 if (this.columnConfig) {
548 this.columnConfig.filterMultiple = newVal;
549 }
550 },
551 align: function align(newVal) {
552 if (this.columnConfig) {
553 this.columnConfig.align = newVal ? 'is-' + newVal : null;
554
555 if (!this.headerAlign) {
556 this.columnConfig.headerAlign = newVal ? 'is-' + newVal : null;
557 }
558 }
559 },
560 headerAlign: function headerAlign(newVal) {
561 if (this.columnConfig) {
562 this.columnConfig.headerAlign = 'is-' + (newVal ? newVal : this.align);
563 }
564 },
565 width: function width(newVal) {
566 if (this.columnConfig) {
567 this.columnConfig.width = parseWidth(newVal);
568 this.owner.store.scheduleLayout();
569 }
570 },
571 minWidth: function minWidth(newVal) {
572 if (this.columnConfig) {
573 this.columnConfig.minWidth = parseMinWidth(newVal);
574 this.owner.store.scheduleLayout();
575 }
576 },
577 fixed: function fixed(newVal) {
578 if (this.columnConfig) {
579 this.columnConfig.fixed = newVal;
580 this.owner.store.scheduleLayout(true);
581 }
582 },
583 sortable: function sortable(newVal) {
584 if (this.columnConfig) {
585 this.columnConfig.sortable = newVal;
586 }
587 },
588 index: function index(newVal) {
589 if (this.columnConfig) {
590 this.columnConfig.index = newVal;
591 }
592 },
593 formatter: function formatter(newVal) {
594 if (this.columnConfig) {
595 this.columnConfig.formatter = newVal;
596 }
597 },
598 className: function className(newVal) {
599 if (this.columnConfig) {
600 this.columnConfig.className = newVal;
601 }
602 },
603 labelClassName: function labelClassName(newVal) {
604 if (this.columnConfig) {
605 this.columnConfig.labelClassName = newVal;
606 }
607 }
608 },
609
610 mounted: function mounted() {
611 var owner = this.owner;
612 var parent = this.columnOrTableParent;
613 var columnIndex = void 0;
614
615 if (!this.isSubColumn) {
616 columnIndex = [].indexOf.call(parent.$refs.hiddenColumns.children, this.$el);
617 } else {
618 columnIndex = [].indexOf.call(parent.$el.children, this.$el);
619 }
620
621 owner.store.commit('insertColumn', this.columnConfig, columnIndex, this.isSubColumn ? parent.columnConfig : null);
622 }
623};
624
625/***/ }),
626
627/***/ 2:
628/***/ (function(module, exports) {
629
630module.exports = require("element-ui/lib/utils/util");
631
632/***/ }),
633
634/***/ 25:
635/***/ (function(module, exports) {
636
637module.exports = require("element-ui/lib/tag");
638
639/***/ }),
640
641/***/ 9:
642/***/ (function(module, exports) {
643
644module.exports = require("element-ui/lib/utils/merge");
645
646/***/ })
647
648/******/ });
\No newline at end of file