| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726 |
- <template>
- <div class="ele-body">
- <el-card shadow="never">
- <header-title title="基本信息">
- <div class="right_control">
- <el-upload
- ref="fileUploadBtn"
- action="#"
- :auto-upload="false"
- :on-change="onChange"
- :limit="1"
- :show-file-list="false"
- accept=".xls,.xlsx"
- >
- <el-button type="primary">备品备件导入excel</el-button>
- </el-upload>
- <el-button type="primary" @click="back">返回</el-button>
- </div>
- </header-title>
- <el-form
- :model="formData"
- ref="formName"
- label-width="110px"
- :rules="rules"
- >
- <el-row :gutter="24">
- <el-col :span="6">
- <el-form-item label="物品类型" prop="extInfo.assetType">
- <el-select
- style="width: 100%"
- 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%"
- 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="">
- <el-input
- placeholder="请选择"
- v-model="formData.clientName"
- style="width: calc(100% - 80px)"
- >
- </el-input>
- <openContactDialog
- style="margin-left: 3px"
- @changeParent="contactDialogSuccess"
- ></openContactDialog>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="单据来源" prop="sourceBizNo">
- <el-input
- placeholder="请选择"
- v-model="formData.sourceBizNo"
- @focus="openDocumentSourceDialog"
- >
- <template #append>
- <el-button
- @click="clearSourceBizNo"
- slot="append"
- icon="el-icon-circle-close"
- ></el-button>
- </template>
- </el-input>
- </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.extInfo.createUserName"
- 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"
- placeholder="请详细说明"
- ></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"
- >
- <ele-pro-table
- ref="table"
- :columns="columns"
- :datasource="productList"
- :needPage="false"
- @columns-change="handleColumnChange"
- :cache-key="cacheKeyUrl"
- >
- <template v-slot:toolbar>
- <el-button
- v-if="productList.length != 0"
- type="success"
- plain
- style="float: right; margin-right: 20px"
- size="mini"
- @click="batchSave"
- >批量保存</el-button
- >
- <el-button
- v-if="productList.length != 0"
- type="success"
- plain
- style="float: right; margin-right: 20px"
- size="mini"
- @click="handleWareHouse(productList, '', 'batch')"
- >批量选择仓库</el-button
- >
- </template>
- <template v-slot:headerBatchNo="{ column }">
- <span class="is-required">{{ column.label }}</span>
- </template>
- <template v-slot:batchNo="{ 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="row.batchNo"
- >
- </el-input>
- </el-form-item>
- </template>
- <template v-slot:quantity="{ row, $index }">
- <template v-if="row.isSave">
- {{ row.quantity }}
- </template>
- <el-form-item
- v-else
- :prop="`productList.${$index}.quantity`"
- required
- >
- <el-input
- :ref="'quantity' + $index"
- type="number"
- placeholder="请输入"
- @keyup.native="
- moveFocus($event, $index, 'quantity', '产品', row)
- "
- v-model="row.quantity"
- @input="computeNum(row, $index, true)"
- :disabled="row.isSave"
- >
- </el-input>
- </el-form-item>
- </template>
- <template v-slot:unit="{ row, $index }">
- <template v-if="row.isSave">
- {{ row.unit }}
- </template>
- <el-form-item
- v-else
- :prop="`productList.${$index}.unit`"
- required
- >
- <el-select
- :disabled="row.isSave"
- v-model="row.unitId"
- 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>
- <template v-slot:packingSpecificationLabel="{ row, $index }">
- <el-tag v-for="item in row.packingSpecificationLabel">{{
- item
- }}</el-tag>
- </template>
- <template v-slot:singleWeight="{ row, $index }">
- <el-input
- :disabled="row.isSave || row.weightUnit == row.unit"
- v-model="row.singleWeight"
- placeholder="请输入"
- :min="0"
- style="width: 100%"
- @input="inputSingleWeight(row, $index)"
- >
- <template slot="append">
- {{ row.weightUnit }}
- </template>
- </el-input>
- </template>
- <template v-slot:weight="{ row, $index }">
- <el-input
- :disabled="row.isSave || row.weightUnit == row.unit"
- v-model="row.weight"
- placeholder="请输入"
- @input="inputAllweight(row, $index)"
- >
- </el-input>
- </template>
- <template v-slot:unitPrice="{ row, $index }">
- <template v-if="row.isSave">
- {{ row.unitPrice ? row.unitPrice + '/元' : '' }}
- </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">
- 元/{{ row.measureUnit }}
- </template>
- </el-input>
- </el-form-item>
- </template>
- <template v-slot:totalMoney="{ row, $index }">
- {{
- changeCount(
- calcSumTotal(row.measureQuantity, row.unitPrice, row)
- )
- }}
- </template>
- <template v-slot:supplierId="{ row, $index }">
- <template v-if="row.isSave">
- {{ row.supplierName }}
- </template>
- <el-select
- v-else
- @change="selectSupplier($event, row)"
- v-model="row.supplierId"
- placeholder="请选择"
- >
- <el-option
- v-for="item in row.supplierListOptions"
- :label="item.name"
- :value="item.id"
- :key="item.id"
- >
- </el-option>
- </el-select>
- </template>
- <template v-slot:warehouseName="{ 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>
- <template v-slot:purpose="{ 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>
- <template v-slot:modelKey="{ row, $index }">
- <el-form-item>
- <DictSelection
- dictName="物品机型"
- clearable
- v-model="row.modelKey"
- :isOne="$index === 0"
- filterable
- allow-create
- default-first-option
- >
- </DictSelection>
- </el-form-item>
- </template>
- <template v-slot:colorKey="{ row, $index }">
- <el-form-item>
- <DictSelection
- dictName="物品颜色"
- clearable
- v-model="row.colorKey"
- :isOne="$index === 0"
- filterable
- allow-create
- default-first-option
- >
- </DictSelection>
- </el-form-item>
- </template>
- <template v-slot:detailProductionDate="{ 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>
- <template v-slot:detailPurchaseDate="{ 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>
- <template v-slot:detailExpireDate="{ 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>
- <template v-slot:action="{ 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>
- </ele-pro-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">
- </el-table-column>
- <el-table-column
- label="批次号"
- prop="batchNo"
- width="150"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="包装编码"
- prop="packageNo"
- width="130"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="名称"
- prop="categoryName"
- width="120"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="编码"
- prop="categoryCode"
- width="120"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="型号"
- prop="categoryModel"
- width="80"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="规格"
- prop="specification"
- width="80"
- :show-overflow-tooltip="true"
- ></el-table-column>
- <el-table-column
- label="牌号"
- prop="brandNum"
- width="80"
- :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="仓库"
- :show-overflow-tooltip="true"
- prop="warehouseName"
- width="200"
- ></el-table-column>
- <el-table-column
- label="供应商"
- align="center"
- prop="supplierName"
- width="200"
- :show-overflow-tooltip="true"
- >
- </el-table-column>
- <el-table-column label="供应商代号" prop="supplierCode" width="130">
- </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">
- <template slot-scope="{ row, $index }">
- <el-input v-model="row.clientCode"></el-input>
- </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 }">
- <DictSelection
- dictName="物品机型"
- clearable
- v-model="row.modelKey"
- :isOne="false"
- filterable
- allow-create
- default-first-option
- >
- </DictSelection>
- </template>
- </el-table-column>
- <el-table-column label="颜色" prop="colorKey" width="300">
- <template slot-scope="{ row }">
- <DictSelection
- dictName="物品颜色"
- clearable
- v-model="row.colorKey"
- :isOne="false"
- filterable
- allow-create
- default-first-option
- >
- </DictSelection>
- </template>
- </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>
- <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="操作" 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="150"
- ></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.extInfo.clientCode"
- ></el-input>
- <span v-else>{{ row.extInfo.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-column label="操作" width="120" fixed="right">
- <template slot-scope="{ row, $index }">
- <el-button type="text" @click="materialDelete(row, $index)">
- 删除
- </el-button>
- </template>
- </el-table-column> -->
- </el-table>
- </div>
- <div class="storage_btn">
- <el-button
- type="primary"
- :loading="saveLoading"
- @click="handleStorage('save')"
- >保存</el-button
- >
- <el-button
- type="primary"
- :loading="saveLoading"
- @click="handleStorage('Storage')"
- >入库</el-button
- >
- </div>
- </el-card>
- <!-- 产品选择弹框 -->
- <selectType
- :visibleDialog.sync="visibleDialog"
- :title="title"
- :bizScene="formData.bizType"
- :treeIds="formData.extInfo.assetType"
- :loadTree.sync="loadTree"
- @selectTableData="addGoods"
- :cacheKeyUrl="'wms-warehouseManagement-stockManagement-add'"
- />
- <!-- 仓库选择弹框 -->
- <WarehousingDialog
- ref="wareHouseDailogRef"
- @selection="wareHouseSelection"
- ></WarehousingDialog>
- <!-- 生产日期、采购日期弹框 -->
- <el-dialog :visible.sync="dateVisible" title="选择日期" width="400px">
- <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>
- <outboundRequisitionDialog
- ref="outboundRequisitionDialogRef"
- @detailData="outboundRequisitionSelection"
- type="1"
- :bizType="formData.bizType"
- />
- </div>
- </template>
- <script>
- import XLSX from 'xlsx';
- import { mapActions, mapGetters } from 'vuex';
- import outboundRequisitionDialog from '../components/outboundRequisitionDialog.vue';
- import openContactDialog from '@/components/contactDialog/openContactDialog.vue';
- import elTableInfiniteScroll from 'el-table-infinite-scroll';
- import storageApi from '@/api/warehouseManagement/index.js';
- import WarehousingDialog from '../components/WarehousingDialog.vue';
- import { getCode } from '@/api/codeManagement/index.js';
- import selectType from './components/selectType';
- import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
- import {
- sceneState,
- qualityResultsOptions,
- qualityResults,
- qualityStatus
- } from '@/utils/dict/index';
- import { getTreeByGroup } from '@/api/classifyManage';
- import outin from '@/api/warehouseManagement/outin';
- import { deepClone } from '@/utils';
- import BigNumber from 'bignumber.js';
- import { isBoolean } from 'mathjs';
- import { parameterGetByCode } from '@/api/sys/index.js';
- import tabMixins from '@/mixins/tableColumnsMixin';
- import { color } from 'echarts';
- export default {
- mixins: [tabMixins],
- name: 'stockManagementAdd',
- components: {
- selectType,
- WarehousingDialog,
- outboundRequisitionDialog,
- openContactDialog
- },
- // 虚拟列表滚动方法
- directives: {
- 'el-table-infinite-scroll': elTableInfiniteScroll
- },
- data() {
- return {
- newColumns: [], // 动态表头
- sceneState,
- saveLoading: false,
- dateVisible: false,
- loadTree: true,
- visibleDialog: false,
- title: '选择产品',
- goodsLists: [],
- cacheKeyUrl: 'wms-stockManagement-add-goods',
- formData: {
- bizType: '',
- storageTime: '',
- extInfo: {
- assetType: []
- }
- },
- rules: {
- 'extInfo.assetType': {
- required: true,
- message: '请选择物品类型',
- trigger: ['change', 'blur']
- },
- bizType: {
- required: true,
- message: '请选择入库场景',
- trigger: 'change'
- }
- },
- qualityResultsOptions, // 质检结果下拉选项 0无 1合格 2不合格
- 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, // 物料虚拟分页页数
- packingSpecificationOption: [], // 包装规格下拉
- isPrice: 1,
- columnsVersion: 1
- };
- },
- computed: {
- ...mapGetters(['dict', 'getDict']),
- clientEnvironmentId() {
- return this.$store.state.user.info.clientEnvironmentId;
- },
- columns() {
- // 当columnsVersion变化时会重新计算
- const version = this.columnsVersion;
- return [
- {
- label: '序号',
- type: 'index',
- width: 50,
- align: 'center'
- },
- {
- label: '产品编码',
- prop: 'categoryCode',
- width: 130,
- showOverflowTooltip: true,
- align: 'center'
- },
- {
- showOverflowTooltip: true,
- label: '产品名称',
- prop: 'categoryName',
- width: 200,
- align: 'center'
- },
- {
- label: '型号',
- showOverflowTooltip: true,
- prop: 'categoryModel',
- width: 100,
- align: 'center'
- },
- {
- label: '规格',
- prop: 'specification',
- showOverflowTooltip: true,
- width: 100,
- align: 'center'
- },
- {
- label: '牌号',
- prop: 'brandNum',
- showOverflowTooltip: true,
- width: 100,
- align: 'center'
- },
- ...this.newColumns.map((item) => {
- return {
- label: item.label,
- prop: item.prop,
- showOverflowTooltip: true,
- width: 100,
- align: 'center'
- };
- }),
- {
- label: '批次号',
- showOverflowTooltip: true,
- prop: 'batchNo',
- width: 200,
- slot: 'batchNo',
- align: 'center',
- headerSlot: 'headerBatchNo'
- },
- {
- label: '数量',
- showOverflowTooltip: true,
- prop: 'quantity',
- slot: 'quantity',
- width: 180,
- align: 'center',
- headerSlot: 'headerPackingQuantity'
- },
- {
- label: '单位',
- showOverflowTooltip: true,
- prop: 'unit',
- slot: 'unit',
- width: 100,
- align: 'center',
- headerSlot: 'headerUnit'
- },
- {
- label: '包装数量',
- showOverflowTooltip: true,
- prop: 'packingQuantity',
- slot: 'packingQuantity',
- width: 180,
- align: 'center'
- },
- {
- label: '包装单位',
- showOverflowTooltip: true,
- prop: 'packingUnit',
- slot: 'packingUnit',
- width: 100,
- align: 'center'
- },
- {
- label: '包装规格',
- showOverflowTooltip: true,
- prop: 'packingSpecificationLabel',
- slot: 'packingSpecificationLabel',
- width: 300,
- align: 'center'
- },
- {
- label: '允许拆包',
- prop: 'isUnpack',
- width: 80,
- formatter: (_row, _column, cellValue) => {
- return cellValue ? '是' : '否';
- },
- align: 'center'
- },
- {
- label: '计量数量',
- prop: 'measureQuantity',
- width: 100,
- align: 'center'
- },
- {
- label: '计量单位',
- prop: 'measureUnit',
- width: 100,
- align: 'center'
- },
- {
- label: '单重',
- prop: 'singleWeight',
- slot: 'singleWeight',
- showOverflowTooltip: true,
- width: 180,
- align: 'center'
- },
- {
- label: '总重',
- prop: 'weight',
- slot: 'weight',
- showOverflowTooltip: true,
- width: 150,
- align: 'center'
- },
- {
- label: '重量单位',
- prop: 'weightUnit',
- showOverflowTooltip: true,
- width: 100,
- align: 'center'
- },
- this.isPrice == 1
- ? {
- label: '单价',
- slot: 'price',
- prop: 'price',
- showOverflowTooltip: true,
- width: 150,
- align: 'center'
- }
- : {
- label: '单价',
- prop: 'price',
- width: 1
- },
- this.isPrice == 1
- ? {
- label: '金额',
- slot: 'totalMoney',
- prop: 'totalMoney',
- showOverflowTooltip: true,
- width: 100,
- align: 'center'
- }
- : {
- label: '金额',
- prop: 'totalMoney',
- width: 1
- },
- {
- label: '供应商',
- slot: 'supplierId',
- prop: 'supplierId',
- showOverflowTooltip: true,
- width: 200,
- align: 'center'
- },
- {
- label: '供应商代号',
- slot: 'supplierCode',
- prop: 'supplierCode',
- showOverflowTooltip: true,
- width: 100,
- align: 'center'
- },
- {
- label: '仓库',
- prop: 'warehouseName',
- slot: 'warehouseName',
- showOverflowTooltip: true,
- width: 300,
- align: 'center',
- headerSlot: 'headerWarehouseName'
- },
- {
- minWidth: 300,
- prop: 'modelKey',
- showOverflowTooltip: true,
- label: '机型',
- slot: 'modelKey',
- align: 'center'
- },
- {
- minWidth: 300,
- prop: 'colorKey',
- showOverflowTooltip: true,
- label: '颜色',
- slot: 'colorKey',
- align: 'center'
- },
- {
- label: '采购原因',
- prop: 'purpose',
- slot: 'purpose',
- showOverflowTooltip: true,
- width: 200,
- align: 'center'
- },
- {
- label: '生产日期',
- prop: 'detailProductionDate',
- slot: 'detailProductionDate',
- showOverflowTooltip: true,
- width: 220,
- align: 'center'
- },
- {
- label: '采购日期',
- prop: 'detailPurchaseDate',
- slot: 'detailPurchaseDate',
- showOverflowTooltip: true,
- width: 220,
- align: 'center'
- },
- {
- label: '失效日期',
- prop: 'detailExpireDate',
- slot: 'detailExpireDate',
- showOverflowTooltip: true,
- width: 220,
- align: 'center'
- },
- {
- columnKey: 'action',
- label: '操作',
- width: 250,
- align: 'center',
- resizable: false,
- slot: 'action',
- showOverflowTooltip: true,
- fixed: 'right'
- }
- ];
- }
- },
- watch: {
- packingList: {
- handler(newVal) {
- console.log('包装列表', newVal);
- console.log('当前包装列表加载页数', this.pickingPageNum);
- this.showPackingList = newVal.slice(
- 0,
- this.pageSize * (this.pickingPageNum > 0 ? this.pickingPageNum : 1)
- );
- this.pickingPageNum = Math.ceil(
- this.showPackingList.length / this.pageSize
- );
- },
- deep: true
- },
- materialList: {
- handler(newVal) {
- console.log('物料列表', newVal);
- console.log('当前物料列表加载页数', this.materielPageNum);
- this.showMaterialList = newVal.slice(
- 0,
- this.pageSize *
- (this.materielPageNum > 0 ? this.materielPageNum : 1)
- );
- },
- deep: true
- },
- '$route.query': {
- handler(newQuery, oldQuery) {
- if (newQuery?.detailId) {
- this.viewInit();
- }
- },
- deep: true // 确保对象内部的属性变化也能被监听到
- }
- },
- created() {
- //仓库出入库是否显示金额(0:不显示 1:显示)
- parameterGetByCode({
- code: 'wms_price'
- }).then((res) => {
- this.isPrice = res.value;
- });
- if (this.$route.query.name == 'inboundRequests') {
- this.getProduct();
- }
- this.requestDict('不拆物料层规格');
- this.getFieldModel();
- this.getListItems();
- this.initUserInfo();
- this.getNowFormatDate();
- if (this.$route.query.id && !this.$route.query.name) {
- storageApi
- .getApplystorageDetailById(this.$route.query.id)
- .then(async (data) => {
- this.formData.extInfo.assetType = [data.rootCategoryLevelId];
- this.formData.bizType = String(data.type);
- this.formData.sourceBizNo = data.code;
- this.formData.id = data.id;
- this.formData.bizNo = data.bizNo;
- const batchNo = await getCode('lot_number_code');
- this.productList = data.detailList.map((item, index) => {
- return {
- index: this.productList.length + index,
- categoryId: item.categoryId, // 物品id
- categoryName: item.categoryName, // 物品名称
- categoryCode: item.categoryCode, // 物品编码
- categoryModel: item.modelType, // 物品型号
- specification: item.specification, // 规格
- brandNum: item.brandNum, // 牌号
- batchNo: item.batchNo || batchNo, // 批次号
- minPackingQuantity: item.quantity, // 最小包装单元数量
- packingQuantity: 1, // 包装数量
- packingUnit: item.packingUnit, // 单位
- measureQuantity: 0, // 计量数量
- measureUnit: item.measuringUnit, // 计量单位
- netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
- weight: item?.packingWeight || 0, // 重量
- weightUnit: item.weightUnit, // 重量单位
- totalMoney: '', // 总价
- unitPrice: item.unitPrice, // 单价
- purpose: item.purpose, // 用途
- isUnpack: item.isUnpack, // 是否允许拆包
- warehouseId: item.warehouseId, // 仓库Id
- warehouseName: item.warehouseName, // 仓库名称
- warehouseIds: [item.warehouseId],
- warehouseNames: [item.warehouseName]
- // 编辑时单位选择消失bug
- };
- });
- // this.$nextTick(() => {
- // this.listSaveArrs();
- // });
- });
- }
- if (this.$route.query.detailId) {
- this.viewInit();
- }
- },
- methods: {
- ...mapActions('dict', ['requestDict']),
- changeCount(number) {
- return new BigNumber(number).toString();
- },
- viewInit() {
- const _this = this;
- // 编辑时选单位没有选项bug
- let packingSpecification;
- storageApi
- .getInboundDetailsById(this.$route.query.detailId)
- .then(async (data) => {
- this.formData.extInfo.assetType = data.extInfo.assetType.split(',');
- this.formData.bizType = String(data.bizType);
- this.formData.sourceBizNo = data.code;
- this.formData.id = data.id;
- this.formData.bizNo = data.bizNo;
- const batchNo = await getCode('lot_number_code');
- packingSpecification =
- await storageApi.getCategoryPackageDisposition({
- categoryIds: data.outInDetailList.map((item) => item.categoryId)
- });
- console.log(packingSpecification);
- this.packingSpecificationOption = data.outInDetailList.map(
- (item) => {
- return packingSpecification
- .filter((ite) => item.categoryId == ite.categoryId)
- .sort((a, b) => a.sort - b.sort);
- }
- );
- const newSpecificationOption = this.packingSpecificationOption;
- this.productList = data.outInDetailList.map(
- (productItem, productIndex) => {
- return {
- ...productItem,
- index: this.productList.length + productIndex,
- isSave: true,
- // 编辑时没有单位选项
- packingSpecificationOption:
- newSpecificationOption[productIndex],
- //
- packingSpecificationLabel:
- productItem.extField?.packingSpecification?.split(','),
- batchNo: productItem.batchNo || batchNo, // 批次号
- warehouseIds: [productItem.warehouseId], // 仓库Id
- warehouseNames: [productItem.warehouseName], // 仓库名称
- outInDetailRecordRequestList:
- productItem.outInDetailRecordRequestList?.length > 0
- ? productItem.outInDetailRecordRequestList.map(
- (packingItem, packingIndex) => {
- return {
- ...packingItem,
- index:
- this.productList.length +
- productIndex +
- '-' +
- packingIndex, // 包装索引
- batchNo: productItem.batchNo || batchNo, // 批次号
- parentIndex:
- this.productList.length + productIndex, // 物品索引
- categoryName: productItem.categoryName,
- categoryCode: productItem.categoryCode,
- materialDetailList:
- packingItem.materialDetailList.map(
- (materialItem, materialIndex) => {
- return {
- ...materialItem,
- index:
- this.productList.length +
- productIndex +
- '-' +
- packingIndex +
- '——' +
- materialIndex, // 包装索引
- parentIndex:
- this.productList.length +
- productIndex +
- '-' +
- packingIndex, // 物品索引
- batchNo: batchNo, // 批次号
- categoryName: productItem.categoryName,
- categoryCode: productItem.categoryCode
- };
- }
- )
- };
- }
- )
- : []
- };
- }
- );
- console.log('this.productList-----------', this.productList);
- // 获取包装维度数据
- const arr = [];
- for (const key in this.productList) {
- for (const k in this.productList[key]
- .outInDetailRecordRequestList) {
- arr.push({
- ...this.productList[key].outInDetailRecordRequestList[k]
- });
- }
- }
- this.packingList = arr;
- // 获取物料维度数据
- let iArr = [];
- arr.forEach((item) => {
- item.materialDetailList.forEach((ele) => {
- iArr.push({ ...ele });
- });
- });
- this.materialList = iArr;
- });
- },
- 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) {
- console.log(row, 'row1');
- if (row.singleWeight < 0) {
- this.$set(this.productList[index], 'singleWeight', 1);
- }
- if (row.measureUnit == row.weightUnit) {
- row.weight = row.singleWeight * row.quantity;
- row.measureQuantity = row.weight;
- } else {
- row.weight = row.singleWeight * row.measureQuantity;
- }
- //重量
- // if (row.measureType == '2') {
- // if (row.packingUnit == 'KG') {
- // const weight =
- // Number(row.measureQuantity) * Number(row.singleWeight);
- // this.$set(this.productList[index], 'weight', weight);
- // } else {
- // this.$set(this.productList[index], 'weight', measureQuantity);
- // }
- // }
- console.log(row, 'row2');
- },
- inputAllweight(row, index) {
- if (row.weight < 0) {
- this.$set(this.productList[index], 'weight', 1);
- }
- if (row.measureUnit == row.weightUnit) {
- row.measureQuantity = row.weight;
- row.singleWeight =
- Math.trunc((row.measureQuantity / row.quantity) * 10000) / 10000;
- } else {
- row.singleWeight = row.measureQuantity
- ? row.weight / row.measureQuantity
- : 0;
- }
- // const singleWeight = Number(row.weight) / Number(row.measureQuantity);
- // this.$set(this.productList[index], 'singleWeight', singleWeight);
- },
- // 仓库选择
- // wareHouseSelection(val, index) {
- // console.log('仓库选择', val);
- // let arr = this.productList[index].outInDetail
- // },
- // 计算最小单元数量
- // 小数处理,最大3位
- format3(str) {
- let value = str;
- value = value.toString().replace(/[^0-9.]/g, '');
- const parts = value.split('.');
- if (parts.length > 2) {
- value = parts[0] + '.' + parts.slice(1).join('');
- }
- if (parts.length === 2) {
- value = parts[0] + '.' + parts[1].slice(0, 3);
- }
- console.log(value);
- return value;
- },
- async computeNum(row, index, isClear) {
- row.quantity = this.format3(row.quantity);
- // console.log(row.packingSpecificationOption);
- // console.log(row.packingUnit);
- let data = row.packingSpecificationOption.find(
- (item) => item.id == row.unitId
- );
- row.unit = data.conversionUnit;
- // 清空仓库(包装数量输入)
- if (isClear) {
- if (row.quantity < 0) {
- this.$set(this.productList[index], 'quantity', 1);
- }
- }
- //如果有包装数量和包装单位
- if (row.quantity && row.unit) {
- //获取仓库
- const res = await warehouseDefinition.list({
- inventoryType: row?.categoryLevelPathIdParent
- });
- // 只有一个仓库自动显示出来
- if (res.length == 1) {
- // let name = res[0]?.factoryName + '-' + res[0]?.name;
- let name = 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.quantity,
- 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 (
- // data.id == ite.id &&
- // ite.packingUnit != ite.conversionUnit
- // );
- // });
- let endIndex = row.packingSpecificationOption.findIndex(
- (ite) => data.id == ite.id
- );
- console.log(endIndex, 'endIndex');
- let total = Number(row.quantity);
- for (; 0 < endIndex; endIndex--) {
- total = this.$math.format(
- row.packingSpecificationOption[endIndex].packageCell * total,
- 14
- );
- }
- //计量数量
- row.measureQuantity = this.changeCount(total);
- // --------------------------------------------------------------------
- //计量单位不是数量时,配置了单重的重量计算
- // row.measureType != 1 &&
- let weight = 0;
- if (row.measureUnit == row.weightUnit) {
- weight = row.measureQuantity;
- //包装单位与重量单位相等时,单重重量为0
- if (row.unit == row.weightUnit) {
- row.singleWeight = 0;
- } else {
- row.singleWeight =
- Math.trunc((row.measureQuantity / row.quantity) * 10000) /
- 10000;
- }
- } else if (row.singleWeight) {
- weight = row.measureQuantity * Number(row.singleWeight);
- }
- this.$set(this.productList[index], 'weight', weight);
- this.$set(
- this.productList[index],
- 'packingQuantity',
- this.setPNum(row)
- );
- }
- },
- //出入库申请列表操作直接入库
- getProduct() {
- let aaa = [this.$route.query.inId];
- console.log(aaa, '出入库申请入库操作直接入库');
- storageApi.getApplystoragedetails(aaa).then(async (res) => {
- if (this.$route.query.type == 2) {
- // 出库
- let data = await storageApi.getHierarchyFifo({
- type: 1,
- builders: res.map((item) => {
- return {
- categoryId: item.categoryId,
- num: item.measureQuantity
- };
- })
- });
- if (data?.length > 0) {
- this.outboundRequisitionSelection(data, 1, {
- sourceBizNo: this.$route.query.code,
- bizType: this.$route.query.sourceType,
- assetType: Array.from(
- new Set(res.map((item) => item.rootCategoryLevelId))
- ).join(',')
- });
- } else {
- this.$message.warning('该出库申请单无库存');
- }
- } else {
- // 入库
- const batchNo = await getCode('lot_number_code');
- console.log(res, '入库');
- let data = res.map((item, index) => {
- delete item.extInfo;
- return {
- ...item,
- index,
- batchNo,
- id: '',
- warehouseIds: [item.warehouseId],
- warehouseNames: [item.warehouseName]
- };
- });
- this.outboundRequisitionSelection(data, 1, {
- sourceBizNo: this.$route.query.code,
- bizType: this.$route.query.sourceType,
- assetType: Array.from(
- new Set(res.map((item) => item.rootCategoryLevelId))
- ).join(',')
- });
- }
- });
- },
- async outboundRequisitionSelection(data, dimension, query) {
- console.log('data-----------', data);
- console.log('query-----------', query);
- console.log(this.formData.bizType, 'bbbbbtype');
- if (this.formData.bizType != 10) {
- this.formData.sourceBizNo = query.sourceBizNo;
- this.formData.bizType = query.bizType;
- this.formData.extInfo.assetType = query.assetType.split(',');
- const batchNo = await getCode('lot_number_code');
- // 获取包装规格
- let packingSpecification =
- await storageApi.getCategoryPackageDisposition({
- categoryIds: data.map((item) => item.categoryId)
- });
- // 获取供应商
- const supplierList = await storageApi.contactQueryByCategoryIdsAPI({
- categoryIds: data.map((item) => item.categoryId)
- });
- this.packingSpecificationOption = data.map((item) => {
- return packingSpecification
- .filter((ite) => item.categoryId == ite.categoryId)
- .sort((a, b) => a.sort - b.sort);
- });
- console.log(
- 'this.packingSpecificationOption------------------------------------------包装组',
- this.packingSpecificationOption
- );
- console.log(data, 'datadatadatadatadata');
- data.map((productItem, productIndex) => {
- // 显示规格
- let packingSpecificationLabel = this.packingSpecificationOption[
- productIndex
- ]
- .map((item) => {
- if (item.sort > 0) {
- return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
- }
- })
- .filter((item) => !!item);
- // let r= {
- // ...productItem,
- console.log(productItem, 'productItem');
- productItem.weight = productItem.weight
- ? Number(productItem.weight)
- : 0;
- // productItem.singleWeight = 0;
- productItem.measureUnit = productItem.measuringUnit; // 计量单位
- productItem.index = this.productList.length + productIndex;
- productItem.isSave =
- productItem.outInDetailRecordRequestList?.length > 0
- ? true
- : false;
- productItem.netWeight =
- productItem.netWeight > 0 ? productItem.netWeight : 0;
- productItem.materielCode = productItem.materielCode;
- productItem.categoryModel = productItem.modelType; // 物品型号
- productItem.specification = productItem.specification; // 规格
- productItem.engrave = productItem.engrave; // 刻码
- productItem.materielDesignation = productItem.materielDesignation; //物料代号
- productItem.clientCode = productItem.clientCode; // 客户代号
- productItem.batchNo = productItem.batchNo || batchNo; // 批次号
- productItem.warehouseIds = [productItem.warehouseId]; // 仓库Id
- productItem.warehouseNames = [productItem.warehouseName]; // 仓库名称
- productItem.packingSpecificationOption =
- this.packingSpecificationOption[productIndex]; // 包装规格选项
- productItem.packingSpecificationLabel = packingSpecificationLabel; // 包装规格显示
- productItem.outInDetailRecordRequestList =
- productItem.outInDetailRecordRequestList?.length > 0
- ? productItem.outInDetailRecordRequestList.map(
- (packingItem, packingIndex) => {
- return {
- ...packingItem,
- index:
- this.productList.length +
- productIndex +
- '-' +
- packingIndex, // 包装索引
- batchNo: productItem.batchNo || batchNo, // 批次号
- parentIndex: this.productList.length + productIndex, // 物品索引
- categoryName: productItem.categoryName,
- categoryCode: productItem.categoryCode,
- materialDetailList: packingItem.materialDetailList.map(
- (materialItem, materialIndex) => {
- return {
- ...materialItem,
- index:
- this.productList.length +
- productIndex +
- '-' +
- packingIndex +
- '——' +
- materialIndex, // 包装索引
- parentIndex:
- this.productList.length +
- productIndex +
- '-' +
- packingIndex, // 物品索引
- batchNo: batchNo, // 批次号
- categoryName: productItem.categoryName,
- categoryCode: productItem.categoryCode
- };
- }
- )
- };
- }
- )
- : [];
- });
- // this.productList = data;
- this.productList = data.map((item) => {
- if (item.weight === null || item.weight === undefined) {
- item.weight = 0;
- }
- (item.supplierListOptions = supplierList[item.categoryId]), // 供应商列表
- (item.packingUnit = item.measuringUnit); // 单位
- item.packingUnitId = item.packingSpecificationOption.find(
- (v) => v.conversionUnit == item.measuringUnit
- )?.id; // 单位
- // if (this.formData.bizType == 4) {
- // item.packingUnit = '箱';
- // } else {
- // item.packingUnit = '';
- // }
- return item;
- });
- console.log(this.productList, 'productList');
- this.$nextTick(() => {
- this.batchSave();
- });
- // this.productList.map((v) => {
- // v.weight = isNaN(v.weight);
- // });
- // 获取包装维度数据
- // const arr = [];
- // for (const key in this.productList) {
- // for (const k in this.productList[key]
- // .outInDetailRecordRequestList) {
- // arr.push({
- // ...this.productList[key].outInDetailRecordRequestList[k]
- // });
- // }
- // }
- // 获取物料维度数据
- // let iArr = [];
- // arr.forEach((item) => {
- // item.materialDetailList.forEach((ele) => {
- // iArr.push({ ...ele });
- // });
- // });
- // this.materialList = iArr;
- } else {
- this.selWWData = query;
- this.$set(this.formData, 'sourceBizNo', query.sourceBizNo);
- }
- },
- // 获取动态表头
- 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
- };
- })
- .filter((item) => item.label !== '包装规格');
- console.log(newRes, 'newRes');
- this.newColumns = [...newRes];
- });
- },
- // 初始化当前用户信息
- async initUserInfo() {
- const res = await warehouseDefinition.tree();
- let info = JSON.parse(localStorage.getItem('info'));
- console.log(info, 'infoinfoinfo');
- let obj = res.find(
- (item) => item.id === info.deptIds[info.deptIds.length - 1]
- );
- // if (!obj) return;
- if (obj) {
- console.log(
- obj,
- 'objobjobjobjobjobjobjobjobjobjobjobjobjobjobjobjobj'
- );
- this.formData.extInfo.deptCode = obj?.id;
- this.formData.extInfo.deptName = obj?.name;
- } else {
- this.formData.extInfo.deptName = info.deptName
- ? info.deptName
- : info.groupName
- ? info.groupName
- : '';
- }
- this.formData.extInfo.createUserName = info.name;
- this.formData.createUserId = info.userId;
- },
- // 获取当前时间函数
- getNowDate() {
- let date = new Date(),
- obj = {
- year: date.getFullYear(), //获取完整的年份(4位)
- 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;
- },
- // 赋值入库时间
- getNowFormatDate() {
- let obj = this.getNowDate();
- this.formData.storageTime = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
- },
- // 获取物品列表
- async getListItems() {
- const res2 = await warehouseDefinition.getTreeByGroup({ type: 2 });
- this.goodsLists = res2;
- },
- // 打开单据来源弹窗
- openDocumentSourceDialog() {
- console.log('打开单据来源弹窗');
- this.$refs.outboundRequisitionDialogRef.open();
- },
- // 清除单据来源
- clearSourceBizNo() {
- this.$set(this.formData, 'sourceBizNo', '');
- this.productList = [];
- this.packingList = [];
- },
- // 返回
- back() {
- this.$router.go(-1);
- },
- // 添加产品
- addProduct() {
- this.$refs.formName.validate((valid) => {
- if (valid) {
- this.visibleDialog = true;
- } else {
- console.log('error submit!!');
- return false;
- }
- });
- // if (this.formData.extInfo.assetType.length <= 0) {
- // return this.$message.error('请选择物品类型');
- // }
- // if (!this.formData.bizType) {
- // return this.$message.error('请选择入库类型');
- // }
- },
- contactDialogSuccess(data) {
- this.$set(this.formData, 'clientName', data.name);
- this.$set(this.formData, 'clientCode', data.code);
- },
- // 键盘移动
- moveFocus(event, index, key, type, row) {
- let keyfield = [];
- let listLength = 0;
- switch (type) {
- case '产品':
- listLength = this.productList.length;
- keyfield = ['batchNo', 'quantity', '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) {
- console.log('向上');
- if (index === 0) {
- // 第一行
- console.log('第一行无法向上');
- 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) {
- console.log('向下');
- if (index === listLength - 1) {
- // 最后一行
- console.log('最后一行无法向下');
- 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) {
- console.log('向右');
- if (
- index === listLength - 1 &&
- key === keyfield[keyfield.length - 1]
- ) {
- // 最后一行最后一个
- console.log('最后一行最后一个无法向左');
- return;
- }
- console.log(this.$refs);
- 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();
- });
- }
- }
- },
- handleAvatarSuccess() {
- this.$refs.fileUploadBtn.clearFiles(); //上传成功之后清除历史记录**加粗样式**
- },
- async onChange(file) {
- console.log(XLSX);
- this.warehousingMaterialList = [];
- this.resultArray = [];
- const loading = this.$loading({
- lock: true,
- text: '加载中...'
- });
- /**
- * 1. 使用原生api去读取好的文件
- * */
- // console.log("原始上传的文件", file);
- // 读取文件不是立马能够读取到的,所以是异步的,使用Promise
- let dataBinary = await new Promise((resolve) => {
- // Web API构造函数FileReader,可实例化对象,去调用其身上方法,去读取解析文件信息
- let reader = new FileReader(); // https://developer.mozilla.org/zh-CN/docs/Web/API/FileReader
- // console.log("实例化对象有各种方法", reader);
- reader.readAsBinaryString(file.raw); // 读取raw的File文件
- reader.onload = (ev) => {
- // console.log("文件解析流程进度事件", ev);
- resolve(ev.target.result); // 将解析好的结果扔出去,以供使用
- };
- });
- // console.log("读取出的流文件", dataBinary);
- /**
- * 2. 使用xlsx插件去解析已经读取好的二进制excel流文件
- * */
- let workBook = XLSX.read(dataBinary, {
- type: 'binary',
- cellDates: true
- });
- // excel中有很多的sheet,这里取了第一个sheet:workBook.SheetNames[0]
- let firstWorkSheet = workBook.Sheets[workBook.SheetNames[0]];
- // 分为第一行的数据,和第一行下方的数据
- // const header = this.getHeaderRow(firstWorkSheet);
- // console.log('读取的excel表头数据(第一行)', header);
- const xlsxData = XLSX.utils.sheet_to_json(firstWorkSheet);
- console.log('读取所有excel数据', xlsxData);
- // let modelTypeList = xlsxData.map((item) => {
- // return item['型号'];
- // });
- // let nameList = xlsxData.map((item) => {
- // return item['物品名称'];
- // });
- let codeList = xlsxData.map((item) => {
- return item['sap物料码'];
- });
- let functionType = {};
- xlsxData.map((item) => {
- functionType[item['sap物料码']] = item['采购原因'];
- });
- this.formData.extInfo.assetType = ['6']; //备品备件
- this.formData.bizType = '2'; // 采购入库
- outin
- .getListByNameOrModeType({
- // modelTypeList,
- // nameList,
- codeList,
- categoryLevelId: '6'
- })
- .then(async (data) => {
- console.log('查询到的备件数据', data);
- const batchNo = await getCode('lot_number_code');
- // 添加包装数量和最小包装单元
- this.productList = data.map((item, index) => {
- console.log(xlsxData);
- let filterArray = xlsxData.filter(
- (xlsxItem) => xlsxItem['sap物料码'] == item.code
- );
- console.log(filterArray);
- 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: item.batchNo || batchNo, // 批次号
- minPackingQuantity: 1, // 最小包装单元数量
- packingQuantity: filterArray[0]['数量'], // 包装数量
- packingUnit: item.packingUnit, // 单位
- measureQuantity: 0, // 计量数量
- measureUnit: item.measuringUnit, // 计量单位
- netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
- weight: 0, // 重量
- weightUnit: item.weightUnit, // 重量单位
- totalMoney: '', // 总价
- unitPrice: item.unitPrice, // 单价
- purpose: functionType[item.code], // 用途
- isUnpack: item.isUnpack // 是否允许拆包
- };
- });
- console.log(this.productList);
- this.handleAvatarSuccess();
- loading.close();
- })
- .catch(() => {
- loading.close();
- });
- },
- // 入库
- handleStorage(type) {
- this.$refs.formName.validate(async (valid) => {
- if (valid) {
- if (!this.productList.length) {
- return this.$message.warning('请至少添加一条产品');
- }
- let boolen = this.productList.every((item) => item.isSave);
- console.log(boolen);
- if (!boolen) {
- this.$message.warning('请先保存所有产品信息');
- return;
- }
- // 处理包装数据
- this.packingList = this.packingList.map((packingItem) => {
- if (packingItem.modelKey) {
- packingItem.modelKey = packingItem.modelKey;
- }
- if (packingItem.colorKey) {
- packingItem.colorKey = packingItem.colorKey;
- }
- return {
- ...packingItem,
- materialDetailList: this.materialList.filter(
- (item) => item.parentIndex === packingItem.index
- ),
- taskId: this.selWWData?.taskId,
- workOrderId: this.selWWData?.workOrderId
- };
- });
- // 处理产品数据
- this.productList = this.productList.map((productItem) => {
- if (productItem.modelKey) {
- productItem.modelKey = productItem.modelKey;
- }
- if (productItem.colorKey) {
- productItem.colorKey = productItem.colorKey;
- }
- return {
- ...productItem,
- outInDetailRecordRequestList: this.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(',');
- // 处理仓库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;
- console.log('入库数据', obj);
- // 是否需要审核(0审核 1跳过审核)
- if (obj.bizType == '12') {
- obj.isSkip = 1;
- } else {
- obj.isSkip = 0;
- }
- // obj.isSkip = 1;
- this.saveLoading = true;
- console.log(obj, 'objobjobjobjobjobj');
- // if(){}
- if (!(await this.isVerifyRepeatIsStock())) {
- this.saveLoading = false;
- return;
- }
- let api = obj.id ? storageApi.update : storageApi.storage;
- api(obj)
- .then(async (res) => {
- console.log('入库成功', res);
- console.log('入库成功', obj.id);
- if (res.code == 0) {
- try {
- if (type != 'save') {
- if (obj.bizType == '12') {
- await storageApi.qualityInspectionTwo({
- outInIds: res.data
- });
- } else {
- await storageApi.submitTwo({ outInIds: res.data });
- }
- this.$message.success('入库成功');
- } else {
- this.$message.success('操作成功');
- }
- // 委外入库(非采购)
- this.saveLoading = false;
- // this.$router.push('/warehouseManagement/stockManagement');
- this.back();
- } catch (error) {
- this.saveLoading = false;
- // this.$router.push('/warehouseManagement/stockManagement');
- this.back();
- console.log('提交流程失败', error);
- }
- }
- })
- .catch((err) => {
- console.log('入库失败', err);
- this.saveLoading = false;
- });
- } else {
- return;
- }
- });
- },
- async isVerifyRepeatIsStock() {
- 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(true);
- })
- .catch(() => {
- resolve(false);
- });
- } else {
- resolve(true);
- }
- });
- },
- pickingHandleScroll() {
- // console.log('---------pickingHandleScroll------------');
- // console.log(this.packingList);
- // console.log(this.showPackingList);
- // console.log(this.pageSize);
- 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;
- console.log(start);
- console.log(end);
- this.showPackingList = this.showPackingList.concat(
- this.packingList.slice(start, end)
- );
- },
- materielHandleScroll() {
- console.log('---------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)
- );
- console.log(this.showMaterialList);
- },
- // 日期选择
- 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
- );
- this.$set(this.productList[productIndex], 'weight', totalWeight);
- this.$set(
- this.productList[productIndex],
- 'singleWeight',
- totalWeight / this.productList[productIndex].measureQuantity
- );
- // 修改拆分物料
- this.materialList.map((item, index) => {
- if (item.parentIndex === row.index) {
- console.log(value / row.measureQuantity);
- 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) {
- // 修改物料质检结果( 1合格 2不合格)
- this.materialList.map((item, index) => {
- if (item.parentIndex === row.index) {
- this.$set(this.materialList[index], 'result', value);
- }
- });
- },
- // 物料质量结果修改
- 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);
- },
- // 重量限制
- 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) {
- //最小包装单元,包装数量,单价
- 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;
- },
- // 表格样式
- rowClass({ row, column, rowIndex, columnIndex }) {
- if (rowIndex === 1) {
- return {
- display: 'none',
- background: '#EEEEEE'
- };
- }
- return { background: '#0000' };
- },
- getNewSpecificationOption(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) {
- if (data.length === 0) return this.$message.warning('请选择产品信息');
- console.log(data, 'datadatadatadatadatadatadata111');
- // 获取批次号
- const batchNo = await getCode('lot_number_code');
- // 获取供应商
- const supplierList = await storageApi.contactQueryByCategoryIdsAPI({
- categoryIds: data.map((item) => item.id)
- });
- console.log(supplierList, '供应商列表');
- // 获取包装规格
- let packingSpecification =
- await storageApi.getCategoryPackageDisposition({
- categoryIds: data.map((item) => item.id)
- });
- console.log(packingSpecification, '--packingSpecification');
- this.packingSpecificationOption = data.map((item) => {
- return packingSpecification
- .filter((ite) => item.id == ite.categoryId)
- .sort((a, b) => a.sort - b.sort);
- });
- console.log('yeyyeyey----------------', data);
- const newSpecificationOption = 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,
- // extField: {
- // packingSpecification: item.extField.packingSpecification
- // }, // 包装规格
- categoryId: item.id, // 物品id
- categoryName: item.name, // 物品名称
- categoryCode: item.code, // 物品编码
- categoryModel: item.modelType, // 物品型号
- specification: item.specification, // 规格
- modelKey: item.modelKey ? item.modelKey : '', // 机型
- colorKey: item.colorKey ? item.colorKey : '', // 颜色
- color: item.color,
- brandNum: item.brandNum, // 牌号
- batchNo: item.batchNo || batchNo, // 批次号
- supplierListOptions: supplierList[item.id], // 供应商列表
- supplierId: '', // 供应商id
- supplierName: '', // 供应商名称
- supplierCode: '',
- measureType: item.measureType, // 计量类型
- approvalNumber: item.approvalNumber, // 批准文号
- packingSpecification: item.packingSpecification, // 包装规格
- packingSpecificationOption: newSpecificationOption[index], // 包装规格选项
- packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
- minPackingQuantity: '', // 最小包装单元数量
- packingQuantity: '', // 包装数量
- packingUnit: item.packingUnit, // 包装数量
- unit: item.measuringUnit, // 单位
- unitId: 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.netWeight, //单重 进来获取净重
- weightUnit: item.weightUnit, // 重量单位
- totalMoney: '', // 总价
- unitPrice: item.unitPrice, // 单价
- purpose: '', // 用途
- isUnpack: item.isUnpack, // 是否允许拆包
- categoryLevelPathIdParent: item.categoryLevelPathIdParent
- };
- });
- this.productList = this.productList.concat(productList);
- console.log('this.productList--------', this.productList);
- },
- // 物品保存验证表单(批量)
- validateForm() {
- return new Promise(async (resolve, reject) => {
- let list = this.productList.map(async (row, index) => {
- let fileds = [
- `productList.${index}.batchNo`,
- `productList.${index}.quantity`,
- `productList.${index}.unit`,
- `productList.${index}.warehouseId`
- ];
- console.log(fileds);
- 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);
- });
- });
- },
- // 物品保存验证表单(单独)
- validateFormIndividually(index) {
- return new Promise(async (resolve) => {
- console.log(index);
- let fileds = [
- `productList.${index}.batchNo`,
- `productList.${index}.quantity`,
- `productList.${index}.unit`,
- `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) {
- console.log(row);
- this.$set(row, 'isSave', false);
- this.deletePackingAndMaterial(row);
- },
- // 根据产品信息删除包装和物料
- deletePackingAndMaterial(row) {
- console.log('row--------', row);
- console.log('packingList------', this.packingList);
- // 删除包装(去掉不相同的包装)
- 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
- );
- console.log('包装当前页数');
- console.log(this.pickingPageNum);
- // 删除物料(获取相同物料)
- 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
- );
- console.log('物料当前页数');
- console.log(this.showMaterialList.length);
- console.log(this.pageSize);
- console.log(this.materielPageNum);
- },
- // 新增批量保存方法
- 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('批量保存失败,请检查必填项');
- }
- },
- setPNum(row) {
- let pNum = 0;
- if (row.unitId) {
- let splitIndex = row.packingSpecificationOption.findIndex(
- (item) => item.id == row.unitId
- );
- if (splitIndex == 0) {
- pNum = Math.ceil(
- row.measureQuantity /
- row.packingSpecificationOption[1]?.packageCell
- );
- }
- if (splitIndex == 1) {
- pNum = row.quantity;
- }
- for (; splitIndex > 1; splitIndex--) {
- pNum = Math.ceil(
- row.quantity *
- row.packingSpecificationOption[splitIndex].packageCell
- );
- }
- } else {
- pNum = Math.ceil(
- row.measureQuantity / row.packingSpecificationOption[1]?.packageCell
- );
- }
- return pNum;
- },
- //产品保存操作
- async listSave(row, index) {
- console.log(row, ';ddd');
- return new Promise(async (resolve, reject) => {
- try {
- await this.validateFormIndividually(index);
- if (row.packingSpecificationLabel?.length < 1) {
- this.$message.error('请到主数据维护包装组信息!');
- return;
- }
- // 不拆包
- if (!row.isUnpack) {
- if (row.packingUnit != row.measureUnit) {
- let pNum = row.quantity;
- let splitIndex = row.packingSpecificationOption.findIndex(
- (item) =>
- item.conversionUnit == row.unit &&
- item.unit != item.conversionUnit
- );
- for (; splitIndex > 1; splitIndex--) {
- pNum = this.$math.format(
- pNum *
- row.packingSpecificationOption[splitIndex].packageCell,
- 14
- );
- }
- console.log(pNum, 'pNum12');
- const { data } = await storageApi.getAssetNum([
- {
- assetCode: row.categoryCode + row.index,
- batchNum: row.batchNo,
- num: Math.ceil(pNum)
- }
- ]);
- // this.generateWrappers(row, index, data)
- } else {
- let pNum = 0;
- const { data } = await storageApi.getAssetNum([
- {
- assetCode: row.categoryCode + row.index,
- batchNum: row.batchNo,
- num: Math.ceil(pNum)
- }
- ]);
- }
- } else {
- let pNum = this.setPNum(row);
- // row.packingQuantity;
- // console.log(row.packingQuantity,'row.packingQuantity')
- // return
- //拆包
- const { data } = await storageApi.getAssetNum([
- {
- assetCode: row.categoryCode + row.index,
- batchNum: row.batchNo,
- num: Math.ceil(pNum)
- }
- ]);
- console.log(data, 'data');
- this.generateWrappers(row, index, data);
- this.$set(
- this.productList[index],
- 'packingQuantity',
- data.length
- );
- }
- this.$set(this.productList[index], 'isSave', true);
- // this.$set(this.productList[index], 'isSave', data.length);
- 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
- ]);
- resolve();
- } catch (error) {
- reject(error);
- }
- });
- },
- // 生成包装
- generateWrappers(row, productIndex, packingCodeList) {
- console.log(packingCodeList, 'packingCodeListROW', row.measureType);
- //计量类型不是数量
- if (!row.isUnpack && row.measureType != 1) {
- // 计量单位=包装单位,则不生成包装层数据
- if (row.measureUnit == row.unit) {
- // 直接生成物品层数据
- this.productList[productIndex].measureQuantity =
- row.measureQuantity;
- this.productList[productIndex].weight = row.weight;
- return;
- }
- }
- 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 || '';
- 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') {
- // 采购入库
- purchaseDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
- // this.curDateType = 'purchaseDate';
- }
- // 判断单位和计量单位是否为不拆物料层规格
- let packingBoolen = !!this.getDict('不拆物料层规格', row.unit)
- .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.unit == '立方') {
- num = 1;
- } else {
- filterArr = row.packingSpecificationOption.filter((item) => {
- return (
- item.packageUnit == row.unit &&
- item.packageUnit != item.conversionUnit
- );
- });
- num = Math.ceil(row.packingQuantity / filterArr[0]?.packageCell);
- }
- } else {
- if (measureBoolen) {
- // 处理单位不为KG类,计量单位为KG类的情况
- let splitIndex = row.packingSpecificationOption.findIndex(
- (item) =>
- item.conversionUnit == row.unit &&
- 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.unit &&
- item.packageUnit != item.conversionUnit
- );
- });
- }
- }
- }
- console.log('num-----------', num);
- if (!row.isUnpack) {
- console.log(row.packingSpecificationOption[1]);
- // let packingUnit = !row.isUnpack ? row.packingUnit : row.packingSpecificationOption[1].conversionUnit;
- // let packingQuantity = row.packingQuantity / packingCodeList.length;
- let unit = row.packingSpecificationOption[1]?.conversionUnit;
- let startIndex = row.packingSpecificationOption.findIndex((ite) => {
- return (
- row.measuringUnit == ite.unit && ite.unit != ite.conversionUnit
- );
- });
- let endIndex = row.packingSpecificationOption.findIndex(
- (ite) => row.unit == ite.conversionUnit
- );
- let total = Number(row.quantity);
- for (; startIndex < endIndex; endIndex--) {
- total = this.$math.format(
- row.packingSpecificationOption[endIndex].packageCell * total,
- 14
- );
- }
- console.log('total-----------', total);
- let packingQuantity = row.measureQuantity / total;
- let measureUnit = row.measureUnit;
- let measureQuantity = row.measureQuantity / packingCodeList.length;
- for (let index = 0; index < packingCodeList.length; index++) {
- 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, // 供应商编码
- brandNum: row.brandNum, // 牌号
- parentIndex: row.index, // 产品索引
- batchNo: row.batchNo, // 批次号
- packageNo: packingCodeList[index]?.onlyCode, // 包装编码
- packingQuantity: packingQuantity, // 包装数量
- packingUnit: packingUnit, //包装单位
- measureQuantity: measureQuantity, // 计量数量
- measureUnit: measureUnit, // 计量单位
- modelKey: row.modelKey, // 机型
- colorKey: row.colorKey, //颜色
- measureType: row.measureType,
- measureUnit: measureUnit, // 计量单位
- weight: 0, // 重量
- packingSpecificationOption: row.packingSpecificationOption, // 包装规格
- weightUnit: row.weightUnit, // 重量单位
- netWeight: row.netWeight, // 净重
- barcodes: '', // 发货条码
- clientCode: row.extInfo ? row.extInfo.clientCode : '', // 客户代号
- materielDesignation:
- row.materielDesignation ||
- (row.extInfo ? row.extInfo.materielCode : ''), // 物料代号
- supplierName: row.supplierName, // 供应商名称
- supplierCode: row.supplierCode, // 供应商代号
- engrave: '', // 刻码
- isUnpack: row.isUnpack, // 是否允许拆包
- productionDate: productionDate, // 生产日期
- purchaseDate: purchaseDate, // 采购时间
- result: 1, // 结果(1合格 2不合格)
- status: 2 // 状态(0=未质检 1待检 2已检)
- };
- 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);
- }
- } else {
- for (let index = 0; index < packingCodeList.length; index++) {
- let measureQuantity = 1;
- let packingQuantity = 1;
- // let packingUnit = row.unit;
- // 处理单位为KG类,计算每桶KG值
- if (packingBoolen) {
- measureQuantity =
- Number(row.quantity) >
- this.$math.format(filterArr[0].packageCell * (index + 1), 14)
- ? filterArr[0].packageCell
- : Number(row.quantity) -
- this.$math.format(filterArr[0].packageCell * index, 14);
- } else {
- //计量单位等于重量单位并且有总重 计量数量=总重/包装数
- if (row.weightUnit == row.measureUnit && row.weight) {
- measureQuantity =
- Math.trunc((row.weight / packingCodeList.length) * 10000) /
- 10000;
- } else {
- measureQuantity = row.packingSpecificationOption[1].packageCell;
- }
- }
- console.log(
- 'meadasdassureQuantity',
- row.weight / row.packingQuantity
- );
- 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, // 供应商编码
- brandNum: row.brandNum, // 牌号
- parentIndex: row.index, // 产品索引
- modelKey: row.modelKey, // 机型
- colorKey: row.colorKey, //颜色
- batchNo: row.batchNo, // 批次号
- packageNo: packingCodeList[index]?.onlyCode, // 包装编码
- packingQuantity: packingQuantity, // 包装数量
- measureQuantity: measureQuantity, // 计量数量
- measureUnit: row.isUnpack
- ? measureBoolen
- ? row.packingSpecificationOption[1]
- ? row.packingSpecificationOption[1].packageUnit
- : row.packingSpecificationOption[0].packageUnit
- : row.measureUnit
- : row.measureUnit, // 计量单位
- weight: row.weight / row.packingQuantity,
- packingSpecificationOption: row.packingSpecificationOption, // 包装规格
- weightUnit: row.weightUnit, // 重量单位
- netWeight: row.netWeight, // 净重
- barcodes: '', // 发货条码
- clientCode:
- row.clientCode || (row.extInfo ? row.extInfo.clientCode : ''), // 客户代号
- materielDesignation:
- row.materielDesignation ||
- (row.extInfo ? row.extInfo.materielCode : ''), // 物料代号
- supplierName: row.supplierName, // 供应商名称
- supplierCode: row.supplierCode, // 供应商代号
- engrave: row.engrave, // 刻码
- isUnpack: row.isUnpack, // 是否允许拆包
- productionDate: productionDate, // 生产日期
- purchaseDate: purchaseDate, // 采购时间
- expireDate: expireDate,
- result: 1, // 结果(1合格 2不合格)
- status: 2 // 状态(0=未质检 1待检 2已检)
- };
- console.log(
- row.packingSpecificationOption[1],
- 'row.packingSpecificationOption[1]'
- );
- if (row.isUnpack) {
- // 第二层条件: packingBoolen
- item.packingUnit =
- row.packingSpecificationOption[1].conversionUnit;
- }
- if (row.weightUnit == row.measureUnit) {
- item.weight = item.measureQuantity
- ? Number(item.measureQuantity)
- : 0;
- } else {
- //单位不相等 物品层总重除包装层计量
- item.weight = this.$math.format(
- (row.singleWeight || 0) * item.measureQuantity,
- 14
- );
- // 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 = item.weight || 0;
- // }
- // }
- // }
- }
- packingList.push(item);
- }
- const existingIndex = this.packingList.findIndex(
- (p) => p.parentIndex === row.index
- );
- if (existingIndex > -1) {
- this.packingList.splice(existingIndex, 1); // 移除旧数据
- }
- }
- console.log(productIndex, 'productIndex');
- // 单独点击保存并插入对应位置(包装)
- 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);
- }
- const lastIndex = this.packingList.length - 1;
- let remainder = 0;
- if (row.weightUnit != row.measureUnit) {
- remainder =
- row.measureQuantity %
- row.packingSpecificationOption[1]?.packageCell;
- }
- console.log(remainder, 'remainder');
- 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
- );
- }
- }
- },
- //入库明细删除
- listDel(row, index) {
- this.productList.splice(index, 1);
- this.deletePackingAndMaterial(row);
- },
- // 打开仓库弹框
- handleWareHouse(row, idx, type) {
- console.log(row, 'row');
- console.log(idx, 'idx');
- console.log(type, 'type');
- if (row.packingSpecificationLabel?.length < 1) {
- this.$message.error('请到主数据维护包装组信息!');
- return;
- }
- if (row.isSave) {
- return false;
- }
- //单个
- if (idx > -1 && type != 'batch') {
- if (row.quantity > 0) {
- if (!row.isUnpack) {
- console.log('不拆');
- //计量和包装单位相同
- if (row.measureUnit == row.unit) {
- let pNum = 0;
- let mNum = row.measureQuantity;
- this.$refs.wareHouseDailogRef.open({
- packingQuantity: pNum,
- measureQuantity: mNum,
- idx,
- warehouseId: row.warehouseId,
- warehouseName: row.warehouseName + '',
- categoryType: row.categoryLevelPathIdParent
- });
- } else {
- if (row.packingSpecificationOption[1]?.packageCell) {
- let num = row.quantity;
- let splitIndex = row.packingSpecificationOption.findIndex(
- (item) =>
- item.conversionUnit == row.unit &&
- item.packageUnit != item.conversionUnit
- );
- for (; splitIndex > 1; splitIndex--) {
- num = this.$math.format(
- num *
- row.packingSpecificationOption[splitIndex].packageCell,
- 14
- );
- }
- this.$refs.wareHouseDailogRef.open({
- packingQuantity: num,
- measureQuantity: row.measureQuantity,
- idx,
- warehouseId: row.warehouseId,
- warehouseName: row.warehouseName + '',
- categoryType: row.categoryLevelPathIdParent
- });
- } else {
- this.$refs.wareHouseDailogRef.open({
- packingQuantity: num,
- measureQuantity: row.measureQuantity,
- idx,
- warehouseId: row.warehouseId,
- warehouseName: row.warehouseName + '',
- categoryType: row.categoryLevelPathIdParent
- });
- }
- }
- } else {
- console.log('拆');
- // let filterArr = row.packingSpecificationOption.filter((item) => {
- // return (
- // item.packageUnit == row.packingUnit &&
- // item.packageUnit != item.conversionUnit
- // );
- // });
- let num = Math.ceil(
- row.measureQuantity /
- row.packingSpecificationOption[1]?.packageCell
- );
- console.log(num);
- this.$refs.wareHouseDailogRef.open({
- packingQuantity: num,
- measureQuantity: row.measureQuantity,
- idx,
- warehouseId: row.warehouseId,
- warehouseName: row.warehouseName + '',
- categoryType: row.categoryLevelPathIdParent
- });
- }
- } else {
- this.$message.error('请先填写包装数量!');
- }
- } else {
- //批量
- console.log(row, `row`);
- console.log(idx, `idx`);
- console.log(type, 'type');
- // 验证所有选中行是否填写了包装数量
- if (row.some((item) => !item.quantity)) {
- this.$message.error('请先填写所有行的包装数量!');
- return;
- }
- // 计算总需求数量
- let totalPacking = row.reduce((sum, item) => {
- return sum + Number(this.calculateRequiredWarehouseNum(item));
- }, 0);
- const mNum = row.reduce((sum, item) => {
- if (
- item.measureQuantity !== undefined &&
- item.measureQuantity !== null
- ) {
- return sum + Number(item.measureQuantity);
- }
- return sum;
- }, 0);
- // 打开仓库选择弹窗
- this.$refs.wareHouseDailogRef.open({
- packingQuantity: totalPacking,
- measureQuantity: mNum,
- batch: this.formData.extInfo.assetType
- });
- // this.$refs.wareHouseDailogRef.open(totalPacking, mNum);
- }
- },
- calculateRequiredWarehouseNum(row) {
- if (!row.isUnpack && row.measureUnit !== row.packingUnit) {
- let splitIndex = row.packingSpecificationOption.findIndex(
- (item) => item.conversionUnit === row.packingUnit
- );
- let num = row.packingQuantity;
- for (; splitIndex > 1; splitIndex--) {
- num = Math.ceil(
- num * row.packingSpecificationOption[splitIndex].packageCell
- );
- }
- return num;
- }
- console.log(row.packingQuantity, 'row.calculateRequiredWarehouseNum');
- return row.packingQuantity;
- },
- wareHouseSelection(argum, idx) {
- console.log(argum, 'argumargumargumargumargumargum', idx);
- // 方便包装遍历获取仓库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, 'idxidxidxidx', this.productList, 'this.productList');
- 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();
- },
- // 生成物料
- 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不合格)
- 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) {
- console.log(resultValue);
- 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>
- .inbound_details {
- margin-top: 10px;
- .el-form-item {
- margin-bottom: 0 !important;
- }
- }
- .el-form-item {
- margin-bottom: 5px;
- }
- .right_control {
- display: flex;
- > button {
- margin-left: 5px;
- }
- }
- .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;
- }
- :deep(.el-col) {
- margin-bottom: 12px;
- }
- </style>
|