table.js 146 KB

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