| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308 | 
							- 'use strict';
 
- /**
 
-  * 变更令详细页js
 
-  *
 
-  * @author EllisRan.
 
-  * @date 2018/11/22
 
-  * @version
 
-  */
 
- const ckBillsSpread = '/tender/' + window.location.pathname.split('/')[2] + '/change/' + window.location.pathname.split('/')[4] + ' ledger-Select';
 
- const ckChangeSpread = '/tender/' + window.location.pathname.split('/')[2] + '/change/' + window.location.pathname.split('/')[4] +  'change-Select';
 
- const is_numeric = (value) => {
 
-     if (typeof(value) === 'object') {
 
-         return false;
 
-     } else {
 
-         return !Number.isNaN(Number(value)) && value.toString().trim() !== '';
 
-     }
 
- };
 
- function sortByCode(a, b) {
 
-     let code1 = a.code.split('-');
 
-     let code2 = b.code.split('-');
 
-     let code1length = code1.length;
 
-     let code2length = code2.length;
 
-     for (let i = 0; i < code1length; i ++) {
 
-         if (i+1 <= code2length) {
 
-             if (code1[i] != code2[i]) {
 
-                 if (/^\d+$/.test(code1[i]) && /^\d+$/.test(code2[i])) {
 
-                     return parseInt(code1[i]) - parseInt(code2[i]);
 
-                 } else if (!/^\d+$/.test(code1[i]) && /^\d+$/.test(code2[i])) {
 
-                     return 1;
 
-                 } else if (/^\d+$/.test(code1[i]) && !/^\d+$/.test(code2[i])) {
 
-                     return -1;
 
-                 } else {
 
-                     const str1length = code1[i].length;
 
-                     const str2length = code2[i].length;
 
-                     for (let j = 0; j < str1length; j++) {
 
-                         if (j+1 <= str2length) {
 
-                             if (code1[i].charAt(j) != code2[i].charAt(j)) {
 
-                                 return code1[i].charAt(j).charCodeAt() - code2[i].charAt(j).charCodeAt();
 
-                             }  else if (j+1 == str1length && code1[i].charAt(j) == code2[i].charAt(j)) {
 
-                                 if (str1length == str2length) {
 
-                                     return 0;
 
-                                 } else {
 
-                                     return str1length - str2length;
 
-                                 }
 
-                             }
 
-                         } else {
 
-                             if (j+1 >= str1length) {
 
-                                 return 1;
 
-                             } else {
 
-                                 return -1;
 
-                             }
 
-                         }
 
-                     }
 
-                 }
 
-             } else if (i+1 == code1length && code1[i] == code2[i]) {
 
-                 if (code1length == code2length) {
 
-                     return 0;
 
-                 } else {
 
-                     return code1length - code2length;
 
-                 }
 
-             }
 
-         } else {
 
-             if (i+1 >= code1length) {
 
-                 return 1;
 
-             } else {
 
-                 return -1;
 
-             }
 
-         }
 
-     }
 
- }
 
- $.event.special.valuechange = {
 
-     teardown: function (namespaces) {
 
-         $(this).unbind('.valuechange');
 
-     },
 
-     handler: function (e) {
 
-         $.event.special.valuechange.triggerChanged($(this));
 
-     },
 
-     add: function (obj) {
 
-         $(this).on('keyup.valuechange cut.valuechange paste.valuechange input.valuechange', obj.selector, $.event.special.valuechange.handler)
 
-     },
 
-     triggerChanged: function (element) {
 
-         var current = element[0].contentEditable === 'true' ? element.html() : element.val()
 
-             , previous = typeof element.data('previous') === 'undefined' ? element[0].defaultValue : element.data('previous');
 
-         if (current !== previous) {
 
-             element.trigger('valuechange', [element.data('previous')]);
 
-             element.data('previous', current);
 
-         }
 
-     }
 
- };
 
- function getPasteHint (str, row = '') {
 
-     let returnObj = str;
 
-     if (row) {
 
-         returnObj.msg = '清单第' + (row+1) + '行' + str.msg;
 
-     }
 
-     return returnObj;
 
- }
 
- $(document).ready(() => {
 
-     //初始化所有附件列表
 
-     getAllList();
 
-     // 计算最新的变更总额和change的total_price是否一致,不一致则更新
 
-     if (changeStatus !== auditConst.status.checked) {
 
-         calcChangePrice();
 
-     }
 
-     //tab change
 
-     $('a[data-toggle="tab"]').on('shown.bs.tab', function () {
 
-         const tab = $(this).data('tab');
 
-         if (tab === 'bgfujian') {
 
-             $('#fujian_btn').show();
 
-             $('#copy_btn').hide();
 
-         } else {
 
-             $('#fujian_btn').hide();
 
-             $('#copy_btn').show();
 
-         }
 
-     });
 
-     $('#add-bj').on('click', 'input[type="checkbox"]', function () {
 
-         const isCheck = $(this).prop('checked');
 
-         if (isCheck) {
 
-             $('#add-bj input[type="checkbox"]').each(function () {
 
-                 $(this).prop('checked', false)
 
-             });
 
-             $(this).prop('checked', true)
 
-         }
 
-     });
 
-     $('#bg-copy').click(function() {
 
-         const cid = $('#add-bj input:checked').data('id');
 
-         postData(window.location.pathname + '/copy', cid, function () {
 
-             window.location.reload();
 
-         })
 
-     });
 
-     // 上传附件
 
-     $('#upload-file-btn').click(function () {
 
-         const files = $('#upload-file')[0].files;
 
-         const formData = new FormData();
 
-         formData.append('cid', $('#changeId').val());
 
-         formData.append('tid', $('#tenderId').val());
 
-         for (const file of files) {
 
-             if (file === undefined) {
 
-                 toastr.error('未选择上传文件!');
 
-                 return false;
 
-             }
 
-             const filesize = file.size;
 
-             if (filesize > 30 * 1024 * 1024) {
 
-                 toastr.error('文件大小过大!');
 
-                 return false;
 
-             }
 
-             const fileext = '.' + file.name.toLowerCase().split('.').splice(-1)[0];
 
-             if (whiteList.indexOf(fileext) === -1) {
 
-                 toastr.error('只能上传指定格式的附件!');
 
-                 return false;
 
-             }
 
-             formData.append('size', filesize);
 
-             formData.append('file[]', file);
 
-         }
 
-         // if (!(change_uid === accountId || (auditors2 && auditors2.findIndex(item => item.uid === parseInt(accountId)) !== -1) || touristPermission)) {
 
-         if (!filePermission) {
 
-             return toastr.error('暂无权限上传!');
 
-         }
 
-         postDataWithFile(window.location.pathname + '/file/upload', formData, function (data) {
 
-             attData = data.concat(attData);
 
-             // 重新生成List
 
-             getAllList();
 
-             $('#addfujian').modal('hide');
 
-             // let html = '';
 
-             // let index = $('#attList tr').length + 1;
 
-             // for (const fileInfo of data) {
 
-             //     html += '<tr> ' +
 
-             //         `<td width="20"><input type="checkbox" class="check-file" file-id=${fileInfo.id}></td>` +
 
-             //         '<td>' + index + '</td> ' +
 
-             //         `<td><a href="javascript: void(0);" class="file-atn" f-id="${fileInfo.id}">${fileInfo.filename}${fileInfo.fileext}</a></td>`+
 
-             //         '<td>' + fileInfo.in_time + '<br>' + fileInfo.filesize + '</td> ' +
 
-             //         `<td><a href="/change/download/file/${fileInfo.id}" class="mr-2" title="下载"><span class="fa fa-download text-primary"></span></a>`+
 
-             //         ( auditStatus === 4 ?
 
-             //             fileInfo.extra_upload ? `<a class="mr-2 delete-file" data-attid="${fileInfo.id}"  title="删除附件"><span class="fa fa-trash text-danger"></span></a>` : ''
 
-             //             : ` <a href="javascript:void(0);" class="mr-2 delete-file" data-attid="${fileInfo.id}"  title="删除附件"><span class="fa fa-trash text-danger"></span></a>`)+
 
-             //         `</td>`+
 
-             //         // '<td> <a class="btn btn-light btn-sm delete-file" data-attid="' + fileInfo.id + '"  title="删除附件"><span class="fa fa-trash text-danger"></span></a> </td> ' +
 
-             //         '</tr>';
 
-             //     ++index;
 
-             // }
 
-             // $('#attList').append(html);
 
-         }, function () {
 
-         });
 
-         $('#upload-file').val('');
 
-     });
 
-     // 删除附件
 
-     $('body').on('click', '.delete-file', function () {
 
-         let attid = $(this).data('attid');
 
-         let self = $(this);
 
-         const data = {id: attid};
 
-         postData(window.location.pathname + '/file/delete', data, function (result) {
 
-             // self.parents('tr').remove();
 
-             // // 重新排序
 
-             // let newsort = 1;
 
-             // $('#attList tr').each(function(){
 
-             //     $(this).children('td').eq(1).text(newsort);
 
-             //     newsort++;
 
-             // });
 
-             // 删除到attData中
 
-             const att_index = attData.findIndex(function (item) {
 
-                 return item.id === parseInt(attid);
 
-             });
 
-             attData.splice(att_index, 1);
 
-             // 重新生成List
 
-             if ($('#attList tr').length === 1) {
 
-                 getAllList(parseInt($('#currentPage').text()) - 1);
 
-             } else {
 
-                 getAllList(parseInt($('#currentPage').text()));
 
-             }
 
-         });
 
-     });
 
-     // /change/download/file/
 
-     $('#attList').on('click', '.file-atn', function() {
 
-         const id = $(this).attr('f-id');
 
-         postData(`/change/download/file/${id}`, {}, (data) => {
 
-             const { filepath } = data;
 
-             $('#file-upload').attr('href', filepath);
 
-             $('#file-upload')[0].click();
 
-         })
 
-     });
 
-     $('#attList').on('click', '.check-file', function() {
 
-         const checkedList = $('#attList').find('input:checked');
 
-         const childs = $('#attList').children().length;
 
-         const checkBox = $('#check-all-file');
 
-         if (checkedList.length === childs) {
 
-             checkBox.prop("checked", true);
 
-         } else {
 
-             checkBox.prop("checked", false);
 
-         }
 
-     });
 
-     $('#check-all-file').click(function() {
 
-         const isCheck = $(this).is(':checked');
 
-         $('#attList').children().each(function() {
 
-             $(this).find('input:checkbox').prop("checked", isCheck);
 
-         })
 
-     });
 
-     $('#bach-download').click(function() {
 
-         const fileIds = [];
 
-         $( '#attList .check-file:checked').each(function() {
 
-             const fileId = $(this).attr('file-id');
 
-             fileId && fileIds.push(fileId);
 
-         });
 
-         if (fileIds.length) {
 
-             // const tid = $('#tenderId').val();
 
-             // const cid = $('#changeId').val();
 
-             // $('#downloadZip').attr('href', `/tender/${tid}/change/${cid}/download/compresse-file?fileIds=${JSON.stringify(fileIds)}`);
 
-             // $('#downloadZip')[0].click();
 
-             if (fileIds.length > 20) {
 
-                 return toastr.warning(`最大允许20个文件(当前${fileIds.length}个)`);
 
-             }
 
-             const tid = $('#tenderId').val();
 
-             const cid = $('#changeId').val();
 
-             toastr.success('正在进行压缩文件...', '', { timeOut: 0, extendedTimeOut: 0});
 
-             $(this).attr('disabled', "true");
 
-             const btn = $(this);
 
-             const fileArr = [];
 
-             for (const id of fileIds) {
 
-                 const fileInfo = _.find(currPageFileData, { id: parseInt(id) });
 
-                 fileArr.push({
 
-                     url: fileInfo.orginpath, //文件的oss存储路径 (必填)
 
-                     name: fileInfo.filename, // 文件名 (可选, 不需要填扩展名)
 
-                     foldPath: '' // (可选, 文件在压缩包中的存储路径)
 
-                 });
 
-             }
 
-             const packageName = `${tenderName}-工程变更-${changeName}-附件.zip`;
 
-             try {
 
-                 zipOss.downloadFromAliOss(fileArr, packageName, btn);
 
-             } catch (e) {
 
-                 btn.removeAttr('disabled');
 
-                 toastr.clear();
 
-                 toastr.error('批量下载失败');
 
-             }
 
-             // postCompressFile(`/tender/${tid}/change/${cid}/download/compresse-file`, {fileIds}, function(result) {
 
-             //   toastr.clear();
 
-             //   toastr.success('压缩文件成功');
 
-             //   btn.removeAttr('disabled');
 
-             //   const href = window.URL.createObjectURL(result);
 
-             //   $('#zipDown').attr('href', href);
 
-             //   $('#zipDown').attr('download', `${tenderName}-工程变更-${changeName}-附件.zip`);
 
-             //   $("#zipDown")[0].click();
 
-             // }, () => {
 
-             //   btn.removeAttr('disabled');
 
-             //   toastr.clear();
 
-             //   toastr.error('批量下载失败');
 
-             // });
 
-         }
 
-     });
 
-     // 差值对比信息获取
 
-     let czSpread = null;
 
-     const czSpreadSetting = {
 
-         cols: [
 
-             {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 80},
 
-             {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 120},
 
-             {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60},
 
-             {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.unit_price'},
 
-             {title: '变更方案|数量', colSpan: '2|1', rowSpan: '1|1', field: 'pamount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.pamount'},
 
-             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'pa_tp', hAlign: 2, width: 80, type: 'Number', getValue: 'getValue.pa_tp'},
 
-             {title: '变更令|数量', colSpan: '2|1', rowSpan: '1|1', field: 'camount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.camount'},
 
-             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'ca_tp', hAlign: 2, width: 80, type: 'Number', getValue: 'getValue.ca_tp'},
 
-             {title: '差值对比|数量', colSpan: '2|1', rowSpan: '1|1', field: 'czamount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.czamount'},
 
-             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'cz_tp', hAlign: 2, width: 80, type: 'Number', getValue: 'getValue.cz_tp'},
 
-         ],
 
-         emptyRows: 0,
 
-         headRows: 2,
 
-         headRowHeight: [25, 25],
 
-         defaultRowHeight: 21,
 
-         headerFont: '12px 微软雅黑',
 
-         font: '12px 微软雅黑',
 
-         readOnly: true,
 
-         localCache: {
 
-             key: 'changes-cz',
 
-             colWidth: true,
 
-         }
 
-     };
 
-     const czCol = {
 
-         getValue: {
 
-             unit_price: function(data) {
 
-                 return ZhCalc.round(data.unit_price, unitPriceUnit);
 
-             },
 
-             pa_tp: function (data) {
 
-                 return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.pamount, findDecimal(data.unit))), totalPriceUnit);
 
-             },
 
-             ca_tp: function (data) {
 
-                 return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.camount, findDecimal(data.unit))), totalPriceUnit);
 
-             },
 
-             pamount: function (data) {
 
-                 return ZhCalc.round(data.pamount, findDecimal(data.unit));
 
-             },
 
-             camount: function (data) {
 
-                 return ZhCalc.round(data.camount, findDecimal(data.unit));
 
-             },
 
-             czamount: function (data) {
 
-                 return ZhCalc.sub(ZhCalc.round(data.camount, findDecimal(data.unit)), ZhCalc.round(data.pamount, findDecimal(data.unit)));
 
-             },
 
-             cz_tp: function (data) {
 
-                 return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(ZhCalc.sub(ZhCalc.round(data.camount, findDecimal(data.unit)), ZhCalc.round(data.pamount, findDecimal(data.unit))), findDecimal(data.unit))), totalPriceUnit);
 
-             },
 
-         }
 
-     };
 
-     const czSpreadObj = {
 
-         makeBackColor: function () {
 
-             const rowCount = czSpread.getActiveSheet().getRowCount();
 
-             for (let i = 0; i < rowCount; i++) {
 
-                 if (czSpread.getActiveSheet().zh_data[i].color) czSpread.getActiveSheet().getRange(i, -1, 1, -1).backColor('#f5c6cb');
 
-             }
 
-         },
 
-         makeSjsFooter: function () {
 
-             // 增加汇总行并设为锁定禁止编辑状态
 
-             czSpread.getActiveSheet().addRows(czSpread.getActiveSheet().getRowCount(), 1);
 
-             czSpread.getActiveSheet().setValue(czSpread.getActiveSheet().getRowCount() - 1, 0, '合计');
 
-             czSpread.getActiveSheet().setStyle(czSpread.getActiveSheet().getRowCount() - 1, -1, style1);
 
-             czSpreadObj.countSum();
 
-         },
 
-         countSum: function () {
 
-             const rowCount = czSpread.getActiveSheet().getRowCount();
 
-             let pSum = 0,
 
-                 cSum = 0,
 
-                 czSum = 0;
 
-             for (let i = 0; i < rowCount - 1; i++) {
 
-                 pSum = ZhCalc.add(pSum, czSpread.getActiveSheet().getValue(i, 5));
 
-                 cSum = ZhCalc.add(cSum, czSpread.getActiveSheet().getValue(i, 7));
 
-                 czSum = ZhCalc.add(czSum, czSpread.getActiveSheet().getValue(i, 9));
 
-             }
 
-             czSpread.getActiveSheet().setValue(czSpread.getActiveSheet().getRowCount() - 1, 5, pSum !== 0 ? pSum : null);
 
-             czSpread.getActiveSheet().setValue(czSpread.getActiveSheet().getRowCount() - 1, 7, cSum !== 0 ? cSum : null);
 
-             czSpread.getActiveSheet().setValue(czSpread.getActiveSheet().getRowCount() - 1, 9, czSum !== 0 ? czSum : null);
 
-         },
 
-     };
 
-     $('#bgfadb').on('shown.bs.modal', function () {
 
-         if (!czSpread) {
 
-             czSpread = SpreadJsObj.createNewSpread($('#cz-spread')[0]);
 
-             SpreadJsObj.initSpreadSettingEvents(czSpreadSetting, czCol);
 
-             SpreadJsObj.initSheet(czSpread.getActiveSheet(), czSpreadSetting);
 
-         }
 
-         const cList = [];
 
-         const newChangeList = _.cloneDeep(changeList);
 
-         for (const cl of newChangeList) {
 
-             const cIndex = _.findIndex(cList, { code: cl.code, name: cl.name, unit: cl.unit, unit_price: cl.unit_price});
 
-             if (cIndex !== -1) {
 
-                 cList[cIndex].spamount = ZhCalc.add(cList[cIndex].spamount, cl.spamount);
 
-             } else {
 
-                 cList.push(cl);
 
-             }
 
-         }
 
-         // 生成差值对比数据列表
 
-         const czList = [];
 
-         const newPlanList = _.cloneDeep(planList);
 
-         for (const c of cList) {
 
-             const planInfo = _.find(newPlanList, { code: c.code, name: c.name, unit: c.unit, unit_price: c.unit_price });
 
-             const pamount = planInfo ? planInfo.spamount : null;
 
-             let color = true;
 
-             if (planInfo) {
 
-                 _.remove(newPlanList, (item) => item === planInfo);
 
-                 if ((pamount ? pamount : 0) === (c.spamount ? c.spamount : 0)) {
 
-                     color = false;
 
-                 }
 
-             }
 
-             czList.push({ code: c.code, name: c.name, unit: c.unit, unit_price: c.unit_price, camount: c.spamount, pamount, color });
 
-         }
 
-         if (newPlanList.length > 0) {
 
-             for (const np of newPlanList) {
 
-                 czList.push({ code: np.code, name: np.name, unit: np.unit, unit_price: np.unit_price, camount: null, pamount: np.spamount, color: true });
 
-             }
 
-         }
 
-         if (czList.length > 0) {
 
-             // 按清单编号排序
 
-             czList.sort(sortByCode);
 
-         }
 
-         console.log(czList);
 
-         // sjs设置
 
-         SpreadJsObj.loadSheetData(czSpread.getActiveSheet(), SpreadJsObj.DataType.Data, czList);
 
-         czSpreadObj.makeBackColor();
 
-         czSpreadObj.makeSjsFooter();
 
-     });
 
-     // 清单汇总信息获取
 
-     let hzSpread = null;
 
-     const hzSpreadSetting = {
 
-         cols: [
 
-             {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 80},
 
-             {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 120},
 
-             {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60},
 
-             {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.unit_price'},
 
-             {title: '申报变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'camount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.camount'},
 
-             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'ca_tp', hAlign: 2, width: 80, type: 'Number', getValue: 'getValue.ca_tp'},
 
-             {title: '审批变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'amount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.amount', visible: readOnly && !shenpiPower},
 
-             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'a_tp', hAlign: 2, width: 80, type: 'Number', getValue: 'getValue.a_tp', visible: readOnly && !shenpiPower},
 
-             {title: '审批变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'spamount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.spamount', visible: readOnly && shenpiPower},
 
-             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'spa_tp', hAlign: 2, width: 80, type: 'Number', getValue: 'getValue.spa_tp', visible: readOnly && shenpiPower},
 
-             {title: '审批变更|数量', colSpan: '2|1', rowSpan: '1|1', hAlign: 2, width: 60, type: 'Number', getValue: '', visible: !readOnly},
 
-             {title: '|金额', colSpan: '|1', rowSpan: '|1', hAlign: 2, width: 80, type: 'Number', getValue: '', visible: !readOnly},
 
-         ],
 
-         emptyRows: 0,
 
-         headRows: 2,
 
-         headRowHeight: [25, 25],
 
-         defaultRowHeight: 21,
 
-         headerFont: '12px 微软雅黑',
 
-         font: '12px 微软雅黑',
 
-         readOnly: true,
 
-         localCache: {
 
-             key: 'changes-hz',
 
-             colWidth: true,
 
-         }
 
-     };
 
-     const hzCol = {
 
-         getValue: {
 
-             unit_price: function(data) {
 
-                 return ZhCalc.round(data.unit_price, unitPriceUnit);
 
-             },
 
-             camount: function (data) {
 
-                 return ZhCalc.round(data.camount, findDecimal(data.unit));
 
-             },
 
-             ca_tp: function (data) {
 
-                 return ZhCalc.round(data.ca_tp, totalPriceUnit);
 
-             },
 
-             amount: function (data) {
 
-                 return ZhCalc.round(data.amount, findDecimal(data.unit));
 
-             },
 
-             a_tp: function (data) {
 
-                 return ZhCalc.round(data.a_tp, totalPriceUnit);
 
-             },
 
-             spamount: function (data) {
 
-                 return ZhCalc.round(data.spamount, findDecimal(data.unit));
 
-             },
 
-             spa_tp: function (data) {
 
-                 return ZhCalc.round(data.spa_tp, totalPriceUnit);
 
-             },
 
-         }
 
-     };
 
-     const hzSpreadObj = {
 
-         makeBackColor: function () {
 
-             const rowCount = hzSpread.getActiveSheet().getRowCount();
 
-             for (let i = 0; i < rowCount; i++) {
 
-                 if (readOnly && shenpiPower && hzSpread.getActiveSheet().zh_data[i].camount != hzSpread.getActiveSheet().zh_data[i].spamount) {
 
-                     hzSpread.getActiveSheet().getRange(i, -1, 1, -1).backColor('#ffeeba');
 
-                 } else if (readOnly && !shenpiPower && hzSpread.getActiveSheet().zh_data[i].camount != hzSpread.getActiveSheet().zh_data[i].amount) {
 
-                     hzSpread.getActiveSheet().getRange(i, -1, 1, -1).backColor('#ffeeba');
 
-                 } else if (!readOnly && !(hzSpread.getActiveSheet().zh_data[i].camount === '' || hzSpread.getActiveSheet().zh_data[i].camount === 0 || hzSpread.getActiveSheet().zh_data[i].camount === null)) {
 
-                     hzSpread.getActiveSheet().getRange(i, -1, 1, -1).backColor('#ffeeba');
 
-                 }
 
-             }
 
-         },
 
-         makeSjsFooter: function () {
 
-             // 增加汇总行并设为锁定禁止编辑状态
 
-             hzSpread.getActiveSheet().addRows(hzSpread.getActiveSheet().getRowCount(), 1);
 
-             hzSpread.getActiveSheet().setValue(hzSpread.getActiveSheet().getRowCount() - 1, 0, '合计');
 
-             hzSpread.getActiveSheet().setStyle(hzSpread.getActiveSheet().getRowCount() - 1, -1, style1);
 
-             hzSpreadObj.countSum();
 
-         },
 
-         countSum: function () {
 
-             const rowCount = hzSpread.getActiveSheet().getRowCount();
 
-             let cSum = 0,
 
-                 sSum = 0,
 
-                 spSum = 0;
 
-             for (let i = 0; i < rowCount - 1; i++) {
 
-                 cSum = ZhCalc.add(cSum, hzSpread.getActiveSheet().getValue(i, 5));
 
-                 sSum = ZhCalc.add(sSum, hzSpread.getActiveSheet().getValue(i, 7));
 
-                 spSum = ZhCalc.add(spSum, hzSpread.getActiveSheet().getValue(i, 9));
 
-             }
 
-             hzSpread.getActiveSheet().setValue(hzSpread.getActiveSheet().getRowCount() - 1, 5, cSum !== 0 ? cSum : null);
 
-             hzSpread.getActiveSheet().setValue(hzSpread.getActiveSheet().getRowCount() - 1, 7, sSum !== 0 ? sSum : null);
 
-             hzSpread.getActiveSheet().setValue(hzSpread.getActiveSheet().getRowCount() - 1, 9, spSum !== 0 ? spSum : null);
 
-         },
 
-     };
 
-     $('#qdgather').on('shown.bs.modal', function () {
 
-         if (!hzSpread) {
 
-             hzSpread = SpreadJsObj.createNewSpread($('#hz-spread')[0]);
 
-             SpreadJsObj.initSpreadSettingEvents(hzSpreadSetting, hzCol);
 
-             SpreadJsObj.initSheet(hzSpread.getActiveSheet(), hzSpreadSetting);
 
-         }
 
-         const hzList = [];
 
-         const newChangeList = _.cloneDeep(changeList);
 
-         for (const cl of newChangeList) {
 
-             const hzIndex = _.findIndex(hzList, { code: cl.code, name: cl.name, unit: cl.unit, unit_price: cl.unit_price});
 
-             const audit_amount = cl.audit_amount ? cl.audit_amount.split(',') : '';
 
-             const amount = audit_amount ? parseFloat(audit_amount[audit_amount.length - 1]) : 0;
 
-             cl.ca_tp = ZhCalc.round(ZhCalc.mul(ZhCalc.round(cl.unit_price, unitPriceUnit), ZhCalc.round(cl.camount, findDecimal(cl.unit))), totalPriceUnit);
 
-             cl.spa_tp = ZhCalc.round(ZhCalc.mul(ZhCalc.round(cl.unit_price, unitPriceUnit), ZhCalc.round(cl.spamount, findDecimal(cl.unit))), totalPriceUnit);
 
-             cl.amount = amount;
 
-             cl.a_tp = ZhCalc.round(ZhCalc.mul(ZhCalc.round(cl.unit_price, unitPriceUnit), ZhCalc.round(cl.amount, findDecimal(cl.unit))), totalPriceUnit);
 
-             if (hzIndex !== -1) {
 
-                 hzList[hzIndex].camount = ZhCalc.add(hzList[hzIndex].camount, cl.camount);
 
-                 hzList[hzIndex].ca_tp = ZhCalc.add(hzList[hzIndex].ca_tp, cl.ca_tp);
 
-                 hzList[hzIndex].spamount = ZhCalc.add(hzList[hzIndex].spamount, cl.spamount);
 
-                 hzList[hzIndex].spa_tp = ZhCalc.add(hzList[hzIndex].spa_tp, cl.spa_tp);
 
-                 hzList[hzIndex].amount = ZhCalc.add(hzList[hzIndex].amount, amount);
 
-                 hzList[hzIndex].a_tp = ZhCalc.add(hzList[hzIndex].a_tp, cl.a_tp);
 
-             } else {
 
-                 hzList.push(cl);
 
-             }
 
-         }
 
-         if (hzList.length > 0) {
 
-             // 按清单编号排序
 
-             hzList.sort(sortByCode);
 
-         }
 
-         console.log(hzList);
 
-         // // sjs设置
 
-         SpreadJsObj.loadSheetData(hzSpread.getActiveSheet(), SpreadJsObj.DataType.Data, hzList);
 
-         hzSpreadObj.makeBackColor();
 
-         hzSpreadObj.makeSjsFooter();
 
-     });
 
-     // 切换页数
 
-     $('.page-select').on('click', function () {
 
-         const totalPageNum = parseInt($('#totalPage').text());
 
-         const lastPageNum = parseInt($('#currentPage').text());
 
-         const status = $(this).attr('content');
 
-         if (status === 'pre' && lastPageNum > 1) {
 
-             getAllList(lastPageNum-1);
 
-             $('#showAttachment').hide();
 
-             $('#syfujian .check-all-file').prop('checked', false)
 
-         } else if (status === 'next' && lastPageNum < totalPageNum) {
 
-             getAllList(lastPageNum+1);
 
-             $('#showAttachment').hide();
 
-             $('#syfujian .check-all-file').prop('checked', false)
 
-         }
 
-     });
 
-     // 数字只判断几个值(unit_price, oamount)
 
-     const numField = ['unit_price', 'oamount2'];
 
-     const changeSpreadSetting = {
 
-         cols: [
 
-             {title: '计价', colSpan: '1', rowSpan: '2', field: 'is_valuation', hAlign: 1, width: 50, cellType: 'checkbox', readOnly: 'readOnly.isValuation'},
 
-             {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 80, formatter: '@', readOnly: 'readOnly.isEdit'},
 
-             {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 120, formatter: '@', readOnly: 'readOnly.isEdit'},
 
-             {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', readOnly: 'readOnly.isEdit', cellType: 'unit', comboItems: changeUnits, comboEdit: true},
 
-             {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isEdit', getValue: 'getValue.unit_price'},
 
-             {title: '变更部位', colSpan: '1', rowSpan: '2', field: 'bwmx', hAlign: 0, width: 120, formatter: '@', readOnly: 'readOnly.isEdit'},
 
-             {title: '变更详情', colSpan: '1', rowSpan: '2', field: 'detail', hAlign: 0, width: 120, formatter: '@', readOnly: 'readOnly.isSettle2'},
 
-             {title: '计量上限(%)', colSpan: '1', rowSpan: '2', field: 'delimit', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isSettle2', visible: openChangeState},
 
-             {title: '原设计|数量', colSpan: '2|1', rowSpan: '1|1', field: 'oamount2', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isSettle', getValue: 'getValue.oamount2'},
 
-             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'oa_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.oa_tp'},
 
-             {title: '申请变更增(+)减(-)|数量', colSpan: '2|1', rowSpan: '1|1', field: 'camount', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isSettle2', getValue: 'getValue.camount'},
 
-             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'ca_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.ca_tp'},
 
-             // {title: '变更后|数量', colSpan: '2|1', rowSpan: '1|1', field: 'samount', hAlign: 2, width: 60, type: 'Number', readOnly: true, getValue: 'getValue.changed_amount'},
 
-             // {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'sa_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.changed_tp'},
 
-             // {title: '操作', colSpan: '1', rowSpan: '2', field: 'del_list', hAlign: 1, width: 40, readOnly: true, cellType: 'mouseTouch', getValue: 'getValue.del_list'},
 
-         ],
 
-         emptyRows: 0,
 
-         headRows: 2,
 
-         headRowHeight: [25, 25],
 
-         defaultRowHeight: 21,
 
-         headerFont: '12px 微软雅黑',
 
-         font: '12px 微软雅黑',
 
-         rowHeader:[
 
-             {
 
-                 rowHeaderType: 'circle',
 
-                 setting: {
 
-                     size: 5,
 
-                     indent: 16,
 
-                     getColor: function (index, data) {
 
-                         if (!data) return;
 
-                         if (data.ccid && data.ccid === 1) {
 
-                             return '#dc3545';
 
-                         }
 
-                         if (data.id && data.lid != 0 && !data.children) {
 
-                             return '#ffc107';
 
-                         }
 
-                         if(data.lid != 0) return;
 
-                         return '#007bff';
 
-                     }
 
-                 },
 
-             },
 
-         ],
 
-         localCache: {
 
-             key: 'changes-spread',
 
-             colWidth: true,
 
-         }
 
-     };
 
-     if (readOnly) {
 
-         changeSpreadSetting.cols.push({title: '批复变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'samount', hAlign: 2, width: 60, type: 'Number', readOnly: true, getValue: 'getValue.samount'});
 
-         changeSpreadSetting.cols.push({title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'sa_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.sa_tp'});
 
-         for (const aid of aidList) {
 
-             // const userinfo = _.find(auditList2, { 'uid': aid });
 
-             const audit = _.find(auditors2, function(item){
 
-                 return _.findIndex(item, { audit_order: aid }) !== -1;
 
-             });
 
-             const newColcount = {
 
-                 title: (audit && audit.length > 1 ? (aid + '审') : audit[0].name) + ' 审批|数量',
 
-                 colSpan: '2|1', rowSpan: '1|1',
 
-                 field: 'audit_amount_' + aid,
 
-                 hAlign: 2, width: 60, type: 'Number', readOnly: _.findIndex(audit, { uid: parseInt(accountId) }) === -1 ? true : 'readOnly.isSettle',
 
-             };
 
-             const newColTp = {
 
-                 title: '|金额',
 
-                 colSpan: '|1', rowSpan: '|1',
 
-                 field: 'sa_tp_' + aid,
 
-                 hAlign: 2, width: 80, type: 'Number',
 
-             };
 
-             changeSpreadSetting.cols.push(newColcount);
 
-             changeSpreadSetting.cols.push(newColTp);
 
-         }
 
-     }
 
-     changeSpreadSetting.cols.push({title: '变更后|数量', colSpan: '2|1', rowSpan: '1|1', field: 'changed_amount', hAlign: 2, width: 60, type: 'Number', readOnly: true, getValue: 'getValue.changed_amount'});
 
-     changeSpreadSetting.cols.push({title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'changed_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.changed_tp'});
 
-     // if (!readOnly) {
 
-     //     changeSpreadSetting.cols.push({title: '操作', colSpan: '1', rowSpan: '2', field: 'del_list', hAlign: 1, width: 40, readOnly: true, cellType: 'mouseTouch', getValue: 'getValue.del_list'});
 
-     // }
 
-     changeSpreadSetting.getColor = function (sheet, data, row, col, defaultColor) {
 
-         return checkIsSettle(data) ? spreadColor.stage.settle : defaultColor;
 
-     }
 
-     const changeCol = {
 
-         getValue: {
 
-             unit_price: function(data) {
 
-                 return ZhCalc.round(data.unit_price, unitPriceUnit);
 
-             },
 
-             oa_tp: function (data) {
 
-                 return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.oamount2, findDecimal(data.unit))), totalPriceUnit);
 
-             },
 
-             ca_tp: function (data) {
 
-                 return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.camount, findDecimal(data.unit))), totalPriceUnit);
 
-             },
 
-             oamount2: function (data) {
 
-                 return ZhCalc.round(data.oamount2, findDecimal(data.unit));
 
-             },
 
-             camount: function (data) {
 
-                 return ZhCalc.round(data.camount, findDecimal(data.unit));
 
-             },
 
-             changed_amount: function (data) {
 
-                 return ZhCalc.round(ZhCalc.add(data.oamount2, data.camount), findDecimal(data.unit));
 
-             },
 
-             changed_tp: function (data) {
 
-                 return ZhCalc.add(ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.oamount2, findDecimal(data.unit))), totalPriceUnit),
 
-                     ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.camount, findDecimal(data.unit))), totalPriceUnit));
 
-             },
 
-             // del_list: function (data) {
 
-             //     return !_.find(changeUsedData, { cbid: data.id }) && !checkIsSettle(data) ? '移除' : '';
 
-             // }
 
-         },
 
-         readOnly: {
 
-             isValuation: function (data) {
 
-                 return !(!readOnly && ((data.id && _.findIndex(changeUsedData, { cbid: data.id }) !== -1) || (data.children && data.children.length === 1 && _.findIndex(changeUsedData, { cbid: data.children[0].id }) !== -1)));
 
-             },
 
-             isEdit: function (data) {
 
-                 return !(!readOnly && data.lid == 0 && data.id && !checkIsSettle(data));
 
-             },
 
-             isSettle: function (data) {
 
-                 return !((!readOnly || shenpiPower) && ((data.id && !checkIsSettle(data)) || (data.children && data.children.length === 1 && !checkIsSettle(data.children[0]))));
 
-             },
 
-             isSettle2: function (data) {
 
-                 return !(!readOnly && ((data.id && !checkIsSettle(data)) || (data.children && data.children.length === 1 && !checkIsSettle(data.children[0]))));
 
-             }
 
-         },
 
-     };
 
-     const changeSpreadObj = {
 
-         makeSjsFooter: function () {
 
-             // 增加汇总行并设为锁定禁止编辑状态
 
-             changeSpreadSheet.addRows(changeSpreadSheet.getRowCount(), 1);
 
-             changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 0, '合计');
 
-             const cellType1 = new GC.Spread.Sheets.CellTypes.Text();
 
-             changeSpreadSheet.getCell(changeSpreadSheet.getRowCount() - 1, 0).cellType(cellType1);
 
-             changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
 
-             changeSpreadObj.countSum();
 
-         },
 
-         setAuditValue: function () {
 
-             if (readOnly) {
 
-                 for (const c of changeList) {
 
-                     for (const j of aidList) {
 
-                         c['audit_amount_' + j] = ZhCalc.round(c['audit_amount_' + j], findDecimal(c.unit));
 
-                         c['sa_tp_' + j] = ZhCalc.round(ZhCalc.mul(c['audit_amount_' + j], ZhCalc.round(c.unit_price, unitPriceUnit)), totalPriceUnit);
 
-                     }
 
-                 }
 
-             }
 
-         },
 
-         loadExprToInput: function () {
 
-             const sel = changeSpreadSheet.getSelections()[0];
 
-             if (!sel) return;
 
-             const col = changeSpreadSheet.zh_setting.cols[sel.col];
 
-             const data = SpreadJsObj.getSelectObject(changeSpreadSheet);
 
-             if (col && col.field === 'camount' && data && (!data.gcl_id || (data.children && data.children.length === 1))) {
 
-                 if (readOnly) {
 
-                     $('#camount-expr').val(data.camount_expr ? data.camount_expr : data.camount);
 
-                 } else {
 
-                     $('#camount-expr').removeAttr('readonly').val(data.camount_expr ? data.camount_expr : data.camount);
 
-                 }
 
-             } else {
 
-                 $('#camount-expr').attr('readonly', true).val('');
 
-             }
 
-         },
 
-         topRowChanged: function (e, info) {
 
-             SpreadJsObj.saveTopAndSelect(info.sheet, ckChangeSpread);
 
-         },
 
-         selectionChanged: function (e, info) {
 
-             if (info.newSelections) {
 
-                 if (!info.oldSelections || info.newSelections[0].row !== info.oldSelections[0].row || info.newSelections[0].rowCount !== info.oldSelections[0].rowCount) {
 
-                     const data = SpreadJsObj.getSelectObject(changeSpreadSheet);
 
-                     if (info.oldSelections && info.oldSelections[0].row !== changeSpreadSheet.getRowCount() - 1) {
 
-                         info.sheet.getRange(info.oldSelections[0].row, -1, 1, -1).backColor('#fff');
 
-                     }
 
-                     if (!data) {
 
-                         SpreadJsObj.loadSheetData(xmjSheet, SpreadJsObj.DataType.Data, []);
 
-                         return;
 
-                     }
 
-                     changeSpreadObj.refreshXmjData();
 
-                     if (!readOnly) changeSpreadObj.refreshActn();
 
-                 }
 
-             }
 
-             changeSpreadObj.loadExprToInput();
 
-         },
 
-         showHideAudit: function (show = false) {
 
-             if (shenpiPower) {
 
-                 show = true;
 
-             }
 
-             if (readOnly) {
 
-                 const count = changeSpreadSetting.cols.length;
 
-                 for (let i = startLimit + 5; i < count - 2; i++) {
 
-                     changeSpreadSheet.setColumnVisible(i, show, GC.Spread.Sheets.SheetArea.viewport);
 
-                 }
 
-                 changeSpreadSheet.setColumnVisible(startLimit + 3, !show, GC.Spread.Sheets.SheetArea.viewport);
 
-                 changeSpreadSheet.setColumnVisible(startLimit + 4, !show, GC.Spread.Sheets.SheetArea.viewport);
 
-             }
 
-         },
 
-         calcOneSum: function (node) {
 
-             if (node.children && node.children.length > 0) {
 
-                 if (readOnly) {
 
-                     for (const aid of aidList) {
 
-                         let audit_amount = 0;
 
-                         for (const c of node.children) {
 
-                             audit_amount = ZhCalc.add(audit_amount, ZhCalc.round(c['audit_amount_' + aid], findDecimal(node.unit)));
 
-                         }
 
-                         if (!_.isEqual(node['audit_amount_' + aid], audit_amount)) {
 
-                             node['audit_amount_' + aid] = audit_amount;
 
-                         }
 
-                         node['sa_tp_' + aid] = ZhCalc.round(ZhCalc.mul(audit_amount, ZhCalc.round(node.unit_price, unitPriceUnit)), totalPriceUnit);
 
-                     }
 
-                 }
 
-                 let is_valuation = 1;
 
-                 let ccid = 0;
 
-                 let oamount2 = 0;
 
-                 let camount = 0;
 
-                 let samount = 0;
 
-                 let spamount = 0;
 
-                 for (const c of node.children) {
 
-                     oamount2 = ZhCalc.add(oamount2, ZhCalc.round(c.oamount2, findDecimal(node.unit)));
 
-                     camount = ZhCalc.add(camount, ZhCalc.round(c.camount, findDecimal(node.unit)));
 
-                     samount = ZhCalc.add(samount, ZhCalc.round(c.samount, findDecimal(node.unit)));
 
-                     spamount = ZhCalc.add(spamount, ZhCalc.round(c.spamount, findDecimal(node.unit)));
 
-                     if (c.is_valuation === 0) is_valuation = 0;
 
-                     if (_.findIndex(changeLedgerList, { id: c.gcl_id }) !== -1 || _.findIndex(changePosList, { id: c.mx_id }) !== -1) {
 
-                         ccid = 1;
 
-                     }
 
-                     c.order = node.order;
 
-                 }
 
-                 if (!_.isEqual(node.oamount2, oamount2) || !_.isEqual(node.camount, camount) || !_.isEqual(node.samount, samount)) {
 
-                     node.oamount2 = oamount2;
 
-                     node.camount = camount;
 
-                     node.samount = samount;
 
-                     node.spamount = spamount;
 
-                     node.change_amount = ZhCalc.add(oamount2, camount);
 
-                 }
 
-                 node.is_valuation = is_valuation;
 
-                 node.ccid = ccid;
 
-                 this.calcNodeTp(node);
 
-             } else {
 
-                 if (readOnly) {
 
-                     for (const aid of aidList) {
 
-                         node['sa_tp_' + aid] = ZhCalc.round(ZhCalc.mul(node['audit_amount_' + aid], ZhCalc.round(node.unit_price, unitPriceUnit)), totalPriceUnit);
 
-                     }
 
-                 }
 
-                 this.calcNodeTp(node);
 
-             }
 
-             return node;
 
-         },
 
-         calcNodeTp: function (node) {
 
-             node.change_amount = ZhCalc.add(node.oamount2, node.camount);
 
-             node.oa_tp = ZhCalc.round(ZhCalc.mul(node.oamount2, ZhCalc.round(node.unit_price, unitPriceUnit)), totalPriceUnit) || 0;
 
-             node.ca_tp = ZhCalc.round(ZhCalc.mul(node.camount, ZhCalc.round(node.unit_price, unitPriceUnit)), totalPriceUnit) || 0;
 
-             node.sa_tp = ZhCalc.round(ZhCalc.mul(node.samount, ZhCalc.round(node.unit_price, unitPriceUnit)), totalPriceUnit) || 0;
 
-             const spa_tp = ZhCalc.round(ZhCalc.mul(node.spamount, ZhCalc.round(node.unit_price, unitPriceUnit)), totalPriceUnit) || 0;
 
-             node.changed_tp = readOnly ? ZhCalc.add(node.oa_tp, spa_tp) || 0 :  ZhCalc.add(node.oa_tp, node.ca_tp) || 0;
 
-         },
 
-         refreshXmjData: function() {
 
-             SpreadJsObj.resetTopAndSelect(xmjSheet);
 
-             xmjSpreadObj.loadCurXmjData();
 
-             SpreadJsObj.saveTopAndSelect(changeSpreadSheet, ckChangeSpread);
 
-             // posSearch.search($('#pos-keyword').val());
 
-         },
 
-         makeNewChangeList: function(newOrder = changeOrder) {
 
-             // 先加载台账数据
 
-             if (!newOrder) {
 
-                 const newChangeList2 = [];
 
-                 for (const gcl of changeListData) {
 
-                     if (!newOrder) {
 
-                         if (gcl.leafXmjs !== undefined && gcl.leafXmjs !== null) {
 
-                             const cl = _.filter(changeList, function (item) {
 
-                                 return _.findIndex(gcl.leafXmjs, { gcl_id: item.gcl_id }) !== -1;
 
-                             });
 
-                             if (cl.length > 0) {
 
-                                 for (const l of gcl.leafXmjs) {
 
-                                     const c = _.find(cl, { gcl_id: l.gcl_id, mx_id: l.mx_id || '' });
 
-                                     if (c) newChangeList2.push(c);
 
-                                 }
 
-                             }
 
-                         } else {
 
-                             // 签约清单
 
-                             const c = _.find(changeList, { lid: gcl.id });
 
-                             if (c) newChangeList2.push(c);
 
-                         }
 
-                     }
 
-                 }
 
-                 // 按台账去重新排序changeList,空白清单居后
 
-                 const sycList = _.difference(changeList, newChangeList2);
 
-                 changeList = newChangeList2.concat(sycList);
 
-             }
 
-             const newChangeList = [];
 
-             for (const cl of changeList) {
 
-                 const newCl = _.cloneDeep(cl);
 
-                 if (cl.gcl_id && _.findIndex(newChangeList, { gcl_id: cl.gcl_id }) === -1) {
 
-                     // delete newCl.id;
 
-                     // newCl.bwmx = '';
 
-                     // newCl.detail = '';
 
-                     // newCl.delimit = null;
 
-                     newCl.children = [];
 
-                     newCl.children.push(cl);
 
-                     if (_.findIndex(changeLedgerList, { id: newCl.gcl_id }) !== -1 || _.findIndex(changePosList, { id: newCl.mx_id }) !== -1) {
 
-                         newCl.ccid = 1;
 
-                     }
 
-                     newChangeList.push(newCl);
 
-                 } else if (!cl.gcl_id) {
 
-                     newChangeList.push(newCl);
 
-                 } else {
 
-                     const newCl2 = _.find(newChangeList, { gcl_id: cl.gcl_id });
 
-                     if (newCl2) {
 
-                         if (_.findIndex(changeLedgerList, { id: newCl.gcl_id }) !== -1 || _.findIndex(changePosList, { id: newCl.mx_id }) !== -1) {
 
-                             newCl2.ccid = 1;
 
-                         }
 
-                         delete newCl2.id;
 
-                         newCl2.bwmx = '';
 
-                         newCl2.detail = '';
 
-                         newCl2.delimit = null;
 
-                         newCl2.children.push(newCl);
 
-                     }
 
-                 }
 
-             }
 
-             const updateOrderList = [];
 
-             // order如果不同,则修改并提交
 
-             let i = 0;
 
-             // 重算金额和数量汇总
 
-             for (const node of newChangeList) {
 
-                 if (node.children && node.children.length > 0) {
 
-                     changeSpreadObj.calcOneSum(node);
 
-                     node.order = i + 1;
 
-                     const cls = node.gcl_id ? _.filter(changeList, { gcl_id: node.gcl_id }) : [];
 
-                     for (const c of cls) {
 
-                         if (node.order !== c.order) {
 
-                             c.order = node.order;
 
-                             updateOrderList.push({ id: c.id, order: node.order });
 
-                         }
 
-                     }
 
-                 } else {
 
-                     if (node.order !== i + 1) {
 
-                         node.order = i + 1;
 
-                         updateOrderList.push({ id: node.id, order: node.order });
 
-                     }
 
-                     changeSpreadObj.calcOneSum(node);
 
-                     if (readOnly) {
 
-                         for (const aid of aidList) {
 
-                             node['sa_tp_' + aid] = ZhCalc.round(ZhCalc.mul(node['audit_amount_' + aid], ZhCalc.round(node.unit_price, unitPriceUnit)), totalPriceUnit) || 0;
 
-                         }
 
-                     }
 
-                 }
 
-                 i++;
 
-             }
 
-             return [newChangeList, updateOrderList];
 
-         },
 
-         countSum: function () {
 
-             const rowCount = changeSpreadSheet.getRowCount();
 
-             let oa_tp = 0,
 
-                 ca_tp = 0,
 
-                 sa_tp = 0,
 
-                 changed_tp = 0;
 
-             const aidLength = readOnly ? aidList.length : 0;
 
-             for (const data of changeSpreadSheet.zh_data) {
 
-                 oa_tp = ZhCalc.add(oa_tp, data.oa_tp);
 
-                 ca_tp = ZhCalc.add(ca_tp, data.ca_tp);
 
-                 sa_tp = ZhCalc.add(sa_tp, data.sa_tp);
 
-                 changed_tp = ZhCalc.add(changed_tp, data.changed_tp);
 
-             }
 
-             changeSpreadSheet.setValue(rowCount - 1, startLimit, oa_tp !== 0 ? oa_tp : null);
 
-             changeSpreadSheet.setValue(rowCount - 1, startLimit + 2, ca_tp !== 0 ? ca_tp : null);
 
-             if (readOnly) {
 
-                 changeSpreadSheet.setValue(rowCount - 1, (startLimit + 4), sa_tp !== 0 ? sa_tp : null);
 
-                 changeSpreadSheet.setValue(rowCount - 1, (startLimit + 4 + aidLength * 2 + 2), changed_tp !== 0 ? changed_tp : null);
 
-             } else {
 
-                 changeSpreadSheet.setValue(rowCount - 1, (startLimit + 4), changed_tp !== 0 ? changed_tp : null);
 
-             }
 
-             if (readOnly) {
 
-                 // 用户的数据合计
 
-                 for (const j in aidList) {
 
-                     let audit_sum = 0;
 
-                     for (const data of changeSpreadSheet.zh_data) {
 
-                         audit_sum = ZhCalc.add(audit_sum, data['sa_tp_' + aidList[j]]);
 
-                     }
 
-                     changeSpreadSheet.setValue(rowCount - 1, startLimit + 6 + j * 2, audit_sum !== 0 ? audit_sum : null);
 
-                 }
 
-             }
 
-         },
 
-         reloadRow: function (sheet, row, rowCount = 0, clearAll = false) {
 
-             if (rowCount) {
 
-                 SpreadJsObj.reLoadRowData(sheet, row, rowCount);
 
-             } else {
 
-                 SpreadJsObj.reLoadRowData(sheet, row);
 
-             }
 
-             if (clearAll) {
 
-                 for (const i in sheet.zh_data) {
 
-                     const data = sheet.zh_data[i];
 
-                     if (data) {
 
-                         sheet.getRange(i, -1, 1, -1).backColor('#fff');
 
-                     }
 
-                 }
 
-             }
 
-             sheet.getRange(row, -1, 1, -1).backColor('#fffacd');
 
-         },
 
-         reloadSheet: function (newChangeList) {
 
-             changeSpreadObj.setAuditValue();
 
-             SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, newChangeList);
 
-             SpreadJsObj.loadTopAndSelect(changeSpreadSheet, ckChangeSpread);
 
-             changeSpreadObj.showHideAudit($('#show-table-detail').is(':checked'));
 
-             changeSpreadObj.makeSjsFooter();
 
-             xmjSpreadObj.loadCurXmjData();
 
-             changeSpreadObj.loadExprToInput();
 
-             if (!readOnly) changeSpreadObj.refreshActn();
 
-         }
 
-     };
 
-     // sjsSettingObj.setGridSelectStyle(changeSpreadSetting);
 
-     SpreadJsObj.initSpreadSettingEvents(changeSpreadSetting, changeCol);
 
-     SpreadJsObj.initSheet(changeSpreadSheet, changeSpreadSetting);
 
-     const preUrl = window.location.pathname.split('/').slice(0, 4).join('/');
 
-     let changeListData;
 
-     let gclGatherData;
 
-     postData(preUrl + '/defaultBills', {}, function (result) {
 
-         ledgerList = result.bills;
 
-         posList = result.pos;
 
-         gclGatherModel.loadLedgerData(result.bills);
 
-         gclGatherModel.loadPosData(result.pos);
 
-         gclGatherData = gclGatherModel.gatherGclData();
 
-         gclGatherData = _.filter(gclGatherData, function (item) {
 
-             return item.leafXmjs && item.leafXmjs.length !== 0;
 
-         });
 
-         for (const ggd in gclGatherData) {
 
-             if (gclGatherData[ggd].leafXmjs && gclGatherData[ggd].leafXmjs.length === 0) {
 
-                 gclGatherData.splice(ggd, 1);
 
-             }
 
-             gclGatherData[ggd].code = gclGatherData[ggd].b_code;
 
-             let hadcid = 0;
 
-             for (const xmj of gclGatherData[ggd].leafXmjs) {
 
-                 const changeLedger = _.find(changeLedgerList, { id: xmj.gcl_id });
 
-                 const changePos = _.find(changePosList, { id: xmj.mx_id, lid: xmj.gcl_id });
 
-                 if (changeLedger || changePos) {
 
-                     xmj.cid = 1;
 
-                     xmj.ccid = changeLedger ? changeLedger.ccid : changePos.ccid;
 
-                     hadcid = 1;
 
-                 }
 
-             }
 
-             if (hadcid !== 0) gclGatherData[ggd].cid = 1;
 
-         }
 
-         console.log(gclGatherData);
 
-         // 数组去重
 
-         const dealBillList = result.dealBills;
 
-         for (const db of gclGatherData) {
 
-             const exist_index = dealBillList.findIndex(function (item) {
 
-                 return item.code === db.code && item.name === db.name && item.unit === db.unit && item.unit_price === db.unit_price;
 
-             });
 
-             if (exist_index !== -1) {
 
-                 dealBillList.splice(exist_index, 1);
 
-             }
 
-         }
 
-         changeListData = gclGatherData.concat(dealBillList).sort(sortByCode);
 
-         if (!readOnly || shenpiPower) {
 
-             checkAndChange(changeListData);
 
-         }
 
-         showMode(changeMode);
 
-     });
 
-     changeSpread.bind(spreadNS.Events.SelectionChanged, changeSpreadObj.selectionChanged);
 
-     changeSpread.bind(spreadNS.Events.topRowChanged, changeSpreadObj.topRowChanged);
 
-     // 项目节信息获取
 
-     const xmjSpreadSetting = {
 
-         cols: [
 
-             {title: '计价', colSpan: '1', rowSpan: '2', field: 'is_valuation', hAlign: 1, width: 50, cellType: 'checkbox', readOnly: 'readOnly.isValuation'},
 
-             {title: '项目节编号', colSpan: '1', rowSpan: '2', field: 'xmj_code', hAlign: 0, width: 80, readOnly: true},
 
-             // {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 120},
 
-             {title: '细目', colSpan: '1', rowSpan: '2', field: 'xmj_jldy', hAlign: 0, width: 100, readOnly: true},
 
-             {title: '单位工程', colSpan: '1', rowSpan: '2', field: 'xmj_dwgc', hAlign: 0, width: 100, readOnly: true},
 
-             {title: '分部工程', colSpan: '1', rowSpan: '2', field: 'xmj_fbgc', hAlign: 0, width: 100, readOnly: true},
 
-             {title: '分项工程', colSpan: '1', rowSpan: '2', field: 'xmj_fxgc', hAlign: 0, width: 100, readOnly: true},
 
-             {title: '计量单元', colSpan: '1', rowSpan: '2', field: 'bwmx', hAlign: 0, width: 100, readOnly: true},
 
-             {title: '变更详情', colSpan: '1', rowSpan: '2', field: 'detail', hAlign: 0, width: 120, formatter: '@', readOnly: 'readOnly.isEdit'},
 
-             {title: '计量上限(%)', colSpan: '1', rowSpan: '2', field: 'delimit', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isSettle2', visible: openChangeState},
 
-             {title: '原设计|数量', colSpan: '1|1', rowSpan: '|1', field: 'oamount2', hAlign: 2, width: 120, type: 'Number', readOnly: 'readOnly.isSettle', getValue: 'getValue.oamount2'},
 
-             {title: '申请变更增(+)减(-)|数量', colSpan: '1|1', rowSpan: '|1', field: 'camount', hAlign: 2, width: 120, readOnly: 'readOnly.isSettle2', getValue: 'getValue.camount'},
 
-             // {title: '数量', colSpan: '1', rowSpan: '2', field: 'oamount', hAlign: 2, width: 80},
 
-         ],
 
-         emptyRows: 0,
 
-         headRows: 2,
 
-         headRowHeight: [25, 25],
 
-         defaultRowHeight: 21,
 
-         headerFont: '12px 微软雅黑',
 
-         font: '12px 微软雅黑',
 
-         // readOnly: true,
 
-         rowHeader:[
 
-             {
 
-                 rowHeaderType: 'circle',
 
-                 setting: {
 
-                     size: 5,
 
-                     indent: 16,
 
-                     getColor: function (index, data) {
 
-                         if (!data) return;
 
-                         if (_.findIndex(changeLedgerList, { id: data.gcl_id }) !== -1 || _.findIndex(changePosList, { id: data.mx_id }) !== -1) {
 
-                             return '#dc3545';
 
-                         }
 
-                     }
 
-                 },
 
-             },
 
-         ],
 
-         localCache: {
 
-             key: 'changes-xmj',
 
-             colWidth: true,
 
-         }
 
-     };
 
-     if (readOnly) {
 
-         xmjSpreadSetting.cols.push({title: '批复变更|数量', colSpan: '1|1', rowSpan: '|1', field: 'samount', hAlign: 2, width: 120, type: 'Number', readOnly: true, getValue: 'getValue.samount'});
 
-         for (const aid of aidList) {
 
-             const audit = _.find(auditors2, function(item){
 
-                 return _.findIndex(item, { audit_order: aid }) !== -1;
 
-             });
 
-             const newColcount = {
 
-                 title: (audit && audit.length > 1 ? (aid + '审') : audit[0].name) + ' 审批|数量',
 
-                 colSpan: '1|1', rowSpan: '|1',
 
-                 field: 'audit_amount_' + aid,
 
-                 hAlign: 2, width: 120, type: 'Number', readOnly: _.findIndex(audit, { uid: parseInt(accountId) }) === -1 ? true : 'readOnly.isSettle' ,
 
-             };
 
-             xmjSpreadSetting.cols.push(newColcount);
 
-         }
 
-     }
 
-     xmjSpreadSetting.cols.push({title: '变更后|数量', colSpan: '1|1', rowSpan: '|1', field: 'changed_amount', hAlign: 2, width: 120, type: 'Number', readOnly: true, getValue: 'getValue.changed_amount'},);
 
-     const xmjCol = {
 
-         getValue: {
 
-             oamount2: function (data) {
 
-                 return ZhCalc.round(data.oamount2, findDecimal(data.unit));
 
-             },
 
-             camount: function (data) {
 
-                 return ZhCalc.round(data.camount, findDecimal(data.unit));
 
-             },
 
-             samount: function (data) {
 
-                 return ZhCalc.round(data.samount, findDecimal(data.unit));
 
-             },
 
-             changed_amount: function (data) {
 
-                 return readOnly ? ZhCalc.round(ZhCalc.add(data.oamount2, data.spamount), findDecimal(data.unit)) : ZhCalc.round(ZhCalc.add(data.oamount2, data.camount), findDecimal(data.unit));
 
-             },
 
-         },
 
-         readOnly: {
 
-             isEdit: function (data) {
 
-                 return readOnly;
 
-             },
 
-             isValuation: function (data) {
 
-                 return !(!readOnly && _.findIndex(changeUsedData, { cbid: data.clid }) !== -1);
 
-             },
 
-             isSettle: function (data) {
 
-                 return !((!readOnly || shenpiPower) && !checkIsSettle(data));
 
-             },
 
-             isSettle2: function (data) {
 
-                 return !(!readOnly && !checkIsSettle(data));
 
-             }
 
-         },
 
-     }
 
-     sjsSettingObj.setGridSelectStyle(xmjSpreadSetting);
 
-     SpreadJsObj.initSpreadSettingEvents(xmjSpreadSetting, xmjCol);
 
-     SpreadJsObj.initSheet(xmjSpread.getActiveSheet(), xmjSpreadSetting);
 
-     const xmjSheet = xmjSpread.getActiveSheet();
 
-     const xmjSpreadObj = {
 
-         loadExprToInput: function () {
 
-             const sel = xmjSheet.getSelections()[0];
 
-             if (!sel) return;
 
-             const col = xmjSheet.zh_setting.cols[sel.col];
 
-             const data = SpreadJsObj.getSelectObject(xmjSheet);
 
-             if (col && col.field === 'camount' && data) {
 
-                 if (readOnly) {
 
-                     $('#xmj-camount-expr').val(data.camount_expr ? data.camount_expr : data.camount);
 
-                 } else {
 
-                     $('#xmj-camount-expr').removeAttr('readonly').val(data.camount_expr ? data.camount_expr : data.camount);
 
-                 }
 
-             } else {
 
-                 $('#xmj-camount-expr').attr('readonly', true).val('');
 
-             }
 
-         },
 
-         /**
 
-          * 加载计量单元 根据当前台账选择节点
 
-          */
 
-         loadCurXmjData: function () {
 
-             const data = SpreadJsObj.getSelectObject(changeSpreadSheet);
 
-             changeSpreadSheet.getRange(changeSpreadSheet.getSelections()[0].row, -1, 1, -1).backColor('#fffacd');
 
-             const xmj = [];
 
-             if (data && data.children && data.children.length > 0) {
 
-                 for (const child of data.children) {
 
-                     if (child.bwmx === child.xmj_jldy) {
 
-                         child.bwmx = '';
 
-                     }
 
-                     xmj.push(child);
 
-                 }
 
-             }
 
-             SpreadJsObj.loadSheetData(xmjSheet, SpreadJsObj.DataType.Data, xmj);
 
-             xmjSpreadObj.showHideAudit($('#show-table-detail').is(':checked'));
 
-             SpreadJsObj.resetTopAndSelect(xmjSheet);
 
-             xmjSpreadObj.loadExprToInput();
 
-         },
 
-         selectionChanged: function (e, info) {
 
-             xmjSpreadObj.loadExprToInput();
 
-         },
 
-         showHideAudit: function (show = false) {
 
-             if (shenpiPower) {
 
-                 show = true;
 
-             }
 
-             if (readOnly) {
 
-                 const xmjStartLimit = 9;
 
-                 const count = xmjSpreadSetting.cols.length;
 
-                 for (let i = xmjStartLimit + 2; i < count - 1; i++) {
 
-                     xmjSheet.setColumnVisible(i, show, GC.Spread.Sheets.SheetArea.viewport);
 
-                 }
 
-                 xmjSheet.setColumnVisible(xmjStartLimit + 2, !show, GC.Spread.Sheets.SheetArea.viewport);
 
-             }
 
-         },
 
-     };
 
-     xmjSpread.bind(spreadNS.Events.SelectionChanged, xmjSpreadObj.selectionChanged);
 
-     if (!readOnly) {
 
-         $('.dropdown-menu input[name="paixu"]').on('click', function () {
 
-             const newChangeOrder = parseInt($(this).val());
 
-             if (newChangeOrder !== changeOrder) {
 
-                 const [newChangeList, updateOrderList] = changeSpreadObj.makeNewChangeList(newChangeOrder);
 
-                 // 更新至服务器
 
-                 postData(window.location.pathname + '/save', { type:'order_by', updateData: newChangeOrder, updateOrderList }, function (result) {
 
-                     if (newChangeOrder === 0) {
 
-                         $('#bpaixu').text('清单排序:清单编号');
 
-                         $('#upAndMoveBtn').attr('style', 'display: none !important');
 
-                         $('.order_text').text('添加');
 
-                         changeOrder = newChangeOrder;
 
-                     } else if (newChangeOrder === 1) {
 
-                         $('#bpaixu').text('清单排序:添加顺序');
 
-                         $('#upAndMoveBtn').show();
 
-                         $('.order_text').text('插入');
 
-                         changeOrder = newChangeOrder;
 
-                     }
 
-                     changeList = result.changeList;
 
-                     changeUsedData = result.usedList;
 
-                     const [newChangeList] = changeSpreadObj.makeNewChangeList();
 
-                     changeSpreadObj.reloadSheet(newChangeList);
 
-                 });
 
-             }
 
-         });
 
-         $('#set-site-btn').click(async function () {
 
-             if (changeOrder && !changeMode) {
 
-                 const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
 
-                 if (!select && changeSpreadSheet.zh_data.length > 0) {
 
-                     toastr.error('请选择清单再插入');
 
-                     return;
 
-                 }
 
-                 postData(window.location.pathname + '/save', { type:'order_site', listid: select && select.id ? select.id : (select && select.children && select.children.length > 0 ? select.children[0].id : null) }, function (result) {
 
-                     window.location.href = window.location.pathname + '/revise';
 
-                 });
 
-             } else {
 
-                 window.location.href = window.location.pathname + '/revise';
 
-             }
 
-         });
 
-         changeSpreadObj.refreshActn = function (rowCount = 1) {
 
-             const setObjEnable = function (obj, enable) {
 
-                 if (enable) {
 
-                     obj.removeClass('disabled');
 
-                 } else {
 
-                     obj.addClass('disabled');
 
-                 }
 
-             };
 
-             // const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
 
-             // 还需判断是否已被调差清单调用
 
-             const selection = changeSpreadSheet.getSelections();
 
-             const sel = selection ? selection[0] : changeSpreadSheet.getSelections()[0];
 
-             const row = sel ? sel.row : -1;
 
-             const first = changeSpreadSheet.zh_data[row];
 
-             let last = first;
 
-             if (sel.rowCount > 1 && first) {
 
-                 for (let r = 1; r < sel.rowCount; r++) {
 
-                     const rNode = changeSpreadSheet.zh_data[sel.row + r];
 
-                     if (!rNode) break;
 
-                     last = rNode;
 
-                 }
 
-             }
 
-             const preNode = changeSpreadSheet.zh_data[row - 1];
 
-             setObjEnable($('#up-move'), !readOnly && first && preNode && changeSpreadSheet.zh_data.indexOf(last) > 0 && sel.row + sel.rowCount <= changeSpreadSheet.zh_data.length);
 
-             setObjEnable($('#down-move'), !readOnly && first && changeSpreadSheet.zh_data.indexOf(last) < changeSpreadSheet.zh_data.length - 1 && sel.row + sel.rowCount <= changeSpreadSheet.zh_data.length);
 
-             // setObjEnable($('#open-list-modal'), !readOnly && select && changeList.indexOf(select) !== -1);
 
-             // setObjEnable($('#add-white-btn'), !readOnly && select && changeList.indexOf(select) !== -1);
 
-         };
 
-         changeSpreadObj.add = function () {
 
-             let select = null;
 
-             if (changeOrder) {
 
-                 select = SpreadJsObj.getSelectObject(changeSpreadSheet);
 
-             }
 
-             postData(window.location.pathname + '/save', {type: 'add', postData: select ? select.order : null}, function (result) {
 
-                 if (result) {
 
-                     if (changeOrder === 1 && select) {
 
-                         // 批量更新changeList的order值
 
-                         _.forEach(changeList, function (item) {
 
-                             item.order = item.order > select.order ? item.order + 1 : item.order;
 
-                         });
 
-                         _.forEach(changeSpreadSheet.zh_data, function (item) {
 
-                             item.order = item.order > select.order ? item.order + 1 : item.order;
 
-                         });
 
-                         changeList.splice(select.order, 0, result);
 
-                         changeSpreadSheet.addRows(select.order, 1);
 
-                         changeSpreadSheet.zh_data.splice(select.order, 0, _.cloneDeep(result));
 
-                         changeSpreadSheet.getRange(select.order - 1, -1, 1, -1).backColor('#fff');
 
-                         changeSpreadSheet.setSelection(select.order, 1, 1, 1);
 
-                         changeSpreadObj.reloadRow(changeSpreadSheet, select.order);
 
-                     } else {
 
-                         changeList.push(result);
 
-                         changeSpreadSheet.zh_data.push(_.cloneDeep(result));
 
-                         changeSpreadSheet.addRows(changeSpreadSheet.zh_data.length - 1, 1);
 
-                         changeSpreadSheet.setSelection(changeSpreadSheet.zh_data.length - 1, 1, 1, 1);
 
-                         changeSpreadObj.reloadRow(changeSpreadSheet, changeSpreadSheet.zh_data.length - 1, 0, true);
 
-                     }
 
-                     changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
 
-                     changeSpreadObj.refreshXmjData();
 
-                     changeSpreadObj.refreshActn();
 
-                 }
 
-             });
 
-         };
 
-         changeSpreadObj.batchAdd = function(num) {
 
-             let select = null;
 
-             if (changeOrder) {
 
-                 select = SpreadJsObj.getSelectObject(changeSpreadSheet);
 
-             }
 
-             postData(window.location.pathname + '/save', {type: 'batchadd', num, postData: select ? select.order : null}, function (result) {
 
-                 if (result) {
 
-                     changeList = result;
 
-                     SpreadJsObj.initSpreadSettingEvents(changeSpreadSetting, changeCol);
 
-                     SpreadJsObj.initSheet(changeSpreadSheet, changeSpreadSetting);
 
-                     const [newChangeList, updateOrderList] = changeSpreadObj.makeNewChangeList();
 
-                     changeSpreadObj.reloadSheet(newChangeList);
 
-                 }
 
-             });
 
-         };
 
-         // 计量单元修改
 
-         changeSpreadObj.del = function () {
 
-             const selection = changeSpreadSheet.getSelections();
 
-             const sel = selection ? selection[0] : xmjSheet.getSelections()[0];
 
-             const row = sel && sel.row !== undefined ? sel.row : -1;
 
-             const count = sel.rowCount;
 
-             if (readOnly || row === -1 || row + count > changeSpreadSheet.zh_data.length) {
 
-                 return false;
 
-             }
 
-             const delList = [];
 
-             let lastSelect = null;
 
-             for (let r = 0; r < count; r++) {
 
-                 const select = changeSpreadSheet.zh_data[row + r];
 
-                 if (!select || !select.id) {
 
-                     toastr.error('变更清单不存在或者该清单存在项目节');
 
-                     return;
 
-                 }
 
-                 if(!select || _.find(changeUsedData, { cbid: select.id })) {
 
-                     toastr.error('已调用的变更清单不能删除');
 
-                     return false;
 
-                 }
 
-                 if (checkIsSettle(select)) {
 
-                     toastr.error('已结算的变更清单不能删除');
 
-                     return false;
 
-                 }
 
-                 if (r === count - 1 && changeOrder) {
 
-                     lastSelect = select;
 
-                 }
 
-                 delList.push(select.id);
 
-             }
 
-             if (delList.length) {
 
-                 postData(window.location.pathname + '/save', {type: 'del', ids: delList, postData: lastSelect ? lastSelect.order : null}, function (result) {
 
-                     changeSpreadSheet.deleteRows(row, count);
 
-                     changeSpreadSheet.zh_data.splice(row, count);
 
-                     changeSpreadObj.countSum();
 
-                     changeSpreadSheet.setSelection(0, 0, 1, 1);
 
-                     changeSpreadObj.refreshXmjData();
 
-                     changeSpreadObj.refreshActn();
 
-                 });
 
-             }
 
-         };
 
-         changeSpreadObj.editStarting = function (e, info) {
 
-             const select = SpreadJsObj.getSelectObject(info.sheet);
 
-             if (select && select.id) {
 
-                 const col = info.sheet.zh_setting.cols[info.col];
 
-                 if (col.field === 'camount') {
 
-                     if (select.camount_expr && select.camount_expr !== '') {
 
-                         info.sheet.getCell(info.row, info.col).text(select.camount_expr);
 
-                     }
 
-                 }
 
-             }
 
-         };
 
-         changeSpreadObj.editEnded = function (e, info) {
 
-             if (!info.sheet.zh_setting) {
 
-                 changeSpreadObj.reloadRow(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const select = info.sheet.zh_data ? info.sheet.zh_data[info.row] : null;
 
-             if (!select || !select.id) {
 
-                 toastr.error('该变更清单无法编辑');
 
-                 changeSpreadObj.reloadRow(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const cInfo = _.find(changeList, { id: select.id });
 
-             if (!cInfo) {
 
-                 toastr.error('数据错误,请刷新页面重试');
 
-                 changeSpreadObj.reloadRow(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const col = info.sheet.zh_setting.cols[info.col];
 
-             if (col.field === 'is_valuation') {
 
-                 return;
 
-             }
 
-             let validText = is_numeric(info.editingText) && _.indexOf(numField, col.field) !== -1 ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : '');
 
-             let orgValue;
 
-             if (col.field === 'camount') {
 
-                 orgValue = validText && validText !== ''
 
-                     ? (_.toNumber(validText) ? select.camount : select.camount_expr)
 
-                     : (select.camount_expr && select.camount_expr !== '' ? select.camount_expr : select.camount);
 
-             } else {
 
-                 orgValue = select[col.field];
 
-             }
 
-             if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === '' || validText === null))) {
 
-                 changeSpreadObj.reloadRow(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             if(col.field === 'camount') {
 
-                 const exprQuantity = {
 
-                     expr: '',
 
-                     quantity: 0,
 
-                 };
 
-                 const [valid, msg] = ledgerTreeSpreadObj._checkExpr(validText, exprQuantity);
 
-                 if (!valid) {
 
-                     toastr.error(msg);
 
-                     changeSpreadObj.reloadRow(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 if (isNaN(exprQuantity.quantity)) {
 
-                     toastr.error('不能输入其它非数字类型字符');
 
-                     changeSpreadObj.reloadRow(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 validText = parseFloat(exprQuantity.quantity);
 
-                 // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
 
-                 const usedInfo = _.find(changeUsedData, { cbid: select.id });
 
-                 if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
 
-                     toastr.error('清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
 
-                     changeSpreadObj.reloadRow(info.sheet, info.row);
 
-                     return;
 
-                 } else if (usedInfo && usedInfo.qty < 0  && validText > usedInfo.qty) {
 
-                     toastr.error('清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
 
-                     changeSpreadObj.reloadRow(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
 
-                 select.camount_expr = exprQuantity.expr;
 
-                 cInfo.spamount = select.spamount;
 
-                 cInfo.camount_expr = exprQuantity.expr;
 
-             }
 
-             if (col.type === 'Number') {
 
-                 if (isNaN(validText)) {
 
-                     toastr.error('不能输入其它非数字类型字符');
 
-                     changeSpreadObj.reloadRow(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 if (col.field === 'unit_price') {
 
-                     validText = ZhCalc.round(validText, unitPriceUnit);
 
-                 } else {
 
-                     validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
 
-                 }
 
-                 if (col.field === 'delimit') {
 
-                     const reg = /^(\d{1,2}|100)$/;
 
-                     if (!(_.isNumber(validText) && reg.test(validText))) {
 
-                         toastr.error('计量上限默认值只能输入0-100之间的整数');
 
-                         changeSpreadObj.reloadRow(info.sheet, info.row);
 
-                         return;
 
-                     }
 
-                     // 需要判断是否已调用,已调用的则不能低于原有值大小
 
-                     const usedInfo = _.find(changeUsedData, { cbid: select.id });
 
-                     if (usedInfo && usedInfo.qty) {
 
-                         const minLimit = Math.ceil(ZhCalc.mul(ZhCalc.div(usedInfo.qty, select.camount), 100));
 
-                         if (validText < minLimit) {
 
-                             toastr.error('计量上限值至少大于等于 ' + minLimit);
 
-                             changeSpreadObj.reloadRow(info.sheet, info.row);
 
-                             return;
 
-                         }
 
-                     }
 
-                 }
 
-             }
 
-             cInfo[col.field] = validText;
 
-             select[col.field] = validText;
 
-             console.log(cInfo);
 
-             delete cInfo.waitingLoading;
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/save', { type:'update', updateData: cInfo }, function (result) {
 
-                 if (select.children && select.children.length === 1) {
 
-                     const child = select.children[0];
 
-                     child[col.field] = validText;
 
-                 }
 
-                 changeSpreadObj.calcOneSum(select);
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 changeSpreadObj.refreshXmjData();
 
-                 changeSpreadObj.countSum();
 
-                 changeSpreadObj.refreshActn();
 
-                 if (info.row === info.sheet.zh_data.length - 1) {
 
-                     const [newChangeList, updateOrderList] = changeSpreadObj.makeNewChangeList();
 
-                     changeSpreadObj.reloadSheet(newChangeList);
 
-                 }
 
-             }, function () {
 
-                 select[col.field] = orgValue;
 
-                 cInfo[col.field] = orgValue;
 
-                 if(col.field === 'camount') {
 
-                     select.spamount = orgValue;
 
-                     cInfo.spamount = orgValue;
 
-                 }
 
-                 changeSpreadObj.reloadRow(info.sheet, info.row);
 
-             });
 
-         };
 
-         changeSpreadObj.clipboardPasted = function (e, info) {
 
-             if (info.sheet.getColumnCount() > info.sheet.zh_setting.cols.length) {
 
-                 info.sheet.setColumnCount(info.sheet.zh_setting.cols.length);
 
-             }
 
-             const hint = {
 
-                 cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
 
-                 numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
 
-                 expr: {type: 'warning', msg: '粘贴了表达式非法,已过滤'},
 
-             };
 
-             const range = info.cellRange;
 
-             const sortData = info.sheet.zh_data || [];
 
-             const data = [];
 
-             // const rowData = [];
 
-             let needCopyIgnore = !$('#customCheck1').is(':checked');
 
-             let needColAdd = false;
 
-             for (let iRow = 0; iRow < range.rowCount; iRow++) {
 
-                 let bPaste = true;
 
-                 const curRow = range.row + iRow;
 
-                 if (!sortData[curRow].id) {
 
-                     bPaste = false;
 
-                     continue;
 
-                 }
 
-                 const cLData = { id: sortData[curRow].id };
 
-                 const hintRow = range.rowCount >= 1 ? curRow : '';
 
-                 let sameCol = 0;
 
-                 for (let iCol = 0; iCol < range.colCount; iCol++) {
 
-                     const curCol = range.col + iCol;
 
-                     let colSetting = info.sheet.zh_setting.cols[curCol];
 
-                     if ((needColAdd && curCol > 2) || (needCopyIgnore && curCol === 2)) { // 要判断是否已隐藏了变更详情,是则变更详情后面的curCol要+1
 
-                         const newCurCol = curCol + 1;
 
-                         needColAdd = true;
 
-                         colSetting = info.sheet.zh_setting.cols[newCurCol];
 
-                     }
 
-                     if (!colSetting) continue;
 
-                     let validText = info.sheet.getText(curRow, curCol);
 
-                     validText = is_numeric(validText) && _.indexOf(numField, colSetting.field) !== -1 ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : '');
 
-                     let orgValue;
 
-                     if (colSetting.field === 'camount') {
 
-                         orgValue = validText && validText !== ''
 
-                             ? (_.toNumber(validText) ? sortData[curRow].camount : sortData[curRow].camount_expr)
 
-                             : (sortData[curRow].camount_expr && sortData[curRow].camount_expr !== '' ? sortData[curRow].camount_expr : sortData[curRow].camount);
 
-                     } else {
 
-                         orgValue = sortData[curRow][colSetting.field];
 
-                     }
 
-                     if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
 
-                         sameCol++;
 
-                         if (range.colCount === sameCol)  {
 
-                             bPaste = false;
 
-                         }
 
-                         continue;
 
-                     }
 
-                     if(colSetting.field === 'camount') {
 
-                         const exprQuantity = {
 
-                             expr: '',
 
-                             quantity: 0,
 
-                         };
 
-                         const [valid, msg] = ledgerTreeSpreadObj._checkExpr(validText, exprQuantity);
 
-                         if (!valid) {
 
-                             toastMessageUniq(getPasteHint(msg, hintRow));
 
-                             bPaste = false;
 
-                             continue;
 
-                         }
 
-                         if (isNaN(exprQuantity.quantity)) {
 
-                             toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
 
-                             bPaste = false;
 
-                             continue;
 
-                         }
 
-                         validText = parseFloat(exprQuantity.quantity);
 
-                         // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
 
-                         const usedInfo = _.find(changeUsedData, { cbid: sortData[curRow].id });
 
-                         if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
 
-                             toastr.error(hintRow ? '清单第' + (hintRow+1) + '行变更数值必须大于等于已调用值 ' + usedInfo.qty : '清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
 
-                             bPaste = false;
 
-                             continue;
 
-                         } else if (usedInfo && usedInfo.qty < 0 && validText > usedInfo.qty) {
 
-                             toastr.error(hintRow ? '清单第' + (hintRow+1) + '行变更数值必须小于等于已调用值 ' + usedInfo.qty : '清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
 
-                             bPaste = false;
 
-                             continue;
 
-                         }
 
-                         cLData.camount_expr = exprQuantity.expr;
 
-                         sortData[curRow].camount_expr = exprQuantity.expr;
 
-                     }
 
-                     if (colSetting.type === 'Number') {
 
-                         if (isNaN(validText)) {
 
-                             toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
 
-                             bPaste = false;
 
-                             continue;
 
-                         }
 
-                         if (colSetting.field === 'unit_price') {
 
-                             validText = ZhCalc.round(validText, unitPriceUnit);
 
-                         } else {
 
-                             validText = ZhCalc.round(validText, findDecimal(sortData[curRow].unit)) || 0;
 
-                         }
 
-                         if (colSetting.field === 'delimit') {
 
-                             const reg = /^(\d{1,2}|100)$/;
 
-                             if (!(_.isNumber(validText) && reg.test(validText))) {
 
-                                 toastr.error('清单第' + (hintRow+1) + '行计量上限默认值只能粘贴0-100之间的整数');
 
-                                 bPaste = false;
 
-                                 continue;
 
-                             }
 
-                             // 需要判断是否已调用,已调用的则不能低于原有值大小
 
-                             const usedInfo = _.find(changeUsedData, { cbid: sortData[curRow].id });
 
-                             if (usedInfo && usedInfo.qty) {
 
-                                 const minLimit = Math.ceil(ZhCalc.mul(ZhCalc.div(usedInfo.qty, sortData[curRow].camount), 100));
 
-                                 if (validText < minLimit) {
 
-                                     toastr.error('清单第' + (hintRow+1) + '行计量上限值至少大于等于 ' + minLimit);
 
-                                     bPaste = false;
 
-                                     continue;
 
-                                 }
 
-                             }
 
-                         }
 
-                     }
 
-                     let unitdecimal = validText;
 
-                     cLData[colSetting.field] = validText;
 
-                     sortData[curRow][colSetting.field] = validText;
 
-                     cLData.spamount = ZhCalc.round(sortData[curRow].camount, findDecimal(unitdecimal)) || 0;
 
-                 }
 
-                 if (bPaste) {
 
-                     data.push(cLData);
 
-                     // rowData.push(curRow);
 
-                 } else {
 
-                     changeSpreadObj.reloadRow(info.sheet, curRow);
 
-                 }
 
-             }
 
-             if (data.length === 0) {
 
-                 changeSpreadObj.reloadRow(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 return;
 
-             }
 
-             console.log(data);
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/save', { type:'paste', updateData: data }, function (result) {
 
-                 changeList = result;
 
-                 const [newChangeList, updateOrderList] = changeSpreadObj.makeNewChangeList();
 
-                 changeSpreadObj.reloadSheet(newChangeList);
 
-             }, function () {
 
-                 changeSpreadObj.reloadRow(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 return;
 
-             });
 
-         };
 
-         changeSpreadObj.buttonClicked = function(e, info) {
 
-             if (info.sheet.zh_setting) {
 
-                 const select = SpreadJsObj.getSelectObject(info.sheet);
 
-                 if (!select || !select.id) {
 
-                     changeSpreadObj.reloadRow(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 const cInfo = _.find(changeList, { id: select.id });
 
-                 if (!cInfo) {
 
-                     toastr.error('数据错误,请刷新页面重试');
 
-                     changeSpreadObj.reloadRow(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 const col = info.sheet.zh_setting.cols[info.col];
 
-                 if (col.field === 'is_valuation') {
 
-                     if (info.sheet.isEditing()) {
 
-                         info.sheet.endEdit(true);
 
-                     }
 
-                     if (_.findIndex(changeUsedData, { cbid: select.id }) !== -1) {
 
-                         return;
 
-                     }
 
-                     select.is_valuation = info.sheet.getValue(info.row, info.col) ? 0 : 1;
 
-                     cInfo.is_valuation = select.is_valuation;
 
-                     delete cInfo.waitingLoading;
 
-                     // 更新至服务器
 
-                     postData(window.location.pathname + '/save', { type:'update', updateData: cInfo }, function (result) {
 
-                         changeSpreadObj.reloadRow(info.sheet, info.row);
 
-                         if (select.children && select.children.length === 1) {
 
-                             const child = select.children[0];
 
-                             child[col.field] = select.is_valuation;
 
-                             changeSpreadObj.refreshXmjData();
 
-                         }
 
-                     }, function () {
 
-                         select.is_valuation = info.sheet.getValue(info.row, info.col) ? 1 : 0;
 
-                         cInfo.is_valuation = select.is_valuation;
 
-                         changeSpreadObj.reloadRow(info.sheet, info.row);
 
-                     });
 
-                 }
 
-             }
 
-         };
 
-         changeSpreadObj.valueChanged = function(e, info) {
 
-             // 防止ctrl+z撤销数据
 
-             changeSpreadObj.reloadRow(info.sheet, info.row);
 
-         };
 
-         changeSpreadObj.setAllValuation = function (is_valuation) {
 
-             if (changeList.length === 0) {
 
-                 toastr.warning('暂无清单无法设置清单计价');
 
-                 return;
 
-             }
 
-             const needChangeList = _.filter(changeList, { is_valuation: is_valuation ? 0 : 1 });
 
-             if (needChangeList.length === 0) {
 
-                 toastr.warning('全部清单已设置清单'+ (is_valuation ? '' : '不') +'计价');
 
-                 return;
 
-             }
 
-             const realNeedChangeList = [];
 
-             for (const nc of needChangeList) {
 
-                 if (_.findIndex(changeUsedData, { cbid: nc.id }) === -1) {
 
-                     realNeedChangeList.push(nc.id);
 
-                 }
 
-             }
 
-             if (realNeedChangeList.length === 0) {
 
-                 toastr.warning('全部清单已设置清单'+ (is_valuation ? '' : '不') +'计价');
 
-                 return;
 
-             }
 
-             postData(window.location.pathname + '/save', { type:'set_all_valuation', ids: realNeedChangeList, is_valuation }, function (result) {
 
-                 changeList = result;
 
-                 const [newChangeList, updateOrderList] = changeSpreadObj.makeNewChangeList();
 
-                 changeSpreadObj.reloadSheet(newChangeList);
 
-             });
 
-         };
 
-         changeSpreadObj.deletePress = function (sheet) {
 
-             if (!sheet.zh_setting) return;
 
-             // 暂时仅支持移除数量
 
-             const sel = sheet.getSelections()[0], datas = [];
 
-             for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
 
-                 let bDel = false;
 
-                 const node = sheet.zh_data[iRow];
 
-                 if (!node || !node.id) continue;
 
-                 const cInfo = _.find(changeList, { id: node.id });
 
-                 for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
 
-                     const col = sheet.zh_setting.cols[iCol];
 
-                     if (col.field === 'camount' || col.field === 'oamount2') {
 
-                         node[col.field] = null;
 
-                         cInfo[col.field] = null;
 
-                         if (col.field === 'camount') {
 
-                             node.camount_expr = '';
 
-                             node.spamount = null;
 
-                             cInfo.camount_expr = '';
 
-                             cInfo.spamount = null;
 
-                         }
 
-                         delete cInfo.waitingLoading;
 
-                         bDel = true;
 
-                     }
 
-                 }
 
-                 if (bDel) datas.push(cInfo);
 
-             }
 
-             if (datas.length > 0) {
 
-                 postData(window.location.pathname + '/save', { type:'paste', updateData: datas }, function (result) {
 
-                     changeList = result;
 
-                     const [newChangeList, updateOrderList] = changeSpreadObj.makeNewChangeList();
 
-                     changeSpreadObj.reloadSheet(newChangeList);
 
-                 }, function () {
 
-                     changeSpreadObj.reloadRow(sheet, sel.row, sel.rowCount);
 
-                     return;
 
-                 });
 
-             }
 
-             return;
 
-         };
 
-         changeSpreadObj.upMove = function () {
 
-             const data = {
 
-                 type: 'changeOrder',
 
-                 postData: [],
 
-             };
 
-             const selection = changeSpreadSheet.getSelections();
 
-             const row = selection[0].row, count = selection[0].rowCount;
 
-             const first = changeSpreadSheet.zh_data[row];
 
-             const firstRow = row;
 
-             if (!first) {
 
-                 changeSpreadObj.refreshActn();
 
-                 return false;
 
-             }
 
-             const pre = changeSpreadSheet.zh_data[row - 1];
 
-             const preUpdates = [];
 
-             if (pre && pre.id) {
 
-                 preUpdates.push({ id: pre.id });
 
-             } else if (pre && pre.children && pre.children.length > 0) {
 
-                 for (const item of pre.children) {
 
-                     preUpdates.push({ id: item.id });
 
-                 }
 
-             }
 
-             for (let iRow = 0; iRow < count; iRow++) {
 
-                 const posData = changeSpreadSheet.zh_data[iRow + row];
 
-                 if (posData) {
 
-                     for (const item of preUpdates) {
 
-                         item.order = posData.order;
 
-                     }
 
-                     if (posData.id) {
 
-                         data.postData.push({id: posData.id, order: changeSpreadSheet.zh_data[iRow + row - 1].order});
 
-                     } else if (posData && posData.children && posData.children.length > 0) {
 
-                         for (const item of posData.children) {
 
-                             data.postData.push({id: item.id, order: changeSpreadSheet.zh_data[iRow + row - 1].order});
 
-                         }
 
-                     }
 
-                 }
 
-             }
 
-             data.postData.push(...preUpdates);
 
-             console.log(data);
 
-             if (data.postData.length > 0) {
 
-                 postData(window.location.pathname + '/save', data, function () {
 
-                     _.forEach(data.postData, function (item) {
 
-                         const cl = _.find(changeList, { id: item.id });
 
-                         cl.order = item.order;
 
-                     });
 
-                     changeList.sort(function (a, b) {
 
-                         return a.order - b.order
 
-                     });
 
-                     const [newChangeList, updateOrderList] = changeSpreadObj.makeNewChangeList();
 
-                     const sel = selection[0];
 
-                     if (sel) {
 
-                         changeSpreadSheet.setSelection(row - 1, sel.col, sel.rowCount, sel.colCount);
 
-                         changeSpreadSheet.getRange(row, -1, 1, -1).backColor('#fff');
 
-                         SpreadJsObj.saveTopAndSelect(changeSpreadSheet, ckChangeSpread);
 
-                     }
 
-                     changeSpreadObj.reloadSheet(newChangeList);
 
-                 });
 
-             }
 
-         };
 
-         changeSpreadObj.downMove = function () {
 
-             const data = {
 
-                 type: 'changeOrder',
 
-                 postData: [],
 
-             };
 
-             const selection = changeSpreadSheet.getSelections();
 
-             const row = selection[0].row, count = selection[0].rowCount;
 
-             const first = changeSpreadSheet.zh_data[row];
 
-             if (!first) {
 
-                 changeSpreadObj.refreshActn();
 
-                 return false;
 
-             }
 
-             const next = changeSpreadSheet.zh_data[row + count];
 
-             const nextUpdates = [];
 
-             if (next && next.id) {
 
-                 preUpdates.push({ id: next.id });
 
-             } else if (next && next.children && next.children.length > 0) {
 
-                 for (const item of next.children) {
 
-                     nextUpdates.push({ id: item.id });
 
-                 }
 
-             }
 
-             for (let iRow = count - 1; iRow >= 0; iRow--) {
 
-                 const posData = changeSpreadSheet.zh_data[iRow + row];
 
-                 if (posData) {
 
-                     for (const item of nextUpdates) {
 
-                         item.order = posData.order;
 
-                     }
 
-                     if (posData.id) {
 
-                         data.postData.push({id: posData.id, order: changeSpreadSheet.zh_data[iRow + row + 1].order});
 
-                     } else if (posData && posData.children && posData.children.length > 0) {
 
-                         for (const item of posData.children) {
 
-                             data.postData.push({id: item.id, order: changeSpreadSheet.zh_data[iRow + row + 1].order});
 
-                         }
 
-                     }
 
-                 }
 
-             }
 
-             data.postData.push(...nextUpdates);
 
-             console.log(data);
 
-             if (data.postData.length > 0) {
 
-                 postData(window.location.pathname + '/save', data, function () {
 
-                     _.forEach(data.postData, function (item) {
 
-                         const cl = _.find(changeList, { id: item.id });
 
-                         cl.order = item.order;
 
-                     });
 
-                     changeList.sort(function (a, b) {
 
-                         return a.order - b.order
 
-                     });
 
-                     const [newChangeList, updateOrderList] = changeSpreadObj.makeNewChangeList();
 
-                     const sel = selection[0];
 
-                     if (sel) {
 
-                         changeSpreadSheet.setSelection(row + 1, sel.col, sel.rowCount, sel.colCount);
 
-                         changeSpreadSheet.getRange(row, -1, 1, -1).backColor('#fff');
 
-                         SpreadJsObj.saveTopAndSelect(changeSpreadSheet, ckChangeSpread);
 
-                     }
 
-                     changeSpreadObj.reloadSheet(newChangeList);
 
-                 });
 
-             }
 
-         };
 
-         // 表达式判断
 
-         $('#camount-expr').change(function () {
 
-             if (this.readOnly) return;
 
-             let validText = $(this).val();
 
-             const sel = changeSpreadSheet.getSelections()[0];
 
-             const row = sel ? sel.row : -1;
 
-             const col = changeSpreadSheet.zh_setting.cols[sel.col];
 
-             if (row === -1 || !(col && col.field === 'camount')) return;
 
-             const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
 
-             if (!select || !select.id) return;
 
-             const cInfo = _.find(changeList, { id: select.id });
 
-             if (!cInfo) return;
 
-             validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : '');
 
-             let orgValue = validText && validText !== ''
 
-                 ? (_.toNumber(validText) ? select.camount : select.camount_expr)
 
-                 : (select.camount_expr && select.camount_expr !== '' ? select.camount_expr : select.camount);
 
-             const orgExprValue = _.clone(select.camount_expr);
 
-             if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === '' || validText === null))) {
 
-                 return;
 
-             }
 
-             const exprQuantity = {
 
-                 expr: '',
 
-                 quantity: 0,
 
-             };
 
-             const [valid, msg] = ledgerTreeSpreadObj._checkExpr(validText, exprQuantity);
 
-             if (!valid) {
 
-                 toastr.error(msg);
 
-                 $(this).val(select.camount_expr ? select.camount_expr : select.camount);
 
-                 return;
 
-             }
 
-             if (isNaN(exprQuantity.quantity)) {
 
-                 toastr.error('不能输入其它非数字类型字符');
 
-                 $(this).val(select.camount_expr ? select.camount_expr : select.camount);
 
-                 return;
 
-             }
 
-             validText = parseFloat(exprQuantity.quantity);
 
-             // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
 
-             const usedInfo = _.find(changeUsedData, { cbid: cInfo.id });
 
-             if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
 
-                 toastr.error('清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
 
-                 $(this).val(select.camount_expr ? select.camount_expr : select.camount);
 
-                 return;
 
-             } else if (usedInfo && usedInfo.qty < 0  && validText > usedInfo.qty) {
 
-                 toastr.error('清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
 
-                 $(this).val(select.camount_expr ? select.camount_expr : select.camount);
 
-                 return;
 
-             }
 
-             select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
 
-             select.camount_expr = exprQuantity.expr;
 
-             select.camount = validText;
 
-             cInfo.spamount = select.spamount;
 
-             cInfo.camount_expr = select.camount_expr;
 
-             cInfo.camount = validText;
 
-             // console.log(select);
 
-             delete cInfo.waitingLoading;
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/save', { type:'update', updateData: cInfo }, function (result) {
 
-                 changeSpreadObj.reloadRow(changeSpreadSheet, row);
 
-                 changeSpreadObj.calcOneSum(select);
 
-                 changeSpreadObj.countSum();
 
-                 changeSpreadObj.refreshActn();
 
-             }, function () {
 
-                 select.camount = orgValue;
 
-                 select.camount_expr = orgExprValue;
 
-                 select.spamount = orgValue;
 
-                 cInfo.camount = orgValue;
 
-                 cInfo.camount_expr = orgExprValue;
 
-                 cInfo.spamount = orgValue;
 
-                 changeSpreadObj.reloadRow(changeSpreadSheet, row);
 
-             });
 
-         });
 
-         $('#add-white-btn').click(changeSpreadObj.add);
 
-         $('#up-move').click(changeSpreadObj.upMove);
 
-         $('#down-move').click(changeSpreadObj.downMove);
 
-         changeSpread.bind(spreadNS.Events.EditEnded, changeSpreadObj.editEnded);
 
-         changeSpread.bind(spreadNS.Events.EditStarting, changeSpreadObj.editStarting);
 
-         changeSpread.bind(spreadNS.Events.ClipboardPasted, changeSpreadObj.clipboardPasted);
 
-         changeSpread.bind(spreadNS.Events.ValueChanged, changeSpreadObj.valueChanged);
 
-         changeSpread.bind(spreadNS.Events.ButtonClicked, changeSpreadObj.buttonClicked);
 
-         SpreadJsObj.addDeleteBind(changeSpread, changeSpreadObj.deletePress);
 
-         // 计量单元修改
 
-         xmjSpreadObj.del = function () {
 
-             const selection = xmjSheet.getSelections();
 
-             const sel = selection ? selection[0] : xmjSheet.getSelections()[0];
 
-             const row = sel && sel.row !== undefined ? sel.row : -1;
 
-             const count = sel.rowCount;
 
-             if (readOnly || row === -1 || row + count > xmjSheet.zh_data.length) {
 
-                 return false;
 
-             }
 
-             const delList = [];
 
-             let lastSelect = null;
 
-             for (let r = 0; r < count; r++) {
 
-                 const select = xmjSheet.zh_data[row + r];
 
-                 if(!select || _.find(changeUsedData, { cbid: select.id })) {
 
-                     toastr.error('已调用的变更清单不能删除');
 
-                     return false;
 
-                 }
 
-                 if (checkIsSettle(select)) {
 
-                     toastr.error('已结算的变更清单不能删除');
 
-                     return false;
 
-                 }
 
-                 if (r === count - 1 && xmjSheet.zh_data.length === count && changeOrder) {
 
-                     lastSelect = select;
 
-                 }
 
-                 delList.push(select.id);
 
-             }
 
-             if (delList.length) {
 
-                 postData(window.location.pathname + '/save', {type: 'del', ids: delList, postData: lastSelect ? lastSelect.order : null, delLength: 1}, function (result) {
 
-                     xmjSheet.deleteRows(row, count);
 
-                     xmjSheet.zh_data.splice(row, count);
 
-                     // 同步删除changeList值
 
-                     _.forEach(delList, function (id) {
 
-                         _.remove(changeList, { id: id });
 
-                     });
 
-                     const billsNode = SpreadJsObj.getSelectObject(changeSpreadSheet);
 
-                     const billIndex = _.indexOf(changeSpreadSheet.zh_data, billsNode);
 
-                     let allDel = false;
 
-                     // 判断是移除还是更新数量和金额
 
-                     if (xmjSheet.zh_data.length === 0) {
 
-                         changeSpreadSheet.deleteRows(billIndex, 1);
 
-                         changeSpreadSheet.zh_data.splice(billIndex, 1);
 
-                         allDel = true;
 
-                     } else {
 
-                         billsNode.children = xmjSheet.zh_data;
 
-                         if (billsNode.children.length === 1) {
 
-                             billsNode.id = billsNode.children[0].id;
 
-                             billsNode.bwmx = billsNode.children[0].bwmx || billsNode.children[0].xmj_jldy;
 
-                             billsNode.detail = billsNode.children[0].detail;
 
-                             billsNode.delimit = billsNode.children[0].delimit;
 
-                         }
 
-                         changeSpreadObj.calcOneSum(billsNode);
 
-                         changeSpreadObj.reloadRow(changeSpreadSheet, billIndex);
 
-                     }
 
-                     changeSpreadObj.countSum();
 
-                     if (allDel) {
 
-                         changeSpreadSheet.setSelection(0, 0, 1, 1);
 
-                         changeSpreadObj.refreshXmjData();
 
-                         changeSpreadObj.refreshActn();
 
-                     }
 
-                 });
 
-             }
 
-         };
 
-         xmjSpreadObj.editStarting = function (e, info) {
 
-             xmjSpreadObj.billsNode = SpreadJsObj.getSelectObject(changeSpreadSheet);
 
-             const col = info.sheet.zh_setting.cols[info.col];
 
-             const select = SpreadJsObj.getSelectObject(info.sheet);
 
-             if (col.field === 'camount') {
 
-                 if (select.camount_expr && select.camount_expr !== '') {
 
-                     info.sheet.getCell(info.row, info.col).text(select.camount_expr);
 
-                 }
 
-             }
 
-         };
 
-         xmjSpreadObj.editEnded = function (e, info) {
 
-             if (!info.sheet.zh_setting) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const select = info.sheet.zh_data ? info.sheet.zh_data[info.row] : null;
 
-             const cInfo = _.find(changeList, { id: select.id });
 
-             if (!cInfo) {
 
-                 toastr.error('数据错误,请刷新页面重试');
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const col = info.sheet.zh_setting.cols[info.col];
 
-             if (col.field === 'is_valuation') {
 
-                 return;
 
-             }
 
-             let validText = is_numeric(info.editingText) && _.indexOf(numField, col.field) !== -1 ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : '');
 
-             let orgValue;
 
-             if (col.field === 'camount') {
 
-                 orgValue = validText && validText !== ''
 
-                     ? (_.toNumber(validText) ? select.camount : select.camount_expr)
 
-                     : (select.camount_expr && select.camount_expr !== '' ? select.camount_expr : select.camount);
 
-             } else {
 
-                 orgValue = select[col.field];
 
-             }
 
-             if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === '' || validText === null))) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const node = xmjSpreadObj.billsNode;
 
-             if (!node) {
 
-                 toastr.error('数据错误,请选择清单节点后再试');
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             if(col.field === 'camount') {
 
-                 const exprQuantity = {
 
-                     expr: '',
 
-                     quantity: 0,
 
-                 };
 
-                 const [valid, msg] = ledgerTreeSpreadObj._checkExpr(validText, exprQuantity);
 
-                 if (!valid) {
 
-                     toastr.error(msg);
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 if (isNaN(exprQuantity.quantity)) {
 
-                     toastr.error('不能输入其它非数字类型字符');
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 validText = parseFloat(exprQuantity.quantity);
 
-                 // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
 
-                 const usedInfo = _.find(changeUsedData, { cbid: select.id });
 
-                 if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
 
-                     toastr.error('清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 } else if (usedInfo && usedInfo.qty < 0  && validText > usedInfo.qty) {
 
-                     toastr.error('清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
 
-                 select.camount_expr = exprQuantity.expr;
 
-                 cInfo.spamount = select.spamount;
 
-                 cInfo.camount_expr = exprQuantity.expr;
 
-             }
 
-             if (col.type === 'Number') {
 
-                 if (isNaN(validText)) {
 
-                     toastr.error('不能输入其它非数字类型字符');
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 if (col.field === 'unit_price') {
 
-                     validText = ZhCalc.round(validText, unitPriceUnit);
 
-                 } else {
 
-                     validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
 
-                 }
 
-                 if (col.field === 'delimit') {
 
-                     const reg = /^(\d{1,2}|100)$/;
 
-                     if (!(_.isNumber(validText) && reg.test(validText))) {
 
-                         toastr.error('计量上限默认值只能输入0-100之间的整数');
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                         return;
 
-                     }
 
-                     // 需要判断是否已调用,已调用的则不能低于原有值大小
 
-                     const usedInfo = _.find(changeUsedData, { cbid: select.id });
 
-                     if (usedInfo && usedInfo.qty) {
 
-                         const minLimit = Math.ceil(ZhCalc.mul(ZhCalc.div(usedInfo.qty, select.camount), 100));
 
-                         if (validText < minLimit) {
 
-                             toastr.error('计量上限值至少大于等于 ' + minLimit);
 
-                             SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                             return;
 
-                         }
 
-                     }
 
-                 }
 
-             }
 
-             cInfo[col.field] = validText;
 
-             select[col.field] = validText;
 
-             console.log(cInfo);
 
-             delete cInfo.waitingLoading;
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/save', { type:'update', updateData: cInfo }, function (result) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 const billIndex = _.indexOf(changeSpreadSheet.zh_data, node);
 
-                 node.children = info.sheet.zh_data;
 
-                 if (node.children && node.children.length === 1) {
 
-                     node[col.field] = validText;
 
-                 }
 
-                 xmjSpreadObj.loadExprToInput();
 
-                 changeSpreadObj.calcOneSum(node);
 
-                 changeSpreadObj.reloadRow(changeSpreadSheet, billIndex);
 
-                 changeSpreadObj.countSum();
 
-             }, function () {
 
-                 select[col.field] = orgValue;
 
-                 cInfo[col.field] = orgValue;
 
-                 if(col.field === 'camount') {
 
-                     select.spamount = orgValue;
 
-                     cInfo.spamount = orgValue;
 
-                 }
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-             });
 
-         };
 
-         xmjSpreadObj.clipboardPasted = function (e, info) {
 
-             if (info.sheet.getColumnCount() > info.sheet.zh_setting.cols.length) {
 
-                 info.sheet.setColumnCount(info.sheet.zh_setting.cols.length);
 
-             }
 
-             const hint = {
 
-                 cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
 
-                 numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
 
-                 expr: {type: 'warning', msg: '粘贴了表达式非法,已过滤'},
 
-             };
 
-             const range = info.cellRange;
 
-             const sortData = info.sheet.zh_data || [];
 
-             if (range.row + range.rowCount > sortData.length) {
 
-                 toastMessageUniq(hint.cellError);
 
-                 // SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
 
-                 xmjSpreadObj.loadCurXmjData();
 
-                 return;
 
-             }
 
-             if (sortData.length > 0 && range.col + range.colCount > 12) {
 
-                 toastMessageUniq(hint.cellError);
 
-                 xmjSpreadObj.loadCurXmjData();
 
-                 return;
 
-             }
 
-             if (!info.sheet.zh_setting) {
 
-                 xmjSpreadObj.loadCurXmjData();
 
-                 return;
 
-             }
 
-             const data = [];
 
-             // const rowData = [];
 
-             let needCopyIgnore = !$('#customCheck1').is(':checked');
 
-             let needColAdd = false;
 
-             for (let iRow = 0; iRow < range.rowCount; iRow++) {
 
-                 let bPaste = true;
 
-                 const curRow = range.row + iRow;
 
-                 // const materialData = JSON.parse(JSON.stringify(sortData[curRow]));
 
-                 const cLData = { id: sortData[curRow].id };
 
-                 const hintRow = range.rowCount >= 1 ? curRow : '';
 
-                 let sameCol = 0;
 
-                 for (let iCol = 0; iCol < range.colCount; iCol++) {
 
-                     const curCol = range.col + iCol;
 
-                     let colSetting = info.sheet.zh_setting.cols[curCol];
 
-                     if ((needColAdd && curCol > 2) || (needCopyIgnore && curCol === 2)) { // 要判断是否已隐藏了变更详情,是则变更详情后面的curCol要+1
 
-                         const newCurCol = curCol + 1;
 
-                         needColAdd = true;
 
-                         colSetting = info.sheet.zh_setting.cols[newCurCol];
 
-                     }
 
-                     if (!colSetting) continue;
 
-                     let validText = info.sheet.getText(curRow, curCol);
 
-                     validText = is_numeric(validText) && _.indexOf(numField, colSetting.field) !== -1 ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : '');
 
-                     let orgValue;
 
-                     if (colSetting.field === 'camount') {
 
-                         orgValue = validText && validText !== ''
 
-                             ? (_.toNumber(validText) ? sortData[curRow].camount : sortData[curRow].camount_expr)
 
-                             : (sortData[curRow].camount_expr && sortData[curRow].camount_expr !== '' ? sortData[curRow].camount_expr : sortData[curRow].camount);
 
-                     } else {
 
-                         orgValue = sortData[curRow][colSetting.field];
 
-                     }
 
-                     if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
 
-                         sameCol++;
 
-                         if (range.colCount === sameCol)  {
 
-                             bPaste = false;
 
-                         }
 
-                         continue;
 
-                     }
 
-                     if(colSetting.field === 'camount') {
 
-                         const exprQuantity = {
 
-                             expr: '',
 
-                             quantity: 0,
 
-                         };
 
-                         const [valid, msg] = ledgerTreeSpreadObj._checkExpr(validText, exprQuantity);
 
-                         if (!valid) {
 
-                             toastMessageUniq(getPasteHint(msg, hintRow));
 
-                             bPaste = false;
 
-                             continue;
 
-                         }
 
-                         if (isNaN(exprQuantity.quantity)) {
 
-                             toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
 
-                             bPaste = false;
 
-                             continue;
 
-                         }
 
-                         validText = parseFloat(exprQuantity.quantity);
 
-                         // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
 
-                         const usedInfo = _.find(changeUsedData, { cbid: sortData[curRow].id });
 
-                         if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
 
-                             toastr.error(hintRow ? '清单第' + (hintRow+1) + '行变更数值必须大于等于已调用值 ' + usedInfo.qty : '清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
 
-                             bPaste = false;
 
-                             continue;
 
-                         } else if (usedInfo && usedInfo.qty < 0 && validText > usedInfo.qty) {
 
-                             toastr.error(hintRow ? '清单第' + (hintRow+1) + '行变更数值必须小于等于已调用值 ' + usedInfo.qty : '清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
 
-                             bPaste = false;
 
-                             continue;
 
-                         }
 
-                         cLData.camount_expr = exprQuantity.expr;
 
-                         sortData[curRow].camount_expr = exprQuantity.expr;
 
-                     }
 
-                     if (colSetting.type === 'Number') {
 
-                         if (isNaN(validText)) {
 
-                             toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
 
-                             bPaste = false;
 
-                             continue;
 
-                         }
 
-                         if (colSetting.field === 'unit_price') {
 
-                             validText = ZhCalc.round(validText, unitPriceUnit);
 
-                         } else {
 
-                             validText = ZhCalc.round(validText, findDecimal(sortData[curRow].unit)) || 0;
 
-                         }
 
-                         if (colSetting.field === 'delimit') {
 
-                             const reg = /^(\d{1,2}|100)$/;
 
-                             if (!(_.isNumber(validText) && reg.test(validText))) {
 
-                                 toastr.error('项目节第' + (hintRow+1) + '行计量上限默认值只能粘贴0-100之间的整数');
 
-                                 bPaste = false;
 
-                                 continue;
 
-                             }
 
-                             // 需要判断是否已调用,已调用的则不能低于原有值大小
 
-                             const usedInfo = _.find(changeUsedData, { cbid: sortData[curRow].id });
 
-                             if (usedInfo && usedInfo.qty) {
 
-                                 const minLimit = Math.ceil(ZhCalc.mul(ZhCalc.div(usedInfo.qty, sortData[curRow].camount), 100));
 
-                                 if (validText < minLimit) {
 
-                                     toastr.error('项目节第' + (hintRow+1) + '行计量上限值至少大于等于 ' + minLimit);
 
-                                     bPaste = false;
 
-                                     continue;
 
-                                 }
 
-                             }
 
-                         }
 
-                     }
 
-                     let unitdecimal = validText;
 
-                     cLData[colSetting.field] = validText;
 
-                     sortData[curRow][colSetting.field] = validText;
 
-                     cLData.spamount = ZhCalc.round(sortData[curRow].camount, findDecimal(unitdecimal)) || 0;
 
-                 }
 
-                 if (bPaste) {
 
-                     data.push(cLData);
 
-                     // rowData.push(curRow);
 
-                 } else {
 
-                     SpreadJsObj.reLoadRowData(info.sheet, curRow);
 
-                 }
 
-             }
 
-             if (data.length === 0) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 return;
 
-             }
 
-             console.log(data);
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/save', { type:'paste', updateData: data }, function (result) {
 
-                 changeList = result;
 
-                 const node = SpreadJsObj.getSelectObject(changeSpreadSheet);
 
-                 const billIndex = _.indexOf(changeSpreadSheet.zh_data, node);
 
-                 node.children = info.sheet.zh_data;
 
-                 if (node.children && node.children.length === 1) {
 
-                     for (const col in data[0]) {
 
-                         node[col] = data[0][col];
 
-                     }
 
-                 }
 
-                 changeSpreadObj.calcOneSum(node);
 
-                 changeSpreadObj.reloadRow(changeSpreadSheet, billIndex);
 
-                 changeSpreadObj.countSum();
 
-                 xmjSpreadObj.loadCurXmjData();
 
-             }, function () {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 return;
 
-             });
 
-         };
 
-         xmjSpreadObj.buttonClicked = function(e, info) {
 
-             if (info.sheet.zh_setting) {
 
-                 const select = SpreadJsObj.getSelectObject(info.sheet);
 
-                 const cInfo = _.find(changeList, { id: select.id });
 
-                 if (!cInfo) {
 
-                     toastr.error('数据错误,请刷新页面重试');
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 const col = info.sheet.zh_setting.cols[info.col];
 
-                 if (col.field === 'is_valuation') {
 
-                     if (info.sheet.isEditing()) {
 
-                         info.sheet.endEdit(true);
 
-                     }
 
-                     if (_.findIndex(changeUsedData, { cbid: select.id }) !== -1) {
 
-                         return;
 
-                     }
 
-                     select.is_valuation = info.sheet.getValue(info.row, info.col) ? 0 : 1;
 
-                     cInfo.is_valuation = select.is_valuation;
 
-                     delete cInfo.waitingLoading;
 
-                     // 更新至服务器
 
-                     postData(window.location.pathname + '/save', { type:'update', updateData: cInfo }, function (result) {
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                         const node = SpreadJsObj.getSelectObject(changeSpreadSheet);
 
-                         const billIndex = _.indexOf(changeSpreadSheet.zh_data, node);
 
-                         node.children = info.sheet.zh_data;
 
-                         changeSpreadObj.calcOneSum(node);
 
-                         changeSpreadObj.reloadRow(changeSpreadSheet, billIndex);
 
-                     }, function () {
 
-                         select.is_valuation = info.sheet.getValue(info.row, info.col) ? 1 : 0;
 
-                         cInfo.is_valuation = select.is_valuation;
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     });
 
-                 }
 
-             }
 
-         };
 
-         xmjSpreadObj.valueChanged = function(e, info) {
 
-             // 防止ctrl+z撤销数据
 
-             SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-         };
 
-         xmjSpreadObj.deletePress = function (sheet) {
 
-             if (!sheet.zh_setting) return;
 
-             // 暂时仅支持移除数量
 
-             const sel = sheet.getSelections()[0], datas = [];
 
-             for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
 
-                 let bDel = false;
 
-                 const node = sheet.zh_data[iRow];
 
-                 const cInfo = _.find(changeList, { id: node.id });
 
-                 for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
 
-                     const col = sheet.zh_setting.cols[iCol];
 
-                     if (col.field === 'camount' || col.field === 'oamount2') {
 
-                         node[col.field] = null;
 
-                         cInfo[col.field] = null;
 
-                         if (col.field === 'camount') {
 
-                             node.camount_expr = '';
 
-                             node.spamount = null;
 
-                             cInfo.camount_expr = '';
 
-                             cInfo.spamount = null;
 
-                         }
 
-                         delete cInfo.waitingLoading;
 
-                         bDel = true;
 
-                     }
 
-                 }
 
-                 if (bDel) datas.push(cInfo);
 
-             }
 
-             if (datas.length > 0) {
 
-                 postData(window.location.pathname + '/save', { type:'paste', updateData: datas }, function (result) {
 
-                     changeList = result;
 
-                     const node = SpreadJsObj.getSelectObject(changeSpreadSheet);
 
-                     const billIndex = _.indexOf(changeSpreadSheet.zh_data, node);
 
-                     node.children = xmjSheet.zh_data;
 
-                     changeSpreadObj.calcOneSum(node);
 
-                     changeSpreadObj.reloadRow(changeSpreadSheet, billIndex);
 
-                     changeSpreadObj.countSum();
 
-                     xmjSpreadObj.loadCurXmjData();
 
-                 }, function () {
 
-                     SpreadJsObj.reLoadRowData(sheet, sel.row, sel.rowCount);
 
-                     return;
 
-                 });
 
-             }
 
-             return;
 
-         };
 
-         // 表达式判断
 
-         $('#xmj-camount-expr').change(function () {
 
-             if (this.readOnly) return;
 
-             let validText = $(this).val();
 
-             const sel = xmjSheet.getSelections()[0];
 
-             const row = sel ? sel.row : -1;
 
-             const col = xmjSheet.zh_setting.cols[sel.col];
 
-             if (row === -1 || !(col && col.field === 'camount')) return;
 
-             const select = SpreadJsObj.getSelectObject(xmjSheet);
 
-             if (!select) return;
 
-             const cInfo = _.find(changeList, { id: select.id });
 
-             if (!cInfo) return;
 
-             validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : '');
 
-             let orgValue = validText && validText !== ''
 
-                 ? (_.toNumber(validText) ? select.camount : select.camount_expr)
 
-                 : (select.camount_expr && select.camount_expr !== '' ? select.camount_expr : select.camount);
 
-             const orgExprValue = _.clone(select.camount_expr);
 
-             if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === '' || validText === null))) {
 
-                 return;
 
-             }
 
-             const exprQuantity = {
 
-                 expr: '',
 
-                 quantity: 0,
 
-             };
 
-             const [valid, msg] = ledgerTreeSpreadObj._checkExpr(validText, exprQuantity);
 
-             if (!valid) {
 
-                 toastr.error(msg);
 
-                 $(this).val(select.camount_expr ? select.camount_expr : select.camount);
 
-                 return;
 
-             }
 
-             if (isNaN(exprQuantity.quantity)) {
 
-                 toastr.error('不能输入其它非数字类型字符');
 
-                 $(this).val(select.camount_expr ? select.camount_expr : select.camount);
 
-                 return;
 
-             }
 
-             validText = parseFloat(exprQuantity.quantity);
 
-             // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
 
-             const usedInfo = _.find(changeUsedData, { cbid: cInfo.id });
 
-             if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
 
-                 toastr.error('清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
 
-                 $(this).val(select.camount_expr ? select.camount_expr : select.camount);
 
-                 return;
 
-             } else if (usedInfo && usedInfo.qty < 0  && validText > usedInfo.qty) {
 
-                 toastr.error('清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
 
-                 $(this).val(select.camount_expr ? select.camount_expr : select.camount);
 
-                 return;
 
-             }
 
-             select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
 
-             select.camount_expr = exprQuantity.expr;
 
-             select.camount = validText;
 
-             cInfo.spamount = select.spamount;
 
-             cInfo.camount_expr = select.camount_expr;
 
-             cInfo.camount = validText;
 
-             // console.log(select);
 
-             delete cInfo.waitingLoading;
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/save', { type:'update', updateData: cInfo }, function (result) {
 
-                 SpreadJsObj.reLoadRowData(xmjSheet, row);
 
-                 const node = SpreadJsObj.getSelectObject(changeSpreadSheet);
 
-                 const billIndex = _.indexOf(changeSpreadSheet.zh_data, node);
 
-                 node.children = xmjSheet.zh_data;
 
-                 changeSpreadObj.calcOneSum(node);
 
-                 changeSpreadObj.reloadRow(changeSpreadSheet, billIndex);
 
-                 changeSpreadObj.countSum();
 
-             }, function () {
 
-                 select.camount = orgValue;
 
-                 select.camount_expr = orgExprValue;
 
-                 select.spamount = orgValue;
 
-                 cInfo.camount = orgValue;
 
-                 cInfo.camount_expr = orgExprValue;
 
-                 cInfo.spamount = orgValue;
 
-                 SpreadJsObj.reLoadRowData(posSheet, row);
 
-             });
 
-         });
 
-         xmjSpread.bind(spreadNS.Events.EditEnded, xmjSpreadObj.editEnded);
 
-         xmjSpread.bind(spreadNS.Events.EditStarting, xmjSpreadObj.editStarting);
 
-         xmjSpread.bind(spreadNS.Events.ClipboardPasted, xmjSpreadObj.clipboardPasted);
 
-         xmjSpread.bind(spreadNS.Events.ValueChanged, xmjSpreadObj.valueChanged);
 
-         xmjSpread.bind(spreadNS.Events.ButtonClicked, xmjSpreadObj.buttonClicked);
 
-         SpreadJsObj.addDeleteBind(xmjSpread, xmjSpreadObj.deletePress);
 
-         let batchInsertObj;
 
-         $.contextMenu.types.batchInsert = function (item, opt, root) {
 
-             const self = this;
 
-             if ($.isFunction(item.icon)) {
 
-                 item._icon = item.icon.call(this, this, $t, key, item);
 
-             } else {
 
-                 if (typeof(item.icon) === 'string' && item.icon.substring(0, 3) === 'fa-') {
 
-                     // to enable font awesome
 
-                     item._icon = root.classNames.icon + ' ' + root.classNames.icon + '--fa fa ' + item.icon;
 
-                 } else {
 
-                     item._icon = root.classNames.icon + ' ' + root.classNames.icon + '-' + item.icon;
 
-                 }
 
-             }
 
-             this.addClass(item._icon);
 
-             const $obj = $('<div>' + item.name + '<input class="text-right ml-1 mr-1" type="tel" max="100" min="1" value="' + item.value + '" style="width: 30px; height: 18px; padding-right: 4px;">行</div>')
 
-                 .appendTo(this);
 
-             const $input = $obj.find('input');
 
-             const event = () => {
 
-                 if (self.hasClass('context-menu-disabled')) return;
 
-                 item.batchInsert($input[0], root);
 
-             };
 
-             $obj.on('click', event).keypress(function (e) {if (e.keyCode === 13) { event(); }});
 
-             $input.click((e) => {e.stopPropagation();})
 
-                 .keyup((e) => {if (e.keyCode === 13) item.batchInsert($input[0], root);})
 
-                 .on('input', function () {this.value = this.value.replace(/[^\d]/g, '');});
 
-         };
 
-         // 右键菜单
 
-         $.contextMenu({
 
-             selector: '#change-spread',
 
-             build: function ($trigger, e) {
 
-                 const target = SpreadJsObj.safeRightClickSelection($trigger, e, changeSpread);
 
-                 // console.log(e, target);
 
-                 // const range = SpreadJsObj.getTargetSelection(changeSpreadSheet, target);
 
-                 // console.log(range);
 
-                 let ts = getLocalCache(ckChangeSpread);
 
-                 if (ts !== '') {
 
-                     ts = JSON.parse(ts);
 
-                     if (ts === undefined || ts === null) return;
 
-                     if (ts.sel) {
 
-                         changeSpreadSheet.getRange(ts.sel.row, -1, 1, -1).backColor('#fff');
 
-                     }
 
-                 }
 
-                 changeSpreadObj.refreshXmjData();
 
-                 changeSpreadObj.refreshActn();
 
-                 return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
 
-             },
 
-             items: {
 
-                 'createList': {
 
-                     name: '添加台账清单',
 
-                     icon: 'fa-sign-in',
 
-                     visible: function () {
 
-                         return changeOrder === 0;
 
-                     },
 
-                     callback: function (key, opt) {
 
-                         // $('#addlist').modal('show');
 
-                         $('#set-site-btn').click();
 
-                     },
 
-                 },
 
-                 'createAdd': {
 
-                     name: '添加空白清单',
 
-                     icon: 'fa-sign-in',
 
-                     visible: function () {
 
-                         return changeOrder === 0 && openChangeWhiteList;
 
-                     },
 
-                     callback: function (key, opt) {
 
-                         changeSpreadObj.add();
 
-                     },
 
-                 },
 
-                 'batchInsert': {
 
-                     name: '批量添加空白清单',
 
-                     type: 'batchInsert',
 
-                     value: '2',
 
-                     icon: 'fa-sign-in',
 
-                     visible: function () {
 
-                         return changeOrder === 0 && openChangeWhiteList;
 
-                     },
 
-                     batchInsert: function (obj, root) {
 
-                         if (_.toNumber(obj.value) > _.toNumber(obj.max)) {
 
-                             obj.value = obj.max;
 
-                             toastr.warning('批量添加不可多于' + obj.max);
 
-                         } else if(_.toNumber(obj.value) < _.toNumber(obj.min)) {
 
-                             obj.value = obj.min;
 
-                             toastr.warning('批量添加不可少于' + obj.min);
 
-                         } else {
 
-                             // treeOperationObj.addNode(ledgerSpread.getActiveSheet(), parseInt(obj.value));
 
-                             changeSpreadObj.batchAdd(obj.value);
 
-                             root.$menu.trigger('contextmenu:hide');
 
-                         }
 
-                     },
 
-                 },
 
-                 'createList1': {
 
-                     name: '插入台账清单',
 
-                     icon: 'fa-sign-in',
 
-                     visible: function () {
 
-                         return changeOrder === 1;
 
-                     },
 
-                     // disabled: function (key, opt) {
 
-                     //     const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
 
-                     //     const sel = changeSpreadSheet.getSelections()[0];
 
-                     //     changeSpreadObj.resetXmjSpread(select);
 
-                     //     // console.log(select, sel);
 
-                     //     if (!readOnly && select && sel.row !== changeSpreadSheet.getRowCount() - 1) {
 
-                     //         return false;
 
-                     //     } else {
 
-                     //         return true;
 
-                     //     }
 
-                     // },
 
-                     callback: function (key, opt) {
 
-                         // $('#addlist').modal('show');
 
-                         $('#set-site-btn').click();
 
-                     },
 
-                 },
 
-                 'createAdd1': {
 
-                     name: '插入空白清单',
 
-                     icon: 'fa-sign-in',
 
-                     visible: function () {
 
-                         return changeOrder === 1 && openChangeWhiteList;
 
-                     },
 
-                     // disabled: function (key, opt) {
 
-                     //     const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
 
-                     //     const sel = changeSpreadSheet.getSelections()[0];
 
-                     //     changeSpreadObj.resetXmjSpread(select);
 
-                     //     // console.log(select, sel);
 
-                     //     if (!readOnly && select && sel.row !== changeSpreadSheet.getRowCount() - 1) {
 
-                     //         return false;
 
-                     //     } else {
 
-                     //         return true;
 
-                     //     }
 
-                     // },
 
-                     callback: function (key, opt) {
 
-                         changeSpreadObj.add();
 
-                     },
 
-                 },
 
-                 'batchInsert1': {
 
-                     name: '批量插入空白清单',
 
-                     type: 'batchInsert',
 
-                     value: '2',
 
-                     icon: 'fa-sign-in',
 
-                     visible: function () {
 
-                         return changeOrder === 1 && openChangeWhiteList;
 
-                     },
 
-                     // disabled: function (key, opt) {
 
-                     //     const select = SpreadJsObj.getSelectObject(changeSpreadSheet);
 
-                     //     const sel = changeSpreadSheet.getSelections()[0];
 
-                     //     changeSpreadObj.resetXmjSpread(select);
 
-                     //     // console.log(select, sel);
 
-                     //     if (!readOnly && select && sel.row !== changeSpreadSheet.getRowCount() - 1) {
 
-                     //         return false;
 
-                     //     } else {
 
-                     //         return true;
 
-                     //     }
 
-                     // },
 
-                     batchInsert: function (obj, root) {
 
-                         if (_.toNumber(obj.value) > _.toNumber(obj.max)) {
 
-                             obj.value = obj.max;
 
-                             toastr.warning('批量插入不可多于' + obj.max);
 
-                         } else if(_.toNumber(obj.value) < _.toNumber(obj.min)) {
 
-                             obj.value = obj.min;
 
-                             toastr.warning('批量插入不可少于' + obj.min);
 
-                         } else {
 
-                             // treeOperationObj.addNode(ledgerSpread.getActiveSheet(), parseInt(obj.value));
 
-                             changeSpreadObj.batchAdd(obj.value);
 
-                             root.$menu.trigger('contextmenu:hide');
 
-                         }
 
-                     },
 
-                 },
 
-                 'delete': {
 
-                     name: '删除',
 
-                     icon: 'fa-remove',
 
-                     callback: function (key, opt) {
 
-                         changeSpreadObj.del();
 
-                     },
 
-                     disabled: function (key, opt) {
 
-                         const selection = changeSpreadSheet.getSelections();
 
-                         const sel = selection ? selection[0] : changeSpreadSheet.getSelections()[0];
 
-                         const row = sel ? sel.row : -1;
 
-                         if (readOnly || row === -1 || sel.row + sel.rowCount > changeSpreadSheet.zh_data.length) {
 
-                             return true;
 
-                         }
 
-                         const first = changeSpreadSheet.zh_data[row];
 
-                         let valid = true;
 
-                         if (sel.rowCount > 1 && first) {
 
-                             for (let r = 1; r < sel.rowCount; r++) {
 
-                                 const rNode = changeSpreadSheet.zh_data[sel.row + r];
 
-                                 if (!rNode || !rNode.id) {
 
-                                     valid = false;
 
-                                     break;
 
-                                 }
 
-                                 if (_.find(changeUsedData, { cbid: rNode.id }) || checkIsSettle(rNode)) {
 
-                                     valid = false;
 
-                                     break;
 
-                                 }
 
-                             }
 
-                         }
 
-                         return !(first && first.id && !_.find(changeUsedData, { cbid: first.id }) && !checkIsSettle(first) && valid);
 
-                     }
 
-                 },
 
-                 sprEdit: '----',
 
-                 'allNotValuation': {
 
-                     name: '设置全部清单不计价',
 
-                     icon: 'fa-magic',
 
-                     callback: function (key, opt) {
 
-                         changeSpreadObj.setAllValuation(0);
 
-                     },
 
-                 },
 
-                 'allValuation': {
 
-                     name: '设置全部清单计价',
 
-                     icon: 'fa-magic',
 
-                     callback: function (key, opt) {
 
-                         changeSpreadObj.setAllValuation(1);
 
-                     },
 
-                 },
 
-             }
 
-         });
 
-         // 右键菜单
 
-         $.contextMenu({
 
-             selector: '#xmj-spread',
 
-             build: function ($trigger, e) {
 
-                 const target = SpreadJsObj.safeRightClickSelection($trigger, e, xmjSpread);
 
-                 return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
 
-             },
 
-             items: {
 
-                 'delete': {
 
-                     name: '删除',
 
-                     icon: 'fa-remove',
 
-                     callback: function (key, opt) {
 
-                         xmjSpreadObj.del();
 
-                     },
 
-                     disabled: function (key, opt) {
 
-                         const selection = xmjSheet.getSelections();
 
-                         const sel = selection ? selection[0] : xmjSheet.getSelections()[0];
 
-                         const row = sel && sel.row !== undefined ? sel.row : -1;
 
-                         if (readOnly || row === -1 || sel.row + sel.rowCount > xmjSheet.zh_data.length) {
 
-                             return true;
 
-                         }
 
-                         let isUsed = false;
 
-                         for (let r = 0; r < sel.rowCount; r++) {
 
-                             const select = xmjSheet.zh_data[row + r];
 
-                             if(!select || _.find(changeUsedData, { cbid: select.id })) {
 
-                                 isUsed = true;
 
-                             }
 
-                             if (checkIsSettle(select)) {
 
-                                 isUsed = true;
 
-                             }
 
-                         }
 
-                         return isUsed;
 
-                     }
 
-                 },
 
-                 // sprEdit: '----',
 
-                 // 'allNotValuation': {
 
-                 //     name: '设置全部清单不计价',
 
-                 //     icon: 'fa-magic',
 
-                 //     callback: function (key, opt) {
 
-                 //         changeSpreadObj.setAllValuation(0);
 
-                 //     },
 
-                 // },
 
-                 // 'allValuation': {
 
-                 //     name: '设置全部清单计价',
 
-                 //     icon: 'fa-magic',
 
-                 //     callback: function (key, opt) {
 
-                 //         changeSpreadObj.setAllValuation(1);
 
-                 //     },
 
-                 // },
 
-             }
 
-         });
 
-     }
 
-     const ledgerSpread = SpreadJsObj.createNewSpread($('#ledger-spread')[0]);
 
-     const ledgerSheet = ledgerSpread.getActiveSheet();
 
-     const ledgerSpreadSetting = {
 
-         cols: [
 
-             {title: '计价', colSpan: '1', rowSpan: '2', field: 'is_valuation', hAlign: 1, width: 50, cellType: 'checkbox', getValue: 'getValue.is_valuation', readOnly: 'readOnly.isValuation'},
 
-             {title: '项目节编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 120, formatter: '@', readOnly: true, cellType: 'tree' },
 
-             {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 80, formatter: '@', readOnly: 'readOnly.isEdit2'},
 
-             {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 120, formatter: '@', readOnly: 'readOnly.isEdit2'},
 
-             {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', readOnly: 'readOnly.isEdit2', cellType: 'unit', comboItems: changeUnits, comboEdit: true},
 
-             {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.unit_price', readOnly: 'readOnly.isEdit2'},
 
-             {title: '变更详情', colSpan: '1', rowSpan: '2', field: 'detail', hAlign: 0, width: 120, formatter: '@', readOnly: 'readOnly.isEdit'},
 
-             {title: '计量上限(%)', colSpan: '1', rowSpan: '2', field: 'delimit', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isEdit', visible: openChangeState},
 
-             {title: '原设计|数量', colSpan: '2|1', rowSpan: '1|1', field: 'oamount2', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isSettle', getValue: 'getValue.oamount2'},
 
-             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'oa_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.oa_tp'},
 
-             {title: '申请变更增(+)减(-)|数量', colSpan: '2|1', rowSpan: '1|1', field: 'camount', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isSettle2', getValue: 'getValue.camount'},
 
-             {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'ca_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.ca_tp'},
 
-         ],
 
-         emptyRows: 0,
 
-         headRows: 2,
 
-         headRowHeight: [25, 25],
 
-         defaultRowHeight: 21,
 
-         headerFont: '12px 微软雅黑',
 
-         font: '12px 微软雅黑',
 
-         // readOnly: true,
 
-         rowHeader:[
 
-             {
 
-                 rowHeaderType: 'circle',
 
-                 setting: {
 
-                     size: 5,
 
-                     indent: 16,
 
-                     getColor: function (index, data) {
 
-                         if (!data) return;
 
-                         if ((!data.clid && data.cid) || (data.clid && data.gcl_id && _.findIndex(changeLedgerList, { id: data.gcl_id }) !== -1)) {
 
-                             return '#dc3545';
 
-                         }
 
-                         if (data.lid == 0) {
 
-                             return '#007bff';
 
-                         }
 
-                         if (data.clid && data.gcl_id) {
 
-                             return '#28a745';
 
-                         }
 
-                         if (data.clid && !data.gcl_id && data.lid != 0) {
 
-                             return '#ffc107';
 
-                         }
 
-                         if(data.lid != 0) return;
 
-                         return '#007bff';
 
-                     }
 
-                 },
 
-             },
 
-         ],
 
-         // localCache: {
 
-         //     key: 'changes-ledger-spread',
 
-         //     colWidth: true,
 
-         // }
 
-     };
 
-     if (readOnly) {
 
-         ledgerSpreadSetting.cols.push({title: '批复变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'samount', hAlign: 2, width: 60, type: 'Number', readOnly: true, getValue: 'getValue.samount'});
 
-         ledgerSpreadSetting.cols.push({title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'sa_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.sa_tp'});
 
-         for (const aid of aidList) {
 
-             // const userinfo = _.find(auditList2, { 'uid': aid });
 
-             const audit = _.find(auditors2, function(item){
 
-                 return _.findIndex(item, { audit_order: aid }) !== -1;
 
-             });
 
-             const newColcount = {
 
-                 title: (audit && audit.length > 1 ? (aid + '审') : audit[0].name) + ' 审批|数量',
 
-                 colSpan: '2|1', rowSpan: '1|1',
 
-                 field: 'audit_amount_' + aid,
 
-                 hAlign: 2, width: 60, type: 'Number', readOnly: _.findIndex(audit, { uid: parseInt(accountId) }) === -1 ? true : 'readOnly.isSettle',
 
-             };
 
-             const newColTp = {
 
-                 title: '|金额',
 
-                 colSpan: '|1', rowSpan: '|1',
 
-                 field: 'sa_tp_' + aid,
 
-                 hAlign: 2, width: 80, type: 'Number',
 
-             };
 
-             ledgerSpreadSetting.cols.push(newColcount);
 
-             ledgerSpreadSetting.cols.push(newColTp);
 
-         }
 
-     }
 
-     ledgerSpreadSetting.cols.push({title: '变更后|数量', colSpan: '2|1', rowSpan: '1|1', field: 'changed_amount', hAlign: 2, width: 60, type: 'Number', readOnly: true, getValue: 'getValue.changed_amount'});
 
-     ledgerSpreadSetting.cols.push({title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'changed_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.changed_tp'});
 
-     const ledgerCol = {
 
-         getValue: {
 
-             is_valuation: function (data) {
 
-                 return data.is_valuation === 1;
 
-             },
 
-             unit_price: function(data) {
 
-                 return ZhCalc.round(data.unit_price, unitPriceUnit);
 
-             },
 
-             oa_tp: function (data) {
 
-                 return data.clid ? ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.oamount2, findDecimal(data.unit))), totalPriceUnit) : data.oa_tp;
 
-             },
 
-             ca_tp: function (data) {
 
-                 return data.clid ? ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.camount, findDecimal(data.unit))), totalPriceUnit) : data.ca_tp;
 
-             },
 
-             oamount2: function (data) {
 
-                 return ZhCalc.round(data.oamount2, findDecimal(data.unit));
 
-             },
 
-             camount: function (data) {
 
-                 return ZhCalc.round(data.camount, findDecimal(data.unit));
 
-             },
 
-             samount: function (data) {
 
-                 return ZhCalc.round(data.samount, findDecimal(data.unit));
 
-             },
 
-             sa_tp: function (data) {
 
-                 return  data.clid ? ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.samount, findDecimal(data.unit))), totalPriceUnit) : data.sa_tp;
 
-             },
 
-             changed_amount: function (data) {
 
-                 return readOnly ? ZhCalc.round(ZhCalc.add(data.oamount2, data.spamount), findDecimal(data.unit)) : ZhCalc.round(ZhCalc.add(data.oamount2, data.camount), findDecimal(data.unit));
 
-             },
 
-             changed_tp: function (data) {
 
-                 return data.clid ? ZhCalc.add(ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.oamount2, findDecimal(data.unit))), totalPriceUnit),
 
-                     ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.camount, findDecimal(data.unit))), totalPriceUnit)) : data.changed_tp;
 
-             },
 
-         },
 
-         readOnly: {
 
-             isEdit: function (data) {
 
-                 return !(!readOnly && data.clid);
 
-             },
 
-             isEdit2: function (data) {
 
-                 return !(!readOnly && data.lid == 0 && data.clid);
 
-             },
 
-             isValuation: function (data) {
 
-                 return !(!readOnly && data.clid && _.findIndex(changeUsedData, { cbid: data.clid }) !== -1);
 
-             },
 
-             isSettle: function (data) {
 
-                 return !((!readOnly || shenpiPower) && data.clid && !checkIsSettle(data));
 
-             },
 
-             isSettle2: function (data) {
 
-                 return !(!readOnly && data.clid && !checkIsSettle(data));
 
-             }
 
-         },
 
-     };
 
-     sjsSettingObj.setFxTreeStyle(ledgerSpreadSetting, sjsSettingObj.FxTreeStyle.jz);
 
-     SpreadJsObj.initSpreadSettingEvents(ledgerSpreadSetting, ledgerCol);
 
-     SpreadJsObj.initSheet(ledgerSheet, ledgerSpreadSetting);
 
-     // 初始化 节点树结构
 
-     const treeSetting = {
 
-         id: 'ledger_id',
 
-         pid: 'ledger_pid',
 
-         order: 'order',
 
-         level: 'level',
 
-         rootId: -1,
 
-         keys: ['id', 'tender_id', 'ledger_id'],
 
-         calcFields: ['oa_tp', 'ca_tp', 'sa_tp', 'changed_tp', 'total_price'],
 
-         autoExpand: 3,
 
-         markExpandKey: 'change-bills-expand',
 
-         markExpandSubKey: window.location.pathname.split('/')[2],
 
-     };
 
-     if (readOnly) {
 
-         for (const aid of aidList) {
 
-             treeSetting.calcFields.push('sa_tp_' + aid);
 
-         }
 
-     }
 
-     treeSetting.calcFun = function (node) {
 
-         if (node && node.b_code) {
 
-             const posData = pos.getLedgerPos(node.id) || [];
 
-             if (!node.clid && posData.length > 0) {
 
-                 let is_valuation = 1;
 
-                 let oamount2 = 0;
 
-                 let camount = 0;
 
-                 let samount = 0;
 
-                 let spamount = 0;
 
-                 if (readOnly) {
 
-                     for (const aid of aidList) {
 
-                         let audit_amount = 0;
 
-                         for (const np of posData) {
 
-                             audit_amount = ZhCalc.add(audit_amount, ZhCalc.round(np['audit_amount_' + aid], findDecimal(node.unit)));
 
-                         }
 
-                         if (!_.isEqual(node['audit_amount_' + aid], audit_amount)) {
 
-                             node['audit_amount_' + aid] = audit_amount;
 
-                             node['sa_tp_' + aid] = ZhCalc.round(ZhCalc.mul(audit_amount, ZhCalc.round(node.unit_price, unitPriceUnit)), totalPriceUnit);
 
-                         }
 
-                     }
 
-                 }
 
-                 for (const np of posData) {
 
-                     oamount2 = ZhCalc.add(oamount2, ZhCalc.round(np.oamount2, findDecimal(node.unit)));
 
-                     camount = ZhCalc.add(camount, ZhCalc.round(np.camount, findDecimal(node.unit)));
 
-                     samount = ZhCalc.add(samount, ZhCalc.round(np.samount, findDecimal(node.unit)));
 
-                     spamount = ZhCalc.add(spamount, ZhCalc.round(np.spamount, findDecimal(node.unit)));
 
-                     if (np.is_valuation === 0) is_valuation = 0;
 
-                 }
 
-                 if (!_.isEqual(node.oamount2, oamount2) || !_.isEqual(node.camount, camount) || !_.isEqual(node.samount, samount)) {
 
-                     node.oamount2 = oamount2;
 
-                     node.camount = camount;
 
-                     node.samount = samount;
 
-                     node.spamount = spamount;
 
-                     node.change_amount = ZhCalc.add(oamount2, camount);
 
-                     node.oa_tp = ZhCalc.round(ZhCalc.mul(oamount2, ZhCalc.round(node.unit_price, unitPriceUnit)), totalPriceUnit) || 0;
 
-                     node.ca_tp = ZhCalc.round(ZhCalc.mul(camount, ZhCalc.round(node.unit_price, unitPriceUnit)), totalPriceUnit) || 0;
 
-                     node.sa_tp = ZhCalc.round(ZhCalc.mul(samount, ZhCalc.round(node.unit_price, unitPriceUnit)), totalPriceUnit) || 0;
 
-                     const spa_tp = ZhCalc.round(ZhCalc.mul(spamount, ZhCalc.round(node.unit_price, unitPriceUnit)), totalPriceUnit) || 0;
 
-                     node.changed_tp = readOnly ? ZhCalc.add(node.oa_tp, spa_tp) || 0 :  ZhCalc.add(node.oa_tp, node.ca_tp) || 0;
 
-                 }
 
-                 node.is_valuation = is_valuation;
 
-             } else if (node.clid) {
 
-                 // node.oamount2 = ZhCalc.round(node.oamount2, findDecimal(node.unit));
 
-                 // node.camount = ZhCalc.round(node.camount, findDecimal(node.unit));
 
-                 // node.change_amount = ZhCalc.add(node.oamount2, node.camount);
 
-                 node.oa_tp = ZhCalc.round(ZhCalc.mul(node.oamount2, ZhCalc.round(node.unit_price, unitPriceUnit)), totalPriceUnit) || 0;
 
-                 node.ca_tp = ZhCalc.round(ZhCalc.mul(node.camount, ZhCalc.round(node.unit_price, unitPriceUnit)), totalPriceUnit) || 0;
 
-                 node.sa_tp = ZhCalc.round(ZhCalc.mul(node.samount, ZhCalc.round(node.unit_price, unitPriceUnit)), totalPriceUnit) || 0;
 
-                 const spa_tp = ZhCalc.round(ZhCalc.mul(node.spamount, ZhCalc.round(node.unit_price, unitPriceUnit)), totalPriceUnit) || 0;
 
-                 node.changed_tp = readOnly ? ZhCalc.add(node.oa_tp, spa_tp) || 0 : ZhCalc.add(node.oa_tp, node.ca_tp) || 0;
 
-                 if (readOnly) {
 
-                     for (const aid of aidList) {
 
-                         node['sa_tp_' + aid] = ZhCalc.round(ZhCalc.mul(node['audit_amount_' + aid], ZhCalc.round(node.unit_price, unitPriceUnit)), totalPriceUnit) || 0;
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-     };
 
-     const ledgerTree = createNewPathTree('revise', treeSetting);
 
-     const ledgerTreeSpreadObj = {
 
-         loadExprToInput: function () {
 
-             const sel = ledgerSheet.getSelections()[0];
 
-             if (!sel) return;
 
-             const col = ledgerSheet.zh_setting.cols[sel.col];
 
-             const data = SpreadJsObj.getSelectObject(ledgerSheet);
 
-             if (col && col.field === 'camount' && data && data.clid) {
 
-                 if (!readOnly) {
 
-                     $('#ledger-camount-expr').removeAttr('readonly').val(data.camount_expr ? data.camount_expr : data.camount);
 
-                 } else {
 
-                     $('#ledger-camount-expr').attr('readonly', true).val(data.camount_expr ? data.camount_expr : data.camount);
 
-                 }
 
-             } else {
 
-                 $('#ledger-camount-expr').attr('readonly', true).val('');
 
-             }
 
-         },
 
-         showHideAudit: function (show = false) {
 
-             if (shenpiPower) {
 
-                 show = true;
 
-             }
 
-             if (readOnly) {
 
-                 const count = ledgerSpreadSetting.cols.length;
 
-                 for (let i = startLimit + 5; i < count - 2; i++) {
 
-                     ledgerSheet.setColumnVisible(i, show, GC.Spread.Sheets.SheetArea.viewport);
 
-                 }
 
-                 ledgerSheet.setColumnVisible(startLimit + 3, !show, GC.Spread.Sheets.SheetArea.viewport);
 
-                 ledgerSheet.setColumnVisible(startLimit + 4, !show, GC.Spread.Sheets.SheetArea.viewport);
 
-             }
 
-         },
 
-         /**
 
-          *
 
-          * @param sheet
 
-          * @param data
 
-          */
 
-         refreshTree: function (sheet, data) {
 
-             SpreadJsObj.massOperationSheet(sheet, function () {
 
-                 const tree = sheet.zh_tree;
 
-                 // 处理删除
 
-                 if (data.delete) {
 
-                     data.delete.sort(function (a, b) {
 
-                         return b.deleteIndex - a.deleteIndex;
 
-                     });
 
-                     for (const d of data.delete) {
 
-                         sheet.deleteRows(d.deleteIndex, 1);
 
-                     }
 
-                 }
 
-                 // 处理新增
 
-                 if (data.create) {
 
-                     const newNodes = data.create;
 
-                     if (newNodes) {
 
-                         newNodes.sort(function (a, b) {
 
-                             return a.index - b.index;
 
-                         });
 
-                         for (const node of newNodes) {
 
-                             sheet.addRows(node.index, 1);
 
-                             SpreadJsObj.reLoadRowData(sheet, tree.nodes.indexOf(node), 1);
 
-                         }
 
-                     }
 
-                 }
 
-                 // 处理更新
 
-                 if (data.update) {
 
-                     const rows = [];
 
-                     for (const u of data.update) {
 
-                         rows.push(tree.nodes.indexOf(u));
 
-                     }
 
-                     SpreadJsObj.reLoadRowsData(sheet, rows);
 
-                 }
 
-                 // 处理展开
 
-                 if (data.expand) {
 
-                     const expanded = [];
 
-                     for (const e of data.expand) {
 
-                         if (expanded.indexOf(e) === -1) {
 
-                             const posterity = tree.getPosterity(e);
 
-                             for (const p of posterity) {
 
-                                 sheet.setRowVisible(tree.nodes.indexOf(p), p.visible);
 
-                                 expanded.push(p);
 
-                             }
 
-                         }
 
-                     }
 
-                 }
 
-             });
 
-         },
 
-         topRowChanged: function (e, info) {
 
-             SpreadJsObj.saveTopAndSelect(info.sheet, ckBillsSpread);
 
-         },
 
-         selectionChanged: function (e, info) {
 
-             if (info.newSelections) {
 
-                 if (!info.oldSelections || info.newSelections[0].row !== info.oldSelections[0].row || info.newSelections[0].rowCount !== info.oldSelections[0].rowCount) {
 
-                     // ledgerTreeSpreadObj.refreshOperationValid(info.sheet);
 
-                     ledgerTreeSpreadObj.refreshPosData();
 
-                 }
 
-             }
 
-             ledgerTreeSpreadObj.loadExprToInput(info.sheet);
 
-         },
 
-         refreshPosData: function() {
 
-             SpreadJsObj.resetTopAndSelect(posSheet);
 
-             posSpreadObj.loadCurPosData();
 
-             SpreadJsObj.saveTopAndSelect(ledgerSheet, ckBillsSpread);
 
-             // posSearch.search($('#pos-keyword').val());
 
-         },
 
-         getDefaultSelectInfo: function (sheet) {
 
-             const tree = sheet.zh_tree;
 
-             if (!tree) return;
 
-             const sel = sheet.getSelections()[0];
 
-             const node = sheet.zh_tree.nodes[sel.row];
 
-             if (!node) return;
 
-             let count = 1;
 
-             if (sel.rowCount > 1) {
 
-                 for (let r = 1; r < sel.rowCount; r++) {
 
-                     const rNode = sheet.zh_tree.nodes[sel.row + r];
 
-                     if (rNode.level > node.level) continue;
 
-                     if ((rNode.level < node.level) || (rNode.level === node.level && rNode.pid !== node.pid)) {
 
-                         toastr.warning('请选择同一节点下的节点,进行该操作');
 
-                         return;
 
-                     }
 
-                     count += 1;
 
-                 }
 
-             }
 
-             return [tree, node, count];
 
-         },
 
-         _checkExprValid(expr) {
 
-             if (!expr) return [true, null];
 
-             const param = [];
 
-             let num = '', base = '';
 
-             for (let i = 0, iLen = expr.length; i < iLen; i++) {
 
-                 if (/^[\d\.%]+/.test(expr[i])) {
 
-                     if (base !== '') {
 
-                         param.push({type: 'base', value: base});
 
-                         base = '';
 
-                     }
 
-                     num = num + expr[i];
 
-                 } else if (expr[i] === '(') {
 
-                     if (num !== '') {
 
-                         param.push({type: 'num', value: num});
 
-                         num = '';
 
-                     }
 
-                     if (base !== '') {
 
-                         param.push({type: 'base', value: base});
 
-                         base = '';
 
-                     }
 
-                     param.push({type: 'left', value: '('});
 
-                 } else if (expr[i] === ')') {
 
-                     if (num !== '') {
 
-                         param.push({type: 'num', value: num});
 
-                         num = '';
 
-                     }
 
-                     if (base !== '') {
 
-                         param.push({type: 'base', value: base});
 
-                         base = '';
 
-                     }
 
-                     param.push({type: 'right', value: ')'});
 
-                 } else if (/^[\+\-*\/]/.test(expr[i])) {
 
-                     if (num !== '') {
 
-                         param.push({type: 'num', value: num});
 
-                         num = '';
 
-                     }
 
-                     if (base !== '') {
 
-                         param.push({type: 'base', value: base});
 
-                         base = '';
 
-                     }
 
-                     param.push({type: 'calc', value: expr[i]});
 
-                 } else {
 
-                     return [false, '输入的表达式含有非法字符: ' + expr[i]];
 
-                 }
 
-             }
 
-             if (num !== '') {
 
-                 param.push({type: 'num', value: num});
 
-                 num = '';
 
-             }
 
-             if (base !== '') {
 
-                 param.push({type: 'base', value: base});
 
-                 base = '';
 
-             }
 
-             if (param.length === 0) return true;
 
-             if (param.length > 1) {
 
-                 if (param[0].value === '-' && param[1].type === 'num') {
 
-                     param[1].value = '-' + param[1].value;
 
-                     param.shift();
 
-                 }
 
-             }
 
-             const iLen = param.length;
 
-             let iLeftCount = 0, iRightCount = 0;
 
-             for (const [i, p] of param.entries()) {
 
-                 if (p.type === 'calc') {
 
-                     if (i === 0 || i === iLen - 1)
 
-                         return [false, '输入的表达式非法:计算符号' + p.value + '前后应有数字'];
 
-                 }
 
-                 if (p.type === 'num') {
 
-                     num = p.value.replace('%', '');
 
-                     if (p.value.length - num.length > 1)
 
-                         return [false, '输入的表达式非法:' + p.value + '不是一个有效的数字'];
 
-                     num = _.toNumber(num);
 
-                     if (num === undefined || num === null || _.isNaN(num))
 
-                         return [false, '输入的表达式非法:' + p.value + '不是一个有效的数字'];
 
-                     if (i > 0) {
 
-                         if (param[i - 1].type !== 'calc' && param[i - 1].type !== 'left') {
 
-                             return [false, '输入的表达式非法:' + p.value + '前应有运算符'];
 
-                         } else if (param[i - 1].value === '/' && num === 0) {
 
-                             return [false, '输入的表达式非法:请勿除0'];
 
-                         }
 
-                     }
 
-                 }
 
-                 if (p.type === 'base') {
 
-                     if (i > 0 && (param[i - 1].type === 'num' || param[i - 1].type === 'right'))
 
-                         return [false, '输入的表达式非法:' + p.value + '前应有运算符'];
 
-                 }
 
-                 if (p.type === 'left') {
 
-                     iLeftCount += 1;
 
-                     if (i !== 0 && param[i-1].type !== 'calc')
 
-                         return [false, '输入的表达式非法:(前应有运算符'];
 
-                 }
 
-                 if (p.type === 'right') {
 
-                     iRightCount += 1;
 
-                     if (i !== iLen - 1 && param[i+1].type !== 'calc')
 
-                         return [false, '输入的表达式非法:)后应有运算符'];
 
-                     if (iRightCount > iLeftCount)
 
-                         return [false, '输入的表达式非法:")"前无对应的"("'];
 
-                 }
 
-             }
 
-             if (iLeftCount > iRightCount)
 
-                 return [false, '输入的表达式非法:"("后无对应的")"'];
 
-             return [true, ''];
 
-         },
 
-         _checkExpr: function (text, data) {
 
-             if (text) {
 
-                 const num = _.toNumber(text);
 
-                 if (num) {
 
-                     data.quantity = num;
 
-                     data.expr = '';
 
-                 } else {
 
-                     const expr = $.trim(text).replace('\t', '').replace('=', '').toLowerCase();
 
-                     const [valid, msg] = this._checkExprValid(expr);
 
-                     if (!valid) return [valid, msg];
 
-                     data.expr = expr;
 
-                     data.quantity = ZhCalc.calcExpr.calcExprStrRpn(expr.replace(new RegExp('%', 'gm'), '/100'));
 
-                     // const ce = new CalcEvalMin();
 
-                     // data.quantity = ce.eval(expr);
 
-                     // console.log(data.quantity);
 
-                 }
 
-             } else {
 
-                 data.quantity = 0;
 
-                 data.expr = '';
 
-             }
 
-             return [true, ''];
 
-         },
 
-     }
 
-     ledgerSpread.bind(spreadNS.Events.SelectionChanged, ledgerTreeSpreadObj.selectionChanged);
 
-     ledgerSpread.bind(spreadNS.Events.topRowChanged, ledgerTreeSpreadObj.topRowChanged);
 
-     // 初始化 计量单元
 
-     const pos = new PosData({ id: 'id', ledgerId: 'lid' });
 
-     const posSpread = SpreadJsObj.createNewSpread($('#pos-spread')[0]);
 
-     const posSheet = posSpread.getActiveSheet();
 
-     const posSpreadSetting = {
 
-         cols: [
 
-             {title: '计价', colSpan: '1', rowSpan: '2', field: 'is_valuation', hAlign: 1, width: 50, cellType: 'checkbox', readOnly: 'readOnly.isValuation'},
 
-             {title: '计量单元', colSpan: '1', rowSpan: '2', field: 'bwmx', hAlign: 0, width: 120, formatter: '@', readOnly: true},
 
-             {title: '变更详情', colSpan: '1', rowSpan: '2', field: 'detail', hAlign: 0, width: 120, formatter: '@', readOnly: 'readOnly.isEdit'},
 
-             {title: '计量上限(%)', colSpan: '1', rowSpan: '2', field: 'delimit', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isSettle2', visible: openChangeState},
 
-             {title: '原设计|数量', colSpan: '1|1', rowSpan: '|1', field: 'oamount2', hAlign: 2, width: 120, type: 'Number', readOnly: 'readOnly.isSettle', getValue: 'getValue.oamount2'},
 
-             {title: '申请变更增(+)减(-)|数量', colSpan: '1|1', rowSpan: '|1', field: 'camount', hAlign: 2, width: 120, readOnly: 'readOnly.isSettle2', getValue: 'getValue.camount'},
 
-         ],
 
-         emptyRows: 0,
 
-         headRows: 2,
 
-         headRowHeight: [25, 25],
 
-         defaultRowHeight: 21,
 
-         headerFont: '12px 微软雅黑',
 
-         font: '12px 微软雅黑',
 
-         rowHeader:[
 
-             {
 
-                 rowHeaderType: 'circle',
 
-                 setting: {
 
-                     size: 5,
 
-                     indent: 16,
 
-                     getColor: function (index, data) {
 
-                         if (!data) return;
 
-                         if (_.findIndex(changeLedgerList, { id: data.gcl_id }) !== -1 || _.findIndex(changePosList, { id: data.mx_id }) !== -1) {
 
-                             return '#dc3545';
 
-                         }
 
-                         if(data.lid != 0) return;
 
-                         return '#007bff';
 
-                     }
 
-                 },
 
-             },
 
-         ],
 
-     };
 
-     if (readOnly) {
 
-         posSpreadSetting.cols.push({title: '批复变更|数量', colSpan: '1|1', rowSpan: '|1', field: 'samount', hAlign: 2, width: 120, type: 'Number', readOnly: true, getValue: 'getValue.samount'});
 
-         for (const aid of aidList) {
 
-             // const userinfo = _.find(auditList2, { 'uid': aid });
 
-             const audit = _.find(auditors2, function(item){
 
-                 return _.findIndex(item, { audit_order: aid }) !== -1;
 
-             });
 
-             const newColcount = {
 
-                 title: (audit && audit.length > 1 ? (aid + '审') : audit[0].name) + ' 审批|数量',
 
-                 colSpan: '1|1', rowSpan: '|1',
 
-                 field: 'audit_amount_' + aid,
 
-                 hAlign: 2, width: 120, type: 'Number', readOnly: _.findIndex(audit, { uid: parseInt(accountId) }) === -1 ? true : 'readOnly.isSettle' ,
 
-             };
 
-             posSpreadSetting.cols.push(newColcount);
 
-         }
 
-     }
 
-     posSpreadSetting.cols.push({title: '变更后|数量', colSpan: '1|1', rowSpan: '|1', field: 'changed_amount', hAlign: 2, width: 120, type: 'Number', readOnly: true, getValue: 'getValue.changed_amount'},);
 
-     const posCol = {
 
-         getValue: {
 
-             oamount2: function (data) {
 
-                 return ZhCalc.round(data.oamount2, findDecimal(data.unit));
 
-             },
 
-             camount: function (data) {
 
-                 return ZhCalc.round(data.camount, findDecimal(data.unit));
 
-             },
 
-             samount: function (data) {
 
-                 return ZhCalc.round(data.samount, findDecimal(data.unit));
 
-             },
 
-             changed_amount: function (data) {
 
-                 return readOnly ? ZhCalc.round(ZhCalc.add(data.oamount2, data.spamount), findDecimal(data.unit)) : ZhCalc.round(ZhCalc.add(data.oamount2, data.camount), findDecimal(data.unit));
 
-             },
 
-         },
 
-         readOnly: {
 
-             isEdit: function (data) {
 
-                 return readOnly;
 
-             },
 
-             isValuation: function (data) {
 
-                 return !(!readOnly && _.findIndex(changeUsedData, { cbid: data.clid }) !== -1);
 
-             },
 
-             isSettle: function (data) {
 
-                 return !((!readOnly || shenpiPower) && !checkIsSettle(data));
 
-             },
 
-             isSettle2: function (data) {
 
-                 return !(!readOnly && !checkIsSettle(data));
 
-             }
 
-         },
 
-     }
 
-     sjsSettingObj.setGridSelectStyle(posSpreadSetting);
 
-     SpreadJsObj.initSpreadSettingEvents(posSpreadSetting, posCol);
 
-     SpreadJsObj.initSheet(posSheet, posSpreadSetting);
 
-     // 计量单元 相关方法&绑定spreadjs事件
 
-     const posSpreadObj = {
 
-         loadExprToInput: function () {
 
-             const sel = posSheet.getSelections()[0];
 
-             if (!sel) return;
 
-             const col = posSheet.zh_setting.cols[sel.col];
 
-             const data = SpreadJsObj.getSelectObject(posSheet);
 
-             if (col && col.field === 'camount' && data) {
 
-                 if (readOnly) {
 
-                     $('#pos-camount-expr').val(data.camount_expr ? data.camount_expr : data.camount);
 
-                 } else {
 
-                     $('#pos-camount-expr').removeAttr('readonly').val(data.camount_expr ? data.camount_expr : data.camount);
 
-                 }
 
-             } else {
 
-                 $('#pos-camount-expr').attr('readonly', true).val('');
 
-             }
 
-         },
 
-         /**
 
-          * 加载计量单元 根据当前台账选择节点
 
-          */
 
-         loadCurPosData: function () {
 
-             const node = SpreadJsObj.getSelectObject(ledgerSheet);
 
-             if (node) {
 
-                 const posData = pos.getLedgerPos(node.id) || [];
 
-                 console.log(posData);
 
-                 SpreadJsObj.loadSheetData(posSheet, 'data', posData);
 
-             } else {
 
-                 SpreadJsObj.loadSheetData(posSheet, 'data', []);
 
-             }
 
-             posSpreadObj.showHideAudit($('#show-table-detail').is(':checked'));
 
-             SpreadJsObj.resetTopAndSelect(posSheet);
 
-             posSpreadObj.loadExprToInput();
 
-         },
 
-         selectionChanged: function (e, info) {
 
-             posSpreadObj.loadExprToInput();
 
-         },
 
-         showHideAudit: function (show = false) {
 
-             if (shenpiPower) {
 
-                 show = true;
 
-             }
 
-             if (readOnly) {
 
-                 const posStartLimit = 4;
 
-                 const count = posSpreadSetting.cols.length;
 
-                 for (let i = posStartLimit + 2; i < count - 1; i++) {
 
-                     posSheet.setColumnVisible(i, show, GC.Spread.Sheets.SheetArea.viewport);
 
-                 }
 
-                 posSheet.setColumnVisible(posStartLimit + 2, !show, GC.Spread.Sheets.SheetArea.viewport);
 
-             }
 
-         },
 
-     }
 
-     posSpread.bind(spreadNS.Events.SelectionChanged, posSpreadObj.selectionChanged);
 
-     if (!readOnly) {
 
-         // 台账修改
 
-         ledgerTreeSpreadObj.del = function () {
 
-             const self = this;
 
-             const [tree, node, count] = this.getDefaultSelectInfo(ledgerSheet);
 
-             if (!tree || !node || !count) return;
 
-             const delList = [];
 
-             let lastSelect = null;
 
-             let hadTaiZhang = false;
 
-             const selects = [];
 
-             const parent = tree.getParent(node);
 
-             const children = parent ? parent.children : tree.children;
 
-             const index = children.indexOf(node);
 
-             for (let r = 0; r < count; r++) {
 
-                 const select = children[r+index];
 
-                 if (!select || _.find(changeUsedData, { cbid: select.clid })) {
 
-                     toastr.error('已调用的变更清单不能删除');
 
-                     return false;
 
-                 }
 
-                 if (checkIsSettle(select)) {
 
-                     toastr.error('已结算的变更清单不能删除');
 
-                     return false;
 
-                 }
 
-                 if (r === count - 1 && changeOrder) {
 
-                     lastSelect = select;
 
-                 }
 
-                 if (select.lid != 0) {
 
-                     hadTaiZhang = true;
 
-                 }
 
-                 delList.push(select.clid);
 
-                 selects.push(select);
 
-             }
 
-             if (delList.length) {
 
-                 postData(window.location.pathname + '/save', {type: 'del', ids: delList, postData: lastSelect ? lastSelect.order : null}, function (result) {
 
-                     const loadResult = {
 
-                         delete: selects,
 
-                     }
 
-                     // 判断父节点是否也要移除
 
-                     if (children.length === count) {
 
-                         loadResult.delete.push(parent);
 
-                         const parentNodes = _.reverse(ledgerTree.getAllParents(parent));
 
-                         for (const node of parentNodes) {
 
-                             if (node.children && node.children.length === 1) {
 
-                                 loadResult.delete.push(node);
 
-                             } else {
 
-                                 break;
 
-                             }
 
-                         }
 
-                     }
 
-                     const refreshData = ledgerTree.loadPostData(loadResult);
 
-                     ledgerTreeSpreadObj.refreshTree(ledgerSheet, refreshData);
 
-                     ledgerSheet.setSelection(0, 0, 1, 1);
 
-                     ledgerTreeSpreadObj.refreshPosData();
 
-                 });
 
-             }
 
-         };
 
-         ledgerTreeSpreadObj.editStarting = function (e, info) {
 
-             const select = SpreadJsObj.getSelectObject(ledgerSheet);
 
-             const col = info.sheet.zh_setting.cols[info.col];
 
-             if (col.field === 'camount') {
 
-                 if (select.camount_expr && select.camount_expr !== '') {
 
-                     info.sheet.getCell(info.row, info.col).text(select.camount_expr);
 
-                 }
 
-             }
 
-         };
 
-         ledgerTreeSpreadObj.editEnded = function (e, info) {
 
-             if (!info.sheet.zh_setting) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const col = info.sheet.zh_setting.cols[info.col];
 
-             if (col.field === 'is_valuation') {
 
-                 return;
 
-             }
 
-             const sortData = info.sheet.zh_dataType === 'tree' ? info.sheet.zh_tree.nodes : info.sheet.zh_data;
 
-             const select = sortData[info.row];
 
-             if (!select || !select.clid) {
 
-                 toastr.error('数据错误,请刷新页面重试');
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const cInfo = _.find(changeList, { id: select.clid });
 
-             if (!cInfo) {
 
-                 toastr.error('数据错误,请刷新页面重试');
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             let validText = is_numeric(info.editingText) && _.indexOf(numField, col.field) !== -1 ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : '');
 
-             let orgValue;
 
-             if (col.field === 'camount') {
 
-                 orgValue = validText && validText !== ''
 
-                     ? (_.toNumber(validText) ? select.camount : select.camount_expr)
 
-                     : (select.camount_expr && select.camount_expr !== '' ? select.camount_expr : select.camount);
 
-             } else {
 
-                 orgValue = select[col.field];
 
-             }
 
-             if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === '' || validText === null))) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             if(col.field === 'camount') {
 
-                 const exprQuantity = {
 
-                     expr: '',
 
-                     quantity: 0,
 
-                 };
 
-                 const [valid, msg] = ledgerTreeSpreadObj._checkExpr(validText, exprQuantity);
 
-                 if (!valid) {
 
-                     toastr.error(msg);
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 if (isNaN(exprQuantity.quantity)) {
 
-                     toastr.error('不能输入其它非数字类型字符');
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 validText = parseFloat(exprQuantity.quantity);
 
-                 // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
 
-                 const usedInfo = _.find(changeUsedData, { cbid: select.clid });
 
-                 if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
 
-                     toastr.error('清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 } else if (usedInfo && usedInfo.qty < 0  && validText > usedInfo.qty) {
 
-                     toastr.error('清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
 
-                 select.camount_expr = exprQuantity.expr;
 
-                 cInfo.spamount = select.spamount;
 
-                 cInfo.camount_expr = exprQuantity.expr;
 
-             }
 
-             if (col.type === 'Number') {
 
-                 if (isNaN(validText)) {
 
-                     toastr.error('不能输入其它非数字类型字符');
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 if (col.field === 'unit_price') {
 
-                     validText = ZhCalc.round(validText, unitPriceUnit);
 
-                 } else {
 
-                     validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
 
-                 }
 
-                 if (col.field === 'delimit') {
 
-                     const reg = /^(\d{1,2}|100)$/;
 
-                     if (!(_.isNumber(validText) && reg.test(validText))) {
 
-                         toastr.error('计量上限默认值只能输入0-100之间的整数');
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                         return;
 
-                     }
 
-                     // 需要判断是否已调用,已调用的则不能低于原有值大小
 
-                     const usedInfo = _.find(changeUsedData, { cbid: select.clid });
 
-                     if (usedInfo && usedInfo.qty) {
 
-                         const minLimit = Math.ceil(ZhCalc.mul(ZhCalc.div(usedInfo.qty, select.camount), 100));
 
-                         if (validText < minLimit) {
 
-                             toastr.error('计量上限值至少大于等于 ' + minLimit);
 
-                             SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                             return;
 
-                         }
 
-                     }
 
-                 }
 
-             }
 
-             if (col.field === 'unit') {
 
-                 select.camount = ZhCalc.round(select.camount, findDecimal(validText)) || 0;
 
-                 select.oamount2 = ZhCalc.round(select.oamount2, findDecimal(validText)) || 0;
 
-                 cInfo.camount = select.camount;
 
-                 cInfo.oamount2 = select.oamount2;
 
-             }
 
-             if (col.field === 'b_code') {
 
-                 cInfo.code = validText;
 
-             } else {
 
-                 cInfo[col.field] = validText;
 
-             }
 
-             cInfo[col.field] = validText;
 
-             select[col.field] = validText;
 
-             console.log(cInfo);
 
-             delete cInfo.waitingLoading;
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/save', { type:'update', updateData: cInfo }, function (result) {
 
-                 const loadResult = {
 
-                     update: [select],
 
-                 };
 
-                 const refreshData = ledgerTree.loadPostData(loadResult);
 
-                 ledgerTreeSpreadObj.refreshTree(ledgerSheet, refreshData);
 
-             }, function () {
 
-                 select[col.field] = orgValue;
 
-                 if (col.field === 'b_code') {
 
-                     cInfo.code = orgValue;
 
-                 } else {
 
-                     cInfo[col.field] = orgValue;
 
-                 }
 
-                 if(col.field === 'camount') {
 
-                     select.spamount = orgValue;
 
-                     cInfo.spamount = orgValue;
 
-                 }
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-             });
 
-         };
 
-         ledgerTreeSpreadObj.clipboardPasted = function (e, info) {
 
-             const tree = info.sheet.zh_tree;
 
-             if (!tree) { return; }
 
-             if (info.sheet.getColumnCount() > info.sheet.zh_setting.cols.length) {
 
-                 info.sheet.setColumnCount(info.sheet.zh_setting.cols.length);
 
-             }
 
-             const hint = {
 
-                 cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
 
-                 numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
 
-                 expr: {type: 'warning', msg: '粘贴了表达式非法,已过滤'},
 
-             };
 
-             const range = info.cellRange;
 
-             const sortData = info.sheet.zh_tree.nodes;
 
-             const selects = [];
 
-             const data = [];
 
-             let needCopyIgnore = !$('#customCheck1').is(':checked');
 
-             let needColAdd = false;
 
-             for (let iRow = 0; iRow < range.rowCount; iRow++) {
 
-                 let bPaste = true;
 
-                 const curRow = range.row + iRow;
 
-                 const node = sortData[curRow];
 
-                 if (!node) {
 
-                     continue;
 
-                 }
 
-                 const cLData = { id: sortData[curRow].clid };
 
-                 const hintRow = range.rowCount >= 1 ? curRow : '';
 
-                 let sameCol = 0;
 
-                 for (let iCol = 0; iCol < range.colCount; iCol++) {
 
-                     const curCol = range.col + iCol;
 
-                     let colSetting = info.sheet.zh_setting.cols[curCol];
 
-                     if ((needColAdd && curCol > 6) || (needCopyIgnore && curCol === 6)) { // 要判断是否已隐藏了变更详情,是则变更详情后面的curCol要+1
 
-                         const newCurCol = curCol + 1;
 
-                         needColAdd = true;
 
-                         colSetting = info.sheet.zh_setting.cols[newCurCol];
 
-                     }
 
-                     if (!colSetting) continue;
 
-                     let validText = info.sheet.getText(curRow, curCol);
 
-                     validText = is_numeric(validText) && _.indexOf(numField, colSetting.field) !== -1 ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : '');
 
-                     let orgValue;
 
-                     if (colSetting.field === 'camount') {
 
-                         orgValue = validText && validText !== ''
 
-                             ? (_.toNumber(validText) ? sortData[curRow].camount : sortData[curRow].camount_expr)
 
-                             : (sortData[curRow].camount_expr && sortData[curRow].camount_expr !== '' ? sortData[curRow].camount_expr : sortData[curRow].camount);
 
-                     } else {
 
-                         orgValue = sortData[curRow][colSetting.field];
 
-                     }
 
-                     if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
 
-                         sameCol++;
 
-                         if (range.colCount === sameCol)  {
 
-                             bPaste = false;
 
-                         }
 
-                         continue;
 
-                     }
 
-                     if(colSetting.field === 'camount') {
 
-                         const exprQuantity = {
 
-                             expr: '',
 
-                             quantity: 0,
 
-                         };
 
-                         const [valid, msg] = ledgerTreeSpreadObj._checkExpr(validText, exprQuantity);
 
-                         if (!valid) {
 
-                             toastMessageUniq(getPasteHint(msg, hintRow));
 
-                             bPaste = false;
 
-                             continue;
 
-                         }
 
-                         if (isNaN(exprQuantity.quantity)) {
 
-                             toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
 
-                             bPaste = false;
 
-                             continue;
 
-                         }
 
-                         validText = parseFloat(exprQuantity.quantity);
 
-                         // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
 
-                         const usedInfo = _.find(changeUsedData, { cbid: sortData[curRow].clid });
 
-                         if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
 
-                             toastr.error(hintRow ? '清单第' + (hintRow+1) + '行变更数值必须大于等于已调用值 ' + usedInfo.qty : '清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
 
-                             bPaste = false;
 
-                             continue;
 
-                         } else if (usedInfo && usedInfo.qty < 0 && validText > usedInfo.qty) {
 
-                             toastr.error(hintRow ? '清单第' + (hintRow+1) + '行变更数值必须小于等于已调用值 ' + usedInfo.qty : '清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
 
-                             bPaste = false;
 
-                             continue;
 
-                         }
 
-                         cLData.camount_expr = exprQuantity.expr;
 
-                         sortData[curRow].camount_expr = exprQuantity.expr;
 
-                     }
 
-                     if (colSetting.type === 'Number') {
 
-                         if (isNaN(validText)) {
 
-                             toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
 
-                             bPaste = false;
 
-                             continue;
 
-                         }
 
-                         if (colSetting.field === 'unit_price') {
 
-                             validText = ZhCalc.round(validText, unitPriceUnit);
 
-                         } else {
 
-                             validText = ZhCalc.round(validText, findDecimal(sortData[curRow].unit)) || 0;
 
-                         }
 
-                         if (colSetting.field === 'delimit') {
 
-                             const reg = /^(\d{1,2}|100)$/;
 
-                             if (!(_.isNumber(validText) && reg.test(validText))) {
 
-                                 toastr.error('清单第' + (hintRow+1) + '行计量上限默认值只能粘贴0-100之间的整数');
 
-                                 bPaste = false;
 
-                                 continue;
 
-                             }
 
-                             // 需要判断是否已调用,已调用的则不能低于原有值大小
 
-                             const usedInfo = _.find(changeUsedData, { cbid: sortData[curRow].clid });
 
-                             if (usedInfo && usedInfo.qty) {
 
-                                 const minLimit = Math.ceil(ZhCalc.mul(ZhCalc.div(usedInfo.qty, sortData[curRow].camount), 100));
 
-                                 if (validText < minLimit) {
 
-                                     toastr.error('清单第' + (hintRow+1) + '行计量上限值至少大于等于 ' + minLimit);
 
-                                     bPaste = false;
 
-                                     continue;
 
-                                 }
 
-                             }
 
-                         }
 
-                     }
 
-                     let unitdecimal = validText;
 
-                     if (colSetting.field === 'unit') {
 
-                         //粘贴内容要为下拉列表里所有的单位,不然为空
 
-                         if (changeUnits.indexOf(validText) === -1) {
 
-                             unitdecimal = '';
 
-                         }
 
-                         cLData.camount = ZhCalc.round(sortData[curRow].camount, findDecimal(unitdecimal)) || 0;
 
-                         cLData.oamount2 = ZhCalc.round(sortData[curRow].oamount2, findDecimal(unitdecimal)) || 0;
 
-                     }
 
-                     if (colSetting.field === 'b_code') {
 
-                         cLData.code = validText;
 
-                     } else {
 
-                         cLData[colSetting.field] = validText;
 
-                     }
 
-                     sortData[curRow][colSetting.field] = validText;
 
-                     cLData.spamount = ZhCalc.round(sortData[curRow].camount, findDecimal(unitdecimal)) || 0;
 
-                     sortData[curRow].spamount = cLData.spamount;
 
-                 }
 
-                 if (bPaste) {
 
-                     data.push(cLData);
 
-                     selects.push(sortData[curRow]);
 
-                 } else {
 
-                     SpreadJsObj.reLoadRowData(info.sheet, curRow);
 
-                 }
 
-             }
 
-             if (data.length === 0) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 return;
 
-             }
 
-             console.log(data, selects);
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/save', { type:'paste', updateData: data }, function (result) {
 
-                 changeList = result;
 
-                 const loadResult = {
 
-                     update: selects,
 
-                 };
 
-                 const refreshData = ledgerTree.loadPostData(loadResult);
 
-                 ledgerTreeSpreadObj.refreshTree(ledgerSheet, refreshData);
 
-                 ledgerTreeSpreadObj.loadExprToInput();
 
-             }, function () {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 return;
 
-             });
 
-         };
 
-         ledgerTreeSpreadObj.buttonClicked = function(e, info) {
 
-             if (info.sheet.zh_setting) {
 
-                 const select = SpreadJsObj.getSelectObject(info.sheet);
 
-                 if (!select || !select.clid) {
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 const cInfo = _.find(changeList, { id: select.clid });
 
-                 if (!cInfo) {
 
-                     toastr.error('数据错误,请刷新页面重试');
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 const col = info.sheet.zh_setting.cols[info.col];
 
-                 if (col.field === 'is_valuation') {
 
-                     if (info.sheet.isEditing()) {
 
-                         info.sheet.endEdit(true);
 
-                     }
 
-                     if (_.findIndex(changeUsedData, { cbid: select.clid }) !== -1) {
 
-                         return;
 
-                     }
 
-                     select.is_valuation = info.sheet.getValue(info.row, info.col) ? 0 : 1;
 
-                     cInfo.is_valuation = select.is_valuation;
 
-                     delete cInfo.waitingLoading;
 
-                     // 更新至服务器
 
-                     postData(window.location.pathname + '/save', { type:'update', updateData: cInfo }, function (result) {
 
-                         const loadResult = {
 
-                             update: [select],
 
-                         };
 
-                         const refreshData = ledgerTree.loadPostData(loadResult);
 
-                         ledgerTreeSpreadObj.refreshTree(ledgerSheet, refreshData);
 
-                     }, function () {
 
-                         select.is_valuation = info.sheet.getValue(info.row, info.col) ? 1 : 0;
 
-                         cInfo.is_valuation = select.is_valuation;
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     });
 
-                 }
 
-             }
 
-         };
 
-         ledgerTreeSpreadObj.valueChanged = function(e, info) {
 
-             // 防止ctrl+z撤销数据
 
-             SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-         };
 
-         ledgerTreeSpreadObj.deletePress = function (sheet) {
 
-             if (!sheet.zh_setting) return;
 
-             // 暂时仅支持移除数量
 
-             const sel = sheet.getSelections()[0], datas = [];
 
-             const selects = [];
 
-             for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
 
-                 let bDel = false;
 
-                 const node = sheet.zh_tree.nodes[iRow];
 
-                 const cInfo = _.find(changeList, { id: node.clid });
 
-                 for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
 
-                     const col = sheet.zh_setting.cols[iCol];
 
-                     if (col.field === 'camount' || col.field === 'oamount2') {
 
-                         node[col.field] = null;
 
-                         cInfo[col.field] = null;
 
-                         if (col.field === 'camount') {
 
-                             node.camount_expr = '';
 
-                             node.spamount = null;
 
-                             cInfo.camount_expr = '';
 
-                             cInfo.spamount = null;
 
-                         }
 
-                         delete cInfo.waitingLoading;
 
-                         bDel = true;
 
-                     }
 
-                 }
 
-                 if (bDel) {
 
-                     datas.push(cInfo);
 
-                     selects.push(node);
 
-                 }
 
-             }
 
-             console.log(datas, selects);
 
-             if (datas.length > 0) {
 
-                 postData(window.location.pathname + '/save', { type:'paste', updateData: datas }, function (result) {
 
-                     changeList = result;
 
-                     const loadResult = {
 
-                         update: selects,
 
-                     };
 
-                     const refreshData = ledgerTree.loadPostData(loadResult);
 
-                     ledgerTreeSpreadObj.refreshTree(ledgerSheet, refreshData);
 
-                     ledgerTreeSpreadObj.loadExprToInput();
 
-                 }, function () {
 
-                     SpreadJsObj.reLoadRowData(sheet, sel.row, sel.rowCount);
 
-                     return;
 
-                 });
 
-             }
 
-             return;
 
-         };
 
-         // 表达式判断
 
-         $('#ledger-camount-expr').change(function () {
 
-             if (this.readOnly) return;
 
-             let validText = $(this).val();
 
-             const sel = ledgerSheet.getSelections()[0];
 
-             const row = sel ? sel.row : -1;
 
-             const col = ledgerSheet.zh_setting.cols[sel.col];
 
-             if (row === -1 || !(col && col.field === 'camount')) return;
 
-             const select = SpreadJsObj.getSelectObject(ledgerSheet);
 
-             if (!select || !select.clid) return;
 
-             const cInfo = _.find(changeList, { id: select.clid });
 
-             if (!cInfo) return;
 
-             validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : '');
 
-             let orgValue = validText && validText !== ''
 
-                 ? (_.toNumber(validText) ? select.camount : select.camount_expr)
 
-                 : (select.camount_expr && select.camount_expr !== '' ? select.camount_expr : select.camount);
 
-             const orgExprValue = _.clone(select.camount_expr);
 
-             if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === '' || validText === null))) {
 
-                 return;
 
-             }
 
-             const exprQuantity = {
 
-                 expr: '',
 
-                 quantity: 0,
 
-             };
 
-             const [valid, msg] = ledgerTreeSpreadObj._checkExpr(validText, exprQuantity);
 
-             if (!valid) {
 
-                 toastr.error(msg);
 
-                 $(this).val(select.camount_expr ? select.camount_expr : select.camount);
 
-                 return;
 
-             }
 
-             if (isNaN(exprQuantity.quantity)) {
 
-                 toastr.error('不能输入其它非数字类型字符');
 
-                 $(this).val(select.camount_expr ? select.camount_expr : select.camount);
 
-                 return;
 
-             }
 
-             validText = parseFloat(exprQuantity.quantity);
 
-             // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
 
-             const usedInfo = _.find(changeUsedData, { cbid: cInfo.id });
 
-             if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
 
-                 toastr.error('清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
 
-                 $(this).val(select.camount_expr ? select.camount_expr : select.camount);
 
-                 return;
 
-             } else if (usedInfo && usedInfo.qty < 0  && validText > usedInfo.qty) {
 
-                 toastr.error('清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
 
-                 $(this).val(select.camount_expr ? select.camount_expr : select.camount);
 
-                 return;
 
-             }
 
-             select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
 
-             select.camount_expr = exprQuantity.expr;
 
-             select.camount = validText;
 
-             cInfo.spamount = select.spamount;
 
-             cInfo.camount_expr = select.camount_expr;
 
-             cInfo.camount = validText;
 
-             // console.log(select);
 
-             delete cInfo.waitingLoading;
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/save', { type:'update', updateData: cInfo }, function (result) {
 
-                 const loadResult = {
 
-                     update: [select],
 
-                 };
 
-                 const refreshData = ledgerTree.loadPostData(loadResult);
 
-                 ledgerTreeSpreadObj.refreshTree(ledgerSheet, refreshData);
 
-             }, function () {
 
-                 select.camount = orgValue;
 
-                 select.camount_expr = orgExprValue;
 
-                 select.spamount = orgValue;
 
-                 cInfo.camount = orgValue;
 
-                 cInfo.camount_expr = orgExprValue;
 
-                 cInfo.spamount = orgValue;
 
-                 SpreadJsObj.reLoadRowData(posSheet, row);
 
-             });
 
-         });
 
-         ledgerSpread.bind(spreadNS.Events.EditEnded, ledgerTreeSpreadObj.editEnded);
 
-         ledgerSpread.bind(spreadNS.Events.EditStarting, ledgerTreeSpreadObj.editStarting);
 
-         ledgerSpread.bind(spreadNS.Events.ClipboardPasted, ledgerTreeSpreadObj.clipboardPasted);
 
-         ledgerSpread.bind(spreadNS.Events.ValueChanged, ledgerTreeSpreadObj.valueChanged);
 
-         ledgerSpread.bind(spreadNS.Events.ButtonClicked, ledgerTreeSpreadObj.buttonClicked);
 
-         SpreadJsObj.addDeleteBind(ledgerSpread, ledgerTreeSpreadObj.deletePress);
 
-         // 计量单元修改
 
-         posSpreadObj.del = function () {
 
-             const selection = posSheet.getSelections();
 
-             const sel = selection ? selection[0] : posSheet.getSelections()[0];
 
-             const row = sel && sel.row !== undefined ? sel.row : -1;
 
-             const count = sel.rowCount;
 
-             if (readOnly || row === -1 || row + count > posSheet.zh_data.length) {
 
-                 return false;
 
-             }
 
-             const delList = [];
 
-             let lastSelect = null;
 
-             let hadTaiZhang = false;
 
-             const selects = [];
 
-             for (let r = 0; r < count; r++) {
 
-                 const select = posSheet.zh_data[row + r];
 
-                 if(!select || _.find(changeUsedData, { cbid: select.clid })) {
 
-                     toastr.error('已调用的变更清单不能删除');
 
-                     return false;
 
-                 }
 
-                 if (checkIsSettle(select)) {
 
-                     toastr.error('已结算的变更清单不能删除');
 
-                     return false;
 
-                 }
 
-                 if (r === count - 1 && changeOrder) {
 
-                     lastSelect = select;
 
-                 }
 
-                 if (select.lid != 0) {
 
-                     hadTaiZhang = true;
 
-                 }
 
-                 delList.push(select.clid);
 
-                 selects.push(select.id);
 
-             }
 
-             if (delList.length) {
 
-                 postData(window.location.pathname + '/save', {type: 'del', ids: delList, postData: lastSelect ? lastSelect.order : null}, function (result) {
 
-                     pos.removeDatas(selects);
 
-                     posSheet.deleteRows(row, count);
 
-                     const billsNode = SpreadJsObj.getSelectObject(ledgerSheet);
 
-                     const loadResult = {};
 
-                     // 判断是移除还是更新数量和金额
 
-                     if (posSheet.zh_data.length === 0) {
 
-                         // 判断父节点是否也要移除
 
-                         const parentNodes = _.reverse(ledgerTree.getAllParents(billsNode));
 
-                         loadResult.delete = [billsNode];
 
-                         for (const node of parentNodes) {
 
-                             if (node.children && node.children.length === 1) {
 
-                                 loadResult.delete.push(node);
 
-                             } else {
 
-                                 break;
 
-                             }
 
-                         }
 
-                     } else {
 
-                         loadResult.update = [billsNode];
 
-                     }
 
-                     if (loadResult.update || loadResult.delete) {
 
-                         const refreshData = ledgerTree.loadPostData(loadResult);
 
-                         ledgerTreeSpreadObj.refreshTree(ledgerSheet, refreshData);
 
-                         if (loadResult.delete) {
 
-                             ledgerSheet.setSelection(0, 0, 1, 1);
 
-                             ledgerTreeSpreadObj.refreshPosData();
 
-                         }
 
-                     }
 
-                 });
 
-             }
 
-         };
 
-         posSpreadObj.editStarting = function (e, info) {
 
-             posSpreadObj.billsNode = SpreadJsObj.getSelectObject(ledgerSheet);
 
-             const col = info.sheet.zh_setting.cols[info.col];
 
-             const select = SpreadJsObj.getSelectObject(info.sheet);
 
-             if (col.field === 'camount') {
 
-                 if (select.camount_expr && select.camount_expr !== '') {
 
-                     info.sheet.getCell(info.row, info.col).text(select.camount_expr);
 
-                 }
 
-             }
 
-         };
 
-         posSpreadObj.editEnded = function (e, info) {
 
-             if (!info.sheet.zh_setting) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const select = info.sheet.zh_data ? info.sheet.zh_data[info.row] : null;
 
-             const cInfo = _.find(changeList, { id: select.clid });
 
-             if (!cInfo) {
 
-                 toastr.error('数据错误,请刷新页面重试');
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const col = info.sheet.zh_setting.cols[info.col];
 
-             if (col.field === 'is_valuation') {
 
-                 return;
 
-             }
 
-             let validText = is_numeric(info.editingText) && _.indexOf(numField, col.field) !== -1 ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : '');
 
-             let orgValue;
 
-             if (col.field === 'camount') {
 
-                 orgValue = validText && validText !== ''
 
-                     ? (_.toNumber(validText) ? select.camount : select.camount_expr)
 
-                     : (select.camount_expr && select.camount_expr !== '' ? select.camount_expr : select.camount);
 
-             } else {
 
-                 orgValue = select[col.field];
 
-             }
 
-             if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === '' || validText === null))) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const node = posSpreadObj.billsNode;
 
-             if (!node) {
 
-                 toastr.error('数据错误,请选择台账节点后再试');
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             if(col.field === 'camount') {
 
-                 const exprQuantity = {
 
-                     expr: '',
 
-                     quantity: 0,
 
-                 };
 
-                 const [valid, msg] = ledgerTreeSpreadObj._checkExpr(validText, exprQuantity);
 
-                 if (!valid) {
 
-                     toastr.error(msg);
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 if (isNaN(exprQuantity.quantity)) {
 
-                     toastr.error('不能输入其它非数字类型字符');
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 validText = parseFloat(exprQuantity.quantity);
 
-                 // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
 
-                 const usedInfo = _.find(changeUsedData, { cbid: select.clid });
 
-                 if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
 
-                     toastr.error('清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 } else if (usedInfo && usedInfo.qty < 0  && validText > usedInfo.qty) {
 
-                     toastr.error('清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
 
-                 select.camount_expr = exprQuantity.expr;
 
-                 cInfo.spamount = select.spamount;
 
-                 cInfo.camount_expr = exprQuantity.expr;
 
-             }
 
-             if (col.type === 'Number') {
 
-                 if (isNaN(validText)) {
 
-                     toastr.error('不能输入其它非数字类型字符');
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 if (col.field === 'unit_price') {
 
-                     validText = ZhCalc.round(validText, unitPriceUnit);
 
-                 } else {
 
-                     validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
 
-                 }
 
-                 if (col.field === 'delimit') {
 
-                     const reg = /^(\d{1,2}|100)$/;
 
-                     if (!(_.isNumber(validText) && reg.test(validText))) {
 
-                         toastr.error('计量上限默认值只能输入0-100之间的整数');
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                         return;
 
-                     }
 
-                     // 需要判断是否已调用,已调用的则不能低于原有值大小
 
-                     const usedInfo = _.find(changeUsedData, { cbid: select.clid });
 
-                     if (usedInfo && usedInfo.qty) {
 
-                         const minLimit = Math.ceil(ZhCalc.mul(ZhCalc.div(usedInfo.qty, select.camount), 100));
 
-                         if (validText < minLimit) {
 
-                             toastr.error('计量上限值至少大于等于 ' + minLimit);
 
-                             SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                             return;
 
-                         }
 
-                     }
 
-                 }
 
-             }
 
-             cInfo[col.field] = validText;
 
-             select[col.field] = validText;
 
-             console.log(cInfo);
 
-             delete cInfo.waitingLoading;
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/save', { type:'update', updateData: cInfo }, function (result) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 const loadResult = {
 
-                     update: [node],
 
-                 };
 
-                 const refreshData = ledgerTree.loadPostData(loadResult);
 
-                 ledgerTreeSpreadObj.refreshTree(ledgerSheet, refreshData);
 
-             }, function () {
 
-                 select[col.field] = orgValue;
 
-                 cInfo[col.field] = orgValue;
 
-                 if(col.field === 'camount') {
 
-                     select.spamount = orgValue;
 
-                     cInfo.spamount = orgValue;
 
-                 }
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-             });
 
-         };
 
-         posSpreadObj.clipboardPasted = function (e, info) {
 
-             if (info.sheet.getColumnCount() > info.sheet.zh_setting.cols.length) {
 
-                 info.sheet.setColumnCount(info.sheet.zh_setting.cols.length);
 
-             }
 
-             const hint = {
 
-                 cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
 
-                 numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
 
-                 expr: {type: 'warning', msg: '粘贴了表达式非法,已过滤'},
 
-             };
 
-             const range = info.cellRange;
 
-             const sortData = info.sheet.zh_data || [];
 
-             if (range.row + range.rowCount > sortData.length) {
 
-                 toastMessageUniq(hint.cellError);
 
-                 // SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
 
-                 posSpreadObj.loadCurPosData();
 
-                 return;
 
-             }
 
-             if (sortData.length > 0 && range.col + range.colCount > 6) {
 
-                 toastMessageUniq(hint.cellError);
 
-                 posSpreadObj.loadCurPosData();
 
-                 return;
 
-             }
 
-             if (!info.sheet.zh_setting) {
 
-                 posSpreadObj.loadCurPosData();
 
-                 return;
 
-             }
 
-             const data = [];
 
-             // const rowData = [];
 
-             let needCopyIgnore = !$('#customCheck1').is(':checked');
 
-             let needColAdd = false;
 
-             for (let iRow = 0; iRow < range.rowCount; iRow++) {
 
-                 let bPaste = true;
 
-                 const curRow = range.row + iRow;
 
-                 // const materialData = JSON.parse(JSON.stringify(sortData[curRow]));
 
-                 const cLData = { id: sortData[curRow].clid };
 
-                 const hintRow = range.rowCount >= 1 ? curRow : '';
 
-                 let sameCol = 0;
 
-                 for (let iCol = 0; iCol < range.colCount; iCol++) {
 
-                     const curCol = range.col + iCol;
 
-                     let colSetting = info.sheet.zh_setting.cols[curCol];
 
-                     if ((needColAdd && curCol > 2) || (needCopyIgnore && curCol === 2)) { // 要判断是否已隐藏了变更详情,是则变更详情后面的curCol要+1
 
-                         const newCurCol = curCol + 1;
 
-                         needColAdd = true;
 
-                         colSetting = info.sheet.zh_setting.cols[newCurCol];
 
-                     }
 
-                     if (!colSetting) continue;
 
-                     let validText = info.sheet.getText(curRow, curCol);
 
-                     validText = is_numeric(validText) && _.indexOf(numField, colSetting.field) !== -1 ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : '');
 
-                     let orgValue;
 
-                     if (colSetting.field === 'camount') {
 
-                         orgValue = validText && validText !== ''
 
-                             ? (_.toNumber(validText) ? sortData[curRow].camount : sortData[curRow].camount_expr)
 
-                             : (sortData[curRow].camount_expr && sortData[curRow].camount_expr !== '' ? sortData[curRow].camount_expr : sortData[curRow].camount);
 
-                     } else {
 
-                         orgValue = sortData[curRow][colSetting.field];
 
-                     }
 
-                     if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
 
-                         sameCol++;
 
-                         if (range.colCount === sameCol)  {
 
-                             bPaste = false;
 
-                         }
 
-                         continue;
 
-                     }
 
-                     if(colSetting.field === 'camount') {
 
-                         const exprQuantity = {
 
-                             expr: '',
 
-                             quantity: 0,
 
-                         };
 
-                         const [valid, msg] = ledgerTreeSpreadObj._checkExpr(validText, exprQuantity);
 
-                         if (!valid) {
 
-                             toastMessageUniq(getPasteHint(msg, hintRow));
 
-                             bPaste = false;
 
-                             continue;
 
-                         }
 
-                         if (isNaN(exprQuantity.quantity)) {
 
-                             toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
 
-                             bPaste = false;
 
-                             continue;
 
-                         }
 
-                         validText = parseFloat(exprQuantity.quantity);
 
-                         // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
 
-                         const usedInfo = _.find(changeUsedData, { cbid: sortData[curRow].clid });
 
-                         if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
 
-                             toastr.error(hintRow ? '清单第' + (hintRow+1) + '行变更数值必须大于等于已调用值 ' + usedInfo.qty : '清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
 
-                             bPaste = false;
 
-                             continue;
 
-                         } else if (usedInfo && usedInfo.qty < 0 && validText > usedInfo.qty) {
 
-                             toastr.error(hintRow ? '清单第' + (hintRow+1) + '行变更数值必须小于等于已调用值 ' + usedInfo.qty : '清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
 
-                             bPaste = false;
 
-                             continue;
 
-                         }
 
-                         cLData.camount_expr = exprQuantity.expr;
 
-                         sortData[curRow].camount_expr = exprQuantity.expr;
 
-                     }
 
-                     if (colSetting.type === 'Number') {
 
-                         if (isNaN(validText)) {
 
-                             toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
 
-                             bPaste = false;
 
-                             continue;
 
-                         }
 
-                         if (colSetting.field === 'unit_price') {
 
-                             validText = ZhCalc.round(validText, unitPriceUnit);
 
-                         } else {
 
-                             validText = ZhCalc.round(validText, findDecimal(sortData[curRow].unit)) || 0;
 
-                         }
 
-                         if (colSetting.field === 'delimit') {
 
-                             const reg = /^(\d{1,2}|100)$/;
 
-                             if (!(_.isNumber(validText) && reg.test(validText))) {
 
-                                 toastr.error('计量单元第' + (hintRow+1) + '行计量上限默认值只能粘贴0-100之间的整数');
 
-                                 bPaste = false;
 
-                                 continue;
 
-                             }
 
-                             // 需要判断是否已调用,已调用的则不能低于原有值大小
 
-                             const usedInfo = _.find(changeUsedData, { cbid: sortData[curRow].clid });
 
-                             if (usedInfo && usedInfo.qty) {
 
-                                 const minLimit = Math.ceil(ZhCalc.mul(ZhCalc.div(usedInfo.qty, sortData[curRow].camount), 100));
 
-                                 if (validText < minLimit) {
 
-                                     toastr.error('计量单元第' + (hintRow+1) + '行计量上限值至少大于等于 ' + minLimit);
 
-                                     bPaste = false;
 
-                                     continue;
 
-                                 }
 
-                             }
 
-                         }
 
-                     }
 
-                     let unitdecimal = validText;
 
-                     cLData[colSetting.field] = validText;
 
-                     sortData[curRow][colSetting.field] = validText;
 
-                     cLData.spamount = ZhCalc.round(sortData[curRow].camount, findDecimal(unitdecimal)) || 0;
 
-                 }
 
-                 if (bPaste) {
 
-                     data.push(cLData);
 
-                     // rowData.push(curRow);
 
-                 } else {
 
-                     SpreadJsObj.reLoadRowData(info.sheet, curRow);
 
-                 }
 
-             }
 
-             if (data.length === 0) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 return;
 
-             }
 
-             console.log(data);
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/save', { type:'paste', updateData: data }, function (result) {
 
-                 changeList = result;
 
-                 const node = SpreadJsObj.getSelectObject(ledgerSheet);
 
-                 const loadResult = {
 
-                     update: [node],
 
-                 };
 
-                 const refreshData = ledgerTree.loadPostData(loadResult);
 
-                 ledgerTreeSpreadObj.refreshTree(ledgerSheet, refreshData);
 
-                 posSpreadObj.loadCurPosData();
 
-             }, function () {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 return;
 
-             });
 
-         };
 
-         posSpreadObj.buttonClicked = function(e, info) {
 
-             if (info.sheet.zh_setting) {
 
-                 const select = SpreadJsObj.getSelectObject(info.sheet);
 
-                 const cInfo = _.find(changeList, { id: select.clid });
 
-                 if (!cInfo) {
 
-                     toastr.error('数据错误,请刷新页面重试');
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 const col = info.sheet.zh_setting.cols[info.col];
 
-                 if (col.field === 'is_valuation') {
 
-                     if (info.sheet.isEditing()) {
 
-                         info.sheet.endEdit(true);
 
-                     }
 
-                     if (_.findIndex(changeUsedData, { cbid: select.clid }) !== -1) {
 
-                         return;
 
-                     }
 
-                     select.is_valuation = info.sheet.getValue(info.row, info.col) ? 0 : 1;
 
-                     cInfo.is_valuation = select.is_valuation;
 
-                     delete cInfo.waitingLoading;
 
-                     // 更新至服务器
 
-                     postData(window.location.pathname + '/save', { type:'update', updateData: cInfo }, function (result) {
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                         const node = SpreadJsObj.getSelectObject(ledgerSheet);
 
-                         const loadResult = {
 
-                             update: [node],
 
-                         };
 
-                         const refreshData = ledgerTree.loadPostData(loadResult);
 
-                         ledgerTreeSpreadObj.refreshTree(ledgerSheet, refreshData);
 
-                     }, function () {
 
-                         select.is_valuation = info.sheet.getValue(info.row, info.col) ? 1 : 0;
 
-                         cInfo.is_valuation = select.is_valuation;
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     });
 
-                 }
 
-             }
 
-         };
 
-         posSpreadObj.valueChanged = function(e, info) {
 
-             // 防止ctrl+z撤销数据
 
-             SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-         };
 
-         posSpreadObj.deletePress = function (sheet) {
 
-             if (!sheet.zh_setting) return;
 
-             // 暂时仅支持移除数量
 
-             const sel = sheet.getSelections()[0], datas = [];
 
-             for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
 
-                 let bDel = false;
 
-                 const node = sheet.zh_data[iRow];
 
-                 const cInfo = _.find(changeList, { id: node.clid });
 
-                 for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
 
-                     const col = sheet.zh_setting.cols[iCol];
 
-                     if (col.field === 'camount' || col.field === 'oamount2') {
 
-                         node[col.field] = null;
 
-                         cInfo[col.field] = null;
 
-                         if (col.field === 'camount') {
 
-                             node.camount_expr = '';
 
-                             node.spamount = null;
 
-                             cInfo.camount_expr = '';
 
-                             cInfo.spamount = null;
 
-                         }
 
-                         delete cInfo.waitingLoading;
 
-                         bDel = true;
 
-                     }
 
-                 }
 
-                 if (bDel) datas.push(cInfo);
 
-             }
 
-             if (datas.length > 0) {
 
-                 postData(window.location.pathname + '/save', { type:'paste', updateData: datas }, function (result) {
 
-                     changeList = result;
 
-                     const billsNode = SpreadJsObj.getSelectObject(ledgerSheet);
 
-                     const loadResult = {
 
-                         update: [billsNode],
 
-                     };
 
-                     const refreshData = ledgerTree.loadPostData(loadResult);
 
-                     ledgerTreeSpreadObj.refreshTree(ledgerSheet, refreshData);
 
-                     posSpreadObj.loadCurPosData();
 
-                 }, function () {
 
-                     SpreadJsObj.reLoadRowData(sheet, sel.row, sel.rowCount);
 
-                     return;
 
-                 });
 
-             }
 
-             return;
 
-         };
 
-         // 表达式判断
 
-         $('#pos-camount-expr').change(function () {
 
-             if (this.readOnly) return;
 
-             let validText = $(this).val();
 
-             const sel = posSheet.getSelections()[0];
 
-             const row = sel ? sel.row : -1;
 
-             const col = posSheet.zh_setting.cols[sel.col];
 
-             if (row === -1 || !(col && col.field === 'camount')) return;
 
-             const select = SpreadJsObj.getSelectObject(posSheet);
 
-             if (!select) return;
 
-             const cInfo = _.find(changeList, { id: select.clid });
 
-             if (!cInfo) return;
 
-             validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : '');
 
-             let orgValue = validText && validText !== ''
 
-                 ? (_.toNumber(validText) ? select.camount : select.camount_expr)
 
-                 : (select.camount_expr && select.camount_expr !== '' ? select.camount_expr : select.camount);
 
-             const orgExprValue = _.clone(select.camount_expr);
 
-             if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === '' || validText === null))) {
 
-                 return;
 
-             }
 
-             const exprQuantity = {
 
-                 expr: '',
 
-                 quantity: 0,
 
-             };
 
-             const [valid, msg] = ledgerTreeSpreadObj._checkExpr(validText, exprQuantity);
 
-             if (!valid) {
 
-                 toastr.error(msg);
 
-                 $(this).val(select.camount_expr ? select.camount_expr : select.camount);
 
-                 return;
 
-             }
 
-             if (isNaN(exprQuantity.quantity)) {
 
-                 toastr.error('不能输入其它非数字类型字符');
 
-                 $(this).val(select.camount_expr ? select.camount_expr : select.camount);
 
-                 return;
 
-             }
 
-             validText = parseFloat(exprQuantity.quantity);
 
-             // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
 
-             const usedInfo = _.find(changeUsedData, { cbid: cInfo.id });
 
-             if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
 
-                 toastr.error('清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
 
-                 $(this).val(select.camount_expr ? select.camount_expr : select.camount);
 
-                 return;
 
-             } else if (usedInfo && usedInfo.qty < 0  && validText > usedInfo.qty) {
 
-                 toastr.error('清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
 
-                 $(this).val(select.camount_expr ? select.camount_expr : select.camount);
 
-                 return;
 
-             }
 
-             select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
 
-             select.camount_expr = exprQuantity.expr;
 
-             select.camount = validText;
 
-             cInfo.spamount = select.spamount;
 
-             cInfo.camount_expr = select.camount_expr;
 
-             cInfo.camount = validText;
 
-             // console.log(select);
 
-             delete cInfo.waitingLoading;
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/save', { type:'update', updateData: cInfo }, function (result) {
 
-                 SpreadJsObj.reLoadRowData(posSheet, row);
 
-                 const node = SpreadJsObj.getSelectObject(ledgerSheet);
 
-                 const loadResult = {
 
-                     update: [node],
 
-                 };
 
-                 const refreshData = ledgerTree.loadPostData(loadResult);
 
-                 ledgerTreeSpreadObj.refreshTree(ledgerSheet, refreshData);
 
-             }, function () {
 
-                 select.camount = orgValue;
 
-                 select.camount_expr = orgExprValue;
 
-                 select.spamount = orgValue;
 
-                 cInfo.camount = orgValue;
 
-                 cInfo.camount_expr = orgExprValue;
 
-                 cInfo.spamount = orgValue;
 
-                 SpreadJsObj.reLoadRowData(posSheet, row);
 
-             });
 
-         });
 
-         posSpread.bind(spreadNS.Events.EditEnded, posSpreadObj.editEnded);
 
-         posSpread.bind(spreadNS.Events.EditStarting, posSpreadObj.editStarting);
 
-         posSpread.bind(spreadNS.Events.ClipboardPasted, posSpreadObj.clipboardPasted);
 
-         posSpread.bind(spreadNS.Events.ValueChanged, posSpreadObj.valueChanged);
 
-         posSpread.bind(spreadNS.Events.ButtonClicked, posSpreadObj.buttonClicked);
 
-         SpreadJsObj.addDeleteBind(posSpread, posSpreadObj.deletePress);
 
-         // 右键菜单
 
-         $.contextMenu({
 
-             selector: '#ledger-spread',
 
-             build: function ($trigger, e) {
 
-                 const target = SpreadJsObj.safeRightClickSelection($trigger, e, ledgerSpread);
 
-                 return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
 
-             },
 
-             items: {
 
-                 'delete': {
 
-                     name: '删除',
 
-                     icon: 'fa-remove',
 
-                     callback: function (key, opt) {
 
-                         ledgerTreeSpreadObj.del();
 
-                     },
 
-                     disabled: function (key, opt) {
 
-                         const selection = ledgerSheet.getSelections();
 
-                         const sel = selection ? selection[0] : ledgerSheet.getSelections()[0];
 
-                         const row = sel ? sel.row : -1;
 
-                         const tree = ledgerSheet.zh_tree;
 
-                         if (!tree) return true;
 
-                         const first = ledgerSheet.zh_tree.nodes[row];
 
-                         let last = first, sameParent = true, listValid = true;
 
-                         if (sel.rowCount > 1 && first) {
 
-                             for (let r = 1; r < sel.rowCount; r++) {
 
-                                 const rNode = tree.nodes[sel.row + r];
 
-                                 if (!rNode) {
 
-                                     sameParent = false;
 
-                                     break;
 
-                                 }
 
-                                 if (!rNode.clid) {
 
-                                     listValid  = false;
 
-                                     break;
 
-                                 }
 
-                                 if (_.find(changeUsedData, { cbid: rNode.clid }) || checkIsSettle(rNode)) {
 
-                                     listValid = false;
 
-                                     break;
 
-                                 }
 
-                                 if (rNode.level > first.level) continue;
 
-                                 if ((rNode.level < first.level) || (rNode.level === first.level && rNode.pid !== first.pid)) {
 
-                                     sameParent = false;
 
-                                     break;
 
-                                 }
 
-                                 last = rNode;
 
-                             }
 
-                         }
 
-                         const valid = !ledgerSheet.zh_setting.readOnly;
 
-                         return !(valid && first && first.clid && !_.find(changeUsedData, { cbid: first.clid }) && !checkIsSettle(first) && sameParent && listValid);
 
-                     }
 
-                 },
 
-                 // sprEdit: '----',
 
-                 // 'allNotValuation': {
 
-                 //     name: '设置全部清单不计价',
 
-                 //     icon: 'fa-magic',
 
-                 //     callback: function (key, opt) {
 
-                 //         changeSpreadObj.setAllValuation(0);
 
-                 //     },
 
-                 // },
 
-                 // 'allValuation': {
 
-                 //     name: '设置全部清单计价',
 
-                 //     icon: 'fa-magic',
 
-                 //     callback: function (key, opt) {
 
-                 //         changeSpreadObj.setAllValuation(1);
 
-                 //     },
 
-                 // },
 
-             }
 
-         });
 
-         // 右键菜单
 
-         $.contextMenu({
 
-             selector: '#pos-spread',
 
-             build: function ($trigger, e) {
 
-                 const target = SpreadJsObj.safeRightClickSelection($trigger, e, posSpread);
 
-                 return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
 
-             },
 
-             items: {
 
-                 'delete': {
 
-                     name: '删除',
 
-                     icon: 'fa-remove',
 
-                     callback: function (key, opt) {
 
-                         posSpreadObj.del();
 
-                     },
 
-                     disabled: function (key, opt) {
 
-                         const selection = posSheet.getSelections();
 
-                         const sel = selection ? selection[0] : posSheet.getSelections()[0];
 
-                         const row = sel && sel.row !== undefined ? sel.row : -1;
 
-                         if (readOnly || row === -1 || sel.row + sel.rowCount > posSheet.zh_data.length) {
 
-                             return true;
 
-                         }
 
-                         let isUsed = false;
 
-                         for (let r = 0; r < sel.rowCount; r++) {
 
-                             const select = posSheet.zh_data[row + r];
 
-                             if(!select || _.find(changeUsedData, { cbid: select.clid })) {
 
-                                 isUsed = true;
 
-                             }
 
-                             if (checkIsSettle(select)) {
 
-                                 isUsed = true;
 
-                             }
 
-                         }
 
-                         return isUsed;
 
-                     }
 
-                 },
 
-                 // sprEdit: '----',
 
-                 // 'allNotValuation': {
 
-                 //     name: '设置全部清单不计价',
 
-                 //     icon: 'fa-magic',
 
-                 //     callback: function (key, opt) {
 
-                 //         changeSpreadObj.setAllValuation(0);
 
-                 //     },
 
-                 // },
 
-                 // 'allValuation': {
 
-                 //     name: '设置全部清单计价',
 
-                 //     icon: 'fa-magic',
 
-                 //     callback: function (key, opt) {
 
-                 //         changeSpreadObj.setAllValuation(1);
 
-                 //     },
 
-                 // },
 
-             }
 
-         });
 
-     }
 
-     if (shenpiPower) {
 
-         changeSpreadObj.editEnded = function (e, info) {
 
-             if (!info.sheet.zh_setting) {
 
-                 changeSpreadObj.reloadRow(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const select = info.sheet.zh_data ? info.sheet.zh_data[info.row] : null;
 
-             if (!select || !select.id) {
 
-                 toastr.error('该变更清单无法编辑');
 
-                 changeSpreadObj.reloadRow(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const cInfo = _.find(changeList, { id: select.id });
 
-             if (!cInfo) {
 
-                 toastr.error('数据错误,请刷新页面重试');
 
-                 changeSpreadObj.reloadRow(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const col = info.sheet.zh_setting.cols[info.col];
 
-             let validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : '');
 
-             const orgValue = select[col.field];
 
-             if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === '' || validText === null))) {
 
-                 changeSpreadObj.reloadRow(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const node = SpreadJsObj.getSelectObject(changeSpreadSheet);
 
-             if (!node) {
 
-                 toastr.error('数据错误,请选择清单节点后再试');
 
-                 changeSpreadObj.reloadRow(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             if (col.type === 'Number') {
 
-                 if (isNaN(validText)) {
 
-                     toastr.error('不能输入其它非数字类型字符');
 
-                     changeSpreadObj.reloadRow(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
 
-                 if (col.field !== 'oamount2') {
 
-                     // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
 
-                     const usedInfo = _.find(changeUsedData, {cbid: select.id});
 
-                     if (usedInfo && validText >= 0 && validText < usedInfo.qty) {
 
-                         toastr.error('清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
 
-                         changeSpreadObj.reloadRow(info.sheet, info.row);
 
-                         return;
 
-                     } else if (usedInfo && validText < 0 && validText > usedInfo.qty) {
 
-                         toastr.error('清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
 
-                         changeSpreadObj.reloadRow(info.sheet, info.row);
 
-                         return;
 
-                     }
 
-                 }
 
-             }
 
-             cInfo[col.field] = validText;
 
-             select[col.field] = validText;
 
-             if (col.field !== 'oamount2') {
 
-                 cInfo.spamount = validText;
 
-                 select.spamount = validText;
 
-             }
 
-             const data = {
 
-                 id: select.id,
 
-             };
 
-             if (col.field === 'oamount2') {
 
-                 data[col.field] = select[col.field];
 
-             } else {
 
-                 data.spamount = select.spamount;
 
-             }
 
-             console.log(data, col.field);
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/save', { type:'update', updateData: data }, function (result) {
 
-                 changeSpreadObj.calcOneSum(select);
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 changeSpreadObj.refreshXmjData();
 
-                 changeSpreadObj.countSum();
 
-                 if (info.row === info.sheet.zh_data.length - 1) {
 
-                     // console.log(info);
 
-                     // changeSpreadSheet.setSelection(info.row, info.col, 1, 1);
 
-                     // changeSpreadObj.reloadRow(changeSpreadSheet, info.row, 0, true);
 
-                     const [newChangeList, updateOrderList] = changeSpreadObj.makeNewChangeList();
 
-                     changeSpreadObj.reloadSheet(newChangeList);
 
-                 }
 
-             }, function () {
 
-                 select[col.field] = orgValue;
 
-                 cInfo[col.field] = orgValue;
 
-                 if (col.field !== 'oamount2') {
 
-                     select.spamount = orgValue;
 
-                     cInfo.spamount = orgValue;
 
-                 }
 
-                 changeSpreadObj.reloadRow(info.sheet, info.row);
 
-             });
 
-         };
 
-         changeSpreadObj.clipboardPasted = function (e, info) {
 
-             if (info.sheet.getColumnCount() > info.sheet.zh_setting.cols.length) {
 
-                 info.sheet.setColumnCount(info.sheet.zh_setting.cols.length);
 
-             }
 
-             const hint = {
 
-                 cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
 
-                 numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
 
-                 expr: {type: 'warning', msg: '粘贴了表达式非法,已过滤'},
 
-             };
 
-             const range = info.cellRange;
 
-             const sortData = info.sheet.zh_data || [];
 
-             const data = [];
 
-             for (let iRow = 0; iRow < range.rowCount; iRow++) {
 
-                 let bPaste = true;
 
-                 const curRow = range.row + iRow;
 
-                 if (!sortData[curRow] || !sortData[curRow].id) {
 
-                     bPaste = false;
 
-                 }
 
-                 const cLData = { id: sortData[curRow].id };
 
-                 const hintRow = range.rowCount >= 1 ? curRow : '';
 
-                 let sameCol = 0;
 
-                 for (let iCol = 0; iCol < range.colCount; iCol++) {
 
-                     const curCol = range.col + iCol;
 
-                     let colSetting = info.sheet.zh_setting.cols[curCol];
 
-                     if (!colSetting) continue;
 
-                     let validText = info.sheet.getText(curRow, curCol);
 
-                     validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : '');
 
-                     const orgValue = sortData[curRow][colSetting.field];
 
-                     if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
 
-                         sameCol++;
 
-                         if (range.colCount === sameCol)  {
 
-                             bPaste = false;
 
-                         }
 
-                         continue;
 
-                     }
 
-                     if (colSetting.type === 'Number') {
 
-                         if (isNaN(validText)) {
 
-                             toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
 
-                             bPaste = false;
 
-                             continue;
 
-                         }
 
-                         validText = ZhCalc.round(validText, findDecimal(sortData[curRow].unit)) || 0;
 
-                         if (colSetting.field !== 'oamount2') {
 
-                             // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
 
-                             const usedInfo = _.find(changeUsedData, {id: sortData[curRow].id});
 
-                             if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
 
-                                 toastr.error(hintRow ? '清单' + (hintRow + 1) + '行变更数值必须大于等于已调用值 ' + usedInfo.qty : '清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
 
-                                 bPaste = false;
 
-                                 continue;
 
-                             } else if (usedInfo && usedInfo.qty < 0 && validText > usedInfo.qty) {
 
-                                 toastr.error(hintRow ? '清单' + (hintRow + 1) + '行变更数值必须小于等于已调用值 ' + usedInfo.qty : '清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
 
-                                 bPaste = false;
 
-                                 continue;
 
-                             }
 
-                         }
 
-                     }
 
-                     sortData[curRow][colSetting.field] = validText;
 
-                     if (colSetting.field === 'oamount2') {
 
-                         cLData[colSetting.field] = validText;
 
-                     } else {
 
-                         cLData.spamount = validText;
 
-                         sortData[curRow].spamount = validText;
 
-                     }
 
-                 }
 
-                 if (bPaste) {
 
-                     data.push(cLData);
 
-                     // rowData.push(curRow);
 
-                 } else {
 
-                     changeSpreadObj.reloadRow(info.sheet, curRow);
 
-                 }
 
-             }
 
-             if (data.length === 0) {
 
-                 changeSpreadObj.reloadRow(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 return;
 
-             }
 
-             console.log(data);
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/save', { type:'paste_amount_rows', updateData: data }, function (result) {
 
-                 changeList = result;
 
-                 const [newChangeList, updateOrderList] = changeSpreadObj.makeNewChangeList();
 
-                 changeSpreadObj.reloadSheet(newChangeList);
 
-             }, function () {
 
-                 changeSpreadObj.reloadRow(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 return;
 
-             });
 
-         };
 
-         changeSpreadObj.deletePress = function (sheet) {
 
-             if (!sheet.zh_setting) return;
 
-             // 暂时仅支持移除数量
 
-             const sel = sheet.getSelections()[0], datas = [];
 
-             for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
 
-                 let bDel = false;
 
-                 const node = sheet.zh_data[iRow];
 
-                 const cInfo = _.find(changeList, { id: node.id });
 
-                 const data = { id: node.id };
 
-                 for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
 
-                     const col = sheet.zh_setting.cols[iCol];
 
-                     if (col.field === 'oamount2' || (col.readOnly !== true && _.includes(col.field, 'audit_amount_') && !checkIsSettle(node))) {
 
-                         node[col.field] = null;
 
-                         cInfo[col.field] = null;
 
-                         if (col.field !== 'oamount2') {
 
-                             data.spamount = null;
 
-                             cInfo.spamount = null;
 
-                             node.spamount = null;
 
-                         } else {
 
-                             data[col.field] = null;
 
-                         }
 
-                         bDel = true;
 
-                     }
 
-                 }
 
-                 if (bDel) datas.push(data);
 
-             }
 
-             if (datas.length > 0) {
 
-                 postData(window.location.pathname + '/save', { type:'paste_amount_rows', updateData: datas }, function (result) {
 
-                     changeList = result;
 
-                     const [newChangeList, updateOrderList] = changeSpreadObj.makeNewChangeList();
 
-                     changeSpreadObj.reloadSheet(newChangeList);
 
-                 }, function () {
 
-                     changeSpreadObj.reloadRow(sheet, sel.row, sel.rowCount);
 
-                     return;
 
-                 });
 
-             }
 
-             return;
 
-         };
 
-         changeSpread.bind(spreadNS.Events.EditEnded, changeSpreadObj.editEnded);
 
-         changeSpread.bind(spreadNS.Events.ClipboardPasted, changeSpreadObj.clipboardPasted);
 
-         SpreadJsObj.addDeleteBind(changeSpread, changeSpreadObj.deletePress);
 
-         xmjSpreadObj.editEnded = function (e, info) {
 
-             if (!info.sheet.zh_setting) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const select = info.sheet.zh_data ? info.sheet.zh_data[info.row] : null;
 
-             const cInfo = _.find(changeList, { id: select.id });
 
-             if (!cInfo) {
 
-                 toastr.error('数据错误,请刷新页面重试');
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const col = info.sheet.zh_setting.cols[info.col];
 
-             let validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : '');
 
-             const orgValue = select[col.field];
 
-             if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === '' || validText === null))) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const node = SpreadJsObj.getSelectObject(changeSpreadSheet);
 
-             if (!node) {
 
-                 toastr.error('数据错误,请选择清单节点后再试');
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             if (col.type === 'Number') {
 
-                 if (isNaN(validText)) {
 
-                     toastr.error('不能输入其它非数字类型字符');
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
 
-                 if (col.field !== 'oamount2') {
 
-                     // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
 
-                     const usedInfo = _.find(changeUsedData, {cbid: select.id});
 
-                     if (usedInfo && validText >= 0 && validText < usedInfo.qty) {
 
-                         toastr.error('清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                         return;
 
-                     } else if (usedInfo && validText < 0 && validText > usedInfo.qty) {
 
-                         toastr.error('清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                         return;
 
-                     }
 
-                 }
 
-             }
 
-             cInfo[col.field] = validText;
 
-             select[col.field] = validText;
 
-             if (col.field !== 'oamount2') {
 
-                 cInfo.spamount = validText;
 
-                 select.spamount = validText;
 
-             }
 
-             const data = {
 
-                 id: select.id,
 
-             };
 
-             if (col.field === 'oamount2') {
 
-                 data[col.field] = select[col.field];
 
-             } else {
 
-                 data.spamount = select.spamount;
 
-             }
 
-             console.log(data);
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/save', { type:'update', updateData: data }, function (result) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 const billIndex = _.indexOf(changeSpreadSheet.zh_data, node);
 
-                 node.children = info.sheet.zh_data;
 
-                 changeSpreadObj.calcOneSum(node);
 
-                 changeSpreadObj.reloadRow(changeSpreadSheet, billIndex);
 
-                 changeSpreadObj.countSum();
 
-             }, function () {
 
-                 select[col.field] = orgValue;
 
-                 cInfo[col.field] = orgValue;
 
-                 if (col.field !== 'oamount2') {
 
-                     select.spamount = orgValue;
 
-                     cInfo.spamount = orgValue;
 
-                 }
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-             });
 
-         };
 
-         xmjSpreadObj.clipboardPasted = function (e, info) {
 
-             if (info.sheet.getColumnCount() > info.sheet.zh_setting.cols.length) {
 
-                 info.sheet.setColumnCount(info.sheet.zh_setting.cols.length);
 
-             }
 
-             const node = SpreadJsObj.getSelectObject(changeSpreadSheet);
 
-             if (!node) {
 
-                 toastr.error('数据错误,请选择清单节点后再试');
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const hint = {
 
-                 cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
 
-                 numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
 
-                 expr: {type: 'warning', msg: '粘贴了表达式非法,已过滤'},
 
-             };
 
-             const range = info.cellRange;
 
-             const sortData = info.sheet.zh_data || [];
 
-             const data = [];
 
-             for (let iRow = 0; iRow < range.rowCount; iRow++) {
 
-                 let bPaste = true;
 
-                 const curRow = range.row + iRow;
 
-                 const cLData = { id: sortData[curRow].id };
 
-                 const hintRow = range.rowCount >= 1 ? curRow : '';
 
-                 let sameCol = 0;
 
-                 for (let iCol = 0; iCol < range.colCount; iCol++) {
 
-                     const curCol = range.col + iCol;
 
-                     let colSetting = info.sheet.zh_setting.cols[curCol];
 
-                     if (!colSetting) continue;
 
-                     let validText = info.sheet.getText(curRow, curCol);
 
-                     validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : '');
 
-                     const orgValue = sortData[curRow][colSetting.field];
 
-                     if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
 
-                         sameCol++;
 
-                         if (range.colCount === sameCol)  {
 
-                             bPaste = false;
 
-                         }
 
-                         continue;
 
-                     }
 
-                     if (colSetting.type === 'Number') {
 
-                         if (isNaN(validText)) {
 
-                             toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
 
-                             bPaste = false;
 
-                             continue;
 
-                         }
 
-                         validText = ZhCalc.round(validText, findDecimal(sortData[curRow].unit)) || 0;
 
-                         if (colSetting.field !== 'oamount2') {
 
-                             // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
 
-                             const usedInfo = _.find(changeUsedData, {id: sortData[curRow].id});
 
-                             if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
 
-                                 toastr.error(hintRow ? '计量单元' + (hintRow + 1) + '行变更数值必须大于等于已调用值 ' + usedInfo.qty : '清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
 
-                                 bPaste = false;
 
-                                 continue;
 
-                             } else if (usedInfo && usedInfo.qty < 0 && validText > usedInfo.qty) {
 
-                                 toastr.error(hintRow ? '计量单元' + (hintRow + 1) + '行变更数值必须小于等于已调用值 ' + usedInfo.qty : '清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
 
-                                 bPaste = false;
 
-                                 continue;
 
-                             }
 
-                         }
 
-                     }
 
-                     sortData[curRow][colSetting.field] = validText;
 
-                     if (colSetting.field === 'oamount2') {
 
-                         cLData[colSetting.field] = validText;
 
-                     } else {
 
-                         cLData.spamount = validText;
 
-                         sortData[curRow].spamount = validText;
 
-                     }
 
-                 }
 
-                 if (bPaste) {
 
-                     data.push(cLData);
 
-                     // rowData.push(curRow);
 
-                 } else {
 
-                     SpreadJsObj.reLoadRowData(info.sheet, curRow);
 
-                 }
 
-             }
 
-             if (data.length === 0) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 return;
 
-             }
 
-             console.log(data);
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/save', { type:'paste_amount_rows', updateData: data }, function (result) {
 
-                 changeList = result;
 
-                 const billIndex = _.indexOf(changeSpreadSheet.zh_data, node);
 
-                 node.children = info.sheet.zh_data;
 
-                 changeSpreadObj.calcOneSum(node);
 
-                 changeSpreadObj.reloadRow(changeSpreadSheet, billIndex);
 
-                 changeSpreadObj.countSum();
 
-                 xmjSpreadObj.loadCurXmjData();
 
-             }, function () {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 return;
 
-             });
 
-         };
 
-         xmjSpreadObj.deletePress = function (sheet) {
 
-             if (!sheet.zh_setting) return;
 
-             const changeNode = SpreadJsObj.getSelectObject(changeSpreadSheet);
 
-             if (!changeNode) {
 
-                 toastr.error('数据错误,请选择清单节点后再试');
 
-                 SpreadJsObj.reLoadRowData(sheet, info.row);
 
-                 return;
 
-             }
 
-             // 暂时仅支持移除数量
 
-             const sel = sheet.getSelections()[0], datas = [];
 
-             for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
 
-                 let bDel = false;
 
-                 const node = sheet.zh_data[iRow];
 
-                 const cInfo = _.find(changeList, { id: node.id });
 
-                 const data = { id: node.id };
 
-                 for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
 
-                     const col = sheet.zh_setting.cols[iCol];
 
-                     if (col.field === 'oamount2' || (col.readOnly !== true && _.includes(col.field, 'audit_amount_') && !checkIsSettle(node))) {
 
-                         node[col.field] = null;
 
-                         cInfo[col.field] = null;
 
-                         if (col.field !== 'oamount2') {
 
-                             data.spamount = null;
 
-                             cInfo.spamount = null;
 
-                             node.spamount = null;
 
-                         } else {
 
-                             data[col.field] = null;
 
-                         }
 
-                         bDel = true;
 
-                     }
 
-                 }
 
-                 if (bDel) datas.push(data);
 
-             }
 
-             if (datas.length > 0) {
 
-                 postData(window.location.pathname + '/save', { type:'paste_amount_rows', updateData: datas }, function (result) {
 
-                     changeList = result;
 
-                     const billIndex = _.indexOf(changeSpreadSheet.zh_data, changeNode);
 
-                     changeNode.children = sheet.zh_data;
 
-                     changeSpreadObj.calcOneSum(changeNode);
 
-                     console.log(changeNode);
 
-                     changeSpreadObj.reloadRow(changeSpreadSheet, billIndex);
 
-                     changeSpreadObj.countSum();
 
-                     xmjSpreadObj.loadCurXmjData();
 
-                 }, function () {
 
-                     SpreadJsObj.reLoadRowData(sheet, sel.row, sel.rowCount);
 
-                     return;
 
-                 });
 
-             }
 
-             return;
 
-         };
 
-         xmjSpread.bind(spreadNS.Events.EditEnded, xmjSpreadObj.editEnded);
 
-         xmjSpread.bind(spreadNS.Events.ClipboardPasted, xmjSpreadObj.clipboardPasted);
 
-         SpreadJsObj.addDeleteBind(xmjSpread, xmjSpreadObj.deletePress);
 
-         ledgerTreeSpreadObj.editEnded = function (e, info) {
 
-             if (!info.sheet.zh_setting) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const col = info.sheet.zh_setting.cols[info.col];
 
-             const sortData = info.sheet.zh_dataType === 'tree' ? info.sheet.zh_tree.nodes : info.sheet.zh_data;
 
-             const select = sortData[info.row];
 
-             if (!select || !select.clid) {
 
-                 toastr.error('数据错误,请刷新页面重试');
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const cInfo = _.find(changeList, { id: select.clid });
 
-             if (!cInfo) {
 
-                 toastr.error('数据错误,请刷新页面重试');
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             let validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : '');
 
-             const orgValue = select[col.field];
 
-             if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === '' || validText === null))) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             if (col.type === 'Number') {
 
-                 if (isNaN(validText)) {
 
-                     toastr.error('不能输入其它非数字类型字符');
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
 
-                 if (col.field !== 'oamount2') {
 
-                     // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
 
-                     const usedInfo = _.find(changeUsedData, {cbid: cInfo.id});
 
-                     if (usedInfo && validText >= 0 && validText < usedInfo.qty) {
 
-                         toastr.error('清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                         return;
 
-                     } else if (usedInfo && validText < 0 && validText > usedInfo.qty) {
 
-                         toastr.error('清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                         return;
 
-                     }
 
-                 }
 
-             }
 
-             cInfo[col.field] = validText;
 
-             select[col.field] = validText;
 
-             if (col.field !== 'oamount2') {
 
-                 cInfo.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
 
-                 select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
 
-             }
 
-             const data = {
 
-                 id: cInfo.id,
 
-             };
 
-             if (col.field === 'oamount2') {
 
-                 data[col.field] = select[col.field];
 
-             } else {
 
-                 data.spamount = select.spamount;
 
-             }
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/save', { type:'update', updateData: data }, function (result) {
 
-                 const loadResult = {
 
-                     update: [select],
 
-                 };
 
-                 const refreshData = ledgerTree.loadPostData(loadResult);
 
-                 ledgerTreeSpreadObj.refreshTree(ledgerSheet, refreshData);
 
-             }, function () {
 
-                 select[col.field] = orgValue;
 
-                 cInfo[col.field] = orgValue;
 
-                 if(col.field !== 'oamount2') {
 
-                     select.spamount = orgValue;
 
-                     cInfo.spamount = orgValue;
 
-                 }
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-             });
 
-         };
 
-         ledgerTreeSpreadObj.clipboardPasted = function (e, info) {
 
-             const tree = info.sheet.zh_tree;
 
-             if (!tree) { return; }
 
-             if (info.sheet.getColumnCount() > info.sheet.zh_setting.cols.length) {
 
-                 info.sheet.setColumnCount(info.sheet.zh_setting.cols.length);
 
-             }
 
-             const hint = {
 
-                 cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
 
-                 numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
 
-                 expr: {type: 'warning', msg: '粘贴了表达式非法,已过滤'},
 
-             };
 
-             const range = info.cellRange;
 
-             const sortData = info.sheet.zh_tree.nodes;
 
-             const selects = [];
 
-             const data = [];
 
-             for (let iRow = 0; iRow < range.rowCount; iRow++) {
 
-                 let bPaste = true;
 
-                 const curRow = range.row + iRow;
 
-                 const node = sortData[curRow];
 
-                 if (!node) {
 
-                     continue;
 
-                 }
 
-                 const cLData = { id: sortData[curRow].clid };
 
-                 const hintRow = range.rowCount >= 1 ? curRow : '';
 
-                 let sameCol = 0;
 
-                 for (let iCol = 0; iCol < range.colCount; iCol++) {
 
-                     const curCol = range.col + iCol;
 
-                     let colSetting = info.sheet.zh_setting.cols[curCol];
 
-                     if (!colSetting) continue;
 
-                     let validText = info.sheet.getText(curRow, curCol);
 
-                     validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : '');
 
-                     const orgValue = sortData[curRow][colSetting.field];
 
-                     if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
 
-                         sameCol++;
 
-                         if (range.colCount === sameCol)  {
 
-                             bPaste = false;
 
-                         }
 
-                         continue;
 
-                     }
 
-                     if (colSetting.type === 'Number') {
 
-                         if (isNaN(validText)) {
 
-                             toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
 
-                             bPaste = false;
 
-                             continue;
 
-                         }
 
-                         validText = ZhCalc.round(validText, findDecimal(sortData[curRow].unit)) || 0;
 
-                         if (colSetting.field !== 'oamount2') {
 
-                             // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
 
-                             const usedInfo = _.find(changeUsedData, {id: sortData[curRow].clid});
 
-                             if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
 
-                                 toastr.error(hintRow ? '台账' + (hintRow + 1) + '行变更数值必须大于等于已调用值 ' + usedInfo.qty : '清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
 
-                                 SpreadJsObj.reLoadRowData(info.sheet, curRow);
 
-                                 bPaste = false;
 
-                                 continue;
 
-                             } else if (usedInfo && usedInfo.qty < 0 && validText > usedInfo.qty) {
 
-                                 toastr.error(hintRow ? '台账' + (hintRow + 1) + '行变更数值必须小于等于已调用值 ' + usedInfo.qty : '清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
 
-                                 SpreadJsObj.reLoadRowData(info.sheet, curRow);
 
-                                 bPaste = false;
 
-                                 continue;
 
-                             }
 
-                         }
 
-                     }
 
-                     sortData[curRow][colSetting.field] = validText;
 
-                     if (colSetting.field === 'oamount2') {
 
-                         cLData[colSetting.field] = validText;
 
-                     } else {
 
-                         cLData.spamount = validText;
 
-                         sortData[curRow].spamount = cLData.spamount;
 
-                     }
 
-                 }
 
-                 if (bPaste) {
 
-                     data.push(cLData);
 
-                     selects.push(sortData[curRow]);
 
-                 } else {
 
-                     SpreadJsObj.reLoadRowData(info.sheet, curRow);
 
-                 }
 
-             }
 
-             if (data.length === 0) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 return;
 
-             }
 
-             console.log(data, selects);
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/save', { type:'paste_amount_rows', updateData: data }, function (result) {
 
-                 changeList = result;
 
-                 const loadResult = {
 
-                     update: selects,
 
-                 };
 
-                 const refreshData = ledgerTree.loadPostData(loadResult);
 
-                 ledgerTreeSpreadObj.refreshTree(ledgerSheet, refreshData);
 
-                 ledgerTreeSpreadObj.loadExprToInput();
 
-             }, function () {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 return;
 
-             });
 
-         };
 
-         ledgerTreeSpreadObj.deletePress = function (sheet) {
 
-             if (!sheet.zh_setting) return;
 
-             // 暂时仅支持移除数量
 
-             const sel = sheet.getSelections()[0], datas = [];
 
-             const selects = [];
 
-             for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
 
-                 let bDel = false;
 
-                 const node = sheet.zh_tree.nodes[iRow];
 
-                 const cInfo = _.find(changeList, { id: node.clid });
 
-                 const data = { id: node.clid };
 
-                 for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
 
-                     const col = sheet.zh_setting.cols[iCol];
 
-                     if (col.field === 'oamount2' || (col.readOnly !== true && _.includes(col.field, 'audit_amount_') && !checkIsSettle(node))) {
 
-                         node[col.field] = null;
 
-                         cInfo[col.field] = null;
 
-                         if (col.field !== 'oamount2') {
 
-                             data.spamount = null;
 
-                             cInfo.spamount = null;
 
-                             node.spamount = null;
 
-                         } else {
 
-                             data[col.field] = null;
 
-                         }
 
-                         bDel = true;
 
-                     }
 
-                 }
 
-                 if (bDel) {
 
-                     datas.push(data);
 
-                     selects.push(node);
 
-                 }
 
-             }
 
-             if (datas.length > 0) {
 
-                 postData(window.location.pathname + '/save', { type:'paste_amount_rows', updateData: datas }, function (result) {
 
-                     changeList = result;
 
-                     const loadResult = {
 
-                         update: selects,
 
-                     };
 
-                     const refreshData = ledgerTree.loadPostData(loadResult);
 
-                     ledgerTreeSpreadObj.refreshTree(ledgerSheet, refreshData);
 
-                     ledgerTreeSpreadObj.loadExprToInput();
 
-                 }, function () {
 
-                     SpreadJsObj.reLoadRowData(sheet, sel.row, sel.rowCount);
 
-                     return;
 
-                 });
 
-             }
 
-             return;
 
-         };
 
-         ledgerSpread.bind(spreadNS.Events.EditEnded, ledgerTreeSpreadObj.editEnded);
 
-         ledgerSpread.bind(spreadNS.Events.ClipboardPasted, ledgerTreeSpreadObj.clipboardPasted);
 
-         SpreadJsObj.addDeleteBind(ledgerSpread, ledgerTreeSpreadObj.deletePress);
 
-         posSpreadObj.editEnded = function (e, info) {
 
-             if (!info.sheet.zh_setting) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const select = info.sheet.zh_data ? info.sheet.zh_data[info.row] : null;
 
-             const cInfo = _.find(changeList, { id: select.clid });
 
-             if (!cInfo) {
 
-                 toastr.error('数据错误,请刷新页面重试');
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const col = info.sheet.zh_setting.cols[info.col];
 
-             let validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : '');
 
-             const orgValue = select[col.field];
 
-             if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === '' || validText === null))) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             const node = SpreadJsObj.getSelectObject(ledgerSheet);
 
-             if (!node) {
 
-                 toastr.error('数据错误,请选择台账节点后再试');
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 return;
 
-             }
 
-             if (col.type === 'Number') {
 
-                 if (isNaN(validText)) {
 
-                     toastr.error('不能输入其它非数字类型字符');
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
 
-                 if (col.field !== 'oamount2') {
 
-                     // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
 
-                     const usedInfo = _.find(changeUsedData, {cbid: select.clid});
 
-                     if (usedInfo && validText >= 0 && validText < usedInfo.qty) {
 
-                         toastr.error('清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                         return;
 
-                     } else if (usedInfo && validText < 0 && validText > usedInfo.qty) {
 
-                         toastr.error('清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                         return;
 
-                     }
 
-                 }
 
-             }
 
-             cInfo[col.field] = validText;
 
-             select[col.field] = validText;
 
-             if (col.field !== 'oamount2') {
 
-                 cInfo.spamount = validText;
 
-                 select.spamount = validText;
 
-             }
 
-             const data = {
 
-                 id: select.clid,
 
-             };
 
-             if (col.field === 'oamount2') {
 
-                 data[col.field] = select[col.field];
 
-             } else {
 
-                 data.spamount = select.spamount;
 
-             }
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/save', { type:'update', updateData: data }, function (result) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 const loadResult = {
 
-                     update: [node],
 
-                 };
 
-                 const refreshData = ledgerTree.loadPostData(loadResult);
 
-                 ledgerTreeSpreadObj.refreshTree(ledgerSheet, refreshData);
 
-             }, function () {
 
-                 select[col.field] = orgValue;
 
-                 cInfo[col.field] = orgValue;
 
-                 if (col.field !== 'oamount2') {
 
-                     select.spamount = orgValue;
 
-                     cInfo.spamount = orgValue;
 
-                 }
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-             });
 
-         };
 
-         posSpreadObj.clipboardPasted = function (e, info) {
 
-             if (info.sheet.getColumnCount() > info.sheet.zh_setting.cols.length) {
 
-                 info.sheet.setColumnCount(info.sheet.zh_setting.cols.length);
 
-             }
 
-             const hint = {
 
-                 cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
 
-                 numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
 
-                 expr: {type: 'warning', msg: '粘贴了表达式非法,已过滤'},
 
-             };
 
-             const range = info.cellRange;
 
-             const sortData = info.sheet.zh_data || [];
 
-             const data = [];
 
-             for (let iRow = 0; iRow < range.rowCount; iRow++) {
 
-                 let bPaste = true;
 
-                 const curRow = range.row + iRow;
 
-                 const cLData = { id: sortData[curRow].clid };
 
-                 const hintRow = range.rowCount >= 1 ? curRow : '';
 
-                 let sameCol = 0;
 
-                 for (let iCol = 0; iCol < range.colCount; iCol++) {
 
-                     const curCol = range.col + iCol;
 
-                     let colSetting = info.sheet.zh_setting.cols[curCol];
 
-                     if (!colSetting) continue;
 
-                     let validText = info.sheet.getText(curRow, curCol);
 
-                     validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : '');
 
-                     const orgValue = sortData[curRow][colSetting.field];
 
-                     if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
 
-                         sameCol++;
 
-                         if (range.colCount === sameCol)  {
 
-                             bPaste = false;
 
-                         }
 
-                         continue;
 
-                     }
 
-                     if (colSetting.type === 'Number') {
 
-                         if (isNaN(validText)) {
 
-                             toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
 
-                             bPaste = false;
 
-                             continue;
 
-                         }
 
-                         validText = ZhCalc.round(validText, findDecimal(sortData[curRow].unit)) || 0;
 
-                         if (colSetting.field !== 'oamount2') {
 
-                             // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
 
-                             const usedInfo = _.find(changeUsedData, {id: sortData[curRow].clid});
 
-                             if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
 
-                                 toastr.error(hintRow ? '计量单元' + (hintRow + 1) + '行变更数值必须大于等于已调用值 ' + usedInfo.qty : '清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
 
-                                 bPaste = false;
 
-                                 continue;
 
-                             } else if (usedInfo && usedInfo.qty < 0 && validText > usedInfo.qty) {
 
-                                 toastr.error(hintRow ? '计量单元' + (hintRow + 1) + '行变更数值必须小于等于已调用值 ' + usedInfo.qty : '清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
 
-                                 bPaste = false;
 
-                                 continue;
 
-                             }
 
-                         }
 
-                     }
 
-                     sortData[curRow][colSetting.field] = validText;
 
-                     if (colSetting.field === 'oamount2') {
 
-                         cLData[colSetting.field] = validText;
 
-                     } else {
 
-                         cLData.spamount = validText;
 
-                         sortData[curRow].spamount = validText;
 
-                     }
 
-                 }
 
-                 if (bPaste) {
 
-                     data.push(cLData);
 
-                     // rowData.push(curRow);
 
-                 } else {
 
-                     SpreadJsObj.reLoadRowData(info.sheet, curRow);
 
-                 }
 
-             }
 
-             if (data.length === 0) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 return;
 
-             }
 
-             console.log(data);
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/save', { type:'paste_amount_rows', updateData: data }, function (result) {
 
-                 changeList = result;
 
-                 const node = SpreadJsObj.getSelectObject(ledgerSheet);
 
-                 const loadResult = {
 
-                     update: [node],
 
-                 };
 
-                 const refreshData = ledgerTree.loadPostData(loadResult);
 
-                 ledgerTreeSpreadObj.refreshTree(ledgerSheet, refreshData);
 
-                 posSpreadObj.loadCurPosData();
 
-             }, function () {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 return;
 
-             });
 
-         };
 
-         posSpreadObj.deletePress = function (sheet) {
 
-             if (!sheet.zh_setting) return;
 
-             // 暂时仅支持移除数量
 
-             const sel = sheet.getSelections()[0], datas = [];
 
-             for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
 
-                 let bDel = false;
 
-                 const node = sheet.zh_data[iRow];
 
-                 const cInfo = _.find(changeList, { id: node.clid });
 
-                 const data = { id: node.clid };
 
-                 for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
 
-                     const col = sheet.zh_setting.cols[iCol];
 
-                     if (col.field === 'oamount2' || (col.readOnly !== true && _.includes(col.field, 'audit_amount_') && !checkIsSettle(node))) {
 
-                         node[col.field] = null;
 
-                         cInfo[col.field] = null;
 
-                         if (col.field !== 'oamount2') {
 
-                             data.spamount = null;
 
-                             cInfo.spamount = null;
 
-                             node.spamount = null;
 
-                         } else {
 
-                             data[col.field] = null;
 
-                         }
 
-                         bDel = true;
 
-                     }
 
-                 }
 
-                 if (bDel) datas.push(data);
 
-             }
 
-             if (datas.length > 0) {
 
-                 postData(window.location.pathname + '/save', { type:'paste_amount_rows', updateData: datas }, function (result) {
 
-                     changeList = result;
 
-                     const billsNode = SpreadJsObj.getSelectObject(ledgerSheet);
 
-                     const loadResult = {
 
-                         update: [billsNode],
 
-                     };
 
-                     const refreshData = ledgerTree.loadPostData(loadResult);
 
-                     ledgerTreeSpreadObj.refreshTree(ledgerSheet, refreshData);
 
-                     posSpreadObj.loadCurPosData();
 
-                 }, function () {
 
-                     SpreadJsObj.reLoadRowData(sheet, sel.row, sel.rowCount);
 
-                     return;
 
-                 });
 
-             }
 
-             return;
 
-         };
 
-         posSpread.bind(spreadNS.Events.EditEnded, posSpreadObj.editEnded);
 
-         posSpread.bind(spreadNS.Events.ClipboardPasted, posSpreadObj.clipboardPasted);
 
-         SpreadJsObj.addDeleteBind(posSpread, posSpreadObj.deletePress);
 
-     }
 
-     // 切换清单模式
 
-     $('.change-mode').on('click', async function () {
 
-         if ($(this).hasClass('active')) {
 
-             return;
 
-         }
 
-         $('.change-mode').removeClass('active');
 
-         $(this).addClass('active');
 
-         const type = parseInt($(this).data('type'));
 
-         postData(window.location.pathname + '/save', { type:'change_mode', updateData: type }, function (result) {
 
-             changeList = result;
 
-             changeMode = type;
 
-             showMode(type);
 
-         });
 
-     });
 
-     function showMode(type) {
 
-         if (type === 0) {
 
-             $('.judge-hide').show();
 
-             $('.judge-show').attr("style","display:none !important");
 
-             if (changeOrder === 0) {
 
-                 $('#upAndMoveBtn').attr("style","display:none !important");
 
-             }
 
-             const [newChangeList, updateOrderList] = changeSpreadObj.makeNewChangeList();
 
-             if (updateOrderList.length > 0) {
 
-                 postData(window.location.pathname + '/save', { type:'changeOrder', postData: updateOrderList }, function (result) {
 
-                 });
 
-             }
 
-             changeSpreadObj.reloadSheet(newChangeList);
 
-             changeSpread.refresh();
 
-             xmjSpread.refresh();
 
-         } else {
 
-             $('.judge-hide').attr("style","display:none !important");
 
-             $('.judge-show').show();
 
-             const {changeLedgers, changePoss} = makeLedgerAndPosData();
 
-             ledgerTree.loadDatas(changeLedgers);
 
-             pos.loadDatas(changePoss);
 
-             treeCalc.calculateAll(ledgerTree);
 
-             console.log(ledgerTree);
 
-             SpreadJsObj.loadSheetData(ledgerSheet, SpreadJsObj.DataType.Tree, ledgerTree);
 
-             ledgerTree.expandByCustom(() => { return true; });
 
-             SpreadJsObj.refreshTreeRowVisible(ledgerSheet);
 
-             SpreadJsObj.loadTopAndSelect(ledgerSheet, ckBillsSpread);
 
-             ledgerTreeSpreadObj.showHideAudit($('#show-table-detail').is(':checked'));
 
-             posSpreadObj.loadCurPosData();
 
-             SpreadJsObj.resetTopAndSelect(posSheet);
 
-             ledgerTreeSpreadObj.loadExprToInput();
 
-             ledgerSpread.refresh();
 
-             posSpread.refresh();
 
-         }
 
-     }
 
-     function makeLedgerAndPosData() {
 
-         const changeLedgers = _.filter(ledgerList, function (item) {
 
-             return _.findIndex(changeList, { gcl_id: item.id}) !== -1;
 
-         });
 
-         // 找出所有父节点
 
-         if (changeLedgers.length > 0) {
 
-             const parentLedgers = [];
 
-             for (const node of changeLedgers) {
 
-                 const cl = _.find(changeList, { gcl_id: node.id, mx_id: '' });
 
-                 if (cl) {
 
-                     const cloneCl = _.cloneDeep(cl);
 
-                     delete cloneCl.id;
 
-                     delete cloneCl.name;
 
-                     delete cloneCl.code;
 
-                     node.clid = cl.id;
 
-                     // cloneCl 合并到node中
 
-                     Object.assign(node, cloneCl);
 
-                 }
 
-                 if (node.full_path && node.full_path !== '') {
 
-                     const parentIds = node.full_path.split('-');
 
-                     parentIds.length = parentIds.length - 1;
 
-                     for (const id of parentIds) {
 
-                         const lid = parseInt(id);
 
-                         if (lid !== node.ledger_id && _.findIndex(parentLedgers, { ledger_id: lid }) === -1) {
 
-                             parentLedgers.push(_.find(ledgerList, { ledger_id: lid }));
 
-                         }
 
-                     }
 
-                 }
 
-             }
 
-             changeLedgers.push(...parentLedgers);
 
-         }
 
-         // 找出空白清单和签约清单
 
-         const otherChangeList = _.filter(changeList, function (item) {
 
-             return item.gcl_id === '' || item.gcl_id === null || item.gcl_id == 0;
 
-         });
 
-         if (otherChangeList.length > 0) {
 
-             // 判断changeLedgers中是否已经存在第一部分
 
-             let firstChangeLedger = _.find(changeLedgers, { order: 1, level: 1 });
 
-             let firstOrder = 1;
 
-             if (firstChangeLedger) {
 
-                 const firstChilds = _.filter(changeLedgers, { ledger_pid: firstChangeLedger.ledger_id });
 
-                 firstOrder =  _.maxBy(firstChilds, 'order').order + 1;
 
-             }
 
-             let maxLedgerId = changeLedgers.length > 0 ? _.maxBy(changeLedgers, 'ledger_id').ledger_id + 1 : 2;
 
-             if (!firstChangeLedger) {
 
-                 const firstLedger = _.find(ledgerList, { order: 1, level: 1 });
 
-                 if (firstLedger) {
 
-                     changeLedgers.push(firstLedger);
 
-                     firstChangeLedger = firstLedger;
 
-                 } else {
 
-                     firstChangeLedger = { id: 'new-tree-ledger-1', ledger_id: 1, ledger_pid: -1, name: '第一部分 建筑安装工程费', unit: '公路公里', unit_price: 0, b_code: null, code: '1', order: 1, level: 1, full_path: '1', is_leaf: 0 };
 
-                     changeLedgers.push(firstChangeLedger);
 
-                 }
 
-             }
 
-             for (const cl of otherChangeList) {
 
-                 const cloneCl = _.cloneDeep(cl);
 
-                 cloneCl.b_code = cloneCl.code;
 
-                 cloneCl.code = null;
 
-                 cloneCl.clid = cl.id;
 
-                 cloneCl.level = 2;
 
-                 cloneCl.order = firstOrder;
 
-                 cloneCl.is_leaf = 1;
 
-                 cloneCl.ledger_pid = firstChangeLedger.ledger_id;
 
-                 cloneCl.ledger_id = maxLedgerId;
 
-                 cloneCl.full_path = firstChangeLedger.full_path + '-' + maxLedgerId;
 
-                 console.log(cloneCl);
 
-                 changeLedgers.push(cloneCl);
 
-                 maxLedgerId++;
 
-                 firstOrder++;
 
-             }
 
-         }
 
-         const changePoss = _.filter(posList, function (item) {
 
-             return _.findIndex(changeList, { mx_id: item.id }) !== -1;
 
-         });
 
-         for (const cp of changePoss) {
 
-             const cl = _.find(changeList, { mx_id: cp.id });
 
-             if (cl) {
 
-                 const cloneCl = _.cloneDeep(cl);
 
-                 delete cloneCl.id;
 
-                 delete cloneCl.lid;
 
-                 delete cloneCl.name;
 
-                 cp.clid = cl.id;
 
-                 // cloneCl 合并到cp中
 
-                 Object.assign(cp, cloneCl);
 
-             }
 
-         }
 
-         return { changeLedgers, changePoss };
 
-     }
 
-     // 审批流程展示与隐藏
 
-     $('#show-table-detail').on('click', function (e) {
 
-         if($(e.target).is('label')){
 
-             return;
 
-         }
 
-         ledgerTreeSpreadObj.showHideAudit($(this).is(':checked'));
 
-         posSpreadObj.showHideAudit($(this).is(':checked'));
 
-         changeSpreadObj.showHideAudit($(this).is(':checked'));
 
-         xmjSpreadObj.showHideAudit($(this).is(':checked'));
 
-     });
 
-     const cca = getLocalCache('change-checkbox-account-' + accountId);
 
-     if (cca !== null && cca !== undefined) {
 
-         $('#customCheck1').prop('checked', cca !== 'false');
 
-     }
 
-     changeSpreadSheet.setColumnVisible(6,$('#customCheck1').is(':checked'), GC.Spread.Sheets.SheetArea.viewport);
 
-     xmjSheet.setColumnVisible(7,$('#customCheck1').is(':checked'), GC.Spread.Sheets.SheetArea.viewport);
 
-     ledgerSheet.setColumnVisible(6,$('#customCheck1').is(':checked'), GC.Spread.Sheets.SheetArea.viewport);
 
-     posSheet.setColumnVisible(2,$('#customCheck1').is(':checked'), GC.Spread.Sheets.SheetArea.viewport);
 
-     // 变更详情展示和隐藏
 
-     $('.change-detail-checkbox').on('click', function (e) {
 
-         if($(e.target).is('label')){
 
-             return;
 
-         }
 
-         // // 设置用户项目本地记录展示和隐藏情况
 
-         setLocalCache('change-checkbox-account-'+ accountId, $(this).is(':checked'));
 
-         changeSpreadSheet.setColumnVisible(6,$(this).is(':checked'), GC.Spread.Sheets.SheetArea.viewport);
 
-         xmjSheet.setColumnVisible(7,$(this).is(':checked'), GC.Spread.Sheets.SheetArea.viewport);
 
-         ledgerSheet.setColumnVisible(6,$(this).is(':checked'), GC.Spread.Sheets.SheetArea.viewport);
 
-         posSheet.setColumnVisible(2,$(this).is(':checked'), GC.Spread.Sheets.SheetArea.viewport);
 
-     });
 
-     $.subMenu({
 
-         menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
 
-         toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
 
-         key: 'menu.1.0.0',
 
-         miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',
 
-         callback: function (info) {
 
-             if (info.mini) {
 
-                 $('.panel-title').addClass('fluid');
 
-                 $('#sub-menu').removeClass('panel-sidebar');
 
-             } else {
 
-                 $('.panel-title').removeClass('fluid');
 
-                 $('#sub-menu').addClass('panel-sidebar');
 
-             }
 
-             autoFlashHeight();
 
-             changeSpread.refresh();
 
-             xmjSpread.refresh();
 
-             ledgerSpread.refresh();
 
-             posSpread.refresh();
 
-         }
 
-     });
 
-     $.divResizer({
 
-         select: '#right-spr',
 
-         callback: function () {
 
-             changeSpread.refresh();
 
-             xmjSpread.refresh();
 
-             ledgerSpread.refresh();
 
-             posSpread.refresh();
 
-             const width = (($('#right-view').width()/$('#right-view').parent('div').width())*100).toFixed();
 
-             setLocalCache('change_information_width', width);
 
-             $('#left-header').css('min-width', (100 - parseFloat(getLocalCache('change_information_width'))) + '%');
 
-         }
 
-     });
 
-     $('.sjs-height-change').height($('.sjs-height-1').height() - $('#list-tab').outerHeight() - 10);
 
-     changeSpread.refresh();
 
-     xmjSpread.refresh();
 
-     ledgerSpread.refresh();
 
-     posSpread.refresh();
 
-     // 根据浏览器记录展开收起
 
-     if (getLocalCache('change_information_width')) {
 
-         $('#left-view').css('width', (100 - parseFloat(getLocalCache('change_information_width'))) + '%');
 
-         $('#right-view').css('width', getLocalCache('change_information_width') + '%');
 
-         $('#left-header').css('min-width', (100 - parseFloat(getLocalCache('change_information_width'))) + '%');
 
-         changeSpread.refresh();
 
-         xmjSpread.refresh();
 
-         ledgerSpread.refresh();
 
-         posSpread.refresh();
 
-     } else {
 
-         $('#left-header').css('min-width', '33.33%');
 
-     }
 
-     $.divResizer({
 
-         select: '#change-pos-resize',
 
-         callback: function () {
 
-             $('.sjs-height-change').height($('.sjs-height-1').height() - $('#list-tab').outerHeight() - 10);
 
-             changeSpread.refresh();
 
-             ledgerSpread.refresh();
 
-             let bcontent = $(".bcontent-wrap") ? $(".bcontent-wrap").height() : 0;
 
-             $(".sp-wrap").height(bcontent-30);
 
-             posSpread.refresh();
 
-             xmjSpread.refresh();
 
-         }
 
-     });
 
-     if (!readOnly) {
 
-         // 自动编号
 
-         $('.reduction-code').click(function () {
 
-             const code = $(this).attr('data-code');
 
-             $('input[name="code"]').val(code);
 
-             changeInfo.code = $('input[name="code"]').val();
 
-             judgeChange();
 
-         });
 
-         // 记录变更信息操作
 
-         $('body').on('valuechange', '#change_form input[type="text"]', function (e, previous) {
 
-             changeInfo[$(this).attr('name')] = $(this).val();
 
-             judgeChange();
 
-         });
 
-         $('body').on('valuechange', '#change_form textarea', function (e, previous) {
 
-             changeInfo[$(this).attr('name')] = $(this).val().replace(/[\r\n]/g, '<br><br>');
 
-             judgeChange();
 
-         });
 
-         $('body').on('change', '#change_form select', function (e, previous) {
 
-             changeInfo[$(this).attr('name')] = $(this).val();
 
-             judgeChange();
 
-         });
 
-         $('body').on('click', '#change_form input[type="radio"]', function (e, previous) {
 
-             changeInfo[$(this).attr('name')] = $(this).val();
 
-             judgeChange();
 
-         });
 
-         $('body').on('click', '#change_form input[type="checkbox"]', function (e, previous) {
 
-             const typecheck = [];
 
-             $.each($('#change_form input[name="type[]"]:checked'), function () {
 
-                 typecheck.push($(this).val());
 
-             });
 
-             changeInfo.type = typecheck.join(',');
 
-             judgeChange();
 
-         });
 
-         // 保存修改ajax提交(不刷新页面)
 
-         $('.save_change_btn').on('click', function () {
 
-             // 保存修改modal
 
-             if ($('input[name="code"]').val() === '') {
 
-                 toastr.error('申请编号不能为空!');
 
-                 return;
 
-             }
 
-             if ($('input[name="name"]').val() === '') {
 
-                 toastr.error('变更工程名称不能为空!');
 
-                 return;
 
-             }
 
-             // 换行更改并提交
 
-             changeInfo.content = changeInfo.content.replace(/<br><br>/g, '\r\n');
 
-             changeInfo.basis = changeInfo.basis.replace(/<br><br>/g, '\r\n');
 
-             changeInfo.expr = changeInfo.expr.replace(/<br><br>/g, '\r\n');
 
-             changeInfo.memo = changeInfo.memo.replace(/<br><br>/g, '\r\n');
 
-             changeInfo.company = $('#change_form select[name="company"]').val();
 
-             // 后改为br
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/save', { type:'info', updateData: changeInfo }, function (result) {
 
-                 $('.reduction-code').attr('data-code', $('input[name="code"]').val());
 
-                 toastr.success(result ? result.msg : '');
 
-                 $('#show-save-btn').hide();
 
-                 $('#sp-btn').show();
 
-                 $('.title-main').removeClass('bg-warning');
 
-                 changeInfo.content = changeInfo.content.replace(/[\r\n]/g, '<br>');
 
-                 changeInfo.basis = changeInfo.basis.replace(/[\r\n]/g, '<br>');
 
-                 changeInfo.expr = changeInfo.expr.replace(/[\r\n]/g, '<br>');
 
-                 changeInfo.memo = changeInfo.memo.replace(/[\r\n]/g, '<br>');
 
-                 back_changeInfo = Object.assign({}, changeInfo);
 
-                 if (result.changeList) {
 
-                     deLimit = result.deLimit;
 
-                     changeList = result.changeList;
 
-                     SpreadJsObj.initSpreadSettingEvents(changeSpreadSetting, changeCol);
 
-                     SpreadJsObj.initSheet(changeSpreadSheet, changeSpreadSetting);
 
-                     const [newChangeList] = changeSpreadObj.makeNewChangeList();
 
-                     changeSpreadObj.reloadSheet(newChangeList);
 
-                 }
 
-             });
 
-             return false;
 
-         });
 
-         $('#cancel_change').on('click', function () {
 
-             $('#show-save-btn').hide();
 
-             $('#sp-btn').show();
 
-             $('.title-main').removeClass('bg-warning');
 
-             if (!isObjEqual(changeInfo, back_changeInfo)) {
 
-                 changeFormRemake();
 
-             }
 
-             toastr.success('已还原到上次保存状态');
 
-         });
 
-         // 判断是否有更改过
 
-         function judgeChange() {
 
-             let change = false;
 
-             console.log(changeInfo, back_changeInfo);
 
-             if (!isObjEqual(changeInfo, back_changeInfo)) {
 
-                 change = true;
 
-             }
 
-             if (change) {
 
-                 $('#show-save-btn').show();
 
-                 $('#sp-btn').hide();
 
-                 $('.title-main').addClass('bg-warning');
 
-             } else {
 
-                 $('#show-save-btn').hide();
 
-                 $('#sp-btn').show();
 
-                 $('.title-main').removeClass('bg-warning');
 
-             }
 
-         }
 
-         function changeFormRemake() {
 
-             changeInfo = Object.assign({}, back_changeInfo);
 
-             $('#change_form input[name="code"]').val(changeInfo.code);
 
-             $('#change_form input[name="name"]').val(changeInfo.name);
 
-             $('#change_form input[name="peg"]').val(changeInfo.peg);
 
-             $('#change_form input[name="org_name"]').val(changeInfo.org_name);
 
-             $('#change_form input[name="org_code"]').val(changeInfo.org_code);
 
-             $('#change_form input[name="new_name"]').val(changeInfo.new_name);
 
-             $('#change_form input[name="new_code"]').val(changeInfo.new_code);
 
-             $('#change_form textarea[name="content"]').val(changeInfo.content.replace(/<br><br>/g, '\r\n'));
 
-             $('#change_form textarea[name="basis"]').val(changeInfo.basis.replace(/<br><br>/g, '\r\n'));
 
-             $('#change_form textarea[name="expr"]').val(changeInfo.expr.replace(/<br><br>/g, '\r\n'));
 
-             $('#change_form textarea[name="memo"]').val(changeInfo.memo.replace(/<br><br>/g, '\r\n'));
 
-             $('#change_form select[name="type"]').val(changeInfo.type);
 
-             $('#change_form select[name="class"]').val(changeInfo.class);
 
-             $('#change_form select[name="quality"]').val(changeInfo.quality);
 
-             $('#change_form select[name="company"]').val(changeInfo.company);
 
-             $('#change_form input[name="charge"][value="'+ changeInfo.charge +'"]').prop('checked', true);
 
-             $('#change_form input[name="state"][value="'+ changeInfo.state +'"]').prop('checked', true);
 
-             $('#change_form input[name="type[]"]').prop('checked', false);
 
-             const typecheck = changeInfo.type.split(',');
 
-             for (const type of typecheck) {
 
-                 $('#change_form input[name="type[]"][value="'+ type +'"]').prop('checked', true);
 
-             }
 
-         }
 
-         $('.checkChangeFrom').on('click', function () {
 
-             let returnFlag = false;
 
-             // 表单判断
 
-             if ($('input[name="code"]').val() === '') {
 
-                 toastr.error('申请编号不能为空!');
 
-                 returnFlag = true;
 
-             }
 
-             if ($('input[name="name"]').val() === '') {
 
-                 toastr.error('变更工程名称不能为空!');
 
-                 returnFlag = true;
 
-             }
 
-             if ($('textarea[name="content"]').val() === '') {
 
-                 toastr.error('工程变更理由及内容不能为空!');
 
-                 returnFlag = true;
 
-             }
 
-             if (changeList.length === 0) {
 
-                 toastr.error('请添加变更清单!');
 
-                 returnFlag = true;
 
-             } else {
 
-                 for (const [i,cl] of changeSpreadSheet.zh_data.entries()) {
 
-                     if (cl.name === '') {
 
-                         toastr.error('清单第' + (i+1) + '行未完整填写数据(名称不可为空)');
 
-                         returnFlag = true;
 
-                     }
 
-                 }
 
-             }
 
-             if(!checkAuditorFrom ()) {
 
-                 returnFlag = true;
 
-             }
 
-             // 判断非空白变更清单是否有重复值(gcl_id及mx_id),如果存在完全相同则需要提示并删除,上报失败,这功能主要是因为清单数据过多服务器处理不过来偶然出现
 
-             const doubleList = findDuplicates(_.filter(changeList, item => item.lid != 0));
 
-             console.log(doubleList);
 
-             if (doubleList.length > 0) {
 
-                 for (const double of doubleList) {
 
-                     const msgIndex = [];
 
-                     for (const one of double) {
 
-                         const index = _.findIndex(changeSpreadSheet.zh_data[double[0].order - 1].children, { id: one.id });
 
-                         if (index !== -1) msgIndex.push(index+1);
 
-                     }
 
-                     if (msgIndex.length > 0) {
 
-                         toastr.error('第 ' + double[0].order + ' 行' + double[0].code + '清单项目节第 ' + msgIndex.splice(',') + '行重复,请只保留一条数据');
 
-                     }
 
-                 }
 
-                 returnFlag = true;
 
-             }
 
-             if (returnFlag) {
 
-                 return false;
 
-             }
 
-             postData(window.location.pathname + '/audit/start', {}, function (result) {
 
-                 window.location.reload();
 
-             })
 
-         });
 
-         // 检查上报情况
 
-         function checkAuditorFrom () {
 
-             if ($('#auditList li').length === 0) {
 
-                 if(shenpi_status === shenpiConst.sp_status.gdspl) {
 
-                     toastr.error('请联系管理员添加审批人');
 
-                 } else {
 
-                     toastr.error('请先选择审批人,再上报数据');
 
-                 }
 
-                 return false;
 
-             }
 
-             return true;
 
-         }
 
-         // 找出数组中相同的清单
 
-         function findDuplicates(arr, keys = ['lid', 'gcl_id', 'mx_id']) {
 
-             const groupedData = _.groupBy(arr, item => JSON.stringify(_.pick(item, keys)));
 
-             const duplicates = _.filter(groupedData, group => group.length > 1);
 
-             return _.values(duplicates);
 
-         }
 
-     }
 
-     if (shenpiPower) {
 
-         // 审批提交与判断
 
-         $('.approval-btn').on('click', function () {
 
-             // 判断审批状态
 
-             let returnflag = true;
 
-             const pData = {
 
-                 change_id: $('#changeId').val(),
 
-                 w_code: $.trim($('#w_code').val()),
 
-             }
 
-             if ($(this).hasClass('btn-success')) {
 
-                 const sdesc = $('#success-approval').find('textarea').val();
 
-                 if (sdesc === '') {
 
-                     toastr.error('审批意见不能为空!');
 
-                     returnflag = false;
 
-                 }
 
-                 if ($('input[name="p_code"]').val() === '') {
 
-                     toastr.error('变更令号(批复编号)不能为空!');
 
-                     returnflag = false;
 
-                 } else if ($('input[name="p_code"]').val() !== undefined) {
 
-                     $('input[name="p_code"]').val($.trim($('input[name="p_code"]').val()));
 
-                     const postData2 = {
 
-                         p_code: $('input[name="p_code"]').val(),
 
-                     };
 
-                     postDataWithAsync('/tender/' + $('#tenderId').val() + '/change/' + $('#changeId').val() + '/check/codeRepeat',postData2, function (result) {
 
-                     }, function (data) {
 
-                         returnflag = false;
 
-                     });
 
-                     pData.p_code = $('input[name="p_code"]').val();
 
-                 }
 
-                 if(returnflag) {
 
-                     $('input[name="w_code"]').val($.trim($('#w_code').val()));
 
-                     $('#success-approval').find('textarea').val(sdesc.replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' '));
 
-                     if ($('#warning-text').length) $('#warning-text').remove();
 
-                     // $('#success-approval').submit();
 
-                     pData.status = auditConst.status.checked;
 
-                     pData.sdesc = sdesc.replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' ');
 
-                 }
 
-             } else {
 
-                 const sdesc = $('#fail-approval').find('textarea').val();
 
-                 if (sdesc === '') {
 
-                     toastr.error('审批意见不能为空!');
 
-                     returnflag = false;
 
-                 }
 
-                 const type = $('#fail-approval').find('input[name="status"]:checked').val();
 
-                 if (type === undefined) {
 
-                     // toastr.error('请选择退回类型!');
 
-                     if (!$('#warning-text').length) {
 
-                         $('#change-back-content').append('<p id="warning-text" style="color: red; margin: 0;">请选择退回流程</p>');
 
-                     }
 
-                     returnflag = false;
 
-                 }
 
-                 if(returnflag) {
 
-                     $('#fail-approval').find('textarea').val(sdesc.replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' '));
 
-                     $('input[name="w_code"]').val($.trim($('#w_code').val()));
 
-                     // $('#fail-approval').submit();
 
-                     pData.status = type;
 
-                     pData.sdesc = sdesc.replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' ');
 
-                 }
 
-             }
 
-             if (pData.status) {
 
-                 console.log(pData);
 
-                 postData('/tender/' + $('#tenderId').val() + '/change/approval', pData, function (result) {
 
-                     window.location.reload();
 
-                 });
 
-             }
 
-         });
 
-         const postDataWithAsync = function (url, data, successCallback, errorCallBack, showWaiting = true) {
 
-             if (showWaiting) showWaitingView();
 
-             $.ajax({
 
-                 type:"POST",
 
-                 url: url,
 
-                 data: {'data': JSON.stringify(data)},
 
-                 dataType: 'json',
 
-                 cache: false,
 
-                 async: false,
 
-                 timeout: 60000,
 
-                 beforeSend: function(xhr) {
 
-                     let csrfToken = Cookies.get('csrfToken_j');
 
-                     xhr.setRequestHeader('x-csrf-token', csrfToken);
 
-                 },
 
-                 success: function(result){
 
-                     if (result.err === 0) {
 
-                         if (successCallback) {
 
-                             successCallback(result.data);
 
-                         }
 
-                     } else {
 
-                         toastr.error(result.msg);
 
-                         if (errorCallBack) {
 
-                             errorCallBack(result.msg);
 
-                         }
 
-                     }
 
-                     if (showWaiting) closeWaitingView();
 
-                 },
 
-                 error: function(jqXHR, textStatus, errorThrown){
 
-                     toastr.error('error: ' + textStatus + " " + errorThrown);
 
-                     if (errorCallBack) {
 
-                         errorCallBack();
 
-                     }
 
-                     if (showWaiting) closeWaitingView();
 
-                 }
 
-             });
 
-         };
 
-     }
 
- });
 
- function calcChangePrice() {
 
-     let positive_tp = 0;
 
-     let negative_tp = 0;
 
-     let valuation_tp = 0;
 
-     let unvaluation_tp = 0;
 
-     let new_tp = 0;
 
-     // 先汇总再统计金额
 
-     const gclChangeList = _.uniq(_.map(changeList, 'gcl_id'));
 
-     for (const g of gclChangeList) {
 
-         if (g) {
 
-             const list = _.filter(changeList, { gcl_id: g });
 
-             let spamount = 0;
 
-             let valuation_amount = 0;
 
-             let unvaluation_amount = 0;
 
-             let unitPrice = 0;
 
-             for (const c of list) {
 
-                 if (c.spamount) {
 
-                     spamount = ZhCalc.add(spamount, ZhCalc.round(c.spamount, findDecimal(c.unit)));
 
-                     unitPrice = c.unit_price;
 
-                     if (c.is_valuation) {
 
-                         valuation_amount = ZhCalc.add(valuation_amount, ZhCalc.round(c.spamount, findDecimal(c.unit)));
 
-                     } else {
 
-                         unvaluation_amount = ZhCalc.add(unvaluation_amount, ZhCalc.round(c.spamount, findDecimal(c.unit)));
 
-                     }
 
-                 }
 
-             }
 
-             const price = ZhCalc.round(ZhCalc.mul(spamount, ZhCalc.round(unitPrice, unitPriceUnit)), totalPriceUnit);
 
-             const valuation_price = ZhCalc.round(ZhCalc.mul(valuation_amount, ZhCalc.round(unitPrice, unitPriceUnit)), totalPriceUnit) || 0;
 
-             const unvaluation_price = ZhCalc.round(ZhCalc.mul(unvaluation_amount, ZhCalc.round(unitPrice, unitPriceUnit)), totalPriceUnit) || 0;
 
-             valuation_tp = ZhCalc.add(valuation_tp, valuation_price);
 
-             unvaluation_tp = ZhCalc.add(unvaluation_tp, unvaluation_price);
 
-             new_tp = ZhCalc.add(new_tp, price);
 
-             if (price >= 0) {
 
-                 positive_tp = ZhCalc.add(positive_tp, price);
 
-             } else {
 
-                 negative_tp = ZhCalc.add(negative_tp, price);
 
-             }
 
-         } else {
 
-             const list = _.filter(changeList, { gcl_id: g });
 
-             for (const c of list) {
 
-                 if (c.spamount) {
 
-                     const price = ZhCalc.round(ZhCalc.mul(ZhCalc.round(c.spamount, findDecimal(c.unit)), ZhCalc.round(c.unit_price, unitPriceUnit)), totalPriceUnit) || 0;
 
-                     new_tp = ZhCalc.add(new_tp, price);
 
-                     if (price >= 0) {
 
-                         positive_tp = ZhCalc.add(positive_tp, price);
 
-                     } else {
 
-                         negative_tp = ZhCalc.add(negative_tp, price);
 
-                     }
 
-                     if (c.is_valuation) {
 
-                         valuation_tp = ZhCalc.add(valuation_tp, price);
 
-                     } else {
 
-                         unvaluation_tp = ZhCalc.add(unvaluation_tp, price);
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-     }
 
-     const updateTpList = {};
 
-     let updateFlag = false;
 
-     if (changeTp !== new_tp) {
 
-         updateTpList.total_price = new_tp;
 
-         updateFlag = true;
 
-     }
 
-     if (positive_tp !== changePp) {
 
-         updateTpList.positive_tp = positive_tp;
 
-         updateFlag = true;
 
-     }
 
-     if (negative_tp !== changeNp) {
 
-         updateTpList.negative_tp = negative_tp;
 
-         updateFlag = true;
 
-     }
 
-     if (valuation_tp !== changeVp) {
 
-         updateTpList.valuation_tp = valuation_tp;
 
-         updateFlag = true;
 
-     }
 
-     if (unvaluation_tp !== changeUp) {
 
-         updateTpList.unvaluation_tp = unvaluation_tp;
 
-         updateFlag = true;
 
-     }
 
-     if (updateFlag) {
 
-         console.log(updateTpList);
 
-         postData(window.location.pathname + '/save', { type:'update_tp', updateData: updateTpList }, function () {
 
-             changePp = positive_tp;
 
-             changeNp = negative_tp;
 
-             changeVp = valuation_tp;
 
-             changeUp = unvaluation_tp;
 
-             changeTp = new_tp;
 
-         });
 
-     }
 
- }
 
- function checkAndChange(changeListData) {
 
-     // 根据已添加的清单显示
 
-     if (changeList.length > 0 && changeList[0]) {
 
-         const removeList = [];
 
-         const updateList = [];
 
-         const updateGclIdList = [];
 
-         for (const [index,clinfo] of changeList.entries()) {
 
-             if (clinfo.lid != 0) {
 
-                 let listinfo = changeListData.find(function (item) {
 
-                     return (item.id !== undefined && item.id == clinfo.lid) || (item.id === undefined && item.leafXmjs !== undefined && item.leafXmjs.length !== 0 && item.leafXmjs[0].gcl_id == clinfo.lid);
 
-                 });
 
-                 if (listinfo === undefined || (clinfo.lid && clinfo.gcl_id && clinfo.lid !== clinfo.gcl_id)) {
 
-                     // 有可能这部分台账发生变化,此时要更新清单lid信息,防止数据丢失
 
-                     const newlistinfo = changeListData.find(function (item) {
 
-                         return (item.id !== undefined && item.id == clinfo.gcl_id) || (item.id === undefined && item.leafXmjs !== undefined && item.leafXmjs.length !== 0 && _.find(item.leafXmjs, {gcl_id: clinfo.gcl_id }));
 
-                     });
 
-                     if ((listinfo === undefined && newlistinfo) || (listinfo && newlistinfo && !isObjEqual(listinfo, newlistinfo))) {
 
-                         listinfo = newlistinfo;
 
-                         updateList.push({id: clinfo.id, lid: newlistinfo.leafXmjs[0].gcl_id});
 
-                         // 更新lid
 
-                         changeList[index].lid = newlistinfo.leafXmjs[0].gcl_id;
 
-                     }
 
-                 }
 
-                 if (listinfo === undefined) {
 
-                     // 针对旧数据获取清单信息
 
-                     listinfo = changeListData[clinfo.lid - 1];
 
-                     if (listinfo === undefined) {
 
-                         toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
 
-                         if (changeStatus !== auditConst.status.revise) {
 
-                             removeList.push(clinfo);
 
-                         } else {
 
-                             updateList.push(makeWhiteList(clinfo));
 
-                         }
 
-                         continue;
 
-                     }
 
-                 }
 
-                 const info = makePushBwmx(clinfo, listinfo, removeList, updateList);
 
-                 if (info && _.findIndex(changeLedgerList, { id: clinfo.gcl_id }) !== -1) {
 
-                     // 可能因为升降级关系:细目,分部分项等会发生变化,更新清单
 
-                     const updateInfo = {};
 
-                     if (info.code !== clinfo.xmj_code) {
 
-                         updateInfo.xmj_code = info.code;
 
-                         changeList[index].xmj_code = info.code;
 
-                     }
 
-                     if (info.jldy !== clinfo.xmj_jldy) {
 
-                         updateInfo.xmj_jldy = info.jldy;
 
-                         changeList[index].xmj_jldy = info.jldy;
 
-                     }
 
-                     if (info.dwgc !== clinfo.xmj_dwgc) {
 
-                         updateInfo.xmj_dwgc = info.dwgc;
 
-                         changeList[index].xmj_dwgc = info.dwgc;
 
-                     }
 
-                     if (info.fbgc !== clinfo.xmj_fbgc) {
 
-                         updateInfo.xmj_fbgc = info.fbgc;
 
-                         changeList[index].xmj_fbgc = info.fbgc;
 
-                     }
 
-                     if (info.fxgc !== clinfo.xmj_fxgc) {
 
-                         updateInfo.xmj_fxgc = info.fxgc;
 
-                         changeList[index].xmj_fxgc = info.fxgc;
 
-                     }
 
-                     if (!_.isEmpty(updateInfo) && _.indexOf(updateGclIdList, clinfo.gcl_id) === -1) {
 
-                         updateGclIdList.push(clinfo.gcl_id);
 
-                         // updateInfo.gcl_id = info.id;
 
-                         updateList.push({ row: updateInfo, where: { tid: tenderId, gcl_id: clinfo.gcl_id } });
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-         if(updateList.length > 0) {
 
-             console.log(updateList);
 
-             postData(window.location.pathname + '/save', { type:'update_list', updateData: updateList }, function (result) {
 
-             }, function () {
 
-             });
 
-         }
 
-         if(removeList.length > 0) {
 
-             _.pullAll(changeList, removeList);
 
-             postData(window.location.pathname + '/save', { type:'remove_list', updateData: removeList }, function (result) {
 
-             }, function () {
 
-             });
 
-         }
 
-     }
 
- }
 
- function makePushBwmx(clinfo, listinfo, removeList, updateList) {
 
-     let info = '';
 
-     const checkKey = ['name', 'code', 'unit', 'unit_price'];
 
-     const checkLeafKey = ['oamount', 'bwmx', 'code', 'dwgc', 'fbgc', 'fxgc', 'jldy'];
 
-     if (listinfo.leafXmjs !== undefined) {
 
-         const leafInfo = listinfo.leafXmjs.find(function (item) {
 
-             // const flag = (item.bwmx === undefined || item.bwmx === clinfo.bwmx || item.jldy === clinfo.bwmx) && item.gcl_id === clinfo.gcl_id && (!clinfo.mx_id || (item.mx_id && clinfo.mx_id && item.mx_id === clinfo.mx_id)) && (item.quantity !== null ? item.quantity === parseFloat(clinfo.oamount) : 0 === parseFloat(clinfo.oamount));
 
-             const flag = item.gcl_id === clinfo.gcl_id && (!clinfo.mx_id || (item.mx_id && clinfo.mx_id && item.mx_id === clinfo.mx_id));
 
-             if (flag && item.code === clinfo.xmj_code) {
 
-                 return flag && item.code === clinfo.xmj_code;
 
-             }
 
-             return flag;
 
-         });
 
-         if (leafInfo) {
 
-             const oneUpdate = { id: clinfo.id };
 
-             let needUpdate = false;
 
-             // 判断要不要更新名称,单位,原数量,单价
 
-             checkKey.forEach(function (key) {
 
-                 if ((key === 'name' || key === 'unit') && listinfo[key] === null) {
 
-                     listinfo[key] = '';
 
-                 }
 
-                 if (listinfo[key] !== clinfo[key]) {
 
-                     oneUpdate[key] = listinfo[key];
 
-                     clinfo[key] = listinfo[key];
 
-                     if (key === 'unit') {
 
-                         const changeKey = ['oamount', 'oamount2', 'camount'];
 
-                         changeKey.forEach(function (key) {
 
-                             const value = ZhCalc.round(clinfo[key], findDecimal(listinfo[key]));
 
-                             if (value !== clinfo[key]) {
 
-                                 oneUpdate[key] = value;
 
-                                 clinfo[key] = value;
 
-                             }
 
-                         });
 
-                     }
 
-                     // else if (key === 'unit_price') {
 
-                     //     // 可能要更新总金额了
 
-                     //     oneUpdate[key] = ZhCalc.round(listinfo[key], unitPriceUnit);
 
-                     //     clinfo[key] = ZhCalc.round(listinfo[key], unitPriceUnit);
 
-                     // }
 
-                     needUpdate = true;
 
-                 }
 
-             });
 
-             checkLeafKey.forEach(function (key) {
 
-                 // 只有数量是对比leafInfo,其它对比listinfo,且有些值需要重新计算
 
-                 if (key === 'oamount') {
 
-                     if (leafInfo.quantity !== clinfo[key]) {
 
-                         oneUpdate[key] = leafInfo.quantity;
 
-                         clinfo[key] = leafInfo.quantity;
 
-                         needUpdate = true;
 
-                     }
 
-                 } else if (key === 'bwmx') {
 
-                     if (leafInfo[key] !== undefined && leafInfo[key] !== clinfo[key]) {
 
-                         oneUpdate[key] = leafInfo[key];
 
-                         clinfo[key] = leafInfo[key];
 
-                         needUpdate = true;
 
-                     } else if (leafInfo[key] === undefined && leafInfo.jldy !== clinfo[key]) {
 
-                         oneUpdate[key] = leafInfo.jldy;
 
-                         clinfo[key] = leafInfo.jldy;
 
-                         needUpdate = true;
 
-                     }
 
-                 } else {
 
-                     if (leafInfo[key] !== clinfo['xmj_' + key]) {
 
-                         oneUpdate['xmj_' + key] = leafInfo[key];
 
-                         clinfo['xmj_' + key] = leafInfo[key];
 
-                         needUpdate = true;
 
-                     }
 
-                 }
 
-             });
 
-             if (needUpdate) {
 
-                 updateList.push(oneUpdate);
 
-             }
 
-             info = leafInfo;
 
-         } else {
 
-             toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
 
-             if (changeStatus !== auditConst.status.revise) {
 
-                 removeList.push(clinfo);
 
-             } else {
 
-                 updateList.push(makeWhiteList(clinfo));
 
-             }
 
-             return false;
 
-         }
 
-     }
 
-     return info;
 
- }
 
- function makeWhiteList(clinfo) {
 
-     clinfo.lid = 0;
 
-     clinfo.xmj_code = null;
 
-     clinfo.xmj_jldy = null;
 
-     clinfo.xmj_dwgc = null;
 
-     clinfo.xmj_fbgc = null;
 
-     clinfo.xmj_fxgc = null;
 
-     clinfo.gcl_id = '';
 
-     clinfo.mx_id = '';
 
-     return clinfo;
 
- }
 
- function isObjEqual(o1,o2){
 
-     var props1 = Object.getOwnPropertyNames(o1);
 
-     var props2 = Object.getOwnPropertyNames(o2);
 
-     if (props1.length != props2.length) {
 
-         return false;
 
-     }
 
-     for (var i = 0,max = props1.length; i < max; i++) {
 
-         var propName = props1[i];
 
-         if (o1[propName] !== o2[propName]) {
 
-             return false;
 
-         }
 
-     }
 
-     return true;
 
- }
 
- function findDecimal(unit) {
 
-     let value = precision.other.value;
 
-     const changeUnits = precision;
 
-     for (const d in changeUnits) {
 
-         if (changeUnits[d].unit !== undefined && changeUnits[d].unit === unit) {
 
-             value = changeUnits[d].value;
 
-             break;
 
-         }
 
-     }
 
-     return value;
 
- }
 
- // 生成附件列表
 
- function getAllList(currPageNum = 1) {
 
-     // 每页最多几个附件
 
-     const pageCount = 20;
 
-     // 附件总数
 
-     const total = attData.length;
 
-     // 总页数
 
-     const pageNum = Math.ceil(total/pageCount);
 
-     $('#totalPage').text(pageNum);
 
-     $('#currentPage').text(total === 0 ? 0 : currPageNum);
 
-     // 当前页附件内容
 
-     const currPageAttData = attData.slice((currPageNum-1)*pageCount, currPageNum*pageCount);
 
-     currPageFileData = currPageAttData;
 
-     let html = '';
 
-     // '/tender/' + tender.id + '/measure/stage/' + stage.order + '/download/file/' + att.id
 
-     for(const [index,att] of currPageAttData.entries()) {
 
-         html += `<tr>
 
-         <td width="25"><input type="checkbox" class="check-file" file-id=${att.id}></td>
 
-         <td>${((currPageNum-1)*pageCount)+index+1}</td>
 
-         <td><a href="${att.filepath}" target="_blank" class="pl-0 col-11 att-file-name" file-id=${att.id}>${att.filename}${att.fileext}</a></td>
 
-         <td>${moment(att.in_time * 1000).format('YYYY-MM-DD')}<br>${bytesToSize(att.filesize)}</td>
 
-         <td>
 
-             <a href="/change/download/file/${att.id}" class="mr-2" title="下载"><span class="fa fa-download text-primary"></span></a>`
 
-         html += (att.uid === accountId && ((changeStatus === auditConst.status.checked ? Boolean(att.extra_upload) : true) || deleteFilePermission)) ?
 
-             `<a href="javascript:void(0)" class="mr-2 delete-file" data-attid="${att.id}" title="删除附件"><span class="fa fa-trash text-danger"></span></a>` : '';
 
-         html += `</td>`;
 
-     }
 
-     $('#attList').html(html);
 
-     $('#attList').on('click', 'tr', function() {
 
-         $('#attList tr').removeClass('bg-light');
 
-         $(this).addClass('bg-light');
 
-     })
 
- }
 
- function bytesToSize(bytes) {
 
-     if (parseInt(bytes) === 0) return '0 B';
 
-     const k = 1024;
 
-     const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
 
-     const i = Math.floor(Math.log(bytes) / Math.log(k));
 
-     // return (bytes / Math.pow(k, i)) + ' ' + sizes[i];
 
-     return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i];
 
- }
 
- // 判断是否是已结算清单
 
- function checkIsSettle(data) {
 
-     const info = data.mx_id ? _.find(settlePos, { lid: data.gcl_id, pid: data.mx_id }) : _.find(settleBills, { lid: data.gcl_id });
 
-     if (info && info.settle_status && info.settle_status === settleStatus.finish) {
 
-         return true;
 
-     }
 
-     return false;
 
- }
 
 
  |