| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148 |
- <template>
- <div>
- <el-card shadow="never">
- <!-- <header-title title="基本信息"> </header-title> -->
- <div>基本信息</div>
- <el-form
- :model="formData"
- ref="formName"
- label-width="110px"
- :rules="rules"
- >
- <el-row :gutter="20">
- <el-col :span="6">
- <el-form-item label="物品类型" prop="extInfo.assetType">
- <el-select
- style="width: 100%"
- disabled
- multiple
- v-model="formData.extInfo.assetType"
- placeholder="请选择"
- >
- <el-option
- v-for="item in goodsLists"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="入库类型" prop="bizType">
- <el-select
- style="width: 100%"
- disabled
- filterable
- placeholder="请选择"
- v-model="formData.bizType"
- clearable
- >
- <el-option
- v-for="item in sceneState"
- :key="item.code"
- :value="item.code"
- :label="item.label"
- ></el-option>
- </el-select> </el-form-item
- ></el-col>
- <el-col :span="6">
- <el-form-item label="单据来源" prop="documentSource">
- <el-input
- placeholder="请选择"
- disabled
- v-model="formData.sourceBizNo"
- @click.native="openDocumentSourceDialog"
- >
- </el-input>
- </el-form-item>
- </el-col>
- <!-- <el-col :span="6">
- <el-form-item label="权属部门" prop="deptName">
- <el-input
- placeholder="权属部门"
- disabled
- v-model="formData.extInfo.deptName"
- clearable
- />
- </el-form-item>
- </el-col> -->
- <el-col :span="6">
- <el-form-item label="入库时间">
- <el-date-picker
- v-model="formData.storageTime"
- type="datetime"
- value-format="yyyy-MM-dd HH:mm:ss"
- placeholder="选择日期时间"
- >
- </el-date-picker></el-form-item
- ></el-col>
- <el-col :span="6">
- <el-form-item label="入库登记人">
- <el-input
- placeholder="登记人"
- disabled
- v-model="formData.createUserName"
- clearable /></el-form-item
- ></el-col>
- <el-col :span="6">
- <el-form-item label="审核人">
- <el-input
- placeholder="审核人"
- disabled
- v-model="formData.approvalUserName"
- clearable /></el-form-item
- ></el-col>
- <!-- <el-col :span="6" v-if="formData.bizType == 2">
- <el-form-item label="供应商" prop="supplierName">
- <el-input
- placeholder="请输入"
- clearable
- v-model="formData.extInfo.supplierName"
- />
- </el-form-item>
- </el-col> -->
- <!-- <el-col :span="6">
- <el-form-item label="送货人" prop="fromUser">
- <el-input placeholder="请输入" v-model="formData.fromUser" clearable /> </el-form-item></el-col>
- <el-col :span="6">
- <el-form-item label="送货人联系方式" prop="deliveryPhone">
- <el-input placeholder="请输入" v-model="formData.extInfo.deliveryPhone" clearable /></el-form-item></el-col> -->
- <el-col :span="6">
- <el-form-item label="备注" prop="remark">
- <el-input
- v-model="formData.remark"
- clearable
- type="textarea"
- placeholder="请详细说明"
- :rows="1"
- ></el-input>
- </el-form-item>
- </el-col>
- <!-- <el-col :span="6">
- <el-form-item label="生产要求" prop="productionRequirements">
- <el-input
- v-model="formData.productionRequirements"
- clearable
- type="textarea"
- placeholder=""
- :rows="1"
- disabled
- ></el-input>
- </el-form-item>
- </el-col> -->
- </el-row>
- </el-form>
- <div class="inbound_details">
- <header-title title="产品信息">
- <el-button type="primary" @click="addProduct">添加</el-button>
- </header-title>
- <div class="form_table">
- <el-form
- ref="productListRef"
- :model="{ productList: productList }"
- :show-message="false"
- >
- <el-button
- v-if="productList.length != 0"
- type="success"
- plain
- style="margin-bottom: 20px; float: right; margin-right: 20px"
- size="mini"
- @click="listSaveArrs"
- >批量保存</el-button
- >
- <el-button
- v-if="productList.length != 0 && this.packingList.length == 0"
- type="success"
- plain
- style="margin-bottom: 20px; float: right; margin-right: 20px"
- size="mini"
- @click="handleWareHouse(productList, '', 'batch')"
- >批量选择仓库</el-button
- >
- <el-table
- :header-cell-style="rowClass"
- :max-height="300"
- border
- ref="productListTable"
- :data="productList"
- tooltip-effect="dark"
- @row-click="handleRowClick"
- :row-class-name="tableRowClassName"
- >
- <el-table-column
- label="序号"
- type="index"
- width="50"
- align="center"
- fixed="left"
- >
- </el-table-column>
- <el-table-column
- label="编码"
- prop="categoryCode"
- align="center"
- width="130"
- :show-overflow-tooltip="true"
- fixed="left"
- ></el-table-column>
- <el-table-column
- label="名称"
- align="center"
- width="200"
- prop="categoryName"
- :show-overflow-tooltip="true"
- fixed="left"
- ></el-table-column>
- <el-table-column
- label="牌号"
- align="center"
- width="100"
- prop="brandNum"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="型号"
- align="center"
- width="100"
- prop="categoryModel"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="规格"
- align="center"
- width="100"
- prop="specification"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- v-for="(item, index) in newColumns"
- :label="item.label"
- :align="item.align"
- :prop="item.prop"
- :show-overflow-tooltip="item.showOverflowTooltip"
- ></el-table-column>
- <el-table-column
- label="包装完好与否"
- align="center"
- width="100"
- prop="ifPackageOk"
- v-if="isShowPackage"
- >
- <template slot-scope="{ row, $index }">
- <!-- <template v-if="row.isSave">
- {{ row.ifPackageOk == 1 ? '是' : row.ifPackageOk == 0 ? '否' : '' }}
- </template> -->
- <el-form-item
- :prop="`productList.${$index}.ifPackageOk`"
- required
- >
- <el-select
- v-model="row.ifPackageOk"
- placeholder="请选择"
- clearable
- style="width: 100%"
- >
- <el-option label="是" :value="1" />
- <el-option label="否" :value="0" />
- </el-select>
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column
- label="拆包装责任人"
- align="center"
- width="100"
- prop="unpackUserName"
- v-if="isShowPackage"
- >
- <template slot-scope="{ row, $index }">
- <!-- <template v-if="row.isSave">
- {{ row.unpackUserName }}
- </template> -->
- <el-form-item
- :prop="`productList.${$index}.unpackUserName`"
- required
- >
- <el-input
- @click.native="handHead(row, $index)"
- v-model="row.unpackUserName"
- placeholder="请选择"
- ></el-input>
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column
- label="批次号"
- align="center"
- width="100"
- prop="batchNo"
- >
- <template slot-scope="{ row, $index }">
- <template v-if="row.isSave">
- {{ row.batchNo }}
- </template>
- <el-form-item
- v-else
- :prop="`productList.${$index}.batchNo`"
- required
- >
- <el-input
- :ref="'batchNo' + $index"
- @keyup.native="
- moveFocus($event, $index, 'batchNo', '产品', row)
- "
- v-model.number="row.batchNo"
- >
- </el-input>
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column
- label="数量"
- align="center"
- width="100"
- prop="packingQuantity"
- >
- <template slot-scope="{ row, $index }">
- <template v-if="row.isSave">
- {{ row.packingQuantity }}
- </template>
- <el-form-item
- v-else
- :prop="`productList.${$index}.packingQuantity`"
- required
- >
- <el-input
- :ref="'packingQuantity' + $index"
- type="number"
- @keyup.native="
- moveFocus(
- $event,
- $index,
- 'packingQuantity',
- '产品',
- row
- )
- "
- v-model="row.packingQuantity"
- @input="computeNum(row, $index, true)"
- >
- </el-input>
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column
- label="单位"
- align="center"
- prop="packingUnit"
- width="100"
- >
- <template slot-scope="{ row, $index }">
- <template v-if="row.isSave">
- {{ row.packingUnit }}
- </template>
- <el-form-item
- v-else
- :prop="`productList.${$index}.packingUnit`"
- required
- >
- <el-select
- v-model="row.packingUnitId"
- placeholder="请选择"
- @change="computeNum(row, $index)"
- >
- <el-option
- v-for="item in row.packingSpecificationOption"
- :label="`${item.conversionUnit}`"
- :value="item.id"
- :key="item.id"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column
- label="包装规格"
- align="center"
- prop="packingSpecificationLabel"
- width="300"
- :show-overflow-tooltip="true"
- >
- <template slot-scope="{ row, $index }">
- <el-tag v-for="item in row.packingSpecificationLabel">{{
- item
- }}</el-tag>
- </template>
- </el-table-column>
- <el-table-column label="允许拆包" prop="isUnpack">
- <template slot-scope="{ row, $index }">
- {{ row.isUnpack == 1 ? '是' : '否' }}
- </template>
- </el-table-column>
- <el-table-column
- label="计量数量"
- align="center"
- prop="measureQuantity"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="计量单位"
- align="center"
- prop="measureUnit"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="单重"
- align="center"
- prop="singleWeight"
- :show-overflow-tooltip="true"
- width="120"
- >
- <template slot-scope="{ row, $index }">
- <template v-if="row.isSave">
- {{ row.singleWeight }}
- </template>
- <el-input-number
- v-else
- v-model="row.singleWeight"
- placeholder="请输入"
- :precision="2"
- :min="0"
- controls-position="right"
- @change="inputsingleWeight(row, $index)"
- :disabled="row.weightUnit == row.packingUnit"
- :controls="false"
- style="width: 100%"
- ></el-input-number>
- <template slot="append">
- {{ row.measureUnit }}
- </template>
- </template>
- </el-table-column>
- <!-- <el-table-column
- label="计价方式"
- align="center"
- prop="pricingWay"
- :show-overflow-tooltip="true"
- width="120"
- >
- <template slot-scope="{ row, $index }">
- <span v-if="row.pricingWay == 1">数量</span>
- <span v-if="row.pricingWay == 2">重量</span>
- </template>
- </el-table-column> -->
- <el-table-column
- label="总重"
- align="center"
- prop="weight"
- width="120"
- :show-overflow-tooltip="true"
- >
- <template slot-scope="{ row, $index }">
- <template v-if="row.isSave">
- {{ row.weight }}
- </template>
- <el-input
- v-else
- v-model="row.weight"
- placeholder="请输入"
- type="number"
- @input="inputWeight(row, $index)"
- :disabled="row.weightUnit == row.packingUnit"
- ></el-input>
- <template slot="append">
- {{ row.measureUnit }}
- </template>
- </template>
- </el-table-column>
- <el-table-column
- label="重量单位"
- align="center"
- prop="weightUnit"
- :show-overflow-tooltip="true"
- >
- <template slot-scope="{ row, $index }">
- {{ row.weightUnit }}
- <template slot="append"> </template>
- </template>
- </el-table-column>
- <el-table-column
- label="生产要求"
- align="center"
- width="200"
- prop="productionRequirements"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column label="机型" prop="modelKey" width="300">
- <template slot-scope="{ row, $index }">
- <DictSelection
- dictName="物品机型"
- clearable
- v-model="row.modelKey"
- :isOne="$index == 1"
- multiple
- filterable
- allow-create
- default-first-option
- >
- </DictSelection>
- </template>
- </el-table-column>
- <el-table-column label="颜色" prop="colorKey" width="300">
- <template slot-scope="{ row, $index }">
- <DictSelection
- dictName="物品颜色"
- clearable
- v-model="row.colorKey"
- :isOne="$index == 1"
- multiple
- filterable
- allow-create
- default-first-option
- >
- </DictSelection>
- </template>
- </el-table-column>
- <!-- <el-table-column label="单价" prop="unitPrice" width="200" align="center">
- <template slot-scope="{ row, $index }">
- <template v-if="row.isSave">
- <span>{{ row.unitPrice }}</span>
- <span v-if="row.unitPrice">/元</span>
- </template>
- <el-form-item v-else>
- <el-input type="number" :ref="'unitPrice' + $index" @keyup.native="
- moveFocus($event, $index, 'unitPrice', '产品', row)
- " v-model.number="row.unitPrice" placeholder="非必填" @input="
- (value) =>
- (row.unitPrice = value.replace(/[^0-9.]+/g, ''))
- ">
- <template slot="append">
- <span v-if="row.unitPrice">/元</span>
- </template>
- </el-input>
- </el-form-item>
- </template>
- </el-table-column> -->
- <!-- <el-table-column label="金额" align="center" prop="totalMoney" :show-overflow-tooltip="true">
- <template slot-scope="{ row, $index }">
- {{
- changeCount(
- calcSumTotal(row.measureQuantity, row.unitPrice, row)
- )
- }}
- </template>
- </el-table-column> -->
- <el-table-column
- label="供应商"
- align="center"
- prop="supplierId"
- width="200"
- :show-overflow-tooltip="true"
- >
- <template slot-scope="{ row, $index }">
- <template v-if="row.isSave || row.supplierId">
- {{ row.supplierName }}
- </template>
- <el-select
- v-else
- @change="selectSupplier($event, row)"
- v-model="row.supplierId"
- placeholder="请选择"
- :clearable="true"
- >
- <el-option
- v-for="item in row.supplierListOptions"
- :label="item.name"
- :value="item.id"
- :key="item.id"
- >
- </el-option>
- </el-select>
- </template>
- </el-table-column>
- <el-table-column
- label="供应商代号"
- align="center"
- prop="supplierCode"
- width="120"
- :show-overflow-tooltip="true"
- >
- <template slot-scope="{ row, $index }">
- {{ row.supplierCode }}
- </template>
- </el-table-column>
- <!-- <el-table-column v-else-if="bizType == 2" label="供应商代号" align="center" prop="supplierMark" width="120"
- :show-overflow-tooltip="true">
- <template slot-scope="{ row, $index }">
- {{ row.supplierMark }}
- </template>
- </el-table-column> -->
- <el-table-column
- label="产地"
- align="center"
- prop="provenance"
- v-if="bizType == 2"
- :show-overflow-tooltip="true"
- width="120"
- >
- <template slot-scope="{ row, $index }">
- {{
- row.provenance &&
- row.provenance
- .map((item) => getDictValue('产地', item))
- .join(',')
- }}
- </template>
- </el-table-column>
- <el-table-column
- label="仓库"
- align="center"
- prop="warehouseName"
- :show-overflow-tooltip="true"
- width="300"
- >
- <template slot-scope="{ row, $index }">
- <el-form-item
- :prop="`productList.${$index}.warehouseId`"
- required
- >
- <div
- :class="
- row.warehouseName
- ? 'wareHouse_style'
- : 'wareHouse_style red_color'
- "
- @click="handleWareHouse(row, $index)"
- >
- <span>
- {{
- row.warehouseName ? row.warehouseName : '请选择仓库'
- }}
- </span>
- </div>
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column
- label="采购原因"
- align="center"
- width="200"
- prop="purpose"
- :show-overflow-tooltip="true"
- >
- <template slot-scope="{ row, $index }">
- <template v-if="row.isSave">
- {{ row.purpose }}
- </template>
- <el-input
- v-else
- :ref="'purpose' + $index"
- @keyup.native="
- moveFocus($event, $index, 'purpose', '产品', row)
- "
- v-model="row.purpose"
- >
- </el-input>
- </template>
- </el-table-column>
- <el-table-column
- label="是否质检"
- align="center"
- width="80"
- prop="qualityControl"
- :show-overflow-tooltip="true"
- v-if="bizType != 1 && bizType != 6 && bizType != 9"
- >
- <template slot-scope="{ row, $index }">
- {{
- row.qualityControl == 1
- ? '是'
- : row.qualityControl == 0
- ? '否'
- : ''
- }}
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- label="生产日期"
- prop="detailProductionDate"
- width="220"
- >
- <template slot-scope="{ row, $index }">
- <template v-if="row.isSave">
- {{ row.detailProductionDate }}
- </template>
- <el-date-picker
- v-else
- :disabled="row.isPack"
- size="small"
- v-model="row.detailProductionDate"
- type="datetime"
- value-format="yyyy-MM-dd HH:mm:ss"
- placeholder="选择日期"
- >
- </el-date-picker
- ></template>
- </el-table-column>
- <el-table-column
- align="center"
- label="采购日期"
- prop="detailPurchaseDate"
- width="220"
- >
- <template slot-scope="{ row, $index }">
- <template v-if="row.isSave">
- {{ row.detailPurchaseDate }}
- </template>
- <el-date-picker
- v-else
- :disabled="row.isPack"
- size="small"
- v-model="row.detailPurchaseDate"
- type="datetime"
- value-format="yyyy-MM-dd HH:mm:ss"
- placeholder="选择日期"
- >
- </el-date-picker
- ></template>
- </el-table-column>
- <el-table-column
- align="center"
- label="失效日期"
- prop="detailExpireDate"
- width="220"
- >
- <template slot-scope="{ row, $index }">
- <template v-if="row.isSave">
- {{ row.detailExpireDate }}
- </template>
- <el-date-picker
- v-else
- :disabled="row.isPack"
- size="small"
- v-model="row.detailExpireDate"
- type="datetime"
- value-format="yyyy-MM-dd HH:mm:ss"
- placeholder="选择日期"
- >
- </el-date-picker
- ></template>
- </el-table-column>
- <el-table-column
- label="操作"
- width="200"
- fixed="right"
- align="center"
- >
- <template slot="header" slot-scope="scope"> 操作 </template>
- <template slot-scope="{ row, $index }">
- <el-button
- type="text"
- v-show="!row.isSave"
- @click="listSave(row, $index)"
- >保存</el-button
- >
- <el-button
- type="text"
- v-show="row.isSave"
- @click="listEdit(row, $index)"
- >编辑</el-button
- >
- <el-button type="text" @click="listDel(row, $index)"
- >删除</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- </el-form>
- </div>
- </div>
- <div v-if="showPackingList.length > 0" class="inbound_details">
- <header-title :title="`包装明细`">
- <div class="switch_right">
- <el-button
- style="margin-left: 20px"
- type="text"
- @click="dateSetting('productionDate')"
- >批量设置生产日期</el-button
- >
- <el-button
- style="margin-left: 20px"
- type="text"
- @click="dateSetting('purchaseDate')"
- >批量设置采购日期</el-button
- >
- <el-button
- style="margin-left: 20px"
- type="text"
- @click="dateSetting('expireDate')"
- >批量设置失效日期</el-button
- >
- </div>
- </header-title>
- <el-table
- v-if="isWrapTable"
- ref="packingListTable"
- :data="showPackingList"
- tooltip-effect="dark"
- :key="formData.bizType"
- :header-cell-style="rowClass"
- style="width: 100%"
- border
- stripe
- :max-height="300"
- v-el-table-infinite-scroll="pickingHandleScroll"
- @selection-change="handleSelectionChange"
- >
- <el-table-column type="selection" align="center" width="50">
- </el-table-column>
- <el-table-column label="序号" type="index" width="50" fixed="left">
- </el-table-column>
- <el-table-column
- label="编码"
- prop="categoryCode"
- width="130"
- :show-overflow-tooltip="true"
- fixed="left"
- ></el-table-column>
- <el-table-column
- label="名称"
- prop="categoryName"
- width="150"
- :show-overflow-tooltip="true"
- fixed="left"
- ></el-table-column>
- <el-table-column
- label="批次号"
- prop="batchNo"
- width="100"
- ></el-table-column>
- <el-table-column
- :label="`包装编码`"
- prop="packageNo"
- width="200"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="包装数量"
- prop="packingQuantity"
- width="80"
- ></el-table-column>
- <el-table-column label="单位" prop="packingUnit"></el-table-column>
- <el-table-column
- label="计量数量"
- prop="measureQuantity"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="计量单位"
- prop="measureUnit"
- ></el-table-column>
- <!-- <el-table-column label="允许拆包" prop="isUnpack">
- <template slot-scope="{ row, $index }">
- {{ row.isUnpack ? '是' : '否' }}
- </template>
- </el-table-column> -->
- <el-table-column
- label="仓库"
- :show-overflow-tooltip="true"
- prop="warehouseName"
- width="200"
- ></el-table-column>
- <el-table-column
- label="物料代号"
- prop="materielDesignation"
- width="130"
- >
- <template slot-scope="{ row, $index }">
- <el-input
- v-if="!row.isPack"
- :ref="'packing_materielDesignation' + $index"
- @keyup.native="
- moveFocus(
- $event,
- $index,
- 'packing_materielDesignation',
- '包装',
- row
- )
- "
- v-model="row.materielDesignation"
- ></el-input>
- <span v-else>{{ row.materielDesignation }}</span>
- </template>
- </el-table-column>
- <el-table-column label="客户代号" prop="clientCode" width="130">
- <template slot-scope="{ row, $index }">
- <el-input
- v-if="!row.isPack"
- :ref="'packing_clientCode' + $index"
- @keyup.native="
- moveFocus($event, $index, 'packing_clientCode', '包装', row)
- "
- v-model="row.clientCode"
- ></el-input>
- <span v-else> {{ row.clientCode }}</span>
- </template>
- <!-- <template slot-scope="{ row, $index }" v-if="bizType == 2">
- <el-input v-if="!row.isPack" :ref="'packing_clientCode' + $index" @keyup.native="
- moveFocus($event, $index, 'packing_clientCode', '包装', row)
- " v-model="row.customerMark"></el-input>
- <span v-else> {{ row.customerMark }}</span>
- </template> -->
- </el-table-column>
- <el-table-column label="牌号" prop="brandNum" width="80">
- </el-table-column>
- <el-table-column
- label="发货条码"
- prop="barcodes"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="供应商"
- align="center"
- prop="supplierName"
- width="120"
- :show-overflow-tooltip="true"
- >
- </el-table-column>
- <el-table-column
- label="供应商代号"
- align="center"
- prop="supplierCode"
- width="120"
- :show-overflow-tooltip="true"
- >
- <template slot-scope="{ row, $index }">
- {{ row.supplierCode }}
- </template>
- </el-table-column>
- <!-- <el-table-column v-else-if="bizType == 2" label="供应商代号" align="center" prop="supplierMark" width="120"
- :show-overflow-tooltip="true">
- <template slot-scope="{ row, $index }">
- {{ row.supplierMark }}
- </template>
- </el-table-column> -->
- <el-table-column label="序列号" prop="engrave" width="140">
- <template slot-scope="{ row, $index }">
- <span> {{ row.productSequence }}</span>
- </template>
- </el-table-column>
- <el-table-column label="刻码" prop="engrave" width="140">
- <template slot-scope="{ row, $index }">
- <el-input
- v-if="!row.isPack"
- :ref="'packing_engrave' + $index"
- @keyup.native="
- moveFocus($event, $index, 'packing_engrave', '包装', row)
- "
- v-model="row.engrave"
- ></el-input>
- <span v-else>{{ row.engrave }}</span>
- </template>
- </el-table-column>
- <el-table-column label="重量" prop="weight" width="100">
- <template slot-scope="{ row, $index }">
- <el-input
- v-if="!row.isPack && row.measureUnit != row.weightUnit"
- :ref="'packing_weight' + $index"
- @keyup.native="
- moveFocus($event, $index, 'packing_weight', '包装', row)
- "
- v-model.number="row.weight"
- @input="weightInput($event, row, '包装')"
- ></el-input>
- <span v-else>{{ row.weight }}</span>
- </template>
- </el-table-column>
- <el-table-column label="重量单位" prop="weightUnit">
- <template slot-scope="{ row }">
- {{ row.weightUnit }}
- </template>
- </el-table-column>
- <el-table-column label="机型" prop="modelKey" width="300">
- <template slot-scope="{ row, $index }">
- <DictSelection
- dictName="物品机型"
- clearable
- v-model="row.modelKey"
- :isOne="$index == 1"
- multiple
- filterable
- allow-create
- default-first-option
- >
- </DictSelection>
- </template>
- </el-table-column>
- <el-table-column label="颜色" prop="colorKey" width="300">
- <template slot-scope="{ row, $index }">
- <DictSelection
- dictName="物品颜色"
- clearable
- v-model="row.colorKey"
- :isOne="$index == 1"
- multiple
- filterable
- allow-create
- default-first-option
- >
- </DictSelection>
- </template>
- </el-table-column>
- <el-table-column label="序列号" prop="serialNumber">
- </el-table-column>
- <el-table-column label="质检结果" prop="result" width="120">
- <template slot-scope="{ row }">
- <el-select
- v-if="!row.isPack"
- @change="changeWrapStatus($event, row, '包装')"
- v-model="row.result"
- placeholder="请选择"
- >
- <el-option
- v-for="item in qualityResultsOptions"
- :label="item.label"
- :value="item.value"
- :key="item.value"
- >
- </el-option>
- </el-select>
- <span v-else>{{ qualityResults[row.result] }}</span>
- </template>
- </el-table-column>
- <el-table-column label="质检状态" prop="status" width="120">
- <template slot-scope="{ row }">
- <span>{{ qualityStatus[row.status] }}</span>
- </template>
- </el-table-column>
- <el-table-column
- label="是否质检"
- align="center"
- width="80"
- prop="qualityControl"
- :show-overflow-tooltip="true"
- v-if="bizType != 1 && bizType != 6 && bizType != 9"
- >
- <template slot-scope="{ row, $index }">
- {{
- row.qualityControl == 1
- ? '是'
- : row.qualityControl == 0
- ? '否'
- : ''
- }}
- </template>
- </el-table-column>
- <template v-if="formData.bizType == 5">
- <el-table-column
- label="生产日期"
- prop="productionDate"
- width="220"
- ></el-table-column>
- <el-table-column
- label="采购日期"
- prop="purchaseDate"
- width="220"
- ></el-table-column>
- </template>
- <template v-else>
- <el-table-column label="生产日期" prop="productionDate" width="220">
- <template slot-scope="{ row, $index }">
- <el-date-picker
- :disabled="row.isPack"
- size="small"
- v-model="row.productionDate"
- type="datetime"
- value-format="yyyy-MM-dd HH:mm:ss"
- placeholder="选择日期"
- >
- </el-date-picker
- ></template>
- </el-table-column>
- <el-table-column label="采购日期" prop="purchaseDate" width="220">
- <template slot-scope="{ row, $index }">
- <el-date-picker
- :disabled="row.isPack"
- size="small"
- v-model="row.purchaseDate"
- type="datetime"
- value-format="yyyy-MM-dd HH:mm:ss"
- placeholder="选择日期"
- >
- </el-date-picker
- ></template>
- </el-table-column>
- <el-table-column label="失效日期" prop="expireDate" width="220">
- <template slot-scope="{ row, $index }">
- <el-date-picker
- :disabled="row.isPack"
- size="small"
- v-model="row.expireDate"
- type="datetime"
- value-format="yyyy-MM-dd HH:mm:ss"
- placeholder="选择日期"
- >
- </el-date-picker
- ></template>
- </el-table-column>
- </template>
- <!-- <el-table-column label="生产日期" prop="" width="220">
- <template slot="header" slot-scope="scope">
- <el-select filterable v-model="curDateType">
- <el-option value="productionDate" label="生产日期"></el-option>
- <el-option value="purchaseDate" label="采购日期"></el-option>
- </el-select>
- </template>
- <template slot-scope="{ row }">
- <template v-if="formData.bizType == 5">
- {{ row[curDateType] }}
- </template>
- <el-date-picker
- v-else
- :disabled="row.isPack"
- size="small"
- v-model="row[curDateType]"
- type="datetime"
- value-format="yyyy-MM-dd HH:mm:ss"
- placeholder="选择日期"
- >
- </el-date-picker>
- </template>
- </el-table-column> -->
- <!-- <el-table-column label="操作" width="120" fixed="right">
- <template slot-scope="{ row, $index }">
- <el-button type="text" @click="wrapDelete(row, $index)">
- 删除
- </el-button>
- </template>
- </el-table-column> -->
- </el-table>
- </div>
- <div v-if="showMaterialList.length > 0" class="inbound_details">
- <!-- <header-title :title="`物料明细`"></header-title> -->
- <!-- <el-table ref="materialListTable" :data="showMaterialList" tooltip-effect="dark" :key="formData.bizType"
- :header-cell-style="rowClass" style="width: 100%" border stripe :max-height="300"
- v-el-table-infinite-scroll="materielHandleScroll">
- <el-table-column label="序号" type="index" width="50">
- </el-table-column>
- <el-table-column label="编码" prop="categoryCode" width="130" :show-overflow-tooltip="true"></el-table-column>
- <el-table-column label="名称" prop="categoryName" width="150" :show-overflow-tooltip="true"></el-table-column>
- <el-table-column label="批次号" prop="batchNo" width="70"></el-table-column>
- <el-table-column label="物料编码" prop="materialCode" width="200" :show-overflow-tooltip="true"></el-table-column>
- <el-table-column label="计量数量" prop="measureQuantity" width="90"
- :show-overflow-tooltip="true"></el-table-column>
- <el-table-column width="80" label="计量单位" prop="measureUnit"></el-table-column>
- <el-table-column label="物料代号" prop="materielDesignation" width="130">
- <template slot-scope="{ row, $index }">
- <el-input v-if="!row.isPack" :ref="'material_materielDesignation' + $index" @keyup.native="
- moveFocus(
- $event,
- $index,
- 'material_materielDesignation',
- '物料',
- row
- )
- " v-model="row.materielDesignation"></el-input>
- <span v-else>{{ row.materielDesignation }}</span>
- </template>
- </el-table-column>
- <el-table-column label="客户代号" prop="clientCode">
- <template slot-scope="{ row, $index }">
- <el-input v-if="!row.isPack" :ref="'material_clientCode' + $index" @keyup.native="
- moveFocus($event, $index, 'material_clientCode', '物料', row)
- " v-model="row.clientCode"></el-input>
- <span v-else>{{ row.clientCode }}</span>
- </template>
- </el-table-column>
- <el-table-column label="刻码" prop="engrave" width="140">
- <template slot-scope="{ row, $index }">
- <el-input v-if="!row.isPack" :ref="'material_engrave' + $index" @keyup.native="
- moveFocus($event, $index, 'material_engrave', '物料', row)
- " v-model="row.engrave"></el-input>
- <span v-else>{{ row.engrave }}</span>
- </template>
- </el-table-column>
- <el-table-column label="重量" prop="weight" width="100">
- <template slot-scope="{ row, $index }">
- <el-input v-if="!row.isPack && row.measureUnit != row.weightUnit" :ref="'material_weight' + $index"
- @keyup.native="
- moveFocus($event, $index, 'material_weight', '物料', row)
- " @input="weightInput($event, row, '物料')" v-model.number="row.weight"></el-input>
- <span v-else>{{ row.weight }}</span>
- </template>
- </el-table-column>
- <el-table-column label="重量单位" prop="weightUnit" width="100"></el-table-column>
- <el-table-column label="质检结果" prop="result" width="120">
- <template slot-scope="{ row }">
- <el-select v-if="!row.isPack" @change="changeWrapStatus($event, row, '物料')" v-model="row.result"
- placeholder="请选择">
- <el-option v-for="item in qualityResultsOptions" :label="item.label" :value="item.value"
- :key="item.value">
- </el-option>
- </el-select>
- <span v-else>{{ qualityResults[row.result] }}</span>
- </template>
- </el-table-column>
- <el-table-column label="质检状态" prop="status" width="120">
- <template slot-scope="{ row }">
- <span>{{ qualityStatus[row.status] }}</span>
- </template>
- </el-table-column>
- </el-table> -->
- </div>
- </el-card>
- <!-- 产品选择弹框 -->
- <selectType
- :visibleDialog.sync="visibleDialog"
- :title="title"
- :treeIds="formData.extInfo.assetType"
- :loadTree.sync="loadTree"
- @selectTableData="addGoods"
- />
- <!-- 仓库选择弹框 -->
- <WarehousingDialog
- ref="wareHouseDailogRef"
- @selection="wareHouseSelection"
- ></WarehousingDialog>
- <!-- 包装负责人 -->
- <head-list ref="headRef" @changeParent="changeHead"></head-list>
- <!-- 生产日期、采购日期弹框 -->
- <el-dialog
- :visible.sync="dateVisible"
- title="选择日期"
- width="400px"
- append-to-body
- >
- <el-date-picker
- size="small"
- v-model="batchTime"
- type="datetime"
- style="width: 320px"
- value-format="yyyy-MM-dd HH:mm:ss"
- placeholder="选择日期"
- >
- </el-date-picker>
- <div style="text-align: right; margin-top: 20px">
- <el-button @click="dateVisible = false">取消</el-button>
- <el-button type="primary" @click="dateConfirm" :disabled="!batchTime"
- >确认</el-button
- >
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import elTableInfiniteScroll from 'el-table-infinite-scroll';
- import storageApi from '@/api/warehouseManagement/index.js';
- import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition.js';
- import WarehousingDialog from './components/WarehousingDialog.vue';
- import { getCode } from '@/api/codeManagement/index.js';
- import selectType from './components/selectType_new.vue';
- import {
- sceneState,
- qualityResultsOptions,
- qualityResults,
- qualityStatus
- } from '@/utils/dict/index';
- import { getTreeByGroup } from '@/api/classifyManage';
- import { deepClone } from '@/utils';
- import { mapActions, mapGetters } from 'vuex';
- import BigNumber from 'bignumber.js';
- import headList from '@/components/headList';
- // import dictMixins from '@/mixins/dictMixins';
- export default {
- components: {
- selectType,
- WarehousingDialog,
- headList
- },
- // mixins: [dictMixins],
- // 虚拟列表滚动方法
- directives: {
- 'el-table-infinite-scroll': elTableInfiniteScroll
- },
- props: {
- form: { type: Object, default: () => {} },
- bizType: { type: Number, default: 1 },
- sourceBizNo: { type: String, default: '' },
- detailList: { type: Array, default: () => [] },
- saleProductList: { type: Array, default: () => [] },
- detailProductList: { type: Array, default: () => [] },
- isMoreProduct: { type: Boolean, default: false }, //多产品包装明细
- processInstance: { type: Object, default: () => {} },
- isShowPackage: { type: Boolean, default: false } //售后退货单仓管审批显示
- },
- data() {
- return {
- newColumns: [], // 动态表头
- sceneState,
- saveLoading: false,
- dateVisible: false,
- loadTree: true,
- visibleDialog: false,
- title: '选择产品',
- goodsLists: [],
- formData: {
- bizType: '',
- storageTime: '',
- qualityControl: '',
- extInfo: {
- assetType: []
- }
- },
- rules: {
- 'extInfo.assetType': {
- required: true,
- message: '请选择物品类型',
- trigger: 'blur'
- },
- bizType: {
- required: true,
- message: '请选择入库场景',
- trigger: 'change'
- },
- storageTime: {
- required: true,
- message: '请选择入库时间',
- trigger: 'change'
- }
- },
- qualityResultsOptions, // 质检结果选项
- qualityStatus, // 质检状态 0未检 1已检
- qualityResults, // 质检结果 0无 1合格 2不合格
- productList: [], // 产品列表
- packingList: [], // 包装列表
- showPackingList: [], // 包装列表(虚拟列表)
- materialList: [], // 物料列表
- showMaterialList: [], // 物料列表(虚拟列表)
- curDateType: 'productionDate',
- packingListSelected: [], // 包装选择列表
- isWrapTable: true, // 解决表格不刷新问题(包装)
- currentPackingQuantity: '', // 当前包装数量
- batchTime: '', // 生产日期、采购日期
- pageSize: 20, // 物料和包装列表条数
- pickingPageNum: 1, // 包装虚拟分页页数
- materielPageNum: 1 // 物料虚拟分页页数
- };
- },
- computed: {
- ...mapGetters(['dict', 'getDict', 'getDictValue']),
- clientEnvironmentId() {
- return this.$store.state.user.info.clientEnvironmentId;
- }
- },
- watch: {
- packingList: {
- handler(newVal) {
- console.log(newVal);
- this.showPackingList = newVal.slice(
- 0,
- this.pageSize * (this.pickingPageNum > 0 ? this.pickingPageNum : 1)
- );
- this.showPackingList.forEach((obj) => {
- console.log(obj, '666666666');
- obj.workOrderId = this.detailProductList[0]?.workOrderId;
- obj.taskId = this.detailProductList[0]?.taskId;
- obj.outsourceBatchNo = this.detailProductList[0]?.batchNo;
- obj.outsourceCode = this.detailProductList[0]?.sourceCode;
- obj.taskId = this.detailList[0]?.taskId;
- obj.workOrderId = this.detailList[0]?.workOrderId;
- });
- this.pickingPageNum = Math.ceil(
- this.showPackingList.length / this.pageSize
- );
- },
- deep: true
- },
- materialList: {
- handler(newVal) {
- this.showMaterialList = newVal.slice(
- 0,
- this.pageSize *
- (this.materielPageNum > 0 ? this.materielPageNum : 1)
- );
- },
- deep: true
- }
- // detailList: {
- // handler(newVal) {
- // if (newVal.length) {
- // this.initFormData();
- // }
- // },
- // deep: true
- // },
- },
- async created() {
- await this.requestDict('产地');
- await this.requestDict('不拆物料层规格');
- await this.getFieldModel();
- await this.getListItems();
- await this.initFormData();
- await this.getNowFormatDate();
- },
- methods: {
- ...mapActions('dict', ['requestDict']),
- // 通过挂起状态设置行样式
- tableRowClassName({row}) {
- // console.log('tableRowClassName', row)
- if (row.isReversal == 1) {
- return 'warning-row';
- }
- return '';
- },
- handleRowClick(row) {
- // this.current = row;
- console.log('handleRowClick', row)
- if (row.isReversal == 1) {
- this.$alert(`替代批次号:${row.suspendOrReverseDetail[0].batchNo}`, {
- confirmButtonText: '知道了',
- type: 'none'
- }).catch(() => {
- // 捕获用户取消操作时的Promise rejection
- });
- }
- },
- changeCount(number) {
- return new BigNumber(number).toString();
- },
- selectSupplier(val, row) {
- row.supplierId = val;
- row.supplierName = row.supplierListOptions.filter(
- (item) => item.id == val
- )[0]?.name;
- row.supplierCode = row.supplierListOptions.filter(
- (item) => item.id == val
- )[0].serialNo;
- },
- inputsingleWeight(row, index) {
- if (row.measureUnit == row.weightUnit) {
- row.weight = row.singleWeight * row.packingQuantity;
- row.measureQuantity = row.weight;
- } else {
- row.weight = row.singleWeight * row.measureQuantity;
- }
- },
- inputWeight(row, index) {
- if (row.measureUnit == row.weightUnit) {
- row.measureQuantity = row.weight;
- row.singleWeight =
- Math.trunc((row.measureQuantity / row.packingQuantity) * 100) / 100;
- } else {
- row.singleWeight = row.measureQuantity
- ? row.weight / row.measureQuantity
- : 0;
- }
- },
- // 计算最小单元数量
- async computeNum(row, index, isClear) {
- console.log('row, index', row, index);
- let data = row.packingSpecificationOption.find(
- (item) => item.id == row.packingUnitId
- );
- row.packingUnit = data.conversionUnit;
- // 清空仓库(包装数量输入)
- if (isClear) {
- if (row.packingQuantity < 0) {
- this.$set(this.productList[index], 'packingQuantity', 1);
- } else if (row.packingQuantity > 9999) {
- this.$set(this.productList[index], 'packingQuantity', 9999);
- }
- }
- //如果有包装数量和包装单位
- if (row.packingQuantity && row.packingUnit) {
- //获取仓库
- const res = await warehouseDefinition.list({
- // inventoryType: this.form.categoryLevelTopId
- });
- // 只有一个仓库自动显示出来
- if (res.length == 1) {
- let name = res[0]?.factoryName + '-' + res[0]?.name;
- console.log('仓库-----------------------------', res);
- this.$set(this.productList[index], 'warehouseId', res[0].id);
- this.$set(this.productList[index], 'warehouseName', name);
- let table1 = [];
- table1.push({
- measureQuantity: row.measureQuantity,
- packingQuantity: row.packingQuantity,
- warehouseName: name,
- warehouseId: res[0].id
- });
- this.wareHouseSelection(table1, index);
- } else {
- this.$set(this.productList[index], 'warehouseId', '');
- this.$set(this.productList[index], 'warehouseName', '');
- }
- // -----------------------------------------------------------------
- let startIndex = row.packingSpecificationOption.findIndex((ite) => {
- return (
- row.measuringUnit == ite.packingUnit &&
- ite.packingUnit != ite.conversionUnit
- );
- });
- let endIndex = row.packingSpecificationOption.findIndex(
- (ite) => data.id == ite.id
- );
- console.log(row, 'rowwwwwwwwwwwwww');
- let total = Number(row.packingQuantity);
- console.log(total, '111');
- if (
- row.packingUnit == row.measureUnit &&
- row.measureUnit == '立方' &&
- row.netWeight
- ) {
- total = Number(row.packingQuantity) * row.netWeight;
- console.log(
- total,
- '单位是立方,计量单位也是立方,如果有单重,就计量数量x单重=总重'
- );
- console.log(total, '2222');
- } else {
- console.log(total, 333);
- for (; 0 < endIndex; endIndex--) {
- total = this.$math.format(
- row.packingSpecificationOption[endIndex].packageCell * total,
- 14
- );
- }
- }
- console.log(total, '444456');
- //计量数量
- row.measureQuantity = this.changeCount(total);
- // 判断单位和计量单位是否为不拆物料层规格
- let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
- .dictValue;
- let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
- .dictValue;
- console.log(packingBoolen, 'packingBoolen');
- console.log(measureBoolen, 'measureBoolen');
- if (packingBoolen && measureBoolen && row.packingUnit != 'L') {
- row.weight = total;
- console.log(total, '6');
- }
- let weight = 0;
- if (row.measureUnit == row.weightUnit) {
- weight = row.measureQuantity;
- // 如果重量单位和包装单位一致,则单重0
- if (row.weightUnit == row.packageUnit) {
- row.singleWeight = 0;
- } else {
- row.singleWeight =
- Math.trunc((row.measureQuantity / row.packingQuantity) * 100) /
- 100;
- }
- } else if (row.singleWeight) {
- weight = row.measureQuantity * Number(row.singleWeight);
- }
- this.$set(this.productList[index], 'weight', weight);
- }
- },
- // 获取动态表头
- getFieldModel() {
- storageApi.fieldModel({ fieldModel: 't_main_category' }).then((res) => {
- let newRes = res.map((m) => {
- return {
- prop: 'extField.' + m.prop,
- label: m.label,
- align: 'center',
- showOverflowTooltip: true
- };
- });
- this.newColumns = [...newRes];
- });
- },
- // 初始化信息
- async initFormData() {
- console.log(this.form, 'form');
- console.log(this.formData, 'formData');
- console.log(this.sourceBizNo, 'sourceBizNo');
- this.formData.type = 1;
- this.formData.bizType = this.bizType;
- if (this.sourceBizNo != null || this.sourceBizNo != '') {
- // this.formData.sourceBizNo = this.sourceBizNo;
- this.$set(this.formData, 'sourceBizNo', this.sourceBizNo);
- } else {
- this.$message.warning('未获取到单据来源!');
- }
- // 入库登记人
- // this.formData.extInfo.createUserId = this.$store.state.user.info.userId;
- // this.formData.extInfo.createUserName = this.$store.state.user.info.name;
- // this.formData.extInfo.deliveryPhone = this.$store.state.user.info.phone;
- // this.formData.createUserId = this.$store.state.user.info.userId;
- // this.formData.extInfo.deptName = this.$store.state.user.info.deptName;
- // 入库登记人
- // const startUser = this.processInstance?.startUser || {};
- const userInfo = this.$store.state.user.info || {};
- // 确保所有值都是原始类型,防止对象被绑定到DOM属性
- this.formData.extInfo.createUserId =
- this.form.createUserId || userInfo.userId || '';
- this.formData.extInfo.createUserName =
- this.form.createUserName || userInfo.name || '';
- this.formData.extInfo.deliveryPhone = userInfo.phone || '';
- this.formData.createUserId =
- this.form.createUserId || userInfo.userId || '';
- this.formData.createUserName =
- this.form.createUserName || userInfo.name || '';
- this.formData.extInfo.deptName =
- this.form.deptName || userInfo.deptName || '';
- this.formData.approvalUserName =
- this.form.approvalUserName || userInfo.name;
- this.formData.approvalUserId =
- this.form.approvalUserId || userInfo.userId;
- // this.formData.extInfo.supplierName = this.form.supplierName;
- // this.formData.extInfo.supplierId = this.form.supplierId;
- console.log('saleProductList-------------------', this.saleProductList);
- if (this.saleProductList?.length > 0) {
- let detailPurchaseDate;
- if (this.formData.bizType == '2' || this.formData.bizType == '10') {
- // 采购入库
- const defaultTime = '00:00:00';
- detailPurchaseDate =
- this.form.purchaseDate ||
- `${this.form.receiveDate} ${defaultTime}`;
- }
- // 物品列表
- let codeList = this.saleProductList.map((item) => {
- return item.productCode || item.categoryCode;
- });
- storageApi.getListByNameOrModeType({ codeList }).then(async (res) => {
- if (res.length <= 0) {
- this.$message.warning('未获取到物品信息!');
- return;
- }
- this.formData.extInfo.assetType = Array.from(
- new Set(res.map((item) => item.categoryLevelPathIdParent))
- );
- console.log(this.formData.extInfo.assetType, '类型类型');
- // 获取批次号
- const batchNo1 = await getCode('lot_number_code');
- // 获取供应商
- const supplierList = await storageApi.contactQueryByCategoryIdsAPI({
- categoryIds: res.map((item) => item.id)
- });
- // 获取包装规格
- let packingSpecification =
- await storageApi.getCategoryPackageDisposition({
- categoryIds: res.map((item) => item.id)
- });
- console.log(packingSpecification);
- this.packingSpecificationOption = res.map((item) => {
- return packingSpecification
- .filter((ite) => item.id == ite.categoryId)
- .sort((a, b) => a.sort - b.sort);
- });
- this.productList = res.map((item, index) => {
- let filtersItem = this.saleProductList.find(
- (detailItem) =>
- item.code == detailItem.productCode ||
- item.code == detailItem.categoryCode
- );
- // let filtersItem = this.saleProductList.filter(
- // (detailItem) =>
- // detailItem.productCode || detailItem.categoryCode == item.code
- // )[0];
- // 显示规格
- let packingSpecificationLabel = this.packingSpecificationOption[
- index
- ]
- .map((item) => {
- if (item.sort > 0) {
- return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
- }
- })
- .filter((item) => !!item);
- const newSpecificationOption = this.getNewSpecificationOption(
- this.packingSpecificationOption
- );
- console.log(newSpecificationOption, '啵啵啵啵啵啵啵啵啵啵啵啵2');
- console.log(filtersItem, 'filtersItemfiltersItemfiltersItem');
- let warehouseId = filtersItem.warehouseId;
- let warehouseName = filtersItem.warehouseName;
- let measureQuantity =
- filtersItem.totalCountNew || filtersItem.totalCount || 0;
- // let measureQuantityOld = filtersItem.totalCount || 0;
- if (
- (filtersItem.sendTotalWeight ||
- filtersItem.receiveTotalWeight) &&
- item.weightUnit == item.measuringUnit
- ) {
- measureQuantity =
- filtersItem.sendTotalWeight || filtersItem.receiveTotalWeight;
- }
- let packingQuantity =
- filtersItem.totalCountNew ||
- filtersItem.purchaseCount ||
- filtersItem.totalCount ||
- 0;
- console.log(packingQuantity,'packingQudasdasdantity')
- let packingUnit =
- filtersItem.purchaseUnit || filtersItem.measuringUnit || '';
- let unitPrice = filtersItem.singlePrice || 0;
- let pricingWay = filtersItem.pricingWay || '';
- let singleWeight =
- filtersItem.singleWeight ||
- this.detailProductList[0]?.singleWeight ||
- 0;
- let weight =
- filtersItem.sendTotalWeight ||
- filtersItem.receiveTotalWeight ||
- singleWeight * measureQuantity;
- console.log(weight, 'weight');
- // if(weight){
- // }
- // 获取相同仓库
- let warehouseIds = [];
- let warehouseNames = [];
- for (let i = 0; i < filtersItem.totalCount; i++) {
- warehouseIds.push(filtersItem.warehouseId);
- warehouseNames.push(filtersItem.warehouseName);
- }
- let totalMoney = filtersItem.totalPrice || 0;
- console.log(
- filtersItem,
- 'filtersItemfiltersItemfiltersItemfiltersItemfiltersItem'
- );
- let batchNo = '';
- if (filtersItem.batchNo) {
- batchNo = filtersItem.batchNo;
- } else {
- batchNo = batchNo1;
- }
- return {
- index: this.productList.length + index,
- categoryId: item.id, // 物品id
- categoryName: item.name, // 物品名称
- categoryCode: item.code, // 物品编码
- categoryModel: item.modelType, // 物品型号
- specification: item.specification, // 规格
- brandNum: item.brandNum, // 牌号
- batchNo: batchNo, // 批次号
- supplierListOptions: supplierList[item.id], // 供应商列表
- supplierId: this.form.supplierId, // 供应商id
- productionRequirements: filtersItem.productionRequirements, //生产要求
- supplierCode:
- this.bizType == 2 || this.bizType == 7
- ? filtersItem.supplierMark
- : item.supplierCode, // 供应商代号
- supplierName: this.form.supplierName, // 供应商名称
- approvalNumber: item.approvalNumber, // 批准文号
- packingSpecification: item.packingSpecification, // 包装规格
- packingSpecificationOption: newSpecificationOption[index], // 包装规格选项
- packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
- // minPackingQuantity: minPackingQuantity, // 最小包装单元数量
- packingQuantity:
- this.saleProductList[index] &&
- this.saleProductList[index].isAllPackageData &&
- this.saleProductList[index].isAllPackageData == 1
- ? this.saleProductList[index].packingCount
- : packingQuantity, // 包装数量
- packingUnit:
- this.saleProductList[index] &&
- this.saleProductList[index].isAllPackageData &&
- this.saleProductList[index].isAllPackageData == 1
- ? this.saleProductList[index].packingUnit
- : packingUnit, // 单位
- measureQuantity:
- this.saleProductList[index] &&
- this.saleProductList[index].isAllPackageData &&
- this.saleProductList[index].isAllPackageData == 1
- ? this.saleProductList[index].quantity
- : measureQuantity, // 计量数量
- // measureQuantityOld,
- measureUnit:
- this.saleProductList[index] &&
- this.saleProductList[index].isAllPackageData &&
- this.saleProductList[index].isAllPackageData == 1
- ? this.saleProductList[index].measuringUnit
- : item.measuringUnit, // 计量单位
- packingUnitId:
- filtersItem.purchaseUnitId || filtersItem.saleUnitId,
- modelKey: filtersItem.modelKey
- ? filtersItem.modelKey.split(',')
- : '', // 机型
- colorKey: filtersItem.colorKey
- ? filtersItem.colorKey.split(',')
- : '', // 颜色
- measureType: item.measureType, // 计量方式
- netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
- singleWeight: singleWeight || 0, // 单重重量
- weight: weight || 0, // 总重量
- weightUnit: item.weightUnit, // 重量单位
- totalMoney: totalMoney, // 总价
- unitPrice: item.unitPrice || unitPrice, // 单价
- pricingWay: pricingWay, //计价方式
- purpose: '', // 用途
- detailPurchaseDate,
- detailExpireDate: this.saleProductList.find(
- (product) => product.productId == item.id
- )?.guaranteePeriodDeadline,
- detailProductionDate: this.saleProductList.find(
- (product) => product.productId == item.id
- )?.productionDate,
- provenance: filtersItem.provenance, //产地
- isUnpack: item.isUnpack, // 是否允许拆包
- warehouseId, // 仓库id
- warehouseName, // 仓库名称
- warehouseIds,
- warehouseNames,
- qualityControl: filtersItem?.isComeCheck // 是否需要质检
- };
- });
- console.log(this.productList, 'this.productListtttttttttttt');
- this.$nextTick(() => {
- this.batchSave();
- // this.listSaveArrs()
- });
- });
- }
- console.log('this.detailList-----------------', this.detailList);
- if (this.detailList?.length > 0) {
- if (
- this.form != null &&
- Object.keys(this.form).length > 0 &&
- this.form.categoryLevelTopId != ''
- ) {
- this.formData.extInfo.assetType = Array.from(
- new Set(this.form?.categoryLevelTopId?.split(','))
- );
- } else {
- this.$message.warning('未获取到物品类型!');
- }
- // 包装列表 this.detailList
- // 获取主数据物品详情
- // let { category } = await getDetails(this.form.categoryId);
- let codeList = this.detailList.map((item) => {
- return item.productCode || item.categoryCode;
- });
- storageApi.getListByNameOrModeType({ codeList }).then(async (res) => {
- console.log(res, 'detailList-res');
- console.log(this.form, 'this.form.warehouseId');
- console.log(this.bizType, 'this.bizType~~~');
- // 获取批次号
- const batchNo = await getCode('lot_number_code');
- // 获取供应商
- const supplierList = await storageApi.contactQueryByCategoryIdsAPI({
- categoryIds: res.map((item) => item.id)
- });
- // 获取包装规格
- let packingSpecification =
- await storageApi.getCategoryPackageDisposition({
- categoryIds: res.map((item) => item.id)
- });
- this.packingSpecificationOption = res.map((item) => {
- return packingSpecification
- .filter((ite) => item.id == ite.categoryId)
- .sort((a, b) => a.sort - b.sort);
- });
- // 获取相同仓库
- let warehouseIds = [];
- let warehouseNames = [];
- console.log(this.form.totalCount, 'this.form.warehouseId');
- for (let index = 0; index < this.form.totalCount; index++) {
- warehouseIds.push(this.form.warehouseId);
- warehouseNames.push(this.form.warehouseName);
- }
- if (this.bizType == 4 || this.bizType == 1) {
- warehouseIds.push(this.form.warehouseId);
- warehouseNames.push(this.form.warehouseName);
- }
- if (this.isMoreProduct) {
- this.formData.extInfo.assetType = [];
- res.map((item) => {
- this.formData.extInfo.assetType.push(
- item.categoryLevelPathIdParent
- );
- });
- this.formData.extInfo.assetType = Array.from(
- new Set(...this.formData.extInfo.assetType)
- );
- }
- const newSpecificationOption = this.getNewSpecificationOption(
- this.packingSpecificationOption
- );
- // 生成产品列表
- this.productList = res.map((item, index) => {
- // 显示规格
- let packingSpecificationLabel = this.packingSpecificationOption[
- index
- ]
- .map((item) => {
- if (item.sort > 0) {
- return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
- }
- })
- .filter((item) => !!item);
- // 换算重量
- let weight = 0;
- if (
- this.form?.weightUnit?.toUpperCase() ==
- item?.weightUnit.toUpperCase()
- ) {
- weight = this.form.totalWeight;
- } else {
- switch (item.weightUnit.toUpperCase()) {
- case 'KG':
- if (this.form.totalWeight > -1) {
- weight = this.$math.format(
- this.form.totalWeight / 1000,
- 14
- );
- } else {
- weight = 0;
- }
- break;
- case 'G':
- if (this.form.totalWeight > -1) {
- weight = this.$math.format(
- this.form.totalWeight * 1000,
- 14
- );
- } else {
- weight = 0;
- }
- break;
- case 'L':
- if (this.form.totalWeight > -1) {
- weight = this.$math.format(
- this.form.totalWeight * 1000,
- 14
- );
- } else {
- weight = 0;
- }
- break;
- case 'l':
- if (this.form.totalWeight > -1) {
- weight = this.$math.format(
- this.form.totalWeight * 1000,
- 14
- );
- } else {
- weight = 0;
- }
- break;
- case 'ML':
- if (this.form.totalWeight > -1) {
- weight = this.$math.format(
- this.form.totalWeight * 1000,
- 14
- );
- } else {
- weight = 0;
- }
- break;
- case 'ml':
- if (this.form.totalWeight > -1) {
- weight = this.$math.format(
- this.form.totalWeight * 1000,
- 14
- );
- } else {
- weight = 0;
- }
- break;
- }
- }
- let packingUnit = item.packingUnit;
- let singleWeight = item.singleWeight || 0; // 单重重量
- return {
- index: this.productList.length + index,
- isSave: true,
- isReversal: this.detailList.find((val) => val.categoryCode == item.code)
- ?.isReversal || item.isReversal || 0, // 是否挂起
- suspendOrReverseDetail: this.detailList.find((val) => val.categoryCode == item.code)
- ?.suspendOrReverseDetail || item.suspendOrReverseDetail || null, // 挂起或反冲详情
- categoryId: item.id, // 物品id
- categoryName: item.name, // 物品名称
- categoryCode: item.code, // 物品编码
- categoryModel: item.modelType, // 物品型号
- specification: item.specification, // 规格
- brandNum: item.brandNum, // 牌号
- batchNo: [1, 3, 6].includes(this.bizType)
- ? this.detailList[0]?.batchNo || batchNo
- : batchNo, // 批次号
- supplierListOptions: supplierList[item.id], // 供应商列表
- supplierId:
- this.detailList.find((val) => val.categoryCode == item.code)
- ?.supplierId || item.supplierId, // 供应商id
- supplierCode:
- this.detailList.find((val) => val.categoryCode == item.code)
- ?.supplierCode || item.supplierCode,
- supplierName:
- this.detailList.find((val) => val.categoryCode == item.code)
- ?.supplierName || item.supplierName, // 供应商名称
- approvalNumber: item.approvalNumber, // 批准文号
- productionRequirements: this.form.productionRequirements,
- packingSpecification: item.packingSpecification, // 包装规格
- packingSpecificationOption: newSpecificationOption[index], // 包装规格选项
- packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
- // minPackingQuantity: 1, // 最小包装单元数量
- packingQuantity: this.isMoreProduct
- ? this.detailList.filter(
- (val) => val.productCode == item.code
- ).length
- : this.detailList.length || this.form.detailList.length, // 包装数量
- packingUnit: packingUnit, // 单位
- measureQuantity: this.isMoreProduct
- ? this.getMeasureQuantity(item.code)
- : this.form.totalCount, // 计量数量
- measureUnit: item.measuringUnit, // 计量单位
- measureType: item.measureType, // 计量方式
- netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
- weight: weight || 0, // 重量
- singleWeight: singleWeight || 0,
- weightUnit: item.weightUnit, // 重量单位
- totalMoney: item.totalPrice, // 总价
- unitPrice: item.unitPrice, // 单价
- purpose: '', // 用途
- isUnpack: item.isUnpack, // 是否允许拆包
- warehouseId: this.isMoreProduct
- ? this.detailList.find((val) => val.productCode == item.code)
- ?.warehouseId
- : this.form.warehouseId, // 仓库id
- warehouseName: this.isMoreProduct
- ? this.detailList.find((val) => val.productCode == item.code)
- ?.warehouseName
- : this.form.warehouseName, // 仓库名称
- warehouseIds: this.isMoreProduct
- ? this.detailList
- .filter((val) => val.productCode == item.code)
- .map((item) => item.warehouseId)
- : warehouseIds,
- warehouseNames: this.isMoreProduct
- ? this.detailList
- .filter((val) => val.productCode == item.code)
- .map((item) => item.warehouseName)
- : warehouseNames
- };
- });
- let getAssetNumPr = this.isMoreProduct
- ? this.detailList.map((val) => {
- return {
- assetCode: val.productCode,
- batchNum: val.productBrand,
- num: 1
- };
- })
- : [
- {
- assetCode:
- this.productList[0].categoryCode +
- this.productList[0].index,
- batchNum: this.productList[0].batchNo,
- num: this.detailList.length
- }
- ];
- console.log(this.productList, 'this.productList');
- console.log(this.detailList, 'this.detailList');
- // 生成包装编码
- const { data } = await storageApi.getAssetNum(getAssetNumPr);
- let packingCodeList = data;
- // 生产包装
- this.packingList = this.detailList.map((item, index) => {
- // if (item.isAllPackageData != 1) {
- console.log(item.packingUnit, 'itemitemitemitemitemitem1');
- console.log(item.packingUnit, 'itemitemitemitemitemitem2');
- // 换算重量
- let weight = 0;
- if (
- this.productList[0].weightUnit.toUpperCase() ==
- item.weightUnit.toUpperCase()
- ) {
- weight = this.form.totalWeight;
- } else {
- switch (this.productList[0].weightUnit.toUpperCase()) {
- case 'KG':
- if (item.weightUnit > -1) {
- weight = this.$math.format(item.weightUnit / 1000, 14);
- } else {
- weight = 0;
- }
- break;
- case 'G':
- if (item.weightUnit > -1) {
- weight = this.$math.format(item.weightUnit * 1000, 14);
- } else {
- weight = 0;
- }
- break;
- case 'L':
- if (item.weightUnit > -1) {
- weight = this.$math.format(item.weightUnit / 1000, 14);
- } else {
- weight = 0;
- }
- break;
- case 'l':
- if (item.weightUnit > -1) {
- weight = this.$math.format(item.weightUnit / 1000, 14);
- } else {
- weight = 0;
- }
- break;
- case 'ML':
- if (item.weightUnit > -1) {
- weight = this.$math.format(item.weightUnit / 1000, 14);
- } else {
- weight = 0;
- }
- break;
- case 'ml':
- if (item.weightUnit > -1) {
- weight = this.$math.format(item.weightUnit / 1000, 14);
- } else {
- weight = 0;
- }
- break;
- }
- }
- // 代入时间
- let obj = this.getNowDate();
- let productionDate = '';
- let purchaseDate = '';
- if (this.formData.bizType == '1') {
- // 生产入库
- productionDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
- // this.curDateType = 'productionDate';
- } else if (this.formData.bizType == '2') {
- // 采购入库
- const defaultTime = '00:00:00';
- purchaseDate =
- this.form.purchaseDate ||
- `${this.form.receiveDate} ${defaultTime}`;
- // this.curDateType = 'purchaseDate';
- }
- let clientCode = '';
- if (this.bizType == 2) {
- clientCode = item.customerMark;
- } else if (this.bizType != 2) {
- clientCode = item.clientCode || item.extInfo?.clientCode;
- }
- return {
- index: this.isMoreProduct
- ? this.productList.find(
- (val) => val.categoryCode == item.productCode
- ).index +
- '-' +
- index
- : this.productList[0].index + '-' + index, // 包装索引
- warehouseId:
- item.warehouseId || this.productList[0].warehouseIds[index], // 仓库id
- warehouseName:
- item.warehouseName ||
- this.productList[0].warehouseNames[index], // 仓库名称
- categoryName:
- item.productName || this.productList[0].categoryName, // 产品名称
- categoryCode:
- item.productCode || this.productList[0].categoryCode, // 产品编码
- categoryModel:
- item.modelType || this.productList[0].categoryModel, // 物品型号
- specification:
- item.specification || this.productList[0].specification, // 规格
- brandNum: item.productBrand || this.productList[0].brandNum, // 牌号
- parentIndex: this.isMoreProduct
- ? this.productList.find(
- (val) => val.categoryCode == item.productCode
- ).index
- : this.productList[0].index, // 产品索引
- batchNo: this.productList[0].batchNo, // 批次号
- packageNo:
- item.packageNo ||
- item.packingCode ||
- packingCodeList[index]?.onlyCode, // 包装编码
- packingQuantity: 1, // 包装数量
- packingUnit: item.packingUnit, // 单位
- measureQuantity: item.quantity || item.measureQuantity, // 计量数量
- measureUnit: item.measuringUnit || item.measureUnit, // 计量单位
- supplierCode: item.supplierCode,
- supplierId: item.supplierId,
- supplierName: item.supplierName,
- weight: item.packingWeight || 0, // 重量
- singleWeight: item.singleWeight || 0,
- pricingWay: item.pricingWay,
- weightUnit: item.weightUnit || this.productList[0].weightUnit, // 重量单位
- packingSpecificationOption: this.isMoreProduct
- ? this.productList.find(
- (val) => val.categoryCode == item.productCode
- )?.packingSpecificationOption
- : this.productList[0].packingSpecificationOption, // 包装规格
- netWeight: this.productList[0].netWeight, // 净重
- barcodes: item.barcodes || item.sendCode, // 发货条码
- clientCode: clientCode, // 客户代号
- materielDesignation:
- item.materielDesignation || item.extInfo?.materielCode, // 物料代号
- engrave: item.engrave || item.extInfo?.engrave, // 刻码
- isUnpack: this.productList[0].isUnpack, // 是否允许拆包
- productionDate: productionDate, // 生产日期
- purchaseDate: purchaseDate, // 采购时间
- result: 1, // 结果(1合格 2不合格)
- status: 2, // 状态(0=未质检 1待检 2已检)
- serialNumber: item.productSequence // 产品序号
- };
- // }
- });
- console.log(this.packingList, '包装明细列表');
- this.packingList.forEach((item) => {
- this.packingWeightCahnge('', item);
- });
- });
- }
- },
- //获取计量数量
- getMeasureQuantity(code) {
- let measureQuantity = 0;
- this.detailList.forEach((item) => {
- if (code == item.productCode) {
- measureQuantity += item.quantity;
- }
- });
- return measureQuantity;
- },
- //多产品明细获取批次号 ys
- // getBatch(code) {
- // let batch=''
- // console.log(this.productList,'this.productList')
- // this.productList.forEach((item) => {
- // if (code == item.) {
- // batch =item.batchNo
- // }
- // });
- // return batch
- // },
- //多产品明细数据转换
- async getDetailsVal(code, productBrand) {
- const { data } = await storageApi.getAssetNum([
- {
- assetCode: code,
- batchNum: 1,
- num: 1
- }
- ]);
- return data[0].onlyCode;
- },
- // 获取当前时间函数
- getNowDate() {
- let date = new Date(),
- obj = {
- year: date.getFullYear(), //获取当前月份(0-11,0代表1月)
- month: date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
- strDate: date.getDate(), // 获取当前日(1-31)
- hour: date.getHours(), //获取当前小时(0 ~ 23)
- minute: date.getMinutes(), //获取当前分钟(0 ~ 59)
- second: date.getSeconds() //获取当前秒数(0 ~ 59)
- };
- Object.keys(obj).forEach((key) => {
- if (obj[key] < 10) obj[key] = `0${obj[key]}`;
- });
- return obj;
- },
- //选择负责人
- handHead(row, index) {
- let item = {
- id: row.unpackUserId
- };
- this.$refs.headRef.open(item, index);
- },
- //选择负责人回调
- changeHead(obj, index) {
- this.$set(this.productList[index], 'unpackUserId', obj.id);
- this.$set(this.productList[index], 'unpackUserName', obj.name);
- },
- // 赋值入库时间
- getNowFormatDate() {
- const obj = this.getNowDate();
- const defaultTime = '00:00:00';
- const currentTime = `${obj.hour}:${obj.minute}:${obj.second}`;
- if (
- this.bizType === 2 ||
- this.bizType === '2' ||
- this.bizType === 6 ||
- this.bizType === '6'
- ) {
- this.formData.storageTime = this.form.receiveDate
- ? `${this.form.receiveDate} ${defaultTime}`
- : `${obj.year}-${obj.month}-${obj.strDate} ${currentTime}`;
- } else {
- this.formData.storageTime = `${obj.year}-${obj.month}-${obj.strDate} ${currentTime}`;
- }
- },
- // 获取物品列表
- async getListItems() {
- const { data } = await getTreeByGroup({ type: 2 });
- this.goodsLists = data;
- },
- // 打开单据来源弹窗
- openDocumentSourceDialog() {
- console.log('打开单据来源弹窗');
- },
- // 清除单据来源
- clearDocumentSource() {
- this.formData.sourceBizNo = '';
- },
- // 添加产品
- addProduct() {
- if (this.formData.extInfo.assetType.length <= 0) {
- return this.$message.error('请选择物品类型');
- }
- if (!this.formData.bizType) {
- return this.$message.error('请选择入库类型');
- }
- this.visibleDialog = true;
- },
- // 键盘移动
- moveFocus(event, index, key, type, row) {
- let keyfield = [];
- let listLength = 0;
- switch (type) {
- case '产品':
- listLength = this.productList.length;
- keyfield = ['batchNo', 'packingQuantity', 'unitPrice', 'purpose'];
- break;
- case '包装':
- listLength = this.showPackingList.length;
- if (row.measureUnit != row.weightUnit) {
- keyfield = [
- 'packing_materielDesignation',
- 'packing_clientCode',
- 'packing_engrave',
- 'packing_weight'
- ];
- } else {
- keyfield = [
- 'packing_materielDesignation',
- 'packing_clientCode',
- 'packing_engrave'
- ];
- }
- break;
- case '物料':
- listLength = this.showMaterialList.length;
- if (row.measureUnit != row.weightUnit) {
- keyfield = [
- 'material_materielDesignation',
- 'material_clientCode',
- 'material_engrave',
- 'material_weight'
- ];
- } else {
- keyfield = [
- 'material_materielDesignation',
- 'material_clientCode',
- 'material_engrave'
- ];
- }
- break;
- }
- if (event.keyCode === 13) {
- // 回车
- if (
- index === listLength - 1 &&
- key === keyfield[keyfield.length - 1]
- ) {
- // 最后一行最后一个
- return;
- }
- this.$refs[key + index].blur();
- if (key === keyfield[keyfield.length - 1]) {
- // 当前行最后一个,跳转下一行第一个
- if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
- this.$refs[keyfield[0] + (index + 1)].value = '';
- }
- this.$refs[keyfield[0] + (index + 1)].focus();
- } else {
- // 跳转下一个
- const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
- this.$nextTick(() => {
- if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
- this.$refs[keyfield[nextkeyindex] + index].value = '';
- }
- this.$refs[keyfield[nextkeyindex] + index].focus();
- });
- }
- }
- // 向上 =38
- if (event.keyCode === 38) {
- if (index === 0) {
- // 第一行
- return;
- }
- this.$refs[key + index].blur();
- this.$nextTick(() => {
- if (this.$refs[key + (index - 1)].value == 0) {
- this.$refs[key + (index - 1)].value = '';
- }
- this.$refs[key + (index - 1)].focus();
- });
- }
- // 下 = 40
- if (event.keyCode === 40) {
- if (index === listLength - 1) {
- // 最后一行
- return;
- }
- this.$refs[key + index].blur();
- this.$nextTick(() => {
- if (this.$refs[key + (index + 1)].value == 0) {
- this.$refs[key + (index + 1)].value = '';
- }
- this.$refs[key + (index + 1)].focus();
- });
- }
- // 左 = 37
- if (event.keyCode === 37) {
- console.log('向左');
- if (index === 0 && key === keyfield[0]) {
- // 第一行第一个
- console.log('第一行第一个无法向左');
- return;
- }
- this.$refs[key + index].blur();
- if (key === keyfield[0]) {
- if (
- this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value == 0
- ) {
- this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value =
- '';
- }
- // 当前行第一个,跳转上一行最后一个
- this.$refs[keyfield[keyfield.length - 1] + (index - 1)].focus();
- } else {
- // 跳转上一个
- const prevkeyindex = keyfield.findIndex((k) => k === key) - 1;
- this.$nextTick(() => {
- if (this.$refs[keyfield[prevkeyindex] + index].value == 0) {
- this.$refs[keyfield[prevkeyindex] + index].value = '';
- }
- this.$refs[keyfield[prevkeyindex] + index].focus();
- });
- }
- }
- // 右 = 39
- if (event.keyCode === 39) {
- if (
- index === listLength - 1 &&
- key === keyfield[keyfield.length - 1]
- ) {
- // 最后一行最后一个
- return;
- }
- this.$refs[key + index].blur();
- if (key === keyfield[keyfield.length - 1]) {
- // 当前行最后一个,跳转下一行第一个
- if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
- this.$refs[keyfield[0] + (index + 1)].value = '';
- }
- this.$refs[keyfield[0] + (index + 1)].focus();
- } else {
- // 跳转下一个
- const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
- this.$nextTick(() => {
- if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
- this.$refs[keyfield[nextkeyindex] + index].value = '';
- }
- this.$refs[keyfield[nextkeyindex] + index].focus();
- });
- }
- }
- },
- // 入库
- async getReturnStorage() {
- if (this.productList.length <= 0) {
- this.$message.error('请先添加产品信息');
- return;
- }
- let boolen = this.productList.every((item) => item.isSave);
- if (!boolen) {
- this.$message.error('请先保存所有产品信息');
- return;
- }
- if (this.isShowPackage) {
- const userNameLength = this.productList.filter(
- (item) => !item.unpackUserName
- ).length;
- const packgeLength = this.productList.filter(
- (item) => !item.ifPackageOk
- ).length;
- if (userNameLength || packgeLength) {
- this.$message.error('请先填写拆包装责任人和包装完好与否');
- return;
- }
- }
- // 处理包装数据
- let _packingList = [];
- _packingList = this.packingList.map((packingItem) => {
- let _taskId = null;
- let _workOrderId = null;
- if ([1].includes(this.bizType)) {
- _workOrderId = this.detailList[0]?.workOrderId;
- _taskId = this.detailList[0]?.taskId;
- } else {
- _workOrderId = this.detailProductList[0]?.workOrderId;
- _taskId = this.detailProductList[0]?.taskId;
- }
- if (packingItem.modelKey) {
- packingItem.modelKey = packingItem.modelKey.toString();
- }
- if (packingItem.colorKey) {
- packingItem.colorKey = packingItem.colorKey.toString();
- }
- return {
- ...packingItem,
- workOrderId: _workOrderId,
- taskId: _taskId,
- outsourceBatchNo: this.detailProductList[0]?.batchNo,
- outsourceCode: this.detailProductList[0]?.sourceCode,
- materialDetailList: this.materialList.filter(
- (item) => item.parentIndex === packingItem.index
- )
- };
- });
- // 处理产品数据
- this.productList = this.productList.map((productItem) => {
- if (productItem.modelKey) {
- productItem.modelKey = productItem.modelKey.toString();
- }
- if (productItem.colorKey) {
- productItem.colorKey = productItem.colorKey.toString();
- }
- return {
- ...productItem,
- outInDetailRecordRequestList: _packingList.filter(
- (item) => item.parentIndex === productItem.index
- )
- };
- });
- this.formData.outInDetailList = this.productList;
- let obj = deepClone(this.formData);
- // 处理物品类型assetType
- obj.extInfo.assetType = obj.extInfo.assetType.join(',');
- obj.extInfo.documentSource = this.formData.sourceBizNo;
- obj.extInfo.deptName = this.formData.extInfo.deptName;
- obj.extInfo.supplierName = this.form.supplierName;
- obj.extInfo.deliveryPhone = this.formData.extInfo.deliveryPhone;
- // 处理仓库id
- let warehouseId = [];
- let warehouseName = [];
- let warehouseIds = this.productList
- .map((item) => item.warehouseIds)
- .flat();
- let warehouseNames = this.productList
- .map((item) => item.warehouseNames)
- .flat();
- warehouseIds.forEach((item, index) => {
- if (!warehouseId.includes(item)) {
- warehouseId.push(item);
- warehouseName.push(warehouseNames[index]);
- }
- });
- obj.warehouseIds = warehouseId;
- obj.warehouseNames = warehouseName;
- obj._packingList = _packingList;
- // setTimeout(() => {
- // resolve(obj);
- // }, 1000);
- // if (productData.length) {
- // this.$alert(
- // `物料${productData.join(',')}没有维护供应商,${
- // productData.length > 1 ? '会合并下发为一个采购订单,' : ''
- // }是否继续下发!`,
- // {
- // confirmButtonText: '确定',
- // callback: (action) => {
- // if (action == 'confirm') {
- // this.issuePurchaseOrderFn();
- // }
- // }
- // }
- // );
- // } else {
- // this.issuePurchaseOrderFn();
- // }
- const isVerifyData = await storageApi.isVerifyRepeatIsStock({
- categoryCodes: this.productList.map((item) => item.categoryCode),
- batchNos: this.productList.map((item) => item.batchNo)
- });
- return new Promise((resolve, reject) => {
- if (isVerifyData?.length) {
- this.$confirm(
- `当前批次:${isVerifyData[0].batchNo},物品${isVerifyData
- .map((item) => item.categoryName)
- .join(',')}已有入库记录,是否继续入库!`,
- {
- confirmButtonText: '是',
- cancelButtonText: '否'
- }
- )
- .then(() => {
- resolve(obj);
- })
- .catch(() => {
- resolve(false);
- });
- } else {
- resolve(obj);
- }
- });
- },
- pickingHandleScroll() {
- if (this.showPackingList.length < this.packingList.length) {
- if (this.packingList.length > this.pageSize) {
- this.pickingPageNum += 1;
- }
- this.pickingFetchData();
- }
- },
- pickingFetchData() {
- const start = (this.pickingPageNum - 1) * this.pageSize;
- const end = start + this.pageSize;
- this.showPackingList = this.showPackingList.concat(
- this.packingList.slice(start, end)
- );
- },
- materielHandleScroll() {
- if (this.showMaterialList.length < this.materialList.length) {
- if (this.materialList.length > this.pageSize) {
- this.materielPageNum += 1;
- }
- this.materielFetchData();
- }
- },
- materielFetchData() {
- const start = (this.materielPageNum - 1) * this.pageSize;
- const end = start + this.pageSize;
- this.showMaterialList = this.showMaterialList.concat(
- this.materialList.slice(start, end)
- );
- },
- // 日期选择
- dateConfirm() {
- this.packingListSelected.forEach((item) => {
- this.$set(item, this.curDateType, this.batchTime);
- });
- this.batchTime = '';
- this.dateVisible = false;
- },
- // 包装重量修改
- packingWeightCahnge(value, row) {
- // 修改物品重量
- let filterPackingList = this.packingList.filter((item) => {
- return item.parentIndex === row.parentIndex;
- });
- let productIndex = this.productList.findIndex((item) => {
- return item.index === row.parentIndex;
- });
- let totalWeight = filterPackingList.reduce(
- (accumulator, currentValue) => {
- return this.$math.format(+accumulator + +currentValue.weight, 14);
- },
- 0
- );
- if (totalWeight != 'NaN') {
- this.$set(this.productList[productIndex], 'weight', totalWeight);
- } else {
- this.$set(this.productList[productIndex], 'weight', 0);
- }
- this.$set(
- this.productList[productIndex],
- 'singleWeight',
- totalWeight / this.productList[productIndex].measureQuantity || 0
- );
- // 修改拆分物料
- // this.materialList.map((item, index) => {
- // if (item.parentIndex === row.index) {
- // this.$set(
- // this.materialList[index],
- // 'weight',
- // this.$math.format(value / row.measureQuantity, 14) >= 0
- // ? this.$math.format(value / row.measureQuantity, 14)
- // : 0
- // );
- // }
- // });
- },
- // 物料重量修改
- materialWeightCahnge(row) {
- // 修改包装重量
- let filterMaterialList = this.materialList.filter((item) => {
- return item.parentIndex === row.parentIndex;
- });
- let packingIndex = this.packingList.findIndex((item) => {
- return item.index === row.parentIndex;
- });
- let totalMaterialWeight = filterMaterialList.reduce(
- (accumulator, currentValue) => {
- return this.$math.format(+accumulator + +currentValue.weight, 14);
- },
- 0
- );
- this.$set(
- this.packingList[packingIndex],
- 'weight',
- totalMaterialWeight
- );
- // 修改物品重量
- let filterPackingList = this.packingList.filter((item) => {
- return (
- item.parentIndex === this.packingList[packingIndex].parentIndex
- );
- });
- let productIndex = this.productList.findIndex((item) => {
- return item.index === this.packingList[packingIndex].parentIndex;
- });
- let totalWeight = filterPackingList.reduce(
- (accumulator, currentValue) => {
- return this.$math.format(+accumulator + +currentValue.weight, 14);
- },
- 0
- );
- this.$set(this.productList[productIndex], 'weight', totalWeight);
- },
- // 包装质检结果修改
- packingResultCahnge(value, row) {
- // 修改物料质检结果(0无 1合格 2不合格 3让步接收)
- this.materialList.map((item, index) => {
- if (item.parentIndex === row.index) {
- this.$set(this.materialList[index], 'result', value);
- this.$set(this.materialList[index], 'status', 2);
- }
- });
- },
- // 物料质量结果修改
- materialResultCahnge(value, row) {
- // 修改包装质检结果
- let filterMaterialList = this.materialList.filter((item) => {
- return item.parentIndex == row.parentIndex;
- });
- let packingIndex = this.packingList.findIndex((item) => {
- return item.index == row.parentIndex;
- });
- let boolen = filterMaterialList.every((item) => {
- return item.result == 1;
- });
- this.$set(this.packingList[packingIndex], 'result', boolen ? 1 : 2);
- this.$set(this.packingList[packingIndex], 'status', 2);
- },
- // 重量限制
- weightInput(value, row, type) {
- const newValue = value.replace(/[^\d.]/g, ''); // 保留数字和小数点
- const decimalCount = (newValue.match(/\./g) || []).length; // 计算小数点的个数
- if (row.weight < 0) {
- row.weight = 0;
- } else if (row.weight > 9999) {
- row.weight = 9999;
- } else {
- if (decimalCount > 1) {
- // 如果小数点个数大于1,移除多余的小数点
- const lastIndex = newValue.lastIndexOf('.');
- row.weight =
- newValue.slice(0, lastIndex) + newValue.slice(lastIndex + 1);
- } else if (decimalCount === 1) {
- // 如果小数点个数等于1,允许小数点的输入
- row.weight = newValue;
- } else {
- row.weight = newValue === '' ? 0 : parseFloat(newValue); // 如果输入为空,则设为0
- }
- }
- if (type === '包装') {
- this.packingWeightCahnge(value, row);
- } else {
- this.materialWeightCahnge(row);
- }
- },
- //计算金额
- calcSumTotal(measureQuantity, unitPrice, row) {
- //最小包装单元,包装数量,单价
- if (this.bizType != 2) {
- const total = {
- measureQuantity: Number(measureQuantity > 0 ? measureQuantity : 0),
- unitPrice: Number(unitPrice > 0 ? unitPrice : 0)
- };
- let number = Number(
- this.$math.format(total.measureQuantity * total.unitPrice, 14)
- );
- row.totalMoney = number;
- return number;
- } else {
- return row.totalMoney;
- }
- },
- // 包装维度最小包装单元改变——>总重量
- minPackingQuantityChange(row, value, index) {
- if (row.measureUnit !== 'KG') {
- if (value.replace(/^(0+)|[^\d]+/g, '') > 9999) {
- this.$set(this.productList[index], 'minPackingQuantity', 9999);
- } else {
- this.$set(
- this.productList[index],
- 'minPackingQuantity',
- value.replace(/^(0+)|[^\d]+/g, '')
- );
- }
- } else {
- if (value < 1) {
- this.$set(this.productList[index], 'minPackingQuantity', 1);
- } else if (value > 9999) {
- this.$set(this.productList[index], 'minPackingQuantity', 9999);
- }
- }
- if (row.packingQuantity >= 0 && value >= 0) {
- this.packNum(row, row.packingQuantity, index);
- }
- },
- // 包装数量过滤处理改变——>总重量
- packNum(row, value, index) {
- const total = {
- minPackingQuantity: Number(
- row.minPackingQuantity > 0
- ? row.minPackingQuantity > 9999
- ? 9999
- : row.minPackingQuantity
- : 0
- ),
- packingQuantity: Number(
- row.packingQuantity > 0
- ? row.packingQuantity > 9999
- ? 9999
- : row.packingQuantity
- : 0
- )
- };
- const totals = Number(
- this.$math.format(
- total.minPackingQuantity * total.packingQuantity,
- 14
- )
- );
- if (row.measureUnit == row.weightUnit) {
- row.weight = Number(
- this.$math.format(
- total.minPackingQuantity *
- 1 *
- Number(total.packingQuantity).toFixed(2),
- 14
- )
- );
- } else {
- row.weight = Number(
- this.$math.format(
- totals *
- (row.netWeight > 0 ? Number(row.netWeight).toFixed(2) : 0),
- 14
- )
- );
- }
- this.$set(this.productList[index], 'measureQuantity', totals);
- // 清空仓库
- this.$set(this.productList[index], 'warehouseId', '');
- this.$set(this.productList[index], 'warehouseName', '');
- if (value.replace(/^(0+)|[^\d]+/g, '') > 9999) {
- this.$set(this.productList[index], 'packingQuantity', 9999);
- } else {
- this.$set(
- this.productList[index],
- 'packingQuantity',
- value.replace(/^(0+)|[^\d]+/g, '')
- );
- }
- // return (row.packingQuantity = value.replace(/^(0+)|[^\d]+/g, ''));
- },
- // 表格样式
- rowClass({ row, column, rowIndex, columnIndex }) {
- if (rowIndex === 1) {
- return {
- display: 'none',
- background: '#EEEEEE'
- };
- }
- return { background: '#0000' };
- },
- //过滤掉单位下拉框 相同的单位
- getNewSpecificationOption(packingSpecificationOption) {
- return packingSpecificationOption;
- return packingSpecificationOption.map((arr) => {
- return arr.reduce((acc, current) => {
- const conversionUnit = current.conversionUnit;
- if (!acc.some((item) => item.conversionUnit === conversionUnit)) {
- acc.push(current);
- }
- return acc;
- }, []);
- });
- },
- // 添加物品明细
- async addGoods(data) {
- // 获取批次号
- const batchNo = await getCode('lot_number_code');
- // 获取供应商
- const supplierList = await storageApi.contactQueryByCategoryIdsAPI({
- categoryIds: data.map((item) => item.id)
- });
- // 获取包装规格
- let packingSpecification =
- await storageApi.getCategoryPackageDisposition({
- categoryIds: data.map((item) => item.id)
- });
- this.packingSpecificationOption = data.map((item) => {
- return packingSpecification
- .filter((ite) => item.id == ite.categoryId)
- .sort((a, b) => a.sort - b.sort);
- });
- const newSpecificationOption = this.getNewSpecificationOption(
- this.packingSpecificationOption
- );
- let productList = data.map((item, index) => {
- // 显示规格
- let packingSpecificationLabel = this.packingSpecificationOption[index]
- .map((item) => {
- if (item.sort > 0) {
- return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
- }
- })
- .filter((item) => !!item);
- return {
- index:
- this.productList.length - 1 > -1
- ? this.productList[this.productList.length - 1].index +
- index +
- 1
- : this.productList.length + index,
- categoryId: item.id, // 物品id
- categoryName: item.name, // 物品名称
- categoryCode: item.code, // 物品编码
- categoryModel: item.modelType, // 物品型号
- specification: item.specification, // 规格
- modelKey: item.modelKey ? item.modelKey.split(',') : '', // 机型
- colorKey: item.colorKey ? item.colorKey.split(',') : '', // 颜色
- brandNum: item.brandNum, // 牌号
- batchNo: batchNo, // 批次号
- supplierListOptions: supplierList[item.id], // 供应商列表
- supplierId: '', // 供应商id
- supplierCode: item.supplierCode, // 供应商代号
- supplierName: item.supplierName, // 供应商名称
- measureType: item.measureType, // 计量类型
- approvalNumber: item.approvalNumber, // 批准文号
- packingSpecification: item.packingSpecification, // 包装规格
- packingSpecificationOption: newSpecificationOption[index], // 包装规格选项
- packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
- minPackingQuantity: '', // 最小包装单元数量
- packingQuantity: '', // 包装数量
- packingUnit: item.measuringUnit, // 单位
- packingUnitId: newSpecificationOption[index].find(
- (v) => v.conversionUnit == item.measuringUnit
- )?.id, // 单位
- measureQuantity: 0, // 计量数量
- measureUnit: item.measuringUnit, // 计量单位
- netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
- weight: 0, // 重量
- singleWeight: item.measuringUnit != 'KG' ? item.netWeight : 0, // 单重
- pricingWay: item.pricingWay,
- weightUnit: item.weightUnit, // 重量单位
- totalMoney: item.totalPrice, // 总价
- unitPrice: item.unitPrice, // 单价
- purpose: '', // 用途
- isUnpack: item.isUnpack // 是否允许拆包
- };
- });
- this.productList = this.productList.concat(productList);
- },
- // 物品保存验证表单(批量)
- validateForm() {
- return new Promise(async (resolve, reject) => {
- let list = this.productList.map(async (row, index) => {
- let fileds = [
- `productList.${index}.batchNo`,
- `productList.${index}.packingQuantity`,
- `productList.${index}.packingUnit`,
- `productList.${index}.warehouseId`
- ];
- if (row.isSave) {
- return Promise.resolve(true);
- } else {
- return await Promise.all(
- fileds.map(
- (item) =>
- new Promise(async (res, rej) => {
- this.$refs.productListRef.validateField(item, (err) => {
- if (err) {
- rej(err);
- } else {
- res(true);
- }
- });
- })
- )
- );
- }
- });
- Promise.all(list)
- .then(() => {
- console.log('保存成功!');
- resolve();
- })
- .catch((err) => {
- console.log('保存失败!');
- this.$message.error('请填入必填项!');
- reject(err);
- });
- });
- },
- // 产品批量保存
- async listSaveArrs() {
- this.validateForm()
- .then(async () => {
- // 批量获取包装编码并处理
- let packingCodePrams = this.productList.map((row) => {
- // 判断单位和计量单位是否为不拆物料层规格
- let packingBoolen = !!this.getDict(
- '不拆物料层规格',
- row.packingUnit
- ).dictValue;
- let measureBoolen = !!this.getDict(
- '不拆物料层规格',
- row.measureUnit
- ).dictValue;
- let num = 0;
- if (packingBoolen) {
- let filterArr = row.packingSpecificationOption.filter(
- (item) => {
- return (
- item.packageUnit == row.packingUnit &&
- item.packageUnit != item.conversionUnit
- );
- }
- );
- num = Math.ceil(row.packingQuantity / filterArr[0].packageCell);
- }
- if (row.isSave) {
- return {};
- } else {
- // 处理单位为KG类的情况
- if (packingBoolen) {
- return {
- assetCode: row.categoryCode + row.index,
- batchNum: row.batchNo,
- num
- };
- } else {
- if (row.isUnpack == 1) {
- if (measureBoolen) {
- // 处理单位不为KG类,计量单位为KG类的情况
- let num = row.packingQuantity;
- let splitIndex = row.packingSpecificationOption.findIndex(
- (item) =>
- item.conversionUnit == row.packingUnit &&
- item.packageUnit != item.conversionUnit
- );
- for (; splitIndex > 1; splitIndex--) {
- num = this.$math.format(
- num *
- row.packingSpecificationOption[splitIndex]
- .packageCell,
- 14
- );
- }
- return {
- assetCode: row.categoryCode + row.index,
- batchNum: row.batchNo,
- num
- };
- } else {
- // 处理拆包到最小包装单元数量的情况
- return {
- assetCode: row.categoryCode + row.index,
- batchNum: row.batchNo,
- num: row.measureQuantity
- };
- }
- } else {
- return {
- assetCode: row.categoryCode + row.index,
- batchNum: row.batchNo,
- num
- };
- }
- }
- }
- });
- let filterPackingCodePrams = packingCodePrams.filter(
- (item) => item.assetCode
- );
- let { data } = await storageApi.getAssetNum(filterPackingCodePrams);
- let packingCodeList = [];
- packingCodePrams.forEach((item, index) => {
- packingCodeList[index] = data.filter(
- (ite) => ite.assetCode == item.assetCode
- );
- });
- // 批量生成包装
- this.productList.map((row, index) => {
- if (!row.isSave) {
- this.generateWrappers(row, index, packingCodeList[index]);
- this.$set(this.productList[index], 'isSave', true);
- }
- });
- // 加载虚拟列表数据(分页)
- // this.pickingFetchData();
- // this.materielFetchData();
- })
- .catch((err) => {
- console.log(err);
- });
- },
- // 物品保存验证表单(单独)
- validateFormIndividually(index) {
- return new Promise(async (resolve) => {
- let fileds = [
- `productList.${index}.batchNo`,
- `productList.${index}.packingQuantity`,
- `productList.${index}.packingUnit`,
- `productList.${index}.warehouseId`
- ];
- Promise.all(
- fileds.map(
- (item) =>
- new Promise(async (res, rej) => {
- this.$refs.productListRef.validateField(item, (err) => {
- if (err) {
- rej(err);
- } else {
- res(true);
- }
- });
- })
- )
- )
- .then(() => {
- resolve();
- })
- .catch(() => {
- this.$message.error('请填入必填项!');
- });
- });
- },
- // 产品编辑
- listEdit(row) {
- this.$set(row, 'isSave', false);
- // // 重新计算重量
- // const totals = Number(
- // this.$math.format(row.minPackingQuantity * row.packingQuantity, 14)
- // );
- // if (row.measureUnit == row.weightUnit) {
- // row.weight = Number(
- // this.$math.format(
- // row.minPackingQuantity *
- // 1 *
- // Number(row.packingQuantity).toFixed(2),
- // 14
- // )
- // );
- // } else {
- // row.weight = Number(
- // this.$math.format(
- // totals *
- // (row.netWeight > 0 ? Number(row.netWeight).toFixed(2) : 0),
- // 14
- // )
- // );
- // }
- this.deletePackingAndMaterial(row);
- },
- // 根据产品信息删除包装和物料
- deletePackingAndMaterial(row) {
- // 删除包装(去掉不相同的包装)
- this.packingList = this.packingList.filter(
- (item) => item.parentIndex !== row.index
- );
- this.showPackingList = this.showPackingList.filter(
- (item) => item.parentIndex !== row.index
- );
- this.pickingPageNum = Math.ceil(
- this.showPackingList.length / this.pageSize
- );
- // 删除物料(获取相同物料)
- let packingIndexs = this.packingList.map((item) => item.index);
- this.materialList = this.materialList.filter((item) =>
- packingIndexs.includes(item.parentIndex)
- );
- this.showMaterialList = this.showMaterialList.filter((item) =>
- packingIndexs.includes(item.parentIndex)
- );
- this.materielPageNum = Math.ceil(
- this.showMaterialList.length / this.pageSize
- );
- },
- async batchSave() {
- try {
- // 验证所有未保存的表单
- await this.validateForm();
- // 遍历所有产品进行保存
- for (let i = 0; i < this.productList.length; i++) {
- const row = this.productList[i];
- if (!row.isSave) {
- // 执行单个保存逻辑
- await this.listSave(row, i);
- }
- }
- } catch (error) {
- // this.$message.error('批量保存失败,请检查必填项');
- }
- },
- listSave(row, index) {
- console.log('row22222222', row);
- this.validateFormIndividually(index).then(async () => {
- // 判断单位和计量单位是否为不拆物料层规格
- let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
- .dictValue;
- let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
- .dictValue;
- console.log('packingBoolen---------', packingBoolen);
- console.log('measureBoolen---------', measureBoolen);
- let packingNum = 0;
- // 处理单位为KG类的情况
- if (packingBoolen) {
- if (!row.isUnpack && row.packingUnit == '立方') {
- packingNum = 1;
- } else {
- let filterArr = row.packingSpecificationOption.filter((item) => {
- return (
- item.packageUnit == row.packingUnit &&
- item.packageUnit != item.conversionUnit
- );
- });
- if (filterArr?.length) {
- packingNum = Math.ceil(
- row.packingQuantity / filterArr[0].packageCell
- );
- }
- }
- }
- // 处理单位不为KG类,计量单位为KG类的情况
- let measureNum = row.packingQuantity;
- let num = 0;
- if (measureBoolen) {
- let splitIndex = row.packingSpecificationOption.findIndex(
- (item) =>
- item.conversionUnit == row.packingUnit &&
- item.packageUnit != item.conversionUnit
- );
- for (; splitIndex > 1; splitIndex--) {
- measureNum = this.$math.format(
- measureNum *
- row.packingSpecificationOption[splitIndex].packageCell,
- 14
- );
- }
- } else {
- if (row.packingSpecificationOption[1]?.packageCell) {
- num = Math.ceil(
- row.measureQuantity /
- row.packingSpecificationOption[1]?.packageCell
- );
- } else {
- num = row.packingQuantity;
- }
- }
- console.log(packingNum, measureNum, num, '加油加油加油');
- // return
- if (row.packingSpecificationLabel?.length < 1) {
- this.$message.error('请到主数据维护包装组信息!');
- return;
- }
- // 不拆包
- if (!row.isUnpack) {
- if (row.packingUnit != row.measureUnit) {
- let pNum = row.packingQuantity;
- const { data } = await storageApi.getAssetNum([
- {
- assetCode: row.categoryCode + row.index,
- batchNum: row.batchNo,
- num: pNum
- }
- ]);
- // this.generateWrappers(row, index, data)
- } else {
- let pNum = 0;
- const { data } = await storageApi.getAssetNum([
- {
- assetCode: row.categoryCode + row.index,
- batchNum: row.batchNo,
- num: pNum
- }
- ]);
- }
- } else {
- if (!packingNum) {
- if (row.packingUnitId) {
- let splitIndex = row.packingSpecificationOption.findIndex(
- (item) => item.id == row.packingUnitId
- );
- if (splitIndex == 0) {
- packingNum = Math.ceil(
- row.measureQuantity /
- row.packingSpecificationOption[1]?.packageCell
- );
- }
- if (splitIndex == 1) {
- packingNum = row.packingQuantity;
- }
- for (; splitIndex > 1; splitIndex--) {
- packingNum = Math.ceil(
- row.packingQuantity *
- row.packingSpecificationOption[splitIndex].packageCell
- );
- }
- } else {
- packingNum = Math.ceil(
- row.measureQuantity /
- row.packingSpecificationOption[1]?.packageCell
- );
- }
- }
- console.log(packingNum, 'packingNum');
- //拆包
- const { data } = await storageApi.getAssetNum([
- {
- assetCode: row.categoryCode + row.index,
- batchNum: row.batchNo,
- num: packingNum
- }
- ]);
- this.generateWrappers(row, index, data);
- }
- this.$set(this.productList[index], 'isSave', true);
- this.$set(this.productList[index], 'warehouseId', row.warehouseId);
- this.$set(
- this.productList[index],
- 'warehouseName',
- row.warehouseName
- );
- this.$set(this.productList[index], 'warehouseIds', row.warehouseId);
- this.$set(
- this.productList[index],
- 'warehouseNames',
- row.warehouseName
- );
- });
- },
- //入库明细删除
- listDel(row, index) {
- this.productList.splice(index, 1);
- this.deletePackingAndMaterial(row);
- },
- // 打开仓库弹框
- handleWareHouse(row, idx, type) {
- console.log(row, '踩踩踩踩踩踩踩踩踩踩踩', this.form);
- if (row.packingSpecificationLabel?.length < 1) {
- this.$message.error('请到主数据维护包装组信息!');
- return;
- }
- if (row.isSave) {
- return false;
- }
- let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
- .dictValue;
- let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
- .dictValue;
- console.log(packingBoolen, 'packingBoolen');
- console.log(measureBoolen, 'measureBoolen');
- //行内选择仓库
- if (idx > -1 && type != 'batch') {
- if (row.packingQuantity > 0) {
- //不拆
- if (!row.isUnpack) {
- //计量和包装单位相同
- if (row.measureUnit == row.packingUnit) {
- let pNum = 0;
- let mNum = row.measureQuantity;
- this.$refs.wareHouseDailogRef.open(
- pNum,
- mNum,
- idx,
- row.warehouseId,
- row.warehouseName + ''
- // this.form.categoryLevelTopId
- );
- } else {
- let pNum = row.packingQuantity;
- let mNum = row.measureQuantity;
- this.$refs.wareHouseDailogRef.open(
- pNum,
- mNum,
- idx,
- row.warehouseId,
- row.warehouseName + ''
- // this.form.categoryLevelTopId
- );
- }
- } else {
- if (packingBoolen) {
- console.log(
- packingBoolen,
- 'packingBoolen',
- row.packageUnit,
- row.isUnpack
- );
- let filterArr = row.packingSpecificationOption.filter(
- (item) => {
- return (
- item.packageUnit == row.packingUnit &&
- item.packageUnit != item.conversionUnit
- );
- }
- );
- let num = Math.ceil(
- row.packingQuantity / filterArr[0].packageCell
- );
- this.$refs.wareHouseDailogRef.open(
- num,
- row.measureQuantity,
- idx,
- row.warehouseId,
- row.warehouseName + ''
- // this.form.categoryLevelTopId
- );
- } else {
- console.log(measureBoolen, 'measureBoolen');
- let num = row.packingQuantity;
- if (measureBoolen) {
- let splitIndex = row.packingSpecificationOption.findIndex(
- (item) =>
- item.conversionUnit == row.packingUnit &&
- item.packageUnit != item.conversionUnit
- );
- for (; splitIndex > 1; splitIndex--) {
- num = this.$math.format(
- num *
- row.packingSpecificationOption[splitIndex].packageCell,
- 14
- );
- }
- this.$refs.wareHouseDailogRef.open(
- num,
- row.measureQuantity,
- idx,
- row.warehouseId,
- row.warehouseName + ''
- // this.form.categoryLevelTopId
- );
- } else {
- if (
- row.measureType != 1 &&
- row.measureUnit == row.packingUnit
- ) {
- let pNum = 0;
- let mNum = row.measureQuantity;
- this.$refs.wareHouseDailogRef.open(
- pNum,
- mNum,
- idx,
- row.warehouseId,
- row.warehouseName + ''
- // this.form.categoryLevelTopId
- );
- } else {
- if (row.packingSpecificationOption[1]?.packageCell) {
- let num = Math.ceil(
- row.measureQuantity /
- row.packingSpecificationOption[1]?.packageCell
- );
- this.$refs.wareHouseDailogRef.open(
- num,
- row.measureQuantity,
- idx,
- row.warehouseId,
- row.warehouseName + ''
- );
- } else {
- this.$refs.wareHouseDailogRef.open(
- row.packingQuantity,
- row.measureQuantity,
- idx,
- row.warehouseId,
- row.warehouseName + ''
- );
- }
- console.log(num, 'num');
- }
- }
- }
- }
- } else {
- this.$message.error('请先填写包装数量!');
- }
- } else {
- //批量
- console.log(row, `row`);
- console.log(idx, `idx`);
- console.log(type, 'type');
- // 批量设置
- if (row.some((item) => !item.packingQuantity)) {
- this.$message.error('请先填写所有行的包装数量!');
- return;
- }
- for (let i = 0; i < row.length; i++) {
- //测量单位等于包装单位
- if (
- row[i].measureType != 1 &&
- row[i].measureUnit === row[i].packingUnit
- ) {
- row[i].packingQuantity2 = 0;
- console.log(row[i].packingQuantity2);
- } else {
- row[i].packingQuantity2 = Math.ceil(
- row[i].measureQuantity /
- row[i].packingSpecificationOption[1]?.packageCell
- );
- console.log(row[i].packingQuantity2, '单位不一样');
- }
- }
- console.log(row, 'rowrowrowrowrowrow我看看');
- const pNum = row.reduce((sum, item) => {
- if (
- item.packingQuantity2 !== undefined &&
- item.packingQuantity2 !== null
- ) {
- return sum + Number(item.packingQuantity2);
- }
- return sum;
- }, 0);
- const mNum = row.reduce((sum, item) => {
- if (
- item.measureQuantity !== undefined &&
- item.measureQuantity !== null
- ) {
- return sum + Number(item.measureQuantity);
- }
- return sum;
- }, 0);
- console.log(pNum, 'pppp');
- console.log(mNum, 'mmmmm');
- this.$refs.wareHouseDailogRef.open(
- pNum,
- mNum
- // this.form.categoryLevelTopId
- );
- }
- },
- wareHouseSelection(argum, idx) {
- console.log(argum, 'argumargumargumargumargumargum');
- // 方便包装遍历获取仓库id和名称
- let warehouseIds = [];
- let warehouseNames = [];
- argum.forEach((item) => {
- console.log(item, 'itemitem');
- for (let index = 0; index < item.packingQuantity; index++) {
- warehouseIds.push(item.warehouseId);
- warehouseNames.push(item.warehouseName);
- }
- });
- console.log(idx, this.productList, 'idxidxidxidx');
- if (idx > -1) {
- this.$set(
- this.productList[idx],
- 'warehouseId',
- argum.map((item) => item.warehouseId).join(',')
- );
- this.$set(
- this.productList[idx],
- 'warehouseName',
- argum.map((item) => item.warehouseName).join(',')
- );
- this.$set(this.productList[idx], 'warehouseIds', warehouseIds);
- this.$set(this.productList[idx], 'warehouseNames', warehouseNames);
- console.log(this.productList, 'productList');
- } else {
- this.productList.map((item, index) => {
- this.$set(
- this.productList[index],
- 'warehouseId',
- argum.map((item) => item.warehouseId).join(',')
- );
- this.$set(
- this.productList[index],
- 'warehouseName',
- argum.map((item) => item.warehouseName).join(',')
- );
- this.$set(this.productList[index], 'warehouseIds', warehouseIds);
- this.$set(
- this.productList[index],
- 'warehouseNames',
- warehouseNames
- );
- });
- }
- this.$forceUpdate();
- },
- // 生成包装
- generateWrappers(row, productIndex, packingCodeList) {
- console.log(packingCodeList, 'packingCodeList', row.measureType);
- if (!row.measureType)
- return this.$message.warning('请到主数据维计量类型!');
- console.log('包装数据--------', row);
- // console.log('包装规格----', row.packingSpecificationOption);
- console.log('计量单位----', row.measureUnit);
- let packingList = [];
- let obj = this.getNowDate();
- let productionDate = row.detailProductionDate || '';
- let purchaseDate = row.detailPurchaseDate || '';
- let expireDate = row.detailExpireDate || '';
- console.log(expireDate, 'expireDate');
- console.log(
- this.formData.bizType,
- 'bizTypebizTypebizTypebizTypebizTypebizTypebizTypebizTypebizTypebizTypebizType'
- );
- if (this.formData.bizType == '1') {
- // 生产入库
- productionDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
- // this.curDateType = 'productionDate';
- }
- // 判断单位和计量单位是否为不拆物料层规格
- let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
- .dictValue;
- let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
- .dictValue;
- let num = row.packingQuantity;
- let filterArr = [];
- // 处理单位为KG类的情况
- if (packingBoolen) {
- console.log(
- packingBoolen,
- 'packingBoolenpackingBoolenpackingBoolenpackingBoolenpackingBoolenpackingBoolen'
- );
- if (!row.isUnpack && row.packingUnit == '立方') {
- num = 1;
- } else {
- filterArr = row.packingSpecificationOption.filter((item) => {
- return (
- item.packageUnit == row.packingUnit &&
- item.packageUnit != item.conversionUnit
- );
- });
- num = Math.ceil(row.packingQuantity / filterArr[0]?.packageCell);
- }
- } else {
- // if (row.isUnpack == 1) {
- if (measureBoolen) {
- // 处理单位不为KG类,计量单位为KG类的情况
- let splitIndex = row.packingSpecificationOption.findIndex(
- (item) =>
- item.conversionUnit == row.packingUnit &&
- item.packageUnit != item.conversionUnit
- );
- for (; splitIndex > 1; splitIndex--) {
- num = this.$math.format(
- num * row.packingSpecificationOption[splitIndex].packageCell,
- 14
- );
- }
- } else {
- if (row.packingSpecificationOption[1]?.packageCell) {
- num = Math.ceil(
- row.measureQuantity /
- row.packingSpecificationOption[1]?.packageCell
- );
- filterArr = row.packingSpecificationOption.filter((item) => {
- return (
- item.packageUnit == row.packingUnit &&
- item.packageUnit != item.conversionUnit
- );
- });
- }
- }
- }
- console.log('num-----------', num);
- for (let index = 0; index < packingCodeList.length; index++) {
- let measureQuantity = 1;
- let packingQuantity = 1;
- let packingUnit = row.packingUnit;
- // 处理单位为KG类,计算每桶KG值
- if (packingBoolen) {
- if (!row.isUnpack && row.packingUnit == '立方') {
- let result =
- row.packingQuantity /
- row.packingSpecificationOption[1].packageCell;
- packingQuantity = Math.ceil(result * 100) / 100;
- console.log(packingQuantity, '包装数oppppp量');
- measureQuantity = row.measureQuantity;
- console.log(measureQuantity, '计量数oppppp量');
- packingUnit = row.packingUnit;
- } else {
- measureQuantity =
- Number(row.packingQuantity) >
- this.$math.format(filterArr[0].packageCell * (index + 1), 14)
- ? filterArr[0].packageCell
- : Number(row.packingQuantity) -
- this.$math.format(filterArr[0].packageCell * index, 14);
- console.log(measureQuantity, 'measureQuantit1111y');
- }
- } else {
- if (row.isUnpack == 1) {
- console.log('1 拆--------', measureBoolen);
- if (measureBoolen) {
- //计量单位等于重量单位并且有总重 计量数量=总重/包装数
- if (row.weightUnit == row.measureUnit && row.weight) {
- measureQuantity =
- Math.trunc((row.weight / packingCodeList.length) * 100) /
- 100;
- } else {
- // 处理单位不为KG类,计量单位为KG类的情况
- let splitIndex = row.packingSpecificationOption.findIndex(
- (item) =>
- item.conversionUnit == row.packingUnit &&
- item.packageUnit != item.conversionUnit
- );
- for (; splitIndex > 0; splitIndex--) {
- measureQuantity = this.$math.format(
- measureQuantity *
- row.packingSpecificationOption[splitIndex].packageCell,
- 14
- );
- }
- }
- } else {
- measureQuantity = row.packingSpecificationOption[1].packageCell;
- }
- } else {
- console.log('4 拆--------');
- if (row.packingQuantity) {
- measureQuantity = row.measureQuantity / row.packingQuantity;
- }
- }
- console.log(measureQuantity, 'measureQuantity');
- }
- let clientCode = '';
- if (this.bizType == 2) {
- clientCode = row?.customerMark;
- } else if (this.bizType != 2) {
- clientCode = row.extInfo?.clientCode;
- }
- console.log(filterArr[0], 'filterArr[0]');
- let status = null;
- //通过委外发货单编码判断是不是委外 委外收货 质检状态显示已质检
- // if (this.form.outsourceSendCode != '') {
- // status = 2;
- // } else {
- // // 0未检 1待检 2 已检
- // if (row.qualityControl == 1) {
- // status = 0;
- // } else {
- // status = 2;
- // }
- // }
- if (row.qualityControl == 1) {
- status = 0;
- } else {
- status = 2;
- }
- let item = {
- index: row.index + '-' + index, // 包装索引
- warehouseId: row.warehouseId, // 仓库id
- warehouseName: row.warehouseName, // 仓库名称
- categoryName: row.categoryName, // 产品名称
- categoryCode: row.categoryCode, // 产品编码
- categoryModel: row.categoryModel, // 物品型号
- specification: row.specification, // 规格
- supplierCode: row.supplierCode, // 供应商编码
- supplierName: row.supplierName, // 供应商名称
- brandNum: row.brandNum, // 牌号
- parentIndex: row.index, // 产品索引
- batchNo: row.batchNo, // 批次号
- packageNo: packingCodeList[index]?.onlyCode, // 包装编码
- packingQuantity: packingQuantity, // 包装数量
- modelKey: row.modelKey, // 机型
- colorKey: row.colorKey, //颜色
- // packingUnit: row.isUnpack ? packingBoolen ? filterArr[0].conversionUnit : measureBoolen ? row.packingSpecificationOption[1]
- // ? row.packingSpecificationOption[1].conversionUnit
- // : row.packingSpecificationOption[0].conversionUnit
- // : row.measureUnit
- // : packingBoolen
- // ? row.packingUnit === '立方' ? row.packingUnit : filterArr[0]?.conversionUnit
- // : row.packingUnit,
- // packingUnit: row.isUnpack ? packingBoolen ? filterArr[0].conversionUnit : measureBoolen ? row.packingSpecificationOption[2] ?
- // row.packingSpecificationOption[2].conversionUnit : row.packingSpecificationOption[1].conversionUnit: row.measureUnit: packingBoolen ? filterArr[0].conversionUnit : row.packingUnit,
- //!row.isUnpack && row.packingUnit
- measureQuantity: measureQuantity, // 计量数量
- measureUnit: row.isUnpack
- ? measureBoolen
- ? row.packingSpecificationOption[1]
- ? row.packingSpecificationOption[1].packageUnit
- : row.packingSpecificationOption[0].packageUnit
- : row.measureUnit
- : row.measureUnit, // 计量单位
- weight: 0, // 重量
- packingSpecificationOption: row.packingSpecificationOption, // 包装规格
- weightUnit: row.weightUnit, // 重量单位
- netWeight: row.netWeight, // 净重
- barcodes: '', // 发货条码
- clientCode: clientCode, // 客户代号
- materielDesignation: row.extInfo ? row.extInfo.materielCode : '', // 物料代号
- engrave: '', // 刻码
- isUnpack: row.isUnpack, // 是否允许拆包
- productionDate: productionDate, // 生产日期
- purchaseDate: purchaseDate, // 采购时间
- expireDate: expireDate, //失效日期
- result: 1, // 结果(1合格 2不合格)
- qualityControl: row.qualityControl,
- status: status // 状态(0=未质检 1待检 2已检)
- };
- /**
- * packingUnit: row.isUnpack ? packingBoolen ? filterArr[0].conversionUnit : measureBoolen ? row.packingSpecificationOption[2] ? row.packingSpecificationOption[2].conversionUnit
- * : row.packingSpecificationOption[1].conversionUnit: row.measureUnit: packingBoolen ? filterArr[0].conversionUnit : row.packingUnit,
- */
- if (row.isUnpack) {
- // 第二层条件: packingBoolen
- if (packingBoolen) {
- // 空值保护: 确保 filterArr[0] 存在
- item.packingUnit =
- row.packingSpecificationOption[1].conversionUnit;
- } else {
- // 第三层条件: measureBoolen
- if (measureBoolen) {
- // 处理 packingSpecificationOption 的索引
- const option =
- row.packingSpecificationOption?.[1] ||
- row.packingSpecificationOption?.[0];
- item.packingUnit = option?.conversionUnit;
- } else {
- item.packingUnit =
- row.packingSpecificationOption[1].conversionUnit;
- }
- }
- }
- let outBoolen = !!this.getDict('不拆物料层规格', item.measureUnit)
- .dictValue;
- if (outBoolen) {
- // 计量单位为KG类,直接替换
- item.weight = item.measureQuantity
- ? Number(item.measureQuantity)
- : 0;
- } else {
- console.log('计量单位为不为KG类======================');
- // 计量单位为不为KG类,重新统计计算
- let inBoolen = !!this.getDict(
- '不拆物料层规格',
- item.packingSpecificationOption[0].packageUnit
- ).dictValue;
- let startIndex = item.packingSpecificationOption.findIndex(
- (ite) => {
- return (
- item.measureUnit == ite.packingUnit &&
- ite.packingUnit != ite.conversionUnit
- );
- }
- );
- let endIndex = item.packingSpecificationOption.findIndex(
- (ite) => item.packingUnit == ite.conversionUnit
- );
- if (measureBoolen) {
- let total = item.packingQuantity
- ? Number(item.packingQuantity)
- : 0;
- for (; startIndex < endIndex; endIndex--) {
- total = this.$math.format(
- item.packingSpecificationOption[endIndex].packageCell * total,
- 14
- );
- }
- if (inBoolen) {
- // 第二层为KG类
- item.weight = total ? Number(total) : 0;
- } else {
- // 第二层不为KG类
- item.weight = this.$math.format(total * item.netWeight, 14);
- }
- } else if (!measureBoolen) {
- if (inBoolen) {
- // 第二层为KG类
- item.weight = item.measureQuantity
- ? Number(item.measureQuantity)
- : 0;
- } else {
- // 第二层不为KG类
- if (row.singleWeight && item.measureQuantity) {
- item.weight =
- Number(item.measureQuantity) * Number(row.singleWeight);
- } else {
- item.weight = 0;
- }
- }
- }
- }
- packingList.push(item);
- console.log(
- packingList,
- 'packingList!!!!!!!!!!!!!!!!!!拆'
- );
- }
- // 单独点击保存并插入对应位置(包装)
- if (productIndex == 0) {
- this.packingList.splice(productIndex, 0, ...packingList);
- } else {
- let packingIndex = this.packingList.findLastIndex(
- (item) =>
- item.parentIndex == this.productList[productIndex - 1].index
- );
- this.packingList.splice(packingIndex + 1, 0, ...packingList);
- }
- let remainder = 0;
- if (row.weightUnit != row.measureUnit) {
- remainder =
- row.measureQuantity %
- row.packingSpecificationOption[1]?.packageCell;
- }
- if (remainder > 0) {
- let onlyCode = packingCodeList[packingCodeList.length - 1]?.onlyCode;
- let index = this.packingList.findIndex(
- (packingItem) => packingItem.packageNo == onlyCode
- );
- this.$set(this.packingList[index], 'measureQuantity', remainder);
- if (row.singleWeight) {
- this.$set(
- this.packingList[index],
- 'weight',
- row.singleWeight * remainder
- );
- }
- }
- // 单独点击保存并插入对应位置(物料)
- // let materialList = packingList
- // .map((item) => {
- // if (item.isUnpack) {
- // return this.generateMaterial(item);
- // } else {
- // return [];
- // }
- // })
- // .flat();
- // console.log(materialList);
- // if (materialList.length > 0) {
- // if (productIndex == 0) {
- // this.materialList.splice(0, 0, ...materialList);
- // } else {
- // let preLastPackingIndex = this.packingList.findLastIndex((ite) => {
- // return ite.parentIndex <= productIndex - 1 && ite.isUnpack;
- // });
- // let preLastMaterialIndex = this.materialList.findLastIndex(
- // (ite) => {
- // return (
- // ite.parentIndex == this.packingList[preLastPackingIndex].index
- // );
- // }
- // );
- // this.materialList.splice(
- // preLastMaterialIndex + 1,
- // 0,
- // ...materialList
- // );
- // }
- // }
- },
- // 生成物料
- generateMaterial(row) {
- let materialList = [];
- for (let index = 0; index < row.measureQuantity; index++) {
- materialList.push({
- materialCode: row.packageNo + index.toString().padStart(4, '0'), // 物料编码
- index: row.index + '——' + index, // 包装索引
- warehouseId: row.warehouseId, // 仓库id
- warehouseName: row.warehouseName, // 仓库名称
- categoryName: row.categoryName, // 产品名称
- categoryCode: row.categoryCode, // 产品编码
- parentIndex: row.index, // 产品索引
- batchNo: row.batchNo, // 批次号
- packageNo: row.packageNo, // 包装编码
- measureQuantity: 1, // 计量数量
- measureUnit: row.measureUnit, // 计量单位
- weight: Number(
- this.$math.format(row.weight / row.packingQuantity, 14)
- ), // 重量
- weightUnit: row.weightUnit, // 重量单位
- barcodes: '', // 发货条码
- clientCode: '', // 客户代号
- materielDesignation: '', // 物料代号
- engrave: '', // 刻码
- result: 1, // 结果(1合格 2不合格 3让步接收)
- status: 2 // 状态(0=未质检 1待检 2已检)
- });
- }
- return materialList;
- },
- // 设置时间
- dateSetting(curDateType) {
- if (!this.packingListSelected.length) {
- return this.$message.error(`请选择${this.title}明细!`);
- }
- this.curDateType = curDateType;
- this.dateVisible = true;
- },
- // 选择包装列表
- handleSelectionChange(val) {
- this.packingListSelected = val;
- },
- // 选择质检结果改变质检状态
- changeWrapStatus(resultValue, row, type) {
- switch (resultValue) {
- case 0:
- // 清空质检状态
- row.status = 0;
- break;
- default:
- // 默认已检质检状态
- row.status = 2;
- break;
- }
- if (type === '包装') {
- this.packingResultCahnge(resultValue, row);
- } else {
- this.materialResultCahnge(resultValue, row);
- }
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- ::v-deep .el-table .warning-row {
- background: #d9ecff;
- }
- .inbound_details {
- margin-top: 10px;
- .el-form-item {
- margin-bottom: 0 !important;
- }
- }
- .right_control {
- display: flex;
- > button {
- margin-left: 20px;
- }
- }
- .storage_btn {
- margin-top: 20px;
- display: flex;
- align-content: center;
- justify-content: center;
- }
- .el-date-editor.el-input,
- .el-date-editor.el-input__inner {
- width: 100% !important;
- }
- .red_color {
- color: red;
- }
- .wareHouse_style {
- text-overflow: ellipsis;
- overflow: hidden;
- word-break: break-all;
- white-space: nowrap;
- }
- </style>
|