index.tsx 171 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265
  1. import { ref, reactive, computed, toRefs, nextTick, inject } from "vue";
  2. import { Table } from "@/hooks/interface";
  3. import { ColumnProps } from "@/components/LjVxeTable/interface";
  4. import { ALLOW_EDIT_STATE, sys_arry_formulatype } from "@/config/index";
  5. import { CommonDynamicSelect } from "@/api/modules/common";
  6. import { GetComputeMattress, GetMattressImportDW2, GetMattressPackagMx, GetComputeSpring } from "@/api/modules/quote";
  7. import { useUserStore } from "@/stores/modules/user";
  8. import MtrldefSelect from "@/views/system/selector/mtrldef/select.vue";
  9. import BednetSelect from "@/views/system/selector/bednet/select.vue";
  10. import { handleRowAccordingToProp, text2Formula } from "@/utils";
  11. import { ElButton, ElMessage, ElPopconfirm, ElMessageBox, ElNotification, ElTag } from "element-plus";
  12. import { Minus, Plus, InfoFilled } from "@element-plus/icons-vue";
  13. import { DwnameEnum } from "@/enums/dwnameEnum";
  14. import { isArray } from "@/utils/is";
  15. import {
  16. calculateFormula,
  17. formulaPartsFormula,
  18. floatAdd,
  19. floatMul,
  20. formatFixedNumber,
  21. autoMergeCells,
  22. formatCutNumber,
  23. formatAmount3,
  24. floatDiv
  25. } from "@/utils/index";
  26. import { cloneDeep, defaultsDeep, throttle } from "lodash-es";
  27. import { TYPE, useToast, POSITION } from "vue-toastification";
  28. import ToastFormula from "@/components/ToastWidget/Formula/index.vue";
  29. import ToastHistoryPrice from "@/components/ToastWidget/HistoryPrice/index.vue";
  30. import { useRouter } from "vue-router";
  31. import { useGlobalStore } from "@/stores/modules/global";
  32. import { storeToRefs } from "pinia";
  33. // import { title } from "process";
  34. interface defaultState {
  35. /**
  36. * @description 单据当前状态
  37. */
  38. orderStatus: string;
  39. vxeTableRef: any;
  40. LjDetailRef: any;
  41. MtrldefDialogRef: any;
  42. MtrldefDialogProps: any;
  43. BednetDialogRef: any;
  44. BednetDialogProps: any;
  45. /**
  46. * @description 面料tab页拆分
  47. */
  48. fabricMxTabList: any[];
  49. otherMxTabList: any[];
  50. /**
  51. * @description 面料当前tab页
  52. */
  53. fabricMxTabs: any;
  54. // fabricMxRef: any;
  55. fabricMxTab8Ref: any;
  56. fabricMxTab9Ref: any;
  57. fabricMxTab10Ref: any;
  58. fabricMxTab11Ref: any;
  59. fabricMxTab12Ref: any;
  60. fabricMxTab13Ref: any;
  61. bednetMxRef: any;
  62. cushionsMxRef: any;
  63. accessoriesMxRef: any;
  64. packagMxRef: any;
  65. innerClothLayerMxRef: any;
  66. topCottonMxRef: any;
  67. subSpecsRef: any;
  68. fabricMxTab8: any[];
  69. fabricMxTab9: any[];
  70. fabricMxTab10: any[];
  71. fabricMxTab11: any[];
  72. fabricMxTab12: any[];
  73. fabricMxTab13: any[];
  74. /**
  75. * @description 面料明细数据-裥大侧 新增
  76. */
  77. fabricMx10NewMtrlGroup: any[];
  78. /**
  79. * @description 面料明细数据-裥小侧 新增
  80. */
  81. fabricMx11NewMtrlGroup: any[];
  82. /**
  83. * @description 床垫类型枚举
  84. */
  85. mattresstypeEnum: any;
  86. /**
  87. * @description 原始明细数据
  88. */
  89. oriMxData: any;
  90. initParams: any;
  91. /**
  92. * @description 垫层数据
  93. */
  94. cushionsMxData: any;
  95. fabricMxData: any;
  96. /**
  97. * @description 辅料数据
  98. */
  99. accessoriesMxData: any;
  100. /**
  101. * @description 床网数据
  102. */
  103. bednetMxData: any;
  104. /**
  105. * @description 包装数据
  106. */
  107. packagMxData: any;
  108. /**
  109. * @description 公式弹窗-是否展示详细公式
  110. */
  111. showFormula: boolean;
  112. QuoteListDrawerRef: any;
  113. formulaKindEnum: any;
  114. formulaKindDcEnum: any;
  115. packtypeOptions: any;
  116. woodpallettypeOptions: any;
  117. areaOptions: any;
  118. cabinetTypeOptions: any;
  119. diancengAreaEnum: any;
  120. topCottonAddList: any;
  121. AllFormulaRef: any;
  122. LjDrawerRef: any;
  123. bednetDrawerProps: bednetDrawerPropsdata;
  124. cmpFormulas: any;
  125. cmpFormulaReplace: any;
  126. cmpFormulasOri: any;
  127. cmpFormulasBednet: any;
  128. cmpDiffer: any;
  129. specialProcessesMxRef: any;
  130. additionalCostsMxRef: any;
  131. specialProcessesMxData: any;
  132. additionalCostsMxData: any;
  133. specialProcessesMxInitData: any;
  134. additionalCostsMxInitData: any;
  135. specialProcessesEnum: any;
  136. additionalCostsEnum: any;
  137. isShowOriginFormulaMattress: boolean;
  138. columnsMx_subSpecs_dis: any[];
  139. subSpecsData: any[];
  140. /**
  141. * @description 记录需要的公式
  142. */
  143. mattressFormulaList: any[];
  144. }
  145. interface bednetDrawerPropsdata {
  146. deptid?: number;
  147. bednetid?: number;
  148. state?: string;
  149. }
  150. export const useHooks = (t?: any) => {
  151. const state = reactive<defaultState>({
  152. orderStatus: "",
  153. vxeTableRef: null,
  154. LjDetailRef: null,
  155. // fabricMxRef: null,
  156. fabricMxTab8Ref: null,
  157. fabricMxTab9Ref: null,
  158. fabricMxTab10Ref: null,
  159. fabricMxTab11Ref: null,
  160. fabricMxTab12Ref: null,
  161. fabricMxTab13Ref: null,
  162. MtrldefDialogRef: null,
  163. MtrldefDialogProps: {},
  164. BednetDialogRef: null,
  165. BednetDialogProps: {},
  166. fabricMxTabs: "",
  167. fabricMxTabList: [
  168. {
  169. label: "裥面",
  170. name: "tabpage_8",
  171. visible: () => Number(state.mattresstypeEnum?.if_top_side) == 1,
  172. type: [0, 80, 40, 50, 60, 70, 9000],
  173. ref: "fabricMxTab8Ref"
  174. },
  175. {
  176. label: "裥底",
  177. name: "tabpage_9",
  178. visible: () => Number(state.mattresstypeEnum?.if_button_sdie) == 1,
  179. type: [1, 81, 41, 51, 61, 71, 9001],
  180. ref: "fabricMxTab9Ref"
  181. },
  182. {
  183. label: "裥大恻",
  184. name: "tabpage_10",
  185. visible: () => Number(state.mattresstypeEnum?.if_big_side) == 1,
  186. type: [2, 82, 42, 52, 62, 72, 9002],
  187. ref: "fabricMxTab10Ref"
  188. },
  189. {
  190. label: "裥小恻",
  191. name: "tabpage_11",
  192. visible: () => Number(state.mattresstypeEnum?.if_small_side) == 1,
  193. type: [3, 83, 43, 53, 63, 73, 9003],
  194. ref: "fabricMxTab11Ref"
  195. },
  196. {
  197. label: "裥V恻",
  198. name: "tabpage_12",
  199. visible: () => Number(state.mattresstypeEnum?.if_v_side) == 1,
  200. type: [4, 84, 44, 54, 64, 74, 9004],
  201. ref: "fabricMxTab12Ref"
  202. },
  203. {
  204. label: "拉手刺绣及其他工艺",
  205. name: "tabpage_13",
  206. visible: () => true,
  207. type: [
  208. 0, 80, 40, 50, 60, 70, 1, 81, 41, 51, 61, 71, 2, 82, 42, 52, 62, 72, 3, 83, 43, 53, 63, 73, 4, 84, 44, 54, 64, 74, 9000,
  209. 9001, 9002, 9003, 9004, 9005, 9006
  210. ], // not in
  211. ref: "fabricMxTab13Ref"
  212. },
  213. {
  214. label: "床网",
  215. name: "bednetMx",
  216. ref: "bednetMxRef"
  217. },
  218. {
  219. label: "垫层",
  220. name: "cushionsMx",
  221. ref: "cushionsMxRef"
  222. },
  223. {
  224. label: "辅料",
  225. name: "accessoriesMx",
  226. ref: "accessoriesMxRef"
  227. },
  228. {
  229. label: "包装",
  230. name: "packagMx",
  231. ref: "packagMxRef"
  232. },
  233. {
  234. label: "内布套",
  235. name: "innerClothLayerMx",
  236. ref: "innerClothLayerMxRef"
  237. },
  238. {
  239. label: "顶布裥棉",
  240. name: "topCottonMx",
  241. ref: "topCottonMxRef"
  242. },
  243. {
  244. label: "特殊工艺费用",
  245. name: "specialProcesses",
  246. ref: "specialProcessesMxRef"
  247. },
  248. {
  249. label: "材料额外费用",
  250. name: "additionalCosts",
  251. ref: "additionalCostsMxRef"
  252. }
  253. ],
  254. otherMxTabList: [
  255. {
  256. label: "内布套",
  257. name: "tabpage_14",
  258. type: [101, 102, 103, 104, 105, 106]
  259. },
  260. {
  261. label: "外布套",
  262. name: "tabpage_15",
  263. type: [111, 112, 113, 114, 115, 116]
  264. }
  265. ],
  266. fabricMxTab8: [],
  267. fabricMxTab9: [],
  268. fabricMxTab10: [],
  269. fabricMxTab11: [],
  270. fabricMxTab12: [],
  271. fabricMxTab13: [],
  272. fabricMx10NewMtrlGroup: [
  273. {
  274. label: "普通大侧",
  275. value: 1
  276. },
  277. {
  278. label: "上下拼侧1",
  279. value: 2
  280. },
  281. {
  282. label: "上下拼侧2",
  283. value: 3
  284. },
  285. {
  286. label: "上下拼侧3",
  287. value: 4
  288. },
  289. {
  290. label: "左右拼侧1",
  291. value: 5
  292. },
  293. {
  294. label: "左右拼侧2",
  295. value: 6
  296. },
  297. {
  298. label: "左右拼侧3",
  299. value: 7
  300. },
  301. {
  302. label: "左右拼侧4",
  303. value: 8
  304. }
  305. ],
  306. fabricMx11NewMtrlGroup: [
  307. {
  308. label: "小侧1",
  309. value: 1
  310. },
  311. {
  312. label: "小侧1-上下拼侧1",
  313. value: 2
  314. },
  315. {
  316. label: "小侧1-上下拼侧2",
  317. value: 3
  318. },
  319. {
  320. label: "小侧1-上下拼侧3",
  321. value: 4
  322. }
  323. ],
  324. mattresstypeEnum: {},
  325. oriMxData: {},
  326. initParams: { arg_mattressid: 0 },
  327. fabricMxData: [],
  328. bednetMxData: [],
  329. cushionsMxData: [],
  330. accessoriesMxData: [],
  331. packagMxData: [],
  332. showFormula: false,
  333. QuoteListDrawerRef: null,
  334. formulaKindEnum: null,
  335. formulaKindDcEnum: null,
  336. bednetMxRef: null,
  337. cushionsMxRef: null,
  338. accessoriesMxRef: null,
  339. packagMxRef: null,
  340. innerClothLayerMxRef: null,
  341. topCottonMxRef: null,
  342. subSpecsRef: null,
  343. packtypeOptions: [
  344. {
  345. label: "压包",
  346. value: 0
  347. },
  348. {
  349. label: "卷包",
  350. value: 1
  351. },
  352. {
  353. label: "国内",
  354. value: 2
  355. }
  356. ],
  357. woodpallettypeOptions: [
  358. {
  359. label: "普通木托",
  360. value: 0
  361. },
  362. {
  363. label: "夹板木托",
  364. value: 1
  365. },
  366. {
  367. label: "铁管木托",
  368. value: 2
  369. }
  370. ],
  371. areaOptions: [
  372. {
  373. label: "普通地区",
  374. value: "普通地区"
  375. },
  376. {
  377. label: "特定地区",
  378. value: "特定地区"
  379. }
  380. ],
  381. cabinetTypeOptions: [
  382. {
  383. label: "大柜",
  384. value: "大柜"
  385. },
  386. {
  387. label: "小柜",
  388. value: "小柜"
  389. }
  390. ],
  391. diancengAreaEnum: [],
  392. topCottonAddList: [],
  393. AllFormulaRef: null,
  394. LjDrawerRef: null,
  395. bednetDrawerProps: {},
  396. cmpFormulas: [],
  397. cmpFormulaReplace: [],
  398. cmpFormulasOri: [],
  399. cmpFormulasBednet: [],
  400. cmpDiffer: [],
  401. specialProcessesMxRef: null,
  402. additionalCostsMxRef: null,
  403. specialProcessesMxData: [],
  404. additionalCostsMxData: [],
  405. specialProcessesMxInitData: [],
  406. additionalCostsMxInitData: [],
  407. specialProcessesEnum: [],
  408. additionalCostsEnum: [],
  409. isShowOriginFormulaMattress: false,
  410. columnsMx_subSpecs_dis: [],
  411. subSpecsData: [],
  412. mattressFormulaList: []
  413. });
  414. const router = useRouter();
  415. /**
  416. * @description 面料分类取值
  417. */
  418. const mtrltypeTabList = [
  419. {
  420. label: "选布料",
  421. formulakinds: [0, 1, 2, 3, 4, 101, 111],
  422. value: 3
  423. },
  424. {
  425. label: "喷胶绵",
  426. formulakinds: [40, 41, 42, 43, 44, 102, 112],
  427. value: 5
  428. },
  429. {
  430. label: "裥绵海绵",
  431. formulakinds: [50, 51, 52, 53, 54, 103, 113],
  432. value: 4
  433. },
  434. {
  435. label: "无纺布",
  436. formulakinds: [60, 61, 62, 63, 64, 104, 114],
  437. value: 30
  438. },
  439. {
  440. label: "裥花图案",
  441. formulakinds: [70, 71, 72, 73, 74, 105, 115],
  442. value: 26
  443. },
  444. {
  445. label: "布料-加工工艺",
  446. formulakinds: [80, 81, 82, 83, 84, 106, 116],
  447. value: 15
  448. },
  449. {
  450. label: "拉手",
  451. formulakinds: [5],
  452. value: 10
  453. },
  454. {
  455. label: "刺绣",
  456. formulakinds: [6],
  457. value: 11
  458. },
  459. {
  460. label: "大侧*压布",
  461. formulakinds: [7],
  462. value: 3
  463. },
  464. {
  465. label: "大侧*边带",
  466. formulakinds: [8, 9],
  467. value: 9
  468. },
  469. {
  470. label: "大侧*上下压线",
  471. formulakinds: [10],
  472. value: 12
  473. },
  474. {
  475. label: "垫层",
  476. formulakinds: [11, 32, 33],
  477. value: 6
  478. },
  479. {
  480. label: "顶布",
  481. formulakinds: [12],
  482. value: 3
  483. },
  484. {
  485. label: "毡类",
  486. formulakinds: [13],
  487. value: 7
  488. },
  489. {
  490. label: "打底无纺布",
  491. formulakinds: [14],
  492. value: 2
  493. },
  494. {
  495. label: "辅料",
  496. formulakinds: [15],
  497. value: 8
  498. },
  499. {
  500. label: "PE",
  501. formulakinds: [16],
  502. value: 16
  503. },
  504. {
  505. label: "外层PE",
  506. formulakinds: [17],
  507. value: 17
  508. },
  509. {
  510. label: "PVC",
  511. formulakinds: [18],
  512. value: 18
  513. },
  514. {
  515. label: "卷包包装",
  516. formulakinds: [19],
  517. value: 19
  518. },
  519. {
  520. label: "牛皮纸袋",
  521. formulakinds: [20],
  522. value: 20
  523. },
  524. {
  525. label: "蓝色PE护角",
  526. formulakinds: [21],
  527. value: 21
  528. },
  529. {
  530. label: "无纺布袋",
  531. formulakinds: [22],
  532. value: 22
  533. },
  534. {
  535. label: "牛皮袋护角",
  536. formulakinds: [23],
  537. value: 23
  538. },
  539. {
  540. label: "编织袋",
  541. formulakinds: [24],
  542. value: 24
  543. },
  544. {
  545. label: "外袋",
  546. formulakinds: [25],
  547. value: 13
  548. },
  549. {
  550. label: "内袋",
  551. formulakinds: [26],
  552. value: 14
  553. },
  554. {
  555. label: "无拉手脚轮",
  556. formulakinds: [27],
  557. value: -1
  558. },
  559. {
  560. label: "拉钮",
  561. formulakinds: [28],
  562. value: -1
  563. },
  564. {
  565. label: "网面布料",
  566. formulakinds: [29],
  567. value: -1
  568. },
  569. {
  570. label: "防火线",
  571. formulakinds: [30],
  572. value: 32
  573. },
  574. {
  575. label: "木托",
  576. formulakinds: [31],
  577. value: -1
  578. },
  579. {
  580. label: "床网",
  581. formulakinds: [99],
  582. value: -1
  583. },
  584. {
  585. label: "拉链",
  586. formulakinds: [202],
  587. value: 31
  588. },
  589. {
  590. label: "席垫",
  591. formulakinds: [203],
  592. value: 32
  593. },
  594. {
  595. label: "车花边",
  596. formulakinds: [205],
  597. value: 32
  598. },
  599. {
  600. label: "骨条",
  601. formulakinds: [206],
  602. value: 33
  603. }
  604. ];
  605. /**
  606. * @description 包装
  607. */
  608. const mtrltypeTabList_packag = [
  609. {
  610. label: "选布料",
  611. formulakinds: [0, 1, 2, 3, 4],
  612. value: 3
  613. },
  614. {
  615. label: "喷胶绵",
  616. formulakinds: [40, 41, 42, 43, 44],
  617. value: 5
  618. },
  619. {
  620. label: "裥绵海绵",
  621. formulakinds: [50, 51, 52, 53, 54],
  622. value: 4
  623. },
  624. {
  625. label: "无纺布",
  626. formulakinds: [60, 61, 62, 63, 64],
  627. value: 2
  628. },
  629. {
  630. label: "裥花图案",
  631. formulakinds: [70, 71, 72, 73, 74],
  632. value: 4
  633. },
  634. {
  635. label: "布料-加工工艺",
  636. formulakinds: [80, 81, 82, 83, 84],
  637. value: 15
  638. },
  639. {
  640. label: "拉手",
  641. formulakinds: [5],
  642. value: 10
  643. },
  644. {
  645. label: "刺绣",
  646. formulakinds: [6],
  647. value: 11
  648. },
  649. {
  650. label: "大侧*压布",
  651. formulakinds: [7],
  652. value: 2
  653. },
  654. {
  655. label: "大侧*边带",
  656. formulakinds: [8, 9],
  657. value: 9
  658. },
  659. {
  660. label: "大侧*上下压线",
  661. formulakinds: [10],
  662. value: 12
  663. },
  664. {
  665. label: "垫层",
  666. formulakinds: [11, 32, 33],
  667. value: 6
  668. },
  669. {
  670. label: "顶布",
  671. formulakinds: [12],
  672. value: 3
  673. },
  674. {
  675. label: "毡类",
  676. formulakinds: [13],
  677. value: 7
  678. },
  679. {
  680. label: "打底无纺布",
  681. formulakinds: [14],
  682. value: 2
  683. },
  684. {
  685. label: "辅料",
  686. formulakinds: [15],
  687. value: 8
  688. },
  689. {
  690. label: "PE",
  691. formulakinds: [16],
  692. value: 16
  693. },
  694. {
  695. label: "外层PE",
  696. formulakinds: [17],
  697. value: 17
  698. },
  699. {
  700. label: "PVC",
  701. formulakinds: [18],
  702. value: 18
  703. },
  704. {
  705. label: "卷包包装",
  706. formulakinds: [19],
  707. value: 19
  708. },
  709. {
  710. label: "牛皮纸袋",
  711. formulakinds: [20],
  712. value: 20
  713. },
  714. {
  715. label: "蓝色PE护角",
  716. formulakinds: [21],
  717. value: 21
  718. },
  719. {
  720. label: "无纺布袋",
  721. formulakinds: [22],
  722. value: 22
  723. },
  724. {
  725. label: "牛皮袋护角",
  726. formulakinds: [23],
  727. value: 23
  728. },
  729. {
  730. label: "编织袋",
  731. formulakinds: [24],
  732. value: 24
  733. },
  734. {
  735. label: "外袋",
  736. formulakinds: [25],
  737. value: 13
  738. },
  739. {
  740. label: "内袋",
  741. formulakinds: [26],
  742. value: 14
  743. },
  744. {
  745. label: "无拉手脚轮",
  746. formulakinds: [27],
  747. value: 19
  748. },
  749. {
  750. label: "拉钮",
  751. formulakinds: [28],
  752. value: -1
  753. },
  754. {
  755. label: "网面布料",
  756. formulakinds: [29],
  757. value: -1
  758. },
  759. {
  760. label: "防火线",
  761. formulakinds: [30],
  762. value: -1
  763. },
  764. {
  765. label: "木托",
  766. formulakinds: [31],
  767. value: 28
  768. },
  769. {
  770. label: "无纺布护角",
  771. formulakinds: [201],
  772. value: 27
  773. },
  774. {
  775. label: "床网",
  776. formulakinds: [99],
  777. value: -1
  778. }
  779. ];
  780. /**
  781. * @description 垫层
  782. */
  783. const mtrltypeTabList_cushions = [
  784. {
  785. label: "垫层",
  786. formulakinds: [11, 32, 33],
  787. value: 6
  788. },
  789. {
  790. label: "顶布",
  791. formulakinds: [12],
  792. value: 29
  793. },
  794. {
  795. label: "毡类",
  796. formulakinds: [13, 35],
  797. value: 7
  798. },
  799. {
  800. label: "打底无纺布",
  801. formulakinds: [14],
  802. value: 2
  803. },
  804. {
  805. label: "网面布料",
  806. formulakinds: [29],
  807. value: 3
  808. },
  809. {
  810. label: "顶布裥棉",
  811. formulakinds: [1201],
  812. value: 1201
  813. }
  814. ];
  815. /**
  816. * @description 辅料
  817. */
  818. const mtrltypeTabList_accessories = [
  819. {
  820. label: "辅料",
  821. formulakinds: [15],
  822. value: 8
  823. }
  824. ];
  825. /**
  826. * @description 内布套
  827. */
  828. const mtrltypeTabList_inner = [
  829. {
  830. label: "选布料",
  831. formulakinds: [0, 1, 2, 3, 4, 101, 111],
  832. value: 3
  833. },
  834. {
  835. label: "喷胶绵",
  836. formulakinds: [40, 41, 42, 43, 44, 102, 112],
  837. value: 5
  838. },
  839. {
  840. label: "裥绵海绵",
  841. formulakinds: [50, 51, 52, 53, 54, 103, 113],
  842. value: 4
  843. },
  844. {
  845. label: "无纺布",
  846. formulakinds: [60, 61, 62, 63, 64, 104, 114],
  847. value: 200
  848. },
  849. {
  850. label: "裥花图案",
  851. formulakinds: [70, 71, 72, 73, 74, 105, 115],
  852. value: 26
  853. },
  854. {
  855. label: "布料-加工工艺",
  856. formulakinds: [80, 81, 82, 83, 84, 106, 116],
  857. value: 15
  858. },
  859. {
  860. label: "拉手",
  861. formulakinds: [5],
  862. value: 10
  863. },
  864. {
  865. label: "刺绣",
  866. formulakinds: [6],
  867. value: 11
  868. },
  869. {
  870. label: "大侧*压布",
  871. formulakinds: [7],
  872. value: 2
  873. },
  874. {
  875. label: "大侧*边带",
  876. formulakinds: [8, 9],
  877. value: 9
  878. },
  879. {
  880. label: "大侧*上下压线",
  881. formulakinds: [10],
  882. value: 12
  883. },
  884. {
  885. label: "垫层",
  886. formulakinds: [11, 32, 33],
  887. value: 6
  888. },
  889. {
  890. label: "顶布",
  891. formulakinds: [12],
  892. value: 3
  893. },
  894. {
  895. label: "毡类",
  896. formulakinds: [13],
  897. value: 7
  898. },
  899. {
  900. label: "打底无纺布",
  901. formulakinds: [14],
  902. value: 2
  903. },
  904. {
  905. label: "辅料",
  906. formulakinds: [15],
  907. value: 8
  908. },
  909. {
  910. label: "PE",
  911. formulakinds: [16],
  912. value: 16
  913. },
  914. {
  915. label: "外层PE",
  916. formulakinds: [17],
  917. value: 17
  918. },
  919. {
  920. label: "PVC",
  921. formulakinds: [18],
  922. value: 18
  923. },
  924. {
  925. label: "卷包包装",
  926. formulakinds: [19],
  927. value: 19
  928. },
  929. {
  930. label: "牛皮纸袋",
  931. formulakinds: [20],
  932. value: 20
  933. },
  934. {
  935. label: "蓝色PE护角",
  936. formulakinds: [21],
  937. value: 21
  938. },
  939. {
  940. label: "无纺布袋",
  941. formulakinds: [22],
  942. value: 22
  943. },
  944. {
  945. label: "牛皮袋护角",
  946. formulakinds: [23],
  947. value: 23
  948. },
  949. {
  950. label: "编织袋",
  951. formulakinds: [24],
  952. value: 24
  953. },
  954. {
  955. label: "外袋",
  956. formulakinds: [25],
  957. value: 13
  958. },
  959. {
  960. label: "内袋",
  961. formulakinds: [26],
  962. value: 14
  963. },
  964. {
  965. label: "无拉手脚轮",
  966. formulakinds: [27],
  967. value: -1
  968. },
  969. {
  970. label: "拉钮",
  971. formulakinds: [28],
  972. value: -1
  973. },
  974. {
  975. label: "网面布料",
  976. formulakinds: [29],
  977. value: -1
  978. },
  979. {
  980. label: "防火线",
  981. formulakinds: [30],
  982. value: -1
  983. },
  984. {
  985. label: "木托",
  986. formulakinds: [31],
  987. value: -1
  988. },
  989. {
  990. label: "床网",
  991. formulakinds: [99],
  992. value: -1
  993. },
  994. {
  995. label: "拉链",
  996. formulakinds: [202],
  997. value: 31
  998. },
  999. {
  1000. label: "边带",
  1001. formulakinds: [203],
  1002. value: 9
  1003. }
  1004. ];
  1005. const { userInfo } = useUserStore();
  1006. state.orderStatus = inject("orderStatus", "");
  1007. const getData_mx = (params: any) => {
  1008. console.log("getData params :>> ", params);
  1009. let newParams: any = {};
  1010. params.pageNum && (newParams.pageindex = params.pageNum);
  1011. params.pageSize && (newParams.pagesize = params.pageSize);
  1012. delete params.pageNum;
  1013. delete params.pageSize;
  1014. newParams.queryParams = params;
  1015. console.log("params :>> ", params);
  1016. newParams.dsname = "web_mattress_mx";
  1017. return CommonDynamicSelect(newParams, DwnameEnum.mattressQuoteMx);
  1018. // return [];
  1019. };
  1020. const dataCallback = (data: any) => {
  1021. console.log("dataCallback data :>> ", data);
  1022. if (data.datatable.length > 0) {
  1023. data.datatable = data.datatable.map((item: any) => {
  1024. item.dannum_rate = Number(item.dannum_rate);
  1025. // item.if_w_butao = Boolean(Number(item.if_w_butao));
  1026. return item;
  1027. });
  1028. }
  1029. return {
  1030. list: data.datatable,
  1031. tableinfo: data.tableinfo,
  1032. total: data.totalcnt,
  1033. pageNum: data.pageindex,
  1034. pageSize: data.pagesize
  1035. };
  1036. };
  1037. const dataCallbackMx = (data: any) => {
  1038. console.log("dataCallback data :>> ", data);
  1039. return {
  1040. list: data.datatable,
  1041. tableinfo: data.tableinfo,
  1042. total: data.totalcnt,
  1043. pageNum: data.pageindex,
  1044. pageSize: data.pagesize
  1045. };
  1046. };
  1047. const funcTaxrateChange = async (val: any, data) => {
  1048. data.taxrate = val;
  1049. };
  1050. /**
  1051. * @description 弹窗模块:床网选择
  1052. * @param data 当前数据
  1053. * @param status 当前订单状态
  1054. * @returns Promise
  1055. */
  1056. const fModelChoseBednet = (data: any, params: any, $table?: any) => {
  1057. return new Promise((resolve, reject) => {
  1058. // if (!ALLOW_EDIT_STATE.includes(status)) return;
  1059. let _params = {
  1060. ...params,
  1061. keyword: ""
  1062. };
  1063. state.BednetDialogProps = {
  1064. onSubmit: (res: any) => {
  1065. // submit
  1066. console.log("openCustDialog res", res);
  1067. nextTick(() => {
  1068. rModelSetBednet(data, res.value[0], $table);
  1069. resolve(1);
  1070. });
  1071. },
  1072. onCancel: (error: any) => {
  1073. // cancel 回调
  1074. console.log("openCustDialog error", error);
  1075. }
  1076. };
  1077. state.BednetDialogRef.show(_params);
  1078. });
  1079. };
  1080. /**
  1081. * @description 在床网tab,更新垫层的床网厚度信息
  1082. * @param data 床网明细信息
  1083. * @param item 床网信息
  1084. * @param action 动作,add,set,del,clear
  1085. */
  1086. const wf_rtr_cwdc = async (data: any, item: any, action: string) => {
  1087. const $table = state.cushionsMxRef.element;
  1088. let { visibleData } = $table.getTableData();
  1089. console.log("wf_rtr_cwdc data :>> ", data, visibleData, item, action);
  1090. // fullData.map(item => {
  1091. // if (Number(item.formulakind) == 999 && Number(item.thickness) == 0) {
  1092. // $table.setRow(item, {
  1093. // thickness: data.bednet_height,
  1094. // qty: 1
  1095. // });
  1096. // }
  1097. // });
  1098. const $tableBednet = state.bednetMxRef.element;
  1099. let currentBednetIndex = $tableBednet.getRowSeq(data);
  1100. if (action == "add") {
  1101. let cushionItem = visibleData.find(o => o.formulakind == 999);
  1102. let records = cloneDeep(cushionItem ?? {});
  1103. if (!records?.chastr) {
  1104. records.chastr = state.diancengAreaEnum[0].value;
  1105. records.formulakind = 999;
  1106. }
  1107. records.thickness = 0;
  1108. records.qty = 0;
  1109. records._X_ROW_KEY = "";
  1110. records.mattressmxid = 0;
  1111. if (item) {
  1112. records.thickness = item?.bednet_height;
  1113. records.qty = 1;
  1114. }
  1115. let bednetList = visibleData.filter(o => Number(o.formulakind) == 999);
  1116. let lastIndex = bednetList.length > 0 ? $table.getRowSeq(bednetList[bednetList.length - 1]) : -1;
  1117. console.log("wf_rtr_cwdc lastIndex :>> ", bednetList, lastIndex, records);
  1118. let _index = visibleData.length > lastIndex ? lastIndex : -1;
  1119. console.log("wf_rtr_cwdc $table :>> ", $table, visibleData.length, _index);
  1120. $table.insertNextAt(records, _index);
  1121. } else {
  1122. console.log("wf_rtr_cwdc currentBednetIndex :>> ", action, currentBednetIndex);
  1123. if (action == "set") {
  1124. let idx = 1;
  1125. let _match = false;
  1126. visibleData.map(o => {
  1127. if (Number(o.formulakind) == 999) {
  1128. if (idx == currentBednetIndex) {
  1129. _match = true;
  1130. }
  1131. idx++;
  1132. }
  1133. });
  1134. if (!_match) {
  1135. await wf_rtr_cwdc(data, null, "add");
  1136. }
  1137. }
  1138. let { visibleData: afterVisibleData } = $table.getTableData();
  1139. let index = 1;
  1140. console.log("after add set", afterVisibleData, item);
  1141. afterVisibleData.map(o => {
  1142. if (Number(o.formulakind) == 999) {
  1143. if (index == currentBednetIndex) {
  1144. if (action == "set") {
  1145. console.log("after add o :>> ", currentBednetIndex, o);
  1146. $table.setRow(o, {
  1147. thickness: item?.bednet_height,
  1148. qty: 1
  1149. });
  1150. } else if (action == "clear") {
  1151. $table.setRow(o, {
  1152. thickness: 0,
  1153. qty: 0
  1154. });
  1155. } else if (action == "del") {
  1156. $table.remove(o);
  1157. }
  1158. }
  1159. index++;
  1160. }
  1161. });
  1162. }
  1163. };
  1164. /**
  1165. * @description 更新床网tab的垫层床网信息
  1166. * @param data 垫层明细信息
  1167. */
  1168. const wf_rtr_bednet = (data: any) => {
  1169. console.log("wf_rtr_bednet data :>> ", data);
  1170. const $table = state.cushionsMxRef.element;
  1171. let { visibleData } = $table.getTableData();
  1172. let currentcushionsIndex = $table.getRowSeq(data);
  1173. console.log("currentcushionsIndex :>> ", currentcushionsIndex);
  1174. const $tableBednet = state.bednetMxRef.element;
  1175. let { visibleData: visibleData_bednet } = $tableBednet.getTableData();
  1176. let currentBednetIndex = 0;
  1177. let index = 0;
  1178. visibleData.map((o, idx) => {
  1179. if (Number(o.formulakind) == 999) {
  1180. if (idx + 1 == currentcushionsIndex) {
  1181. currentBednetIndex = index;
  1182. }
  1183. index++;
  1184. }
  1185. });
  1186. console.log("wf_rtr_bednet currentBednetIndex :>> ", currentBednetIndex);
  1187. if (visibleData_bednet.length == 1) {
  1188. visibleData_bednet[0].mtrlid = 0;
  1189. visibleData_bednet[0].mtrlname = "";
  1190. visibleData_bednet[0].price = 0;
  1191. $tableBednet.reloadData(visibleData_bednet);
  1192. } else {
  1193. funcDelMtrlMx({ row: visibleData_bednet[currentBednetIndex], data: visibleData_bednet }, "bednetMxRef");
  1194. }
  1195. // 床网与主副规格互联
  1196. nextTick(() => {
  1197. updateSubspecsTable();
  1198. });
  1199. };
  1200. /**
  1201. * @description 垫层tab,公式名选择,联动增删床网tab
  1202. * @param val
  1203. * @param lastVal
  1204. * @param scope
  1205. */
  1206. const cushionsFormulaKindChange = (val: any, lastVal: any, scope: any) => {
  1207. console.log("wf_rtr_cwdc cushionsFormulaKindChange val :>> ", val, lastVal, scope);
  1208. const $table = state.cushionsMxRef.element;
  1209. const $table_bednet = state.bednetMxRef.element;
  1210. const { visibleData } = $table.getTableData();
  1211. if (Number(val) === 999 && Number(lastVal) !== 999) {
  1212. // 新增
  1213. if ($table_bednet) {
  1214. const { visibleData: visibleData_bednet } = $table_bednet.getTableData();
  1215. let curIndex = visibleData_bednet.length - 1;
  1216. // 寻找垫层当前位置,对上一个床网行位置进行复制
  1217. let arr = visibleData.filter((t, i) => t.formulakind == 999 && i < scope.$rowIndex);
  1218. if (arr.length > 0) {
  1219. curIndex = arr.length - 1;
  1220. }
  1221. console.log("wf_rtr_cwdc curIndex :>> ", curIndex);
  1222. rModelClearMtrl(scope.row);
  1223. funcAddMtrlMx({ row: visibleData_bednet[curIndex] }, null, "bednetMxRef", arr.length == 0);
  1224. // 床网与主副规格互联
  1225. nextTick(() => {
  1226. updateSubspecsTable();
  1227. });
  1228. }
  1229. } else if (Number(val) !== 999 && Number(lastVal) === 999) {
  1230. // 删除
  1231. if ($table_bednet) {
  1232. const { visibleData: visibleData_bednet } = $table_bednet.getTableData();
  1233. let curIndex = visibleData_bednet.length - 1;
  1234. curIndex = visibleData
  1235. .filter(t => t.formulakind == 999 || t._X_ROW_KEY === scope.row._X_ROW_KEY)
  1236. .findIndex(t => t._X_ROW_KEY === scope.row._X_ROW_KEY);
  1237. console.log("wf_rtr_cwdc curIndex :>> ", curIndex);
  1238. if (visibleData_bednet.length == 1) {
  1239. ElMessage.warning("不能全部删除,至少保留一个床网");
  1240. scope.row.formulakind = 999;
  1241. return false;
  1242. }
  1243. rModelClearMtrl(scope.row);
  1244. funcDelBednet({ row: visibleData_bednet[curIndex], data: visibleData_bednet }, null, "bednetMxRef");
  1245. // 床网与主副规格互联
  1246. nextTick(() => {
  1247. updateSubspecsTable();
  1248. });
  1249. }
  1250. } else {
  1251. rModelClearMtrl(scope.row);
  1252. }
  1253. };
  1254. const rModelSetBednet = (data: any, item: any, $table?: any) => {
  1255. console.log("rModelSetBednet data :>> ", data, item);
  1256. if (item) {
  1257. let _mtrlname =
  1258. item.typename +
  1259. " " +
  1260. item.bednetcode +
  1261. " " +
  1262. item.mattress_width +
  1263. "*" +
  1264. item.mattress_length +
  1265. "*" +
  1266. item.mattress_height;
  1267. data.mtrlid = item.bednetid;
  1268. data.mtrlname = _mtrlname;
  1269. // data.price = item.nottax_factory_cost;
  1270. data.price = item.total_cost;
  1271. data.qty = 1;
  1272. wf_rtr_cwdc(data, item, "set");
  1273. if ($table) {
  1274. $table.clearEdit();
  1275. nextTick(() => {
  1276. $table.setActiveRow(data);
  1277. // 床网与主副规格互联
  1278. updateSubspecsTable();
  1279. });
  1280. }
  1281. }
  1282. };
  1283. const rModelClearBednet = (data: any, $table?: any) => {
  1284. console.log("rModelSetBednet data :>> ", data);
  1285. data.mtrlid = 0;
  1286. data.mtrlname = "";
  1287. data.price = 0;
  1288. wf_rtr_cwdc(data, null, "clear");
  1289. if ($table) {
  1290. $table.clearEdit();
  1291. nextTick(() => {
  1292. // 床网与主副规格互联
  1293. updateSubspecsTable();
  1294. });
  1295. }
  1296. };
  1297. /**
  1298. * @description 弹窗模块:物料选择
  1299. * @param data 当前数据
  1300. * @param status 当前订单状态
  1301. * @returns Promise
  1302. */
  1303. const fModelChoseMtrl = (data: any, params: any, cb: any, label?: string, $table?: any) => {
  1304. return new Promise((resolve, reject) => {
  1305. // if (!ALLOW_EDIT_STATE.includes(status)) return;
  1306. let _params = {
  1307. keyword: "",
  1308. arg_mtrltype: params.mtrltype,
  1309. arg_pricelistid: params.pricelistid
  1310. };
  1311. state.MtrldefDialogProps = {
  1312. onSubmit: (res: any) => {
  1313. // submit
  1314. console.log("openCustDialog res", res);
  1315. nextTick(() => {
  1316. cb(data, res.value[0], $table);
  1317. resolve(1);
  1318. });
  1319. },
  1320. onCancel: (error: any) => {
  1321. // cancel 回调
  1322. console.log("openCustDialog error", error);
  1323. }
  1324. };
  1325. state.MtrldefDialogRef.show(_params, label);
  1326. });
  1327. };
  1328. /**
  1329. * @description 数据赋值:物料信息
  1330. * @param data 当前数据
  1331. * @param item 当前选择的数据
  1332. */
  1333. const rModelSetMtrl = (data: any, item: any, $table?: any) => {
  1334. console.log("rModelSetMtrl data :>> ", data);
  1335. console.log("rModelSetMtrl item :>> ", item);
  1336. if (item) {
  1337. data.mattressid = state.LjDetailRef._mainData.mattressid;
  1338. data.mattressmxid = 0;
  1339. data.mtrlid = item.mtrlid;
  1340. data.price = item.pricelistprice;
  1341. data.gram_weight = item.gram_weight;
  1342. data.cloth_width = item.cloth_width;
  1343. data.if_inputqty = Number(item.if_inputqty);
  1344. data.if_areaprice = item.if_areaprice;
  1345. data.if_subspecs = item.if_subspecs;
  1346. data.mtrlname = item.mtrlname;
  1347. data.priceunit = item.priceunit;
  1348. data.shrinkage = item.price; // 收缩率
  1349. data.extra_cost = item.extra_cost;
  1350. if (item.if_inputqty == 1 || Number(data.thickness) == 0) {
  1351. data.thickness = Number(item.thickness);
  1352. }
  1353. data.price_formula = item.price_formula;
  1354. let _qty = 1;
  1355. if (data.formulakind == 5) {
  1356. //默认4个拉手
  1357. _qty = 4;
  1358. } else if ([7, 8, 9, 202].includes(data.formulakind)) {
  1359. // 拉手刺绣及其他工艺,大侧压压布、拉链等自动带出数量=周长
  1360. let mattress_width = state.LjDetailRef._mainData.mattress_width ?? 0;
  1361. let mattress_length = state.LjDetailRef._mainData.mattress_length ?? 0;
  1362. _qty = (mattress_width / 100 + mattress_length / 100) * 2;
  1363. } else if ([206].includes(data.formulakind)) {
  1364. _qty = 2;
  1365. }
  1366. data.qty = _qty;
  1367. // cb && cb();
  1368. if ($table) {
  1369. $table.clearEdit();
  1370. nextTick(() => {
  1371. $table.setActiveRow(data);
  1372. // 垫层tab、辅料tab,修改物料后,触发刷新主规格
  1373. if (data.formulatype == 1 || data.formulatype == 2) {
  1374. updateSubspecsTable();
  1375. }
  1376. autoLoadMtrlExtra(item);
  1377. });
  1378. }
  1379. }
  1380. };
  1381. const rModelClearMtrl = (data: any, $table?: any) => {
  1382. const _item = {
  1383. mtrlid: data.mtrlid,
  1384. mtrlname: data.mtrlname,
  1385. extra_cost: data.extra_cost
  1386. };
  1387. console.log("rModelClearMtrl data :>> ", data);
  1388. data.mattressid = state.LjDetailRef._mainData.mattressid;
  1389. data.mattressmxid = 0;
  1390. data.mtrlid = 0;
  1391. data.price = 0;
  1392. data.gram_weight = 0;
  1393. data.cloth_width = 0;
  1394. data.if_inputqty = 0;
  1395. data.if_areaprice = 0;
  1396. data.if_subspecs = 0;
  1397. data.mtrlname = "";
  1398. data.priceunit = "";
  1399. data.shrinkage = 0;
  1400. data.thickness = 0;
  1401. data.price_formula = "";
  1402. data.qty = "";
  1403. if ($table) {
  1404. $table.clearEdit();
  1405. nextTick(() => {
  1406. // 垫层tab、辅料tab,修改物料后,触发刷新主规格
  1407. if (data.formulatype == 1 || data.formulatype == 2) {
  1408. updateSubspecsTable();
  1409. }
  1410. autoLoadMtrlExtra(_item, 5, "del");
  1411. });
  1412. }
  1413. };
  1414. /**
  1415. * @description 数据赋值:物料信息
  1416. * @param data 当前数据
  1417. * @param item 当前选择的数据
  1418. */
  1419. const rModelSetMtrlInner = (data: any, item: any, $table?: any) => {
  1420. console.log("rModelSetMtrl data :>> ", data);
  1421. console.log("rModelSetMtrl item :>> ", item);
  1422. if (item) {
  1423. data.mattressid = state.LjDetailRef._mainData.mattressid;
  1424. data.mattressmxid = 0;
  1425. data.mtrlid = item.mtrlid;
  1426. data.price = item.pricelistprice;
  1427. data.gram_weight = item.gram_weight;
  1428. data.cloth_width = item.cloth_width;
  1429. data.if_inputqty = Number(item.if_inputqty);
  1430. data.if_areaprice = item.if_areaprice;
  1431. data.mtrlname = item.mtrlname;
  1432. data.priceunit = item.priceunit;
  1433. data.shrinkage = item.price; // 收缩率
  1434. if (item.if_inputqty == 1 || Number(data.thickness) == 0) {
  1435. data.thickness = Number(item.thickness);
  1436. }
  1437. item?.price_formula != "" && (data.price_formula = item.price_formula);
  1438. let _qty = 1;
  1439. if (data.formulakind == 5) {
  1440. //默认4个拉手
  1441. _qty = 4;
  1442. } else if ([7, 8, 9, 30, 202, 203].includes(data.formulakind)) {
  1443. // 拉手刺绣及其他工艺,大侧压压布7、大侧压边带8、大侧压织带9、防火线30、拉链202、内布套围边边带203,自动带出数量=周长
  1444. let mattress_width = state.LjDetailRef._mainData.mattress_width ?? 0;
  1445. let mattress_length = state.LjDetailRef._mainData.mattress_length ?? 0;
  1446. _qty = (mattress_width / 100 + mattress_length / 100) * 2;
  1447. }
  1448. data.qty = _qty;
  1449. if ($table) {
  1450. $table.clearEdit();
  1451. nextTick(() => {
  1452. $table.setActiveRow(data);
  1453. });
  1454. }
  1455. }
  1456. };
  1457. /**
  1458. * @description 面料-裥大、小侧,增加物料
  1459. */
  1460. const funcAddMxSide = async (params: any, data: any, targetRef?: any) => {
  1461. // arg_array_formulakind
  1462. let newParams: any = {};
  1463. newParams.queryParams = params;
  1464. newParams.dsname = "web_mattress_formulalist";
  1465. let res = await CommonDynamicSelect(newParams);
  1466. console.log("funcAddBigSide res :>> ", res);
  1467. if (res.datatable) {
  1468. if (targetRef) {
  1469. const $table = targetRef.element;
  1470. if ($table) {
  1471. res.datatable.map(itm => {
  1472. let records: any = {
  1473. formulatype: itm.formulatype,
  1474. if_mtrl: Number(itm.if_mtrl),
  1475. formulaid: itm.formulaid,
  1476. sortcode: data.label,
  1477. chastr: data.label,
  1478. costamt: 0,
  1479. formulakind: Number(itm.formulakind),
  1480. formula: itm.formula,
  1481. useformula: itm.useformula,
  1482. gydscrp: itm.gydscrp
  1483. };
  1484. if (records.if_mtrl > 1) {
  1485. records.addmx = "+";
  1486. records.delmx = "-";
  1487. }
  1488. $table.insertAt(records, -1);
  1489. });
  1490. }
  1491. } else {
  1492. let arr = [];
  1493. res.datatable.map(itm => {
  1494. let records: any = {
  1495. formulatype: itm.formulatype,
  1496. if_mtrl: Number(itm.if_mtrl),
  1497. formulaid: itm.formulaid,
  1498. sortcode: data.label,
  1499. chastr: data.label,
  1500. costamt: 0,
  1501. formulakind: Number(itm.formulakind),
  1502. formula: itm.formula,
  1503. useformula: itm.useformula,
  1504. gydscrp: itm.gydscrp
  1505. };
  1506. if (records.if_mtrl > 1) {
  1507. records.addmx = "+";
  1508. records.delmx = "-";
  1509. }
  1510. arr.push(records);
  1511. });
  1512. return arr;
  1513. }
  1514. } else {
  1515. return [];
  1516. }
  1517. };
  1518. const wf_mtrl_find = async (params: any) => {
  1519. let _params: any = {
  1520. dsname: "web_mtrl_choose",
  1521. queryparams: params
  1522. };
  1523. let res = await CommonDynamicSelect(_params);
  1524. if (res?.datatable?.length) {
  1525. return res?.datatable;
  1526. } else {
  1527. return [];
  1528. }
  1529. };
  1530. // /**
  1531. // * @description 垫层配置 和 垫层可选项
  1532. // * @author w_mattress_add wf_add_dianceng_bytype
  1533. // */
  1534. // const wf_add_dianceng_bytype = (dianceng_sort: string) => {
  1535. // let newMxData = [];
  1536. // let _diancengSortStr = dianceng_sort.replace(/,/g, ",").replace(/~r~n/g, "").replace(/~r/g, "").replace(/~n/g, "");
  1537. // let arr = _diancengSortStr.split("/");
  1538. // let formulakindArr = [];
  1539. // arr.map(async (t, index) => {
  1540. // let result = f_pb_split(t);
  1541. // let _formulakind;
  1542. // switch (result.left) {
  1543. // case "垫层":
  1544. // _formulakind = 32;
  1545. // break;
  1546. // case "床网":
  1547. // _formulakind = 999;
  1548. // break;
  1549. // case "顶布":
  1550. // _formulakind = 12;
  1551. // break;
  1552. // case "毡类":
  1553. // _formulakind = 13;
  1554. // break;
  1555. // case "打底无纺布":
  1556. // _formulakind = 14;
  1557. // break;
  1558. // case "网面布料":
  1559. // _formulakind = 29;
  1560. // break;
  1561. // default:
  1562. // _formulakind = -1;
  1563. // break;
  1564. // }
  1565. // let _params = {
  1566. // dsname: "web_mattress_formulalist",
  1567. // queryparams: {
  1568. // arg_array_formulakind: [_formulakind],
  1569. // arg_array_formulatype: [0, 1, 2, 3],
  1570. // pageindex: 1,
  1571. // pagesize: 1
  1572. // }
  1573. // };
  1574. // let res = await CommonDynamicSelect(_params);
  1575. // if (res?.datatable?.length) {
  1576. // res?.datatable.map((item: any) => {
  1577. // let _data: any = {};
  1578. // _data.formulatype = item.formulatype;
  1579. // _data.if_mtrl = 2;
  1580. // _data.formulaid = item.formulaid;
  1581. // _data.sortcode = item.sortcode;
  1582. // _data.formulakind = item.formulakind;
  1583. // _data.formula = item.formula;
  1584. // _data.chastr = wf_set_area_text(result.right);
  1585. // _data.qty = 1;
  1586. // _data.xu = index;
  1587. // _data.useformula = item.useformula;
  1588. // _data.gydscrp = item.gydscrp;
  1589. // newMxData.push(_data);
  1590. // });
  1591. // }
  1592. // });
  1593. // };
  1594. // const wf_add_dianceng_area_bytype = (data: string) => {
  1595. // if (!data) return;
  1596. // let _dataStr = data.replace(/,/g, ",").replace(/~r~n/g, "").replace(/~r/g, "").replace(/~n/g, "");
  1597. // let result: any = _dataStr.split(",");
  1598. // result = result.map(t => {
  1599. // return { value: t, label: t };
  1600. // });
  1601. // return result;
  1602. // };
  1603. // function wf_set_area_text(arg_str) {
  1604. // let ls_rtn = "";
  1605. // if (arg_str.includes("大侧")) {
  1606. // ls_rtn = "大侧";
  1607. // } else if (arg_str.includes("小侧1")) {
  1608. // ls_rtn = "小侧1";
  1609. // } else if (arg_str.includes("小侧2")) {
  1610. // ls_rtn = "小侧2";
  1611. // } else if (arg_str.includes("小侧3")) {
  1612. // ls_rtn = "小侧3";
  1613. // } else if (arg_str.includes("V侧1")) {
  1614. // ls_rtn = "V侧1";
  1615. // } else if (arg_str.includes("V侧2")) {
  1616. // ls_rtn = "V侧2";
  1617. // } else if (arg_str.includes("V侧3")) {
  1618. // ls_rtn = "V侧3";
  1619. // } else {
  1620. // ls_rtn = "";
  1621. // }
  1622. // return ls_rtn;
  1623. // }
  1624. // /**
  1625. // * @description 包装默认物料设置
  1626. // */
  1627. // const wf_default_mtrlid = async () => {
  1628. // // 包装
  1629. // console.log("wf_default_mtrlid state.packagMxData :>> ", state.packagMxData);
  1630. // let _deptid = state.LjDetailRef._mainData.deptid;
  1631. // let deptEnum = state.LjDetailRef.enumMap.get("deptid");
  1632. // let _pricelistid = 0;
  1633. // console.log("deptEnum :>> ", deptEnum);
  1634. // if (deptEnum) {
  1635. // let depItem = deptEnum.find((item: any) => item.value == _deptid);
  1636. // console.log("depItem :>> ", depItem);
  1637. // if (depItem) {
  1638. // _pricelistid = Number(depItem.pricelistid);
  1639. // }
  1640. // }
  1641. // // 根据formulaid,获取全部设置的默认物料信息
  1642. // let defaultMtrlList = [];
  1643. // let _param_mf = {
  1644. // dsname: "web_mtrl_choose",
  1645. // queryparams: {
  1646. // arg_array_formulaid: [16, 17, 18, 19, 27],
  1647. // arg_pricelistid: _pricelistid,
  1648. // arg_array_mtrlid: [46804, 46809, 46811, 46817, 46872]
  1649. // }
  1650. // };
  1651. // let res_mf = await CommonDynamicSelect(_param_mf);
  1652. // if (res_mf?.datatable?.length) {
  1653. // defaultMtrlList = res_mf?.datatable;
  1654. // }
  1655. // // let _mtrlData = await wf_mtrl_find(_pricelistid, [46804, 46809, 46811, 46817, 46872]);
  1656. // console.log("wf_default_mtrlid ccccc state.packagMxData :>> ", state.packagMxData);
  1657. // state.packagMxData.map(itm => {
  1658. // console.log("packagMxData itm :>> ", itm);
  1659. // let _formulakind = Number(itm.formulakind);
  1660. // let _data = null;
  1661. // if (_formulakind == 16) {
  1662. // //默认 pe kind = 16 默认 10C PE袋 mtrlid 46804
  1663. // itm.mtrlid = 46804;
  1664. // } else if (_formulakind == 17) {
  1665. // //默认 外层pe kind = 17 默认 20C mtrlid 46809
  1666. // itm.mtrlid = 46809;
  1667. // } else if (_formulakind == 18) {
  1668. // //默认 pvc kind = 18 默认 15C mtrlid 46811
  1669. // itm.mtrlid = 46811;
  1670. // } else if (_formulakind == 19) {
  1671. // //默认 卷包外包装 kind = 19 默认 彩箱 32*32 46817
  1672. // itm.mtrlid = 46817;
  1673. // } else if (_formulakind == 27) {
  1674. // //默认 拉手脚轮 kind = 27 默认 46872
  1675. // itm.mtrlid = 46872;
  1676. // }
  1677. // _data = defaultMtrlList.find(t => t.mtrlid == itm.mtrlid);
  1678. // console.log("wf_default_mtrlid _data :>> ", _data);
  1679. // if (_data) {
  1680. // itm.mtrlname = _data.mtrlname;
  1681. // itm.price = _data.pricelistprice;
  1682. // itm.gram_weight = _data.gram_weight;
  1683. // itm.cloth_width = _data.cloth_width;
  1684. // itm.if_inputqty = _data.if_inputqty;
  1685. // itm.priceunit = _data.priceunit;
  1686. // itm.shrinkage = _data.shrinkage;
  1687. // itm.qty = 1;
  1688. // if (_data.formula != "") {
  1689. // itm.formula = _data.formula;
  1690. // }
  1691. // }
  1692. // return itm;
  1693. // });
  1694. // console.log("wf_default_mtrlid state.packagMxData :>> ", state.packagMxData);
  1695. // };
  1696. // const wf_default_mtrlid_notbz = async () => {
  1697. // console.log("state.oriMxData.list bf state.oriMxData.list :>> ", state.oriMxData.list);
  1698. // // 收集数据中各种公式的formulaid
  1699. // let _formulaids = [];
  1700. // state.oriMxData.list.forEach((itm: any) => {
  1701. // _formulaids.push(itm.formulaid);
  1702. // });
  1703. // // 数组去重
  1704. // _formulaids = Array.from(new Set(_formulaids));
  1705. // // 部门设置的报价表
  1706. // let _pricelistid = 0;
  1707. // let _deptid = state.LjDetailRef._mainData.deptid;
  1708. // let deptEnum = state.LjDetailRef.enumMap.get("deptid");
  1709. // console.log("deptEnum :>> ", deptEnum);
  1710. // if (deptEnum) {
  1711. // let depItem = deptEnum.find((item: any) => item.value == _deptid);
  1712. // console.log("depItem :>> ", depItem);
  1713. // if (depItem) {
  1714. // _pricelistid = Number(depItem.pricelistid);
  1715. // }
  1716. // }
  1717. // // 根据formulaid,获取全部设置的默认物料信息
  1718. // let defaultMtrlList = [];
  1719. // let _param_mf = {
  1720. // dsname: "web_mtrl_choose",
  1721. // queryparams: {
  1722. // arg_array_formulaid: _formulaids,
  1723. // arg_pricelistid: _pricelistid,
  1724. // arg_array_mtrlid: [46804, 46809, 46811, 46817, 46872]
  1725. // }
  1726. // };
  1727. // let res_mf = await CommonDynamicSelect(_param_mf);
  1728. // if (res_mf?.datatable?.length) {
  1729. // defaultMtrlList = res_mf?.datatable;
  1730. // }
  1731. // state.oriMxData.list.forEach((itm: any) => {
  1732. // let _formulakind = Number(itm.formulakind);
  1733. // let _data = defaultMtrlList.find(t => t.formulaid == itm.formulaid);
  1734. // console.log("wf_default_mtrlid_notbz 查询默认物料_data :>> ", _data);
  1735. // // 包装default
  1736. // if (itm.formulatype == "3") {
  1737. // let changeMtrl = 0;
  1738. // if (_formulakind == 16) {
  1739. // //默认 pe kind = 16 默认 10C PE袋 mtrlid 46804
  1740. // changeMtrl = 46804;
  1741. // } else if (_formulakind == 17) {
  1742. // //默认 外层pe kind = 17 默认 20C mtrlid 46809
  1743. // changeMtrl = 46809;
  1744. // } else if (_formulakind == 18) {
  1745. // //默认 pvc kind = 18 默认 15C mtrlid 46811
  1746. // changeMtrl = 46811;
  1747. // } else if (_formulakind == 19) {
  1748. // //默认 卷包外包装 kind = 19 默认 彩箱 32*32 46817
  1749. // changeMtrl = 46817;
  1750. // } else if (_formulakind == 27) {
  1751. // //默认 拉手脚轮 kind = 27 默认 46872
  1752. // changeMtrl = 46872;
  1753. // }
  1754. // if (changeMtrl && !_data) {
  1755. // _data = defaultMtrlList.find(t => t.mtrlid == changeMtrl);
  1756. // }
  1757. // }
  1758. // if (_data) {
  1759. // itm.mtrlid = _data.mtrlid;
  1760. // itm.mtrlname = _data.mtrlname;
  1761. // itm.price = _data.pricelistprice;
  1762. // itm.gram_weight = _data.gram_weight;
  1763. // itm.cloth_width = _data.cloth_width;
  1764. // itm.if_inputqty = _data.if_inputqty;
  1765. // itm.priceunit = _data.priceunit;
  1766. // itm.shrinkage = _data.shrinkage;
  1767. // itm.qty = 1;
  1768. // if (_data.formula != "") {
  1769. // itm.formula = _data.formula;
  1770. // }
  1771. // }
  1772. // });
  1773. // console.log("state.oriMxData.list affff state.oriMxData.list :>> ", state.oriMxData.list);
  1774. // };
  1775. /**
  1776. * @description 明细,新增
  1777. */
  1778. const funcAddMtrlMx = async (data: any, cb?: Function, refName?: string, firstRow?: any) => {
  1779. console.log("state.LjDetail. :>> ", state.LjDetailRef);
  1780. console.log("funcAddMtrlMx data :>> ", data);
  1781. let { row, $rowIndex, visibleData } = data;
  1782. let tgRefName = "";
  1783. if (refName) {
  1784. tgRefName = refName;
  1785. } else {
  1786. let { tabsActive } = state.LjDetailRef;
  1787. let _target = tabsActive == "fabricMx" ? state.fabricMxTabs : tabsActive;
  1788. let currentTab = state.fabricMxTabList.find(t => t.name == _target);
  1789. tgRefName = currentTab.ref;
  1790. }
  1791. const $table = state[tgRefName].element;
  1792. if ($table) {
  1793. let records = {};
  1794. if (["specialProcessesMxRef", "additionalCostsMxRef"].includes(tgRefName)) {
  1795. records = {
  1796. addmx: "+",
  1797. delmx: "-",
  1798. mattressid: state.LjDetailRef._mainData.mattressid,
  1799. mattressmxid: 0,
  1800. extraid: row?.extraid ?? 0,
  1801. extramxid: row?.extramxid ?? 0,
  1802. extraname: "",
  1803. price: "",
  1804. qty: 1,
  1805. dscrp: ""
  1806. };
  1807. } else if (tgRefName === "accessoriesMxRef") {
  1808. const result = state.mattressFormulaList.find(item => item.formulatype === 2 && item.formulakind === 15);
  1809. records = {
  1810. mattressmxid: 0,
  1811. formulatype: 2,
  1812. if_mtrl: 2,
  1813. formula: "",
  1814. sortcode: "",
  1815. formulakind: 15,
  1816. formulaid: result.formulaid || 0
  1817. };
  1818. } else {
  1819. records = {
  1820. addmx: "+",
  1821. delmx: "-",
  1822. mattressmxid: 0,
  1823. formulatype: row.formulatype,
  1824. if_mtrl: row.if_mtrl,
  1825. formulaid: row.formulaid,
  1826. sortcode: row.sortcode,
  1827. formulakind: row.formulakind,
  1828. formula: row.formula,
  1829. thickness: 0,
  1830. mtrlid: 0,
  1831. chastr: row.chastr,
  1832. xu: Number(row.xu) + 0.01
  1833. };
  1834. }
  1835. // null 从第一行插入, row: 从当前行下一行插入
  1836. let _rowIdx = firstRow == -1 ? -1 : firstRow ? null : row;
  1837. console.log("funcAddMtrlMx _rowIdx :>> ", firstRow, firstRow == -1, _rowIdx);
  1838. const { row: newRow } = await $table.insertNextAt(records, _rowIdx);
  1839. await $table.setEditCell(newRow, "mtrlname");
  1840. await $table.setCurrentRow(newRow);
  1841. cb && cb();
  1842. }
  1843. };
  1844. /**
  1845. * @description 明细,删除
  1846. */
  1847. const funcDelMtrlMx = (data: any, refName?: string) => {
  1848. let { row } = data;
  1849. const _item = {
  1850. mtrlid: row.mtrlid,
  1851. mtrlname: row.mtrlname,
  1852. extra_cost: row.extra_cost
  1853. };
  1854. let tgRefName = "";
  1855. if (refName) {
  1856. tgRefName = refName;
  1857. } else {
  1858. let { tabsActive } = state.LjDetailRef;
  1859. let _target = tabsActive == "fabricMx" ? state.fabricMxTabs : tabsActive;
  1860. let currentTab = state.fabricMxTabList.find(t => t.name == _target);
  1861. tgRefName = currentTab.ref;
  1862. }
  1863. const $table = state[tgRefName].element;
  1864. if ($table) {
  1865. $table.remove(row);
  1866. autoLoadMtrlExtra(_item, 5, "del");
  1867. }
  1868. };
  1869. /**
  1870. * @description 明细,删除
  1871. */
  1872. const funcDelBednet = (scope: any, cb?: Function, refName?: string) => {
  1873. console.log("funcDelBednet: ", scope);
  1874. if (scope.data.length == 1) {
  1875. ElMessage.warning("不能全部删除,至少保留一个床网");
  1876. return false;
  1877. }
  1878. cb && cb();
  1879. funcDelMtrlMx(scope, refName);
  1880. // 床网与主副规格互联
  1881. nextTick(() => {
  1882. updateSubspecsTable();
  1883. });
  1884. };
  1885. /**
  1886. * @description 据字符串'myRef'来获取ref
  1887. * @param name
  1888. * @returns
  1889. */
  1890. const dynamicRef = name => {
  1891. return state[name]; // 获取ref的值
  1892. };
  1893. /**
  1894. * @description 获取当前需要显示的面料明细tabs
  1895. */
  1896. const getMattressType = () => {
  1897. const globalStore = useGlobalStore();
  1898. const { enumMap, _mainData } = state.LjDetailRef;
  1899. console.log("getMattressType enumMap :>> ", enumMap, _mainData, state.LjDetailRef);
  1900. let _enum = enumMap.get("mattresstypeid");
  1901. console.log("_enum :>> ", _enum);
  1902. if (_enum) {
  1903. state.mattresstypeEnum = _enum.find(t => t.value == _mainData.mattresstypeid);
  1904. console.log("mattresstypeEnum :>> ", state.mattresstypeEnum);
  1905. }
  1906. let _dwname = DwnameEnum.mattressQuote + "__fabric";
  1907. let _dftabs = "";
  1908. let _fabricShowList = undefined;
  1909. let itmshow = null;
  1910. if (globalStore?.detailtabs && Object.keys(globalStore?.detailtabs).includes(_dwname)) {
  1911. _dftabs = globalStore?.detailtabs[_dwname];
  1912. }
  1913. if (_dftabs) {
  1914. _fabricShowList = state.fabricMxTabList
  1915. .map(o => Object.keys(o).includes("visible") && o?.visible() && o)
  1916. .find(o => o?.name == _dftabs);
  1917. }
  1918. if (_fabricShowList) {
  1919. itmshow = _fabricShowList;
  1920. } else {
  1921. itmshow = state.fabricMxTabList.find(o => Object.keys(o).includes("visible") && o?.visible() && o);
  1922. }
  1923. state.fabricMxTabs = itmshow.name;
  1924. };
  1925. const funcChaifenTab = () => {
  1926. const { _mainData } = state.LjDetailRef;
  1927. // 面料
  1928. state.fabricMxData = state.oriMxData.list.filter(
  1929. t => t.formulatype == 0 || (Number(_mainData.if_bcp_type) == 1 && t.formulatype == 104)
  1930. );
  1931. console.log("funcChaifenTab fabricMxData :>> ", state.fabricMxData);
  1932. let _mx8 = state.fabricMxTabList.find(t => t.name == "tabpage_8");
  1933. state.fabricMxTab8 = state.fabricMxData.filter(t => _mx8.type.includes(Number(t.formulakind)));
  1934. state.fabricMxTab8.forEach((o, i) => {
  1935. o.xu = i + 1;
  1936. });
  1937. console.log("funcChaifenTab fabricMxTab8 :>> ", state.fabricMxTab8);
  1938. let _mx9 = state.fabricMxTabList.find(t => t.name == "tabpage_9");
  1939. state.fabricMxTab9 = state.fabricMxData.filter(t => _mx9.type.includes(Number(t.formulakind)));
  1940. state.fabricMxTab9.forEach((o, i) => {
  1941. o.xu = i + 1;
  1942. });
  1943. let _mx10 = state.fabricMxTabList.find(t => t.name == "tabpage_10");
  1944. state.fabricMxTab10 = state.fabricMxData.filter(t => _mx10.type.includes(Number(t.formulakind)));
  1945. state.fabricMxTab10.forEach((o, i) => {
  1946. o.xu = i + 1;
  1947. });
  1948. let _mx11 = state.fabricMxTabList.find(t => t.name == "tabpage_11");
  1949. state.fabricMxTab11 = state.fabricMxData.filter(t => _mx11.type.includes(Number(t.formulakind)));
  1950. state.fabricMxTab11.forEach((o, i) => {
  1951. o.xu = i + 1;
  1952. });
  1953. console.log("funcChaifenTab state.fabricMxTab11 :>> ", state.fabricMxTab11);
  1954. let _mx12 = state.fabricMxTabList.find(t => t.name == "tabpage_12");
  1955. state.fabricMxTab12 = state.fabricMxData.filter(t => _mx12.type.includes(Number(t.formulakind)));
  1956. state.fabricMxTab12.forEach((o, i) => {
  1957. o.xu = i + 1;
  1958. });
  1959. let _mx13 = state.fabricMxTabList.find(t => t.name == "tabpage_13");
  1960. state.fabricMxTab13 = state.fabricMxData.filter(t => !_mx13.type.includes(Number(t.formulakind)));
  1961. state.fabricMxTab13.forEach((o, i) => {
  1962. o.xu = i + 1;
  1963. });
  1964. // 垫层
  1965. state.cushionsMxData = state.oriMxData.list.filter(t => t.formulatype == 1);
  1966. state.cushionsMxData.forEach((o, i) => {
  1967. o.xu = i + 1;
  1968. });
  1969. // 辅料
  1970. state.accessoriesMxData = state.oriMxData.list.filter(t => t.formulatype == 2);
  1971. state.accessoriesMxData.forEach((o, i) => {
  1972. o.xu = i + 1;
  1973. });
  1974. // 包装
  1975. state.packagMxData = state.oriMxData.list.filter(t => t.formulatype == 3);
  1976. state.packagMxData.forEach((o, i) => {
  1977. o.xu = i + 1;
  1978. });
  1979. // 床网
  1980. state.bednetMxData = state.oriMxData.list.filter(t => t.formulatype == 99);
  1981. state.bednetMxData.forEach((o, i) => {
  1982. o.xu = i + 1;
  1983. });
  1984. };
  1985. /**
  1986. * 拆分表格数据到不同的分类
  1987. * @param {Object} _mainData - 主数据对象
  1988. * @param {Object} oriMxData - 原始明细数据对象
  1989. * @returns {Object} 包含所有分类数据的对象
  1990. */
  1991. const funcChaifenTabPro = (_mainData, oriMxData) => {
  1992. // 1. 处理面料数据
  1993. const processFabricData = () => {
  1994. const fabricMxData = oriMxData.filter(
  1995. t => t.formulatype == 0 || (Number(_mainData.if_bcp_type) == 1 && t.formulatype == 104)
  1996. );
  1997. console.log("funcChaifenTab fabricMxData :>> ", fabricMxData);
  1998. // 处理面料分页数据
  1999. const processFabricTab = (tabName, isExclude = false) => {
  2000. const tab = state.fabricMxTabList.find(t => t.name === tabName);
  2001. const key = `fabricMxTab${tabName.split("_")[1]}`;
  2002. const result = isExclude
  2003. ? fabricMxData.filter(t => !tab.type.includes(Number(t.formulakind)))
  2004. : fabricMxData.filter(t => tab.type.includes(Number(t.formulakind)));
  2005. // 添加序号
  2006. result.forEach((o, i) => {
  2007. o.xu = i + 1;
  2008. });
  2009. console.log(`funcChaifenTab ${key} :>> `, result);
  2010. return { [key]: result };
  2011. };
  2012. // 处理各个面料分页并合并结果
  2013. return {
  2014. ...processFabricTab("tabpage_8"),
  2015. ...processFabricTab("tabpage_9"),
  2016. ...processFabricTab("tabpage_10"),
  2017. ...processFabricTab("tabpage_11"),
  2018. ...processFabricTab("tabpage_12"),
  2019. ...processFabricTab("tabpage_13", true) // 最后一个tab是排除逻辑
  2020. };
  2021. };
  2022. // 2. 处理其他分类数据
  2023. const processOtherCategories = () => {
  2024. const categories = [
  2025. { key: "cushionsMxData", type: 1 }, // 垫层
  2026. { key: "accessoriesMxData", type: 2 }, // 辅料
  2027. { key: "packagMxData", type: 3 }, // 包装
  2028. { key: "bednetMxData", type: 99 } // 床网
  2029. ];
  2030. return categories.reduce((acc, { key, type }) => {
  2031. const result = oriMxData.filter(t => t.formulatype == type);
  2032. result.forEach((o, i) => {
  2033. o.xu = i + 1;
  2034. });
  2035. return { ...acc, [key]: result };
  2036. }, {});
  2037. };
  2038. // 处理内布套
  2039. const processNeiBuTaoData = () => {
  2040. // 处理面料分页数据
  2041. const otherMxTabList = [
  2042. {
  2043. label: "内布套",
  2044. name: "innerClothLayerMx",
  2045. ref: "innerClothLayerMxRef",
  2046. type: [101, 102]
  2047. },
  2048. {
  2049. label: "顶布裥棉",
  2050. name: "topCottonMx",
  2051. ref: "topCottonMxRef",
  2052. type: [103]
  2053. }
  2054. ];
  2055. const processNeiBuTaoTab = (tabName, isExclude = false) => {
  2056. const tab = otherMxTabList.find(t => t.name === tabName);
  2057. const key = `${tab.name}`;
  2058. const result = oriMxData.filter(t => tab.type.includes(Number(t.formulatype)));
  2059. // 添加序号
  2060. result.forEach((o, i) => {
  2061. o.xu = i + 1;
  2062. });
  2063. console.log(`funcChaifenTab ${key} :>> `, result);
  2064. return { [key]: result };
  2065. };
  2066. // 处理各个面料分页并合并结果
  2067. return {
  2068. ...processNeiBuTaoTab("innerClothLayerMx"),
  2069. ...processNeiBuTaoTab("topCottonMx")
  2070. };
  2071. };
  2072. // 合并所有结果并返回
  2073. return {
  2074. ...processFabricData(),
  2075. ...processOtherCategories(),
  2076. ...processNeiBuTaoData()
  2077. };
  2078. };
  2079. /**
  2080. * 获取报价单明细数据
  2081. * @returns {Array} 报价单明细数据数组
  2082. */
  2083. const getQuoteListMxData = data => {
  2084. return [
  2085. {
  2086. label: "面裥绵",
  2087. field: "tabpage_8",
  2088. replace: "面裥绵-",
  2089. data: data.fabricMxTab8 || []
  2090. },
  2091. {
  2092. label: "底裥绵",
  2093. field: "tabpage_9",
  2094. replace: "底裥绵-",
  2095. data: data.fabricMxTab9 || []
  2096. },
  2097. {
  2098. label: "裥大侧",
  2099. field: "tabpage_10",
  2100. replace: "大侧裥绵-",
  2101. data: data.fabricMxTab10 || []
  2102. },
  2103. {
  2104. label: "裥小侧",
  2105. field: "tabpage_11",
  2106. replace: "小侧裥绵-",
  2107. data: data.fabricMxTab11 || []
  2108. },
  2109. {
  2110. label: "裥V侧",
  2111. field: "tabpage_12",
  2112. replace: "V侧裥绵-",
  2113. data: data.fabricMxTab12 || []
  2114. },
  2115. {
  2116. label: "其他工艺",
  2117. field: "tabpage_13",
  2118. replace: "V侧裥绵-",
  2119. data: data.fabricMxTab13 || []
  2120. },
  2121. {
  2122. label: "垫层",
  2123. field: "cushions",
  2124. data: {
  2125. cushions: data.cushionsMxData || [],
  2126. bednet: data.bednetMxData || []
  2127. }
  2128. },
  2129. {
  2130. label: "辅料",
  2131. field: "accessories",
  2132. data: data.accessoriesMxData || []
  2133. },
  2134. {
  2135. label: "包装",
  2136. field: "packag",
  2137. data: data.packagMxData || []
  2138. },
  2139. {
  2140. label: "内布套",
  2141. field: "innerClothLayerMx",
  2142. data: data.innerClothLayerMx || []
  2143. },
  2144. {
  2145. label: "顶布裥棉",
  2146. field: "topCottonMx",
  2147. data: data.topCottonMx || []
  2148. }
  2149. ];
  2150. };
  2151. /**
  2152. * @description 切换包装方式select,获取默认物料
  2153. * @param val
  2154. */
  2155. const funcPacktypeChange = async (val: any) => {
  2156. console.log("wf_import_bz val :>> ", val);
  2157. let newMxData: any = [];
  2158. const { _mainData, enumMap } = state.LjDetailRef;
  2159. if (val == "0") {
  2160. _mainData.diameter = 0;
  2161. } else if (val == "1") {
  2162. _mainData.packqty = 0;
  2163. } else {
  2164. _mainData.diameter = 0;
  2165. _mainData.packqty = 0;
  2166. }
  2167. let _pricelistid = getPriceid();
  2168. let _params = {
  2169. mattresstypeid: _mainData.mattresstypeid,
  2170. ifbcptype: _mainData.if_bcp_type,
  2171. packtype: _mainData.packtype,
  2172. pricelistid: _pricelistid
  2173. };
  2174. let res = await GetMattressPackagMx(_params);
  2175. if (res) {
  2176. newMxData = res.mattressMx;
  2177. // _mainData.biandai_qty = res?.biandai_qty;
  2178. state.diancengAreaEnum = res?.diancengarea;
  2179. }
  2180. state.packagMxData = newMxData;
  2181. };
  2182. /**
  2183. * @description 重新获取明细数据
  2184. * @author w_mattress_add wf_import_dw_2
  2185. */
  2186. const wf_import_dw_2 = async () => {
  2187. // let _biandaiqty = 0;
  2188. let newMxData: any = [];
  2189. /**
  2190. * @description 床垫类别参数
  2191. */
  2192. let mattressTypeData: any = {};
  2193. const { _mainData, enumMap } = state.LjDetailRef;
  2194. let _pricelistid = getPriceid();
  2195. let _params = {
  2196. mattressid: Number(_mainData.mattressid),
  2197. mattresstypeid: _mainData.mattresstypeid,
  2198. ifbcptype: _mainData.if_bcp_type,
  2199. packtype: _mainData.packtype,
  2200. pricelistid: _pricelistid
  2201. };
  2202. let res = await GetMattressImportDW2(_params);
  2203. if (res) {
  2204. newMxData = res.mattressMx;
  2205. _mainData.biandai_qty = res?.biandai_qty;
  2206. state.diancengAreaEnum = res?.diancengarea;
  2207. state.specialProcessesMxData = res?.extraEnum.filter(t => t.typeid == 1);
  2208. state.additionalCostsMxData = res?.extraEnum.filter(t => t.typeid == 2);
  2209. state.specialProcessesEnum = res?.extraTypeEnum.filter(t => t.typeid == 1);
  2210. state.additionalCostsEnum = res?.extraTypeEnum.filter(t => t.typeid == 2);
  2211. state.specialProcessesMxInitData = res?.extraProcessesMx;
  2212. state.additionalCostsMxInitData = res?.extraCostsMx;
  2213. }
  2214. state.oriMxData.list = newMxData;
  2215. getMattressType();
  2216. funcChaifenTab();
  2217. await initExtraData();
  2218. };
  2219. const initExtraData = async () => {
  2220. console.log("initExtraData state.specialProcessesMxInitData :>> ", state.specialProcessesMxInitData);
  2221. console.log("initExtraData state.additionalCostsMxInitData :>> ", state.additionalCostsMxInitData);
  2222. const $tableSpecial = state.specialProcessesMxRef.element;
  2223. const $tableAdditional = state.additionalCostsMxRef.element;
  2224. if ($tableSpecial) {
  2225. $tableSpecial.remove();
  2226. let _arr = [];
  2227. let _mattressId = state.LjDetailRef._mainData.mattressid;
  2228. state.specialProcessesMxInitData.map(o => {
  2229. let _itm = {
  2230. addmx: "+",
  2231. delmx: "-",
  2232. mattressid: _mattressId,
  2233. mattressmxid: 0,
  2234. extraid: o.extraid,
  2235. extraname: o.extraname,
  2236. price: o.price,
  2237. qty: o.qty,
  2238. dscrp: o.dscrp,
  2239. inputtype: o.inputtype,
  2240. typeid: o.typeid
  2241. };
  2242. _arr.push(_itm);
  2243. });
  2244. await $tableSpecial.insertAt(_arr, -1);
  2245. }
  2246. if ($tableAdditional) {
  2247. $tableAdditional.remove();
  2248. let _arr = [];
  2249. let _mattressId = state.LjDetailRef._mainData.mattressid;
  2250. state.additionalCostsMxInitData.map(o => {
  2251. let _itm = {
  2252. addmx: "+",
  2253. delmx: "-",
  2254. mattressid: _mattressId,
  2255. mattressmxid: 0,
  2256. extraid: o.extraid,
  2257. extraname: o.extraname,
  2258. price: o.price,
  2259. qty: o.qty,
  2260. dscrp: o.dscrp,
  2261. inputtype: o.inputtype,
  2262. typeid: o.typeid
  2263. };
  2264. _arr.push(_itm);
  2265. });
  2266. await $tableAdditional.insertAt(_arr, -1);
  2267. }
  2268. };
  2269. /**
  2270. * @description 变更床垫分类时,重载明细数据 dw_1 itemchange
  2271. * @author w_mattress_add dw_1 itemchange
  2272. */
  2273. const funcImportMattressMx = async () => {
  2274. console.log("funcImportMattressMx state.LjDetailRef._mainData :>> ", state.LjDetailRef, state.orderStatus);
  2275. const { _mainData, enumMap, baseformRef } = state.LjDetailRef;
  2276. // let mainData = state.orderStatus == "new" ? initParam : _mainData;
  2277. console.log("mainData :>> ", _mainData);
  2278. if (!Number(_mainData.deptid)) {
  2279. ElMessage.warning("请先选择部门");
  2280. console.log("baseformRef.element :>> ", baseformRef.element);
  2281. baseformRef.element.validateField("deptid");
  2282. _mainData.mattresstypeid = "";
  2283. return;
  2284. }
  2285. let _pricelistid = getPriceid();
  2286. if (!_pricelistid) {
  2287. ElMessage.warning("选择部门未设置价格表,请检查");
  2288. return;
  2289. }
  2290. // if (!_mainData.mattresstypeid) {
  2291. // ElMessage.warning("请先选择床垫类别");
  2292. // return;
  2293. // }
  2294. wf_import_dw_2();
  2295. };
  2296. /**
  2297. * @description 刷新报价清单
  2298. */
  2299. const wf_factory_profitrate = async () => {
  2300. const { _mainData, enumMap } = state.LjDetailRef;
  2301. console.log("wf_factory_profitrate enumMap :>> ", enumMap);
  2302. let _pricelistid = getPriceid();
  2303. let _params = {
  2304. dsname: "web_factory_profitratelist",
  2305. queryparams: {
  2306. arg_deptid: _mainData.deptid,
  2307. arg_bednettypeid_mattresstypeid: _mainData.mattresstypeid,
  2308. kind: 1
  2309. }
  2310. };
  2311. let res = await CommonDynamicSelect(_params);
  2312. if (res?.datatable?.length > 0) {
  2313. _mainData.profitrate = res?.datatable[0].profitrate;
  2314. }
  2315. };
  2316. /**
  2317. * @description 获取部门汇率 和 折扣率
  2318. */
  2319. const wf_get_moneyrate_discount = (val: any, data) => {
  2320. const { _mainData, enumMap } = state.LjDetailRef;
  2321. let deptEnum = enumMap.get("deptid");
  2322. console.log("deptEnum :>> ", deptEnum);
  2323. if (deptEnum) {
  2324. let depItem = deptEnum.find((item: any) => item.value == _mainData.deptid);
  2325. if (depItem) {
  2326. let _moneyrate = !depItem.moneyrate || Number(depItem.moneyrate) == 0 ? 1 : depItem.moneyrate;
  2327. if (val == 0 || !_mainData.if_moneyrate) {
  2328. data.moneyrate = 1;
  2329. } else {
  2330. data.moneyrate = _moneyrate;
  2331. }
  2332. data.discount = depItem.discount;
  2333. }
  2334. }
  2335. };
  2336. /**
  2337. * @description 计算价格
  2338. */
  2339. const wf_cmp_cb = async () => {
  2340. const { _mainData, enumMap, baseformRef } = state.LjDetailRef;
  2341. //wf_paixu 未有
  2342. await wf_factory_profitrate();
  2343. // 佣金
  2344. if (_mainData?.commission == 0 || !_mainData.commission) {
  2345. _mainData.commission = 1;
  2346. }
  2347. if (_mainData?.taxrate == 0 || !_mainData.taxrate) {
  2348. _mainData.taxrate = 1;
  2349. }
  2350. if (_mainData?.other_rate == 0 || !_mainData.other_rate) {
  2351. _mainData.other_rate = 1;
  2352. }
  2353. if (_mainData?.moneyrate == 0 || !_mainData.moneyrate) {
  2354. _mainData.moneyrate = 1;
  2355. }
  2356. if (_mainData?.commission < 1) {
  2357. throw new Error("佣金点数不能小于1");
  2358. }
  2359. if (_mainData?.taxrate < 1) {
  2360. throw new Error("税率不能小于1");
  2361. }
  2362. if (_mainData?.other_rate < 1) {
  2363. throw new Error("额外点数不能小于1");
  2364. }
  2365. if (_mainData?.dept_profitrate == 0) {
  2366. throw new Error("部门利润率不能为0!");
  2367. }
  2368. return true;
  2369. };
  2370. /**
  2371. * @description 展示计算公式
  2372. * @param timeout
  2373. */
  2374. const gotoSummy = async (timeout = 0) => {
  2375. const globalStore = useGlobalStore();
  2376. const { isShowOriginFormulaMattress } = storeToRefs(globalStore);
  2377. state.isShowOriginFormulaMattress = isShowOriginFormulaMattress.value;
  2378. // if (userInfo.usermode == 1) {
  2379. // ElMessage.error("'业务员模式不可以查看计算公式!'");
  2380. // return false;
  2381. // }
  2382. let mattress = state.LjDetailRef._mainData;
  2383. mattress.mattressid = Number(mattress.mattressid ?? 0);
  2384. mattress.xd_flag = Number(mattress.xd_flag ?? 0);
  2385. mattress.js1_flag = Number(mattress.js1_flag ?? 0);
  2386. mattress.flag = Number(mattress.flag ?? 0);
  2387. console.log("bbbbbbbbbbbbbbbbbbbb mattress :>> ", mattress);
  2388. // mattress.if_moneyrate = Number(mattress.if_moneyrate ?? 0);
  2389. // mattress.if_bcp_type = Number(mattress.if_bcp_type ?? 0);
  2390. // mattress.if_d_chai = Number(mattress.if_d_chai ?? 0);
  2391. // mattress.if_m_chai = Number(mattress.if_m_chai ?? 0);
  2392. // mattress.if_m_wbutao_way = Number(mattress.if_m_wbutao_way ?? 0);
  2393. // mattress.if_n_butao = Number(mattress.if_n_butao ?? 0);
  2394. // mattress.if_w_butao = Number(mattress.if_w_butao ?? 0);
  2395. // mattress.if_z_chai = Number(mattress.if_z_chai ?? 0);
  2396. // mattress.if_zhedie_type = Number(mattress.if_zhedie_type ?? 0);
  2397. let mattressMx = [];
  2398. state.fabricMxTabList.map(t => {
  2399. if (t.ref) {
  2400. console.log("t.ref?.value :>> ", t.ref, dynamicRef(t.ref));
  2401. if (dynamicRef(t.ref)) {
  2402. let { fullData } = dynamicRef(t.ref)?.element.getTableData();
  2403. console.log("fullData :>> ", fullData);
  2404. fullData = fullData.map((itm, idx) => {
  2405. itm.xu = idx + 1;
  2406. return itm;
  2407. });
  2408. mattressMx = mattressMx.concat(fullData);
  2409. }
  2410. }
  2411. });
  2412. let _params = {
  2413. mattress,
  2414. // mattressMx,
  2415. check_original: Number(state.isShowOriginFormulaMattress)
  2416. };
  2417. let res = await GetComputeMattress(_params);
  2418. console.log("GetComputeBednet res :>> ", res);
  2419. // let summaryData = [];
  2420. // let fieldParams = [];
  2421. let cpData = {};
  2422. if (!res.message) {
  2423. // summaryData = res.formulas;
  2424. // fieldParams = res.replace;
  2425. state.cmpFormulas = res.formulas;
  2426. state.cmpFormulaReplace = res.replace;
  2427. // state.
  2428. state.cmpFormulasOri = res.formulas_origin ?? [];
  2429. state.cmpFormulasBednet = res.formulas_bednet ?? [];
  2430. state.cmpDiffer = res.differ;
  2431. // 更新床网tab大小单单价显示
  2432. if (state.cmpDiffer.length > 0) {
  2433. let costArr = [];
  2434. state.cmpDiffer.forEach(o => {
  2435. let bednetMatch = o.replace.filter(itm => itm.label.indexOf("床网车间成本") > -1 && itm.label.indexOf("总") == -1);
  2436. if (!costArr.length) {
  2437. // 先加入空对象
  2438. bednetMatch.forEach(itm => {
  2439. costArr.push({
  2440. dannum2_cost: 0, // 标准
  2441. dannum1_cost: 0, // 散单
  2442. dannum3_cost: 0, // 大单
  2443. dannum4_cost: 0 // 小单
  2444. });
  2445. });
  2446. }
  2447. // 取文本出现的数字
  2448. let reg = /\d+/g;
  2449. if (bednetMatch.length) {
  2450. bednetMatch.forEach(itm => {
  2451. let matchIdx = itm.label.match(reg);
  2452. if (matchIdx && matchIdx.length) {
  2453. let idx = Number(matchIdx[0]);
  2454. costArr[idx - 1][`dannum${o.type}_cost`] = itm.value;
  2455. }
  2456. });
  2457. }
  2458. });
  2459. state.bednetMxData = state.bednetMxData.map((o, idx) => {
  2460. o.dannum2_cost = costArr[idx]?.dannum2_cost;
  2461. o.dannum1_cost = costArr[idx]?.dannum1_cost;
  2462. o.dannum3_cost = costArr[idx]?.dannum3_cost;
  2463. o.dannum4_cost = costArr[idx]?.dannum4_cost;
  2464. return o;
  2465. });
  2466. console.log("床网报价cost :>> ", costArr, state.bednetMxData);
  2467. }
  2468. } else {
  2469. setTimeout(() => {
  2470. if (res.message) {
  2471. ElNotification({
  2472. title: "计算失败",
  2473. message: res.message,
  2474. type: "warning"
  2475. });
  2476. }
  2477. }, 100);
  2478. return false;
  2479. }
  2480. // console.log("LjDetailRef.value.mainData :>> ", LjDetailRef.value._mainData, summaryData.value);
  2481. // const { _mainData, enumMap, baseformRef } = state.LjDetailRef;
  2482. // const toast = useToast();
  2483. // let result = await calculateFormula(summaryData.value, fieldParams.value, _mainData);
  2484. // if (result.length) {
  2485. // let _data = cloneDeep(_mainData);
  2486. // result.map((t, i) => {
  2487. // _data[t.field] = t.value;
  2488. // });
  2489. // result.map((t, i) => {
  2490. // _mainData[t.field] = t.value;
  2491. // });
  2492. // console.log("_data :>> ", _mainData, result);
  2493. // toast.clear();
  2494. // toast(
  2495. // {
  2496. // component: ToastFormula,
  2497. // props: {
  2498. // t: t,
  2499. // formulas: summaryData,
  2500. // // data: cpData,
  2501. // fields: fieldParams
  2502. // },
  2503. // listeners: {
  2504. // tomore: () => {
  2505. // console.log("tomore summaryData :>> ", summaryData);
  2506. // state.AllFormulaRef.open(summaryData, fieldParams);
  2507. // toast.clear();
  2508. // },
  2509. // refresh: () => {
  2510. // gotoSummy();
  2511. // }
  2512. // }
  2513. // },
  2514. // {
  2515. // position: POSITION.BOTTOM_RIGHT,
  2516. // icon: false,
  2517. // timeout: timeout,
  2518. // closeButton: false,
  2519. // toastClassName: "longjoe-toast"
  2520. // }
  2521. // );
  2522. // } else {
  2523. // ElMessage.error("计算公式有误");
  2524. // }
  2525. };
  2526. /**
  2527. * @description 展示历史价格
  2528. * @param timeout
  2529. * @param params
  2530. */
  2531. const gotoHisprice = async (title: string, timeout = 0, params: any, cbClose?: any) => {
  2532. const toast = useToast();
  2533. toast.clear();
  2534. nextTick(() => {
  2535. toast(
  2536. {
  2537. component: ToastHistoryPrice,
  2538. props: {
  2539. title: title,
  2540. ...params
  2541. },
  2542. listeners: {
  2543. todetail: (row: any) => {
  2544. console.log("gotoHisprice dd val :>> ", row, router);
  2545. if (Number(row.typeid) == 1) {
  2546. router.push(`/mattressQuote/detail?id=${row.bednetid_mattressid}`);
  2547. // state.bednetDrawerProps.deptid = state.LjDetailRef._mainData.deptid;
  2548. // state.bednetDrawerProps.bednetid = row.bednetid_mattressid;
  2549. // state.bednetDrawerProps.state = "";
  2550. // state.LjDrawerRef.show();
  2551. } else if (Number(row.typeid) == 2) {
  2552. router.push(`/bednetQuote/detail?id=${row.bednetid_mattressid}`);
  2553. }
  2554. },
  2555. closeToast: () => {
  2556. cbClose && cbClose();
  2557. }
  2558. }
  2559. },
  2560. {
  2561. position: POSITION.BOTTOM_RIGHT,
  2562. icon: false,
  2563. timeout: timeout,
  2564. closeButton: false,
  2565. toastClassName: "longjoe-toast"
  2566. }
  2567. );
  2568. });
  2569. };
  2570. const getFormulakindEnum = async () => {
  2571. let _params = {
  2572. dsname: "_Mapper_formulakind",
  2573. queryparams: {}
  2574. };
  2575. let res = await CommonDynamicSelect(_params);
  2576. let result = [];
  2577. if (res?.datatable?.length > 0) {
  2578. result = res?.datatable;
  2579. }
  2580. state.formulaKindEnum = result;
  2581. let _params2 = {
  2582. dsname: "_Mapper_formulakind_dc",
  2583. queryparams: {}
  2584. };
  2585. let res2 = await CommonDynamicSelect(_params2);
  2586. let result2 = [];
  2587. if (res2?.datatable?.length > 0) {
  2588. result2 = res2?.datatable;
  2589. state.formulaKindDcEnum = result2;
  2590. }
  2591. console.log("getFormulakindEnum state. state.formulaKindEnum :>> ", state.formulaKindEnum);
  2592. console.log("getFormulakindEnum state.formulaKindDcEnum :>> ", state.formulaKindDcEnum);
  2593. };
  2594. // 表格配置项
  2595. const columns: ColumnProps<any>[] = [
  2596. { type: "checkbox", width: 40, fixed: "left" },
  2597. { title: "#", type: "seq", fixed: "left", width: 80 },
  2598. {
  2599. field: "deptid",
  2600. title: "部门",
  2601. search: {
  2602. el: "select",
  2603. key: "arg_deptid",
  2604. props: {
  2605. filterable: true,
  2606. onChange: val => {
  2607. state.initParams.arg_deptid = val;
  2608. }
  2609. },
  2610. order: 2
  2611. },
  2612. basicinfo: {
  2613. el: "select",
  2614. editable: (scope: any) => {
  2615. return Boolean(Number(scope.searchParam.deptid) == 0);
  2616. },
  2617. rules: [{ required: true, message: "请先选择部门", trigger: "change" }],
  2618. props: {
  2619. filterable: true,
  2620. clearable: false
  2621. },
  2622. order: 1,
  2623. group: "单据信息"
  2624. }
  2625. },
  2626. {
  2627. field: "mattressrelcode",
  2628. title: "核价编码",
  2629. basicinfo: {
  2630. el: "input",
  2631. editable: ALLOW_EDIT_STATE
  2632. }
  2633. },
  2634. {
  2635. field: "mattresstypeid",
  2636. title: "床垫类别",
  2637. basicinfo: {
  2638. el: "select",
  2639. editable: ALLOW_EDIT_STATE,
  2640. rules: [{ required: true, message: "请先选择床垫类别", trigger: "change" }],
  2641. props: {
  2642. clearable: false,
  2643. filterable: true,
  2644. onChange: () => funcImportMattressMx()
  2645. }
  2646. }
  2647. },
  2648. {
  2649. field: "mattressname",
  2650. title: "核价名称",
  2651. align: "left",
  2652. table: "u_mattress",
  2653. search: {
  2654. el: "input",
  2655. key: "arg_search",
  2656. titleKey: "searchKw",
  2657. props: {
  2658. placeholder: "唯一码/编码/名称"
  2659. },
  2660. order: 1
  2661. },
  2662. basicinfo: {
  2663. el: "input",
  2664. editable: ALLOW_EDIT_STATE
  2665. },
  2666. treeNode: true,
  2667. render: scope => {
  2668. return !scope.row?.child_count && !scope.row?.parentid ? (
  2669. scope.row?.mattressname
  2670. ) : scope.row?.parentid ? (
  2671. <div class="flx-justify-between">
  2672. <span class="mle">{scope.row?.mattressname}</span>
  2673. <el-tag type="warning" effect="light" disable-transitions size="small" round class="ml-4">
  2674. </el-tag>
  2675. </div>
  2676. ) : (
  2677. <div class="flx-justify-between">
  2678. <span class="mle">{scope.row?.mattressname}</span>
  2679. <el-tag type="primary" effect="light" disable-transitions size="small" round class="ml-4">
  2680. </el-tag>
  2681. </div>
  2682. );
  2683. }
  2684. },
  2685. {
  2686. field: "flag",
  2687. title: "财务审核",
  2688. table: "u_mattress",
  2689. search: {
  2690. el: "select",
  2691. key: "status_flag",
  2692. titleKey: "status",
  2693. props: {
  2694. clearable: true,
  2695. placeholder: "全部",
  2696. onChange: () => {
  2697. state.vxeTableRef.refresh();
  2698. }
  2699. },
  2700. order: 3,
  2701. render: scope => {
  2702. // let _keys = Object.keys(scope);
  2703. // let _data = _keys.includes("row") ? scope.row : _keys.includes("searchParam") ? scope.searchParam : scope;
  2704. return (
  2705. <el-select v-model={scope.searchParam.status_flag} placeholder="全部" clearable>
  2706. <el-option label="待下单" value="1" />
  2707. <el-option label="已下单" value="2" />
  2708. <el-option label="待财务审核" value="3" />
  2709. <el-option label="已财务审核" value="4" />
  2710. </el-select>
  2711. );
  2712. }
  2713. }
  2714. },
  2715. {
  2716. field: "dept_profitrate_rangli",
  2717. title: "部门让利点数",
  2718. basicinfo: {
  2719. el: "input-number",
  2720. editable: ALLOW_EDIT_STATE,
  2721. order: 2,
  2722. group: "单据信息"
  2723. }
  2724. },
  2725. {
  2726. field: "fees_dscrp",
  2727. title: "额外费用说明",
  2728. basicinfo: {
  2729. el: "input",
  2730. props: { type: "textarea", rows: 2 },
  2731. editable: ALLOW_EDIT_STATE,
  2732. row: 2
  2733. }
  2734. },
  2735. {
  2736. field: "foreign_cost",
  2737. table: "u_mattress",
  2738. title: "外币价",
  2739. basicinfo: {
  2740. titleKey: "bi_foreign_cost"
  2741. }
  2742. },
  2743. {
  2744. field: "nottax_dept_cost",
  2745. table: "u_mattress",
  2746. title: "部门不含税价",
  2747. basicinfo: {
  2748. titleKey: "bi_nottax_dept_cost"
  2749. }
  2750. },
  2751. {
  2752. field: "if_bcp_type",
  2753. title: "半成品",
  2754. basicinfo: {
  2755. labelHidden: true,
  2756. render: (scope: any) => {
  2757. let _disabled = !ALLOW_EDIT_STATE.includes(scope.status);
  2758. return (
  2759. <>
  2760. <el-checkbox
  2761. v-model={scope.searchParam.if_bcp_type}
  2762. true-value={1}
  2763. false-value={0}
  2764. disabled={_disabled}
  2765. label="半成品"
  2766. class="mr-8"
  2767. />
  2768. <el-checkbox
  2769. v-model={scope.searchParam.if_zhedie_type}
  2770. true-value={1}
  2771. false-value={0}
  2772. disabled={_disabled}
  2773. label="折叠款"
  2774. />
  2775. </>
  2776. );
  2777. }
  2778. }
  2779. },
  2780. {
  2781. field: "if_m_chai",
  2782. title: "面拆",
  2783. basicinfo: {
  2784. span: 2,
  2785. labelHidden: true,
  2786. render: (scope: any) => {
  2787. let _disabled = !ALLOW_EDIT_STATE.includes(scope.status);
  2788. return (
  2789. <>
  2790. <el-checkbox
  2791. v-model={scope.searchParam.if_m_chai}
  2792. true-value={1}
  2793. false-value={0}
  2794. disabled={_disabled}
  2795. label="面拆"
  2796. class="mr-8"
  2797. onChange={val => autoLoadExtraData_chai(val, "if_m_chai")}
  2798. />
  2799. <el-checkbox
  2800. v-model={scope.searchParam.if_z_chai}
  2801. true-value={1}
  2802. false-value={0}
  2803. disabled={_disabled}
  2804. label="中拆"
  2805. class="mr-8"
  2806. onChange={val => autoLoadExtraData_chai(val, "if_z_chai")}
  2807. />
  2808. <el-checkbox
  2809. v-model={scope.searchParam.if_d_chai}
  2810. true-value={1}
  2811. false-value={0}
  2812. disabled={_disabled}
  2813. label="底拆"
  2814. onChange={val => autoLoadExtraData_chai(val, "if_d_chai")}
  2815. />
  2816. </>
  2817. );
  2818. }
  2819. }
  2820. },
  2821. {
  2822. field: "erp_mtrlcode",
  2823. title: "L1物料编码",
  2824. search: {
  2825. el: "input",
  2826. key: "arg_erp_mtrlcode",
  2827. props: {
  2828. placeholder: "L1物料编码"
  2829. },
  2830. order: 0
  2831. }
  2832. },
  2833. {
  2834. field: "mattress_width",
  2835. title: "床垫宽/CM",
  2836. basicinfo: {
  2837. el: "input-number",
  2838. editable: ALLOW_EDIT_STATE
  2839. }
  2840. },
  2841. {
  2842. field: "mattress_length",
  2843. title: "床垫长/CM",
  2844. basicinfo: {
  2845. el: "input-number",
  2846. editable: ALLOW_EDIT_STATE
  2847. }
  2848. },
  2849. {
  2850. field: "mattress_height",
  2851. title: "床垫高/CM",
  2852. basicinfo: {
  2853. el: "input-number",
  2854. props: {
  2855. onChange: (val: any) => {
  2856. const $table = state.subSpecsRef?.element;
  2857. if ($table) {
  2858. const { visibleData } = $table.getTableData();
  2859. visibleData.forEach((o: any) => {
  2860. o.mattress_height = val;
  2861. });
  2862. }
  2863. }
  2864. },
  2865. editable: ALLOW_EDIT_STATE
  2866. }
  2867. },
  2868. {
  2869. field: "if_w_butao",
  2870. title: "顶布裥棉",
  2871. basicinfo: {
  2872. // el: "checkbox",
  2873. // editable: ALLOW_EDIT_STATE
  2874. labelHidden: true,
  2875. render: (scope: any) => {
  2876. console.log("if_w_butao scope :>> ", scope);
  2877. let _disabled = !ALLOW_EDIT_STATE.includes(scope.status);
  2878. return (
  2879. <>
  2880. <el-checkbox
  2881. v-model={scope.searchParam.if_w_butao}
  2882. true-value={1}
  2883. false-value={0}
  2884. disabled={_disabled}
  2885. label="顶布裥棉"
  2886. class="mr-8"
  2887. />
  2888. </>
  2889. );
  2890. }
  2891. }
  2892. },
  2893. {
  2894. field: "biandai_qty",
  2895. title: "边带数",
  2896. basicinfo: {
  2897. el: "input-number",
  2898. editable: (scope: any) => {
  2899. let someone =
  2900. Number(scope.searchParam?.if_m_chai ?? 0) +
  2901. Number(scope.searchParam?.if_z_chai ?? 0) +
  2902. Number(scope.searchParam?.if_d_chai ?? 0);
  2903. if (ALLOW_EDIT_STATE.includes(scope.status) && someone > 0) {
  2904. return true;
  2905. }
  2906. return false;
  2907. }
  2908. }
  2909. },
  2910. {
  2911. field: "if_n_butao",
  2912. title: "内布套",
  2913. basicinfo: {
  2914. labelHidden: true,
  2915. render: (scope: any) => {
  2916. let _disabled = !ALLOW_EDIT_STATE.includes(scope.status);
  2917. return (
  2918. <>
  2919. <el-checkbox
  2920. v-model={scope.searchParam.if_n_butao}
  2921. true-value={1}
  2922. false-value={0}
  2923. disabled={_disabled}
  2924. label="内布套"
  2925. class="mr-8"
  2926. />
  2927. </>
  2928. );
  2929. },
  2930. editvisible: (scope: any) => {
  2931. let someone =
  2932. Number(scope.searchParam?.if_m_chai ?? 0) +
  2933. Number(scope.searchParam?.if_z_chai ?? 0) +
  2934. Number(scope.searchParam?.if_d_chai ?? 0);
  2935. if (someone > 0) {
  2936. return true;
  2937. }
  2938. return false;
  2939. }
  2940. }
  2941. },
  2942. // {
  2943. // field: "s_cover_qty",
  2944. // title: "内布套上覆",
  2945. // basicinfo: {
  2946. // el: "input-number",
  2947. // editable: (scope: any) => {
  2948. // if (ALLOW_EDIT_STATE.includes(scope.status) && Number(scope.searchParam.if_n_butao)) {
  2949. // return true;
  2950. // }
  2951. // return false;
  2952. // },
  2953. // editvisible: (scope: any) => {
  2954. // let someone =
  2955. // Number(scope.searchParam?.if_m_chai ?? 0) +
  2956. // Number(scope.searchParam?.if_z_chai ?? 0) +
  2957. // Number(scope.searchParam?.if_d_chai ?? 0);
  2958. // if (someone > 0 && Number(scope.searchParam.if_n_butao)) {
  2959. // return true;
  2960. // }
  2961. // return false;
  2962. // }
  2963. // }
  2964. // },
  2965. // {
  2966. // field: "z_cover_qty",
  2967. // title: "内布套侧覆",
  2968. // basicinfo: {
  2969. // el: "input-number",
  2970. // editable: (scope: any) => {
  2971. // if (ALLOW_EDIT_STATE.includes(scope.status) && Number(scope.searchParam.if_n_butao)) {
  2972. // return true;
  2973. // }
  2974. // return false;
  2975. // },
  2976. // editvisible: (scope: any) => {
  2977. // let someone =
  2978. // Number(scope.searchParam?.if_m_chai ?? 0) +
  2979. // Number(scope.searchParam?.if_z_chai ?? 0) +
  2980. // Number(scope.searchParam?.if_d_chai ?? 0);
  2981. // if (someone > 0 && Number(scope.searchParam.if_n_butao)) {
  2982. // return true;
  2983. // }
  2984. // return false;
  2985. // }
  2986. // }
  2987. // },
  2988. // {
  2989. // field: "x_cover_qty",
  2990. // title: "内布套下覆",
  2991. // basicinfo: {
  2992. // el: "input-number",
  2993. // editable: (scope: any) => {
  2994. // if (ALLOW_EDIT_STATE.includes(scope.status) && Number(scope.searchParam.if_n_butao)) {
  2995. // return true;
  2996. // }
  2997. // return false;
  2998. // },
  2999. // editvisible: (scope: any) => {
  3000. // let someone =
  3001. // Number(scope.searchParam?.if_m_chai ?? 0) +
  3002. // Number(scope.searchParam?.if_z_chai ?? 0) +
  3003. // Number(scope.searchParam?.if_d_chai ?? 0);
  3004. // if (someone > 0 && Number(scope.searchParam.if_n_butao)) {
  3005. // return true;
  3006. // }
  3007. // return false;
  3008. // }
  3009. // }
  3010. // },
  3011. {
  3012. field: "if_m_wbutao_way",
  3013. title: "面料外布套做法",
  3014. basicinfo: {
  3015. labelHidden: true,
  3016. render: (scope: any) => {
  3017. let _disabled = !ALLOW_EDIT_STATE.includes(scope.status);
  3018. return (
  3019. <>
  3020. <el-checkbox
  3021. v-model={scope.searchParam.if_m_wbutao_way}
  3022. true-value={1}
  3023. false-value={0}
  3024. disabled={_disabled}
  3025. label="面料外布套做法"
  3026. class="mr-8"
  3027. />
  3028. </>
  3029. );
  3030. },
  3031. editvisible: (scope: any) => {
  3032. let someone =
  3033. Number(scope.searchParam?.if_m_chai ?? 0) +
  3034. Number(scope.searchParam?.if_z_chai ?? 0) +
  3035. Number(scope.searchParam?.if_d_chai ?? 0);
  3036. if (someone > 0) {
  3037. return true;
  3038. }
  3039. return false;
  3040. }
  3041. }
  3042. },
  3043. {
  3044. field: "s_m_cover_qty",
  3045. title: "面层向大侧覆盖",
  3046. basicinfo: {
  3047. el: "input-number",
  3048. editable: (scope: any) => {
  3049. if (ALLOW_EDIT_STATE.includes(scope.status) && Number(scope.searchParam.if_m_wbutao_way)) {
  3050. return true;
  3051. }
  3052. return false;
  3053. },
  3054. editvisible: (scope: any) => {
  3055. let someone =
  3056. Number(scope.searchParam?.if_m_chai ?? 0) +
  3057. Number(scope.searchParam?.if_z_chai ?? 0) +
  3058. Number(scope.searchParam?.if_d_chai ?? 0);
  3059. if (someone > 0 && Number(scope.searchParam.if_m_wbutao_way)) {
  3060. return true;
  3061. }
  3062. return false;
  3063. }
  3064. }
  3065. },
  3066. {
  3067. field: "z_m_cover_qty",
  3068. title: "大侧向底层覆盖",
  3069. basicinfo: {
  3070. el: "input-number",
  3071. editable: (scope: any) => {
  3072. if (ALLOW_EDIT_STATE.includes(scope.status) && Number(scope.searchParam.if_m_wbutao_way)) {
  3073. return true;
  3074. }
  3075. return false;
  3076. },
  3077. editvisible: (scope: any) => {
  3078. let someone =
  3079. Number(scope.searchParam?.if_m_chai ?? 0) +
  3080. Number(scope.searchParam?.if_z_chai ?? 0) +
  3081. Number(scope.searchParam?.if_d_chai ?? 0);
  3082. if (someone > 0 && Number(scope.searchParam.if_m_wbutao_way)) {
  3083. return true;
  3084. }
  3085. return false;
  3086. }
  3087. }
  3088. },
  3089. {
  3090. field: "x_m_cover_qty",
  3091. title: "底层向大侧覆盖",
  3092. basicinfo: {
  3093. el: "input-number",
  3094. editable: (scope: any) => {
  3095. if (ALLOW_EDIT_STATE.includes(scope.status) && Number(scope.searchParam.if_m_wbutao_way)) {
  3096. return true;
  3097. }
  3098. return false;
  3099. },
  3100. editvisible: (scope: any) => {
  3101. let someone =
  3102. Number(scope.searchParam?.if_m_chai ?? 0) +
  3103. Number(scope.searchParam?.if_z_chai ?? 0) +
  3104. Number(scope.searchParam?.if_d_chai ?? 0);
  3105. if (someone > 0 && Number(scope.searchParam.if_m_wbutao_way)) {
  3106. return true;
  3107. }
  3108. return false;
  3109. }
  3110. }
  3111. },
  3112. {
  3113. field: "commission",
  3114. title: "佣金点数",
  3115. basicinfo: {
  3116. el: "input-number",
  3117. editable: ALLOW_EDIT_STATE
  3118. }
  3119. },
  3120. {
  3121. field: "other_rate",
  3122. title: "额外点数",
  3123. basicinfo: {
  3124. el: "input-number",
  3125. editable: ALLOW_EDIT_STATE
  3126. }
  3127. },
  3128. {
  3129. field: "extras_cost",
  3130. title: "额外费用",
  3131. basicinfo: {
  3132. el: "input-number",
  3133. editable: ALLOW_EDIT_STATE
  3134. }
  3135. },
  3136. {
  3137. field: "taxes",
  3138. title: "税金",
  3139. enum: [
  3140. {
  3141. label: "不含税",
  3142. value: 1
  3143. },
  3144. {
  3145. label: "含税",
  3146. value: 1.07
  3147. }
  3148. ],
  3149. basicinfo: {
  3150. el: "select",
  3151. editable: ALLOW_EDIT_STATE,
  3152. render: (scope: any) => {
  3153. let optionRender = [];
  3154. let _disabled = !ALLOW_EDIT_STATE.includes(scope.status);
  3155. console.log("taxrate scope.enum :>> ", scope.enum);
  3156. scope.enum.map(item => {
  3157. optionRender.push(<el-option label={item.label} value={item.value} />);
  3158. });
  3159. let slotprefix = {
  3160. prefix: () => {
  3161. return <>{scope.searchParam.taxrate}</>;
  3162. }
  3163. };
  3164. let _taxrate = Number(scope.searchParam.taxrate);
  3165. return (
  3166. <el-select
  3167. v-model={_taxrate}
  3168. v-slots={slotprefix}
  3169. class="select-text-right"
  3170. disabled={_disabled}
  3171. onChange={val => funcTaxrateChange(val, scope.searchParam)}
  3172. >
  3173. {optionRender}
  3174. </el-select>
  3175. );
  3176. }
  3177. }
  3178. },
  3179. {
  3180. field: "moneyrate",
  3181. title: "币种",
  3182. render: (scope: any) => {
  3183. return (
  3184. <>
  3185. <div class="flx-justify-between">
  3186. <span>
  3187. <>{scope.row.moneyrate > 1 ? `美元` : "人民币"}</>
  3188. </span>
  3189. {scope.row.moneyrate > 1 && (
  3190. <span>
  3191. <>{scope.row.moneyrate}</>
  3192. </span>
  3193. )}
  3194. </div>
  3195. </>
  3196. );
  3197. },
  3198. basicinfo: {
  3199. el: "select",
  3200. editable: ALLOW_EDIT_STATE,
  3201. render: (scope: any) => {
  3202. let optionRender = [];
  3203. let _disabled = !ALLOW_EDIT_STATE.includes(scope.status);
  3204. scope.enum.map(item => {
  3205. optionRender.push(<el-option label={item.label} value={item.value} />);
  3206. });
  3207. let slotprefix = {
  3208. prefix: () => {
  3209. return <>{scope.searchParam.moneyrate}</>;
  3210. }
  3211. };
  3212. return (
  3213. <el-select
  3214. v-model={scope.searchParam.if_moneyrate}
  3215. v-slots={slotprefix}
  3216. class="select-text-right"
  3217. disabled={_disabled}
  3218. onChange={val => wf_get_moneyrate_discount(val, scope.searchParam)}
  3219. >
  3220. {optionRender}
  3221. </el-select>
  3222. );
  3223. }
  3224. }
  3225. },
  3226. {
  3227. field: "packtype",
  3228. enum: state.packtypeOptions
  3229. },
  3230. {
  3231. field: "dannum_cost1",
  3232. render: (scope: any) => {
  3233. if (scope.row?.moneyrate > 1) {
  3234. return (
  3235. <div>
  3236. <span class="text-f-s" style="color: var(--lj-color-gray-7)">
  3237. $
  3238. </span>
  3239. {formatAmount3({ val: floatDiv(scope.row?.dannum_cost1 ?? 0, scope.row.moneyrate) })}
  3240. </div>
  3241. );
  3242. } else {
  3243. return formatAmount3({ val: scope.row?.dannum_cost1 ?? 0 });
  3244. }
  3245. }
  3246. },
  3247. {
  3248. field: "dannum_cost2",
  3249. render: (scope: any) => {
  3250. if (scope.row?.moneyrate > 1) {
  3251. return (
  3252. <div>
  3253. <span class="text-f-s" style="color: var(--lj-color-gray-7)">
  3254. $
  3255. </span>
  3256. {formatAmount3({ val: floatDiv(scope.row?.dannum_cost2 ?? 0, scope.row.moneyrate) })}
  3257. </div>
  3258. );
  3259. } else {
  3260. return formatAmount3({ val: scope.row?.dannum_cost2 ?? 0 });
  3261. }
  3262. }
  3263. },
  3264. {
  3265. field: "dannum_cost3",
  3266. render: (scope: any) => {
  3267. if (scope.row?.moneyrate > 1) {
  3268. return (
  3269. <div>
  3270. <span class="text-f-s" style="color: var(--lj-color-gray-7)">
  3271. $
  3272. </span>
  3273. {formatAmount3({ val: floatDiv(scope.row?.dannum_cost3 ?? 0, scope.row.moneyrate) })}
  3274. </div>
  3275. );
  3276. } else {
  3277. return formatAmount3({ val: scope.row?.dannum_cost3 ?? 0 });
  3278. }
  3279. }
  3280. },
  3281. {
  3282. field: "dannum_cost4",
  3283. render: (scope: any) => {
  3284. if (scope.row?.moneyrate > 1) {
  3285. return (
  3286. <div>
  3287. <span class="text-f-s" style="color: var(--lj-color-gray-7)">
  3288. $
  3289. </span>
  3290. {formatAmount3({ val: floatDiv(scope.row?.dannum_cost4 ?? 0, scope.row.moneyrate) })}
  3291. </div>
  3292. );
  3293. } else {
  3294. return formatAmount3({ val: scope.row?.dannum_cost4 ?? 0 });
  3295. }
  3296. }
  3297. },
  3298. {
  3299. field: "createby",
  3300. search: {
  3301. el: "input",
  3302. key: "arg_createby",
  3303. props: {
  3304. placeholder: "搜索登记人"
  3305. }
  3306. // order: 1
  3307. }
  3308. }
  3309. ];
  3310. const columnsMx: ColumnProps<any>[] = [
  3311. { title: "#", type: "seq", fixed: "left", width: 80 },
  3312. {
  3313. title: "计算成功?",
  3314. field: "if_success",
  3315. datatype: "checkbox",
  3316. limited: () => {
  3317. const { userInfo } = useUserStore();
  3318. return userInfo.usermode != 0;
  3319. },
  3320. render: (scope: any) => {
  3321. if (Number(scope.row.if_success)) {
  3322. return (
  3323. <>
  3324. <ElTag type="danger">异常</ElTag>
  3325. </>
  3326. );
  3327. } else {
  3328. return <></>;
  3329. }
  3330. }
  3331. },
  3332. {
  3333. title: "+",
  3334. field: "addmx",
  3335. width: 80,
  3336. render: (scope: any) => {
  3337. let _if_mtrl = Number(scope.row.if_mtrl);
  3338. if (_if_mtrl > 1) {
  3339. if (state.orderStatus) {
  3340. return <ElButton type="primary" plain circle icon={Plus} onClick={() => funcAddMtrlMx(scope)}></ElButton>;
  3341. } else {
  3342. return <>+</>;
  3343. }
  3344. } else {
  3345. return <></>;
  3346. }
  3347. }
  3348. },
  3349. {
  3350. title: "-",
  3351. field: "delmx",
  3352. width: 80,
  3353. render: (scope: any) => {
  3354. let _if_mtrl = Number(scope.row.if_mtrl);
  3355. if (_if_mtrl > 1) {
  3356. if (state.orderStatus) {
  3357. return (
  3358. <>
  3359. <ElPopconfirm
  3360. width="220"
  3361. icon={InfoFilled}
  3362. title={t("business.tips.mattress.delMx")}
  3363. confirm-button-text={t("common.delText")}
  3364. confirm-button-type="danger"
  3365. onConfirm={() => funcDelMtrlMx(scope)}
  3366. >
  3367. {{
  3368. reference: () => {
  3369. return <ElButton type="danger" plain circle icon={Minus} />;
  3370. }
  3371. }}
  3372. </ElPopconfirm>
  3373. </>
  3374. );
  3375. // return <ElButton type="danger" plain circle icon={Minus} onClick={() => funcDelMtrlMx(scope)}></ElButton>;
  3376. } else {
  3377. return <>-</>;
  3378. }
  3379. } else {
  3380. return <></>;
  3381. }
  3382. }
  3383. },
  3384. {
  3385. title: "位置",
  3386. field: "chastr"
  3387. },
  3388. {
  3389. title: "公式名",
  3390. field: "formulakind",
  3391. table: "u_mattress_formula",
  3392. align: "left",
  3393. isFilterEnum: true,
  3394. fieldNames: { value: "value", label: "label" },
  3395. // enum: async () => {
  3396. // let res = await CommonDynamicSelect({
  3397. // dsname: "_Mapper_formulakind",
  3398. // queryparams: {}
  3399. // });
  3400. // return { data: res.datatable };
  3401. // }
  3402. render: (scope: any) => {
  3403. const { column, row, status } = scope;
  3404. let itmName = state.formulaKindEnum.find(t => t.value == row.formulakind)?.label ?? "";
  3405. return <>{itmName}</>;
  3406. }
  3407. },
  3408. {
  3409. title: "按物料?",
  3410. field: "if_mtrl",
  3411. table: "u_mattress_formula",
  3412. enum: [
  3413. {
  3414. value: "0",
  3415. label: "无物料"
  3416. },
  3417. {
  3418. value: "1",
  3419. label: "单物料"
  3420. },
  3421. {
  3422. value: "2",
  3423. label: "多物料"
  3424. }
  3425. ]
  3426. },
  3427. {
  3428. title: "厚度cm",
  3429. field: "thickness",
  3430. datatype: "number",
  3431. editRender: {},
  3432. editColRender: (scope: any) => {
  3433. const { $table, column, row, status } = scope;
  3434. const _disabled = !(
  3435. (row.if_inputqty == 0 && [50, 51, 52, 53, 54, 104, 114, 11, 12, 13, 14, 32, 33].includes(row.formulakind)) ||
  3436. row.formulakind == 202 ||
  3437. row.formulakind == 7
  3438. );
  3439. return <el-input v-model={scope.row.thickness} disabled={_disabled}></el-input>;
  3440. }
  3441. },
  3442. {
  3443. title: "物料",
  3444. field: "mtrlname",
  3445. editRender: {},
  3446. editColRender: (scope: any) => {
  3447. const { $table, column, row, status } = scope;
  3448. let field = column.field;
  3449. let _label = column.title;
  3450. // if (column?.format) {
  3451. // _label = handleRowAccordingToProp(searchParam, field, column?.format);
  3452. // }
  3453. let _pricelistid = getPriceid();
  3454. let _mtrltypeItem: any = mtrltypeTabList.find(t => t.formulakinds.includes(Number(row.formulakind)));
  3455. !_mtrltypeItem && (_mtrltypeItem = { value: -1 });
  3456. let params = {
  3457. mtrltype: _mtrltypeItem.value,
  3458. pricelistid: _pricelistid
  3459. };
  3460. return (
  3461. <>
  3462. <MtrldefSelect
  3463. value={row.mtrlid}
  3464. {...params}
  3465. clearable
  3466. placeholder={_label}
  3467. onOpenModal={() => fModelChoseMtrl(row, params, rModelSetMtrl, _mtrltypeItem.label, $table)}
  3468. onSelect={val => rModelSetMtrl(row, val, $table)}
  3469. onClear={() => rModelClearMtrl(row, $table)}
  3470. >
  3471. {{
  3472. label: () => row.mtrlname
  3473. }}
  3474. </MtrldefSelect>
  3475. </>
  3476. );
  3477. }
  3478. },
  3479. {
  3480. title: "数量/长度",
  3481. field: "qty",
  3482. datatype: "number",
  3483. editRender: {},
  3484. editColRender: (scope: any) => {
  3485. const { $table, column, row, status } = scope;
  3486. // 面料(面、底、侧)的数量/长度,不能输入
  3487. let arr = [
  3488. {
  3489. // label: "裥面",
  3490. type: [0, 80, 40, 50, 60, 70, 9000]
  3491. },
  3492. {
  3493. // label: "裥底",
  3494. type: [1, 81, 41, 51, 61, 71, 9001]
  3495. },
  3496. {
  3497. // label: "裥大恻",
  3498. type: [2, 82, 42, 52, 62, 72, 9002]
  3499. }
  3500. // {
  3501. // // label: "裥小恻",
  3502. // type: [3, 83, 43, 53, 63, 73, 9003]
  3503. // // ref: "fabricMxTab11Ref"
  3504. // },
  3505. // {
  3506. // // label: "裥V恻",
  3507. // type: [4, 84, 44, 54, 64, 74, 9004]
  3508. // // ref: "fabricMxTab12Ref"
  3509. // }
  3510. ];
  3511. let _disabled = arr.some(t => t.type.includes(row.formulakind));
  3512. let _mtrlItem = {
  3513. mtrlid: row.mtrlid,
  3514. mtrlname: row.mtrlname,
  3515. extra_cost: row.extra_cost
  3516. };
  3517. return (
  3518. <el-input
  3519. v-model={scope.row.qty}
  3520. type="number"
  3521. disabled={row.mtrlid == 0 || _disabled}
  3522. onChange={val => autoLoadMtrlExtra({ ..._mtrlItem, qty: val })}
  3523. ></el-input>
  3524. );
  3525. }
  3526. },
  3527. {
  3528. title: "规格宽/CM",
  3529. field: "mattress_width",
  3530. visible: false
  3531. },
  3532. {
  3533. title: "规格长/CM",
  3534. field: "mattress_length",
  3535. visible: false
  3536. },
  3537. {
  3538. title: "物料单价",
  3539. field: "price",
  3540. datatype: "number",
  3541. limited: () => {
  3542. return userInfo.usermode != 0;
  3543. }
  3544. },
  3545. {
  3546. title: "单位",
  3547. field: "priceunit"
  3548. },
  3549. {
  3550. title: "收缩率",
  3551. field: "shrinkage",
  3552. datatype: "number",
  3553. limited: () => {
  3554. return userInfo.usermode != 0;
  3555. }
  3556. },
  3557. {
  3558. title: "克重",
  3559. field: "gram_weight",
  3560. datatype: "number",
  3561. limited: () => {
  3562. return userInfo.usermode != 0;
  3563. }
  3564. },
  3565. {
  3566. title: "幅宽",
  3567. field: "cloth_width",
  3568. datatype: "number",
  3569. limited: () => {
  3570. return userInfo.usermode != 0;
  3571. }
  3572. },
  3573. {
  3574. title: "固定厚度?",
  3575. field: "if_inputqty",
  3576. datatype: "checkbox",
  3577. limited: () => {
  3578. return userInfo.usermode != 0;
  3579. }
  3580. },
  3581. {
  3582. title: "按面积单价?",
  3583. field: "if_areaprice",
  3584. datatype: "checkbox",
  3585. limited: () => {
  3586. return userInfo.usermode != 0;
  3587. }
  3588. },
  3589. {
  3590. title: "成本金额",
  3591. field: "costamt",
  3592. datatype: "number",
  3593. limited: () => {
  3594. return userInfo.usermode != 0;
  3595. }
  3596. },
  3597. {
  3598. title: "标准\r\n成本金额",
  3599. field: "dannum2_rate",
  3600. datatype: "number",
  3601. limited: () => {
  3602. return userInfo.usermode != 0;
  3603. },
  3604. render: (scope: any) => {
  3605. if (scope.row.hasOwnProperty("dannum2_cost")) {
  3606. return formatCutNumber({ val: scope.row.dannum2_cost });
  3607. }
  3608. return formatCutNumber({ val: floatMul(scope.row.costamt, 1 + scope.row.dannum2_rate) });
  3609. }
  3610. },
  3611. {
  3612. title: "散单\r\n成本金额",
  3613. field: "dannum1_rate",
  3614. datatype: "number",
  3615. limited: () => {
  3616. return userInfo.usermode != 0;
  3617. },
  3618. render: (scope: any) => {
  3619. if (scope.row.hasOwnProperty("dannum1_cost")) {
  3620. return formatCutNumber({ val: scope.row.dannum1_cost });
  3621. }
  3622. return formatCutNumber({ val: floatMul(scope.row.costamt, 1 + scope.row.dannum1_rate) });
  3623. }
  3624. },
  3625. {
  3626. title: "大单\r\n成本金额",
  3627. field: "dannum3_rate",
  3628. datatype: "number",
  3629. limited: () => {
  3630. return userInfo.usermode != 0;
  3631. },
  3632. render: (scope: any) => {
  3633. if (scope.row.hasOwnProperty("dannum3_cost")) {
  3634. return formatCutNumber({ val: scope.row.dannum3_cost });
  3635. }
  3636. return formatCutNumber({ val: floatMul(scope.row.costamt, 1 + scope.row.dannum3_rate) });
  3637. }
  3638. },
  3639. {
  3640. title: "小单\r\n成本金额",
  3641. field: "dannum4_rate",
  3642. datatype: "number",
  3643. limited: () => {
  3644. return userInfo.usermode != 0;
  3645. },
  3646. render: (scope: any) => {
  3647. if (scope.row.hasOwnProperty("dannum4_cost")) {
  3648. return formatCutNumber({ val: scope.row.dannum4_cost });
  3649. }
  3650. return formatCutNumber({ val: floatMul(scope.row.costamt, 1 + scope.row.dannum4_rate) });
  3651. }
  3652. },
  3653. {
  3654. title: "金额文本公式",
  3655. field: "formula",
  3656. limited: () => {
  3657. return userInfo.usermode != 0;
  3658. }
  3659. },
  3660. {
  3661. title: "金额数字公式",
  3662. field: "replace_formula",
  3663. limited: () => {
  3664. return userInfo.usermode != 0;
  3665. }
  3666. },
  3667. {
  3668. title: "清单用量",
  3669. field: "useqty",
  3670. datatype: "number",
  3671. limited: () => {
  3672. return userInfo.usermode != 0;
  3673. }
  3674. },
  3675. {
  3676. title: "用量文本公式",
  3677. field: "useformula",
  3678. limited: () => {
  3679. return userInfo.usermode != 0;
  3680. }
  3681. },
  3682. {
  3683. title: "用量数字公式",
  3684. field: "replace_useformula",
  3685. limited: () => {
  3686. return userInfo.usermode != 0;
  3687. }
  3688. },
  3689. {
  3690. title: "工艺填写说明",
  3691. field: "gydscrp",
  3692. editRender: {
  3693. name: "input",
  3694. props: {
  3695. type: "textarea"
  3696. }
  3697. }
  3698. }
  3699. ];
  3700. // /**
  3701. // * @description 主表计算公式
  3702. // */
  3703. // const summaryData = ref<any>([
  3704. // {
  3705. // label: "总成本",
  3706. // field: "total_cost",
  3707. // formula:
  3708. // "if([折叠款] = 1, ([总材料成本]*[大小单]+[款式费用]+[边带费用]+[额外费用]+[制造费用]) * 2, [总材料成本]*[大小单]+[款式费用]+[边带费用]+[额外费用]+[制造费用])",
  3709. // power: () => {
  3710. // if (userInfo.empid != 0 && userInfo.usermode != 0) {
  3711. // return false;
  3712. // } else {
  3713. // return true;
  3714. // }
  3715. // }
  3716. // },
  3717. // {
  3718. // label: "不含税出厂价",
  3719. // field: "nottax_factory_cost",
  3720. // formula: "[总成本] * ([工厂利润率] + [利润率点数] + [布套点数] + [拆装点数] + [海绵点数]) * [管理费点]"
  3721. // },
  3722. // {
  3723. // label: "部门售价",
  3724. // field: "nottax_dept_cost",
  3725. // formula: "[dijia_cost] / (1 - ([佣金点数] - 1)) * [额外点数] + [fob]"
  3726. // },
  3727. // {
  3728. // label: "税金",
  3729. // field: "taxes",
  3730. // formula: "([部门售价] * ([税率] - 1)) + [佣金] * 0.05"
  3731. // },
  3732. // {
  3733. // label: "部门含税价",
  3734. // field: "dept_cost",
  3735. // formula: "([部门售价] + [佣金] * 0.06) * [税率] * if([fob] = 0, 1, [折扣率])"
  3736. // },
  3737. // {
  3738. // label: "外币价",
  3739. // field: "foreign_cost",
  3740. // formula: "if([汇率] <> 0, [部门含税价] / [汇率], 0)"
  3741. // },
  3742. // {
  3743. // label: "底价 ",
  3744. // field: "dijia_cost_cp",
  3745. // formula: "if(([dept_profitrate] + [dept_profitrate_rangli] / 100) <> 0, [dijia_cost] ,0 )"
  3746. // },
  3747. // {
  3748. // label: "佣金",
  3749. // field: "commission_cp",
  3750. // formula: "[dijia_cost] / (1 - ([佣金点数] - 1 )) - [dijia_cost]"
  3751. // },
  3752. // {
  3753. // label: "FOB",
  3754. // field: "fob",
  3755. // formula: "[fob]"
  3756. // }
  3757. // ]);
  3758. // /**
  3759. // * @description 主表公式字段照表
  3760. // */
  3761. // const fieldParams = ref<any>([
  3762. // {
  3763. // label: "总成本",
  3764. // field: "total_cost"
  3765. // },
  3766. // {
  3767. // label: "不含税出厂价",
  3768. // field: "nottax_factory_cost"
  3769. // },
  3770. // {
  3771. // label: "部门售价",
  3772. // field: "nottax_dept_cost"
  3773. // },
  3774. // {
  3775. // label: "税金",
  3776. // field: "taxes"
  3777. // },
  3778. // {
  3779. // label: "部门含税价",
  3780. // field: "dept_cost"
  3781. // },
  3782. // {
  3783. // label: "外币价",
  3784. // field: "foreign_cost"
  3785. // },
  3786. // {
  3787. // label: "总材料成本",
  3788. // field: "total_material_cost"
  3789. // },
  3790. // {
  3791. // label: "大小单",
  3792. // field: "dannum_rate"
  3793. // },
  3794. // {
  3795. // label: "款式费用",
  3796. // field: "hrcost"
  3797. // },
  3798. // {
  3799. // label: "边带费用",
  3800. // field: "biandaicost"
  3801. // },
  3802. // {
  3803. // label: "额外费用",
  3804. // field: "extras_cost"
  3805. // },
  3806. // {
  3807. // label: "制造费用",
  3808. // field: "zhizao_amt"
  3809. // },
  3810. // {
  3811. // label: "折叠款",
  3812. // field: "if_zhedie_type"
  3813. // },
  3814. // {
  3815. // label: "管理费点",
  3816. // field: "guanli_rate"
  3817. // },
  3818. // {
  3819. // label: "工厂利润率",
  3820. // field: "profitrate"
  3821. // },
  3822. // {
  3823. // label: "利润率点数",
  3824. // field: "profitrate_point"
  3825. // },
  3826. // {
  3827. // label: "布套点数",
  3828. // field: "butao_point"
  3829. // },
  3830. // {
  3831. // label: "拆装点数",
  3832. // field: "chaizhuang_point"
  3833. // },
  3834. // {
  3835. // label: "海绵点数",
  3836. // field: "haimian_point"
  3837. // },
  3838. // {
  3839. // label: "部门利润率",
  3840. // field: "dept_profitrate"
  3841. // },
  3842. // {
  3843. // label: "部门让利点",
  3844. // field: "dept_profitrate_rangli"
  3845. // },
  3846. // {
  3847. // label: "额外点数",
  3848. // field: "other_rate"
  3849. // },
  3850. // {
  3851. // label: "佣金点数",
  3852. // field: "commission"
  3853. // },
  3854. // {
  3855. // label: "税率",
  3856. // field: "taxrate"
  3857. // },
  3858. // {
  3859. // label: "折扣率",
  3860. // field: "discount"
  3861. // },
  3862. // {
  3863. // label: "汇率",
  3864. // field: "moneyrate"
  3865. // },
  3866. // {
  3867. // label: "底价",
  3868. // field: "dijia_cost"
  3869. // }
  3870. // ]);
  3871. // /**
  3872. // * @description 明细公式字段照表
  3873. // */
  3874. // const fieldMxParams = ref<any>([
  3875. // {
  3876. // label: "名称前2位",
  3877. // field: "ls_temp_left_2"
  3878. // },
  3879. // {
  3880. // label: "规格宽",
  3881. // field: "ls_mattress_width"
  3882. // },
  3883. // {
  3884. // label: "规格长",
  3885. // field: "ls_mattress_length"
  3886. // },
  3887. // {
  3888. // label: "规格高",
  3889. // field: "ls_mattress_height"
  3890. // },
  3891. // {
  3892. // label: "压包数量",
  3893. // field: "ls_packqty"
  3894. // },
  3895. // {
  3896. // label: "卷包直径",
  3897. // field: "ls_diameter"
  3898. // },
  3899. // {
  3900. // label: "顶布裥棉外布套做法",
  3901. // field: "ls_if_db_wbutao_way"
  3902. // },
  3903. // {
  3904. // label: "面料外布套做法",
  3905. // field: "ls_if_m_wbutao_way"
  3906. // },
  3907. // {
  3908. // label: "内布套上覆",
  3909. // field: "ls_s_cover_qty"
  3910. // },
  3911. // {
  3912. // label: "内布套侧覆",
  3913. // field: "ls_z_cover_qty"
  3914. // },
  3915. // {
  3916. // label: "内布套下覆",
  3917. // field: "ls_x_cover_qty"
  3918. // },
  3919. // {
  3920. // label: "面料上覆",
  3921. // field: "ls_s_m_cover_qty"
  3922. // },
  3923. // {
  3924. // label: "面料侧覆",
  3925. // field: "ls_z_m_cover_qty"
  3926. // },
  3927. // {
  3928. // label: "面料下覆",
  3929. // field: "ls_x_m_cover_qty"
  3930. // },
  3931. // {
  3932. // label: "面拆",
  3933. // field: "ls_if_m_chai"
  3934. // },
  3935. // {
  3936. // label: "中拆",
  3937. // field: "ls_if_z_chai"
  3938. // },
  3939. // {
  3940. // label: "底拆",
  3941. // field: "ls_if_d_chai"
  3942. // },
  3943. // {
  3944. // label: "物料单价",
  3945. // field: "ls_price"
  3946. // },
  3947. // {
  3948. // label: "物料克重",
  3949. // field: "ls_gram_weight"
  3950. // },
  3951. // {
  3952. // label: "幅宽",
  3953. // field: "ls_cloth_width"
  3954. // },
  3955. // {
  3956. // label: "数量",
  3957. // field: "ls_qty"
  3958. // },
  3959. // {
  3960. // label: "物料厚度",
  3961. // field: "ls_if_inputqty"
  3962. // },
  3963. // {
  3964. // label: "固定厚度",
  3965. // field: "ls_if_inputqty"
  3966. // },
  3967. // {
  3968. // label: "厚度",
  3969. // field: "ls_thickness"
  3970. // },
  3971. // {
  3972. // label: "按面积单价",
  3973. // field: "ls_if_areaprice"
  3974. // },
  3975. // {
  3976. // label: "物料名称",
  3977. // field: "ls_mtrlname"
  3978. // },
  3979. // {
  3980. // label: "木托方式",
  3981. // field: "ls_woodpallettype",
  3982. // enum: [
  3983. // { label: " '普通木托' ", value: "0" },
  3984. // { label: " '夹板木托' ", value: "1" },
  3985. // { label: " '铁管木托' ", value: "2" }
  3986. // ]
  3987. // }
  3988. // ]);
  3989. // /**
  3990. // * @description 明细表计算公式
  3991. // */
  3992. // const summaryMxData = ref<any>([
  3993. // {
  3994. // label: "计算成本金额",
  3995. // field: "costamt",
  3996. // formula: ""
  3997. // },
  3998. // {
  3999. // label: "计算清单用量",
  4000. // field: "useqty",
  4001. // formula: ""
  4002. // }
  4003. // ]);
  4004. const funcMergeColumn = (columns: any, target: any, extra?: any) => {
  4005. let col = columns.map(t => {
  4006. let itm = target.find(item => t.field === item.field);
  4007. if (itm) {
  4008. t = defaultsDeep(itm, t);
  4009. }
  4010. return t;
  4011. });
  4012. if (extra) {
  4013. col = col.concat(extra);
  4014. }
  4015. return col;
  4016. };
  4017. // const cushionsEdit = reactive<any>({
  4018. // name: "VxeSelect",
  4019. // options: state.formulaKindDcEnum,
  4020. // optionProps: {
  4021. // label: "label",
  4022. // value: "value"
  4023. // }
  4024. // });
  4025. const bednetCoumns: ColumnProps<any>[] = [
  4026. {
  4027. title: "位置",
  4028. field: "chastr",
  4029. visible: false
  4030. },
  4031. {
  4032. title: "床网",
  4033. field: "mtrlname",
  4034. editRender: {},
  4035. width: 250,
  4036. editColRender: (scope: any) => {
  4037. const { column, row, status, $table } = scope;
  4038. let _label = column.title;
  4039. let _deptid = state.LjDetailRef._mainData.deptid;
  4040. let params = {
  4041. deptid: _deptid,
  4042. mattress_width: state.LjDetailRef._mainData.mattress_width,
  4043. mattress_length: state.LjDetailRef._mainData.mattress_length
  4044. };
  4045. return (
  4046. <BednetSelect
  4047. value={row.mtrlid}
  4048. {...params}
  4049. clearable
  4050. placeholder={_label}
  4051. onOpenModal={() => fModelChoseBednet(row, params, $table)}
  4052. onSelect={(val: any) => rModelSetBednet(row, val, $table)}
  4053. onClear={() => rModelClearBednet(row, $table)}
  4054. >
  4055. {{
  4056. label: () => row.mtrlname
  4057. }}
  4058. </BednetSelect>
  4059. );
  4060. }
  4061. },
  4062. {
  4063. title: "+",
  4064. field: "addmx",
  4065. width: 80,
  4066. render: (scope: any) => {
  4067. let _if_mtrl = Number(scope.row.if_mtrl);
  4068. if (_if_mtrl > 1) {
  4069. if (state.orderStatus) {
  4070. return (
  4071. <ElPopconfirm
  4072. width="220"
  4073. icon={InfoFilled}
  4074. title={t("business.tips.mattress.addMx")}
  4075. confirm-button-text={t("common.addText")}
  4076. onConfirm={() => funcAddMtrlMx(scope, () => wf_rtr_cwdc(scope.row, null, "add"))}
  4077. >
  4078. {{
  4079. reference: () => {
  4080. return <ElButton type="primary" plain circle icon={Plus}></ElButton>;
  4081. }
  4082. }}
  4083. </ElPopconfirm>
  4084. );
  4085. } else {
  4086. return "+";
  4087. }
  4088. } else {
  4089. return "";
  4090. }
  4091. }
  4092. },
  4093. {
  4094. title: "-",
  4095. field: "delmx",
  4096. width: 80,
  4097. render: (scope: any) => {
  4098. let _if_mtrl = Number(scope.row.if_mtrl);
  4099. if (_if_mtrl > 1) {
  4100. if (state.orderStatus) {
  4101. return (
  4102. <ElPopconfirm
  4103. width="220"
  4104. icon={InfoFilled}
  4105. title={t("business.tips.mattress.delMx")}
  4106. confirm-button-text={t("common.delText")}
  4107. confirm-button-type="danger"
  4108. onConfirm={() => funcDelBednet(scope, () => wf_rtr_cwdc(scope.row, null, "del"))}
  4109. >
  4110. {{
  4111. reference: () => {
  4112. return <ElButton type="danger" plain circle icon={Minus} />;
  4113. }
  4114. }}
  4115. </ElPopconfirm>
  4116. );
  4117. } else {
  4118. return "-";
  4119. }
  4120. } else {
  4121. return "";
  4122. }
  4123. }
  4124. }
  4125. ];
  4126. const bednetExtraColumns: ColumnProps<any>[] = [
  4127. {
  4128. title: "弹簧排列个数-宽",
  4129. field: "spring_qty_width",
  4130. datatype: "integer"
  4131. // editRender: {
  4132. // name: "$input"
  4133. // // props: {
  4134. // // type: "number"
  4135. // // }
  4136. // }
  4137. },
  4138. {
  4139. title: "弹簧排列个数-长",
  4140. field: "spring_qty_length",
  4141. datatype: "integer"
  4142. // editRender: {
  4143. // name: "$input"
  4144. // // props: {
  4145. // // type: "number"
  4146. // // }
  4147. // }
  4148. }
  4149. ];
  4150. const cushionsColumns: ColumnProps<any>[] = [
  4151. {
  4152. title: "位置",
  4153. field: "chastr",
  4154. editRender: {},
  4155. editColRender: (scope: any) => {
  4156. return (
  4157. <el-select v-model={scope.row.chastr}>
  4158. {{
  4159. default: () => {
  4160. let rs = [];
  4161. if (state.diancengAreaEnum.length) {
  4162. state.diancengAreaEnum.map((t: any) => {
  4163. rs.push(<el-option label={t.label} value={t.value} />);
  4164. });
  4165. }
  4166. return rs;
  4167. }
  4168. }}
  4169. </el-select>
  4170. );
  4171. }
  4172. },
  4173. {
  4174. title: "公式名",
  4175. field: "formulakind",
  4176. table: "u_mattress_formula",
  4177. align: "left",
  4178. isFilterEnum: true,
  4179. fieldNames: { value: "value", label: "label" },
  4180. // editRender: {
  4181. // name: "VxeSelect",
  4182. // options: state.formulaKindDcEnum
  4183. // }
  4184. // editRender: cushionsEdit
  4185. // render: (scope: any) => {
  4186. // const { column, row, status } = scope;
  4187. // let itmName = state.formulaKindEnum.find(t => t.value == row.formulakind)?.label ?? "";
  4188. // return <>{itmName}</>;
  4189. // },
  4190. editRender: {},
  4191. editColRender: (scope: any) => {
  4192. let lastVal = scope.row.formulakind;
  4193. return (
  4194. <el-select v-model={scope.row.formulakind} onChange={val => cushionsFormulaKindChange(val, lastVal, scope)}>
  4195. {{
  4196. default: () => {
  4197. let rs = [];
  4198. if (state.formulaKindDcEnum.length) {
  4199. state.formulaKindDcEnum.map((t: any) => {
  4200. rs.push(<el-option label={t.label} value={t.value} />);
  4201. });
  4202. }
  4203. return rs;
  4204. }
  4205. }}
  4206. </el-select>
  4207. );
  4208. }
  4209. },
  4210. {
  4211. title: "+",
  4212. field: "addmx",
  4213. visible: false
  4214. },
  4215. {
  4216. title: "-",
  4217. field: "delmx",
  4218. visible: false
  4219. },
  4220. {
  4221. title: "按物料?",
  4222. field: "if_mtrl",
  4223. visible: false
  4224. },
  4225. {
  4226. title: "物料",
  4227. field: "mtrlname",
  4228. editRender: {},
  4229. editColRender: (scope: any) => {
  4230. const { column, row, status, $table } = scope;
  4231. let _label = column.title;
  4232. let _pricelistid = getPriceid();
  4233. let _mtrltypeItem: any = mtrltypeTabList_cushions.find(t => t.formulakinds.includes(Number(row.formulakind)));
  4234. if (!_mtrltypeItem) {
  4235. // ElMessage.error("不是垫层类型行,不能选物料");
  4236. // return <></>;
  4237. }
  4238. console.log("垫层 row.formulakind :>> ", row.formulakind, _mtrltypeItem);
  4239. let params = {
  4240. mtrltype: _mtrltypeItem?.value,
  4241. pricelistid: _pricelistid
  4242. };
  4243. return (
  4244. <>
  4245. <MtrldefSelect
  4246. value={row.mtrlid}
  4247. {...params}
  4248. disabled={!_mtrltypeItem}
  4249. clearable
  4250. placeholder={_label}
  4251. onOpenModal={() => fModelChoseMtrl(row, params, rModelSetMtrl, _mtrltypeItem?.label, $table)}
  4252. onSelect={(val: any) => rModelSetMtrl(row, val, $table)}
  4253. onClear={() => rModelClearMtrl(row, $table)}
  4254. >
  4255. {{
  4256. label: () => row.mtrlname
  4257. }}
  4258. </MtrldefSelect>
  4259. </>
  4260. );
  4261. }
  4262. },
  4263. {
  4264. title: "规格宽/CM",
  4265. field: "mattress_width",
  4266. datatype: "number",
  4267. editRender: {
  4268. name: "input"
  4269. },
  4270. visible: true
  4271. },
  4272. {
  4273. title: "规格长/CM",
  4274. field: "mattress_length",
  4275. datatype: "number",
  4276. editRender: {
  4277. name: "input"
  4278. },
  4279. visible: true
  4280. },
  4281. {
  4282. title: "厚度cm",
  4283. field: "thickness",
  4284. datatype: "number",
  4285. editRender: {},
  4286. editColRender: (scope: any) => {
  4287. const { $table, column, row, status } = scope;
  4288. const _disabled = !(
  4289. (row.if_inputqty == 0 && [50, 51, 52, 53, 54, 104, 114, 11, 14, 32, 33].includes(row.formulakind)) ||
  4290. row.formulakind == 7 ||
  4291. row.formulakind == 999
  4292. );
  4293. return <el-input v-model={scope.row.thickness} type="number" disabled={_disabled}></el-input>;
  4294. }
  4295. }
  4296. ];
  4297. const accessoriesColumns: ColumnProps<any>[] = [
  4298. {
  4299. title: "位置",
  4300. field: "chastr",
  4301. visible: false
  4302. },
  4303. {
  4304. title: "物料",
  4305. field: "mtrlname",
  4306. editRender: {},
  4307. editColRender: (scope: any) => {
  4308. const { column, row, status, $table } = scope;
  4309. let field = column.field;
  4310. let _label = column.title;
  4311. // if (column?.format) {
  4312. // _label = handleRowAccordingToProp(searchParam, field, column?.format);
  4313. // }
  4314. let _pricelistid = getPriceid();
  4315. let _mtrltypeItem: any = mtrltypeTabList_accessories.find(t => t.formulakinds.includes(Number(row.formulakind)));
  4316. if (!_mtrltypeItem) {
  4317. ElMessage.error("不是辅料类型行,不能选物料");
  4318. return "";
  4319. }
  4320. let params = {
  4321. mtrltype: _mtrltypeItem.value,
  4322. pricelistid: _pricelistid
  4323. };
  4324. return (
  4325. <>
  4326. <MtrldefSelect
  4327. value={row.mtrlid}
  4328. {...params}
  4329. clearable
  4330. placeholder={_label}
  4331. onOpenModal={() => fModelChoseMtrl(row, params, rModelSetMtrl, _mtrltypeItem.label, $table)}
  4332. onSelect={(val: any) => rModelSetMtrl(row, val, $table)}
  4333. onClear={() => rModelClearMtrl(row, $table)}
  4334. >
  4335. {{
  4336. label: () => row.mtrlname
  4337. }}
  4338. </MtrldefSelect>
  4339. </>
  4340. );
  4341. }
  4342. },
  4343. {
  4344. title: "厚度cm",
  4345. field: "thickness",
  4346. limited: true
  4347. }
  4348. ];
  4349. const packagColumns: ColumnProps<any>[] = [
  4350. {
  4351. title: "位置",
  4352. field: "chastr",
  4353. visible: false
  4354. },
  4355. {
  4356. title: "物料",
  4357. field: "mtrlname",
  4358. editRender: {},
  4359. editColRender: (scope: any) => {
  4360. const { column, row, status, $table } = scope;
  4361. let field = column.field;
  4362. let _label = column.title;
  4363. // if (column?.format) {
  4364. // _label = handleRowAccordingToProp(searchParam, field, column?.format);
  4365. // }
  4366. let _pricelistid = getPriceid();
  4367. let _mtrltypeItem: any = mtrltypeTabList_packag.find(t => t.formulakinds.includes(Number(row.formulakind)));
  4368. !_mtrltypeItem && (_mtrltypeItem = { value: -1 });
  4369. let params = {
  4370. mtrltype: _mtrltypeItem.value,
  4371. pricelistid: _pricelistid
  4372. };
  4373. return (
  4374. <>
  4375. <MtrldefSelect
  4376. value={row.mtrlid}
  4377. {...params}
  4378. clearable
  4379. placeholder={_label}
  4380. onOpenModal={() => fModelChoseMtrl(row, params, rModelSetMtrl, _mtrltypeItem.label, $table)}
  4381. onSelect={(val: any) => rModelSetMtrl(row, val, $table)}
  4382. onClear={() => rModelClearMtrl(row, $table)}
  4383. >
  4384. {{
  4385. label: () => row.mtrlname
  4386. }}
  4387. </MtrldefSelect>
  4388. </>
  4389. );
  4390. }
  4391. },
  4392. {
  4393. title: "厚度cm",
  4394. field: "thickness",
  4395. limited: true
  4396. }
  4397. ];
  4398. const columnsMxInnerClothLayer: ColumnProps<any>[] = [
  4399. {
  4400. title: "计算成功?",
  4401. field: "if_success",
  4402. datatype: "checkbox",
  4403. limited: () => {
  4404. const { userInfo } = useUserStore();
  4405. return userInfo.usermode != 0;
  4406. },
  4407. render: (scope: any) => {
  4408. if (Number(scope.row.if_success)) {
  4409. return (
  4410. <>
  4411. <ElTag type="danger">异常</ElTag>
  4412. </>
  4413. );
  4414. } else {
  4415. return <></>;
  4416. }
  4417. }
  4418. },
  4419. {
  4420. title: "位置",
  4421. field: "chastr"
  4422. // treeNode: true
  4423. },
  4424. {
  4425. title: "+",
  4426. field: "addmx",
  4427. width: 80,
  4428. render: (scope: any) => {
  4429. let _if_mtrl = Number(scope.row.if_mtrl);
  4430. if (_if_mtrl > 1) {
  4431. if (state.orderStatus) {
  4432. return (
  4433. <>
  4434. <ElPopconfirm
  4435. width="220"
  4436. icon={InfoFilled}
  4437. title={t("business.tips.mattress.addMx")}
  4438. confirm-button-text={t("common.addText")}
  4439. onConfirm={() => funcAddMtrlMx(scope)}
  4440. >
  4441. {{
  4442. reference: () => {
  4443. return <ElButton type="primary" plain circle icon={Plus}></ElButton>;
  4444. }
  4445. }}
  4446. </ElPopconfirm>
  4447. </>
  4448. );
  4449. // return <ElButton type="primary" plain circle icon={Plus} onClick={() => funcAddMtrlMx(scope)}></ElButton>;
  4450. } else {
  4451. return <>+</>;
  4452. }
  4453. } else {
  4454. return <></>;
  4455. }
  4456. }
  4457. },
  4458. {
  4459. title: "-",
  4460. field: "delmx",
  4461. width: 80,
  4462. render: (scope: any) => {
  4463. let _if_mtrl = Number(scope.row.if_mtrl);
  4464. if (_if_mtrl > 1) {
  4465. if (state.orderStatus) {
  4466. return (
  4467. <>
  4468. <ElPopconfirm
  4469. width="220"
  4470. icon={InfoFilled}
  4471. title={t("business.tips.mattress.delMx")}
  4472. confirm-button-text={t("common.delText")}
  4473. confirm-button-type="danger"
  4474. onConfirm={() => funcDelMtrlMx(scope)}
  4475. >
  4476. {{
  4477. reference: () => {
  4478. return <ElButton type="danger" plain circle icon={Minus} />;
  4479. }
  4480. }}
  4481. </ElPopconfirm>
  4482. </>
  4483. );
  4484. // return <ElButton type="danger" plain circle icon={Minus} onClick={() => funcDelMtrlMx(scope)}></ElButton>;
  4485. } else {
  4486. return <>-</>;
  4487. }
  4488. } else {
  4489. return <></>;
  4490. }
  4491. }
  4492. },
  4493. {
  4494. title: "厚度cm",
  4495. field: "thickness",
  4496. datatype: "number",
  4497. editRender: {},
  4498. editColRender: (scope: any) => {
  4499. const { $table, column, row, status } = scope;
  4500. const _disabled = !(
  4501. (row.if_inputqty == 0 && [50, 51, 52, 53, 54, 104, 114, 11, 14, 32, 33].includes(row.formulakind)) ||
  4502. row.formulakind == 202 ||
  4503. row.formulakind == 203
  4504. );
  4505. return <el-input v-model={scope.row.thickness} type="number" disabled={_disabled}></el-input>;
  4506. }
  4507. },
  4508. {
  4509. title: "物料",
  4510. field: "mtrlname",
  4511. editRender: {},
  4512. editColRender: (scope: any) => {
  4513. const { column, row, status, $table } = scope;
  4514. let _label = column.title;
  4515. let _pricelistid = getPriceid();
  4516. let _mtrltypeItem: any = mtrltypeTabList_inner.find(t => t.formulakinds.includes(Number(row.formulakind)));
  4517. !_mtrltypeItem && (_mtrltypeItem = { value: -1 });
  4518. let params = {
  4519. mtrltype: _mtrltypeItem.value,
  4520. pricelistid: _pricelistid
  4521. };
  4522. return (
  4523. <>
  4524. <MtrldefSelect
  4525. value={row.mtrlid}
  4526. {...params}
  4527. clearable
  4528. placeholder={_label}
  4529. onOpenModal={() => fModelChoseMtrl(row, params, rModelSetMtrlInner, _mtrltypeItem.label, $table)}
  4530. onSelect={(val: any) => rModelSetMtrlInner(row, val, $table)}
  4531. onClear={() => rModelClearMtrl(row, $table)}
  4532. >
  4533. {{
  4534. label: () => row.mtrlname
  4535. }}
  4536. </MtrldefSelect>
  4537. </>
  4538. );
  4539. }
  4540. },
  4541. {
  4542. title: "数量/长度",
  4543. field: "qty",
  4544. datatype: "number",
  4545. editRender: {},
  4546. editColRender: (scope: any) => {
  4547. const { $table, column, row, status } = scope;
  4548. return <el-input v-model={scope.row.qty} type="number" disabled={row.mtrlid == 0}></el-input>;
  4549. }
  4550. },
  4551. {
  4552. title: "规格宽/CM",
  4553. field: "mattress_width",
  4554. datatype: "number",
  4555. editRender: {
  4556. name: "input"
  4557. }
  4558. },
  4559. {
  4560. title: "规格长/CM",
  4561. field: "mattress_length",
  4562. datatype: "number",
  4563. editRender: {
  4564. name: "input"
  4565. }
  4566. },
  4567. {
  4568. title: "标准\r\n成本金额",
  4569. field: "dannum2_rate",
  4570. datatype: "number",
  4571. limited: () => {
  4572. return userInfo.usermode != 0;
  4573. },
  4574. render: (scope: any) => {
  4575. return formatCutNumber({ val: floatMul(scope.row.costamt, 1 + scope.row.dannum2_rate) });
  4576. }
  4577. },
  4578. {
  4579. title: "散单\r\n成本金额",
  4580. field: "dannum1_rate",
  4581. datatype: "number",
  4582. limited: () => {
  4583. return userInfo.usermode != 0;
  4584. },
  4585. render: (scope: any) => {
  4586. return formatCutNumber({ val: floatMul(scope.row.costamt, 1 + scope.row.dannum1_rate) });
  4587. }
  4588. },
  4589. {
  4590. title: "大单\r\n成本金额",
  4591. field: "dannum3_rate",
  4592. datatype: "number",
  4593. limited: () => {
  4594. return userInfo.usermode != 0;
  4595. },
  4596. render: (scope: any) => {
  4597. return formatCutNumber({ val: floatMul(scope.row.costamt, 1 + scope.row.dannum3_rate) });
  4598. }
  4599. },
  4600. {
  4601. title: "小单\r\n成本金额",
  4602. field: "dannum4_rate",
  4603. datatype: "number",
  4604. limited: () => {
  4605. return userInfo.usermode != 0;
  4606. },
  4607. render: (scope: any) => {
  4608. return formatCutNumber({ val: floatMul(scope.row.costamt, 1 + scope.row.dannum4_rate) });
  4609. }
  4610. }
  4611. ];
  4612. const columnsMx_processes: any = [
  4613. { type: "checkbox", width: 50, fixed: "left" },
  4614. {
  4615. title: "+",
  4616. field: "addmx",
  4617. width: 80,
  4618. render: (scope: any) => {
  4619. let oItem = state.specialProcessesMxData.find(o => o.extraid == scope.row.extraid);
  4620. if (!oItem) {
  4621. oItem = {
  4622. inputtype: 1
  4623. };
  4624. }
  4625. if (state.orderStatus) {
  4626. return (
  4627. <ElButton
  4628. type="primary"
  4629. plain
  4630. circle
  4631. icon={Plus}
  4632. disabled={oItem.inputtype == 2}
  4633. onClick={() => funcAddMtrlMx(scope)}
  4634. ></ElButton>
  4635. );
  4636. } else {
  4637. return <>+</>;
  4638. }
  4639. }
  4640. },
  4641. {
  4642. title: "-",
  4643. field: "delmx",
  4644. width: 80,
  4645. render: (scope: any) => {
  4646. let oItem = state.specialProcessesMxData.find(o => o.extraid == scope.row.extraid);
  4647. if (!oItem) {
  4648. oItem = {
  4649. inputtype: 1
  4650. };
  4651. }
  4652. if (state.orderStatus) {
  4653. return (
  4654. <>
  4655. <ElPopconfirm
  4656. width="220"
  4657. icon={InfoFilled}
  4658. title={t("business.tips.mattress.delMx")}
  4659. confirm-button-text={t("common.delText")}
  4660. confirm-button-type="danger"
  4661. onConfirm={() => funcDelMtrlMx(scope)}
  4662. >
  4663. {{
  4664. reference: () => {
  4665. return <ElButton type="danger" plain circle disabled={oItem.inputtype == 2} icon={Minus} />;
  4666. }
  4667. }}
  4668. </ElPopconfirm>
  4669. </>
  4670. );
  4671. // return <ElButton type="danger" plain circle icon={Minus} onClick={() => funcDelMtrlMx(scope)}></ElButton>;
  4672. } else {
  4673. return <>-</>;
  4674. }
  4675. }
  4676. },
  4677. {
  4678. title: "项目类型",
  4679. field: "extraid",
  4680. // editRender: {
  4681. // name: "select"
  4682. // }
  4683. editRender: {},
  4684. editColRender: (scope: any) => {
  4685. return (
  4686. <el-select
  4687. v-model={scope.row.extraid}
  4688. disabled={scope.row.inputtype == 2}
  4689. onChange={val => extratypeOnChange(val, scope)}
  4690. >
  4691. {{
  4692. default: () => {
  4693. let rs = [];
  4694. if (state.specialProcessesEnum.length) {
  4695. state.specialProcessesEnum.map((t: any) => {
  4696. rs.push(<el-option label={t.typename} value={t.extraid} disabled={t.inputtype == 2} />);
  4697. });
  4698. }
  4699. return rs;
  4700. }
  4701. }}
  4702. </el-select>
  4703. );
  4704. },
  4705. render: scope => {
  4706. let item = state.specialProcessesEnum.find(t => t.extraid == scope.row.extraid);
  4707. if (item) {
  4708. return item.typename;
  4709. } else {
  4710. return "";
  4711. }
  4712. }
  4713. },
  4714. {
  4715. title: "项目名称",
  4716. field: "extraname",
  4717. editRender: {},
  4718. editColRender: (scope: any) => {
  4719. let _disabled = scope.row.inputtype == 2;
  4720. if (scope.row.inputtype == 0) {
  4721. return (
  4722. <el-select
  4723. v-model={scope.row.extramxid}
  4724. disabled={_disabled}
  4725. onChange={val => additionalOnChange(val, scope, state.specialProcessesMxData)}
  4726. >
  4727. {{
  4728. default: () => {
  4729. let rs = [];
  4730. if (state.specialProcessesMxData.length) {
  4731. state.specialProcessesMxData
  4732. .filter(t => t.extraid == scope.row.extraid)
  4733. .map((t: any) => {
  4734. rs.push(<el-option label={t.extramxname} value={t.extramxid} />);
  4735. });
  4736. }
  4737. return rs;
  4738. }
  4739. }}
  4740. </el-select>
  4741. );
  4742. } else {
  4743. return (
  4744. <el-autocomplete
  4745. v-model={scope.row.extraname}
  4746. disabled={_disabled}
  4747. value-key="extramxname"
  4748. fetch-suggestions={(queryString: string, callback: any) =>
  4749. querySearch_processes(queryString, callback, scope, state.specialProcessesMxData)
  4750. }
  4751. onSelect={itm => additionalOnSelect(itm, scope)}
  4752. clearable
  4753. />
  4754. );
  4755. }
  4756. }
  4757. },
  4758. {
  4759. title: "金额",
  4760. field: "price",
  4761. datatype: "number",
  4762. editRender: {},
  4763. editColRender: (scope: any) => {
  4764. const { $table, column, row, status } = scope;
  4765. return <el-input v-model={scope.row.price} type="number" disabled={row.inputtype == 2}></el-input>;
  4766. }
  4767. },
  4768. {
  4769. title: "数量",
  4770. field: "qty",
  4771. datatype: "number",
  4772. editRender: {},
  4773. editColRender: (scope: any) => {
  4774. const { $table, column, row, status } = scope;
  4775. return <el-input v-model={scope.row.qty} type="number" disabled={row.inputtype == 2}></el-input>;
  4776. }
  4777. },
  4778. {
  4779. title: "备注",
  4780. field: "dscrp",
  4781. editRender: {
  4782. name: "$input"
  4783. }
  4784. }
  4785. ];
  4786. const columnsMx_additional: any = [
  4787. { type: "checkbox", width: 50, fixed: "left" },
  4788. {
  4789. title: "+",
  4790. field: "addmx",
  4791. width: 80,
  4792. render: (scope: any) => {
  4793. if (state.orderStatus) {
  4794. return <ElButton type="primary" plain circle icon={Plus} onClick={() => funcAddMtrlMx(scope)}></ElButton>;
  4795. } else {
  4796. return <>+</>;
  4797. }
  4798. }
  4799. },
  4800. {
  4801. title: "-",
  4802. field: "delmx",
  4803. width: 80,
  4804. render: (scope: any) => {
  4805. let oItem = state.additionalCostsMxData.find(o => o.extraid == scope.row.extraid);
  4806. if (!oItem) {
  4807. oItem = {
  4808. inputtype: 1
  4809. };
  4810. }
  4811. if (state.orderStatus) {
  4812. return (
  4813. <>
  4814. <ElPopconfirm
  4815. width="220"
  4816. icon={InfoFilled}
  4817. title={t("business.tips.mattress.delMx")}
  4818. confirm-button-text={t("common.delText")}
  4819. confirm-button-type="danger"
  4820. onConfirm={() => funcDelMtrlMx(scope)}
  4821. >
  4822. {{
  4823. reference: () => {
  4824. return <ElButton type="danger" plain circle disabled={oItem.inputtype == 2} icon={Minus} />;
  4825. }
  4826. }}
  4827. </ElPopconfirm>
  4828. </>
  4829. );
  4830. // return <ElButton type="danger" plain circle icon={Minus} onClick={() => funcDelMtrlMx(scope)}></ElButton>;
  4831. } else {
  4832. return <>-</>;
  4833. }
  4834. }
  4835. },
  4836. {
  4837. title: "项目类型",
  4838. field: "extraid",
  4839. editRender: {},
  4840. editColRender: (scope: any) => {
  4841. return (
  4842. <el-select
  4843. v-model={scope.row.extraid}
  4844. disabled={scope.row.inputtype == 2}
  4845. onChange={val => extratypeOnChange(val, scope)}
  4846. >
  4847. {{
  4848. default: () => {
  4849. let rs = [];
  4850. if (state.additionalCostsEnum.length) {
  4851. state.additionalCostsEnum.map((t: any) => {
  4852. rs.push(<el-option label={t.typename} value={t.extraid} disabled={t.inputtype == 2} />);
  4853. });
  4854. }
  4855. return rs;
  4856. }
  4857. }}
  4858. </el-select>
  4859. );
  4860. },
  4861. render: scope => {
  4862. let item = state.additionalCostsEnum.find(t => t.extraid == scope.row.extraid);
  4863. if (item) {
  4864. return item.typename;
  4865. } else {
  4866. return "";
  4867. }
  4868. }
  4869. },
  4870. {
  4871. title: "项目名称",
  4872. field: "extraname",
  4873. editRender: {},
  4874. editColRender: (scope: any) => {
  4875. console.log("editColRender 1111 scope :>> ", scope);
  4876. let _disabled = scope.row.inputtype == 2;
  4877. if (scope.row.inputtype == 0) {
  4878. return (
  4879. <el-select
  4880. v-model={scope.row.extramxid}
  4881. disabled={_disabled}
  4882. onChange={val => additionalOnChange(val, scope, state.additionalCostsMxData)}
  4883. >
  4884. {{
  4885. default: () => {
  4886. let rs = [];
  4887. if (state.additionalCostsMxData.length) {
  4888. state.additionalCostsMxData
  4889. .filter(t => t.extraid == scope.row.extraid)
  4890. .map((t: any) => {
  4891. rs.push(<el-option label={t.extramxname} value={t.extramxid} />);
  4892. });
  4893. }
  4894. return rs;
  4895. }
  4896. }}
  4897. </el-select>
  4898. );
  4899. } else {
  4900. return (
  4901. <el-autocomplete
  4902. v-model={scope.row.extraname}
  4903. disabled={_disabled}
  4904. value-key="extramxname"
  4905. fetch-suggestions={(queryString: string, callback: any) =>
  4906. querySearch_additional(queryString, callback, scope, state.additionalCostsMxData)
  4907. }
  4908. onSelect={itm => additionalOnSelect(itm, scope)}
  4909. clearable
  4910. />
  4911. );
  4912. }
  4913. }
  4914. },
  4915. {
  4916. title: "金额",
  4917. field: "price",
  4918. datatype: "number",
  4919. editRender: {},
  4920. editColRender: (scope: any) => {
  4921. const { $table, column, row, status } = scope;
  4922. return <el-input v-model={scope.row.price} type="number" disabled={row.inputtype == 2}></el-input>;
  4923. }
  4924. },
  4925. {
  4926. title: "数量",
  4927. field: "qty",
  4928. datatype: "number",
  4929. editRender: {},
  4930. editColRender: (scope: any) => {
  4931. const { $table, column, row, status } = scope;
  4932. return <el-input v-model={scope.row.qty} type="number" disabled={row.inputtype == 2}></el-input>;
  4933. }
  4934. },
  4935. {
  4936. title: "备注",
  4937. field: "dscrp",
  4938. editRender: {
  4939. name: "$input"
  4940. }
  4941. }
  4942. ];
  4943. const extratypeOnChange = (value: any, scope: any) => {
  4944. const { row } = scope;
  4945. if (state.specialProcessesEnum.length) {
  4946. let item = state.specialProcessesEnum.find(t => t.extraid == value);
  4947. if (item) {
  4948. row.extramxid = 0;
  4949. row.inputtype = 0;
  4950. row.extraname = "";
  4951. row.price = 0;
  4952. row.qty = 0;
  4953. row.dscrp = "";
  4954. }
  4955. }
  4956. };
  4957. const additionalOnChange = (value: any, scope: any, enumdata: any) => {
  4958. const { row } = scope;
  4959. if (enumdata.length) {
  4960. let item = enumdata.find(t => t.extraid == row.extraid && t.extramxid == value);
  4961. if (item) {
  4962. additionalOnSelect(item, scope);
  4963. }
  4964. }
  4965. };
  4966. const additionalOnSelect = (item: Record<string, any>, scope: any) => {
  4967. const { row } = scope;
  4968. // console.log("additionalOnSelect: >>", item);
  4969. // const $tableAdditional = state.additionalCostsMxRef.element;
  4970. // if ($tableAdditional) {
  4971. // const { visibleData } = $tableAdditional.getTableData();
  4972. // const row = visibleData[$rowIndex];
  4973. // console.log("additionalOnSelect: row >>", row);
  4974. // row.extramxname = item.extramxname;
  4975. row.extramxid = item.extramxid ?? 0;
  4976. row.inputtype = item.inputtype;
  4977. row.extraid = item.extraid;
  4978. row.extraname = item.extramxname;
  4979. // row.typeid = item.typeid;
  4980. row.price = item.price;
  4981. row.qty = item.qty;
  4982. row.dscrp = item.dscrp;
  4983. // $tableAdditional.reloadData(visibleData);
  4984. // }
  4985. };
  4986. const querySearch_processes = (queryString: string, cb: any, data, list) => {
  4987. const { row } = data;
  4988. const results = queryString
  4989. ? list.filter(o => {
  4990. return o.extramxname.indexOf(queryString) > -1 && o.extraid == row.extraid;
  4991. })
  4992. : list.filter(o => o.extraid == row.extraid);
  4993. cb(results);
  4994. };
  4995. const querySearch_additional = (queryString: string, cb: any, data, list) => {
  4996. const { row } = data;
  4997. const results = queryString
  4998. ? list.filter(o => {
  4999. return o.extramxname.indexOf(queryString) > -1 && o.extraid == row.extraid;
  5000. })
  5001. : list.filter(o => o.extraid == row.extraid);
  5002. cb(results);
  5003. };
  5004. const columnsMx_subSpecs: any = [
  5005. { type: "checkbox", width: 50, fixed: "left" },
  5006. {
  5007. title: "报价唯一码",
  5008. field: "mattresscode"
  5009. },
  5010. {
  5011. title: "核价编码",
  5012. field: "mattressrelcode",
  5013. editRender: {
  5014. name: "$input"
  5015. }
  5016. },
  5017. {
  5018. title: "核价名称",
  5019. field: "mattressname",
  5020. editRender: {
  5021. name: "$input"
  5022. }
  5023. },
  5024. {
  5025. title: "床垫宽/CM",
  5026. field: "mattress_width",
  5027. datatype: "number",
  5028. // editRender: {
  5029. // name: "VxeInput",
  5030. // props: {
  5031. // type: "number",
  5032. // onBlur: (e: any) => {
  5033. // const {value} = e
  5034. // console.log("columnsMx_subSpecs: e >>", e);
  5035. // if (value) {
  5036. // setMxSpringQtyWidthAndLength();
  5037. // }
  5038. // }
  5039. // }
  5040. // }
  5041. editRender: {},
  5042. editColRender: (scope: any) => {
  5043. return (
  5044. <>
  5045. <el-input v-model={scope.row.mattress_width} onChange={() => disshow_subspecs(scope)} />
  5046. </>
  5047. );
  5048. }
  5049. },
  5050. {
  5051. title: "床垫长/CM",
  5052. field: "mattress_length",
  5053. datatype: "number",
  5054. // editRender: {
  5055. // name: "$input",
  5056. // props: {
  5057. // type: "number"
  5058. // }
  5059. // }
  5060. editRender: {},
  5061. editColRender: (scope: any) => {
  5062. return (
  5063. <>
  5064. <el-input v-model={scope.row.mattress_length} onChange={() => disshow_subspecs(scope)} />
  5065. </>
  5066. );
  5067. }
  5068. },
  5069. {
  5070. title: "床垫高/CM",
  5071. field: "mattress_height",
  5072. datatype: "number"
  5073. // editRender: {
  5074. // name: "$input",
  5075. // props: {
  5076. // type: "number"
  5077. // }
  5078. // }
  5079. // editRender: {},
  5080. // editColRender: (scope: any) => {
  5081. // return (
  5082. // <>
  5083. // <el-input v-model={scope.row.mattress_height} onChange={() => disshow_subspecs(scope.row)} />
  5084. // </>
  5085. // );
  5086. // }
  5087. }
  5088. // {
  5089. // title: "弹簧排列个数-宽",
  5090. // field: "spring_qty_width",
  5091. // datatype: "integer",
  5092. // editRender: {
  5093. // name: "$input"
  5094. // // props: {
  5095. // // type: "number"
  5096. // // }
  5097. // }
  5098. // },
  5099. // {
  5100. // title: "弹簧排列个数-长",
  5101. // field: "spring_qty_length",
  5102. // datatype: "integer",
  5103. // editRender: {
  5104. // name: "$input"
  5105. // // props: {
  5106. // // type: "number"
  5107. // // }
  5108. // }
  5109. // }
  5110. ];
  5111. const handleToImportMxInner = async () => {
  5112. let _params = {
  5113. dsname: "web_mattress_formulalist",
  5114. queryparams: {
  5115. arg_array_formulatype: [101],
  5116. arrg_usetype: 0
  5117. }
  5118. };
  5119. let res = await CommonDynamicSelect(_params);
  5120. let idxStr = "";
  5121. const $table = state.innerClothLayerMxRef.element;
  5122. if ($table) {
  5123. const { visibleData } = $table.getTableData();
  5124. if (visibleData.length) {
  5125. let lastMx = visibleData[visibleData.length - 1];
  5126. idxStr = Number(lastMx.chastr.match(/\d+$/)?.[0] ?? 0) + 1 + "";
  5127. } else {
  5128. idxStr = "";
  5129. }
  5130. }
  5131. if (res?.datatable?.length) {
  5132. const $table = state.innerClothLayerMxRef.element;
  5133. // $table.remove();
  5134. let _rows = res?.datatable.map((item: any, index: number) => {
  5135. let _data: any = {};
  5136. if (Number(item.if_mtrl) > 1) {
  5137. _data.addmx = "+";
  5138. _data.delmx = "-";
  5139. }
  5140. _data.formulatype = item.formulatype;
  5141. _data.if_mtrl = item.if_mtrl;
  5142. _data.formulaid = item.formulaid;
  5143. _data.sortcode = item.sortcode;
  5144. _data.formulakind = item.formulakind;
  5145. _data.formula = item.formula;
  5146. _data.chastr = "内布套" + idxStr;
  5147. _data.useformula = item.useformula;
  5148. _data.gydscrp = item.gydscrp;
  5149. _data.pid = index + 1;
  5150. return _data;
  5151. });
  5152. // let tree = {
  5153. // chastr: "内布套",
  5154. // children: _rows
  5155. // };
  5156. // $table.insertAt(tree, -1);
  5157. await $table.insertAt(_rows, -1);
  5158. ElMessage.success("导入成功");
  5159. autoLoadExtraData(state.innerClothLayerMxRef, state.specialProcessesMxRef, 4, "chastr");
  5160. }
  5161. resetMergeCellsInner();
  5162. };
  5163. const resetMergeCellsInner = () => {
  5164. setTimeout(() => {
  5165. const $table = state.innerClothLayerMxRef.element;
  5166. if ($table) {
  5167. let mergeCells = autoMergeCells($table, ["chastr"]);
  5168. console.log("resetMergeCellsInner autoMergeCells :>> ", mergeCells);
  5169. $table.setMergeCells(mergeCells);
  5170. }
  5171. }, 200);
  5172. };
  5173. const resetSpecialProcesses = (type: string) => {
  5174. console.log("resetSpecialProcesses type:>> ", type);
  5175. console.log("resetSpecialProcesses additionalCostsMxInitData:>> ", state.additionalCostsMxInitData);
  5176. console.log("resetSpecialProcesses specialProcessesMxInitData:>> ", state.specialProcessesMxInitData);
  5177. // setTimeout(() => {
  5178. // const $table = state.innerClothLayerMxRef.element;
  5179. // if ($table) {
  5180. // let mergeCells = autoMergeCells($table, ["chastr"]);
  5181. // console.log("resetMergeCellsInner autoMergeCells :>> ", mergeCells);
  5182. // $table.setMergeCells(mergeCells);
  5183. // }
  5184. // }, 200);
  5185. };
  5186. const hanleDelMxInner = async (type: number) => {
  5187. const $table = state.innerClothLayerMxRef.element;
  5188. if ($table) {
  5189. if (type == 1) {
  5190. // 全部
  5191. await $table.remove();
  5192. } else if (type == 0) {
  5193. // 删除选中
  5194. const curRow = $table.getCurrentRecord();
  5195. if (!curRow) {
  5196. ElMessage.warning("请先选择要删除的行");
  5197. return;
  5198. }
  5199. let _chastr = curRow?.chastr;
  5200. const { visibleData } = $table.getTableData();
  5201. let _vData = visibleData.filter((o: any) => o.chastr != _chastr);
  5202. await $table.reloadData(_vData);
  5203. ElMessage.success("成功删除" + _chastr);
  5204. }
  5205. autoLoadExtraData(state.innerClothLayerMxRef, state.specialProcessesMxRef, 4, "chastr");
  5206. resetMergeCellsInner();
  5207. }
  5208. };
  5209. const w_mattress_add_itemname_choose = (type: number) => {
  5210. let arr = [];
  5211. if (type == 1) {
  5212. } else if (type == 2) {
  5213. } else if (type == 3) {
  5214. arr.push({
  5215. label: "内布套",
  5216. value: "内布套"
  5217. });
  5218. arr.push({
  5219. label: "内布套拆装",
  5220. value: "内布套拆装"
  5221. });
  5222. } else if (type == 4) {
  5223. arr.push({
  5224. label: "顶布裥棉1",
  5225. value: "顶布裥棉1"
  5226. });
  5227. arr.push({
  5228. label: "顶布裥棉2",
  5229. value: "顶布裥棉2"
  5230. });
  5231. arr.push({
  5232. label: "顶布裥棉3",
  5233. value: "顶布裥棉3"
  5234. });
  5235. arr.push({
  5236. label: "顶布裥棉4",
  5237. value: "顶布裥棉4"
  5238. });
  5239. }
  5240. return arr;
  5241. };
  5242. const wf_add_w_butao = async (val: any) => {
  5243. console.log("val :>> ", val);
  5244. const $table = state.topCottonMxRef.element;
  5245. if ($table) {
  5246. const { fullData } = $table.getTableData();
  5247. let ifind = fullData.find(t => t.chastr == val.value);
  5248. if (ifind) {
  5249. ElMessage.warning(`该选项${val.value}已存在`);
  5250. return;
  5251. }
  5252. let newParams: any = {};
  5253. newParams.queryParams = {
  5254. arg_array_formulatype: [103],
  5255. arrg_usetype: 0
  5256. };
  5257. newParams.dsname = "web_mattress_formulalist";
  5258. let res = await CommonDynamicSelect(newParams);
  5259. console.log("funcAddBigSide res :>> ", res);
  5260. if (res.datatable) {
  5261. let _rows = res?.datatable.map((item: any) => {
  5262. let _data: any = {};
  5263. if (Number(item.if_mtrl) > 1) {
  5264. _data.addmx = "+";
  5265. _data.delmx = "-";
  5266. }
  5267. _data.formulatype = item.formulatype;
  5268. _data.if_mtrl = item.if_mtrl;
  5269. _data.formulaid = item.formulaid;
  5270. _data.sortcode = item.sortcode;
  5271. _data.formulakind = item.formulakind;
  5272. _data.formula = item.formula;
  5273. _data.chastr = val.value;
  5274. _data.useformula = item.useformula;
  5275. _data.gydscrp = item.gydscrp;
  5276. return _data;
  5277. });
  5278. $table.insertAt(_rows, -1);
  5279. }
  5280. }
  5281. resetMergeCellsTopCotton();
  5282. };
  5283. const resetMergeCellsTopCotton = () => {
  5284. setTimeout(() => {
  5285. const $table = state.topCottonMxRef.element;
  5286. if ($table) {
  5287. let mergeCells = autoMergeCells($table, ["chastr"]);
  5288. console.log("resetMergeCellsInner autoMergeCells :>> ", mergeCells);
  5289. $table.setMergeCells(mergeCells);
  5290. }
  5291. }, 1);
  5292. };
  5293. /**
  5294. * @description 删除顶布裥棉明细
  5295. */
  5296. const wf_del_w_butao = async () => {
  5297. const $table = state.topCottonMxRef.element;
  5298. // 删除选中
  5299. const curRow = $table.getCurrentRecord();
  5300. const { fullData } = $table.getTableData();
  5301. if (!curRow) {
  5302. ElMessage.warning("请先选择要删除的行");
  5303. return;
  5304. }
  5305. let ls_chastr = curRow.chastr;
  5306. ElMessageBox.confirm(`是否确定要删除【${ls_chastr}】的明细行?`, "询问", {
  5307. confirmButtonText: "是",
  5308. cancelButtonText: "否",
  5309. type: "warning"
  5310. }).then(() => {
  5311. let _rows = fullData.filter((item: any) => item.chastr == ls_chastr);
  5312. $table.remove(_rows);
  5313. ElMessage({
  5314. type: "success",
  5315. message: "删除成功"
  5316. });
  5317. });
  5318. };
  5319. /**
  5320. * @description 获取部门的价格表id
  5321. * @returns
  5322. */
  5323. const getPriceid = () => {
  5324. let _deptid = state.LjDetailRef?._mainData?.deptid ?? 0;
  5325. if (!_deptid) {
  5326. ElMessage.warning("请先选择部门");
  5327. state.LjDetailRef?.baseformRef.element.validateField("deptid");
  5328. return 0;
  5329. }
  5330. let deptEnum = state.LjDetailRef.enumMap.get("deptid");
  5331. let _pricelistid = 0;
  5332. if (deptEnum) {
  5333. let depItem = deptEnum.find((item: any) => item.value == _deptid);
  5334. if (depItem) {
  5335. _pricelistid = Number(depItem.pricelistid);
  5336. }
  5337. }
  5338. return _pricelistid;
  5339. };
  5340. // 节流
  5341. const disshow_subspecs = throttle((val: any) => {
  5342. setMxSpringQtyWidthAndLength(val);
  5343. }, 500);
  5344. /**
  5345. * @description 设置床网高度,自动计算宽度,长度
  5346. */
  5347. const setMxSpringQtyWidthAndLength = async scope => {
  5348. console.log("setMxSpringQtyWidthAndLength varow :>> ", scope);
  5349. const { row } = scope;
  5350. const $tableBednet = state.bednetMxRef.element;
  5351. if ($tableBednet) {
  5352. const { visibleData } = $tableBednet.getTableData();
  5353. // 需要填写关键数据
  5354. if (!Number(row.mattress_width) || !Number(row.mattress_length) || !Number(row.mattress_height)) {
  5355. return;
  5356. }
  5357. // 如果表格没有数据/没有选床网,则不执行
  5358. if (!visibleData.length || !visibleData[0].mtrlid) {
  5359. return;
  5360. }
  5361. let _pricelistid = getPriceid();
  5362. for (let i = 0; i < visibleData.length; i++) {
  5363. let _mainData = visibleData[i];
  5364. if (_mainData.mtrlid > 0) {
  5365. let bednet = cloneDeep(_mainData);
  5366. bednet.bednetid = _mainData.mtrlid;
  5367. // bednet.if_doublenet = Number(bednet.if_doublenet);
  5368. // bednet.if_doublespring = Number(bednet.if_doublespring);
  5369. // bednet.if_side_iron = Number(bednet.if_side_iron);
  5370. // bednet.if_rsorwa = Number(bednet.if_rsorwa);
  5371. // bednet.if_sponge_drilling = Number(bednet.if_sponge_drilling);
  5372. // bednet.iffork = Number(bednet.iffork);
  5373. // bednet.ifsaleout = Number(bednet.ifsaleout);
  5374. // bednet.if_jb = Number(bednet.if_jb);
  5375. // bednet.flag = Number(bednet.flag);
  5376. bednet.mattress_length = row.mattress_length;
  5377. bednet.mattress_width = row.mattress_width;
  5378. bednet.pricelistid = _pricelistid;
  5379. let _params: any = {
  5380. bednet: bednet
  5381. // bednetMx: state.vxeTableMxRef?.element.getTableData().fullData ?? [],
  5382. // spring: state.vxeTableMxSpringRef?.element.getTableData().fullData ?? []
  5383. };
  5384. console.log("setMxSpringQtyWidthAndLength _params :>> ", _params);
  5385. let res = await GetComputeSpring(_params);
  5386. console.log("setMxSpringQtyWidthAndLength res :>> ", res);
  5387. console.log("setMxSpringQtyWidthAndLength row :>> ", row);
  5388. if (!res?.message) {
  5389. scope.row["spring_qty_width_" + (i + 1)] = res.bednetMx[0].spring_qty_width;
  5390. scope.row["spring_qty_length_" + (i + 1)] = res.bednetMx[0].spring_qty_length;
  5391. }
  5392. console.log("setMxSpringQtyWidthAndLength scopes row :>> ", scope.row);
  5393. }
  5394. }
  5395. }
  5396. };
  5397. /**
  5398. * @description 计算拼侧数量
  5399. */
  5400. const computedExtraSizeNum = (enumarr: any, arr: any, key: string, arg_extraid: number) => {
  5401. console.log("computedExtraSizeNum specialProcessesEnum.value :>> ", enumarr);
  5402. let extraArr = enumarr.filter(item => item.typeid == 1 && item.extraid == arg_extraid && item.extramxname.includes(key));
  5403. let arrNum = arr.filter(item => item.includes(key)).length;
  5404. let result = [];
  5405. extraArr.forEach(o => {
  5406. // 判断名称中出现的数量
  5407. try {
  5408. const checker = new Function("value", `return ${text2Formula(o.extramxname)};`);
  5409. if (checker(arrNum)) {
  5410. result.push(o);
  5411. }
  5412. } catch (error) {
  5413. console.log("error :>> ", error);
  5414. ElMessage.error(`${t("sys.api.operationFailed")}特殊工艺名称: ${error}`);
  5415. }
  5416. });
  5417. return result;
  5418. };
  5419. /**
  5420. * @description 判断目前选择的拼接数据量,自动导入修改特殊工艺费用
  5421. * @params tableRef 表格实例
  5422. * @params targetRef 目标表格实例
  5423. * @params arg_extraid 数据库建立的特殊费用id,1:特殊费用,4:内布套
  5424. * @params matchAttr 匹配字段
  5425. */
  5426. const autoLoadExtraData = (tableRef?: any, targetRef?: any, arg_extraid = 1, matchAttr = "sortcode") => {
  5427. //计算拼侧数量
  5428. const $table = tableRef.element;
  5429. const { visibleData } = $table.getTableData();
  5430. const $tableTarget = targetRef.element;
  5431. const { visibleData: tgVisibleData } = $tableTarget.getTableData();
  5432. let arr = [];
  5433. // 收集拼侧,并去重
  5434. visibleData.map(t => arr.push(t[matchAttr]));
  5435. arr = Array.from(new Set(arr));
  5436. console.log("autoLoadExtraData 收集拼侧,并去重 arr :>> ", arr, visibleData);
  5437. //
  5438. let _remove = [];
  5439. tgVisibleData.map(t => {
  5440. if (t.extraid == arg_extraid) {
  5441. _remove.push(t);
  5442. }
  5443. });
  5444. $tableTarget.remove(_remove);
  5445. let result = [];
  5446. if (!arr.includes("普通大侧")) {
  5447. result = result.concat(computedExtraSizeNum(state.specialProcessesMxData, arr, "上下", arg_extraid));
  5448. result = result.concat(computedExtraSizeNum(state.specialProcessesMxData, arr, "左右", arg_extraid));
  5449. result = result.concat(computedExtraSizeNum(state.specialProcessesMxData, arr, "内布套", arg_extraid));
  5450. console.log("autoLoadExtraData result :>> ", result, state.specialProcessesMxData);
  5451. }
  5452. if (result.length) {
  5453. let _arr = [];
  5454. let _mattressId = state.LjDetailRef._mainData.mattressid;
  5455. result.map(o => {
  5456. let _itm = {
  5457. mattressid: _mattressId,
  5458. mattressmxid: 0,
  5459. extraid: o.extraid,
  5460. extramxid: o.extramxid,
  5461. // extratypename: "",
  5462. extraname: o.extramxname,
  5463. price: o.price,
  5464. qty: o.qty,
  5465. dscrp: o.dscrp,
  5466. inputtype: o.inputtype,
  5467. typeid: o.typeid
  5468. };
  5469. _arr.push(_itm);
  5470. });
  5471. $tableTarget.insertAt(_arr, -1);
  5472. }
  5473. };
  5474. /**
  5475. * @description 获取特殊工艺数据
  5476. * @params mtrlItem 物料
  5477. * @params arg_extraid 数据库建立的特殊费用id,5: 物料的特殊工艺费用
  5478. */
  5479. const autoLoadMtrlExtra = (mtrlItem?: any, arg_extraid = 5, action = "add") => {
  5480. const $tableTarget = state.specialProcessesMxRef.element;
  5481. const { visibleData: tgVisibleData } = $tableTarget.getTableData();
  5482. let _sum = getSumMtrlQty(mtrlItem?.mtrlid);
  5483. console.log("autoLoadMtrlExtra _sum :>> ", _sum, mtrlItem);
  5484. let _remove = [];
  5485. tgVisibleData.map(t => {
  5486. if (t.extraid == arg_extraid && mtrlItem.mtrlid == t?.mtrlid) {
  5487. _remove.push(t);
  5488. }
  5489. });
  5490. $tableTarget.remove(_remove);
  5491. //计算拼侧数量
  5492. if (action == "add") {
  5493. if (mtrlItem?.extra_cost == 0) return;
  5494. } else if (action == "del") {
  5495. if (_sum <= 0) {
  5496. return;
  5497. }
  5498. }
  5499. let result = [];
  5500. let extraArr = state.specialProcessesMxData.filter(item => item.typeid == 1 && item.extraid == arg_extraid);
  5501. if (extraArr.length) {
  5502. // 取额外费用数据模版,插入
  5503. result.push(extraArr[0]);
  5504. }
  5505. if (result.length) {
  5506. let _arr = [];
  5507. let _mattressId = state.LjDetailRef._mainData.mattressid;
  5508. result.map(o => {
  5509. let _itm = {
  5510. mattressid: _mattressId,
  5511. mattressmxid: 0,
  5512. extraid: o.extraid,
  5513. extramxid: o.extramxid,
  5514. extraname: mtrlItem.mtrlname,
  5515. price: mtrlItem.extra_cost,
  5516. qty: _sum,
  5517. dscrp: o.dscrp,
  5518. inputtype: o.inputtype,
  5519. typeid: o.typeid,
  5520. mtrlid: mtrlItem.mtrlid
  5521. };
  5522. _arr.push(_itm);
  5523. });
  5524. $tableTarget.insertAt(_arr, -1);
  5525. }
  5526. };
  5527. /**
  5528. * @description 统计物料使用数量
  5529. * @param mtrlid
  5530. * @returns
  5531. */
  5532. const getSumMtrlQty = (mtrlid?: number) => {
  5533. let sum = 0;
  5534. state.fabricMxTabList.map(t => {
  5535. if (t.ref) {
  5536. if (dynamicRef(t.ref) && !["specialProcessesMxRef", "additionalCostsMxRef"].includes(t.ref)) {
  5537. let $table = dynamicRef(t.ref)?.element;
  5538. $table.clearEdit();
  5539. let { visibleData } = $table.getTableData();
  5540. visibleData.map((itm, idx) => {
  5541. if (itm.mtrlid == mtrlid) {
  5542. sum += Number(itm.qty ?? 0);
  5543. }
  5544. });
  5545. }
  5546. }
  5547. });
  5548. return sum;
  5549. };
  5550. /**
  5551. * @description 自动导入修改特殊工艺费用
  5552. */
  5553. const autoLoadExtraData_chai = (value?: any, fieldName?: any) => {
  5554. console.log("autoLoadExtraData_chai value :>> ", value);
  5555. let _type = "";
  5556. switch (fieldName) {
  5557. case "if_m_chai":
  5558. _type = "面拆";
  5559. break;
  5560. case "if_z_chai":
  5561. _type = "中拆";
  5562. break;
  5563. case "if_d_chai":
  5564. _type = "底拆";
  5565. break;
  5566. }
  5567. console.log("state. specialProcessesEnum:>> ", state.specialProcessesEnum, state.specialProcessesMxData);
  5568. let result = state.specialProcessesMxData.filter((item: any) => item.extramxname.indexOf(_type) > -1);
  5569. if (result.length) {
  5570. const $tableTarget = state.specialProcessesMxRef.element;
  5571. const { visibleData: tgVisibleData } = $tableTarget.getTableData();
  5572. if (tgVisibleData) {
  5573. let _remove = [];
  5574. tgVisibleData.map(t => {
  5575. let _itm = result.find(i => i.extraid === t.extraid && i.extramxid === t.extramxid);
  5576. if (_itm) {
  5577. _remove.push(t);
  5578. }
  5579. });
  5580. $tableTarget.remove(_remove);
  5581. }
  5582. if (value) {
  5583. // 新增
  5584. if (result.length) {
  5585. let _arr = [];
  5586. let _mattressId = state.LjDetailRef._mainData.mattressid;
  5587. result.map(o => {
  5588. let _itm = {
  5589. mattressid: _mattressId,
  5590. mattressmxid: 0,
  5591. extraid: o.extraid,
  5592. extramxid: o.extramxid,
  5593. extraname: o.extramxname,
  5594. price: o.price,
  5595. qty: o.qty,
  5596. dscrp: o.dscrp,
  5597. inputtype: o.inputtype,
  5598. typeid: o.typeid
  5599. };
  5600. _arr.push(_itm);
  5601. });
  5602. $tableTarget.insertAt(_arr, -1);
  5603. }
  5604. } else {
  5605. // 删除
  5606. }
  5607. }
  5608. };
  5609. const gotoErpapi = (_cur, type) => {
  5610. try {
  5611. if (type === 1) {
  5612. if (_cur.yw_flag == 1) {
  5613. throw new Error(_cur.mattresscode + ":已业务补充审核,无法修改");
  5614. }
  5615. } else if (type === 2) {
  5616. if (_cur.js1_flag == 1) {
  5617. throw new Error(_cur.mattresscode + ":已产品补充审核,无法修改");
  5618. }
  5619. } else if (type === 3) {
  5620. if (_cur.js2_flag == 1) {
  5621. throw new Error(_cur.mattresscode + ":已清单补充审核,无法修改");
  5622. }
  5623. }
  5624. } catch (error) {
  5625. ElMessage.error(error.message);
  5626. return false;
  5627. }
  5628. router.push({
  5629. path: `/erpapi/mattressInterface/edit/${_cur.mattressid}`,
  5630. query: {
  5631. code: _cur.mattresscode,
  5632. type: type
  5633. }
  5634. });
  5635. };
  5636. /**
  5637. * @description 更新主副规格表结构
  5638. */
  5639. const updateSubspecsTable = () => {
  5640. // state.columnsMx_subSpecs_dis = [];
  5641. // 检查床网
  5642. console.log("updateSubspecsTable state.columnsMx_subSpecs_dis :>> ", state.columnsMx_subSpecs_dis);
  5643. const $tableBendet = state.bednetMxRef.element;
  5644. const $tableSubspecs = state.subSpecsRef?.element;
  5645. let cols = [];
  5646. let visibleData = [];
  5647. if ($tableSubspecs) {
  5648. visibleData = $tableSubspecs.getTableData().visibleData;
  5649. }
  5650. if ($tableBendet) {
  5651. const { visibleData: bednetVisibleData } = $tableBendet.getTableData();
  5652. if (bednetVisibleData && bednetVisibleData.length) {
  5653. // let filedsName = state.columnsMx_subSpecs_dis
  5654. // .filter((item: any) => item.field && item.field.indexOf("spring_qty_width_") > -1)
  5655. // .map(item => item.field);
  5656. // let bednetFieldsName = bednetVisibleData
  5657. // .filter((item: any) => item.mtrlid)
  5658. // .map(item => "spring_qty_width_" + item.mtrlid);
  5659. console.log(
  5660. 'filedsName.join(",") != bednetFieldsName.join(",") :>> ',
  5661. // filedsName.join(","),
  5662. // bednetFieldsName.join(","),
  5663. bednetVisibleData
  5664. );
  5665. // if (filedsName.join(",") != bednetFieldsName.join(",")) {
  5666. bednetVisibleData.map((item: any, idx: any) => {
  5667. if (item.mtrlid) {
  5668. cols.push({
  5669. title: "弹簧排列个数-宽" + "-床网" + (idx + 1),
  5670. field: "spring_qty_width_" + (idx + 1),
  5671. datatype: "integer",
  5672. editRender: {
  5673. name: "$input"
  5674. }
  5675. });
  5676. cols.push({
  5677. title: "弹簧排列个数-宽" + "-床网" + (idx + 1),
  5678. field: "spring_qty_length_" + (idx + 1),
  5679. datatype: "integer",
  5680. editRender: {
  5681. name: "$input"
  5682. }
  5683. });
  5684. // 床网使用弹叉
  5685. cols.push({
  5686. title: "弹叉数量" + "-床网" + (idx + 1),
  5687. field: "bednet_fork_qty_" + (idx + 1),
  5688. datatype: "integer",
  5689. editRender: {
  5690. name: "$input"
  5691. }
  5692. });
  5693. }
  5694. });
  5695. // }
  5696. }
  5697. }
  5698. /**
  5699. * @description 垫层tab-记录需要变更的主副规格调整物料
  5700. */
  5701. const $tableCushions = state.cushionsMxRef.element;
  5702. if ($tableCushions) {
  5703. const { visibleData: cushionsVisibleData } = $tableCushions.getTableData();
  5704. if (cushionsVisibleData && cushionsVisibleData.length) {
  5705. // let filedsName = state.columnsMx_subSpecs_dis
  5706. // .filter((item: any) => item.field && item.field.indexOf("cushions_subspecs_") > -1)
  5707. // .map(item => item.field);
  5708. // let cushionsFieldsName = cushionsVisibleData
  5709. // .filter((item: any) => item.mtrlid && item.if_subspecs)
  5710. // .map(item => "cushions_subspecs_" + item.mtrlid);
  5711. // console.log('filedsName.join(",") ', filedsName.join(","));
  5712. // console.log(' cushionsFieldsName.join(",") :>> ', cushionsFieldsName.join(","));
  5713. // if (filedsName.join(",") != cushionsFieldsName.join(",")) {
  5714. let idx = 0;
  5715. cushionsVisibleData.map((item: any, index: any) => {
  5716. if (item.mtrlid && item.if_subspecs) {
  5717. let _field = "cushions_subspecs_" + (idx + 1);
  5718. let _mtrlname = "cushions_subspecs_mtrlname_" + (idx + 1);
  5719. let _formulakind = "cushions_subspecs_formulakind_" + (idx + 1);
  5720. idx++;
  5721. visibleData = visibleData.map(itm => {
  5722. itm[_formulakind] = item.formulakind;
  5723. return itm;
  5724. });
  5725. cols.push({
  5726. title: "垫层物料-" + item.chastr + " " + (index + 1),
  5727. field: _mtrlname,
  5728. width: "200",
  5729. editRender: {},
  5730. editColRender: (scope: any) => {
  5731. const { column, row, status, $table } = scope;
  5732. let _label = column.title;
  5733. let _pricelistid = getPriceid();
  5734. let _mtrltypeItem: any = mtrltypeTabList_cushions.find(t => t.formulakinds.includes(Number(row[_formulakind])));
  5735. if (!_mtrltypeItem) {
  5736. // ElMessage.error("不是垫层类型行,不能选物料");
  5737. // return <></>;
  5738. }
  5739. console.log("updateSubspecsTable _mtrltypeItem :>> ", _mtrltypeItem);
  5740. let params = {
  5741. mtrltype: _mtrltypeItem?.value,
  5742. pricelistid: _pricelistid
  5743. };
  5744. return (
  5745. <>
  5746. <MtrldefSelect
  5747. value={row[_field]}
  5748. {...params}
  5749. disabled={!_mtrltypeItem}
  5750. clearable
  5751. placeholder={_label}
  5752. onOpenModal={() =>
  5753. fModelChoseMtrl(
  5754. row,
  5755. params,
  5756. (data, val: any) => {
  5757. row[_field] = val.mtrlid;
  5758. row[_mtrlname] = val.mtrlname;
  5759. },
  5760. _mtrltypeItem?.label,
  5761. $table
  5762. )
  5763. }
  5764. onSelect={(val: any) => {
  5765. row[_field] = val.mtrlid;
  5766. row[_mtrlname] = val.mtrlname;
  5767. }}
  5768. onClear={() => {
  5769. row[_field] = 0;
  5770. row[_mtrlname] = "";
  5771. }}
  5772. >
  5773. {{
  5774. label: () => row[_mtrlname]
  5775. }}
  5776. </MtrldefSelect>
  5777. </>
  5778. );
  5779. }
  5780. });
  5781. }
  5782. });
  5783. // }
  5784. }
  5785. }
  5786. /**
  5787. * @description 辅料tab-记录需要变更的主副规格调整物料
  5788. */
  5789. const $tableAccessories = state.accessoriesMxRef.element;
  5790. if ($tableAccessories) {
  5791. const { visibleData: accessVisibleData } = $tableAccessories.getTableData();
  5792. if (accessVisibleData && accessVisibleData.length) {
  5793. let idx = 0;
  5794. accessVisibleData.map((item: any, index: any) => {
  5795. if (item.mtrlid && item.if_subspecs) {
  5796. let _field = "accessories_subspecs_" + (idx + 1);
  5797. let _mtrlname = "accessories_subspecs_mtrlname_" + (idx + 1);
  5798. let _formulakind = "accessories_subspecs_formulakind_" + (idx + 1);
  5799. idx++;
  5800. visibleData = visibleData.map(itm => {
  5801. itm[_formulakind] = item.formulakind;
  5802. return itm;
  5803. });
  5804. let itmName = state.formulaKindEnum.find(t => t.value == item.formulakind)?.label ?? "";
  5805. cols.push({
  5806. title: "辅料物料-" + itmName + " " + (index + 1),
  5807. field: _mtrlname,
  5808. width: "200",
  5809. editRender: {},
  5810. editColRender: (scope: any) => {
  5811. const { column, row, status, $table } = scope;
  5812. let _label = column.title;
  5813. let _pricelistid = getPriceid();
  5814. let _mtrltypeItem: any = mtrltypeTabList_accessories.find(t =>
  5815. t.formulakinds.includes(Number(row[_formulakind]))
  5816. );
  5817. if (!_mtrltypeItem) {
  5818. // ElMessage.error("不是垫层类型行,不能选物料");
  5819. // return <></>;
  5820. }
  5821. console.log("updateSubspecsTable _mtrltypeItem :>> ", _mtrltypeItem);
  5822. let params = {
  5823. mtrltype: _mtrltypeItem?.value,
  5824. pricelistid: _pricelistid
  5825. };
  5826. return (
  5827. <>
  5828. <MtrldefSelect
  5829. value={row[_field]}
  5830. {...params}
  5831. disabled={!_mtrltypeItem}
  5832. clearable
  5833. placeholder={_label}
  5834. onOpenModal={() =>
  5835. fModelChoseMtrl(
  5836. row,
  5837. params,
  5838. (data, val: any) => {
  5839. row[_field] = val.mtrlid;
  5840. row[_mtrlname] = val.mtrlname;
  5841. },
  5842. _mtrltypeItem?.label,
  5843. $table
  5844. )
  5845. }
  5846. onSelect={(val: any) => {
  5847. row[_field] = val.mtrlid;
  5848. row[_mtrlname] = val.mtrlname;
  5849. }}
  5850. onClear={() => {
  5851. row[_field] = 0;
  5852. row[_mtrlname] = "";
  5853. }}
  5854. >
  5855. {{
  5856. label: () => row[_mtrlname]
  5857. }}
  5858. </MtrldefSelect>
  5859. </>
  5860. );
  5861. }
  5862. });
  5863. }
  5864. });
  5865. // }
  5866. }
  5867. }
  5868. // if (cols.length > 0) {
  5869. state.columnsMx_subSpecs_dis = columnsMx_subSpecs.concat(cols);
  5870. console.log("updateSubspecsTable state.columnsMx_subSpecs_dis 321:>> ", state.columnsMx_subSpecs_dis);
  5871. nextTick(() => {
  5872. // state.subSpecsRef.element.loadColumn(state.columnsMx_subSpecs_dis);
  5873. state.subSpecsRef.loadColumns(state.columnsMx_subSpecs_dis);
  5874. console.log("visibleData :>> ", visibleData);
  5875. if ($tableSubspecs) {
  5876. state.subSpecsData = visibleData;
  5877. }
  5878. });
  5879. // }
  5880. };
  5881. const getAllFormulaList = async () => {
  5882. const need_formula = [2];
  5883. let _param = {
  5884. dsname: "web_mattress_formulalist",
  5885. queryparams: {
  5886. arrg_usetype: 0,
  5887. arg_array_formulatype: need_formula
  5888. }
  5889. };
  5890. let res = await CommonDynamicSelect(_param);
  5891. state.mattressFormulaList = res.datatable;
  5892. };
  5893. return {
  5894. ...toRefs(state),
  5895. columns,
  5896. columnsMx,
  5897. columnsMxBednet: funcMergeColumn(columnsMx, bednetCoumns, bednetExtraColumns),
  5898. columnsMxCushions: funcMergeColumn(columnsMx, cushionsColumns),
  5899. columnsMxAccessories: funcMergeColumn(columnsMx, accessoriesColumns),
  5900. columnsMxPackag: funcMergeColumn(columnsMx, packagColumns),
  5901. columnsMxInnerClothLayer,
  5902. // summaryData,
  5903. // fieldParams,
  5904. columnsMx_subSpecs,
  5905. columnsMx_processes,
  5906. columnsMx_additional,
  5907. funcAddMxSide,
  5908. funcChaifenTab,
  5909. getData_mx,
  5910. dataCallback,
  5911. dataCallbackMx,
  5912. getMattressType,
  5913. gotoSummy,
  5914. gotoHisprice,
  5915. getFormulakindEnum,
  5916. funcPacktypeChange,
  5917. dynamicRef,
  5918. wf_cmp_cb,
  5919. handleToImportMxInner,
  5920. hanleDelMxInner,
  5921. wf_add_w_butao,
  5922. wf_del_w_butao,
  5923. w_mattress_add_itemname_choose,
  5924. wf_rtr_bednet,
  5925. funcAddMtrlMx,
  5926. resetMergeCellsInner,
  5927. resetSpecialProcesses,
  5928. resetMergeCellsTopCotton,
  5929. wf_rtr_cwdc,
  5930. gotoErpapi,
  5931. updateSubspecsTable,
  5932. funcChaifenTabPro,
  5933. getQuoteListMxData,
  5934. autoLoadExtraData,
  5935. autoLoadExtraData_chai,
  5936. getAllFormulaList
  5937. };
  5938. };