table.js 76 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907
  1. module.exports =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/ // Check if module is in cache
  8. /******/ if(installedModules[moduleId])
  9. /******/ return installedModules[moduleId].exports;
  10. /******/ // Create a new module (and put it into the cache)
  11. /******/ var module = installedModules[moduleId] = {
  12. /******/ exports: {},
  13. /******/ id: moduleId,
  14. /******/ loaded: false
  15. /******/ };
  16. /******/ // Execute the module function
  17. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  18. /******/ // Flag the module as loaded
  19. /******/ module.loaded = true;
  20. /******/ // Return the exports of the module
  21. /******/ return module.exports;
  22. /******/ }
  23. /******/ // expose the modules object (__webpack_modules__)
  24. /******/ __webpack_require__.m = modules;
  25. /******/ // expose the module cache
  26. /******/ __webpack_require__.c = installedModules;
  27. /******/ // __webpack_public_path__
  28. /******/ __webpack_require__.p = "/dist/";
  29. /******/ // Load entry module and return exports
  30. /******/ return __webpack_require__(0);
  31. /******/ })
  32. /************************************************************************/
  33. /******/ ({
  34. /***/ 0:
  35. /***/ function(module, exports, __webpack_require__) {
  36. module.exports = __webpack_require__(301);
  37. /***/ },
  38. /***/ 3:
  39. /***/ function(module, exports) {
  40. module.exports = function normalizeComponent (
  41. rawScriptExports,
  42. compiledTemplate,
  43. scopeId,
  44. cssModules
  45. ) {
  46. var esModule
  47. var scriptExports = rawScriptExports = rawScriptExports || {}
  48. // ES6 modules interop
  49. var type = typeof rawScriptExports.default
  50. if (type === 'object' || type === 'function') {
  51. esModule = rawScriptExports
  52. scriptExports = rawScriptExports.default
  53. }
  54. // Vue.extend constructor export interop
  55. var options = typeof scriptExports === 'function'
  56. ? scriptExports.options
  57. : scriptExports
  58. // render functions
  59. if (compiledTemplate) {
  60. options.render = compiledTemplate.render
  61. options.staticRenderFns = compiledTemplate.staticRenderFns
  62. }
  63. // scopedId
  64. if (scopeId) {
  65. options._scopeId = scopeId
  66. }
  67. // inject cssModules
  68. if (cssModules) {
  69. var computed = options.computed || (options.computed = {})
  70. Object.keys(cssModules).forEach(function (key) {
  71. var module = cssModules[key]
  72. computed[key] = function () { return module }
  73. })
  74. }
  75. return {
  76. esModule: esModule,
  77. exports: scriptExports,
  78. options: options
  79. }
  80. }
  81. /***/ },
  82. /***/ 10:
  83. /***/ function(module, exports) {
  84. module.exports = require("element-ui/lib/utils/clickoutside");
  85. /***/ },
  86. /***/ 13:
  87. /***/ function(module, exports) {
  88. module.exports = require("element-ui/lib/utils/vue-popper");
  89. /***/ },
  90. /***/ 45:
  91. /***/ function(module, exports) {
  92. module.exports = require("throttle-debounce/throttle");
  93. /***/ },
  94. /***/ 46:
  95. /***/ function(module, exports) {
  96. module.exports = require("throttle-debounce/debounce");
  97. /***/ },
  98. /***/ 47:
  99. /***/ function(module, exports) {
  100. module.exports = require("element-ui/lib/utils/resize-event");
  101. /***/ },
  102. /***/ 56:
  103. /***/ function(module, exports) {
  104. module.exports = require("vue");
  105. /***/ },
  106. /***/ 60:
  107. /***/ function(module, exports) {
  108. module.exports = require("element-ui/lib/mixins/locale");
  109. /***/ },
  110. /***/ 117:
  111. /***/ function(module, exports) {
  112. module.exports = require("element-ui/lib/utils/dom");
  113. /***/ },
  114. /***/ 132:
  115. /***/ function(module, exports) {
  116. module.exports = require("element-ui/lib/utils/popup");
  117. /***/ },
  118. /***/ 256:
  119. /***/ function(module, exports) {
  120. module.exports = require("element-ui/lib/utils/scrollbar-width");
  121. /***/ },
  122. /***/ 266:
  123. /***/ function(module, exports) {
  124. module.exports = require("element-ui/lib/tag");
  125. /***/ },
  126. /***/ 274:
  127. /***/ function(module, exports) {
  128. module.exports = require("element-ui/lib/tooltip");
  129. /***/ },
  130. /***/ 301:
  131. /***/ function(module, exports, __webpack_require__) {
  132. 'use strict';
  133. exports.__esModule = true;
  134. var _table = __webpack_require__(302);
  135. var _table2 = _interopRequireDefault(_table);
  136. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  137. /* istanbul ignore next */
  138. _table2.default.install = function (Vue) {
  139. Vue.component(_table2.default.name, _table2.default);
  140. };
  141. exports.default = _table2.default;
  142. /***/ },
  143. /***/ 302:
  144. /***/ function(module, exports, __webpack_require__) {
  145. var Component = __webpack_require__(3)(
  146. /* script */
  147. __webpack_require__(303),
  148. /* template */
  149. __webpack_require__(315),
  150. /* scopeId */
  151. null,
  152. /* cssModules */
  153. null
  154. )
  155. module.exports = Component.exports
  156. /***/ },
  157. /***/ 303:
  158. /***/ function(module, exports, __webpack_require__) {
  159. 'use strict';
  160. exports.__esModule = true;
  161. var _checkbox = __webpack_require__(304);
  162. var _checkbox2 = _interopRequireDefault(_checkbox);
  163. var _throttle = __webpack_require__(45);
  164. var _throttle2 = _interopRequireDefault(_throttle);
  165. var _debounce = __webpack_require__(46);
  166. var _debounce2 = _interopRequireDefault(_debounce);
  167. var _resizeEvent = __webpack_require__(47);
  168. var _locale = __webpack_require__(60);
  169. var _locale2 = _interopRequireDefault(_locale);
  170. var _tableStore = __webpack_require__(305);
  171. var _tableStore2 = _interopRequireDefault(_tableStore);
  172. var _tableLayout = __webpack_require__(307);
  173. var _tableLayout2 = _interopRequireDefault(_tableLayout);
  174. var _tableBody = __webpack_require__(308);
  175. var _tableBody2 = _interopRequireDefault(_tableBody);
  176. var _tableHeader = __webpack_require__(309);
  177. var _tableHeader2 = _interopRequireDefault(_tableHeader);
  178. var _util = __webpack_require__(306);
  179. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  180. //
  181. //
  182. //
  183. //
  184. //
  185. //
  186. //
  187. //
  188. //
  189. //
  190. //
  191. //
  192. //
  193. //
  194. //
  195. //
  196. //
  197. //
  198. //
  199. //
  200. //
  201. //
  202. //
  203. //
  204. //
  205. //
  206. //
  207. //
  208. //
  209. //
  210. //
  211. //
  212. //
  213. //
  214. //
  215. //
  216. //
  217. //
  218. //
  219. //
  220. //
  221. //
  222. //
  223. //
  224. //
  225. //
  226. //
  227. //
  228. //
  229. //
  230. //
  231. //
  232. //
  233. //
  234. //
  235. //
  236. //
  237. //
  238. //
  239. //
  240. //
  241. //
  242. //
  243. //
  244. //
  245. //
  246. //
  247. //
  248. //
  249. //
  250. //
  251. //
  252. //
  253. //
  254. //
  255. //
  256. //
  257. //
  258. //
  259. //
  260. //
  261. //
  262. //
  263. //
  264. //
  265. //
  266. //
  267. //
  268. //
  269. //
  270. //
  271. //
  272. //
  273. //
  274. //
  275. //
  276. //
  277. //
  278. //
  279. //
  280. //
  281. //
  282. //
  283. //
  284. //
  285. //
  286. var tableIdSeed = 1;
  287. exports.default = {
  288. name: 'ElTable',
  289. mixins: [_locale2.default],
  290. props: {
  291. data: {
  292. type: Array,
  293. default: function _default() {
  294. return [];
  295. }
  296. },
  297. width: [String, Number],
  298. height: [String, Number],
  299. maxHeight: [String, Number],
  300. fit: {
  301. type: Boolean,
  302. default: true
  303. },
  304. stripe: Boolean,
  305. border: Boolean,
  306. rowKey: [String, Function],
  307. context: {},
  308. showHeader: {
  309. type: Boolean,
  310. default: true
  311. },
  312. rowClassName: [String, Function],
  313. rowStyle: [Object, Function],
  314. highlightCurrentRow: Boolean,
  315. currentRowKey: [String, Number],
  316. emptyText: String,
  317. expandRowKeys: Array,
  318. defaultExpandAll: Boolean,
  319. defaultSort: Object,
  320. tooltipEffect: String
  321. },
  322. components: {
  323. TableHeader: _tableHeader2.default,
  324. TableBody: _tableBody2.default,
  325. ElCheckbox: _checkbox2.default
  326. },
  327. methods: {
  328. toggleRowSelection: function toggleRowSelection(row, selected) {
  329. this.store.toggleRowSelection(row, selected);
  330. this.store.updateAllSelected();
  331. },
  332. clearSelection: function clearSelection() {
  333. this.store.clearSelection();
  334. },
  335. handleMouseLeave: function handleMouseLeave() {
  336. this.store.commit('setHoverRow', null);
  337. if (this.hoverState) this.hoverState = null;
  338. },
  339. updateScrollY: function updateScrollY() {
  340. this.layout.updateScrollY();
  341. },
  342. bindEvents: function bindEvents() {
  343. var _this = this;
  344. var headerWrapper = this.$refs.headerWrapper;
  345. var refs = this.$refs;
  346. this.bodyWrapper.addEventListener('scroll', function () {
  347. if (headerWrapper) headerWrapper.scrollLeft = this.scrollLeft;
  348. if (refs.fixedBodyWrapper) refs.fixedBodyWrapper.scrollTop = this.scrollTop;
  349. if (refs.rightFixedBodyWrapper) refs.rightFixedBodyWrapper.scrollTop = this.scrollTop;
  350. });
  351. if (headerWrapper) {
  352. (0, _util.mousewheel)(headerWrapper, (0, _throttle2.default)(16, function (event) {
  353. var deltaX = event.deltaX;
  354. if (deltaX > 0) {
  355. _this.bodyWrapper.scrollLeft += 10;
  356. } else {
  357. _this.bodyWrapper.scrollLeft -= 10;
  358. }
  359. }));
  360. }
  361. if (this.fit) {
  362. this.windowResizeListener = (0, _throttle2.default)(50, function () {
  363. if (_this.$ready) _this.doLayout();
  364. });
  365. (0, _resizeEvent.addResizeListener)(this.$el, this.windowResizeListener);
  366. }
  367. },
  368. doLayout: function doLayout() {
  369. var _this2 = this;
  370. this.store.updateColumns();
  371. this.layout.update();
  372. this.updateScrollY();
  373. this.$nextTick(function () {
  374. if (_this2.height) {
  375. _this2.layout.setHeight(_this2.height);
  376. } else if (_this2.maxHeight) {
  377. _this2.layout.setMaxHeight(_this2.maxHeight);
  378. } else if (_this2.shouldUpdateHeight) {
  379. _this2.layout.updateHeight();
  380. }
  381. });
  382. }
  383. },
  384. created: function created() {
  385. var _this3 = this;
  386. this.tableId = 'el-table_' + tableIdSeed + '_';
  387. this.debouncedLayout = (0, _debounce2.default)(50, function () {
  388. return _this3.doLayout();
  389. });
  390. },
  391. computed: {
  392. bodyWrapper: function bodyWrapper() {
  393. return this.$refs.bodyWrapper;
  394. },
  395. shouldUpdateHeight: function shouldUpdateHeight() {
  396. return typeof this.height === 'number' || this.fixedColumns.length > 0 || this.rightFixedColumns.length > 0;
  397. },
  398. selection: function selection() {
  399. return this.store.selection;
  400. },
  401. columns: function columns() {
  402. return this.store.states.columns;
  403. },
  404. tableData: function tableData() {
  405. return this.store.states.data;
  406. },
  407. fixedColumns: function fixedColumns() {
  408. return this.store.states.fixedColumns;
  409. },
  410. rightFixedColumns: function rightFixedColumns() {
  411. return this.store.states.rightFixedColumns;
  412. },
  413. bodyHeight: function bodyHeight() {
  414. var style = {};
  415. if (this.height) {
  416. style = {
  417. height: this.layout.bodyHeight ? this.layout.bodyHeight + 'px' : ''
  418. };
  419. } else if (this.maxHeight) {
  420. style = {
  421. 'max-height': (this.showHeader ? this.maxHeight - this.layout.headerHeight : this.maxHeight) + 'px'
  422. };
  423. }
  424. return style;
  425. },
  426. bodyWidth: function bodyWidth() {
  427. var _layout = this.layout,
  428. bodyWidth = _layout.bodyWidth,
  429. scrollY = _layout.scrollY,
  430. gutterWidth = _layout.gutterWidth;
  431. return bodyWidth ? bodyWidth - (scrollY ? gutterWidth : 0) + 'px' : '';
  432. },
  433. fixedBodyHeight: function fixedBodyHeight() {
  434. var style = {};
  435. if (this.height) {
  436. style = {
  437. height: this.layout.fixedBodyHeight ? this.layout.fixedBodyHeight + 'px' : ''
  438. };
  439. } else if (this.maxHeight) {
  440. var maxHeight = this.layout.scrollX ? this.maxHeight - this.layout.gutterWidth : this.maxHeight;
  441. if (this.showHeader) {
  442. maxHeight -= this.layout.headerHeight;
  443. }
  444. style = {
  445. 'max-height': maxHeight + 'px'
  446. };
  447. }
  448. return style;
  449. },
  450. fixedHeight: function fixedHeight() {
  451. var style = {};
  452. if (this.maxHeight) {
  453. style = {
  454. bottom: this.layout.scrollX && this.data.length ? this.layout.gutterWidth + 'px' : ''
  455. };
  456. } else {
  457. style = {
  458. height: this.layout.viewportHeight ? this.layout.viewportHeight + 'px' : ''
  459. };
  460. }
  461. return style;
  462. }
  463. },
  464. watch: {
  465. height: function height(value) {
  466. this.layout.setHeight(value);
  467. },
  468. currentRowKey: function currentRowKey(newVal) {
  469. this.store.setCurrentRowKey(newVal);
  470. },
  471. data: {
  472. immediate: true,
  473. handler: function handler(val) {
  474. this.store.commit('setData', val);
  475. }
  476. },
  477. expandRowKeys: function expandRowKeys(newVal) {
  478. this.store.setExpandRowKeys(newVal);
  479. }
  480. },
  481. destroyed: function destroyed() {
  482. if (this.windowResizeListener) (0, _resizeEvent.removeResizeListener)(this.$el, this.windowResizeListener);
  483. },
  484. mounted: function mounted() {
  485. var _this4 = this;
  486. this.bindEvents();
  487. this.doLayout();
  488. // init filters
  489. this.store.states.columns.forEach(function (column) {
  490. if (column.filteredValue && column.filteredValue.length) {
  491. _this4.store.commit('filterChange', {
  492. column: column,
  493. values: column.filteredValue,
  494. silent: true
  495. });
  496. }
  497. });
  498. this.$ready = true;
  499. },
  500. data: function data() {
  501. var store = new _tableStore2.default(this, {
  502. rowKey: this.rowKey,
  503. defaultExpandAll: this.defaultExpandAll
  504. });
  505. var layout = new _tableLayout2.default({
  506. store: store,
  507. table: this,
  508. fit: this.fit,
  509. showHeader: this.showHeader
  510. });
  511. return {
  512. store: store,
  513. layout: layout,
  514. renderExpanded: null,
  515. resizeProxyVisible: false
  516. };
  517. }
  518. };
  519. /***/ },
  520. /***/ 304:
  521. /***/ function(module, exports) {
  522. module.exports = require("element-ui/lib/checkbox");
  523. /***/ },
  524. /***/ 305:
  525. /***/ function(module, exports, __webpack_require__) {
  526. 'use strict';
  527. exports.__esModule = true;
  528. var _vue = __webpack_require__(56);
  529. var _vue2 = _interopRequireDefault(_vue);
  530. var _debounce = __webpack_require__(46);
  531. var _debounce2 = _interopRequireDefault(_debounce);
  532. var _util = __webpack_require__(306);
  533. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  534. var sortData = function sortData(data, states) {
  535. var sortingColumn = states.sortingColumn;
  536. if (!sortingColumn || typeof sortingColumn.sortable === 'string') {
  537. return data;
  538. }
  539. return (0, _util.orderBy)(data, states.sortProp, states.sortOrder, sortingColumn.sortMethod);
  540. };
  541. var getKeysMap = function getKeysMap(array, rowKey) {
  542. var arrayMap = {};
  543. (array || []).forEach(function (row, index) {
  544. arrayMap[(0, _util.getRowIdentity)(row, rowKey)] = { row: row, index: index };
  545. });
  546. return arrayMap;
  547. };
  548. var toggleRowSelection = function toggleRowSelection(states, row, selected) {
  549. var changed = false;
  550. var selection = states.selection;
  551. var index = selection.indexOf(row);
  552. if (typeof selected === 'undefined') {
  553. if (index === -1) {
  554. selection.push(row);
  555. changed = true;
  556. } else {
  557. selection.splice(index, 1);
  558. changed = true;
  559. }
  560. } else {
  561. if (selected && index === -1) {
  562. selection.push(row);
  563. changed = true;
  564. } else if (!selected && index > -1) {
  565. selection.splice(index, 1);
  566. changed = true;
  567. }
  568. }
  569. return changed;
  570. };
  571. var TableStore = function TableStore(table) {
  572. var initialState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  573. if (!table) {
  574. throw new Error('Table is required.');
  575. }
  576. this.table = table;
  577. this.states = {
  578. rowKey: null,
  579. _columns: [],
  580. originColumns: [],
  581. columns: [],
  582. fixedColumns: [],
  583. rightFixedColumns: [],
  584. isComplex: false,
  585. _data: null,
  586. filteredData: null,
  587. data: null,
  588. sortingColumn: null,
  589. sortProp: null,
  590. sortOrder: null,
  591. isAllSelected: false,
  592. selection: [],
  593. reserveSelection: false,
  594. selectable: null,
  595. currentRow: null,
  596. hoverRow: null,
  597. filters: {},
  598. expandRows: [],
  599. defaultExpandAll: false
  600. };
  601. for (var prop in initialState) {
  602. if (initialState.hasOwnProperty(prop) && this.states.hasOwnProperty(prop)) {
  603. this.states[prop] = initialState[prop];
  604. }
  605. }
  606. };
  607. TableStore.prototype.mutations = {
  608. setData: function setData(states, data) {
  609. var _this = this;
  610. var dataInstanceChanged = states._data !== data;
  611. states._data = data;
  612. states.data = sortData(data || [], states);
  613. // states.data.forEach((item) => {
  614. // if (!item.$extra) {
  615. // Object.defineProperty(item, '$extra', {
  616. // value: {},
  617. // enumerable: false
  618. // });
  619. // }
  620. // });
  621. this.updateCurrentRow();
  622. if (!states.reserveSelection) {
  623. if (dataInstanceChanged) {
  624. this.clearSelection();
  625. } else {
  626. this.cleanSelection();
  627. }
  628. this.updateAllSelected();
  629. } else {
  630. (function () {
  631. var rowKey = states.rowKey;
  632. if (rowKey) {
  633. (function () {
  634. var selection = states.selection;
  635. var selectedMap = getKeysMap(selection, rowKey);
  636. states.data.forEach(function (row) {
  637. var rowId = (0, _util.getRowIdentity)(row, rowKey);
  638. var rowInfo = selectedMap[rowId];
  639. if (rowInfo) {
  640. selection[rowInfo.index] = row;
  641. }
  642. });
  643. _this.updateAllSelected();
  644. })();
  645. } else {
  646. console.warn('WARN: rowKey is required when reserve-selection is enabled.');
  647. }
  648. })();
  649. }
  650. var defaultExpandAll = states.defaultExpandAll;
  651. if (defaultExpandAll) {
  652. this.states.expandRows = (states.data || []).slice(0);
  653. }
  654. _vue2.default.nextTick(function () {
  655. return _this.table.updateScrollY();
  656. });
  657. },
  658. changeSortCondition: function changeSortCondition(states) {
  659. var _this2 = this;
  660. states.data = sortData(states.filteredData || states._data || [], states);
  661. this.table.$emit('sort-change', {
  662. column: this.states.sortingColumn,
  663. prop: this.states.sortProp,
  664. order: this.states.sortOrder
  665. });
  666. _vue2.default.nextTick(function () {
  667. return _this2.table.updateScrollY();
  668. });
  669. },
  670. filterChange: function filterChange(states, options) {
  671. var _this3 = this;
  672. var column = options.column,
  673. values = options.values,
  674. silent = options.silent;
  675. if (values && !Array.isArray(values)) {
  676. values = [values];
  677. }
  678. var prop = column.property;
  679. var filters = {};
  680. if (prop) {
  681. states.filters[column.id] = values;
  682. filters[column.columnKey || column.id] = values;
  683. }
  684. var data = states._data;
  685. Object.keys(states.filters).forEach(function (columnId) {
  686. var values = states.filters[columnId];
  687. if (!values || values.length === 0) return;
  688. var column = (0, _util.getColumnById)(_this3.states, columnId);
  689. if (column && column.filterMethod) {
  690. data = data.filter(function (row) {
  691. return values.some(function (value) {
  692. return column.filterMethod.call(null, value, row);
  693. });
  694. });
  695. }
  696. });
  697. states.filteredData = data;
  698. states.data = sortData(data, states);
  699. if (!silent) {
  700. this.table.$emit('filter-change', filters);
  701. }
  702. _vue2.default.nextTick(function () {
  703. return _this3.table.updateScrollY();
  704. });
  705. },
  706. insertColumn: function insertColumn(states, column, index, parent) {
  707. var array = states._columns;
  708. if (parent) {
  709. array = parent.children;
  710. if (!array) array = parent.children = [];
  711. }
  712. if (typeof index !== 'undefined') {
  713. array.splice(index, 0, column);
  714. } else {
  715. array.push(column);
  716. }
  717. if (column.type === 'selection') {
  718. states.selectable = column.selectable;
  719. states.reserveSelection = column.reserveSelection;
  720. }
  721. this.updateColumns(); // hack for dynamics insert column
  722. this.scheduleLayout();
  723. },
  724. removeColumn: function removeColumn(states, column) {
  725. var _columns = states._columns;
  726. if (_columns) {
  727. _columns.splice(_columns.indexOf(column), 1);
  728. }
  729. this.updateColumns(); // hack for dynamics remove column
  730. this.scheduleLayout();
  731. },
  732. setHoverRow: function setHoverRow(states, row) {
  733. states.hoverRow = row;
  734. },
  735. setCurrentRow: function setCurrentRow(states, row) {
  736. var oldCurrentRow = states.currentRow;
  737. states.currentRow = row;
  738. if (oldCurrentRow !== row) {
  739. this.table.$emit('current-change', row, oldCurrentRow);
  740. }
  741. },
  742. rowSelectedChanged: function rowSelectedChanged(states, row) {
  743. var changed = toggleRowSelection(states, row);
  744. var selection = states.selection;
  745. if (changed) {
  746. var table = this.table;
  747. table.$emit('selection-change', selection);
  748. table.$emit('select', selection, row);
  749. }
  750. this.updateAllSelected();
  751. },
  752. toggleRowExpanded: function toggleRowExpanded(states, row, expanded) {
  753. var expandRows = states.expandRows;
  754. if (typeof expanded !== 'undefined') {
  755. var index = expandRows.indexOf(row);
  756. if (expanded) {
  757. if (index === -1) expandRows.push(row);
  758. } else {
  759. if (index !== -1) expandRows.splice(index, 1);
  760. }
  761. } else {
  762. var _index = expandRows.indexOf(row);
  763. if (_index === -1) {
  764. expandRows.push(row);
  765. } else {
  766. expandRows.splice(_index, 1);
  767. }
  768. }
  769. this.table.$emit('expand', row, expandRows.indexOf(row) !== -1);
  770. },
  771. toggleAllSelection: (0, _debounce2.default)(10, function (states) {
  772. var data = states.data || [];
  773. var value = !states.isAllSelected;
  774. var selection = this.states.selection;
  775. var selectionChanged = false;
  776. data.forEach(function (item, index) {
  777. if (states.selectable) {
  778. if (states.selectable.call(null, item, index) && toggleRowSelection(states, item, value)) {
  779. selectionChanged = true;
  780. }
  781. } else {
  782. if (toggleRowSelection(states, item, value)) {
  783. selectionChanged = true;
  784. }
  785. }
  786. });
  787. var table = this.table;
  788. if (selectionChanged) {
  789. table.$emit('selection-change', selection);
  790. }
  791. table.$emit('select-all', selection);
  792. states.isAllSelected = value;
  793. })
  794. };
  795. var doFlattenColumns = function doFlattenColumns(columns) {
  796. var result = [];
  797. columns.forEach(function (column) {
  798. if (column.children) {
  799. result.push.apply(result, doFlattenColumns(column.children));
  800. } else {
  801. result.push(column);
  802. }
  803. });
  804. return result;
  805. };
  806. TableStore.prototype.updateColumns = function () {
  807. var states = this.states;
  808. var _columns = states._columns || [];
  809. states.fixedColumns = _columns.filter(function (column) {
  810. return column.fixed === true || column.fixed === 'left';
  811. });
  812. states.rightFixedColumns = _columns.filter(function (column) {
  813. return column.fixed === 'right';
  814. });
  815. if (states.fixedColumns.length > 0 && _columns[0] && _columns[0].type === 'selection' && !_columns[0].fixed) {
  816. _columns[0].fixed = true;
  817. states.fixedColumns.unshift(_columns[0]);
  818. }
  819. states.originColumns = [].concat(states.fixedColumns).concat(_columns.filter(function (column) {
  820. return !column.fixed;
  821. })).concat(states.rightFixedColumns);
  822. states.columns = doFlattenColumns(states.originColumns);
  823. states.isComplex = states.fixedColumns.length > 0 || states.rightFixedColumns.length > 0;
  824. };
  825. TableStore.prototype.isSelected = function (row) {
  826. return (this.states.selection || []).indexOf(row) > -1;
  827. };
  828. TableStore.prototype.clearSelection = function () {
  829. var states = this.states;
  830. states.isAllSelected = false;
  831. var oldSelection = states.selection;
  832. states.selection = [];
  833. if (oldSelection.length > 0) {
  834. this.table.$emit('selection-change', states.selection);
  835. }
  836. };
  837. TableStore.prototype.setExpandRowKeys = function (rowKeys) {
  838. var expandRows = [];
  839. var data = this.states.data;
  840. var rowKey = this.states.rowKey;
  841. if (!rowKey) throw new Error('[Table] prop row-key should not be empty.');
  842. var keysMap = getKeysMap(data, rowKey);
  843. rowKeys.forEach(function (key) {
  844. var info = keysMap[key];
  845. if (info) {
  846. expandRows.push(info.row);
  847. }
  848. });
  849. this.states.expandRows = expandRows;
  850. };
  851. TableStore.prototype.toggleRowSelection = function (row, selected) {
  852. var changed = toggleRowSelection(this.states, row, selected);
  853. if (changed) {
  854. this.table.$emit('selection-change', this.states.selection);
  855. }
  856. };
  857. TableStore.prototype.cleanSelection = function () {
  858. var selection = this.states.selection || [];
  859. var data = this.states.data;
  860. var rowKey = this.states.rowKey;
  861. var deleted = void 0;
  862. if (rowKey) {
  863. deleted = [];
  864. var selectedMap = getKeysMap(selection, rowKey);
  865. var dataMap = getKeysMap(data, rowKey);
  866. for (var key in selectedMap) {
  867. if (selectedMap.hasOwnProperty(key) && !dataMap[key]) {
  868. deleted.push(selectedMap[key].row);
  869. }
  870. }
  871. } else {
  872. deleted = selection.filter(function (item) {
  873. return data.indexOf(item) === -1;
  874. });
  875. }
  876. deleted.forEach(function (deletedItem) {
  877. selection.splice(selection.indexOf(deletedItem), 1);
  878. });
  879. if (deleted.length) {
  880. this.table.$emit('selection-change', selection);
  881. }
  882. };
  883. TableStore.prototype.updateAllSelected = function () {
  884. var states = this.states;
  885. var selection = states.selection,
  886. rowKey = states.rowKey,
  887. selectable = states.selectable,
  888. data = states.data;
  889. if (!data || data.length === 0) {
  890. states.isAllSelected = false;
  891. return;
  892. }
  893. var selectedMap = void 0;
  894. if (rowKey) {
  895. selectedMap = getKeysMap(states.selection, rowKey);
  896. }
  897. var isSelected = function isSelected(row) {
  898. if (selectedMap) {
  899. return !!selectedMap[(0, _util.getRowIdentity)(row, rowKey)];
  900. } else {
  901. return selection.indexOf(row) !== -1;
  902. }
  903. };
  904. var isAllSelected = true;
  905. var selectedCount = 0;
  906. for (var i = 0, j = data.length; i < j; i++) {
  907. var item = data[i];
  908. if (selectable) {
  909. var isRowSelectable = selectable.call(null, item, i);
  910. if (isRowSelectable) {
  911. if (!isSelected(item)) {
  912. isAllSelected = false;
  913. break;
  914. } else {
  915. selectedCount++;
  916. }
  917. }
  918. } else {
  919. if (!isSelected(item)) {
  920. isAllSelected = false;
  921. break;
  922. } else {
  923. selectedCount++;
  924. }
  925. }
  926. }
  927. if (selectedCount === 0) isAllSelected = false;
  928. states.isAllSelected = isAllSelected;
  929. };
  930. TableStore.prototype.scheduleLayout = function () {
  931. this.table.debouncedLayout();
  932. };
  933. TableStore.prototype.setCurrentRowKey = function (key) {
  934. var states = this.states;
  935. var rowKey = states.rowKey;
  936. if (!rowKey) throw new Error('[Table] row-key should not be empty.');
  937. var data = states.data || [];
  938. var keysMap = getKeysMap(data, rowKey);
  939. var info = keysMap[key];
  940. if (info) {
  941. states.currentRow = info.row;
  942. }
  943. };
  944. TableStore.prototype.updateCurrentRow = function () {
  945. var states = this.states;
  946. var table = this.table;
  947. var data = states.data || [];
  948. var oldCurrentRow = states.currentRow;
  949. if (data.indexOf(oldCurrentRow) === -1) {
  950. states.currentRow = null;
  951. if (states.currentRow !== oldCurrentRow) {
  952. table.$emit('current-change', null, oldCurrentRow);
  953. }
  954. }
  955. };
  956. TableStore.prototype.commit = function (name) {
  957. var mutations = this.mutations;
  958. if (mutations[name]) {
  959. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  960. args[_key - 1] = arguments[_key];
  961. }
  962. mutations[name].apply(this, [this.states].concat(args));
  963. } else {
  964. throw new Error('Action not found: ' + name);
  965. }
  966. };
  967. exports.default = TableStore;
  968. /***/ },
  969. /***/ 306:
  970. /***/ function(module, exports) {
  971. 'use strict';
  972. exports.__esModule = true;
  973. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  974. var getCell = exports.getCell = function getCell(event) {
  975. var cell = event.target;
  976. while (cell && cell.tagName.toUpperCase() !== 'HTML') {
  977. if (cell.tagName.toUpperCase() === 'TD') {
  978. return cell;
  979. }
  980. cell = cell.parentNode;
  981. }
  982. return null;
  983. };
  984. var getValueByPath = exports.getValueByPath = function getValueByPath(object, prop) {
  985. prop = prop || '';
  986. var paths = prop.split('.');
  987. var current = object;
  988. var result = null;
  989. for (var i = 0, j = paths.length; i < j; i++) {
  990. var path = paths[i];
  991. if (!current) break;
  992. if (i === j - 1) {
  993. result = current[path];
  994. break;
  995. }
  996. current = current[path];
  997. }
  998. return result;
  999. };
  1000. var isObject = function isObject(obj) {
  1001. return obj !== null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object';
  1002. };
  1003. var orderBy = exports.orderBy = function orderBy(array, sortKey, reverse, sortMethod) {
  1004. if (typeof reverse === 'string') {
  1005. reverse = reverse === 'descending' ? -1 : 1;
  1006. }
  1007. if (!sortKey) {
  1008. return array;
  1009. }
  1010. var order = reverse && reverse < 0 ? -1 : 1;
  1011. // sort on a copy to avoid mutating original array
  1012. return array.slice().sort(sortMethod ? function (a, b) {
  1013. return sortMethod(a, b) ? order : -order;
  1014. } : function (a, b) {
  1015. if (sortKey !== '$key') {
  1016. if (isObject(a) && '$value' in a) a = a.$value;
  1017. if (isObject(b) && '$value' in b) b = b.$value;
  1018. }
  1019. a = isObject(a) ? getValueByPath(a, sortKey) : a;
  1020. b = isObject(b) ? getValueByPath(b, sortKey) : b;
  1021. return a === b ? 0 : a > b ? order : -order;
  1022. });
  1023. };
  1024. var getColumnById = exports.getColumnById = function getColumnById(table, columnId) {
  1025. var column = null;
  1026. table.columns.forEach(function (item) {
  1027. if (item.id === columnId) {
  1028. column = item;
  1029. }
  1030. });
  1031. return column;
  1032. };
  1033. var getColumnByCell = exports.getColumnByCell = function getColumnByCell(table, cell) {
  1034. var matches = (cell.className || '').match(/el-table_[^\s]+/gm);
  1035. if (matches) {
  1036. return getColumnById(table, matches[0]);
  1037. }
  1038. return null;
  1039. };
  1040. var isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
  1041. var mousewheel = exports.mousewheel = function mousewheel(element, callback) {
  1042. if (element && element.addEventListener) {
  1043. element.addEventListener(isFirefox ? 'DOMMouseScroll' : 'mousewheel', callback);
  1044. }
  1045. };
  1046. var getRowIdentity = exports.getRowIdentity = function getRowIdentity(row, rowKey) {
  1047. if (!row) throw new Error('row is required when get row identity');
  1048. if (typeof rowKey === 'string') {
  1049. return row[rowKey];
  1050. } else if (typeof rowKey === 'function') {
  1051. return rowKey.call(null, row);
  1052. }
  1053. };
  1054. /***/ },
  1055. /***/ 307:
  1056. /***/ function(module, exports, __webpack_require__) {
  1057. 'use strict';
  1058. exports.__esModule = true;
  1059. var _scrollbarWidth = __webpack_require__(256);
  1060. var _scrollbarWidth2 = _interopRequireDefault(_scrollbarWidth);
  1061. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1062. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1063. var TableLayout = function () {
  1064. function TableLayout(options) {
  1065. _classCallCheck(this, TableLayout);
  1066. this.table = null;
  1067. this.store = null;
  1068. this.columns = null;
  1069. this.fit = true;
  1070. this.showHeader = true;
  1071. this.height = null;
  1072. this.scrollX = false;
  1073. this.scrollY = false;
  1074. this.bodyWidth = null;
  1075. this.fixedWidth = null;
  1076. this.rightFixedWidth = null;
  1077. this.tableHeight = null;
  1078. this.headerHeight = 44; // Table Header Height
  1079. this.viewportHeight = null; // Table Height - Scroll Bar Height
  1080. this.bodyHeight = null; // Table Height - Table Header Height
  1081. this.fixedBodyHeight = null; // Table Height - Table Header Height - Scroll Bar Height
  1082. this.gutterWidth = (0, _scrollbarWidth2.default)();
  1083. for (var name in options) {
  1084. if (options.hasOwnProperty(name)) {
  1085. this[name] = options[name];
  1086. }
  1087. }
  1088. if (!this.table) {
  1089. throw new Error('table is required for Table Layout');
  1090. }
  1091. if (!this.store) {
  1092. throw new Error('store is required for Table Layout');
  1093. }
  1094. }
  1095. TableLayout.prototype.updateScrollY = function updateScrollY() {
  1096. var height = this.height;
  1097. if (typeof height !== 'string' && typeof height !== 'number') return;
  1098. var bodyWrapper = this.table.bodyWrapper;
  1099. if (this.table.$el && bodyWrapper) {
  1100. var body = bodyWrapper.querySelector('.el-table__body');
  1101. this.scrollY = body.offsetHeight > bodyWrapper.offsetHeight;
  1102. }
  1103. };
  1104. TableLayout.prototype.setHeight = function setHeight(value) {
  1105. var prop = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'height';
  1106. var el = this.table.$el;
  1107. if (typeof value === 'string' && /^\d+$/.test(value)) {
  1108. value = Number(value);
  1109. }
  1110. this.height = value;
  1111. if (!el) return;
  1112. if (typeof value === 'number') {
  1113. el.style[prop] = value + 'px';
  1114. this.updateHeight();
  1115. } else if (typeof value === 'string') {
  1116. if (value === '') {
  1117. el.style[prop] = '';
  1118. }
  1119. this.updateHeight();
  1120. }
  1121. };
  1122. TableLayout.prototype.setMaxHeight = function setMaxHeight(value) {
  1123. return this.setHeight(value, 'max-height');
  1124. };
  1125. TableLayout.prototype.updateHeight = function updateHeight() {
  1126. var height = this.tableHeight = this.table.$el.clientHeight;
  1127. var noData = !this.table.data || this.table.data.length === 0;
  1128. var headerWrapper = this.table.$refs.headerWrapper;
  1129. if (this.showHeader && !headerWrapper) return;
  1130. if (!this.showHeader) {
  1131. this.headerHeight = 0;
  1132. if (this.height !== null && (!isNaN(this.height) || typeof this.height === 'string')) {
  1133. this.bodyHeight = height;
  1134. }
  1135. this.fixedBodyHeight = this.scrollX ? height - this.gutterWidth : height;
  1136. } else {
  1137. var headerHeight = this.headerHeight = headerWrapper.offsetHeight;
  1138. var bodyHeight = height - headerHeight;
  1139. if (this.height !== null && (!isNaN(this.height) || typeof this.height === 'string')) {
  1140. this.bodyHeight = bodyHeight;
  1141. }
  1142. this.fixedBodyHeight = this.scrollX ? bodyHeight - this.gutterWidth : bodyHeight;
  1143. }
  1144. this.viewportHeight = this.scrollX ? height - (noData ? 0 : this.gutterWidth) : height;
  1145. };
  1146. TableLayout.prototype.update = function update() {
  1147. var fit = this.fit;
  1148. var columns = this.table.columns;
  1149. var bodyWidth = this.table.$el.clientWidth;
  1150. var bodyMinWidth = 0;
  1151. var flattenColumns = [];
  1152. columns.forEach(function (column) {
  1153. if (column.isColumnGroup) {
  1154. flattenColumns.push.apply(flattenColumns, column.columns);
  1155. } else {
  1156. flattenColumns.push(column);
  1157. }
  1158. });
  1159. var flexColumns = flattenColumns.filter(function (column) {
  1160. return typeof column.width !== 'number';
  1161. });
  1162. if (flexColumns.length > 0 && fit) {
  1163. flattenColumns.forEach(function (column) {
  1164. bodyMinWidth += column.width || column.minWidth || 80;
  1165. });
  1166. if (bodyMinWidth < bodyWidth - this.gutterWidth) {
  1167. // DON'T HAVE SCROLL BAR
  1168. this.scrollX = false;
  1169. var totalFlexWidth = bodyWidth - this.gutterWidth - bodyMinWidth;
  1170. if (flexColumns.length === 1) {
  1171. flexColumns[0].realWidth = (flexColumns[0].minWidth || 80) + totalFlexWidth;
  1172. } else {
  1173. (function () {
  1174. var allColumnsWidth = flexColumns.reduce(function (prev, column) {
  1175. return prev + (column.minWidth || 80);
  1176. }, 0);
  1177. var flexWidthPerPixel = totalFlexWidth / allColumnsWidth;
  1178. var noneFirstWidth = 0;
  1179. flexColumns.forEach(function (column, index) {
  1180. if (index === 0) return;
  1181. var flexWidth = Math.floor((column.minWidth || 80) * flexWidthPerPixel);
  1182. noneFirstWidth += flexWidth;
  1183. column.realWidth = (column.minWidth || 80) + flexWidth;
  1184. });
  1185. flexColumns[0].realWidth = (flexColumns[0].minWidth || 80) + totalFlexWidth - noneFirstWidth;
  1186. })();
  1187. }
  1188. } else {
  1189. // HAVE HORIZONTAL SCROLL BAR
  1190. this.scrollX = true;
  1191. flexColumns.forEach(function (column) {
  1192. column.realWidth = column.minWidth;
  1193. });
  1194. }
  1195. this.bodyWidth = Math.max(bodyMinWidth, bodyWidth);
  1196. } else {
  1197. flattenColumns.forEach(function (column) {
  1198. if (!column.width && !column.minWidth) {
  1199. column.realWidth = 80;
  1200. } else {
  1201. column.realWidth = column.width || column.minWidth;
  1202. }
  1203. bodyMinWidth += column.realWidth;
  1204. });
  1205. this.scrollX = bodyMinWidth > bodyWidth;
  1206. this.bodyWidth = bodyMinWidth;
  1207. }
  1208. var fixedColumns = this.store.states.fixedColumns;
  1209. if (fixedColumns.length > 0) {
  1210. var fixedWidth = 0;
  1211. fixedColumns.forEach(function (column) {
  1212. fixedWidth += column.realWidth;
  1213. });
  1214. this.fixedWidth = fixedWidth;
  1215. }
  1216. var rightFixedColumns = this.store.states.rightFixedColumns;
  1217. if (rightFixedColumns.length > 0) {
  1218. var rightFixedWidth = 0;
  1219. rightFixedColumns.forEach(function (column) {
  1220. rightFixedWidth += column.realWidth;
  1221. });
  1222. this.rightFixedWidth = rightFixedWidth;
  1223. }
  1224. };
  1225. return TableLayout;
  1226. }();
  1227. exports.default = TableLayout;
  1228. /***/ },
  1229. /***/ 308:
  1230. /***/ function(module, exports, __webpack_require__) {
  1231. 'use strict';
  1232. exports.__esModule = true;
  1233. var _util = __webpack_require__(306);
  1234. var _dom = __webpack_require__(117);
  1235. var _checkbox = __webpack_require__(304);
  1236. var _checkbox2 = _interopRequireDefault(_checkbox);
  1237. var _tooltip = __webpack_require__(274);
  1238. var _tooltip2 = _interopRequireDefault(_tooltip);
  1239. var _debounce = __webpack_require__(46);
  1240. var _debounce2 = _interopRequireDefault(_debounce);
  1241. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1242. exports.default = {
  1243. components: {
  1244. ElCheckbox: _checkbox2.default,
  1245. ElTooltip: _tooltip2.default
  1246. },
  1247. props: {
  1248. store: {
  1249. required: true
  1250. },
  1251. context: {},
  1252. layout: {
  1253. required: true
  1254. },
  1255. rowClassName: [String, Function],
  1256. rowStyle: [Object, Function],
  1257. fixed: String,
  1258. highlight: Boolean
  1259. },
  1260. render: function render(h) {
  1261. var _this = this;
  1262. var columnsHidden = this.columns.map(function (column, index) {
  1263. return _this.isColumnHidden(index);
  1264. });
  1265. return h(
  1266. 'table',
  1267. {
  1268. 'class': 'el-table__body',
  1269. attrs: { cellspacing: '0',
  1270. cellpadding: '0',
  1271. border: '0' }
  1272. },
  1273. [h(
  1274. 'colgroup',
  1275. null,
  1276. [this._l(this.columns, function (column) {
  1277. return h(
  1278. 'col',
  1279. {
  1280. attrs: {
  1281. name: column.id,
  1282. width: column.realWidth || column.width
  1283. }
  1284. },
  1285. []
  1286. );
  1287. })]
  1288. ), h(
  1289. 'tbody',
  1290. null,
  1291. [this._l(this.data, function (row, $index) {
  1292. return [h(
  1293. 'tr',
  1294. {
  1295. style: _this.rowStyle ? _this.getRowStyle(row, $index) : null,
  1296. key: _this.table.rowKey ? _this.getKeyOfRow(row, $index) : $index,
  1297. on: {
  1298. 'dblclick': function dblclick($event) {
  1299. return _this.handleDoubleClick($event, row);
  1300. },
  1301. 'click': function click($event) {
  1302. return _this.handleClick($event, row);
  1303. },
  1304. 'contextmenu': function contextmenu($event) {
  1305. return _this.handleContextMenu($event, row);
  1306. },
  1307. 'mouseenter': function mouseenter(_) {
  1308. return _this.handleMouseEnter($index);
  1309. },
  1310. 'mouseleave': function mouseleave(_) {
  1311. return _this.handleMouseLeave();
  1312. }
  1313. },
  1314. 'class': [_this.getRowClass(row, $index)] },
  1315. [_this._l(_this.columns, function (column, cellIndex) {
  1316. return h(
  1317. 'td',
  1318. {
  1319. 'class': [column.id, column.align, column.className || '', columnsHidden[cellIndex] ? 'is-hidden' : ''],
  1320. on: {
  1321. 'mouseenter': function mouseenter($event) {
  1322. return _this.handleCellMouseEnter($event, row);
  1323. },
  1324. 'mouseleave': _this.handleCellMouseLeave
  1325. }
  1326. },
  1327. [column.renderCell.call(_this._renderProxy, h, { row: row, column: column, $index: $index, store: _this.store, _self: _this.context || _this.table.$vnode.context }, columnsHidden[cellIndex])]
  1328. );
  1329. }), !_this.fixed && _this.layout.scrollY && _this.layout.gutterWidth ? h(
  1330. 'td',
  1331. { 'class': 'gutter' },
  1332. []
  1333. ) : '']
  1334. ), _this.store.states.expandRows.indexOf(row) > -1 ? h(
  1335. 'tr',
  1336. null,
  1337. [h(
  1338. 'td',
  1339. {
  1340. attrs: { colspan: _this.columns.length },
  1341. 'class': 'el-table__expanded-cell' },
  1342. [_this.table.renderExpanded ? _this.table.renderExpanded(h, { row: row, $index: $index, store: _this.store }) : '']
  1343. )]
  1344. ) : ''];
  1345. }).concat(h(
  1346. 'el-tooltip',
  1347. {
  1348. attrs: { effect: this.table.tooltipEffect, placement: 'top', content: this.tooltipContent },
  1349. ref: 'tooltip' },
  1350. []
  1351. ))]
  1352. )]
  1353. );
  1354. },
  1355. watch: {
  1356. 'store.states.hoverRow': function storeStatesHoverRow(newVal, oldVal) {
  1357. if (!this.store.states.isComplex) return;
  1358. var el = this.$el;
  1359. if (!el) return;
  1360. var rows = el.querySelectorAll('tbody > tr');
  1361. var oldRow = rows[oldVal];
  1362. var newRow = rows[newVal];
  1363. if (oldRow) {
  1364. oldRow.classList.remove('hover-row');
  1365. }
  1366. if (newRow) {
  1367. newRow.classList.add('hover-row');
  1368. }
  1369. },
  1370. 'store.states.currentRow': function storeStatesCurrentRow(newVal, oldVal) {
  1371. if (!this.highlight) return;
  1372. var el = this.$el;
  1373. if (!el) return;
  1374. var data = this.store.states.data;
  1375. var rows = el.querySelectorAll('tbody > tr');
  1376. var oldRow = rows[data.indexOf(oldVal)];
  1377. var newRow = rows[data.indexOf(newVal)];
  1378. if (oldRow) {
  1379. oldRow.classList.remove('current-row');
  1380. } else if (rows) {
  1381. [].forEach.call(rows, function (row) {
  1382. return row.classList.remove('current-row');
  1383. });
  1384. }
  1385. if (newRow) {
  1386. newRow.classList.add('current-row');
  1387. }
  1388. }
  1389. },
  1390. computed: {
  1391. table: function table() {
  1392. return this.$parent;
  1393. },
  1394. data: function data() {
  1395. return this.store.states.data;
  1396. },
  1397. columnsCount: function columnsCount() {
  1398. return this.store.states.columns.length;
  1399. },
  1400. leftFixedCount: function leftFixedCount() {
  1401. return this.store.states.fixedColumns.length;
  1402. },
  1403. rightFixedCount: function rightFixedCount() {
  1404. return this.store.states.rightFixedColumns.length;
  1405. },
  1406. columns: function columns() {
  1407. return this.store.states.columns;
  1408. }
  1409. },
  1410. data: function data() {
  1411. return {
  1412. tooltipContent: ''
  1413. };
  1414. },
  1415. created: function created() {
  1416. this.activateTooltip = (0, _debounce2.default)(50, function (tooltip) {
  1417. return tooltip.handleShowPopper();
  1418. });
  1419. },
  1420. methods: {
  1421. getKeyOfRow: function getKeyOfRow(row, index) {
  1422. var rowKey = this.table.rowKey;
  1423. if (rowKey) {
  1424. return (0, _util.getRowIdentity)(row, rowKey);
  1425. }
  1426. return index;
  1427. },
  1428. isColumnHidden: function isColumnHidden(index) {
  1429. if (this.fixed === true || this.fixed === 'left') {
  1430. return index >= this.leftFixedCount;
  1431. } else if (this.fixed === 'right') {
  1432. return index < this.columnsCount - this.rightFixedCount;
  1433. } else {
  1434. return index < this.leftFixedCount || index >= this.columnsCount - this.rightFixedCount;
  1435. }
  1436. },
  1437. getRowStyle: function getRowStyle(row, index) {
  1438. var rowStyle = this.rowStyle;
  1439. if (typeof rowStyle === 'function') {
  1440. return rowStyle.call(null, row, index);
  1441. }
  1442. return rowStyle;
  1443. },
  1444. getRowClass: function getRowClass(row, index) {
  1445. var classes = [];
  1446. var rowClassName = this.rowClassName;
  1447. if (typeof rowClassName === 'string') {
  1448. classes.push(rowClassName);
  1449. } else if (typeof rowClassName === 'function') {
  1450. classes.push(rowClassName.call(null, row, index) || '');
  1451. }
  1452. return classes.join(' ');
  1453. },
  1454. handleCellMouseEnter: function handleCellMouseEnter(event, row) {
  1455. var table = this.table;
  1456. var cell = (0, _util.getCell)(event);
  1457. if (cell) {
  1458. var column = (0, _util.getColumnByCell)(table, cell);
  1459. var hoverState = table.hoverState = { cell: cell, column: column, row: row };
  1460. table.$emit('cell-mouse-enter', hoverState.row, hoverState.column, hoverState.cell, event);
  1461. }
  1462. // 判断是否text-overflow, 如果是就显示tooltip
  1463. var cellChild = event.target.querySelector('.cell');
  1464. if ((0, _dom.hasClass)(cellChild, 'el-tooltip') && cellChild.scrollWidth > cellChild.offsetWidth) {
  1465. var tooltip = this.$refs.tooltip;
  1466. this.tooltipContent = cell.innerText;
  1467. tooltip.referenceElm = cell;
  1468. tooltip.$refs.popper.style.display = 'none';
  1469. tooltip.doDestroy();
  1470. this.activateTooltip(tooltip);
  1471. }
  1472. },
  1473. handleCellMouseLeave: function handleCellMouseLeave(event) {
  1474. this.$refs.tooltip.handleClosePopper();
  1475. var cell = (0, _util.getCell)(event);
  1476. if (!cell) return;
  1477. var oldHoverState = this.table.hoverState;
  1478. this.table.$emit('cell-mouse-leave', oldHoverState.row, oldHoverState.column, oldHoverState.cell, event);
  1479. },
  1480. handleMouseEnter: function handleMouseEnter(index) {
  1481. this.store.commit('setHoverRow', index);
  1482. },
  1483. handleMouseLeave: function handleMouseLeave() {
  1484. this.store.commit('setHoverRow', null);
  1485. },
  1486. handleContextMenu: function handleContextMenu(event, row) {
  1487. this.handleEvent(event, row, 'contextmenu');
  1488. },
  1489. handleDoubleClick: function handleDoubleClick(event, row) {
  1490. this.handleEvent(event, row, 'dblclick');
  1491. },
  1492. handleClick: function handleClick(event, row) {
  1493. this.store.commit('setCurrentRow', row);
  1494. this.handleEvent(event, row, 'click');
  1495. },
  1496. handleEvent: function handleEvent(event, row, name) {
  1497. var table = this.table;
  1498. var cell = (0, _util.getCell)(event);
  1499. var column = void 0;
  1500. if (cell) {
  1501. column = (0, _util.getColumnByCell)(table, cell);
  1502. if (column) {
  1503. table.$emit('cell-' + name, row, column, cell, event);
  1504. }
  1505. }
  1506. table.$emit('row-' + name, row, event, column);
  1507. },
  1508. handleExpandClick: function handleExpandClick(row) {
  1509. this.store.commit('toggleRowExpanded', row);
  1510. }
  1511. }
  1512. };
  1513. /***/ },
  1514. /***/ 309:
  1515. /***/ function(module, exports, __webpack_require__) {
  1516. 'use strict';
  1517. exports.__esModule = true;
  1518. var _checkbox = __webpack_require__(304);
  1519. var _checkbox2 = _interopRequireDefault(_checkbox);
  1520. var _tag = __webpack_require__(266);
  1521. var _tag2 = _interopRequireDefault(_tag);
  1522. var _vue = __webpack_require__(56);
  1523. var _vue2 = _interopRequireDefault(_vue);
  1524. var _filterPanel = __webpack_require__(310);
  1525. var _filterPanel2 = _interopRequireDefault(_filterPanel);
  1526. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1527. var getAllColumns = function getAllColumns(columns) {
  1528. var result = [];
  1529. columns.forEach(function (column) {
  1530. if (column.children) {
  1531. result.push(column);
  1532. result.push.apply(result, getAllColumns(column.children));
  1533. } else {
  1534. result.push(column);
  1535. }
  1536. });
  1537. return result;
  1538. };
  1539. var convertToRows = function convertToRows(originColumns) {
  1540. var maxLevel = 1;
  1541. var traverse = function traverse(column, parent) {
  1542. if (parent) {
  1543. column.level = parent.level + 1;
  1544. if (maxLevel < column.level) {
  1545. maxLevel = column.level;
  1546. }
  1547. }
  1548. if (column.children) {
  1549. var colSpan = 0;
  1550. column.children.forEach(function (subColumn) {
  1551. traverse(subColumn, column);
  1552. colSpan += subColumn.colSpan;
  1553. });
  1554. column.colSpan = colSpan;
  1555. } else {
  1556. column.colSpan = 1;
  1557. }
  1558. };
  1559. originColumns.forEach(function (column) {
  1560. column.level = 1;
  1561. traverse(column);
  1562. });
  1563. var rows = [];
  1564. for (var i = 0; i < maxLevel; i++) {
  1565. rows.push([]);
  1566. }
  1567. var allColumns = getAllColumns(originColumns);
  1568. allColumns.forEach(function (column) {
  1569. if (!column.children) {
  1570. column.rowSpan = maxLevel - column.level + 1;
  1571. } else {
  1572. column.rowSpan = 1;
  1573. }
  1574. rows[column.level - 1].push(column);
  1575. });
  1576. return rows;
  1577. };
  1578. exports.default = {
  1579. name: 'ElTableHeader',
  1580. render: function render(h) {
  1581. var _this = this;
  1582. var originColumns = this.store.states.originColumns;
  1583. var columnRows = convertToRows(originColumns, this.columns);
  1584. return h(
  1585. 'table',
  1586. {
  1587. 'class': 'el-table__header',
  1588. attrs: { cellspacing: '0',
  1589. cellpadding: '0',
  1590. border: '0' }
  1591. },
  1592. [h(
  1593. 'colgroup',
  1594. null,
  1595. [this._l(this.columns, function (column) {
  1596. return h(
  1597. 'col',
  1598. {
  1599. attrs: {
  1600. name: column.id,
  1601. width: column.realWidth || column.width
  1602. }
  1603. },
  1604. []
  1605. );
  1606. }), !this.fixed && this.layout.gutterWidth ? h(
  1607. 'col',
  1608. {
  1609. attrs: { name: 'gutter', width: this.layout.scrollY ? this.layout.gutterWidth : '' }
  1610. },
  1611. []
  1612. ) : '']
  1613. ), h(
  1614. 'thead',
  1615. null,
  1616. [this._l(columnRows, function (columns, rowIndex) {
  1617. return h(
  1618. 'tr',
  1619. null,
  1620. [_this._l(columns, function (column, cellIndex) {
  1621. return h(
  1622. 'th',
  1623. {
  1624. attrs: {
  1625. colspan: column.colSpan,
  1626. rowspan: column.rowSpan
  1627. },
  1628. on: {
  1629. 'mousemove': function mousemove($event) {
  1630. return _this.handleMouseMove($event, column);
  1631. },
  1632. 'mouseout': _this.handleMouseOut,
  1633. 'mousedown': function mousedown($event) {
  1634. return _this.handleMouseDown($event, column);
  1635. },
  1636. 'click': function click($event) {
  1637. return _this.handleHeaderClick($event, column);
  1638. }
  1639. },
  1640. 'class': [column.id, column.order, column.headerAlign, column.className || '', rowIndex === 0 && _this.isCellHidden(cellIndex, columns) ? 'is-hidden' : '', !column.children ? 'is-leaf' : '', column.labelClassName] },
  1641. [h(
  1642. 'div',
  1643. { 'class': ['cell', column.filteredValue && column.filteredValue.length > 0 ? 'highlight' : '', column.labelClassName] },
  1644. [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(
  1645. 'span',
  1646. { 'class': 'caret-wrapper', on: {
  1647. 'click': function click($event) {
  1648. return _this.handleSortClick($event, column);
  1649. }
  1650. }
  1651. },
  1652. [h(
  1653. 'i',
  1654. { 'class': 'sort-caret ascending', on: {
  1655. 'click': function click($event) {
  1656. return _this.handleSortClick($event, column, 'ascending');
  1657. }
  1658. }
  1659. },
  1660. []
  1661. ), h(
  1662. 'i',
  1663. { 'class': 'sort-caret descending', on: {
  1664. 'click': function click($event) {
  1665. return _this.handleSortClick($event, column, 'descending');
  1666. }
  1667. }
  1668. },
  1669. []
  1670. )]
  1671. ) : '', column.filterable ? h(
  1672. 'span',
  1673. { 'class': 'el-table__column-filter-trigger', on: {
  1674. 'click': function click($event) {
  1675. return _this.handleFilterClick($event, column);
  1676. }
  1677. }
  1678. },
  1679. [h(
  1680. 'i',
  1681. { 'class': ['el-icon-arrow-down', column.filterOpened ? 'el-icon-arrow-up' : ''] },
  1682. []
  1683. )]
  1684. ) : '']
  1685. )]
  1686. );
  1687. }), !_this.fixed && _this.layout.gutterWidth ? h(
  1688. 'th',
  1689. { 'class': 'gutter', style: { width: _this.layout.scrollY ? _this.layout.gutterWidth + 'px' : '0' } },
  1690. []
  1691. ) : '']
  1692. );
  1693. })]
  1694. )]
  1695. );
  1696. },
  1697. props: {
  1698. fixed: String,
  1699. store: {
  1700. required: true
  1701. },
  1702. layout: {
  1703. required: true
  1704. },
  1705. border: Boolean,
  1706. defaultSort: {
  1707. type: Object,
  1708. default: function _default() {
  1709. return {
  1710. prop: '',
  1711. order: ''
  1712. };
  1713. }
  1714. }
  1715. },
  1716. components: {
  1717. ElCheckbox: _checkbox2.default,
  1718. ElTag: _tag2.default
  1719. },
  1720. computed: {
  1721. isAllSelected: function isAllSelected() {
  1722. return this.store.states.isAllSelected;
  1723. },
  1724. columnsCount: function columnsCount() {
  1725. return this.store.states.columns.length;
  1726. },
  1727. leftFixedCount: function leftFixedCount() {
  1728. return this.store.states.fixedColumns.length;
  1729. },
  1730. rightFixedCount: function rightFixedCount() {
  1731. return this.store.states.rightFixedColumns.length;
  1732. },
  1733. columns: function columns() {
  1734. return this.store.states.columns;
  1735. }
  1736. },
  1737. created: function created() {
  1738. this.filterPanels = {};
  1739. },
  1740. mounted: function mounted() {
  1741. var _this2 = this;
  1742. if (this.defaultSort.prop) {
  1743. (function () {
  1744. var states = _this2.store.states;
  1745. states.sortProp = _this2.defaultSort.prop;
  1746. states.sortOrder = _this2.defaultSort.order || 'ascending';
  1747. _this2.$nextTick(function (_) {
  1748. for (var i = 0, length = _this2.columns.length; i < length; i++) {
  1749. var column = _this2.columns[i];
  1750. if (column.property === states.sortProp) {
  1751. column.order = states.sortOrder;
  1752. states.sortingColumn = column;
  1753. break;
  1754. }
  1755. }
  1756. if (states.sortingColumn) {
  1757. _this2.store.commit('changeSortCondition');
  1758. }
  1759. });
  1760. })();
  1761. }
  1762. },
  1763. beforeDestroy: function beforeDestroy() {
  1764. var panels = this.filterPanels;
  1765. for (var prop in panels) {
  1766. if (panels.hasOwnProperty(prop) && panels[prop]) {
  1767. panels[prop].$destroy(true);
  1768. }
  1769. }
  1770. },
  1771. methods: {
  1772. isCellHidden: function isCellHidden(index, columns) {
  1773. if (this.fixed === true || this.fixed === 'left') {
  1774. return index >= this.leftFixedCount;
  1775. } else if (this.fixed === 'right') {
  1776. var before = 0;
  1777. for (var i = 0; i < index; i++) {
  1778. before += columns[i].colSpan;
  1779. }
  1780. return before < this.columnsCount - this.rightFixedCount;
  1781. } else {
  1782. return index < this.leftFixedCount || index >= this.columnsCount - this.rightFixedCount;
  1783. }
  1784. },
  1785. toggleAllSelection: function toggleAllSelection() {
  1786. this.store.commit('toggleAllSelection');
  1787. },
  1788. handleFilterClick: function handleFilterClick(event, column) {
  1789. event.stopPropagation();
  1790. var target = event.target;
  1791. var cell = target.parentNode;
  1792. var table = this.$parent;
  1793. var filterPanel = this.filterPanels[column.id];
  1794. if (filterPanel && column.filterOpened) {
  1795. filterPanel.showPopper = false;
  1796. return;
  1797. }
  1798. if (!filterPanel) {
  1799. filterPanel = new _vue2.default(_filterPanel2.default);
  1800. this.filterPanels[column.id] = filterPanel;
  1801. filterPanel.table = table;
  1802. filterPanel.cell = cell;
  1803. filterPanel.column = column;
  1804. !this.$isServer && filterPanel.$mount(document.createElement('div'));
  1805. }
  1806. setTimeout(function () {
  1807. filterPanel.showPopper = true;
  1808. }, 16);
  1809. },
  1810. handleHeaderClick: function handleHeaderClick(event, column) {
  1811. if (!column.filters && column.sortable) {
  1812. this.handleSortClick(event, column);
  1813. } else if (column.filters && !column.sortable) {
  1814. this.handleFilterClick(event, column);
  1815. }
  1816. this.$parent.$emit('header-click', column, event);
  1817. },
  1818. handleMouseDown: function handleMouseDown(event, column) {
  1819. var _this3 = this;
  1820. if (this.$isServer) return;
  1821. if (column.children && column.children.length > 0) return;
  1822. /* istanbul ignore if */
  1823. if (this.draggingColumn && this.border) {
  1824. (function () {
  1825. _this3.dragging = true;
  1826. _this3.$parent.resizeProxyVisible = true;
  1827. var table = _this3.$parent;
  1828. var tableEl = table.$el;
  1829. var tableLeft = tableEl.getBoundingClientRect().left;
  1830. var columnEl = _this3.$el.querySelector('th.' + column.id);
  1831. var columnRect = columnEl.getBoundingClientRect();
  1832. var minLeft = columnRect.left - tableLeft + 30;
  1833. columnEl.classList.add('noclick');
  1834. _this3.dragState = {
  1835. startMouseLeft: event.clientX,
  1836. startLeft: columnRect.right - tableLeft,
  1837. startColumnLeft: columnRect.left - tableLeft,
  1838. tableLeft: tableLeft
  1839. };
  1840. var resizeProxy = table.$refs.resizeProxy;
  1841. resizeProxy.style.left = _this3.dragState.startLeft + 'px';
  1842. document.onselectstart = function () {
  1843. return false;
  1844. };
  1845. document.ondragstart = function () {
  1846. return false;
  1847. };
  1848. var handleMouseMove = function handleMouseMove(event) {
  1849. var deltaLeft = event.clientX - _this3.dragState.startMouseLeft;
  1850. var proxyLeft = _this3.dragState.startLeft + deltaLeft;
  1851. resizeProxy.style.left = Math.max(minLeft, proxyLeft) + 'px';
  1852. };
  1853. var handleMouseUp = function handleMouseUp() {
  1854. if (_this3.dragging) {
  1855. var _dragState = _this3.dragState,
  1856. startColumnLeft = _dragState.startColumnLeft,
  1857. startLeft = _dragState.startLeft;
  1858. var finalLeft = parseInt(resizeProxy.style.left, 10);
  1859. var columnWidth = finalLeft - startColumnLeft;
  1860. column.width = column.realWidth = columnWidth;
  1861. table.$emit('header-dragend', column.width, startLeft - startColumnLeft, column, event);
  1862. _this3.store.scheduleLayout();
  1863. document.body.style.cursor = '';
  1864. _this3.dragging = false;
  1865. _this3.draggingColumn = null;
  1866. _this3.dragState = {};
  1867. table.resizeProxyVisible = false;
  1868. }
  1869. document.removeEventListener('mousemove', handleMouseMove);
  1870. document.removeEventListener('mouseup', handleMouseUp);
  1871. document.onselectstart = null;
  1872. document.ondragstart = null;
  1873. setTimeout(function () {
  1874. columnEl.classList.remove('noclick');
  1875. }, 0);
  1876. };
  1877. document.addEventListener('mousemove', handleMouseMove);
  1878. document.addEventListener('mouseup', handleMouseUp);
  1879. })();
  1880. }
  1881. },
  1882. handleMouseMove: function handleMouseMove(event, column) {
  1883. if (column.children && column.children.length > 0) return;
  1884. var target = event.target;
  1885. while (target && target.tagName !== 'TH') {
  1886. target = target.parentNode;
  1887. }
  1888. if (!column || !column.resizable) return;
  1889. if (!this.dragging && this.border) {
  1890. var rect = target.getBoundingClientRect();
  1891. var bodyStyle = document.body.style;
  1892. if (rect.width > 12 && rect.right - event.pageX < 8) {
  1893. bodyStyle.cursor = 'col-resize';
  1894. this.draggingColumn = column;
  1895. } else if (!this.dragging) {
  1896. bodyStyle.cursor = '';
  1897. this.draggingColumn = null;
  1898. }
  1899. }
  1900. },
  1901. handleMouseOut: function handleMouseOut() {
  1902. if (this.$isServer) return;
  1903. document.body.style.cursor = '';
  1904. },
  1905. toggleOrder: function toggleOrder(order) {
  1906. return !order ? 'ascending' : order === 'ascending' ? 'descending' : null;
  1907. },
  1908. handleSortClick: function handleSortClick(event, column, givenOrder) {
  1909. event.stopPropagation();
  1910. var order = givenOrder || this.toggleOrder(column.order);
  1911. var target = event.target;
  1912. while (target && target.tagName !== 'TH') {
  1913. target = target.parentNode;
  1914. }
  1915. if (target && target.tagName === 'TH') {
  1916. if (target.classList.contains('noclick')) {
  1917. target.classList.remove('noclick');
  1918. return;
  1919. }
  1920. }
  1921. if (!column.sortable) return;
  1922. var states = this.store.states;
  1923. var sortProp = states.sortProp;
  1924. var sortOrder = void 0;
  1925. var sortingColumn = states.sortingColumn;
  1926. if (sortingColumn !== column) {
  1927. if (sortingColumn) {
  1928. sortingColumn.order = null;
  1929. }
  1930. states.sortingColumn = column;
  1931. sortProp = column.property;
  1932. }
  1933. if (!order) {
  1934. sortOrder = column.order = null;
  1935. states.sortingColumn = null;
  1936. sortProp = null;
  1937. } else {
  1938. sortOrder = column.order = order;
  1939. }
  1940. states.sortProp = sortProp;
  1941. states.sortOrder = sortOrder;
  1942. this.store.commit('changeSortCondition');
  1943. }
  1944. },
  1945. data: function data() {
  1946. return {
  1947. draggingColumn: null,
  1948. dragging: false,
  1949. dragState: {}
  1950. };
  1951. }
  1952. };
  1953. /***/ },
  1954. /***/ 310:
  1955. /***/ function(module, exports, __webpack_require__) {
  1956. var Component = __webpack_require__(3)(
  1957. /* script */
  1958. __webpack_require__(311),
  1959. /* template */
  1960. __webpack_require__(314),
  1961. /* scopeId */
  1962. null,
  1963. /* cssModules */
  1964. null
  1965. )
  1966. module.exports = Component.exports
  1967. /***/ },
  1968. /***/ 311:
  1969. /***/ function(module, exports, __webpack_require__) {
  1970. 'use strict';
  1971. exports.__esModule = true;
  1972. var _vuePopper = __webpack_require__(13);
  1973. var _vuePopper2 = _interopRequireDefault(_vuePopper);
  1974. var _popup = __webpack_require__(132);
  1975. var _locale = __webpack_require__(60);
  1976. var _locale2 = _interopRequireDefault(_locale);
  1977. var _clickoutside = __webpack_require__(10);
  1978. var _clickoutside2 = _interopRequireDefault(_clickoutside);
  1979. var _dropdown = __webpack_require__(312);
  1980. var _dropdown2 = _interopRequireDefault(_dropdown);
  1981. var _checkbox = __webpack_require__(304);
  1982. var _checkbox2 = _interopRequireDefault(_checkbox);
  1983. var _checkboxGroup = __webpack_require__(313);
  1984. var _checkboxGroup2 = _interopRequireDefault(_checkboxGroup);
  1985. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1986. exports.default = {
  1987. name: 'ElTableFilterPanel',
  1988. mixins: [_vuePopper2.default, _locale2.default],
  1989. directives: {
  1990. Clickoutside: _clickoutside2.default
  1991. },
  1992. components: {
  1993. ElCheckbox: _checkbox2.default,
  1994. ElCheckboxGroup: _checkboxGroup2.default
  1995. },
  1996. props: {
  1997. placement: {
  1998. type: String,
  1999. default: 'bottom-end'
  2000. }
  2001. },
  2002. customRender: function customRender(h) {
  2003. return h(
  2004. 'div',
  2005. { 'class': 'el-table-filter' },
  2006. [h(
  2007. 'div',
  2008. { 'class': 'el-table-filter__content' },
  2009. []
  2010. ), h(
  2011. 'div',
  2012. { 'class': 'el-table-filter__bottom' },
  2013. [h(
  2014. 'button',
  2015. {
  2016. on: {
  2017. 'click': this.handleConfirm
  2018. }
  2019. },
  2020. [this.t('el.table.confirmFilter')]
  2021. ), h(
  2022. 'button',
  2023. {
  2024. on: {
  2025. 'click': this.handleReset
  2026. }
  2027. },
  2028. [this.t('el.table.resetFilter')]
  2029. )]
  2030. )]
  2031. );
  2032. },
  2033. methods: {
  2034. isActive: function isActive(filter) {
  2035. return filter.value === this.filterValue;
  2036. },
  2037. handleOutsideClick: function handleOutsideClick() {
  2038. this.showPopper = false;
  2039. },
  2040. handleConfirm: function handleConfirm() {
  2041. this.confirmFilter(this.filteredValue);
  2042. this.handleOutsideClick();
  2043. },
  2044. handleReset: function handleReset() {
  2045. this.filteredValue = [];
  2046. this.confirmFilter(this.filteredValue);
  2047. this.handleOutsideClick();
  2048. },
  2049. handleSelect: function handleSelect(filterValue) {
  2050. this.filterValue = filterValue;
  2051. if (typeof filterValue !== 'undefined' && filterValue !== null) {
  2052. this.confirmFilter(this.filteredValue);
  2053. } else {
  2054. this.confirmFilter([]);
  2055. }
  2056. this.handleOutsideClick();
  2057. },
  2058. confirmFilter: function confirmFilter(filteredValue) {
  2059. this.table.store.commit('filterChange', {
  2060. column: this.column,
  2061. values: filteredValue
  2062. });
  2063. }
  2064. },
  2065. data: function data() {
  2066. return {
  2067. table: null,
  2068. cell: null,
  2069. column: null
  2070. };
  2071. },
  2072. computed: {
  2073. filters: function filters() {
  2074. return this.column && this.column.filters;
  2075. },
  2076. filterValue: {
  2077. get: function get() {
  2078. return (this.column.filteredValue || [])[0];
  2079. },
  2080. set: function set(value) {
  2081. if (this.filteredValue) {
  2082. if (typeof value !== 'undefined' && value !== null) {
  2083. this.filteredValue.splice(0, 1, value);
  2084. } else {
  2085. this.filteredValue.splice(0, 1);
  2086. }
  2087. }
  2088. }
  2089. },
  2090. filteredValue: {
  2091. get: function get() {
  2092. if (this.column) {
  2093. return this.column.filteredValue || [];
  2094. }
  2095. return [];
  2096. },
  2097. set: function set(value) {
  2098. if (this.column) {
  2099. this.column.filteredValue = value;
  2100. }
  2101. }
  2102. },
  2103. multiple: function multiple() {
  2104. if (this.column) {
  2105. return this.column.filterMultiple;
  2106. }
  2107. return true;
  2108. }
  2109. },
  2110. mounted: function mounted() {
  2111. var _this = this;
  2112. this.popperElm = this.$el;
  2113. this.referenceElm = this.cell;
  2114. this.table.bodyWrapper.addEventListener('scroll', function () {
  2115. _this.updatePopper();
  2116. });
  2117. this.$watch('showPopper', function (value) {
  2118. if (_this.column) _this.column.filterOpened = value;
  2119. if (value) {
  2120. _dropdown2.default.open(_this);
  2121. } else {
  2122. _dropdown2.default.close(_this);
  2123. }
  2124. });
  2125. },
  2126. watch: {
  2127. showPopper: function showPopper(val) {
  2128. if (val === true && parseInt(this.popperJS._popper.style.zIndex, 10) < _popup.PopupManager.zIndex) {
  2129. this.popperJS._popper.style.zIndex = _popup.PopupManager.nextZIndex();
  2130. }
  2131. }
  2132. }
  2133. }; //
  2134. //
  2135. //
  2136. //
  2137. //
  2138. //
  2139. //
  2140. //
  2141. //
  2142. //
  2143. //
  2144. //
  2145. //
  2146. //
  2147. //
  2148. //
  2149. //
  2150. //
  2151. //
  2152. //
  2153. //
  2154. //
  2155. //
  2156. //
  2157. //
  2158. //
  2159. //
  2160. //
  2161. //
  2162. //
  2163. //
  2164. //
  2165. /***/ },
  2166. /***/ 312:
  2167. /***/ function(module, exports, __webpack_require__) {
  2168. 'use strict';
  2169. exports.__esModule = true;
  2170. var _vue = __webpack_require__(56);
  2171. var _vue2 = _interopRequireDefault(_vue);
  2172. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2173. var dropdowns = [];
  2174. !_vue2.default.prototype.$isServer && document.addEventListener('click', function (event) {
  2175. dropdowns.forEach(function (dropdown) {
  2176. var target = event.target;
  2177. if (!dropdown || !dropdown.$el) return;
  2178. if (target === dropdown.$el || dropdown.$el.contains(target)) {
  2179. return;
  2180. }
  2181. dropdown.handleOutsideClick && dropdown.handleOutsideClick(event);
  2182. });
  2183. });
  2184. exports.default = {
  2185. open: function open(instance) {
  2186. if (instance) {
  2187. dropdowns.push(instance);
  2188. }
  2189. },
  2190. close: function close(instance) {
  2191. var index = dropdowns.indexOf(instance);
  2192. if (index !== -1) {
  2193. dropdowns.splice(instance, 1);
  2194. }
  2195. }
  2196. };
  2197. /***/ },
  2198. /***/ 313:
  2199. /***/ function(module, exports) {
  2200. module.exports = require("element-ui/lib/checkbox-group");
  2201. /***/ },
  2202. /***/ 314:
  2203. /***/ function(module, exports) {
  2204. module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
  2205. return _c('transition', {
  2206. attrs: {
  2207. "name": "el-zoom-in-top"
  2208. }
  2209. }, [(_vm.multiple) ? _c('div', {
  2210. directives: [{
  2211. name: "show",
  2212. rawName: "v-show",
  2213. value: (_vm.showPopper),
  2214. expression: "showPopper"
  2215. }],
  2216. staticClass: "el-table-filter"
  2217. }, [_c('div', {
  2218. staticClass: "el-table-filter__content"
  2219. }, [_c('el-checkbox-group', {
  2220. directives: [{
  2221. name: "model",
  2222. rawName: "v-model",
  2223. value: (_vm.filteredValue),
  2224. expression: "filteredValue"
  2225. }],
  2226. staticClass: "el-table-filter__checkbox-group",
  2227. domProps: {
  2228. "value": (_vm.filteredValue)
  2229. },
  2230. on: {
  2231. "input": function($event) {
  2232. _vm.filteredValue = $event
  2233. }
  2234. }
  2235. }, _vm._l((_vm.filters), function(filter) {
  2236. return _c('el-checkbox', {
  2237. attrs: {
  2238. "label": filter.value
  2239. }
  2240. }, [_vm._v(_vm._s(filter.text))])
  2241. }))], 1), _c('div', {
  2242. staticClass: "el-table-filter__bottom"
  2243. }, [_c('button', {
  2244. class: {
  2245. 'is-disabled': _vm.filteredValue.length === 0
  2246. },
  2247. attrs: {
  2248. "disabled": _vm.filteredValue.length === 0
  2249. },
  2250. on: {
  2251. "click": _vm.handleConfirm
  2252. }
  2253. }, [_vm._v(_vm._s(_vm.t('el.table.confirmFilter')))]), _c('button', {
  2254. on: {
  2255. "click": _vm.handleReset
  2256. }
  2257. }, [_vm._v(_vm._s(_vm.t('el.table.resetFilter')))])])]) : _c('div', {
  2258. directives: [{
  2259. name: "show",
  2260. rawName: "v-show",
  2261. value: (_vm.showPopper),
  2262. expression: "showPopper"
  2263. }],
  2264. staticClass: "el-table-filter"
  2265. }, [_c('ul', {
  2266. staticClass: "el-table-filter__list"
  2267. }, [_c('li', {
  2268. staticClass: "el-table-filter__list-item",
  2269. class: {
  2270. 'is-active': !_vm.filterValue
  2271. },
  2272. on: {
  2273. "click": function($event) {
  2274. _vm.handleSelect(null)
  2275. }
  2276. }
  2277. }, [_vm._v(_vm._s(_vm.t('el.table.clearFilter')))]), _vm._l((_vm.filters), function(filter) {
  2278. return _c('li', {
  2279. staticClass: "el-table-filter__list-item",
  2280. class: {
  2281. 'is-active': _vm.isActive(filter)
  2282. },
  2283. attrs: {
  2284. "label": filter.value
  2285. },
  2286. on: {
  2287. "click": function($event) {
  2288. _vm.handleSelect(filter.value)
  2289. }
  2290. }
  2291. }, [_vm._v(_vm._s(filter.text))])
  2292. })], 2)])])
  2293. },staticRenderFns: []}
  2294. /***/ },
  2295. /***/ 315:
  2296. /***/ function(module, exports) {
  2297. module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
  2298. return _c('div', {
  2299. staticClass: "el-table",
  2300. class: {
  2301. 'el-table--fit': _vm.fit,
  2302. 'el-table--striped': _vm.stripe,
  2303. 'el-table--border': _vm.border,
  2304. 'el-table--fluid-height': _vm.maxHeight,
  2305. 'el-table--enable-row-hover': !_vm.store.states.isComplex,
  2306. 'el-table--enable-row-transition': true || (_vm.store.states.data || []).length !== 0 && (_vm.store.states.data || []).length < 100
  2307. },
  2308. on: {
  2309. "mouseleave": function($event) {
  2310. _vm.handleMouseLeave($event)
  2311. }
  2312. }
  2313. }, [_c('div', {
  2314. ref: "hiddenColumns",
  2315. staticClass: "hidden-columns"
  2316. }, [_vm._t("default")], 2), (_vm.showHeader) ? _c('div', {
  2317. ref: "headerWrapper",
  2318. staticClass: "el-table__header-wrapper"
  2319. }, [_c('table-header', {
  2320. style: ({
  2321. width: _vm.layout.bodyWidth ? _vm.layout.bodyWidth + 'px' : ''
  2322. }),
  2323. attrs: {
  2324. "store": _vm.store,
  2325. "layout": _vm.layout,
  2326. "border": _vm.border,
  2327. "default-sort": _vm.defaultSort
  2328. }
  2329. })], 1) : _vm._e(), _c('div', {
  2330. ref: "bodyWrapper",
  2331. staticClass: "el-table__body-wrapper",
  2332. style: ([_vm.bodyHeight])
  2333. }, [_c('table-body', {
  2334. style: ({
  2335. width: _vm.bodyWidth
  2336. }),
  2337. attrs: {
  2338. "context": _vm.context,
  2339. "store": _vm.store,
  2340. "layout": _vm.layout,
  2341. "row-class-name": _vm.rowClassName,
  2342. "row-style": _vm.rowStyle,
  2343. "highlight": _vm.highlightCurrentRow
  2344. }
  2345. }), (!_vm.data || _vm.data.length === 0) ? _c('div', {
  2346. staticClass: "el-table__empty-block",
  2347. style: ({
  2348. width: _vm.bodyWidth
  2349. })
  2350. }, [_c('span', {
  2351. staticClass: "el-table__empty-text"
  2352. }, [_vm._t("empty", [_vm._v(_vm._s(_vm.emptyText || _vm.t('el.table.emptyText')))])], 2)]) : _vm._e()], 1), (_vm.fixedColumns.length > 0) ? _c('div', {
  2353. ref: "fixedWrapper",
  2354. staticClass: "el-table__fixed",
  2355. style: ([{
  2356. width: _vm.layout.fixedWidth ? _vm.layout.fixedWidth + 'px' : ''
  2357. },
  2358. _vm.fixedHeight
  2359. ])
  2360. }, [(_vm.showHeader) ? _c('div', {
  2361. ref: "fixedHeaderWrapper",
  2362. staticClass: "el-table__fixed-header-wrapper"
  2363. }, [_c('table-header', {
  2364. style: ({
  2365. width: _vm.layout.fixedWidth ? _vm.layout.fixedWidth + 'px' : ''
  2366. }),
  2367. attrs: {
  2368. "fixed": "left",
  2369. "border": _vm.border,
  2370. "store": _vm.store,
  2371. "layout": _vm.layout
  2372. }
  2373. })], 1) : _vm._e(), _c('div', {
  2374. ref: "fixedBodyWrapper",
  2375. staticClass: "el-table__fixed-body-wrapper",
  2376. style: ([{
  2377. top: _vm.layout.headerHeight + 'px'
  2378. },
  2379. _vm.fixedBodyHeight
  2380. ])
  2381. }, [_c('table-body', {
  2382. style: ({
  2383. width: _vm.layout.fixedWidth ? _vm.layout.fixedWidth + 'px' : ''
  2384. }),
  2385. attrs: {
  2386. "fixed": "left",
  2387. "store": _vm.store,
  2388. "layout": _vm.layout,
  2389. "highlight": _vm.highlightCurrentRow,
  2390. "row-class-name": _vm.rowClassName,
  2391. "row-style": _vm.rowStyle
  2392. }
  2393. })], 1)]) : _vm._e(), (_vm.rightFixedColumns.length > 0) ? _c('div', {
  2394. ref: "rightFixedWrapper",
  2395. staticClass: "el-table__fixed-right",
  2396. style: ([{
  2397. width: _vm.layout.rightFixedWidth ? _vm.layout.rightFixedWidth + 'px' : ''
  2398. }, {
  2399. right: _vm.layout.scrollY ? (_vm.border ? _vm.layout.gutterWidth : (_vm.layout.gutterWidth || 1)) + 'px' : ''
  2400. },
  2401. _vm.fixedHeight
  2402. ])
  2403. }, [(_vm.showHeader) ? _c('div', {
  2404. ref: "rightFixedHeaderWrapper",
  2405. staticClass: "el-table__fixed-header-wrapper"
  2406. }, [_c('table-header', {
  2407. style: ({
  2408. width: _vm.layout.rightFixedWidth ? _vm.layout.rightFixedWidth + 'px' : ''
  2409. }),
  2410. attrs: {
  2411. "fixed": "right",
  2412. "border": _vm.border,
  2413. "store": _vm.store,
  2414. "layout": _vm.layout
  2415. }
  2416. })], 1) : _vm._e(), _c('div', {
  2417. ref: "rightFixedBodyWrapper",
  2418. staticClass: "el-table__fixed-body-wrapper",
  2419. style: ([{
  2420. top: _vm.layout.headerHeight + 'px'
  2421. },
  2422. _vm.fixedBodyHeight
  2423. ])
  2424. }, [_c('table-body', {
  2425. style: ({
  2426. width: _vm.layout.rightFixedWidth ? _vm.layout.rightFixedWidth + 'px' : ''
  2427. }),
  2428. attrs: {
  2429. "fixed": "right",
  2430. "store": _vm.store,
  2431. "layout": _vm.layout,
  2432. "row-class-name": _vm.rowClassName,
  2433. "row-style": _vm.rowStyle,
  2434. "highlight": _vm.highlightCurrentRow
  2435. }
  2436. })], 1)]) : _vm._e(), (_vm.rightFixedColumns.length > 0) ? _c('div', {
  2437. staticClass: "el-table__fixed-right-patch",
  2438. style: ({
  2439. width: _vm.layout.scrollY ? _vm.layout.gutterWidth + 'px' : '0',
  2440. height: _vm.layout.headerHeight + 'px'
  2441. })
  2442. }) : _vm._e(), _c('div', {
  2443. directives: [{
  2444. name: "show",
  2445. rawName: "v-show",
  2446. value: (_vm.resizeProxyVisible),
  2447. expression: "resizeProxyVisible"
  2448. }],
  2449. ref: "resizeProxy",
  2450. staticClass: "el-table__column-resize-proxy"
  2451. })])
  2452. },staticRenderFns: []}
  2453. /***/ }
  2454. /******/ });