| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859 |
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _ctor = _interopRequireDefault(require("xe-utils/ctor"));
- var _conf = _interopRequireDefault(require("../../conf"));
- var _cell = _interopRequireDefault(require("../../cell"));
- var _vXETable = _interopRequireDefault(require("../../v-x-e-table"));
- var _tools = require("../../tools");
- var _formats = _interopRequireDefault(require("../../v-x-e-table/src/formats"));
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
- var getRowid = _tools.UtilTools.getRowid,
- getRowkey = _tools.UtilTools.getRowkey,
- setCellValue = _tools.UtilTools.setCellValue,
- hasChildrenList = _tools.UtilTools.hasChildrenList;
- var browse = _tools.DomTools.browse,
- calcHeight = _tools.DomTools.calcHeight,
- hasClass = _tools.DomTools.hasClass,
- addClass = _tools.DomTools.addClass,
- removeClass = _tools.DomTools.removeClass,
- getEventTargetNode = _tools.DomTools.getEventTargetNode;
- var isWebkit = browse['-webkit'] && !browse.edge;
- var debounceScrollYDuration = browse.msie ? 40 : 20;
- var resizableStorageKey = 'VXE_TABLE_CUSTOM_COLUMN_WIDTH';
- var visibleStorageKey = 'VXE_TABLE_CUSTOM_COLUMN_VISIBLE';
- /**
- * 生成行的唯一主键
- */
- function getRowUniqueId() {
- return _ctor.default.uniqueId('row_');
- }
- function eqCellNull(cellValue) {
- return cellValue === '' || _ctor.default.eqNull(cellValue);
- }
- function eqCellValue(row1, row2, field) {
- var val1 = _ctor.default.get(row1, field);
- var val2 = _ctor.default.get(row2, field);
- if (eqCellNull(val1) && eqCellNull(val2)) {
- return true;
- }
- if (_ctor.default.isString(val1) || _ctor.default.isNumber(val1)) {
- /* eslint-disable eqeqeq */
- return val1 == val2;
- }
- return _ctor.default.isEqual(val1, val2);
- }
- function getNextSortOrder(_vm, column) {
- var orders = _vm.sortOpts.orders;
- var currOrder = column.order || null;
- var oIndex = orders.indexOf(currOrder) + 1;
- return orders[oIndex < orders.length ? oIndex : 0];
- }
- function getCustomStorageMap(key) {
- var version = _conf.default.version;
- var rest = _ctor.default.toStringJSON(localStorage.getItem(key));
- return rest && rest._v === version ? rest : {
- _v: version
- };
- }
- function getRecoverRow(_vm, list) {
- var fullAllDataRowMap = _vm.fullAllDataRowMap;
- return list.filter(function (row) {
- return fullAllDataRowMap.has(row);
- });
- }
- function handleReserveRow(_vm, reserveRowMap) {
- var fullDataRowIdData = _vm.fullDataRowIdData;
- var reserveList = [];
- _ctor.default.each(reserveRowMap, function (item, rowid) {
- if (fullDataRowIdData[rowid] && reserveList.indexOf(fullDataRowIdData[rowid].row) === -1) {
- reserveList.push(fullDataRowIdData[rowid].row);
- }
- });
- return reserveList;
- }
- function setMerges(_vm, merges, mList, rowList) {
- if (merges) {
- var treeConfig = _vm.treeConfig,
- visibleColumn = _vm.visibleColumn;
- if (treeConfig) {
- throw new Error(_tools.UtilTools.getLog('vxe.error.noTree', ['merge-footer-items']));
- }
- if (!_ctor.default.isArray(merges)) {
- merges = [merges];
- }
- merges.forEach(function (item) {
- var row = item.row,
- col = item.col,
- rowspan = item.rowspan,
- colspan = item.colspan;
- if (rowList && _ctor.default.isNumber(row)) {
- row = rowList[row];
- }
- if (_ctor.default.isNumber(col)) {
- col = visibleColumn[col];
- }
- if ((rowList ? row : _ctor.default.isNumber(row)) && col && (rowspan || colspan)) {
- rowspan = _ctor.default.toNumber(rowspan) || 1;
- colspan = _ctor.default.toNumber(colspan) || 1;
- if (rowspan > 1 || colspan > 1) {
- var mcIndex = _ctor.default.findIndexOf(mList, function (item) {
- return item._row === row && item._col === col;
- });
- var mergeItem = mList[mcIndex];
- if (mergeItem) {
- mergeItem.rowspan = rowspan;
- mergeItem.colspan = colspan;
- mergeItem._rowspan = rowspan;
- mergeItem._colspan = colspan;
- } else {
- var mergeRowIndex = rowList ? rowList.indexOf(row) : row;
- var mergeColIndex = visibleColumn.indexOf(col);
- mList.push({
- row: mergeRowIndex,
- col: mergeColIndex,
- rowspan: rowspan,
- colspan: colspan,
- _row: row,
- _col: col,
- _rowspan: rowspan,
- _colspan: colspan
- });
- }
- }
- }
- });
- }
- }
- function removeMerges(_vm, merges, mList, rowList) {
- var rest = [];
- if (merges) {
- var treeConfig = _vm.treeConfig,
- visibleColumn = _vm.visibleColumn;
- if (treeConfig) {
- throw new Error(_tools.UtilTools.getLog('vxe.error.noTree', ['merge-cells']));
- }
- if (!_ctor.default.isArray(merges)) {
- merges = [merges];
- }
- merges.forEach(function (item) {
- var row = item.row,
- col = item.col;
- if (rowList && _ctor.default.isNumber(row)) {
- row = rowList[row];
- }
- if (_ctor.default.isNumber(col)) {
- col = visibleColumn[col];
- }
- var mcIndex = _ctor.default.findIndexOf(mList, function (item) {
- return item._row === row && item._col === col;
- });
- if (mcIndex > -1) {
- var rItems = mList.splice(mcIndex, 1);
- rest.push(rItems[0]);
- }
- });
- }
- return rest;
- }
- function getOrderField(_vm, column) {
- var sortBy = column.sortBy,
- sortType = column.sortType;
- if (sortBy && _ctor.default.isArray(sortBy)) {
- return sortBy;
- }
- return function (row) {
- var cellValue;
- if (sortBy) {
- cellValue = _ctor.default.isFunction(sortBy) ? sortBy({
- row: row,
- column: column
- }) : _ctor.default.get(row, sortBy);
- } else {
- cellValue = _vm.getCellLabel(row, column);
- }
- if (!sortType || sortType === 'auto') {
- return isNaN(cellValue) ? cellValue : _ctor.default.toNumber(cellValue);
- } else if (sortType === 'number') {
- return _ctor.default.toNumber(cellValue);
- } else if (sortType === 'string') {
- return _ctor.default.toValueString(cellValue);
- }
- return cellValue;
- };
- }
- var Methods = {
- /**
- * 获取父容器元素
- */
- getParentElem: function getParentElem() {
- return this.$xegrid ? this.$xegrid.$el.parentNode : this.$el.parentNode;
- },
- /**
- * 获取父容器的高度
- */
- getParentHeight: function getParentHeight() {
- return this.$xegrid ? this.$xegrid.getParentHeight() : this.getParentElem().clientHeight;
- },
- /**
- * 获取需要排除的高度
- * 但渲染表格高度时,需要排除工具栏或分页等相关组件的高度
- * 如果存在表尾合计滚动条,则需要排除滚动条高度
- */
- getExcludeHeight: function getExcludeHeight() {
- return this.$xegrid ? this.$xegrid.getExcludeHeight() : 0;
- },
- /**
- * 重置表格的一切数据状态
- */
- clearAll: function clearAll() {
- this.inited = false;
- this.clearSort();
- this.clearCurrentRow();
- this.clearCurrentColumn();
- this.clearRadioRow();
- this.clearRadioReserve();
- this.clearCheckboxRow();
- this.clearCheckboxReserve();
- this.clearRowExpand();
- this.clearRowExpandReserve();
- this.clearTreeExpand();
- this.clearTreeExpandReserve();
- if (_vXETable.default._edit) {
- this.clearActived();
- }
- if (_vXETable.default._filter) {
- this.clearFilter();
- }
- if (this.keyboardConfig || this.mouseConfig) {
- this.clearIndexChecked();
- this.clearHeaderChecked();
- this.clearChecked();
- this.clearSelected();
- this.clearCopyed();
- }
- if (this.mouseConfig) {
- this.clearCellAreas();
- this.clearCopyCellArea();
- }
- return this.clearScroll();
- },
- refreshData: function refreshData() {
- _tools.UtilTools.warn('vxe.error.delFunc', ['refreshData', 'syncData']);
- return this.syncData();
- },
- /**
- * 同步 data 数据
- * 如果用了该方法,那么组件将不再记录增删改的状态,只能自行实现对应逻辑
- * 对于某些特殊的场景,比如深层树节点元素发生变动时可能会用到
- */
- syncData: function syncData() {
- var _this = this;
- return this.$nextTick().then(function () {
- _this.tableData = [];
- return _this.$nextTick().then(function () {
- return _this.loadTableData(_this.tableFullData);
- });
- });
- },
- /**
- * 手动处理数据
- * 对于手动更改了排序、筛选...等条件后需要重新处理数据时可能会用到
- */
- updateData: function updateData() {
- return this.handleTableData(true).then(this.updateFooter).then(this.recalculate);
- },
- handleTableData: function handleTableData(force) {
- var scrollYLoad = this.scrollYLoad,
- scrollYStore = this.scrollYStore;
- var fullData = force ? this.updateAfterFullData() : this.afterFullData;
- this.tableData = scrollYLoad ? fullData.slice(scrollYStore.startIndex, Math.max(scrollYStore.startIndex + scrollYStore.renderSize, 1)) : fullData.slice(0);
- return this.$nextTick();
- },
- /**
- * 加载表格数据
- * @param {Array} datas 数据
- */
- loadTableData: function loadTableData(datas) {
- var _this2 = this;
- var keepSource = this.keepSource,
- treeConfig = this.treeConfig,
- editStore = this.editStore,
- sYOpts = this.sYOpts,
- scrollYStore = this.scrollYStore;
- var tableFullData = datas ? datas.slice(0) : [];
- var scrollYLoad = !treeConfig && sYOpts.enabled && sYOpts.gt > -1 && sYOpts.gt < tableFullData.length;
- scrollYStore.startIndex = 0;
- scrollYStore.visibleIndex = 0;
- scrollYStore.renderSize = 1;
- editStore.insertList = [];
- editStore.removeList = []; // 全量数据
- this.tableFullData = tableFullData; // 缓存数据
- this.updateCache(true); // 原始数据
- this.tableSynchData = datas;
- if (keepSource) {
- this.tableSourceData = _ctor.default.clone(tableFullData, true);
- }
- this.scrollYLoad = scrollYLoad;
- if (scrollYLoad) {
- if (!(this.height || this.maxHeight)) {
- _tools.UtilTools.error('vxe.error.reqProp', ['height | max-height']);
- }
- if (!this.showOverflow) {
- _tools.UtilTools.warn('vxe.error.reqProp', ['show-overflow']);
- }
- if (this.spanMethod) {
- _tools.UtilTools.warn('vxe.error.scrollErrProp', ['span-method']);
- }
- }
- this.clearMergeCells();
- this.clearMergeFooterItems();
- this.handleTableData(true);
- this.updateFooter();
- return this.computeScrollLoad().then(function () {
- // 是否加载了数据
- _this2.isLoadData = true;
- _this2.computeRowHeight();
- _this2.handleReserveStatus();
- _this2.checkSelectionStatus();
- return _this2.$nextTick().then(_this2.recalculate).then(_this2.refreshScroll);
- });
- },
- /**
- * 重新加载数据,不会清空表格状态
- * @param {Array} datas 数据
- */
- loadData: function loadData(datas) {
- this.inited = true;
- return this.loadTableData(datas).then(this.recalculate);
- },
- /**
- * 重新加载数据,会清空表格状态
- * @param {Array} datas 数据
- */
- reloadData: function reloadData(datas) {
- var _this3 = this;
- return this.clearAll().then(function () {
- _this3.inited = true;
- return _this3.loadTableData(datas);
- }).then(this.handleDefaults);
- },
- /**
- * 局部加载行数据并恢复到初始状态
- * 对于行数据需要局部更改的场景中可能会用到
- * @param {Row} row 行对象
- * @param {Object} record 新数据
- * @param {String} field 字段名
- */
- reloadRow: function reloadRow(row, record, field) {
- var tableSourceData = this.tableSourceData,
- tableData = this.tableData; // 在 v3 中必须要开启 keep-source
- if (!this.keepSource) {
- _tools.UtilTools.warn('vxe.error.reqProp', ['keep-source']);
- return this.$nextTick();
- }
- var rowIndex = this.getRowIndex(row);
- var oRow = tableSourceData[rowIndex];
- if (oRow && row) {
- if (field) {
- _ctor.default.set(oRow, field, _ctor.default.get(record || row, field));
- } else {
- if (record) {
- tableSourceData[rowIndex] = record;
- _ctor.default.clear(row, undefined);
- Object.assign(row, this.defineField(Object.assign({}, record)));
- this.updateCache(true);
- } else {
- _ctor.default.destructuring(oRow, _ctor.default.clone(row, true));
- }
- }
- }
- this.tableData = tableData.slice(0);
- return this.$nextTick();
- },
- /**
- * 加载列配置
- * 对于表格列需要重载、局部递增场景下可能会用到
- * @param {ColumnInfo} columns 列配置
- */
- loadColumn: function loadColumn(columns) {
- var _this4 = this;
- this.collectColumn = _ctor.default.mapTree(columns, function (column) {
- return _cell.default.createColumn(_this4, column);
- });
- return this.$nextTick();
- },
- /**
- * 加载列配置并恢复到初始状态
- * 对于表格列需要重载、局部递增场景下可能会用到
- * @param {ColumnInfo} columns 列配置
- */
- reloadColumn: function reloadColumn(columns) {
- var _this5 = this;
- return this.clearAll().then(function () {
- return _this5.loadColumn(columns);
- });
- },
- /**
- * 更新数据行的 Map
- * 牺牲数据组装的耗时,用来换取使用过程中的流畅
- */
- updateCache: function updateCache(source) {
- var _this6 = this;
- var treeConfig = this.treeConfig,
- treeOpts = this.treeOpts,
- tableFullData = this.tableFullData,
- fullDataRowMap = this.fullDataRowMap,
- fullAllDataRowMap = this.fullAllDataRowMap;
- var fullDataRowIdData = this.fullDataRowIdData,
- fullAllDataRowIdData = this.fullAllDataRowIdData;
- var rowkey = getRowkey(this);
- var isLazy = treeConfig && treeOpts.lazy;
- var handleCache = function handleCache(row, index, items, path, parent) {
- var rowid = getRowid(_this6, row);
- if (_tools.UtilTools.eqEmptyValue(rowid)) {
- rowid = getRowUniqueId();
- _ctor.default.set(row, rowkey, rowid);
- }
- if (isLazy && row[treeOpts.hasChild] && _ctor.default.isUndefined(row[treeOpts.children])) {
- row[treeOpts.children] = null;
- }
- var rest = {
- row: row,
- rowid: rowid,
- index: treeConfig && parent ? -1 : index,
- items: items,
- parent: parent
- };
- if (source) {
- fullDataRowIdData[rowid] = rest;
- fullDataRowMap.set(row, rest);
- }
- fullAllDataRowIdData[rowid] = rest;
- fullAllDataRowMap.set(row, rest);
- };
- if (source) {
- fullDataRowIdData = this.fullDataRowIdData = {};
- fullDataRowMap.clear();
- }
- fullAllDataRowIdData = this.fullAllDataRowIdData = {};
- fullAllDataRowMap.clear();
- if (treeConfig) {
- _ctor.default.eachTree(tableFullData, handleCache, treeOpts);
- } else {
- tableFullData.forEach(handleCache);
- }
- },
- loadChildren: function loadChildren(row, childRecords) {
- var _this7 = this;
- return this.createData(childRecords).then(function (rows) {
- var keepSource = _this7.keepSource,
- tableSourceData = _this7.tableSourceData,
- treeOpts = _this7.treeOpts,
- fullDataRowIdData = _this7.fullDataRowIdData,
- fullDataRowMap = _this7.fullDataRowMap,
- fullAllDataRowMap = _this7.fullAllDataRowMap,
- fullAllDataRowIdData = _this7.fullAllDataRowIdData;
- var children = treeOpts.children;
- if (keepSource) {
- var rowid = getRowid(_this7, row);
- var matchObj = _ctor.default.findTree(tableSourceData, function (item) {
- return rowid === getRowid(_this7, item);
- }, treeOpts);
- if (matchObj) {
- matchObj.item[children] = _ctor.default.clone(rows, true);
- }
- }
- _ctor.default.eachTree(rows, function (childRow, index, items, path, parent) {
- var rowid = getRowid(_this7, childRow);
- var rest = {
- row: childRow,
- rowid: rowid,
- index: -1,
- items: items,
- parent: parent
- };
- fullDataRowIdData[rowid] = rest;
- fullDataRowMap.set(childRow, rest);
- fullAllDataRowIdData[rowid] = rest;
- fullAllDataRowMap.set(childRow, rest);
- }, treeOpts);
- row[children] = rows;
- return rows;
- });
- },
- /**
- * 更新数据列的 Map
- * 牺牲数据组装的耗时,用来换取使用过程中的流畅
- */
- cacheColumnMap: function cacheColumnMap() {
- var isGroup = this.isGroup,
- tableFullColumn = this.tableFullColumn,
- collectColumn = this.collectColumn,
- fullColumnMap = this.fullColumnMap;
- var fullColumnIdData = this.fullColumnIdData = {};
- var fullColumnFieldData = this.fullColumnFieldData = {};
- var expandColumn;
- var treeNodeColumn;
- var checkboxColumn;
- var radioColumn;
- var hasFixed;
- var handleFunc = function handleFunc(column, index, items, path, parent) {
- var colid = column.id,
- property = column.property,
- fixed = column.fixed,
- type = column.type,
- treeNode = column.treeNode;
- var rest = {
- column: column,
- colid: colid,
- index: index,
- items: items,
- parent: parent
- };
- if (property) {
- if (fullColumnFieldData[property]) {
- _tools.UtilTools.warn('vxe.error.colRepet', ['field', property]);
- }
- fullColumnFieldData[property] = rest;
- }
- if (!hasFixed && fixed) {
- hasFixed = fixed;
- }
- if (treeNode) {
- if (treeNodeColumn) {
- _tools.UtilTools.warn('vxe.error.colRepet', ['tree-node', treeNode]);
- }
- if (!treeNodeColumn) {
- treeNodeColumn = column;
- }
- } else if (type === 'expand') {
- if (expandColumn) {
- _tools.UtilTools.warn('vxe.error.colRepet', ['type', type]);
- }
- if (!expandColumn) {
- expandColumn = column;
- }
- }
- if (type === 'checkbox') {
- if (checkboxColumn) {
- _tools.UtilTools.warn('vxe.error.colRepet', ['type', type]);
- }
- if (!checkboxColumn) {
- checkboxColumn = column;
- }
- } else if (type === 'radio') {
- if (radioColumn) {
- _tools.UtilTools.warn('vxe.error.colRepet', ['type', type]);
- }
- if (!radioColumn) {
- radioColumn = column;
- }
- }
- if (fullColumnIdData[colid]) {
- _tools.UtilTools.error('vxe.error.colRepet', ['colId', colid]);
- }
- fullColumnIdData[colid] = rest;
- fullColumnMap.set(column, rest);
- };
- fullColumnMap.clear();
- if (isGroup) {
- _ctor.default.eachTree(collectColumn, function (column, index, items, path, parent, nodes) {
- column.level = nodes.length;
- handleFunc(column, index, items, path, parent);
- });
- } else {
- tableFullColumn.forEach(handleFunc);
- }
- if (expandColumn && hasFixed) {
- _tools.UtilTools.warn('vxe.error.errConflicts', ['column.fixed', 'column.type=expand']);
- }
- if (expandColumn && this.mouseOpts.area) {
- _tools.UtilTools.error('vxe.error.errConflicts', ['mouse-config.area', 'column.type=expand']);
- }
- this.treeNodeColumn = treeNodeColumn;
- this.expandColumn = expandColumn;
- },
- /**
- * 根据 tr 元素获取对应的 row 信息
- * @param {Element} tr 元素
- */
- getRowNode: function getRowNode(tr) {
- if (tr) {
- var fullAllDataRowIdData = this.fullAllDataRowIdData;
- var rowid = tr.getAttribute('data-rowid');
- var rest = fullAllDataRowIdData[rowid];
- if (rest) {
- return {
- rowid: rest.rowid,
- item: rest.row,
- index: rest.index,
- items: rest.items,
- parent: rest.parent
- };
- }
- }
- return null;
- },
- /**
- * 根据 th/td 元素获取对应的 column 信息
- * @param {Element} cell 元素
- */
- getColumnNode: function getColumnNode(cell) {
- if (cell) {
- var fullColumnIdData = this.fullColumnIdData;
- var colid = cell.getAttribute('data-colid');
- var rest = fullColumnIdData[colid];
- if (rest) {
- return {
- colid: rest.colid,
- item: rest.column,
- index: rest.index,
- items: rest.items,
- parent: rest.parent
- };
- }
- }
- return null;
- },
- /**
- * 根据 row 获取相对于 data 中的索引
- * @param {Row} row 行对象
- */
- getRowIndex: function getRowIndex(row) {
- return this.fullDataRowMap.has(row) ? this.fullDataRowMap.get(row).index : -1;
- },
- /**
- * 根据 row 获取相对于当前数据中的索引
- * @param {Row} row 行对象
- */
- getVTRowIndex: function getVTRowIndex(row) {
- return this.afterFullData.indexOf(row);
- },
- // 在 v3 中废弃
- _getRowIndex: function _getRowIndex(row) {
- _tools.UtilTools.warn('vxe.error.delFunc', ['_getRowIndex', 'getVTRowIndex']);
- return this.getVTRowIndex(row);
- },
- /**
- * 根据 row 获取渲染中的虚拟索引
- * @param {Row} row 行对象
- */
- getVMRowIndex: function getVMRowIndex(row) {
- return this.tableData.indexOf(row);
- },
- // 在 v3 中废弃
- $getRowIndex: function $getRowIndex(row) {
- _tools.UtilTools.warn('vxe.error.delFunc', ['$getRowIndex', 'getVMRowIndex']);
- return this.getVMRowIndex(row);
- },
- /**
- * 根据 column 获取相对于 columns 中的索引
- * @param {ColumnInfo} column 列配置
- */
- getColumnIndex: function getColumnIndex(column) {
- return this.fullColumnMap.has(column) ? this.fullColumnMap.get(column).index : -1;
- },
- /**
- * 根据 column 获取相对于当前表格列中的索引
- * @param {ColumnInfo} column 列配置
- */
- getVTColumnIndex: function getVTColumnIndex(column) {
- return this.visibleColumn.indexOf(column);
- },
- // 在 v3 中废弃
- _getColumnIndex: function _getColumnIndex(column) {
- _tools.UtilTools.warn('vxe.error.delFunc', ['_getColumnIndex', 'getVTColumnIndex']);
- return this.getVTColumnIndex(column);
- },
- /**
- * 根据 column 获取渲染中的虚拟索引
- * @param {ColumnInfo} column 列配置
- */
- getVMColumnIndex: function getVMColumnIndex(column) {
- return this.tableColumn.indexOf(column);
- },
- // 在 v3 中废弃
- $getColumnIndex: function $getColumnIndex(column) {
- _tools.UtilTools.warn('vxe.error.delFunc', ['$getColumnIndex', 'getVMColumnIndex']);
- return this.getVMColumnIndex(column);
- },
- /**
- * 判断是否为索引列
- * @param {ColumnInfo} column 列配置
- */
- isSeqColumn: function isSeqColumn(column) {
- return column && (column.type === 'seq' || column.type === 'index');
- },
- /**
- * 定义行数据中的列属性,如果不存在则定义
- * @param {Row} record 行数据
- */
- defineField: function defineField(record) {
- var radioOpts = this.radioOpts,
- checkboxOpts = this.checkboxOpts,
- treeConfig = this.treeConfig,
- treeOpts = this.treeOpts,
- expandOpts = this.expandOpts;
- var rowkey = getRowkey(this);
- this.visibleColumn.forEach(function (_ref) {
- var property = _ref.property,
- editRender = _ref.editRender;
- if (property && !_ctor.default.has(record, property)) {
- _ctor.default.set(record, property, editRender && !_ctor.default.isUndefined(editRender.defaultValue) ? editRender.defaultValue : null);
- }
- });
- var ohterFields = [radioOpts.labelField, checkboxOpts.checkField, checkboxOpts.labelField, expandOpts.labelField];
- ohterFields.forEach(function (key) {
- if (key && _tools.UtilTools.eqEmptyValue(_ctor.default.get(record, key))) {
- _ctor.default.set(record, key, null);
- }
- });
- if (treeConfig && treeOpts.lazy && _ctor.default.isUndefined(record[treeOpts.children])) {
- record[treeOpts.children] = null;
- } // 必须有行数据的唯一主键,可以自行设置;也可以默认生成一个随机数
- if (_tools.UtilTools.eqEmptyValue(_ctor.default.get(record, rowkey))) {
- _ctor.default.set(record, rowkey, getRowUniqueId());
- }
- return record;
- },
- /**
- * 创建 data 对象
- * 对于某些特殊场景可能会用到,会自动对数据的字段名进行检测,如果不存在就自动定义
- * @param {Array} records 新数据
- */
- createData: function createData(records) {
- var _this8 = this;
- var treeConfig = this.treeConfig,
- treeOpts = this.treeOpts;
- var handleRrecord = function handleRrecord(record) {
- return _this8.defineField(Object.assign({}, record));
- };
- var rows = treeConfig ? _ctor.default.mapTree(records, handleRrecord, treeOpts) : records.map(handleRrecord);
- return this.$nextTick().then(function () {
- return rows;
- });
- },
- /**
- * 创建 Row|Rows 对象
- * 对于某些特殊场景需要对数据进行手动插入时可能会用到
- * @param {Array/Object} records 新数据
- */
- createRow: function createRow(records) {
- var _this9 = this;
- var isArr = _ctor.default.isArray(records);
- if (!isArr) {
- records = [records];
- }
- return this.$nextTick().then(function () {
- return _this9.createData(records).then(function (rows) {
- return isArr ? rows : rows[0];
- });
- });
- },
- revert: function revert() {
- _tools.UtilTools.warn('vxe.error.delFunc', ['revert', 'revertData']);
- return this.revertData.apply(this, arguments);
- },
- /**
- * 还原数据
- * 如果不传任何参数,则还原整个表格
- * 如果传 row 则还原一行
- * 如果传 rows 则还原多行
- * 如果还额外传了 field 则还原指定的单元格数据
- */
- revertData: function revertData(rows, field) {
- var _this10 = this;
- var tableSourceData = this.tableSourceData,
- treeConfig = this.treeConfig; // 在 v3 中必须要开启 keep-source
- if (!this.keepSource) {
- _tools.UtilTools.warn('vxe.error.reqProp', ['keep-source']);
- return this.$nextTick();
- }
- var targetRows = rows;
- if (rows) {
- if (!_ctor.default.isArray(rows)) {
- targetRows = [rows];
- }
- } else {
- targetRows = _ctor.default.toArray(this.getUpdateRecords());
- }
- if (targetRows.length) {
- targetRows.forEach(function (row) {
- if (!_this10.isInsertByRow(row)) {
- var rowIndex = _this10.getRowIndex(row);
- if (treeConfig && rowIndex === -1) {
- throw new Error(_tools.UtilTools.getLog('vxe.error.noTree', ['revertData']));
- }
- var oRow = tableSourceData[rowIndex];
- if (oRow && row) {
- if (field) {
- _ctor.default.set(row, field, _ctor.default.clone(_ctor.default.get(oRow, field), true));
- } else {
- _ctor.default.destructuring(row, _ctor.default.clone(oRow, true));
- }
- }
- }
- });
- }
- if (rows) {
- return this.$nextTick();
- }
- return this.reloadData(tableSourceData);
- },
- /**
- * 清空单元格内容
- * 如果不创参数,则清空整个表格内容
- * 如果传 row 则清空一行内容
- * 如果传 rows 则清空多行内容
- * 如果还额外传了 field 则清空指定单元格内容
- * @param {Array/Row} rows 行数据
- * @param {String} field 字段名
- */
- clearData: function clearData(rows, field) {
- var tableFullData = this.tableFullData,
- visibleColumn = this.visibleColumn;
- if (!arguments.length) {
- rows = tableFullData;
- } else if (rows && !_ctor.default.isArray(rows)) {
- rows = [rows];
- }
- if (field) {
- rows.forEach(function (row) {
- return _ctor.default.set(row, field, null);
- });
- } else {
- rows.forEach(function (row) {
- visibleColumn.forEach(function (column) {
- if (column.property) {
- setCellValue(row, column, null);
- }
- });
- });
- }
- return this.$nextTick();
- },
- /**
- * 检查是否为临时行数据
- * @param {Row} row 行对象
- */
- isInsertByRow: function isInsertByRow(row) {
- return this.editStore.insertList.indexOf(row) > -1;
- },
- // 在 v3.0 中废弃 hasRowChange
- hasRowChange: function hasRowChange(row, field) {
- _tools.UtilTools.warn('vxe.error.delFunc', ['hasRowChange', 'isUpdateByRow']);
- return this.isUpdateByRow(row, field);
- },
- /**
- * 检查行或列数据是否发生改变
- * @param {Row} row 行对象
- * @param {String} field 字段名
- */
- isUpdateByRow: function isUpdateByRow(row, field) {
- var _this11 = this;
- var visibleColumn = this.visibleColumn,
- keepSource = this.keepSource,
- treeConfig = this.treeConfig,
- treeOpts = this.treeOpts,
- tableSourceData = this.tableSourceData,
- fullDataRowIdData = this.fullDataRowIdData;
- if (keepSource) {
- var oRow, property;
- var rowid = getRowid(this, row); // 新增的数据不需要检测
- if (!fullDataRowIdData[rowid]) {
- return false;
- }
- if (treeConfig) {
- var children = treeOpts.children;
- var matchObj = _ctor.default.findTree(tableSourceData, function (item) {
- return rowid === getRowid(_this11, item);
- }, treeOpts);
- row = Object.assign({}, row, _defineProperty({}, children, null));
- if (matchObj) {
- oRow = Object.assign({}, matchObj.item, _defineProperty({}, children, null));
- }
- } else {
- var oRowIndex = fullDataRowIdData[rowid].index;
- oRow = tableSourceData[oRowIndex];
- }
- if (oRow) {
- if (arguments.length > 1) {
- return !eqCellValue(oRow, row, field);
- }
- for (var index = 0, len = visibleColumn.length; index < len; index++) {
- property = visibleColumn[index].property;
- if (property && !eqCellValue(oRow, row, property)) {
- return true;
- }
- }
- }
- }
- return false;
- },
- /**
- * 获取表格的可视列,也可以指定索引获取列
- * @param {Number} columnIndex 索引
- */
- getColumns: function getColumns(columnIndex) {
- var columns = this.visibleColumn;
- return arguments.length ? columns[columnIndex] : columns.slice(0);
- },
- /**
- * 根据列的唯一主键获取列
- * @param {String} colid 列主键
- */
- getColumnById: function getColumnById(colid) {
- var fullColumnIdData = this.fullColumnIdData;
- return fullColumnIdData[colid] ? fullColumnIdData[colid].column : null;
- },
- /**
- * 根据列的字段名获取列
- * @param {String} field 字段名
- */
- getColumnByField: function getColumnByField(field) {
- var fullColumnFieldData = this.fullColumnFieldData;
- return fullColumnFieldData[field] ? fullColumnFieldData[field].column : null;
- },
- /**
- * 获取当前表格的列
- * 收集到的全量列、全量表头列、处理条件之后的全量表头列、当前渲染中的表头列
- */
- getTableColumn: function getTableColumn() {
- return {
- collectColumn: this.collectColumn.slice(0),
- fullColumn: this.tableFullColumn.slice(0),
- visibleColumn: this.visibleColumn.slice(0),
- tableColumn: this.tableColumn.slice(0)
- };
- },
- // 在 v3.0 中废弃 getRecords
- getRecords: function getRecords() {
- _tools.UtilTools.warn('vxe.error.delFunc', ['getRecords', 'getData']);
- return this.getData.apply(this, arguments);
- },
- /**
- * 获取数据,和 data 的行为一致,也可以指定索引获取数据
- */
- getData: function getData(rowIndex) {
- var tableSynchData = this.data || this.tableSynchData;
- return arguments.length ? tableSynchData[rowIndex] : tableSynchData.slice(0);
- },
- // 在 v3.0 中废弃 getAllRecords
- getAllRecords: function getAllRecords() {
- _tools.UtilTools.warn('vxe.error.delFunc', ['getAllRecords', 'getRecordset']);
- return this.getRecordset();
- },
- // 在 v3.0 中废弃 getSelectRecords
- getSelectRecords: function getSelectRecords() {
- _tools.UtilTools.warn('vxe.error.delFunc', ['getSelectRecords', 'getCheckboxRecords']);
- return this.getCheckboxRecords();
- },
- /**
- * 用于多选行,获取已选中的数据
- */
- getCheckboxRecords: function getCheckboxRecords() {
- var tableFullData = this.tableFullData,
- treeConfig = this.treeConfig,
- treeOpts = this.treeOpts,
- checkboxOpts = this.checkboxOpts;
- var property = checkboxOpts.checkField;
- var rowList = [];
- if (property) {
- if (treeConfig) {
- rowList = _ctor.default.filterTree(tableFullData, function (row) {
- return _ctor.default.get(row, property);
- }, treeOpts);
- } else {
- rowList = tableFullData.filter(function (row) {
- return _ctor.default.get(row, property);
- });
- }
- } else {
- var selection = this.selection;
- if (treeConfig) {
- rowList = _ctor.default.filterTree(tableFullData, function (row) {
- return selection.indexOf(row) > -1;
- }, treeOpts);
- } else {
- rowList = tableFullData.filter(function (row) {
- return selection.indexOf(row) > -1;
- });
- }
- }
- return rowList;
- },
- /**
- * 获取处理后全量的表格数据
- * 如果存在筛选条件,继续处理
- */
- updateAfterFullData: function updateAfterFullData() {
- var _this12 = this;
- var tableFullColumn = this.tableFullColumn,
- tableFullData = this.tableFullData,
- remoteSort = this.remoteSort,
- remoteFilter = this.remoteFilter,
- filterOpts = this.filterOpts,
- sortOpts = this.sortOpts;
- var tableData = tableFullData.slice(0);
- var column = _ctor.default.find(tableFullColumn, function (column) {
- return column.order;
- });
- var filterColumns = [];
- var orderColumns = [];
- tableFullColumn.forEach(function (column) {
- if (column.filters && column.filters.length) {
- var valueList = [];
- var itemList = [];
- column.filters.forEach(function (item) {
- if (item.checked) {
- itemList.push(item);
- valueList.push(item.value);
- }
- });
- filterColumns.push({
- column: column,
- valueList: valueList,
- itemList: itemList
- });
- }
- if (column.sortable && column.order) {
- orderColumns.push({
- column: column,
- sortBy: column.sortBy,
- property: column.property,
- order: column.order
- });
- }
- });
- if (filterColumns.length) {
- tableData = tableData.filter(function (row) {
- return filterColumns.every(function (_ref2) {
- var column = _ref2.column,
- valueList = _ref2.valueList,
- itemList = _ref2.itemList;
- if (valueList.length && !(filterOpts.remote || remoteFilter)) {
- var filterRender = column.filterRender,
- property = column.property;
- var filterMethod = column.filterMethod;
- var allFilterMethod = filterOpts.filterMethod;
- var compConf = filterRender ? _vXETable.default.renderer.get(filterRender.name) : null;
- var compFilterMethod = compConf && compConf.renderFilter ? compConf.filterMethod : null;
- var defaultFilterMethod = compConf ? compConf.defaultFilterMethod : null;
- var cellValue = _tools.UtilTools.getCellValue(row, column);
- if (filterMethod) {
- return itemList.some(function (item) {
- return filterMethod({
- value: item.value,
- option: item,
- cellValue: cellValue,
- row: row,
- column: column,
- $table: _this12
- });
- });
- } else if (compFilterMethod) {
- return itemList.some(function (item) {
- return compFilterMethod({
- value: item.value,
- option: item,
- cellValue: cellValue,
- row: row,
- column: column,
- $table: _this12
- });
- });
- } else if (allFilterMethod) {
- return allFilterMethod({
- options: itemList,
- values: valueList,
- cellValue: cellValue,
- row: row,
- column: column
- });
- } else if (defaultFilterMethod) {
- return itemList.some(function (item) {
- return defaultFilterMethod({
- value: item.value,
- option: item,
- cellValue: cellValue,
- row: row,
- column: column,
- $table: _this12
- });
- });
- }
- return valueList.indexOf(_ctor.default.get(row, property)) > -1;
- }
- return true;
- });
- });
- }
- if (column && column.order) {
- var allSortMethod = sortOpts.sortMethod || this.sortMethod;
- var isRemote = _ctor.default.isBoolean(column.remoteSort) ? column.remoteSort : sortOpts.remote || remoteSort;
- if (!isRemote) {
- if (allSortMethod) {
- tableData = allSortMethod({
- data: tableData,
- column: column,
- property: column.property,
- order: column.order,
- sortList: orderColumns,
- $table: this
- }) || tableData;
- } else {
- var rest = column.sortMethod ? tableData.sort(column.sortMethod) : _ctor.default.orderBy(tableData, getOrderField(this, column));
- tableData = column.order === 'desc' ? rest.reverse() : rest;
- }
- }
- }
- this.afterFullData = tableData;
- return tableData;
- },
- /**
- * 根据行的唯一主键获取行
- * @param {String/Number} rowid 行主键
- */
- getRowById: function getRowById(rowid) {
- var fullDataRowIdData = this.fullDataRowIdData;
- return fullDataRowIdData[rowid] ? fullDataRowIdData[rowid].row : null;
- },
- /**
- * 根据行获取行的唯一主键
- * @param {Row} row 行对象
- */
- getRowid: function getRowid(row) {
- var fullAllDataRowMap = this.fullAllDataRowMap;
- return fullAllDataRowMap.has(row) ? fullAllDataRowMap.get(row).rowid : null;
- },
- /**
- * 获取处理后的表格数据
- * 如果存在筛选条件,继续处理
- * 如果存在排序,继续处理
- */
- getTableData: function getTableData() {
- var tableFullData = this.tableFullData,
- afterFullData = this.afterFullData,
- tableData = this.tableData,
- footerTableData = this.footerTableData;
- return {
- fullData: tableFullData.slice(0),
- visibleData: afterFullData.slice(0),
- tableData: tableData.slice(0),
- footerData: footerTableData.slice(0)
- };
- },
- /**
- * 默认行为只允许执行一次
- */
- handleDefaults: function handleDefaults() {
- var _this13 = this;
- // 在 v3.0 中废弃 selectConfig
- var checkboxConfig = this.checkboxConfig || this.selectConfig;
- if (checkboxConfig) {
- this.handleDefaultSelectionChecked();
- }
- if (this.radioConfig) {
- this.handleDefaultRadioChecked();
- }
- if (this.sortConfig) {
- this.handleDefaultSort();
- }
- if (this.expandConfig) {
- this.handleDefaultRowExpand();
- }
- if (this.treeConfig) {
- this.handleDefaultTreeExpand();
- }
- if (this.mergeCells) {
- this.handleDefaultMergeCells();
- }
- if (this.mergeFooterItems) {
- this.handleDefaultMergeFooterItems();
- }
- this.$nextTick(function () {
- return setTimeout(_this13.recalculate);
- });
- },
- /**
- * 动态列处理
- */
- mergeCustomColumn: function mergeCustomColumn(customColumns) {
- var tableFullColumn = this.tableFullColumn;
- this.isUpdateCustoms = true;
- if (customColumns.length) {
- tableFullColumn.forEach(function (column) {
- // 在 v3.0 中废弃 prop
- var item = _ctor.default.find(customColumns, function (item) {
- return column.property && (item.field || item.prop) === column.property;
- });
- if (item) {
- if (_ctor.default.isNumber(item.resizeWidth)) {
- column.resizeWidth = item.resizeWidth;
- }
- if (_ctor.default.isBoolean(item.visible)) {
- column.visible = item.visible;
- }
- }
- });
- }
- this.emitEvent('update:customs', tableFullColumn);
- },
- /**
- * 手动重置列的所有操作,还原到初始状态
- * 如果已关联工具栏,则会同步更新
- */
- resetAll: function resetAll() {
- _tools.UtilTools.warn('vxe.error.delFunc', ['resetAll', 'resetColumn']);
- this.resetColumn(true);
- },
- /**
- * 隐藏指定列
- * @param {ColumnInfo} column 列配置
- */
- hideColumn: function hideColumn(column) {
- column.visible = false;
- return this.handleCustom();
- },
- /**
- * 显示指定列
- * @param {ColumnInfo} column 列配置
- */
- showColumn: function showColumn(column) {
- column.visible = true;
- return this.handleCustom();
- },
- /**
- * 手动重置列的显示隐藏、列宽拖动的状态;
- * 如果为 true 则重置所有状态
- * 如果已关联工具栏,则会同步更新
- */
- resetColumn: function resetColumn(options) {
- var customOpts = this.customOpts;
- var checkMethod = customOpts.checkMethod;
- var opts = Object.assign({
- visible: true,
- resizable: options === true
- }, options);
- this.tableFullColumn.forEach(function (column) {
- if (opts.resizable) {
- column.resizeWidth = 0;
- }
- if (!checkMethod || checkMethod({
- column: column
- })) {
- column.visible = column.defaultVisible;
- }
- });
- if (opts.resizable) {
- this.saveCustomResizable(true);
- }
- return this.handleCustom();
- },
- handleCustom: function handleCustom() {
- this.saveCustomVisible();
- this.analyColumnWidth();
- return this.refreshColumn();
- },
- resetResizable: function resetResizable() {
- _tools.UtilTools.warn('vxe.error.delFunc', ['resetResizable', 'resetColumn']);
- return this.resetColumn();
- },
- /**
- * 已废弃的方法
- */
- reloadCustoms: function reloadCustoms(customColumns) {
- var _this14 = this;
- _tools.UtilTools.warn('vxe.error.delFunc', ['reloadCustoms', 'column.visible & refreshColumn']);
- return this.$nextTick().then(function () {
- _this14.mergeCustomColumn(customColumns);
- return _this14.refreshColumn().then(function () {
- return _this14.tableFullColumn;
- });
- });
- },
- /**
- * 还原自定义列操作状态
- */
- restoreCustomStorage: function restoreCustomStorage() {
- var $toolbar = this.$toolbar,
- collectColumn = this.collectColumn,
- customConfig = this.customConfig,
- customOpts = this.customOpts;
- var storage = customOpts.storage;
- var isAllStorage = customOpts.storage === true;
- var isResizable = isAllStorage || storage && storage.resizable || $toolbar && $toolbar.resizableOpts.storage;
- var isVisible = isAllStorage || storage && storage.visible || $toolbar && $toolbar.customOpts.storage; // 在 v3.0 中废弃 $toolbar 方式
- if ((customConfig || $toolbar) && (isResizable || isVisible)) {
- // 在 v3.0 中废弃 toolbar.id
- var id = customConfig ? this.id : $toolbar ? $toolbar.id : null;
- var customMap = {};
- if (!id) {
- _tools.UtilTools.error('vxe.error.reqProp', ['id']);
- return;
- }
- if (isResizable) {
- var columnWidthStorage = getCustomStorageMap(resizableStorageKey)[id];
- if (columnWidthStorage) {
- _ctor.default.each(columnWidthStorage, function (resizeWidth, field) {
- customMap[field] = {
- field: field,
- resizeWidth: resizeWidth
- };
- });
- }
- }
- if (isVisible) {
- var columnVisibleStorage = getCustomStorageMap(visibleStorageKey)[id];
- if (columnVisibleStorage) {
- var colVisibles = columnVisibleStorage.split('|');
- var colHides = colVisibles[0] ? colVisibles[0].split(',') : [];
- var colShows = colVisibles[1] ? colVisibles[1].split(',') : [];
- colHides.forEach(function (field) {
- if (customMap[field]) {
- customMap[field].visible = false;
- } else {
- customMap[field] = {
- field: field,
- visible: false
- };
- }
- });
- colShows.forEach(function (field) {
- if (customMap[field]) {
- customMap[field].visible = true;
- } else {
- customMap[field] = {
- field: field,
- visible: true
- };
- }
- });
- }
- }
- var keyMap = {};
- _ctor.default.eachTree(collectColumn, function (column) {
- var colKey = column.getKey();
- if (colKey) {
- keyMap[colKey] = column;
- }
- });
- _ctor.default.each(customMap, function (_ref3, field) {
- var visible = _ref3.visible,
- resizeWidth = _ref3.resizeWidth;
- var column = keyMap[field];
- if (column) {
- if (_ctor.default.isNumber(resizeWidth)) {
- column.resizeWidth = resizeWidth;
- }
- if (_ctor.default.isBoolean(visible)) {
- column.visible = visible;
- }
- }
- });
- }
- },
- saveCustomVisible: function saveCustomVisible() {
- var $toolbar = this.$toolbar,
- collectColumn = this.collectColumn,
- customConfig = this.customConfig,
- customOpts = this.customOpts;
- var checkMethod = customOpts.checkMethod,
- storage = customOpts.storage;
- var isAllStorage = customOpts.storage === true;
- var isVisible = isAllStorage || storage && storage.visible || $toolbar && $toolbar.customOpts.storage; // 在 v3.0 中废弃 $toolbar 方式
- if ((customConfig || $toolbar) && isVisible) {
- // 在 v3.0 中废弃 toolbar.id
- var id = customConfig ? this.id : $toolbar ? $toolbar.id : null;
- var columnVisibleStorageMap = getCustomStorageMap(visibleStorageKey);
- var colHides = [];
- var colShows = [];
- if (!id) {
- _tools.UtilTools.error('vxe.error.reqProp', ['id']);
- return;
- }
- _ctor.default.eachTree(collectColumn, function (column) {
- if (!checkMethod || checkMethod({
- column: column
- })) {
- if (!column.visible && column.defaultVisible) {
- var colKey = column.getKey();
- if (colKey) {
- colHides.push(colKey);
- }
- } else if (column.visible && !column.defaultVisible) {
- var _colKey = column.getKey();
- if (_colKey) {
- colShows.push(_colKey);
- }
- }
- }
- });
- columnVisibleStorageMap[id] = [colHides.join(',')].concat(colShows.length ? [colShows.join(',')] : []).join('|') || undefined;
- localStorage.setItem(visibleStorageKey, _ctor.default.toJSONString(columnVisibleStorageMap));
- }
- },
- saveCustomResizable: function saveCustomResizable(isReset) {
- var $toolbar = this.$toolbar,
- collectColumn = this.collectColumn,
- customConfig = this.customConfig,
- customOpts = this.customOpts;
- var storage = customOpts.storage;
- var isAllStorage = customOpts.storage === true;
- var isResizable = isAllStorage || storage && storage.resizable || $toolbar && $toolbar.resizableOpts.storage; // 在 v3.0 中废弃 $toolbar 方式
- if ((customConfig || $toolbar) && isResizable) {
- // 在 v3.0 中废弃 toolbar.id
- var id = customConfig ? this.id : $toolbar ? $toolbar.id : null;
- var columnWidthStorageMap = getCustomStorageMap(resizableStorageKey);
- var columnWidthStorage;
- if (!id) {
- _tools.UtilTools.error('vxe.error.reqProp', ['id']);
- return;
- }
- if (!isReset) {
- columnWidthStorage = _ctor.default.isPlainObject(columnWidthStorageMap[id]) ? columnWidthStorageMap[id] : {};
- _ctor.default.eachTree(collectColumn, function (column) {
- if (column.resizeWidth) {
- var colKey = column.getKey();
- if (colKey) {
- columnWidthStorage[colKey] = column.renderWidth;
- }
- }
- });
- }
- columnWidthStorageMap[id] = _ctor.default.isEmpty(columnWidthStorage) ? undefined : columnWidthStorage;
- localStorage.setItem(resizableStorageKey, _ctor.default.toJSONString(columnWidthStorageMap));
- }
- },
- /**
- * 刷新列信息
- * 将固定的列左边、右边分别靠边
- */
- refreshColumn: function refreshColumn() {
- var _this15 = this;
- var leftList = [];
- var centerList = [];
- var rightList = [];
- var collectColumn = this.collectColumn,
- tableFullColumn = this.tableFullColumn,
- isGroup = this.isGroup,
- columnStore = this.columnStore,
- sXOpts = this.sXOpts,
- scrollXStore = this.scrollXStore; // 如果是分组表头,如果子列全部被隐藏,则根列也隐藏
- if (isGroup) {
- var leftGroupList = [];
- var centerGroupList = [];
- var rightGroupList = [];
- _ctor.default.eachTree(collectColumn, function (column, index, items, path, parent) {
- var isColGroup = hasChildrenList(column); // 如果是分组,必须按组设置固定列,不允许给子列设置固定
- if (parent && parent.fixed) {
- column.fixed = parent.fixed;
- }
- if (parent && column.fixed !== parent.fixed) {
- _tools.UtilTools.error('vxe.error.groupFixed');
- }
- if (isColGroup) {
- column.visible = !!_ctor.default.findTree(column.children, function (subColumn) {
- return hasChildrenList(subColumn) ? null : subColumn.visible;
- });
- } else if (column.visible) {
- if (column.fixed === 'left') {
- leftList.push(column);
- } else if (column.fixed === 'right') {
- rightList.push(column);
- } else {
- centerList.push(column);
- }
- }
- });
- collectColumn.forEach(function (column) {
- if (column.visible) {
- if (column.fixed === 'left') {
- leftGroupList.push(column);
- } else if (column.fixed === 'right') {
- rightGroupList.push(column);
- } else {
- centerGroupList.push(column);
- }
- }
- });
- this.tableGroupColumn = leftGroupList.concat(centerGroupList).concat(rightGroupList);
- } else {
- // 重新分配列
- tableFullColumn.forEach(function (column) {
- if (column.visible) {
- if (column.fixed === 'left') {
- leftList.push(column);
- } else if (column.fixed === 'right') {
- rightList.push(column);
- } else {
- centerList.push(column);
- }
- }
- });
- }
- var visibleColumn = leftList.concat(centerList).concat(rightList);
- var tableColumn = visibleColumn;
- var scrollXLoad = sXOpts.enabled && sXOpts.gt > -1 && sXOpts.gt < tableFullColumn.length;
- Object.assign(columnStore, {
- leftList: leftList,
- centerList: centerList,
- rightList: rightList
- });
- if (scrollXLoad && isGroup) {
- scrollXLoad = false;
- _tools.UtilTools.warn('vxe.error.scrollXNotGroup');
- }
- if (scrollXLoad) {
- if (this.showHeader && !this.showHeaderOverflow) {
- _tools.UtilTools.warn('vxe.error.reqProp', ['show-header-overflow']);
- }
- if (this.showFooter && !this.showFooterOverflow) {
- _tools.UtilTools.warn('vxe.error.reqProp', ['show-footer-overflow']);
- }
- if (this.spanMethod) {
- _tools.UtilTools.warn('vxe.error.scrollErrProp', ['span-method']);
- }
- if (this.footerSpanMethod) {
- _tools.UtilTools.warn('vxe.error.scrollErrProp', ['footer-span-method']);
- }
- Object.assign(scrollXStore, {
- startIndex: 0,
- visibleIndex: 0
- });
- tableColumn = visibleColumn.slice(scrollXStore.startIndex, scrollXStore.startIndex + scrollXStore.renderSize);
- } // 如果列被显示/隐藏,则清除合并状态
- // 如果列被设置为固定,则清除合并状态
- if (visibleColumn.length !== this.visibleColumn.length || !this.visibleColumn.every(function (column, index) {
- return column === visibleColumn[index];
- })) {
- this.clearMergeCells();
- this.clearMergeFooterItems();
- }
- this.scrollXLoad = scrollXLoad;
- this.tableColumn = tableColumn;
- this.visibleColumn = visibleColumn;
- return this.$nextTick().then(function () {
- _this15.updateFooter();
- return _this15.recalculate(true);
- }).then(function () {
- _this15.updateCellAreas();
- return _this15.$nextTick().then(function () {
- return _this15.recalculate();
- });
- });
- },
- /**
- * 指定列宽的列进行拆分
- */
- analyColumnWidth: function analyColumnWidth() {
- var columnWidth = this.columnWidth,
- columnMinWidth = this.columnMinWidth,
- columnOpts = this.columnOpts; // 在 v3.0 中废弃 columnWidth
- var defaultWidth = columnOpts.width || columnWidth; // 在 v3.0 中废弃 columnMinWidth
- var defaultMinWidth = columnOpts.minWidth || columnMinWidth;
- var resizeList = [];
- var pxList = [];
- var pxMinList = [];
- var scaleList = [];
- var scaleMinList = [];
- var autoList = [];
- this.tableFullColumn.forEach(function (column) {
- if (defaultWidth && !column.width) {
- column.width = defaultWidth;
- }
- if (defaultMinWidth && !column.minWidth) {
- column.minWidth = defaultMinWidth;
- }
- if (column.visible) {
- if (column.resizeWidth) {
- resizeList.push(column);
- } else if (_tools.DomTools.isPx(column.width)) {
- pxList.push(column);
- } else if (_tools.DomTools.isScale(column.width)) {
- scaleList.push(column);
- } else if (_tools.DomTools.isPx(column.minWidth)) {
- pxMinList.push(column);
- } else if (_tools.DomTools.isScale(column.minWidth)) {
- scaleMinList.push(column);
- } else {
- autoList.push(column);
- }
- }
- });
- Object.assign(this.columnStore, {
- resizeList: resizeList,
- pxList: pxList,
- pxMinList: pxMinList,
- scaleList: scaleList,
- scaleMinList: scaleMinList,
- autoList: autoList
- });
- },
- /**
- * 刷新滚动操作,手动同步滚动相关位置(对于某些特殊的操作,比如滚动条错位、固定列不同步)
- */
- refreshScroll: function refreshScroll() {
- var _this16 = this;
- var lastScrollLeft = this.lastScrollLeft,
- lastScrollTop = this.lastScrollTop;
- return this.clearScroll().then(function () {
- if (lastScrollLeft || lastScrollTop) {
- // 重置最后滚动状态
- _this16.lastScrollLeft = 0;
- _this16.lastScrollTop = 0; // 还原滚动状态
- return _this16.scrollTo(lastScrollLeft, lastScrollTop);
- }
- });
- },
- /**
- * 计算单元格列宽,动态分配可用剩余空间
- * 支持 width=? width=?px width=?% min-width=? min-width=?px min-width=?%
- */
- recalculate: function recalculate(refull) {
- var _this17 = this;
- var $refs = this.$refs;
- var tableBody = $refs.tableBody,
- tableHeader = $refs.tableHeader,
- tableFooter = $refs.tableFooter;
- var bodyElem = tableBody ? tableBody.$el : null;
- var headerElem = tableHeader ? tableHeader.$el : null;
- var footerElem = tableFooter ? tableFooter.$el : null;
- if (bodyElem) {
- this.autoCellWidth(headerElem, bodyElem, footerElem);
- if (refull === true) {
- // 初始化时需要在列计算之后再执行优化运算,达到最优显示效果
- return this.computeScrollLoad().then(function () {
- _this17.autoCellWidth(headerElem, bodyElem, footerElem);
- _this17.computeScrollLoad();
- });
- }
- }
- return this.computeScrollLoad();
- },
- /**
- * 列宽算法
- * 支持 px、%、固定 混合分配
- * 支持动态列表调整分配
- * 支持自动分配偏移量
- * @param {Element} headerElem
- * @param {Element} bodyElem
- * @param {Element} footerElem
- * @param {Number} bodyWidth
- */
- autoCellWidth: function autoCellWidth(headerElem, bodyElem, footerElem) {
- var tableWidth = 0;
- var minCellWidth = 40; // 列宽最少限制 40px
- var bodyWidth = bodyElem.clientWidth;
- var remainWidth = bodyWidth;
- var meanWidth = remainWidth / 100;
- var fit = this.fit,
- columnStore = this.columnStore;
- var resizeList = columnStore.resizeList,
- pxMinList = columnStore.pxMinList,
- pxList = columnStore.pxList,
- scaleList = columnStore.scaleList,
- scaleMinList = columnStore.scaleMinList,
- autoList = columnStore.autoList; // 最小宽
- pxMinList.forEach(function (column) {
- var minWidth = parseInt(column.minWidth);
- tableWidth += minWidth;
- column.renderWidth = minWidth;
- }); // 最小百分比
- scaleMinList.forEach(function (column) {
- var scaleWidth = Math.floor(parseInt(column.minWidth) * meanWidth);
- tableWidth += scaleWidth;
- column.renderWidth = scaleWidth;
- }); // 固定百分比
- scaleList.forEach(function (column) {
- var scaleWidth = Math.floor(parseInt(column.width) * meanWidth);
- tableWidth += scaleWidth;
- column.renderWidth = scaleWidth;
- }); // 固定宽
- pxList.forEach(function (column) {
- var width = parseInt(column.width);
- tableWidth += width;
- column.renderWidth = width;
- }); // 调整了列宽
- resizeList.forEach(function (column) {
- var width = parseInt(column.resizeWidth);
- tableWidth += width;
- column.renderWidth = width;
- });
- remainWidth -= tableWidth;
- meanWidth = remainWidth > 0 ? Math.floor(remainWidth / (scaleMinList.length + pxMinList.length + autoList.length)) : 0;
- if (fit) {
- if (remainWidth > 0) {
- scaleMinList.concat(pxMinList).forEach(function (column) {
- tableWidth += meanWidth;
- column.renderWidth += meanWidth;
- });
- }
- } else {
- meanWidth = minCellWidth;
- } // 自适应
- autoList.forEach(function (column) {
- var width = Math.max(meanWidth, minCellWidth);
- column.renderWidth = width;
- tableWidth += width;
- });
- if (fit) {
- /**
- * 偏移量算法
- * 如果所有列足够放的情况下,从最后动态列开始分配
- */
- var dynamicList = scaleList.concat(scaleMinList).concat(pxMinList).concat(autoList);
- var dynamicSize = dynamicList.length - 1;
- if (dynamicSize > 0) {
- var odiffer = bodyWidth - tableWidth;
- if (odiffer > 0) {
- while (odiffer > 0 && dynamicSize >= 0) {
- odiffer--;
- dynamicList[dynamicSize--].renderWidth++;
- }
- tableWidth = bodyWidth;
- }
- }
- }
- var tableHeight = bodyElem.offsetHeight;
- var overflowY = bodyElem.scrollHeight > bodyElem.clientHeight;
- this.scrollbarWidth = overflowY ? bodyElem.offsetWidth - bodyWidth : 0;
- this.overflowY = overflowY;
- this.tableWidth = tableWidth;
- this.tableHeight = tableHeight;
- if (headerElem) {
- this.headerHeight = headerElem.clientHeight; // 检测是否同步滚动
- if (headerElem.scrollLeft !== bodyElem.scrollLeft) {
- headerElem.scrollLeft = bodyElem.scrollLeft;
- }
- } else {
- this.headerHeight = 0;
- }
- if (footerElem) {
- var footerHeight = footerElem.offsetHeight;
- this.scrollbarHeight = Math.max(footerHeight - footerElem.clientHeight, 0);
- this.overflowX = tableWidth > footerElem.clientWidth;
- this.footerHeight = footerHeight;
- } else {
- this.footerHeight = 0;
- this.scrollbarHeight = Math.max(tableHeight - bodyElem.clientHeight, 0);
- this.overflowX = tableWidth > bodyWidth;
- }
- this.customHeight = calcHeight(this, 'height');
- this.customMaxHeight = calcHeight(this, 'maxHeight');
- this.parentHeight = Math.max(this.headerHeight + this.footerHeight + 20, this.getParentHeight());
- if (this.overflowX) {
- this.checkScrolling();
- }
- },
- updateStyle: function updateStyle() {
- var _this18 = this;
- var $refs = this.$refs,
- isGroup = this.isGroup,
- fullColumnIdData = this.fullColumnIdData,
- tableColumn = this.tableColumn,
- customHeight = this.customHeight,
- customMaxHeight = this.customMaxHeight,
- border = this.border,
- headerHeight = this.headerHeight,
- showFooter = this.showFooter,
- allColumnOverflow = this.showOverflow,
- allColumnHeaderOverflow = this.showHeaderOverflow,
- allColumnFooterOverflow = this.showFooterOverflow,
- footerHeight = this.footerHeight,
- tableHeight = this.tableHeight,
- tableWidth = this.tableWidth,
- scrollbarHeight = this.scrollbarHeight,
- scrollbarWidth = this.scrollbarWidth,
- scrollXLoad = this.scrollXLoad,
- scrollYLoad = this.scrollYLoad,
- cellOffsetWidth = this.cellOffsetWidth,
- columnStore = this.columnStore,
- elemStore = this.elemStore,
- editStore = this.editStore,
- currentRow = this.currentRow,
- mouseConfig = this.mouseConfig;
- var containerList = ['main', 'left', 'right'];
- var emptyPlaceholderElem = $refs.emptyPlaceholder;
- var bodyWrapperElem = elemStore['main-body-wrapper'];
- if (emptyPlaceholderElem) {
- emptyPlaceholderElem.style.top = "".concat(headerHeight, "px");
- emptyPlaceholderElem.style.height = bodyWrapperElem ? "".concat(bodyWrapperElem.offsetHeight - scrollbarHeight, "px") : '';
- }
- if (customHeight > 0) {
- if (showFooter) {
- customHeight += scrollbarHeight;
- }
- }
- containerList.forEach(function (name, index) {
- var fixedType = index > 0 ? name : '';
- var layoutList = ['header', 'body', 'footer'];
- var fixedColumn = columnStore["".concat(fixedType, "List")];
- var fixedWrapperElem = $refs["".concat(fixedType, "Container")];
- layoutList.forEach(function (layout) {
- var wrapperElem = elemStore["".concat(name, "-").concat(layout, "-wrapper")];
- var tableElem = elemStore["".concat(name, "-").concat(layout, "-table")];
- if (layout === 'header') {
- // 表头体样式处理
- // 横向滚动渲染
- var tWidth = tableWidth;
- if (scrollXLoad) {
- if (fixedType) {
- tableColumn = fixedColumn;
- }
- tWidth = tableColumn.reduce(function (previous, column) {
- return previous + column.renderWidth;
- }, 0);
- }
- if (tableElem) {
- tableElem.style.width = tWidth ? "".concat(tWidth + scrollbarWidth, "px") : ''; // 修复 IE 中高度无法自适应问题
- if (browse.msie) {
- _ctor.default.arrayEach(tableElem.querySelectorAll('.vxe-resizable'), function (resizeElem) {
- resizeElem.style.height = "".concat(resizeElem.parentNode.offsetHeight, "px");
- });
- }
- }
- var repairElem = elemStore["".concat(name, "-").concat(layout, "-repair")];
- if (repairElem) {
- repairElem.style.width = "".concat(tableWidth, "px");
- }
- var listElem = elemStore["".concat(name, "-").concat(layout, "-list")];
- if (isGroup && listElem) {
- // XEUtils.arrayEach(listElem.querySelectorAll(`.col--gutter`), thElem => {
- // thElem.style.width = `${scrollbarWidth}px`
- // })
- _ctor.default.arrayEach(listElem.querySelectorAll('.col--group'), function (thElem) {
- var colNode = _this18.getColumnNode(thElem);
- if (colNode) {
- var column = colNode.item;
- var showHeaderOverflow = column.showHeaderOverflow;
- var cellOverflow = _ctor.default.isBoolean(showHeaderOverflow) ? showHeaderOverflow : allColumnHeaderOverflow;
- var showEllipsis = cellOverflow === 'ellipsis';
- var showTitle = cellOverflow === 'title';
- var showTooltip = cellOverflow === true || cellOverflow === 'tooltip';
- var hasEllipsis = showTitle || showTooltip || showEllipsis;
- var childWidth = 0;
- var countChild = 0;
- if (hasEllipsis) {
- _ctor.default.eachTree(column.children, function (item) {
- if (!item.children || !column.children.length) {
- countChild++;
- }
- childWidth += item.renderWidth;
- });
- }
- thElem.style.width = hasEllipsis ? "".concat(childWidth - countChild - (border ? 2 : 0), "px") : '';
- }
- });
- }
- } else if (layout === 'body') {
- var emptyBlockElem = elemStore["".concat(name, "-").concat(layout, "-emptyBlock")];
- if (wrapperElem) {
- if (customMaxHeight > 0) {
- wrapperElem.style.maxHeight = "".concat(fixedType ? customMaxHeight - headerHeight - (showFooter ? 0 : scrollbarHeight) : customMaxHeight - headerHeight, "px");
- } else {
- if (customHeight > 0) {
- wrapperElem.style.height = "".concat(fixedType ? (customHeight > 0 ? customHeight - headerHeight - footerHeight : tableHeight) - (showFooter ? 0 : scrollbarHeight) : customHeight - headerHeight - footerHeight, "px");
- } else {
- wrapperElem.style.height = '';
- }
- }
- } // 如果是固定列
- if (fixedWrapperElem) {
- var isRightFixed = fixedType === 'right';
- var _fixedColumn = columnStore["".concat(fixedType, "List")];
- if (wrapperElem) {
- wrapperElem.style.top = "".concat(headerHeight, "px");
- }
- fixedWrapperElem.style.height = "".concat((customHeight > 0 ? customHeight - headerHeight - footerHeight : tableHeight) + headerHeight + footerHeight - scrollbarHeight * (showFooter ? 2 : 1), "px");
- fixedWrapperElem.style.width = "".concat(_fixedColumn.reduce(function (previous, column) {
- return previous + column.renderWidth;
- }, isRightFixed ? scrollbarWidth : 0), "px");
- }
- var _tWidth = tableWidth; // 如果是固定列与设置了超出隐藏
- if (fixedType && allColumnOverflow) {
- tableColumn = fixedColumn;
- _tWidth = tableColumn.reduce(function (previous, column) {
- return previous + column.renderWidth;
- }, 0);
- } else if (scrollXLoad) {
- if (fixedType) {
- tableColumn = fixedColumn;
- }
- _tWidth = tableColumn.reduce(function (previous, column) {
- return previous + column.renderWidth;
- }, 0);
- }
- if (tableElem) {
- tableElem.style.width = _tWidth ? "".concat(_tWidth, "px") : ''; // 兼容性处理
- tableElem.style.paddingRight = scrollbarWidth && fixedType && (browse['-moz'] || browse.safari) ? "".concat(scrollbarWidth, "px") : '';
- }
- if (emptyBlockElem) {
- emptyBlockElem.style.width = _tWidth ? "".concat(_tWidth, "px") : '';
- }
- } else if (layout === 'footer') {
- // 如果是使用优化模式
- var _tWidth2 = tableWidth;
- if (fixedType && allColumnOverflow) {
- tableColumn = fixedColumn;
- _tWidth2 = tableColumn.reduce(function (previous, column) {
- return previous + column.renderWidth;
- }, 0);
- } else if (scrollXLoad) {
- if (fixedType) {
- tableColumn = fixedColumn;
- }
- _tWidth2 = tableColumn.reduce(function (previous, column) {
- return previous + column.renderWidth;
- }, 0);
- }
- if (wrapperElem) {
- // 如果是固定列
- if (fixedWrapperElem) {
- wrapperElem.style.top = "".concat(customHeight > 0 ? customHeight - footerHeight : tableHeight + headerHeight, "px");
- }
- wrapperElem.style.marginTop = "".concat(-scrollbarHeight, "px");
- }
- if (tableElem) {
- tableElem.style.width = _tWidth2 ? "".concat(_tWidth2 + scrollbarWidth, "px") : '';
- } // const listElem = elemStore[`${name}-${layout}-list`]
- // if (listElem) {
- // XEUtils.arrayEach(listElem.querySelectorAll(`.col--gutter`), thElem => {
- // thElem.style.width = `${scrollbarWidth}px`
- // })
- // }
- }
- var colgroupElem = elemStore["".concat(name, "-").concat(layout, "-colgroup")];
- if (colgroupElem) {
- _ctor.default.arrayEach(colgroupElem.children, function (colElem) {
- var colid = colElem.getAttribute('name');
- if (colid === 'col_gutter') {
- colElem.style.width = "".concat(scrollbarWidth, "px");
- }
- if (fullColumnIdData[colid]) {
- var column = fullColumnIdData[colid].column;
- var showHeaderOverflow = column.showHeaderOverflow,
- showFooterOverflow = column.showFooterOverflow,
- showOverflow = column.showOverflow;
- var cellOverflow;
- colElem.style.width = "".concat(column.renderWidth, "px");
- if (layout === 'header') {
- cellOverflow = _ctor.default.isUndefined(showHeaderOverflow) || _ctor.default.isNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow;
- } else if (layout === 'footer') {
- cellOverflow = _ctor.default.isUndefined(showFooterOverflow) || _ctor.default.isNull(showFooterOverflow) ? allColumnFooterOverflow : showFooterOverflow;
- } else {
- cellOverflow = _ctor.default.isUndefined(showOverflow) || _ctor.default.isNull(showOverflow) ? allColumnOverflow : showOverflow;
- }
- var showEllipsis = cellOverflow === 'ellipsis';
- var showTitle = cellOverflow === 'title';
- var showTooltip = cellOverflow === true || cellOverflow === 'tooltip';
- var hasEllipsis = showTitle || showTooltip || showEllipsis;
- var _listElem = elemStore["".concat(name, "-").concat(layout, "-list")]; // 滚动的渲染不支持动态行高
- if (layout === 'header' || layout === 'footer') {
- if (scrollXLoad && !hasEllipsis) {
- hasEllipsis = true;
- }
- } else {
- if ((scrollXLoad || scrollYLoad) && !hasEllipsis) {
- hasEllipsis = true;
- }
- }
- if (_listElem) {
- _ctor.default.arrayEach(_listElem.querySelectorAll(".".concat(column.id)), function (elem) {
- var colspan = parseInt(elem.getAttribute('colspan') || 1);
- var cellElem = elem.querySelector('.vxe-cell');
- var colWidth = column.renderWidth;
- if (cellElem) {
- if (colspan > 1) {
- var columnIndex = _this18.getColumnIndex(column);
- for (var _index = 1; _index < colspan; _index++) {
- var nextColumn = _this18.getColumns(columnIndex + _index);
- if (nextColumn) {
- colWidth += nextColumn.renderWidth;
- }
- }
- }
- cellElem.style.width = hasEllipsis ? "".concat(colWidth - cellOffsetWidth * colspan, "px") : '';
- }
- });
- }
- }
- });
- }
- });
- });
- if (currentRow) {
- this.setCurrentRow(currentRow);
- }
- if (mouseConfig && mouseConfig.selected && editStore.selected.row && editStore.selected.column) {
- this.addColSdCls();
- }
- return this.$nextTick();
- },
- /**
- * 处理固定列的显示状态
- */
- checkScrolling: function checkScrolling() {
- var _this$$refs = this.$refs,
- tableBody = _this$$refs.tableBody,
- leftContainer = _this$$refs.leftContainer,
- rightContainer = _this$$refs.rightContainer;
- var bodyElem = tableBody ? tableBody.$el : null;
- if (bodyElem) {
- if (leftContainer) {
- _tools.DomTools[bodyElem.scrollLeft > 0 ? 'addClass' : 'removeClass'](leftContainer, 'scrolling--middle');
- }
- if (rightContainer) {
- _tools.DomTools[bodyElem.clientWidth < bodyElem.scrollWidth - Math.ceil(bodyElem.scrollLeft) ? 'addClass' : 'removeClass'](rightContainer, 'scrolling--middle');
- }
- }
- },
- preventEvent: function preventEvent(evnt, type, args, next, end) {
- var _this19 = this;
- var evntList = _vXETable.default.interceptor.get(type);
- var rest;
- if (!evntList.some(function (func) {
- return func(Object.assign({
- $grid: _this19.$xegrid,
- $table: _this19,
- $event: evnt
- }, args), evnt, _this19) === false;
- })) {
- if (next) {
- rest = next();
- }
- }
- if (end) {
- end();
- }
- return rest;
- },
- /**
- * 全局按下事件处理
- */
- handleGlobalMousedownEvent: function handleGlobalMousedownEvent(evnt) {
- var _this20 = this;
- var $el = this.$el,
- $refs = this.$refs,
- $xegrid = this.$xegrid,
- $toolbar = this.$toolbar,
- mouseConfig = this.mouseConfig,
- mouseOpts = this.mouseOpts,
- editStore = this.editStore,
- ctxMenuStore = this.ctxMenuStore,
- editOpts = this.editOpts,
- filterStore = this.filterStore,
- getRowNode = this.getRowNode;
- var actived = editStore.actived;
- var filterWrapper = $refs.filterWrapper,
- validTip = $refs.validTip; // 在 v3.0 中废弃 mouse-config.checked
- var isMouseChecked = mouseConfig && mouseOpts.checked;
- if (filterWrapper) {
- if (getEventTargetNode(evnt, $el, 'vxe-cell--filter').flag) {// 如果点击了筛选按钮
- } else if (getEventTargetNode(evnt, filterWrapper.$el).flag) {// 如果点击筛选容器
- } else {
- if (!getEventTargetNode(evnt, document.body, 'vxe-table--ignore-clear').flag) {
- this.preventEvent(evnt, 'event.clearFilter', filterStore.args, this.closeFilter);
- }
- }
- } // 如果已激活了编辑状态
- if (actived.row) {
- if (!(editOpts.autoClear === false)) {
- // 如果是激活状态,点击了单元格之外
- var cell = actived.args.cell;
- if (!cell || !getEventTargetNode(evnt, cell).flag) {
- if (validTip && getEventTargetNode(evnt, validTip.$el).flag) {// 如果是激活状态,且点击了校验提示框
- } else if (!this.lastCallTime || this.lastCallTime + 50 < Date.now()) {
- if (!getEventTargetNode(evnt, document.body, 'vxe-table--ignore-clear').flag) {
- // 如果手动调用了激活单元格,避免触发源被移除后导致重复关闭
- this.preventEvent(evnt, 'event.clearActived', actived.args, function () {
- var isClearActived;
- if (editOpts.mode === 'row') {
- var rowNode = getEventTargetNode(evnt, $el, 'vxe-body--row'); // row 方式,如果点击了不同行
- isClearActived = rowNode.flag ? getRowNode(rowNode.targetElem).item !== actived.args.row : false;
- } else {
- // cell 方式,如果是非编辑列
- isClearActived = !getEventTargetNode(evnt, $el, 'col--edit').flag;
- }
- if (!isClearActived) {
- isClearActived = getEventTargetNode(evnt, $el, 'vxe-header--row').flag;
- }
- if (!isClearActived) {
- isClearActived = getEventTargetNode(evnt, $el, 'vxe-footer--row').flag;
- } // 如果固定了高度且点击了行之外的空白处,则清除激活状态
- if (!isClearActived && _this20.height && !_this20.overflowY) {
- var bodyWrapperElem = evnt.target;
- if (hasClass(bodyWrapperElem, 'vxe-table--body-wrapper')) {
- isClearActived = evnt.offsetY < bodyWrapperElem.clientHeight;
- }
- }
- if (isClearActived || // 如果点击了当前表格之外
- !getEventTargetNode(evnt, $el).flag) {
- // this.triggerValidate('blur').then(a => {
- // 保证 input 的 change 事件能先触发之后再清除
- setTimeout(function () {
- return _this20.clearActived(evnt);
- }); // }).catch(e => e)
- }
- });
- }
- }
- }
- }
- } else if (mouseConfig) {
- if (!getEventTargetNode(evnt, $el).flag && !($xegrid && getEventTargetNode(evnt, $xegrid.$el).flag) && !getEventTargetNode(evnt, $refs.tableWrapper).flag && !($toolbar && getEventTargetNode(evnt, $toolbar.$el).flag)) {
- if (isMouseChecked) {
- this.clearIndexChecked();
- this.clearHeaderChecked();
- this.clearChecked();
- }
- this.clearSelected();
- if (!getEventTargetNode(evnt, document.body, 'vxe-table--ignore-areas-clear').flag) {
- this.preventEvent(evnt, 'event.clearAreas', {}, function () {
- _this20.clearCellAreas();
- _this20.clearCopyCellArea();
- });
- }
- }
- } // 如果配置了快捷菜单且,点击了其他地方则关闭
- if (ctxMenuStore.visible && this.$refs.ctxWrapper && !getEventTargetNode(evnt, this.$refs.ctxWrapper.$el).flag) {
- this.closeMenu();
- } // 最后激活的表格
- this.isActivated = getEventTargetNode(evnt, ($xegrid || this).$el).flag;
- },
- /**
- * 窗口失焦事件处理
- */
- handleGlobalBlurEvent: function handleGlobalBlurEvent() {
- this.closeFilter();
- this.closeMenu();
- },
- /**
- * 全局滚动事件
- */
- handleGlobalMousewheelEvent: function handleGlobalMousewheelEvent() {
- this.closeTooltip();
- this.closeMenu();
- },
- /**
- * 全局键盘事件
- */
- handleGlobalKeydownEvent: function handleGlobalKeydownEvent(evnt) {
- var _this21 = this;
- // 该行为只对当前激活的表格有效
- if (this.isActivated) {
- this.preventEvent(evnt, 'event.keydown', null, function () {
- var filterStore = _this21.filterStore,
- isCtxMenu = _this21.isCtxMenu,
- ctxMenuStore = _this21.ctxMenuStore,
- editStore = _this21.editStore,
- editOpts = _this21.editOpts,
- editConfig = _this21.editConfig,
- mouseConfig = _this21.mouseConfig,
- mouseOpts = _this21.mouseOpts,
- keyboardConfig = _this21.keyboardConfig,
- keyboardOpts = _this21.keyboardOpts,
- treeConfig = _this21.treeConfig,
- treeOpts = _this21.treeOpts,
- highlightCurrentRow = _this21.highlightCurrentRow,
- currentRow = _this21.currentRow,
- bodyCtxMenu = _this21.bodyCtxMenu;
- var selected = editStore.selected,
- actived = editStore.actived;
- var keyCode = evnt.keyCode;
- var isBack = keyCode === 8;
- var isTab = keyCode === 9;
- var isEnter = keyCode === 13;
- var isEsc = keyCode === 27;
- var isSpacebar = keyCode === 32;
- var isLeftArrow = keyCode === 37;
- var isUpArrow = keyCode === 38;
- var isRightArrow = keyCode === 39;
- var isDwArrow = keyCode === 40;
- var isDel = keyCode === 46;
- var isA = keyCode === 65;
- var isF2 = keyCode === 113;
- var isContextMenu = keyCode === 93;
- var hasMetaKey = evnt.metaKey;
- var hasCtrlKey = evnt.ctrlKey;
- var hasShiftKey = evnt.shiftKey;
- var operArrow = isLeftArrow || isUpArrow || isRightArrow || isDwArrow;
- var operCtxMenu = isCtxMenu && ctxMenuStore.visible && (isEnter || isSpacebar || operArrow);
- var isEditStatus = editConfig && actived.column && actived.row;
- var params;
- if (filterStore.visible) {
- if (isEsc) {
- _this21.closeFilter();
- }
- return;
- }
- if (operCtxMenu) {
- // 如果配置了右键菜单; 支持方向键操作、回车
- evnt.preventDefault();
- if (ctxMenuStore.showChild && hasChildrenList(ctxMenuStore.selected)) {
- _this21.moveCtxMenu(evnt, keyCode, ctxMenuStore, 'selectChild', 37, false, ctxMenuStore.selected.children);
- } else {
- _this21.moveCtxMenu(evnt, keyCode, ctxMenuStore, 'selected', 39, true, _this21.ctxMenuList);
- }
- } else if (keyboardConfig && mouseConfig && mouseOpts.area && _this21.handleKeyboardEvent) {
- _this21.handleKeyboardEvent(evnt);
- } else if (isSpacebar && keyboardConfig && keyboardOpts.isChecked && selected.row && selected.column && (selected.column.type === 'checkbox' || selected.column.type === 'selection' || selected.column.type === 'radio')) {
- // 在 v3.0 中废弃 type=selection
- // 空格键支持选中复选框
- evnt.preventDefault(); // 在 v3.0 中废弃 type=selection
- if (selected.column.type === 'checkbox' || selected.column.type === 'selection') {
- _this21.handleToggleCheckRowEvent(evnt, selected.args);
- } else {
- _this21.triggerRadioRowEvent(evnt, selected.args);
- }
- } else if (isEsc) {
- // 如果按下了 Esc 键,关闭快捷菜单、筛选
- _this21.closeMenu();
- _this21.closeFilter(); // 如果是激活编辑状态,则取消编辑
- if (actived.row) {
- params = actived.args;
- _this21.clearActived(evnt); // 如果配置了选中功能,则为选中状态
- if (mouseConfig && mouseOpts.selected) {
- _this21.$nextTick(function () {
- return _this21.handleSelected(params, evnt);
- });
- }
- }
- } else if (isF2) {
- if (!isEditStatus) {
- // 如果按下了 F2 键
- if (selected.row && selected.column) {
- evnt.preventDefault();
- _this21.handleActived(selected.args, evnt);
- }
- }
- } else if (isContextMenu) {
- // 如果按下上下文键
- _this21._keyCtx = selected.row && selected.column && bodyCtxMenu.length;
- clearTimeout(_this21.keyCtxTimeout);
- _this21.keyCtxTimeout = setTimeout(function () {
- _this21._keyCtx = false;
- }, 1000);
- } else if (isEnter && keyboardConfig && keyboardOpts.isEnter && (selected.row || actived.row || treeConfig && highlightCurrentRow && currentRow)) {
- // 退出选中
- if (hasCtrlKey) {
- // 如果是激活编辑状态,则取消编辑
- if (actived.row) {
- params = actived.args;
- _this21.clearActived(evnt); // 如果配置了选中功能,则为选中状态
- if (mouseConfig && mouseOpts.selected) {
- _this21.$nextTick(function () {
- return _this21.handleSelected(params, evnt);
- });
- }
- }
- } else {
- // 如果是激活状态,退则出到上一行/下一行
- if (selected.row || actived.row) {
- var targetArgs = selected.row ? selected.args : actived.args;
- if (hasShiftKey) {
- if (keyboardOpts.enterToTab) {
- _this21.moveTabSelected(targetArgs, hasShiftKey, evnt);
- } else {
- _this21.moveSelected(targetArgs, isLeftArrow, true, isRightArrow, false, evnt);
- }
- } else {
- if (keyboardOpts.enterToTab) {
- _this21.moveTabSelected(targetArgs, hasShiftKey, evnt);
- } else {
- _this21.moveSelected(targetArgs, isLeftArrow, false, isRightArrow, true, evnt);
- }
- }
- } else if (treeConfig && highlightCurrentRow && currentRow) {
- // 如果是树形表格当前行回车移动到子节点
- var childrens = currentRow[treeOpts.children];
- if (childrens && childrens.length) {
- evnt.preventDefault();
- var targetRow = childrens[0];
- params = {
- $table: _this21,
- row: targetRow
- };
- _this21.setTreeExpand(currentRow, true).then(function () {
- return _this21.scrollToRow(targetRow);
- }).then(function () {
- return _this21.triggerCurrentRowEvent(evnt, params);
- });
- }
- }
- }
- } else if (operArrow && keyboardConfig && keyboardOpts.isArrow) {
- if (!isEditStatus) {
- // 如果按下了方向键
- if (selected.row && selected.column) {
- _this21.moveSelected(selected.args, isLeftArrow, isUpArrow, isRightArrow, isDwArrow, evnt);
- } else if ((isUpArrow || isDwArrow) && highlightCurrentRow) {
- // 当前行按键上下移动
- _this21.moveCurrentRow(isUpArrow, isDwArrow, evnt);
- }
- }
- } else if (isTab && keyboardConfig && keyboardOpts.isTab) {
- // 如果按下了 Tab 键切换
- if (selected.row || selected.column) {
- _this21.moveTabSelected(selected.args, hasShiftKey, evnt);
- } else if (actived.row || actived.column) {
- _this21.moveTabSelected(actived.args, hasShiftKey, evnt);
- }
- } else if (keyboardConfig && (isDel || (treeConfig && highlightCurrentRow && currentRow ? isBack && keyboardOpts.isArrow : isBack))) {
- if (!isEditStatus) {
- var delMethod = keyboardOpts.delMethod,
- backMethod = keyboardOpts.backMethod; // 如果是删除键
- if (keyboardOpts.isDel && (selected.row || selected.column)) {
- if (delMethod) {
- delMethod({
- row: selected.row,
- rowIndex: _this21.getRowIndex(selected.row),
- column: selected.column,
- columnIndex: _this21.getColumnIndex(selected.column),
- $table: _this21
- });
- } else {
- setCellValue(selected.row, selected.column, null);
- }
- if (isBack) {
- if (backMethod) {
- backMethod({
- row: selected.row,
- rowIndex: _this21.getRowIndex(selected.row),
- column: selected.column,
- columnIndex: _this21.getColumnIndex(selected.column),
- $table: _this21
- });
- } else {
- _this21.handleActived(selected.args, evnt);
- }
- } else if (isDel) {
- // 如果按下 del 键,更新表尾数据
- _this21.updateFooter();
- }
- } else if (isBack && keyboardOpts.isArrow && treeConfig && highlightCurrentRow && currentRow) {
- // 如果树形表格回退键关闭当前行返回父节点
- var _XEUtils$findTree = _ctor.default.findTree(_this21.afterFullData, function (item) {
- return item === currentRow;
- }, treeOpts),
- parentRow = _XEUtils$findTree.parent;
- if (parentRow) {
- evnt.preventDefault();
- params = {
- $table: _this21,
- row: parentRow
- };
- _this21.setTreeExpand(parentRow, false).then(function () {
- return _this21.scrollToRow(parentRow);
- }).then(function () {
- return _this21.triggerCurrentRowEvent(evnt, params);
- });
- }
- }
- }
- } else if (keyboardConfig && hasCtrlKey && isA) {
- if (!isEditStatus) {
- // 如果开启复制功能
- if (keyboardOpts.isCut && mouseConfig && mouseOpts.checked) {
- _this21.handleAllChecked(evnt);
- }
- }
- } else if (keyboardConfig && keyboardOpts.isEdit && !hasCtrlKey && !hasMetaKey && (isSpacebar || keyCode >= 48 && keyCode <= 57 || keyCode >= 65 && keyCode <= 90 || keyCode >= 96 && keyCode <= 111 || keyCode >= 186 && keyCode <= 192 || keyCode >= 219 && keyCode <= 222)) {
- var editMethod = keyboardOpts.editMethod; // 启用编辑后,空格键功能将失效
- // if (isSpacebar) {
- // evnt.preventDefault()
- // }
- // 如果是按下非功能键之外允许直接编辑
- if (selected.column && selected.row && _tools.UtilTools.isEnableConf(selected.column.editRender)) {
- if (!editOpts.activeMethod || editOpts.activeMethod(selected.args)) {
- if (editMethod) {
- editMethod({
- row: selected.row,
- rowIndex: _this21.getRowIndex(selected.row),
- column: selected.column,
- columnIndex: _this21.getColumnIndex(selected.column),
- $table: _this21
- });
- } else {
- setCellValue(selected.row, selected.column, null);
- _this21.handleActived(selected.args, evnt);
- }
- }
- }
- }
- _this21.emitEvent('keydown', {}, evnt);
- });
- }
- },
- handleGlobalPasteEvent: function handleGlobalPasteEvent(evnt) {
- var isActivated = this.isActivated,
- keyboardConfig = this.keyboardConfig,
- keyboardOpts = this.keyboardOpts,
- mouseConfig = this.mouseConfig,
- mouseOpts = this.mouseOpts,
- editStore = this.editStore,
- filterStore = this.filterStore;
- var actived = editStore.actived;
- if (isActivated && !filterStore.visible) {
- if (!(actived.row || actived.column)) {
- if (keyboardConfig && keyboardOpts.isClip && mouseConfig && mouseOpts.area && this.handlePasteCellAreaEvent) {
- this.handlePasteCellAreaEvent(evnt);
- } else if (keyboardConfig && keyboardOpts.isCut && mouseConfig && mouseOpts.checked) {
- this.handlePaste(evnt);
- }
- }
- this.emitEvent('paste', {}, evnt);
- }
- },
- handleGlobalCopyEvent: function handleGlobalCopyEvent(evnt) {
- var isActivated = this.isActivated,
- keyboardConfig = this.keyboardConfig,
- keyboardOpts = this.keyboardOpts,
- mouseConfig = this.mouseConfig,
- mouseOpts = this.mouseOpts,
- editStore = this.editStore,
- filterStore = this.filterStore;
- var actived = editStore.actived;
- if (isActivated && !filterStore.visible) {
- if (!(actived.row || actived.column)) {
- if (keyboardConfig && keyboardOpts.isClip && mouseConfig && mouseOpts.area && this.handleCopyCellAreaEvent) {
- this.handleCopyCellAreaEvent(evnt);
- } else if (keyboardConfig && keyboardOpts.isCut && mouseConfig && mouseOpts.checked) {
- this.handleCopyed(false, evnt);
- }
- }
- this.emitEvent('copy', {}, evnt);
- }
- },
- handleGlobalCutEvent: function handleGlobalCutEvent(evnt) {
- var isActivated = this.isActivated,
- keyboardConfig = this.keyboardConfig,
- keyboardOpts = this.keyboardOpts,
- mouseConfig = this.mouseConfig,
- mouseOpts = this.mouseOpts,
- editStore = this.editStore,
- filterStore = this.filterStore;
- var actived = editStore.actived;
- if (isActivated && !filterStore.visible) {
- if (!(actived.row || actived.column)) {
- if (keyboardConfig && keyboardOpts.isClip && mouseConfig && mouseOpts.area && this.handleCutCellAreaEvent) {
- this.handleCutCellAreaEvent(evnt);
- } else if (keyboardConfig && keyboardOpts.isCut && mouseConfig && mouseOpts.checked) {
- this.handleCopyed(true, evnt);
- }
- }
- this.emitEvent('cut', {}, evnt);
- }
- },
- handleGlobalResizeEvent: function handleGlobalResizeEvent() {
- this.closeMenu();
- this.recalculate(true);
- this.updateCellAreas();
- },
- handleTooltipLeaveEvent: function handleTooltipLeaveEvent() {
- var _this22 = this;
- var tooltipOpts = this.tooltipOpts;
- setTimeout(function () {
- if (!_this22.tooltipActive) {
- _this22.closeTooltip();
- }
- }, tooltipOpts.leaveDelay);
- },
- handleTargetEnterEvent: function handleTargetEnterEvent() {
- clearTimeout(this.tooltipTimeout);
- this.tooltipActive = true;
- this.closeTooltip();
- },
- handleTargetLeaveEvent: function handleTargetLeaveEvent() {
- var _this23 = this;
- var tooltipOpts = this.tooltipOpts;
- this.tooltipActive = false;
- if (tooltipOpts.enterable) {
- this.tooltipTimeout = setTimeout(function () {
- var tooltip = _this23.$refs.tooltip;
- if (tooltip && !tooltip.isHover) {
- _this23.closeTooltip();
- }
- }, tooltipOpts.leaveDelay);
- } else {
- this.closeTooltip();
- }
- },
- triggerHeaderHelpEvent: function triggerHeaderHelpEvent(evnt, params) {
- var column = params.column;
- var titleHelp = column.titleHelp;
- if (titleHelp.content || titleHelp.message) {
- var $refs = this.$refs,
- tooltipStore = this.tooltipStore;
- var tooltip = $refs.tooltip;
- var content = _tools.UtilTools.getFuncText(titleHelp.content || titleHelp.message);
- this.handleTargetEnterEvent();
- tooltipStore.visible = true;
- if (tooltip) {
- tooltip.open(evnt.currentTarget, content);
- }
- }
- },
- /**
- * 触发表头 tooltip 事件
- */
- triggerHeaderTooltipEvent: function triggerHeaderTooltipEvent(evnt, params) {
- var tooltipStore = this.tooltipStore;
- var column = params.column;
- var titleElem = evnt.currentTarget;
- this.handleTargetEnterEvent();
- if (tooltipStore.column !== column || !tooltipStore.visible) {
- this.handleTooltip(evnt, titleElem, titleElem, null, params);
- }
- },
- /**
- * 触发单元格 tooltip 事件
- */
- triggerBodyTooltipEvent: function triggerBodyTooltipEvent(evnt, params) {
- var editConfig = this.editConfig,
- editOpts = this.editOpts,
- editStore = this.editStore,
- tooltipStore = this.tooltipStore;
- var actived = editStore.actived;
- var row = params.row,
- column = params.column;
- var cell = evnt.currentTarget;
- this.handleTargetEnterEvent();
- if (editConfig) {
- if (editOpts.mode === 'row' && actived.row === row || actived.row === row && actived.column === column) {
- return;
- }
- }
- if (tooltipStore.column !== column || tooltipStore.row !== row || !tooltipStore.visible) {
- var overflowElem;
- var tipElem;
- if (column.treeNode) {
- overflowElem = cell.querySelector('.vxe-tree-cell');
- if (column.type === 'html') {
- tipElem = cell.querySelector('.vxe-cell--html');
- }
- } else {
- tipElem = cell.querySelector(column.type === 'html' ? '.vxe-cell--html' : '.vxe-cell--label');
- }
- this.handleTooltip(evnt, cell, overflowElem || cell.children[0], tipElem, params);
- }
- },
- /**
- * 触发表尾 tooltip 事件
- */
- triggerFooterTooltipEvent: function triggerFooterTooltipEvent(evnt, params) {
- var tooltipStore = this.tooltipStore;
- var column = params.column;
- var cell = evnt.currentTarget;
- this.handleTargetEnterEvent();
- if (tooltipStore.column !== column || !tooltipStore.visible) {
- this.handleTooltip(evnt, cell, cell.querySelector('.vxe-cell--item') || cell.children[0], null, params);
- }
- },
- /**
- * 处理显示 tooltip
- * @param {Event} evnt 事件
- * @param {ColumnInfo} column 列配置
- * @param {Row} row 行对象
- */
- handleTooltip: function handleTooltip(evnt, cell, overflowElem, tipElem, params) {
- params.cell = cell;
- var $refs = this.$refs,
- tooltipOpts = this.tooltipOpts,
- tooltipStore = this.tooltipStore;
- var column = params.column,
- row = params.row;
- var showAll = tooltipOpts.showAll,
- enabled = tooltipOpts.enabled,
- contentMethod = tooltipOpts.contentMethod;
- var tooltip = $refs.tooltip;
- var customContent = contentMethod ? contentMethod(params) : null;
- var useCustom = contentMethod && !_ctor.default.eqNull(customContent);
- var content = useCustom ? customContent : (column.type === 'html' ? overflowElem.innerText : overflowElem.textContent).trim();
- var isCellOverflow = overflowElem.scrollWidth > overflowElem.clientWidth;
- if (content && (showAll || enabled || useCustom || isCellOverflow)) {
- Object.assign(tooltipStore, {
- row: row,
- column: column,
- visible: true
- });
- if (tooltip) {
- tooltip.open(isCellOverflow ? overflowElem : tipElem || overflowElem, _tools.UtilTools.formatText(content));
- }
- }
- return this.$nextTick();
- },
- openTooltip: function openTooltip(target, message) {
- var $refs = this.$refs;
- var commTip = $refs.commTip;
- if (commTip) {
- return commTip.open(target, message);
- }
- return this.$nextTick();
- },
- /**
- * 关闭 tooltip
- */
- closeTooltip: function closeTooltip() {
- var tooltip = this.$refs.tooltip;
- var commTip = this.$refs.commTip;
- Object.assign(this.tooltipStore, {
- row: null,
- column: null,
- content: null,
- visible: false
- });
- if (tooltip) {
- tooltip.close();
- }
- if (commTip) {
- commTip.close();
- }
- return this.$nextTick();
- },
- /**
- * 判断列头复选框是否被选中
- */
- isAllCheckboxChecked: function isAllCheckboxChecked() {
- return this.isAllSelected;
- },
- /**
- * 判断列头复选框是否被半选
- */
- isAllCheckboxIndeterminate: function isAllCheckboxIndeterminate() {
- return !this.isAllSelected && this.isIndeterminate;
- },
- isCheckboxIndeterminate: function isCheckboxIndeterminate() {
- _tools.UtilTools.warn('vxe.error.delFunc', ['isCheckboxIndeterminate', 'isAllCheckboxIndeterminate']);
- return this.isAllCheckboxIndeterminate();
- },
- /**
- * 获取复选框半选状态的行数据
- */
- getCheckboxIndeterminateRecords: function getCheckboxIndeterminateRecords() {
- var treeConfig = this.treeConfig,
- treeIndeterminates = this.treeIndeterminates;
- if (treeConfig) {
- return treeIndeterminates.slice(0);
- }
- return [];
- },
- /**
- * 处理默认勾选
- */
- handleDefaultSelectionChecked: function handleDefaultSelectionChecked() {
- var fullDataRowIdData = this.fullDataRowIdData,
- checkboxOpts = this.checkboxOpts;
- var checkAll = checkboxOpts.checkAll,
- checkRowKeys = checkboxOpts.checkRowKeys;
- if (checkAll) {
- this.setAllCheckboxRow(true);
- } else if (checkRowKeys) {
- var defSelection = [];
- checkRowKeys.forEach(function (rowid) {
- if (fullDataRowIdData[rowid]) {
- defSelection.push(fullDataRowIdData[rowid].row);
- }
- });
- this.setCheckboxRow(defSelection, true);
- }
- },
- // 在 v3.0 中废弃 setSelection
- setSelection: function setSelection(rows, value) {
- _tools.UtilTools.warn('vxe.error.delFunc', ['setSelection', 'setCheckboxRow']);
- return this.setCheckboxRow(rows, value);
- },
- /**
- * 用于多选行,设置行为选中状态,第二个参数为选中与否
- * @param {Array/Row} rows 行数据
- * @param {Boolean} value 是否选中
- */
- setCheckboxRow: function setCheckboxRow(rows, value) {
- var _this24 = this;
- if (rows && !_ctor.default.isArray(rows)) {
- rows = [rows];
- }
- rows.forEach(function (row) {
- return _this24.handleSelectRow({
- row: row
- }, !!value);
- });
- return this.$nextTick();
- },
- isCheckedByRow: function isCheckedByRow(row) {
- _tools.UtilTools.warn('vxe.error.delFunc', ['isCheckedByRow', 'isCheckedByCheckboxRow']);
- return this.isCheckedByCheckboxRow(row);
- },
- isCheckedByCheckboxRow: function isCheckedByCheckboxRow(row) {
- var property = this.checkboxOpts.checkField;
- if (property) {
- return _ctor.default.get(row, property);
- }
- return this.selection.indexOf(row) > -1;
- },
- /**
- * 多选,行选中事件
- * value 选中true 不选false 不确定-1
- */
- handleSelectRow: function handleSelectRow(_ref4, value) {
- var _this25 = this;
- var row = _ref4.row;
- var selection = this.selection,
- afterFullData = this.afterFullData,
- treeConfig = this.treeConfig,
- treeOpts = this.treeOpts,
- treeIndeterminates = this.treeIndeterminates,
- checkboxOpts = this.checkboxOpts;
- var property = checkboxOpts.checkField,
- checkStrictly = checkboxOpts.checkStrictly,
- checkMethod = checkboxOpts.checkMethod;
- if (property) {
- if (treeConfig && !checkStrictly) {
- if (value === -1) {
- if (treeIndeterminates.indexOf(row) === -1) {
- treeIndeterminates.push(row);
- }
- _ctor.default.set(row, property, false);
- } else {
- // 更新子节点状态
- _ctor.default.eachTree([row], function (item) {
- if (row === item || !checkMethod || checkMethod({
- row: item
- })) {
- _ctor.default.set(item, property, value);
- _ctor.default.remove(treeIndeterminates, function (half) {
- return half === item;
- });
- _this25.handleCheckboxReserveRow(row, value);
- }
- }, treeOpts);
- } // 如果存在父节点,更新父节点状态
- var matchObj = _ctor.default.findTree(afterFullData, function (item) {
- return item === row;
- }, treeOpts);
- if (matchObj && matchObj.parent) {
- var parentStatus;
- var vItems = checkMethod ? matchObj.items.filter(function (item) {
- return checkMethod({
- row: item
- });
- }) : matchObj.items;
- var indeterminatesItem = _ctor.default.find(matchObj.items, function (item) {
- return treeIndeterminates.indexOf(item) > -1;
- });
- if (indeterminatesItem) {
- parentStatus = -1;
- } else {
- var selectItems = matchObj.items.filter(function (item) {
- return _ctor.default.get(item, property);
- });
- parentStatus = selectItems.filter(function (item) {
- return vItems.indexOf(item) > -1;
- }).length === vItems.length ? true : selectItems.length || value === -1 ? -1 : false;
- }
- return this.handleSelectRow({
- row: matchObj.parent
- }, parentStatus);
- }
- } else {
- if (!checkMethod || checkMethod({
- row: row
- })) {
- _ctor.default.set(row, property, value);
- this.handleCheckboxReserveRow(row, value);
- }
- }
- } else {
- if (treeConfig && !checkStrictly) {
- if (value === -1) {
- if (treeIndeterminates.indexOf(row) === -1) {
- treeIndeterminates.push(row);
- }
- _ctor.default.remove(selection, function (item) {
- return item === row;
- });
- } else {
- // 更新子节点状态
- _ctor.default.eachTree([row], function (item) {
- if (row === item || !checkMethod || checkMethod({
- row: item
- })) {
- if (value) {
- selection.push(item);
- } else {
- _ctor.default.remove(selection, function (select) {
- return select === item;
- });
- }
- _ctor.default.remove(treeIndeterminates, function (half) {
- return half === item;
- });
- _this25.handleCheckboxReserveRow(row, value);
- }
- }, treeOpts);
- } // 如果存在父节点,更新父节点状态
- var _matchObj = _ctor.default.findTree(afterFullData, function (item) {
- return item === row;
- }, treeOpts);
- if (_matchObj && _matchObj.parent) {
- var _parentStatus;
- var _vItems = checkMethod ? _matchObj.items.filter(function (item) {
- return checkMethod({
- row: item
- });
- }) : _matchObj.items;
- var _indeterminatesItem = _ctor.default.find(_matchObj.items, function (item) {
- return treeIndeterminates.indexOf(item) > -1;
- });
- if (_indeterminatesItem) {
- _parentStatus = -1;
- } else {
- var _selectItems = _matchObj.items.filter(function (item) {
- return selection.indexOf(item) > -1;
- });
- _parentStatus = _selectItems.filter(function (item) {
- return _vItems.indexOf(item) > -1;
- }).length === _vItems.length ? true : _selectItems.length || value === -1 ? -1 : false;
- }
- return this.handleSelectRow({
- row: _matchObj.parent
- }, _parentStatus);
- }
- } else {
- if (!checkMethod || checkMethod({
- row: row
- })) {
- if (value) {
- if (selection.indexOf(row) === -1) {
- selection.push(row);
- }
- } else {
- _ctor.default.remove(selection, function (item) {
- return item === row;
- });
- }
- this.handleCheckboxReserveRow(row, value);
- }
- }
- }
- this.checkSelectionStatus();
- },
- handleToggleCheckRowEvent: function handleToggleCheckRowEvent(evnt, params) {
- var selection = this.selection,
- checkboxOpts = this.checkboxOpts;
- var property = checkboxOpts.checkField;
- var row = params.row;
- var value = property ? !_ctor.default.get(row, property) : selection.indexOf(row) === -1;
- if (evnt) {
- this.triggerCheckRowEvent(evnt, params, value);
- } else {
- this.handleSelectRow(params, value);
- }
- },
- triggerCheckRowEvent: function triggerCheckRowEvent(evnt, params, value) {
- var checkMethod = this.checkboxOpts.checkMethod;
- if (!checkMethod || checkMethod({
- row: params.row
- })) {
- this.handleSelectRow(params, value);
- var records = this.getCheckboxRecords(); // 在 v3.0 中废弃 select-change
- if (this.$listeners['select-change']) {
- _tools.UtilTools.warn('vxe.error.delEvent', ['select-change', 'checkbox-change']);
- this.emitEvent('select-change', Object.assign({
- records: records,
- selection: records,
- reserves: this.getCheckboxReserveRecords(),
- checked: value
- }, params), evnt);
- } else {
- this.emitEvent('checkbox-change', Object.assign({
- records: records,
- selection: records,
- reserves: this.getCheckboxReserveRecords(),
- indeterminates: this.getCheckboxIndeterminateRecords(),
- checked: value
- }, params), evnt);
- }
- }
- },
- // 在 v3.0 中废弃 toggleRowSelection
- toggleRowSelection: function toggleRowSelection(row) {
- _tools.UtilTools.warn('vxe.error.delFunc', ['toggleRowSelection', 'toggleCheckboxRow']);
- return this.toggleCheckboxRow(row);
- },
- /**
- * 多选,切换某一行的选中状态
- */
- toggleCheckboxRow: function toggleCheckboxRow(row) {
- this.handleToggleCheckRowEvent(null, {
- row: row
- });
- return this.$nextTick();
- },
- // 在 v3.0 中废弃 setAllSelection
- setAllSelection: function setAllSelection(value) {
- _tools.UtilTools.warn('vxe.error.delFunc', ['setAllSelection', 'setAllCheckboxRow']);
- return this.setAllCheckboxRow(value);
- },
- /**
- * 用于多选行,设置所有行的选中状态
- * @param {Boolean} value 是否选中
- */
- setAllCheckboxRow: function setAllCheckboxRow(value) {
- var _this26 = this;
- var afterFullData = this.afterFullData,
- treeConfig = this.treeConfig,
- treeOpts = this.treeOpts,
- selection = this.selection,
- checkboxReserveRowMap = this.checkboxReserveRowMap,
- checkboxOpts = this.checkboxOpts;
- var property = checkboxOpts.checkField,
- reserve = checkboxOpts.reserve,
- checkStrictly = checkboxOpts.checkStrictly,
- checkMethod = checkboxOpts.checkMethod;
- var selectRows = [];
- var beforeSelection = treeConfig ? [] : selection.filter(function (row) {
- return afterFullData.indexOf(row) === -1;
- });
- if (checkStrictly) {
- this.isAllSelected = value;
- } else {
- /**
- * 绑定属性方式(高性能,有污染)
- * 必须在行数据存在对应的属性,否则将不响应
- */
- if (property) {
- var checkValFn = function checkValFn(row) {
- if (!checkMethod || checkMethod({
- row: row
- })) {
- if (value) {
- selectRows.push(row);
- }
- _ctor.default.set(row, property, value);
- }
- }; // 如果存在选中方法
- // 如果方法成立,则更新值,否则忽略该数据
- if (treeConfig) {
- _ctor.default.eachTree(afterFullData, checkValFn, treeOpts);
- } else {
- afterFullData.forEach(checkValFn);
- }
- } else {
- /**
- * 默认方式(低性能,无污染)
- * 无需任何属性,直接绑定
- */
- if (treeConfig) {
- if (value) {
- /**
- * 如果是树勾选
- * 如果方法成立,则添加到临时集合中
- */
- _ctor.default.eachTree(afterFullData, function (row) {
- if (!checkMethod || checkMethod({
- row: row
- })) {
- selectRows.push(row);
- }
- }, treeOpts);
- } else {
- /**
- * 如果是树取消
- * 如果方法成立,则不添加到临时集合中
- */
- if (checkMethod) {
- _ctor.default.eachTree(afterFullData, function (row) {
- if (checkMethod({
- row: row
- }) ? 0 : selection.indexOf(row) > -1) {
- selectRows.push(row);
- }
- }, treeOpts);
- }
- }
- } else {
- if (value) {
- /**
- * 如果是行勾选
- * 如果存在选中方法且成立或者本身已勾选,则添加到临时集合中
- * 如果不存在选中方法,则添加所有数据到临时集合中
- */
- if (checkMethod) {
- selectRows = afterFullData.filter(function (row) {
- return selection.indexOf(row) > -1 || checkMethod({
- row: row
- });
- });
- } else {
- selectRows = afterFullData.slice(0);
- }
- } else {
- /**
- * 如果是行取消
- * 如果方法成立,则不添加到临时集合中;如果方法不成立则判断当前是否已勾选,如果已被勾选则添加到新集合中
- * 如果不存在选中方法,无需处理,临时集合默认为空
- */
- if (checkMethod) {
- selectRows = afterFullData.filter(function (row) {
- return checkMethod({
- row: row
- }) ? 0 : selection.indexOf(row) > -1;
- });
- }
- }
- }
- }
- if (reserve) {
- if (value) {
- selectRows.forEach(function (row) {
- checkboxReserveRowMap[getRowid(_this26, row)] = row;
- });
- } else {
- afterFullData.forEach(function (row) {
- return _this26.handleCheckboxReserveRow(row, false);
- });
- }
- }
- this.selection = property ? [] : beforeSelection.concat(selectRows);
- }
- this.treeIndeterminates = [];
- this.checkSelectionStatus();
- },
- checkSelectionStatus: function checkSelectionStatus() {
- var afterFullData = this.afterFullData,
- selection = this.selection,
- treeIndeterminates = this.treeIndeterminates,
- checkboxOpts = this.checkboxOpts,
- treeConfig = this.treeConfig;
- var checkField = checkboxOpts.checkField,
- halfField = checkboxOpts.halfField,
- checkStrictly = checkboxOpts.checkStrictly,
- checkMethod = checkboxOpts.checkMethod;
- if (!checkStrictly) {
- var isAllSelected = false;
- var isIndeterminate = false;
- if (checkField) {
- isAllSelected = afterFullData.length && afterFullData.every(checkMethod ? function (row) {
- return !checkMethod({
- row: row
- }) || _ctor.default.get(row, checkField);
- } : function (row) {
- return _ctor.default.get(row, checkField);
- });
- if (treeConfig) {
- if (halfField) {
- isIndeterminate = !isAllSelected && afterFullData.some(function (row) {
- return _ctor.default.get(row, checkField) || _ctor.default.get(row, halfField) || treeIndeterminates.indexOf(row) > -1;
- });
- } else {
- isIndeterminate = !isAllSelected && afterFullData.some(function (row) {
- return _ctor.default.get(row, checkField) || treeIndeterminates.indexOf(row) > -1;
- });
- }
- } else {
- if (halfField) {
- isIndeterminate = !isAllSelected && afterFullData.some(function (row) {
- return _ctor.default.get(row, checkField) || _ctor.default.get(row, halfField);
- });
- } else {
- isIndeterminate = !isAllSelected && afterFullData.some(function (row) {
- return _ctor.default.get(row, checkField);
- });
- }
- }
- } else {
- isAllSelected = afterFullData.length && afterFullData.every(checkMethod ? function (row) {
- return !checkMethod({
- row: row
- }) || selection.indexOf(row) > -1;
- } : function (row) {
- return selection.indexOf(row) > -1;
- });
- if (treeConfig) {
- isIndeterminate = !isAllSelected && afterFullData.some(function (row) {
- return treeIndeterminates.indexOf(row) > -1 || selection.indexOf(row) > -1;
- });
- } else {
- isIndeterminate = !isAllSelected && afterFullData.some(function (row) {
- return selection.indexOf(row) > -1;
- });
- }
- }
- this.isAllSelected = isAllSelected;
- this.isIndeterminate = isIndeterminate;
- }
- },
- // 还原展开、选中等相关状态
- handleReserveStatus: function handleReserveStatus() {
- var expandColumn = this.expandColumn,
- treeOpts = this.treeOpts,
- treeConfig = this.treeConfig,
- fullDataRowIdData = this.fullDataRowIdData,
- fullAllDataRowMap = this.fullAllDataRowMap,
- currentRow = this.currentRow,
- selectRow = this.selectRow,
- radioReserveRow = this.radioReserveRow,
- radioOpts = this.radioOpts,
- checkboxOpts = this.checkboxOpts,
- selection = this.selection,
- rowExpandeds = this.rowExpandeds,
- treeExpandeds = this.treeExpandeds,
- expandOpts = this.expandOpts; // 单选框
- if (selectRow && !fullAllDataRowMap.has(selectRow)) {
- this.selectRow = null; // 刷新单选行状态
- } // 还原保留选中状态
- if (radioOpts.reserve && radioReserveRow) {
- var rowid = getRowid(this, radioReserveRow);
- if (fullDataRowIdData[rowid]) {
- this.setRadioRow(fullDataRowIdData[rowid].row);
- }
- } // 复选框
- this.selection = getRecoverRow(this, selection); // 刷新多选行状态
- // 还原保留选中状态
- if (checkboxOpts.reserve) {
- this.setCheckboxRow(handleReserveRow(this, this.checkboxReserveRowMap), true);
- }
- if (currentRow && !fullAllDataRowMap.has(currentRow)) {
- this.currentRow = null; // 刷新当前行状态
- } // 行展开
- this.rowExpandeds = expandColumn ? getRecoverRow(this, rowExpandeds) : []; // 刷新行展开状态
- // 还原保留状态
- if (expandColumn && expandOpts.reserve) {
- this.setRowExpand(handleReserveRow(this, this.rowExpandedReserveRowMap), true);
- } // 树展开
- this.treeExpandeds = treeConfig ? getRecoverRow(this, treeExpandeds) : []; // 刷新树展开状态
- if (treeConfig && treeOpts.reserve) {
- this.setTreeExpand(handleReserveRow(this, this.treeExpandedReserveRowMap), true);
- }
- },
- /**
- * 获取单选框保留选中的行
- */
- getRadioReserveRecord: function getRadioReserveRecord() {
- var fullDataRowIdData = this.fullDataRowIdData,
- radioReserveRow = this.radioReserveRow,
- radioOpts = this.radioOpts;
- if (radioOpts.reserve && radioReserveRow) {
- if (!fullDataRowIdData[getRowid(this, radioReserveRow)]) {
- return radioReserveRow;
- }
- }
- return null;
- },
- clearRadioReserve: function clearRadioReserve() {
- this.radioReserveRow = null;
- return this.$nextTick();
- },
- handleRadioReserveRow: function handleRadioReserveRow(row) {
- var radioOpts = this.radioOpts;
- if (radioOpts.reserve) {
- this.radioReserveRow = row;
- }
- },
- // 在 v3.0 中废弃 getSelectReserveRecords
- getSelectReserveRecords: function getSelectReserveRecords() {
- _tools.UtilTools.warn('vxe.error.delFunc', ['getSelectReserveRecords', 'getCheckboxReserveRecords']);
- return this.getCheckboxReserveRecords();
- },
- /**
- * 获取保留选中的行
- */
- getCheckboxReserveRecords: function getCheckboxReserveRecords() {
- var fullDataRowIdData = this.fullDataRowIdData,
- checkboxReserveRowMap = this.checkboxReserveRowMap,
- checkboxOpts = this.checkboxOpts;
- var reserveSelection = [];
- if (checkboxOpts.reserve) {
- Object.keys(checkboxReserveRowMap).forEach(function (rowid) {
- if (!fullDataRowIdData[rowid]) {
- reserveSelection.push(checkboxReserveRowMap[rowid]);
- }
- });
- }
- return reserveSelection;
- },
- // 在 v3.0 中废弃 clearSelectReserve
- clearSelectReserve: function clearSelectReserve() {
- _tools.UtilTools.warn('vxe.error.delFunc', ['clearSelectReserve', 'clearCheckboxReserve']);
- return this.clearCheckboxReserve();
- },
- clearCheckboxReserve: function clearCheckboxReserve() {
- this.checkboxReserveRowMap = {};
- return this.$nextTick();
- },
- handleCheckboxReserveRow: function handleCheckboxReserveRow(row, checked) {
- var checkboxReserveRowMap = this.checkboxReserveRowMap,
- checkboxOpts = this.checkboxOpts;
- if (checkboxOpts.reserve) {
- var rowid = getRowid(this, row);
- if (checked) {
- checkboxReserveRowMap[rowid] = row;
- } else if (checkboxReserveRowMap[rowid]) {
- delete checkboxReserveRowMap[rowid];
- }
- }
- },
- /**
- * 多选,选中所有事件
- */
- triggerCheckAllEvent: function triggerCheckAllEvent(evnt, value) {
- this.setAllCheckboxRow(value);
- var records = this.getCheckboxRecords(); // 在 v3.0 中废弃 select-all
- if (this.$listeners['select-all']) {
- _tools.UtilTools.warn('vxe.error.delEvent', ['select-all', 'checkbox-all']);
- this.emitEvent('select-all', {
- records: records,
- selection: records,
- reserves: this.getCheckboxReserveRecords(),
- checked: value
- }, evnt);
- } else {
- this.emitEvent('checkbox-all', {
- records: records,
- selection: records,
- reserves: this.getCheckboxReserveRecords(),
- indeterminates: this.getCheckboxIndeterminateRecords(),
- checked: value
- }, evnt);
- }
- },
- // 在 v3.0 中废弃 toggleAllSelection
- toggleAllSelection: function toggleAllSelection() {
- _tools.UtilTools.warn('vxe.error.delFunc', ['toggleAllSelection', 'toggleAllCheckboxRow']);
- return this.toggleAllCheckboxRow();
- },
- /**
- * 多选,切换所有行的选中状态
- */
- toggleAllCheckboxRow: function toggleAllCheckboxRow() {
- this.triggerCheckAllEvent(null, !this.isAllSelected);
- return this.$nextTick();
- },
- // 在 v3.0 中废弃 clearSelection
- clearSelection: function clearSelection() {
- _tools.UtilTools.warn('vxe.error.delFunc', ['clearSelection', 'clearCheckboxRow']);
- return this.clearCheckboxRow();
- },
- /**
- * 用于多选行,手动清空用户的选择
- * 清空行为不管是否被禁用还是保留记录,都将彻底清空选中状态
- */
- clearCheckboxRow: function clearCheckboxRow() {
- var _this27 = this;
- var tableFullData = this.tableFullData,
- treeConfig = this.treeConfig,
- treeOpts = this.treeOpts,
- checkboxOpts = this.checkboxOpts;
- var property = checkboxOpts.checkField,
- reserve = checkboxOpts.reserve;
- if (property) {
- if (treeConfig) {
- _ctor.default.eachTree(tableFullData, function (item) {
- return _ctor.default.set(item, property, false);
- }, treeOpts);
- } else {
- tableFullData.forEach(function (item) {
- return _ctor.default.set(item, property, false);
- });
- }
- }
- if (reserve) {
- tableFullData.forEach(function (row) {
- return _this27.handleCheckboxReserveRow(row, false);
- });
- }
- this.isAllSelected = false;
- this.isIndeterminate = false;
- this.selection = [];
- this.treeIndeterminates = [];
- return this.$nextTick();
- },
- /**
- * 处理单选框默认勾选
- */
- handleDefaultRadioChecked: function handleDefaultRadioChecked() {
- var radioOpts = this.radioOpts,
- fullDataRowIdData = this.fullDataRowIdData;
- var rowid = radioOpts.checkRowKey,
- reserve = radioOpts.reserve;
- if (rowid) {
- if (fullDataRowIdData[rowid]) {
- this.setRadioRow(fullDataRowIdData[rowid].row);
- }
- if (reserve) {
- var rowkey = getRowkey(this);
- this.radioReserveRow = _defineProperty({}, rowkey, rowid);
- }
- }
- },
- /**
- * 单选,行选中事件
- */
- triggerRadioRowEvent: function triggerRadioRowEvent(evnt, params) {
- var isChange = this.selectRow !== params.row;
- this.setRadioRow(params.row);
- if (isChange) {
- this.emitEvent('radio-change', params, evnt);
- }
- },
- triggerCurrentRowEvent: function triggerCurrentRowEvent(evnt, params) {
- var isChange = this.currentRow !== params.row;
- this.setCurrentRow(params.row);
- if (isChange) {
- this.emitEvent('current-change', params, evnt);
- }
- },
- /**
- * 用于当前行,设置某一行为高亮状态
- * @param {Row} row 行对象
- */
- setCurrentRow: function setCurrentRow(row) {
- this.clearCurrentRow();
- this.clearCurrentColumn();
- this.currentRow = row;
- if (this.highlightCurrentRow) {
- _ctor.default.arrayEach(this.$el.querySelectorAll("[data-rowid=\"".concat(getRowid(this, row), "\"]")), function (elem) {
- return addClass(elem, 'row--current');
- });
- }
- return this.$nextTick();
- },
- isCheckedByRadioRow: function isCheckedByRadioRow(row) {
- return this.selectRow === row;
- },
- /**
- * 用于单选行,设置某一行为选中状态
- * @param {Row} row 行对象
- */
- setRadioRow: function setRadioRow(row) {
- var radioOpts = this.radioOpts;
- var checkMethod = radioOpts.checkMethod;
- if (row && (!checkMethod || checkMethod({
- row: row
- }))) {
- this.selectRow = row;
- this.handleRadioReserveRow(row);
- }
- return this.$nextTick();
- },
- /**
- * 用于当前行,手动清空当前高亮的状态
- */
- clearCurrentRow: function clearCurrentRow() {
- this.currentRow = null;
- this.hoverRow = null;
- _ctor.default.arrayEach(this.$el.querySelectorAll('.row--current'), function (elem) {
- return removeClass(elem, 'row--current');
- });
- return this.$nextTick();
- },
- /**
- * 用于单选行,手动清空用户的选择
- */
- clearRadioRow: function clearRadioRow() {
- this.selectRow = null;
- return this.$nextTick();
- },
- // 在 v3.0 中废弃 getCurrentRow
- getCurrentRow: function getCurrentRow() {
- _tools.UtilTools.warn('vxe.error.delFunc', ['getCurrentRow', 'getCurrentRecord']);
- return this.getCurrentRecord();
- },
- /**
- * 用于当前行,获取当前行的数据
- */
- getCurrentRecord: function getCurrentRecord() {
- return this.highlightCurrentRow ? this.currentRow : null;
- },
- // 在 v3.0 中废弃 getRadioRow
- getRadioRow: function getRadioRow() {
- _tools.UtilTools.warn('vxe.error.delFunc', ['getRadioRow', 'getRadioRecord']);
- return this.getRadioRecord();
- },
- /**
- * 用于单选行,获取当已选中的数据
- */
- getRadioRecord: function getRadioRecord() {
- return this.selectRow;
- },
- /**
- * 行 hover 事件
- */
- triggerHoverEvent: function triggerHoverEvent(evnt, _ref5) {
- var row = _ref5.row;
- this.setHoverRow(row);
- },
- setHoverRow: function setHoverRow(row) {
- var rowid = getRowid(this, row);
- this.clearHoverRow();
- _ctor.default.arrayEach(this.$el.querySelectorAll("[data-rowid=\"".concat(rowid, "\"]")), function (elem) {
- return addClass(elem, 'row--hover');
- });
- this.hoverRow = row;
- },
- clearHoverRow: function clearHoverRow() {
- _ctor.default.arrayEach(this.$el.querySelectorAll('.vxe-body--row.row--hover'), function (elem) {
- return removeClass(elem, 'row--hover');
- });
- this.hoverRow = null;
- },
- triggerHeaderCellClickEvent: function triggerHeaderCellClickEvent(evnt, params) {
- var _lastResizeTime = this._lastResizeTime,
- sortOpts = this.sortOpts;
- var column = params.column;
- var cell = evnt.currentTarget;
- var triggerResizable = _lastResizeTime && _lastResizeTime > Date.now() - 300;
- var triggerSort = getEventTargetNode(evnt, cell, 'vxe-cell--sort').flag;
- var triggerFilter = getEventTargetNode(evnt, cell, 'vxe-cell--filter').flag;
- if (sortOpts.trigger === 'cell' && !(triggerResizable || triggerSort || triggerFilter)) {
- this.triggerSortEvent(evnt, column, getNextSortOrder(this, column));
- }
- this.emitEvent('header-cell-click', Object.assign({
- triggerResizable: triggerResizable,
- triggerSort: triggerSort,
- triggerFilter: triggerFilter,
- cell: cell
- }, params), evnt);
- if (this.highlightCurrentColumn) {
- return this.setCurrentColumn(column);
- }
- return this.$nextTick();
- },
- triggerHeaderCellDBLClickEvent: function triggerHeaderCellDBLClickEvent(evnt, params) {
- this.emitEvent('header-cell-dblclick', Object.assign({
- cell: evnt.currentTarget
- }, params), evnt);
- },
- getCurrentColumn: function getCurrentColumn() {
- return this.highlightCurrentColumn ? this.currentColumn : null;
- },
- /**
- * 用于当前列,设置某列行为高亮状态
- * @param {ColumnInfo} column 列配置
- */
- setCurrentColumn: function setCurrentColumn(column) {
- this.clearCurrentRow();
- this.clearCurrentColumn();
- this.currentColumn = column;
- return this.$nextTick();
- },
- /**
- * 用于当前列,手动清空当前高亮的状态
- */
- clearCurrentColumn: function clearCurrentColumn() {
- this.currentColumn = null;
- return this.$nextTick();
- },
- checkValidate: function checkValidate(type) {
- if (_vXETable.default._valid) {
- return this.triggerValidate(type);
- }
- return this.$nextTick();
- },
- /**
- * 当单元格发生改变时
- * 如果存在规则,则校验
- */
- handleChangeCell: function handleChangeCell(evnt, params) {
- var _this28 = this;
- this.checkValidate('blur').catch(function (e) {
- return e;
- }).then(function () {
- _this28.handleActived(params, evnt).then(function () {
- return _this28.checkValidate('change');
- }).catch(function (e) {
- return e;
- });
- });
- },
- /**
- * 列点击事件
- * 如果是单击模式,则激活为编辑状态
- * 如果是双击模式,则单击后选中状态
- */
- triggerCellClickEvent: function triggerCellClickEvent(evnt, params) {
- var highlightCurrentRow = this.highlightCurrentRow,
- editStore = this.editStore,
- radioOpts = this.radioOpts,
- expandOpts = this.expandOpts,
- treeOpts = this.treeOpts,
- editConfig = this.editConfig,
- editOpts = this.editOpts,
- checkboxOpts = this.checkboxOpts,
- mouseConfig = this.mouseConfig,
- mouseOpts = this.mouseOpts;
- var actived = editStore.actived;
- var _params = params,
- row = _params.row,
- column = _params.column;
- var type = column.type,
- treeNode = column.treeNode;
- var isRadioType = type === 'radio'; // 在 v3.0 中废弃 selection
- var isCheckboxType = type === 'checkbox' || type === 'selection';
- var isExpandType = type === 'expand';
- var cell = evnt.currentTarget;
- var triggerRadio = isRadioType && getEventTargetNode(evnt, cell, 'vxe-cell--radio').flag;
- var triggerCheckbox = isCheckboxType && getEventTargetNode(evnt, cell, 'vxe-cell--checkbox').flag;
- var triggerTreeNode = treeNode && getEventTargetNode(evnt, cell, 'vxe-tree--btn-wrapper').flag;
- var triggerExpandNode = isExpandType && getEventTargetNode(evnt, cell, 'vxe-table--expanded').flag;
- params = Object.assign({
- cell: cell,
- triggerRadio: triggerRadio,
- triggerCheckbox: triggerCheckbox,
- triggerTreeNode: triggerTreeNode,
- triggerExpandNode: triggerExpandNode
- }, params); // 在 v3.0 中废弃 mouse-config.checked
- var isMouseChecked = mouseConfig && mouseOpts.checked; // 如果是展开行
- if (!triggerExpandNode && (expandOpts.trigger === 'row' || isExpandType && expandOpts.trigger === 'cell')) {
- this.triggerRowExpandEvent(evnt, params);
- } // 如果是树形表格
- if (treeOpts.trigger === 'row' || treeNode && treeOpts.trigger === 'cell') {
- this.triggerTreeExpandEvent(evnt, params);
- } // 如果点击了树节点
- if (!triggerTreeNode) {
- if (!triggerExpandNode) {
- // 如果是高亮行
- if (highlightCurrentRow) {
- if (!triggerCheckbox && !triggerRadio) {
- this.triggerCurrentRowEvent(evnt, params);
- }
- } // 如果是单选框
- if (!triggerRadio && (radioOpts.trigger === 'row' || isRadioType && radioOpts.trigger === 'cell')) {
- this.triggerRadioRowEvent(evnt, params);
- } // 如果是复选框
- if (!triggerCheckbox && (checkboxOpts.trigger === 'row' || isCheckboxType && checkboxOpts.trigger === 'cell')) {
- this.handleToggleCheckRowEvent(evnt, params);
- }
- } // 如果设置了单元格选中功能,则不会使用点击事件去处理(只能支持双击模式)
- if (!isMouseChecked) {
- if (editConfig) {
- if (editOpts.trigger === 'manual') {
- if (actived.args && actived.row === row && column !== actived.column) {
- this.handleChangeCell(evnt, params);
- }
- } else if (!actived.args || row !== actived.row || column !== actived.column) {
- if (editOpts.trigger === 'click') {
- this.handleChangeCell(evnt, params);
- } else if (editOpts.trigger === 'dblclick') {
- if (editOpts.mode === 'row' && actived.row === row) {
- this.handleChangeCell(evnt, params);
- }
- }
- }
- }
- }
- }
- this.emitEvent('cell-click', params, evnt);
- },
- /**
- * 列双击点击事件
- * 如果是双击模式,则激活为编辑状态
- */
- triggerCellDBLClickEvent: function triggerCellDBLClickEvent(evnt, params) {
- var _this29 = this;
- var editStore = this.editStore,
- editConfig = this.editConfig,
- editOpts = this.editOpts;
- var actived = editStore.actived;
- var cell = evnt.currentTarget;
- params.cell = cell;
- if (editConfig && editOpts.trigger === 'dblclick') {
- if (!actived.args || evnt.currentTarget !== actived.args.cell) {
- if (editOpts.mode === 'row') {
- this.checkValidate('blur').catch(function (e) {
- return e;
- }).then(function () {
- _this29.handleActived(params, evnt).then(function () {
- return _this29.checkValidate('change');
- }).catch(function (e) {
- return e;
- });
- });
- } else if (editOpts.mode === 'cell') {
- this.handleActived(params, evnt).then(function () {
- return _this29.checkValidate('change');
- }).catch(function (e) {
- return e;
- });
- }
- }
- }
- this.emitEvent('cell-dblclick', params, evnt);
- },
- handleDefaultSort: function handleDefaultSort() {
- var defaultSort = this.sortOpts.defaultSort;
- if (defaultSort) {
- var field = defaultSort.field,
- order = defaultSort.order;
- if (field && order) {
- var column = _ctor.default.find(this.tableFullColumn, function (item) {
- return item.property === field;
- });
- if (column && !column.order) {
- this.sort(field, order);
- }
- }
- }
- },
- /**
- * 点击排序事件
- */
- triggerSortEvent: function triggerSortEvent(evnt, column, order) {
- var property = column.property;
- if (column.sortable || column.remoteSort) {
- if (!order || column.order === order) {
- this.clearSort();
- } else {
- this.sort(property, order);
- }
- var params = {
- column: column,
- property: property,
- order: column.order,
- sortBy: column.sortBy,
- sortList: this.getSortColumns()
- };
- this.emitEvent('sort-change', params, evnt);
- }
- },
- sort: function sort(field, order) {
- var tableFullColumn = this.tableFullColumn,
- sortOpts = this.sortOpts;
- var column = this.getColumnByField(field);
- if (column) {
- var isRemote = _ctor.default.isBoolean(column.remoteSort) ? column.remoteSort : sortOpts.remote;
- if (column.sortable || column.remoteSort) {
- if (arguments.length <= 1) {
- order = getNextSortOrder(this, column);
- }
- if (column.order !== order) {
- tableFullColumn.forEach(function (column) {
- column.order = null;
- });
- column.order = order; // 如果是服务端排序,则跳过本地排序处理
- if (!isRemote) {
- this.handleTableData(true);
- }
- }
- return this.$nextTick().then(this.updateStyle);
- }
- }
- return this.$nextTick();
- },
- /**
- * 手动清空排序条件,数据会恢复成未排序的状态
- */
- clearSort: function clearSort() {
- this.tableFullColumn.forEach(function (column) {
- column.order = null;
- });
- return this.handleTableData(true);
- },
- // 在 v3 中废弃
- getSortColumn: function getSortColumn() {
- // UtilTools.warn('vxe.error.delFunc', ['getSortColumn', 'getSortColumns'])
- return _ctor.default.find(this.tableFullColumn, function (column) {
- return (column.sortable || column.remoteSort) && column.order;
- });
- },
- isSort: function isSort(field) {
- if (field) {
- var column = this.getColumnByField(field);
- return column && (column.sortable || column.remoteSort) && column.order;
- }
- return this.getSortColumns().length > 0;
- },
- getSortColumns: function getSortColumns() {
- var sortList = [];
- this.tableFullColumn.forEach(function (column) {
- var order = column.order;
- if ((column.sortable || column.remoteSort) && order) {
- sortList.push({
- column: column,
- sortBy: column.sortBy,
- property: column.property,
- order: order
- });
- }
- });
- return sortList;
- },
- /**
- * 关闭筛选
- * @param {Event} evnt 事件
- */
- closeFilter: function closeFilter() {
- Object.assign(this.filterStore, {
- isAllSelected: false,
- isIndeterminate: false,
- options: [],
- visible: false
- });
- return this.$nextTick();
- },
- /**
- * 判断指定列是否为筛选状态,如果为空则判断所有列
- * @param {String} fieldOrColumn 字段名或列
- */
- isFilter: function isFilter(fieldOrColumn) {
- var column = _ctor.default.isString(fieldOrColumn) ? this.getColumnByField(fieldOrColumn) : fieldOrColumn;
- if (column) {
- return column.filters && column.filters.some(function (option) {
- return option.checked;
- });
- }
- return this.visibleColumn.some(function (column) {
- return column.filters && column.filters.some(function (option) {
- return option.checked;
- });
- });
- },
- /**
- * 判断展开行是否懒加载完成
- * @param {Row} row 行对象
- */
- isRowExpandLoaded: function isRowExpandLoaded(row) {
- var rest = this.fullAllDataRowMap.get(row);
- return rest && rest.expandLoaded;
- },
- clearRowExpandLoaded: function clearRowExpandLoaded(row) {
- var expandOpts = this.expandOpts,
- expandLazyLoadeds = this.expandLazyLoadeds,
- fullAllDataRowMap = this.fullAllDataRowMap;
- var lazy = expandOpts.lazy;
- var rest = fullAllDataRowMap.get(row);
- if (lazy && rest) {
- rest.expandLoaded = false;
- _ctor.default.remove(expandLazyLoadeds, function (item) {
- return row === item;
- });
- }
- return this.$nextTick();
- },
- /**
- * 重新加载展开行的内容
- * @param {Row} row 行对象
- */
- reloadExpandContent: function reloadExpandContent(row) {
- var _this30 = this;
- var expandOpts = this.expandOpts,
- expandLazyLoadeds = this.expandLazyLoadeds;
- var lazy = expandOpts.lazy;
- if (lazy && expandLazyLoadeds.indexOf(row) === -1) {
- this.clearRowExpandLoaded(row).then(function () {
- return _this30.handleAsyncRowExpand(row);
- });
- }
- return this.$nextTick();
- },
- /**
- * 展开行事件
- */
- triggerRowExpandEvent: function triggerRowExpandEvent(evnt, params) {
- var $listeners = this.$listeners,
- expandOpts = this.expandOpts,
- expandLazyLoadeds = this.expandLazyLoadeds,
- column = this.expandColumn;
- var row = params.row;
- var lazy = expandOpts.lazy;
- if (!lazy || expandLazyLoadeds.indexOf(row) === -1) {
- var expanded = !this.isExpandByRow(row);
- var columnIndex = this.getColumnIndex(column);
- var $columnIndex = this.getVMColumnIndex(column);
- this.setRowExpand(row, expanded); // 在 v3.0 中废弃 toggle-expand-change
- if ($listeners['toggle-expand-change']) {
- _tools.UtilTools.warn('vxe.error.delEvent', ['toggle-expand-change', 'toggle-row-expand']);
- this.emitEvent('toggle-expand-change', {
- expanded: expanded,
- column: column,
- columnIndex: columnIndex,
- $columnIndex: $columnIndex,
- row: row,
- rowIndex: this.getRowIndex(row),
- $rowIndex: this.getVMRowIndex(row)
- }, evnt);
- } else {
- this.emitEvent('toggle-row-expand', {
- expanded: expanded,
- column: column,
- columnIndex: columnIndex,
- $columnIndex: $columnIndex,
- row: row,
- rowIndex: this.getRowIndex(row),
- $rowIndex: this.getVMRowIndex(row)
- }, evnt);
- }
- }
- },
- toggleRowExpansion: function toggleRowExpansion(row) {
- _tools.UtilTools.warn('vxe.error.delFunc', ['toggleRowExpansion', 'toggleRowExpand']);
- return this.toggleRowExpand(row);
- },
- /**
- * 切换展开行
- */
- toggleRowExpand: function toggleRowExpand(row) {
- return this.setRowExpand(row, !this.isExpandByRow(row));
- },
- /**
- * 处理默认展开行
- */
- handleDefaultRowExpand: function handleDefaultRowExpand() {
- var expandOpts = this.expandOpts,
- fullDataRowIdData = this.fullDataRowIdData;
- var expandAll = expandOpts.expandAll,
- expandRowKeys = expandOpts.expandRowKeys;
- if (expandAll) {
- this.setAllRowExpand(true);
- } else if (expandRowKeys) {
- var defExpandeds = [];
- expandRowKeys.forEach(function (rowid) {
- if (fullDataRowIdData[rowid]) {
- defExpandeds.push(fullDataRowIdData[rowid].row);
- }
- });
- this.setRowExpand(defExpandeds, true);
- }
- },
- setAllRowExpansion: function setAllRowExpansion(expanded) {
- _tools.UtilTools.warn('vxe.error.delFunc', ['setAllRowExpansion', 'setAllRowExpand']);
- return this.setAllRowExpand(expanded);
- },
- /**
- * 设置所有行的展开与否
- * @param {Boolean} expanded 是否展开
- */
- setAllRowExpand: function setAllRowExpand(expanded) {
- return this.setRowExpand(this.expandOpts.lazy ? this.tableData : this.tableFullData, expanded);
- },
- handleAsyncRowExpand: function handleAsyncRowExpand(row) {
- var _this31 = this;
- var rest = this.fullAllDataRowMap.get(row);
- return new Promise(function (resolve) {
- _this31.expandLazyLoadeds.push(row);
- _this31.expandOpts.loadMethod({
- $table: _this31,
- row: row,
- rowIndex: _this31.getRowIndex(row),
- $rowIndex: _this31.getVMRowIndex(row)
- }).catch(function (e) {
- return e;
- }).then(function () {
- rest.expandLoaded = true;
- _ctor.default.remove(_this31.expandLazyLoadeds, function (item) {
- return item === row;
- });
- _this31.rowExpandeds.push(row);
- resolve(_this31.$nextTick().then(_this31.recalculate));
- });
- });
- },
- setRowExpansion: function setRowExpansion(rows, expanded) {
- _tools.UtilTools.warn('vxe.error.delFunc', ['setRowExpansion', 'setRowExpand']);
- return this.setRowExpand(rows, expanded);
- },
- /**
- * 设置展开行,二个参数设置这一行展开与否
- * 支持单行
- * 支持多行
- * @param {Array/Row} rows 行数据
- * @param {Boolean} expanded 是否展开
- */
- setRowExpand: function setRowExpand(rows, expanded) {
- var _this32 = this;
- var fullAllDataRowMap = this.fullAllDataRowMap,
- expandLazyLoadeds = this.expandLazyLoadeds,
- expandOpts = this.expandOpts,
- column = this.expandColumn;
- var rowExpandeds = this.rowExpandeds;
- var reserve = expandOpts.reserve,
- lazy = expandOpts.lazy,
- accordion = expandOpts.accordion,
- toggleMethod = expandOpts.toggleMethod;
- var lazyRests = [];
- var columnIndex = this.getColumnIndex(column);
- var $columnIndex = this.getVMColumnIndex(column);
- if (rows) {
- if (!_ctor.default.isArray(rows)) {
- rows = [rows];
- }
- if (accordion) {
- // 只能同时展开一个
- rowExpandeds = [];
- rows = rows.slice(rows.length - 1, rows.length);
- }
- var validRows = toggleMethod ? rows.filter(function (row) {
- return toggleMethod({
- expanded: expanded,
- column: column,
- columnIndex: columnIndex,
- $columnIndex: $columnIndex,
- row: row,
- rowIndex: _this32.getRowIndex(row),
- $rowIndex: _this32.getVMRowIndex(row)
- });
- }) : rows;
- if (expanded) {
- validRows.forEach(function (row) {
- if (rowExpandeds.indexOf(row) === -1) {
- var rest = fullAllDataRowMap.get(row);
- var isLoad = lazy && !rest.expandLoaded && expandLazyLoadeds.indexOf(row) === -1;
- if (isLoad) {
- lazyRests.push(_this32.handleAsyncRowExpand(row));
- } else {
- rowExpandeds.push(row);
- }
- }
- });
- } else {
- _ctor.default.remove(rowExpandeds, function (row) {
- return validRows.indexOf(row) > -1;
- });
- }
- if (reserve) {
- validRows.forEach(function (row) {
- return _this32.handleRowExpandReserve(row, expanded);
- });
- }
- }
- this.rowExpandeds = rowExpandeds;
- return Promise.all(lazyRests).then(this.recalculate);
- },
- // 在 v3.0 中废弃 getRecords
- hasRowExpand: function hasRowExpand(row) {
- _tools.UtilTools.warn('vxe.error.delFunc', ['hasRowExpand', 'isExpandByRow']);
- return this.isExpandByRow(row);
- },
- /**
- * 判断行是否为展开状态
- * @param {Row} row 行对象
- */
- isExpandByRow: function isExpandByRow(row) {
- return this.rowExpandeds.indexOf(row) > -1;
- },
- /**
- * 手动清空展开行状态,数据会恢复成未展开的状态
- */
- clearRowExpand: function clearRowExpand() {
- var _this33 = this;
- var expandOpts = this.expandOpts,
- rowExpandeds = this.rowExpandeds,
- tableFullData = this.tableFullData;
- var reserve = expandOpts.reserve;
- var isExists = rowExpandeds.length;
- this.rowExpandeds = [];
- if (reserve) {
- tableFullData.forEach(function (row) {
- return _this33.handleRowExpandReserve(row, false);
- });
- }
- return this.$nextTick().then(function () {
- if (isExists) {
- _this33.recalculate();
- }
- });
- },
- clearRowExpandReserve: function clearRowExpandReserve() {
- this.rowExpandedReserveRowMap = {};
- return this.$nextTick();
- },
- handleRowExpandReserve: function handleRowExpandReserve(row, expanded) {
- var rowExpandedReserveRowMap = this.rowExpandedReserveRowMap,
- expandOpts = this.expandOpts;
- if (expandOpts.reserve) {
- var rowid = getRowid(this, row);
- if (expanded) {
- rowExpandedReserveRowMap[rowid] = row;
- } else if (rowExpandedReserveRowMap[rowid]) {
- delete rowExpandedReserveRowMap[rowid];
- }
- }
- },
- getRowExpandRecords: function getRowExpandRecords() {
- return this.rowExpandeds.slice(0);
- },
- getTreeExpandRecords: function getTreeExpandRecords() {
- return this.treeExpandeds.slice(0);
- },
- /**
- * 获取数表格状态
- */
- getTreeStatus: function getTreeStatus() {
- if (this.treeConfig) {
- return {
- config: this.treeOpts,
- rowExpandeds: this.getTreeExpandRecords()
- };
- }
- return null;
- },
- /**
- * 判断树节点是否懒加载完成
- * @param {Row} row 行对象
- */
- isTreeExpandLoaded: function isTreeExpandLoaded(row) {
- var rest = this.fullAllDataRowMap.get(row);
- return rest && rest.treeLoaded;
- },
- clearTreeExpandLoaded: function clearTreeExpandLoaded(row) {
- var treeOpts = this.treeOpts,
- treeExpandeds = this.treeExpandeds,
- fullAllDataRowMap = this.fullAllDataRowMap;
- var lazy = treeOpts.lazy;
- var rest = fullAllDataRowMap.get(row);
- if (lazy && rest) {
- rest.treeLoaded = false;
- _ctor.default.remove(treeExpandeds, function (item) {
- return row === item;
- });
- }
- return this.$nextTick();
- },
- /**
- * 重新加载树的子节点
- * @param {Row} row 行对象
- */
- reloadTreeChilds: function reloadTreeChilds(row) {
- var _this34 = this;
- var treeOpts = this.treeOpts,
- treeLazyLoadeds = this.treeLazyLoadeds;
- var lazy = treeOpts.lazy,
- hasChild = treeOpts.hasChild;
- if (lazy && row[hasChild] && treeLazyLoadeds.indexOf(row) === -1) {
- this.clearTreeExpandLoaded(row).then(function () {
- return _this34.handleAsyncTreeExpandChilds(row);
- });
- }
- return this.$nextTick();
- },
- /**
- * 展开树节点事件
- */
- triggerTreeExpandEvent: function triggerTreeExpandEvent(evnt, params) {
- var $listeners = this.$listeners,
- treeOpts = this.treeOpts,
- treeLazyLoadeds = this.treeLazyLoadeds;
- var row = params.row,
- column = params.column;
- var lazy = treeOpts.lazy;
- if (!lazy || treeLazyLoadeds.indexOf(row) === -1) {
- var expanded = !this.isTreeExpandByRow(row);
- var columnIndex = this.getColumnIndex(column);
- var $columnIndex = this.getVMColumnIndex(column);
- this.setTreeExpand(row, expanded); // 在 v3.0 中废弃 toggle-tree-change
- if ($listeners['toggle-tree-change']) {
- _tools.UtilTools.warn('vxe.error.delEvent', ['toggle-tree-change', 'toggle-tree-expand']);
- this.emitEvent('toggle-tree-change', {
- expanded: expanded,
- column: column,
- columnIndex: columnIndex,
- $columnIndex: $columnIndex,
- row: row
- }, evnt);
- } else {
- this.emitEvent('toggle-tree-expand', {
- expanded: expanded,
- column: column,
- columnIndex: columnIndex,
- $columnIndex: $columnIndex,
- row: row
- }, evnt);
- }
- }
- },
- toggleTreeExpansion: function toggleTreeExpansion(row) {
- _tools.UtilTools.warn('vxe.error.delFunc', ['toggleTreeExpansion', 'toggleTreeExpand']);
- return this.toggleTreeExpand(row);
- },
- /**
- * 切换/展开树节点
- */
- toggleTreeExpand: function toggleTreeExpand(row) {
- return this.setTreeExpand(row, !this.isTreeExpandByRow(row));
- },
- /**
- * 处理默认展开树节点
- */
- handleDefaultTreeExpand: function handleDefaultTreeExpand() {
- var treeConfig = this.treeConfig,
- treeOpts = this.treeOpts,
- tableFullData = this.tableFullData;
- if (treeConfig) {
- var expandAll = treeOpts.expandAll,
- expandRowKeys = treeOpts.expandRowKeys;
- if (expandAll) {
- this.setAllTreeExpand(true);
- } else if (expandRowKeys) {
- var defExpandeds = [];
- var rowkey = getRowkey(this);
- expandRowKeys.forEach(function (rowid) {
- var matchObj = _ctor.default.findTree(tableFullData, function (item) {
- return rowid === _ctor.default.get(item, rowkey);
- }, treeOpts);
- if (matchObj) {
- defExpandeds.push(matchObj.item);
- }
- });
- this.setTreeExpand(defExpandeds, true);
- }
- }
- },
- handleAsyncTreeExpandChilds: function handleAsyncTreeExpandChilds(row) {
- var _this35 = this;
- var fullAllDataRowMap = this.fullAllDataRowMap,
- treeExpandeds = this.treeExpandeds,
- treeOpts = this.treeOpts,
- treeLazyLoadeds = this.treeLazyLoadeds,
- checkboxOpts = this.checkboxOpts;
- var loadMethod = treeOpts.loadMethod;
- var checkStrictly = checkboxOpts.checkStrictly;
- var rest = fullAllDataRowMap.get(row);
- return new Promise(function (resolve) {
- treeLazyLoadeds.push(row);
- loadMethod({
- $table: _this35,
- row: row
- }).catch(function () {
- return [];
- }).then(function (childRecords) {
- rest.treeLoaded = true;
- _ctor.default.remove(treeLazyLoadeds, function (item) {
- return item === row;
- });
- if (!_ctor.default.isArray(childRecords)) {
- childRecords = [];
- }
- if (childRecords) {
- _this35.loadChildren(row, childRecords).then(function (childRows) {
- if (childRows.length && treeExpandeds.indexOf(row) === -1) {
- treeExpandeds.push(row);
- } // 如果当前节点已选中,则展开后子节点也被选中
- if (!checkStrictly && _this35.isCheckedByCheckboxRow(row)) {
- _this35.setCheckboxRow(childRows, true);
- }
- });
- }
- resolve(_this35.$nextTick().then(_this35.recalculate));
- });
- });
- },
- setAllTreeExpansion: function setAllTreeExpansion(expanded) {
- _tools.UtilTools.warn('vxe.error.delFunc', ['setAllTreeExpansion', 'setAllTreeExpand']);
- return this.setAllTreeExpand(expanded);
- },
- /**
- * 设置所有树节点的展开与否
- * @param {Boolean} expanded 是否展开
- */
- setAllTreeExpand: function setAllTreeExpand(expanded) {
- var tableFullData = this.tableFullData,
- treeOpts = this.treeOpts;
- var lazy = treeOpts.lazy,
- children = treeOpts.children;
- var expandeds = [];
- _ctor.default.eachTree(tableFullData, function (row) {
- var rowChildren = row[children];
- if (lazy || rowChildren && rowChildren.length) {
- expandeds.push(row);
- }
- }, treeOpts);
- return this.setTreeExpand(expandeds, expanded);
- },
- setTreeExpansion: function setTreeExpansion(rows, expanded) {
- _tools.UtilTools.warn('vxe.error.delFunc', ['setTreeExpansion', 'setTreeExpand']);
- return this.setTreeExpand(rows, expanded);
- },
- /**
- * 设置展开树形节点,二个参数设置这一行展开与否
- * 支持单行
- * 支持多行
- * @param {Array/Row} rows 行数据
- * @param {Boolean} expanded 是否展开
- */
- setTreeExpand: function setTreeExpand(rows, expanded) {
- var _this36 = this;
- var fullAllDataRowMap = this.fullAllDataRowMap,
- tableFullData = this.tableFullData,
- treeExpandeds = this.treeExpandeds,
- treeOpts = this.treeOpts,
- treeLazyLoadeds = this.treeLazyLoadeds,
- treeNodeColumn = this.treeNodeColumn;
- var reserve = treeOpts.reserve,
- lazy = treeOpts.lazy,
- hasChild = treeOpts.hasChild,
- children = treeOpts.children,
- accordion = treeOpts.accordion,
- toggleMethod = treeOpts.toggleMethod;
- var result = [];
- var columnIndex = this.getColumnIndex(treeNodeColumn);
- var $columnIndex = this.getVMColumnIndex(treeNodeColumn);
- if (rows) {
- if (!_ctor.default.isArray(rows)) {
- rows = [rows];
- }
- if (rows.length) {
- var validRows = toggleMethod ? rows.filter(function (row) {
- return toggleMethod({
- expanded: expanded,
- column: treeNodeColumn,
- columnIndex: columnIndex,
- $columnIndex: $columnIndex,
- row: row
- });
- }) : rows;
- if (accordion) {
- validRows = validRows.length ? [validRows[validRows.length - 1]] : []; // 同一级只能展开一个
- var matchObj = _ctor.default.findTree(tableFullData, function (item) {
- return item === validRows[0];
- }, treeOpts);
- if (matchObj) {
- _ctor.default.remove(treeExpandeds, function (item) {
- return matchObj.items.indexOf(item) > -1;
- });
- }
- }
- if (expanded) {
- validRows.forEach(function (row) {
- if (treeExpandeds.indexOf(row) === -1) {
- var rest = fullAllDataRowMap.get(row);
- var isLoad = lazy && row[hasChild] && !rest.treeLoaded && treeLazyLoadeds.indexOf(row) === -1; // 是否使用懒加载
- if (isLoad) {
- result.push(_this36.handleAsyncTreeExpandChilds(row));
- } else {
- if (row[children] && row[children].length) {
- treeExpandeds.push(row);
- }
- }
- }
- });
- } else {
- _ctor.default.remove(treeExpandeds, function (row) {
- return validRows.indexOf(row) > -1;
- });
- }
- if (reserve) {
- validRows.forEach(function (row) {
- return _this36.handleTreeExpandReserve(row, expanded);
- });
- }
- return Promise.all(result).then(this.recalculate);
- }
- }
- return this.$nextTick();
- },
- // 在 v3.0 中废弃 hasTreeExpand
- hasTreeExpand: function hasTreeExpand(row) {
- _tools.UtilTools.warn('vxe.error.delFunc', ['hasTreeExpand', 'isTreeExpandByRow']);
- return this.isTreeExpandByRow(row);
- },
- /**
- * 判断行是否为树形节点展开状态
- * @param {Row} row 行对象
- */
- isTreeExpandByRow: function isTreeExpandByRow(row) {
- return this.treeExpandeds.indexOf(row) > -1;
- },
- /**
- * 手动清空树形节点的展开状态,数据会恢复成未展开的状态
- */
- clearTreeExpand: function clearTreeExpand() {
- var _this37 = this;
- var treeOpts = this.treeOpts,
- treeExpandeds = this.treeExpandeds,
- tableFullData = this.tableFullData;
- var reserve = treeOpts.reserve;
- var isExists = treeExpandeds.length;
- this.treeExpandeds = [];
- if (reserve) {
- _ctor.default.eachTree(tableFullData, function (row) {
- return _this37.handleTreeExpandReserve(row, false);
- }, treeOpts);
- }
- return this.$nextTick().then(function () {
- if (isExists) {
- _this37.recalculate();
- }
- });
- },
- clearTreeExpandReserve: function clearTreeExpandReserve() {
- this.treeExpandedReserveRowMap = {};
- return this.$nextTick();
- },
- handleTreeExpandReserve: function handleTreeExpandReserve(row, expanded) {
- var treeExpandedReserveRowMap = this.treeExpandedReserveRowMap,
- treeOpts = this.treeOpts;
- if (treeOpts.reserve) {
- var rowid = getRowid(this, row);
- if (expanded) {
- treeExpandedReserveRowMap[rowid] = row;
- } else if (treeExpandedReserveRowMap[rowid]) {
- delete treeExpandedReserveRowMap[rowid];
- }
- }
- },
- getVirtualScroller: function getVirtualScroller() {
- _tools.UtilTools.warn('vxe.error.delFunc', ['getVirtualScroller', 'getScroll']);
- return this.getScroll();
- },
- getTableScroll: function getTableScroll() {
- _tools.UtilTools.warn('vxe.error.delFunc', ['getTableScroll', 'getScroll']);
- return this.getScroll();
- },
- /**
- * 获取表格的滚动状态
- */
- getScroll: function getScroll() {
- var $refs = this.$refs,
- scrollXLoad = this.scrollXLoad,
- scrollYLoad = this.scrollYLoad;
- var bodyElem = $refs.tableBody.$el;
- return {
- virtualX: scrollXLoad,
- virtualY: scrollYLoad,
- scrollTop: bodyElem.scrollTop,
- scrollLeft: bodyElem.scrollLeft
- };
- },
- /**
- * 横向 X 可视渲染事件处理
- */
- triggerScrollXEvent: function triggerScrollXEvent() {
- this.loadScrollXData();
- },
- loadScrollXData: function loadScrollXData(force) {
- var $refs = this.$refs,
- visibleColumn = this.visibleColumn,
- scrollXStore = this.scrollXStore;
- var startIndex = scrollXStore.startIndex,
- renderSize = scrollXStore.renderSize,
- offsetSize = scrollXStore.offsetSize,
- visibleSize = scrollXStore.visibleSize;
- var scrollBodyElem = $refs.tableBody.$el;
- var scrollLeft = scrollBodyElem.scrollLeft;
- var toVisibleIndex = 0;
- var width = 0;
- var preload = force || false;
- var colLen = visibleColumn.length;
- for (var colIndex = 0; colIndex < colLen; colIndex++) {
- width += visibleColumn[colIndex].renderWidth;
- if (scrollLeft < width) {
- toVisibleIndex = colIndex;
- break;
- }
- }
- if (force || scrollXStore.visibleIndex !== toVisibleIndex) {
- var marginSize = Math.min(Math.floor((renderSize - visibleSize) / 2), visibleSize);
- if (scrollXStore.visibleIndex === toVisibleIndex) {
- scrollXStore.startIndex = toVisibleIndex;
- } else if (scrollXStore.visibleIndex > toVisibleIndex) {
- // 向左
- preload = toVisibleIndex - offsetSize <= startIndex;
- if (preload) {
- scrollXStore.startIndex = Math.max(0, Math.max(0, toVisibleIndex - marginSize));
- }
- } else {
- // 向右
- preload = toVisibleIndex + visibleSize + offsetSize >= startIndex + renderSize;
- if (preload) {
- scrollXStore.startIndex = Math.max(0, Math.min(visibleColumn.length - renderSize, toVisibleIndex - marginSize));
- }
- }
- if (preload) {
- this.updateScrollXData();
- }
- scrollXStore.visibleIndex = toVisibleIndex;
- }
- this.closeTooltip();
- },
- /**
- * 纵向 Y 可视渲染事件处理
- */
- triggerScrollYEvent: function triggerScrollYEvent(evnt) {
- var scrollYStore = this.scrollYStore;
- var adaptive = scrollYStore.adaptive,
- offsetSize = scrollYStore.offsetSize,
- visibleSize = scrollYStore.visibleSize; // webkit 浏览器使用最佳的渲染方式
- if (isWebkit && adaptive && offsetSize * 2 + visibleSize <= 80) {
- this.loadScrollYData(evnt);
- } else {
- this.debounceScrollY(evnt);
- }
- },
- debounceScrollY: _ctor.default.debounce(function (evnt) {
- this.loadScrollYData(evnt);
- }, debounceScrollYDuration, {
- leading: false,
- trailing: true
- }),
- /**
- * 纵向 Y 可视渲染处理
- */
- loadScrollYData: function loadScrollYData(evnt) {
- var afterFullData = this.afterFullData,
- scrollYStore = this.scrollYStore,
- isLoadData = this.isLoadData;
- var startIndex = scrollYStore.startIndex,
- renderSize = scrollYStore.renderSize,
- offsetSize = scrollYStore.offsetSize,
- visibleSize = scrollYStore.visibleSize,
- rowHeight = scrollYStore.rowHeight;
- var scrollBodyElem = evnt.target;
- var scrollTop = scrollBodyElem.scrollTop;
- var toVisibleIndex = Math.ceil(scrollTop / rowHeight);
- var preload = false;
- if (isLoadData || scrollYStore.visibleIndex !== toVisibleIndex) {
- var marginSize = Math.min(Math.floor((renderSize - visibleSize) / 2), visibleSize);
- if (scrollYStore.visibleIndex > toVisibleIndex) {
- // 向上
- preload = toVisibleIndex - offsetSize <= startIndex;
- if (preload) {
- scrollYStore.startIndex = Math.max(0, toVisibleIndex - Math.max(marginSize, renderSize - visibleSize));
- }
- } else {
- // 向下
- preload = toVisibleIndex + visibleSize + offsetSize >= startIndex + renderSize;
- if (preload) {
- scrollYStore.startIndex = Math.max(0, Math.min(afterFullData.length - renderSize, toVisibleIndex - marginSize));
- }
- }
- if (preload) {
- this.updateScrollYData();
- }
- scrollYStore.visibleIndex = toVisibleIndex;
- this.isLoadData = false;
- }
- },
- computeRowHeight: function computeRowHeight() {
- var tableBody = this.$refs.tableBody;
- var tableBodyElem = tableBody ? tableBody.$el : null;
- var tableHeader = this.$refs.tableHeader;
- var rowHeight;
- if (tableBodyElem) {
- var firstTrElem = tableBodyElem.querySelector('tbody>tr');
- if (!firstTrElem && tableHeader) {
- firstTrElem = tableHeader.$el.querySelector('thead>tr');
- }
- if (firstTrElem) {
- rowHeight = firstTrElem.clientHeight;
- }
- } // 默认的行高
- if (!rowHeight) {
- rowHeight = this.rowHeightMaps[this.vSize || 'default'];
- }
- this.rowHeight = rowHeight;
- },
- // 计算可视渲染相关数据
- computeScrollLoad: function computeScrollLoad() {
- var _this38 = this;
- return this.$nextTick().then(function () {
- var vSize = _this38.vSize,
- scrollXLoad = _this38.scrollXLoad,
- scrollYLoad = _this38.scrollYLoad,
- sYOpts = _this38.sYOpts,
- scrollYStore = _this38.scrollYStore,
- sXOpts = _this38.sXOpts,
- scrollXStore = _this38.scrollXStore,
- visibleColumn = _this38.visibleColumn,
- rowHeightMaps = _this38.rowHeightMaps;
- var tableBody = _this38.$refs.tableBody;
- var tableBodyElem = tableBody ? tableBody.$el : null;
- var tableHeader = _this38.$refs.tableHeader;
- if (tableBodyElem) {
- // 计算 X 逻辑
- if (scrollXLoad) {
- var bodyWidth = tableBodyElem.clientWidth;
- var visibleXSize = _ctor.default.toNumber(sXOpts.vSize);
- if (!sXOpts.vSize) {
- var len = visibleXSize = visibleColumn.length;
- var countWidth = 0;
- var column;
- for (var colIndex = 0; colIndex < len; colIndex++) {
- column = visibleColumn[colIndex];
- countWidth += column.renderWidth;
- if (countWidth > bodyWidth) {
- visibleXSize = colIndex + 1;
- break;
- }
- }
- }
- scrollXStore.visibleSize = visibleXSize; // 自动优化
- if (!sXOpts.oSize) {
- scrollXStore.offsetSize = visibleXSize;
- }
- if (!sXOpts.rSize) {
- scrollXStore.renderSize = Math.max(8, visibleXSize + 6);
- }
- _this38.updateScrollXData();
- } else {
- _this38.updateScrollXSpace();
- } // 计算 Y 逻辑
- if (scrollYLoad) {
- var rHeight;
- if (sYOpts.rHeight) {
- rHeight = sYOpts.rHeight;
- } else {
- var firstTrElem = tableBodyElem.querySelector('tbody>tr');
- if (!firstTrElem && tableHeader) {
- firstTrElem = tableHeader.$el.querySelector('thead>tr');
- }
- if (firstTrElem) {
- rHeight = firstTrElem.clientHeight;
- }
- } // 默认的行高
- if (!rHeight) {
- rHeight = rowHeightMaps[vSize || 'default'];
- }
- var visibleYSize = _ctor.default.toNumber(sYOpts.vSize || Math.ceil(tableBodyElem.clientHeight / rHeight));
- scrollYStore.visibleSize = visibleYSize;
- scrollYStore.rowHeight = rHeight; // 自动优化
- if (!sYOpts.oSize) {
- scrollYStore.offsetSize = visibleYSize;
- }
- if (!sYOpts.rSize) {
- scrollYStore.renderSize = Math.max(6, browse.edge ? visibleYSize * 10 : isWebkit ? visibleYSize + 2 : visibleYSize * 6);
- }
- _this38.updateScrollYData();
- } else {
- _this38.updateScrollYSpace();
- }
- }
- _this38.$nextTick(_this38.updateStyle);
- });
- },
- updateScrollXData: function updateScrollXData() {
- var visibleColumn = this.visibleColumn,
- scrollXStore = this.scrollXStore;
- this.tableColumn = visibleColumn.slice(scrollXStore.startIndex, scrollXStore.startIndex + scrollXStore.renderSize);
- this.updateScrollXSpace();
- },
- // 更新横向 X 可视渲染上下剩余空间大小
- updateScrollXSpace: function updateScrollXSpace() {
- var $refs = this.$refs,
- elemStore = this.elemStore,
- visibleColumn = this.visibleColumn,
- scrollXStore = this.scrollXStore,
- scrollXLoad = this.scrollXLoad,
- tableWidth = this.tableWidth,
- scrollbarWidth = this.scrollbarWidth;
- var tableHeader = $refs.tableHeader,
- tableBody = $refs.tableBody,
- tableFooter = $refs.tableFooter;
- var headerElem = tableHeader ? tableHeader.$el.querySelector('.vxe-table--header') : null;
- var bodyElem = tableBody.$el.querySelector('.vxe-table--body');
- var footerElem = tableFooter ? tableFooter.$el.querySelector('.vxe-table--footer') : null;
- var leftSpaceWidth = visibleColumn.slice(0, scrollXStore.startIndex).reduce(function (previous, column) {
- return previous + column.renderWidth;
- }, 0);
- var marginLeft = '';
- if (scrollXLoad) {
- marginLeft = "".concat(leftSpaceWidth, "px");
- }
- if (headerElem) {
- headerElem.style.marginLeft = marginLeft;
- }
- bodyElem.style.marginLeft = marginLeft;
- if (footerElem) {
- footerElem.style.marginLeft = marginLeft;
- }
- var containerList = ['main'];
- containerList.forEach(function (name) {
- var layoutList = ['header', 'body', 'footer'];
- layoutList.forEach(function (layout) {
- var xSpaceElem = elemStore["".concat(name, "-").concat(layout, "-xSpace")];
- if (xSpaceElem) {
- xSpaceElem.style.width = scrollXLoad ? "".concat(tableWidth + (layout === 'header' ? scrollbarWidth : 0), "px") : '';
- }
- });
- });
- this.$nextTick(this.updateStyle);
- },
- updateScrollYData: function updateScrollYData() {
- this.handleTableData();
- this.updateScrollYSpace();
- },
- // 更新纵向 Y 可视渲染上下剩余空间大小
- updateScrollYSpace: function updateScrollYSpace() {
- var elemStore = this.elemStore,
- scrollYStore = this.scrollYStore,
- scrollYLoad = this.scrollYLoad,
- afterFullData = this.afterFullData;
- var bodyHeight = afterFullData.length * scrollYStore.rowHeight;
- var topSpaceHeight = Math.max(scrollYStore.startIndex * scrollYStore.rowHeight, 0);
- var containerList = ['main', 'left', 'right'];
- var marginTop = '';
- var ySpaceHeight = '';
- if (scrollYLoad) {
- marginTop = "".concat(topSpaceHeight, "px");
- ySpaceHeight = "".concat(bodyHeight, "px");
- }
- containerList.forEach(function (name) {
- var layoutList = ['header', 'body', 'footer'];
- var tableElem = elemStore["".concat(name, "-body-table")];
- if (tableElem) {
- tableElem.style.marginTop = marginTop;
- }
- layoutList.forEach(function (layout) {
- var ySpaceElem = elemStore["".concat(name, "-").concat(layout, "-ySpace")];
- if (ySpaceElem) {
- ySpaceElem.style.height = ySpaceHeight;
- }
- });
- });
- this.$nextTick(this.updateStyle);
- },
- /**
- * 如果有滚动条,则滚动到对应的位置
- * @param {Number} scrollLeft 左距离
- * @param {Number} scrollTop 上距离
- */
- scrollTo: function scrollTo(scrollLeft, scrollTop) {
- var _this39 = this;
- var $refs = this.$refs;
- var tableBody = $refs.tableBody,
- rightBody = $refs.rightBody,
- tableFooter = $refs.tableFooter;
- var tableBodyElem = tableBody ? tableBody.$el : null;
- var rightBodyElem = rightBody ? rightBody.$el : null;
- var bodyTargetElem = rightBodyElem || tableBodyElem;
- var tableFooterElem = tableFooter ? tableFooter.$el : null;
- var footerTargetElem = tableFooterElem || tableBodyElem;
- if (_ctor.default.isNumber(scrollLeft)) {
- footerTargetElem.scrollLeft = scrollLeft;
- }
- if (_ctor.default.isNumber(scrollTop)) {
- bodyTargetElem.scrollTop = scrollTop;
- }
- if (this.scrollXLoad || this.scrollYLoad) {
- return new Promise(function (resolve) {
- return setTimeout(function () {
- return resolve(_this39.$nextTick());
- }, 50);
- });
- }
- return this.$nextTick();
- },
- /**
- * 如果有滚动条,则滚动到对应的行
- * @param {Row} row 行对象
- * @param {ColumnInfo} column 列配置
- */
- scrollToRow: function scrollToRow(row, column) {
- var rest = [];
- if (row) {
- if (this.treeConfig) {
- rest.push(this.scrollToTreeRow(row));
- } else {
- rest.push(_tools.DomTools.rowToVisible(this, row));
- }
- }
- if (column) {
- rest.push(this.scrollToColumn(column));
- }
- return Promise.all(rest);
- },
- /**
- * 如果有滚动条,则滚动到对应的列
- * @param {ColumnInfo} column 列配置
- */
- scrollToColumn: function scrollToColumn(column) {
- if (column && this.fullColumnMap.has(column)) {
- return _tools.DomTools.colToVisible(this, column);
- }
- return this.$nextTick();
- },
- /**
- * 对于树形结构中,可以直接滚动到指定深层节点中
- * 对于某些特定的场景可能会用到,比如定位到某一节点
- * @param {Row} row 行对象
- */
- scrollToTreeRow: function scrollToTreeRow(row) {
- var _this40 = this;
- var tableFullData = this.tableFullData,
- treeConfig = this.treeConfig,
- treeOpts = this.treeOpts;
- var rests = [];
- if (treeConfig) {
- var matchObj = _ctor.default.findTree(tableFullData, function (item) {
- return item === row;
- }, treeOpts);
- if (matchObj) {
- var nodes = matchObj.nodes;
- nodes.forEach(function (row, index) {
- if (index < nodes.length - 1 && !_this40.isTreeExpandByRow(row)) {
- rests.push(_this40.setTreeExpand(row, true));
- }
- });
- }
- }
- return Promise.all(rests).then(function () {
- return _tools.DomTools.rowToVisible(_this40, row);
- });
- },
- /**
- * 手动清除滚动相关信息,还原到初始状态
- */
- clearScroll: function clearScroll() {
- var $refs = this.$refs;
- var tableBody = $refs.tableBody,
- rightBody = $refs.rightBody,
- tableFooter = $refs.tableFooter;
- var tableBodyElem = tableBody ? tableBody.$el : null;
- var rightBodyElem = rightBody ? rightBody.$el : null;
- var tableFooterElem = tableFooter ? tableFooter.$el : null;
- if (rightBodyElem) {
- rightBodyElem.scrollTop = 0;
- }
- if (tableFooterElem) {
- tableFooterElem.scrollLeft = 0;
- }
- if (tableBodyElem) {
- tableBodyElem.scrollTop = 0;
- tableBodyElem.scrollLeft = 0;
- }
- return this.$nextTick();
- },
- /**
- * 更新表尾合计
- */
- updateFooter: function updateFooter() {
- var showFooter = this.showFooter,
- visibleColumn = this.visibleColumn,
- footerMethod = this.footerMethod;
- if (showFooter && footerMethod) {
- this.footerTableData = visibleColumn.length ? footerMethod({
- columns: visibleColumn,
- data: this.afterFullData,
- $table: this,
- $grid: this.$xegrid
- }) : [];
- }
- return this.$nextTick();
- },
- /**
- * 更新列状态
- * 如果组件值 v-model 发生 change 时,调用改函数用于更新某一列编辑状态
- * 如果单元格配置了校验规则,则会进行校验
- */
- updateStatus: function updateStatus(scope, cellValue) {
- var _this41 = this;
- var customVal = !_ctor.default.isUndefined(cellValue);
- return this.$nextTick().then(function () {
- var $refs = _this41.$refs,
- editRules = _this41.editRules,
- validStore = _this41.validStore;
- if (scope && $refs.tableBody && editRules) {
- var row = scope.row,
- column = scope.column;
- var type = 'change';
- if (_this41.hasCellRules(type, row, column)) {
- var cell = _this41.getCell(row, column);
- if (cell) {
- return _this41.validCellRules(type, row, column, cellValue).then(function () {
- if (customVal && validStore.visible) {
- setCellValue(row, column, cellValue);
- }
- _this41.clearValidate();
- }).catch(function (_ref6) {
- var rule = _ref6.rule;
- if (customVal) {
- setCellValue(row, column, cellValue);
- }
- _this41.showValidTooltip({
- rule: rule,
- row: row,
- column: column,
- cell: cell
- });
- });
- }
- }
- }
- });
- },
- handleDefaultMergeCells: function handleDefaultMergeCells() {
- this.setMergeCells(this.mergeCells);
- },
- /**
- * 设置合并单元格
- * @param {MergeOptions[]} merges { row: Row|number, column: ColumnInfo|number, rowspan: number, colspan: number }
- */
- setMergeCells: function setMergeCells(merges) {
- var _this42 = this;
- if (this.spanMethod) {
- _tools.UtilTools.error('vxe.error.errConflicts', ['merge-cells', 'span-method']);
- }
- setMerges(this, merges, this.mergeList, this.afterFullData);
- return this.$nextTick().then(function () {
- return _this42.updateCellAreas();
- });
- },
- /**
- * 移除单元格合并
- * @param {MergeOptions[]} merges 多个或数组 [{row:Row|number, col:ColumnInfo|number}]
- */
- removeMergeCells: function removeMergeCells(merges) {
- var _this43 = this;
- if (this.spanMethod) {
- _tools.UtilTools.error('vxe.error.errConflicts', ['merge-cells', 'span-method']);
- }
- var rest = removeMerges(this, merges, this.mergeList, this.afterFullData);
- return this.$nextTick().then(function () {
- _this43.updateCellAreas();
- return rest;
- });
- },
- /**
- * 获取所有被合并的单元格
- */
- getMergeCells: function getMergeCells() {
- return this.mergeList.slice(0);
- },
- /**
- * 清除所有单元格合并
- */
- clearMergeCells: function clearMergeCells() {
- this.mergeList = [];
- return this.$nextTick();
- },
- handleDefaultMergeFooterItems: function handleDefaultMergeFooterItems() {
- this.setMergeFooterItems(this.mergeFooterItems);
- },
- setMergeFooterItems: function setMergeFooterItems(merges) {
- var _this44 = this;
- if (this.footerSpanMethod) {
- _tools.UtilTools.error('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method']);
- }
- setMerges(this, merges, this.mergeFooterList, null);
- return this.$nextTick().then(function () {
- return _this44.updateCellAreas();
- });
- },
- removeMergeFooterItems: function removeMergeFooterItems(merges) {
- var _this45 = this;
- if (this.footerSpanMethod) {
- _tools.UtilTools.error('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method']);
- }
- var rest = removeMerges(this, merges, this.mergeFooterList, null);
- return this.$nextTick().then(function () {
- _this45.updateCellAreas();
- return rest;
- });
- },
- /**
- * 获取所有被合并的表尾
- */
- getMergeFooterItems: function getMergeFooterItems() {
- return this.mergeFooterList.slice(0);
- },
- /**
- * 清除所有表尾合并
- */
- clearMergeFooterItems: function clearMergeFooterItems() {
- this.mergeFooterList = [];
- return this.$nextTick();
- },
- updateZindex: function updateZindex() {
- if (this.zIndex) {
- this.tZindex = this.zIndex;
- } else if (this.tZindex < _tools.UtilTools.getLastZIndex()) {
- this.tZindex = _tools.UtilTools.nextZIndex();
- }
- },
- updateCellAreas: function updateCellAreas() {
- if (this.mouseConfig && this.mouseOpts.area && this.handleUpdateCellAreas) {
- this.handleUpdateCellAreas();
- }
- },
- emitEvent: function emitEvent(type, params, evnt) {
- this.$emit(type, Object.assign({
- $table: this,
- $grid: this.$xegrid,
- $event: evnt
- }, params), evnt);
- },
- focus: function focus() {
- this.isActivated = true;
- return this.$nextTick();
- },
- blur: function blur() {
- this.isActivated = false;
- return this.$nextTick();
- },
- // 与工具栏对接
- connect: function connect($toolbar) {
- if ($toolbar && $toolbar.syncUpdate) {
- $toolbar.syncUpdate({
- collectColumn: this.collectColumn,
- $table: this
- });
- this.$toolbar = $toolbar;
- } else {
- _tools.UtilTools.error('vxe.error.barUnableLink');
- }
- return this.$nextTick();
- },
- // 检查触发源是否属于目标节点
- getEventTargetNode: getEventTargetNode,
- /*************************
- * Publish methods
- *************************/
- getCell: function getCell(row, column) {
- var $refs = this.$refs;
- var rowid = getRowid(this, row);
- var bodyElem = $refs["".concat(column.fixed || 'table', "Body")] || $refs.tableBody;
- if (bodyElem && bodyElem.$el) {
- return bodyElem.$el.querySelector(".vxe-body--row[data-rowid=\"".concat(rowid, "\"] .").concat(column.id));
- }
- return null;
- },
- getCellLabel: function getCellLabel(row, column) {
- var formatter = column.formatter;
- var cellValue = _tools.UtilTools.getCellValue(row, column);
- var cellLabel = cellValue;
- if (formatter) {
- var rest, formatData;
- var colid = column.id;
- var fullAllDataRowMap = this.fullAllDataRowMap;
- var cacheFormat = fullAllDataRowMap.has(row);
- if (cacheFormat) {
- rest = fullAllDataRowMap.get(row);
- formatData = rest.formatData;
- if (!formatData) {
- formatData = fullAllDataRowMap.get(row).formatData = {};
- }
- if (rest && formatData[colid]) {
- if (formatData[colid].value === cellValue) {
- return formatData[colid].label;
- }
- }
- }
- var formatParams = {
- cellValue: cellValue,
- row: row,
- rowIndex: this.getRowIndex(row),
- column: column,
- columnIndex: this.getColumnIndex(column)
- };
- if (_ctor.default.isString(formatter)) {
- if (_ctor.default[formatter]) {
- cellLabel = _ctor.default[formatter](cellValue);
- } else if (_formats.default.get(formatter)) {
- cellLabel = _formats.default.get(formatter)(formatParams);
- } else {
- cellLabel = '';
- }
- } else if (_ctor.default.isArray(formatter)) {
- if (_ctor.default[formatter[0]]) {
- cellLabel = _ctor.default[formatter[0]].apply(_ctor.default, [cellValue].concat(_toConsumableArray(formatter.slice(1))));
- } else if (_formats.default.get(formatter[0])) {
- cellLabel = _formats.default.get(formatter[0]).apply(void 0, [formatParams].concat(_toConsumableArray(formatter.slice(1))));
- } else {
- cellLabel = '';
- }
- } else {
- cellLabel = formatter(formatParams);
- }
- if (formatData) {
- formatData[colid] = {
- value: cellValue,
- label: cellLabel
- };
- }
- }
- return cellLabel;
- }
- /*************************
- * Publish methods
- *************************/
- }; // Module methods
- var funcs = 'setFilter,filter,clearFilter,getCheckedFilters,closeMenu,setActiveCellArea,getActiveCellArea,getCellAreas,clearCellAreas,copyCellArea,cutCellArea,pasteCellArea,getCopyCellArea,clearCopyCellArea,setCellAreas,openFind,openReplace,getMouseSelecteds,getMouseCheckeds,getSelectedCell,getSelectedRanges,clearCopyed,clearChecked,clearHeaderChecked,clearIndexChecked,clearSelected,insert,insertAt,remove,removeSelecteds,removeCheckboxRow,removeRadioRow,removeCurrentRow,getRecordset,getInsertRecords,getRemoveRecords,getUpdateRecords,clearActived,getActiveRecord,getActiveRow,hasActiveRow,isActiveByRow,setActiveRow,setActiveCell,setSelectCell,clearValidate,fullValidate,validate,exportCsv,openExport,exportData,openImport,importData,saveFile,readFile,importByFile,print'.split(',');
- funcs.forEach(function (name) {
- Methods[name] = function () {
- return this["_".concat(name)] ? this["_".concat(name)].apply(this, arguments) : null;
- };
- });
- var _default = Methods;
- exports.default = _default;
|