table.js 144 KB

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