table.js 142 KB

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