table.js 124 KB

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