table.js 108 KB

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