table.js 145 KB

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