storage.vue 160 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347
  1. <template>
  2. <div>
  3. <el-card shadow="never">
  4. <!-- <header-title title="基本信息"> </header-title> -->
  5. <div>基本信息</div>
  6. <el-form
  7. :model="formData"
  8. ref="formName"
  9. label-width="110px"
  10. :rules="rules"
  11. >
  12. <el-row :gutter="20">
  13. <el-col :span="6">
  14. <el-form-item label="物品类型" prop="extInfo.assetType">
  15. <el-select
  16. style="width: 100%"
  17. disabled
  18. multiple
  19. v-model="formData.extInfo.assetType"
  20. placeholder="请选择"
  21. >
  22. <el-option
  23. v-for="item in goodsLists"
  24. :key="item.id"
  25. :label="item.name"
  26. :value="item.id"
  27. >
  28. </el-option>
  29. </el-select>
  30. </el-form-item>
  31. </el-col>
  32. <el-col :span="6">
  33. <el-form-item label="入库类型" prop="bizType">
  34. <el-select
  35. style="width: 100%"
  36. disabled
  37. filterable
  38. placeholder="请选择"
  39. v-model="formData.bizType"
  40. clearable
  41. >
  42. <el-option
  43. v-for="item in sceneState"
  44. :key="item.code"
  45. :value="item.code"
  46. :label="item.label"
  47. ></el-option>
  48. </el-select> </el-form-item
  49. ></el-col>
  50. <el-col :span="6">
  51. <el-form-item label="单据来源" prop="documentSource">
  52. <el-input
  53. placeholder="请选择"
  54. disabled
  55. v-model="formData.sourceBizNo"
  56. @click.native="openDocumentSourceDialog"
  57. >
  58. </el-input>
  59. </el-form-item>
  60. </el-col>
  61. <!-- <el-col :span="6">
  62. <el-form-item label="权属部门" prop="deptName">
  63. <el-input
  64. placeholder="权属部门"
  65. disabled
  66. v-model="formData.extInfo.deptName"
  67. clearable
  68. />
  69. </el-form-item>
  70. </el-col> -->
  71. <el-col :span="6">
  72. <el-form-item label="入库时间">
  73. <el-date-picker
  74. v-model="formData.storageTime"
  75. type="datetime"
  76. value-format="yyyy-MM-dd HH:mm:ss"
  77. placeholder="选择日期时间"
  78. >
  79. </el-date-picker></el-form-item
  80. ></el-col>
  81. <el-col :span="6">
  82. <el-form-item label="入库登记人">
  83. <el-input
  84. placeholder="登记人"
  85. disabled
  86. v-model="formData.createUserName"
  87. clearable /></el-form-item
  88. ></el-col>
  89. <el-col :span="6">
  90. <el-form-item label="审核人">
  91. <el-input
  92. placeholder="审核人"
  93. disabled
  94. v-model="formData.approvalUserName"
  95. clearable /></el-form-item
  96. ></el-col>
  97. <!-- <el-col :span="6" v-if="formData.bizType == 2">
  98. <el-form-item label="供应商" prop="supplierName">
  99. <el-input
  100. placeholder="请输入"
  101. clearable
  102. v-model="formData.extInfo.supplierName"
  103. />
  104. </el-form-item>
  105. </el-col> -->
  106. <!-- <el-col :span="6">
  107. <el-form-item label="送货人" prop="fromUser">
  108. <el-input placeholder="请输入" v-model="formData.fromUser" clearable /> </el-form-item></el-col>
  109. <el-col :span="6">
  110. <el-form-item label="送货人联系方式" prop="deliveryPhone">
  111. <el-input placeholder="请输入" v-model="formData.extInfo.deliveryPhone" clearable /></el-form-item></el-col> -->
  112. <el-col :span="6">
  113. <el-form-item label="备注" prop="remark">
  114. <el-input
  115. v-model="formData.remark"
  116. clearable
  117. type="textarea"
  118. placeholder="请详细说明"
  119. :rows="1"
  120. ></el-input>
  121. </el-form-item>
  122. </el-col>
  123. <!-- <el-col :span="6">
  124. <el-form-item label="生产要求" prop="productionRequirements">
  125. <el-input
  126. v-model="formData.productionRequirements"
  127. clearable
  128. type="textarea"
  129. placeholder=""
  130. :rows="1"
  131. disabled
  132. ></el-input>
  133. </el-form-item>
  134. </el-col> -->
  135. </el-row>
  136. </el-form>
  137. <div class="inbound_details">
  138. <header-title title="产品信息">
  139. <el-button type="primary" @click="addProduct">添加</el-button>
  140. </header-title>
  141. <div class="form_table">
  142. <el-form
  143. ref="productListRef"
  144. :model="{ productList: productList }"
  145. :show-message="false"
  146. >
  147. <div style="text-align: right; margin-bottom: 10px">
  148. <el-button
  149. v-if="productList.length != 0"
  150. type="success"
  151. plain
  152. size="mini"
  153. @click="listSaveArrs"
  154. >批量保存</el-button
  155. >
  156. <el-button
  157. v-if="productList.length != 0 && this.packingList.length == 0"
  158. type="success"
  159. plain
  160. size="mini"
  161. @click="handleWareHouse(productList, '', 'batch')"
  162. >批量选择仓库</el-button
  163. >
  164. </div>
  165. <ele-pro-table
  166. ref="productListTable"
  167. :needPage="false"
  168. :columns="columns"
  169. :datasource="productList"
  170. :header-cell-style="rowClass"
  171. :max-height="300"
  172. :cache-key="cacheKeyUrl"
  173. @columns-change="handleColumnChange"
  174. >
  175. <!-- 包装完好与否 -->
  176. <template
  177. v-slot:ifPackageOk="{ row, $index }"
  178. v-if="isShowPackage"
  179. >
  180. <el-form-item
  181. :prop="'productList.' + $index + '.ifPackageOk'"
  182. :rules="{
  183. required: true,
  184. message: '请选择包装完好与否',
  185. trigger: 'change'
  186. }"
  187. >
  188. <el-select
  189. v-model="row.ifPackageOk"
  190. placeholder="请选择"
  191. clearable
  192. style="width: 100%"
  193. >
  194. <el-option label="是" :value="1" />
  195. <el-option label="否" :value="0" />
  196. </el-select>
  197. </el-form-item>
  198. </template>
  199. <!-- 拆包装责任人 -->
  200. <template
  201. v-slot:unpackUserName="{ row, $index }"
  202. v-if="isShowPackage"
  203. >
  204. <el-form-item
  205. :prop="'productList.' + $index + '.unpackUserName'"
  206. :rules="{
  207. required: true,
  208. message: '请选择拆包装责任人',
  209. trigger: 'change'
  210. }"
  211. >
  212. <el-input
  213. @click.native="handHead(row, $index)"
  214. v-model="row.unpackUserName"
  215. placeholder="请选择"
  216. ></el-input>
  217. </el-form-item>
  218. </template>
  219. <!-- 批次号 -->
  220. <template v-slot:batchNo="{ row, $index }">
  221. <template v-if="row.isSave">
  222. {{ row.batchNo }}
  223. </template>
  224. <el-form-item
  225. v-else
  226. :prop="'productList.' + $index + '.batchNo'"
  227. :rules="{
  228. required: true,
  229. message: '请输入批次号',
  230. trigger: 'blur'
  231. }"
  232. >
  233. <el-input
  234. :ref="'batchNo' + $index"
  235. @keyup.native="
  236. moveFocus($event, $index, 'batchNo', '产品', row)
  237. "
  238. v-model.number="row.batchNo"
  239. >
  240. </el-input>
  241. </el-form-item>
  242. </template>
  243. <!-- 数量 -->
  244. <template v-slot:quantity="{ row, $index }">
  245. <template v-if="row.isSave">
  246. {{ row.quantity }}
  247. </template>
  248. <el-form-item
  249. v-else
  250. :prop="'productList.' + $index + '.quantity'"
  251. :rules="{
  252. required: true,
  253. message: '请输入数量',
  254. trigger: 'blur'
  255. }"
  256. >
  257. <el-input
  258. :ref="'quantity' + $index"
  259. type="number"
  260. @keyup.native="
  261. moveFocus($event, $index, 'quantity', '产品', row)
  262. "
  263. v-model="row.quantity"
  264. @input="computeNum(row, $index, true)"
  265. >
  266. </el-input>
  267. </el-form-item>
  268. </template>
  269. <!-- 单位 -->
  270. <template v-slot:unit="{ row, $index }">
  271. <template v-if="row.isSave">
  272. {{ row.unit }}
  273. </template>
  274. <el-form-item
  275. v-else
  276. :prop="'productList.' + $index + '.unit'"
  277. :rules="{
  278. required: true,
  279. message: '请选择单位',
  280. trigger: 'change'
  281. }"
  282. >
  283. <el-select
  284. v-model="row.unitId"
  285. placeholder="请选择"
  286. @change="computeNum(row, $index)"
  287. >
  288. <el-option
  289. v-for="item in row.packingSpecificationOption"
  290. :label="`${item.conversionUnit}`"
  291. :value="item.id"
  292. :key="item.id"
  293. >
  294. </el-option>
  295. </el-select>
  296. </el-form-item>
  297. </template>
  298. <!-- 包装规格 -->
  299. <template v-slot:packingSpecificationLabel="{ row, $index }">
  300. <el-tag v-for="item in row.packingSpecificationLabel">{{
  301. item
  302. }}</el-tag>
  303. </template>
  304. <!-- 单重 -->
  305. <template v-slot:singleWeight="{ row, $index }">
  306. <template v-if="row.isSave">
  307. {{ row.singleWeight }}
  308. </template>
  309. <template v-else>
  310. <el-input-number
  311. v-model="row.singleWeight"
  312. placeholder="请输入"
  313. :min="0"
  314. controls-position="right"
  315. @change="inputsingleWeight(row, $index)"
  316. :disabled="row.weightUnit == row.unit"
  317. :controls="false"
  318. style="width: 100%"
  319. ></el-input-number>
  320. </template>
  321. </template>
  322. <!-- 总重 -->
  323. <template v-slot:weight="{ row, $index }">
  324. <template v-if="row.isSave">
  325. {{ row.weight }}
  326. </template>
  327. <el-input
  328. v-else
  329. v-model="row.weight"
  330. placeholder="请输入"
  331. type="number"
  332. @input="inputWeight(row, $index)"
  333. :disabled="row.weightUnit == row.unit"
  334. ></el-input>
  335. </template>
  336. <!-- 仓库 -->
  337. <template v-slot:warehouseName="{ row, $index }">
  338. <el-form-item
  339. :prop="'productList.' + $index + '.warehouseId'"
  340. :rules="{
  341. required: true,
  342. message: '请选择仓库',
  343. trigger: 'change'
  344. }"
  345. >
  346. <div
  347. :class="
  348. row.warehouseName
  349. ? 'wareHouse_style'
  350. : 'wareHouse_style red_color'
  351. "
  352. @click="handleWareHouse(row, $index)"
  353. >
  354. <span>
  355. {{ row.warehouseName ? row.warehouseName : '请选择仓库' }}
  356. </span>
  357. </div>
  358. </el-form-item>
  359. </template>
  360. <!-- 采购原因 -->
  361. <template v-slot:purpose="{ row, $index }">
  362. <template v-if="row.isSave">
  363. {{ row.purpose }}
  364. </template>
  365. <el-input
  366. v-else
  367. :ref="'purpose' + $index"
  368. @keyup.native="
  369. moveFocus($event, $index, 'purpose', '产品', row)
  370. "
  371. v-model="row.purpose"
  372. >
  373. </el-input>
  374. </template>
  375. <!-- 生产日期 -->
  376. <template v-slot:detailProductionDate="{ row, $index }">
  377. <template v-if="row.isSave">
  378. {{ row.detailProductionDate }}
  379. </template>
  380. <el-date-picker
  381. v-else
  382. :disabled="row.isPack"
  383. size="small"
  384. v-model="row.detailProductionDate"
  385. type="datetime"
  386. value-format="yyyy-MM-dd HH:mm:ss"
  387. placeholder="选择日期"
  388. >
  389. </el-date-picker>
  390. </template>
  391. <!-- 采购日期 -->
  392. <template v-slot:detailPurchaseDate="{ row, $index }">
  393. <template v-if="row.isSave">
  394. {{ row.detailPurchaseDate }}
  395. </template>
  396. <el-date-picker
  397. v-else
  398. :disabled="row.isPack"
  399. size="small"
  400. v-model="row.detailPurchaseDate"
  401. type="datetime"
  402. value-format="yyyy-MM-dd HH:mm:ss"
  403. placeholder="选择日期"
  404. >
  405. </el-date-picker>
  406. </template>
  407. <!-- 失效日期 -->
  408. <template v-slot:detailExpireDate="{ row, $index }">
  409. <template v-if="row.isSave">
  410. {{ row.detailExpireDate }}
  411. </template>
  412. <el-date-picker
  413. v-else
  414. :disabled="row.isPack"
  415. size="small"
  416. v-model="row.detailExpireDate"
  417. type="datetime"
  418. value-format="yyyy-MM-dd HH:mm:ss"
  419. placeholder="选择日期"
  420. >
  421. </el-date-picker>
  422. </template>
  423. <!-- 颜色 -->
  424. <template v-slot:colorKey="{ row, $index }">
  425. <DictSelection
  426. dictName="物品颜色"
  427. clearable
  428. v-model="row.colorKey"
  429. :isOne="$index == 1"
  430. filterable
  431. allow-create
  432. default-first-option
  433. >
  434. </DictSelection>
  435. </template>
  436. <!-- 机型 -->
  437. <template v-slot:modelKey="{ row, $index }">
  438. <DictSelection
  439. dictName="物品机型"
  440. clearable
  441. v-model="row.modelKey"
  442. :isOne="$index == 1"
  443. filterable
  444. allow-create
  445. default-first-option
  446. >
  447. </DictSelection>
  448. </template>
  449. <!-- 操作 -->
  450. <template v-slot:action="{ row, $index }">
  451. <el-button
  452. type="text"
  453. v-show="!row.isSave"
  454. @click="listSave(row, $index)"
  455. >保存</el-button
  456. >
  457. <el-button
  458. type="text"
  459. v-show="row.isSave"
  460. @click="listEdit(row, $index)"
  461. >编辑</el-button
  462. >
  463. <el-button type="text" @click="listDel(row, $index)"
  464. >删除</el-button
  465. >
  466. </template>
  467. </ele-pro-table>
  468. </el-form>
  469. </div>
  470. </div>
  471. <div v-if="showPackingList.length > 0" class="inbound_details">
  472. <header-title :title="`包装明细`">
  473. <div class="switch_right">
  474. <el-button
  475. style="margin-left: 20px"
  476. type="text"
  477. @click="dateSetting('productionDate')"
  478. >批量设置生产日期</el-button
  479. >
  480. <el-button
  481. style="margin-left: 20px"
  482. type="text"
  483. @click="dateSetting('purchaseDate')"
  484. >批量设置采购日期</el-button
  485. >
  486. <el-button
  487. style="margin-left: 20px"
  488. type="text"
  489. @click="dateSetting('expireDate')"
  490. >批量设置失效日期</el-button
  491. >
  492. </div>
  493. </header-title>
  494. <el-table
  495. v-if="isWrapTable"
  496. ref="packingListTable"
  497. :data="showPackingList"
  498. tooltip-effect="dark"
  499. :key="formData.bizType"
  500. :header-cell-style="rowClass"
  501. style="width: 100%"
  502. border
  503. stripe
  504. :max-height="300"
  505. v-el-table-infinite-scroll="pickingHandleScroll"
  506. @selection-change="handleSelectionChange"
  507. >
  508. <el-table-column type="selection" align="center" width="50">
  509. </el-table-column>
  510. <el-table-column label="序号" type="index" width="50" fixed="left">
  511. </el-table-column>
  512. <el-table-column
  513. label="编码"
  514. prop="categoryCode"
  515. width="130"
  516. :show-overflow-tooltip="true"
  517. fixed="left"
  518. ></el-table-column>
  519. <el-table-column
  520. label="名称"
  521. prop="categoryName"
  522. width="150"
  523. :show-overflow-tooltip="true"
  524. fixed="left"
  525. ></el-table-column>
  526. <el-table-column
  527. label="批次号"
  528. prop="batchNo"
  529. width="100"
  530. ></el-table-column>
  531. <el-table-column
  532. :label="`包装编码`"
  533. prop="packageNo"
  534. width="200"
  535. :show-overflow-tooltip="true"
  536. ></el-table-column>
  537. <el-table-column
  538. label="包装数量"
  539. prop="packingQuantity"
  540. width="80"
  541. ></el-table-column>
  542. <el-table-column label="单位" prop="packingUnit"></el-table-column>
  543. <el-table-column
  544. label="计量数量"
  545. prop="measureQuantity"
  546. :show-overflow-tooltip="true"
  547. ></el-table-column>
  548. <el-table-column
  549. label="计量单位"
  550. prop="measureUnit"
  551. ></el-table-column>
  552. <!-- <el-table-column label="允许拆包" prop="isUnpack">
  553. <template slot-scope="{ row, $index }">
  554. {{ row.isUnpack ? '是' : '否' }}
  555. </template>
  556. </el-table-column> -->
  557. <el-table-column
  558. label="仓库"
  559. :show-overflow-tooltip="true"
  560. prop="warehouseName"
  561. width="200"
  562. ></el-table-column>
  563. <el-table-column
  564. label="物料代号"
  565. prop="materielDesignation"
  566. width="130"
  567. >
  568. <template slot-scope="{ row, $index }">
  569. <el-input
  570. v-if="!row.isPack"
  571. :ref="'packing_materielDesignation' + $index"
  572. @keyup.native="
  573. moveFocus(
  574. $event,
  575. $index,
  576. 'packing_materielDesignation',
  577. '包装',
  578. row
  579. )
  580. "
  581. v-model="row.materielDesignation"
  582. ></el-input>
  583. <span v-else>{{ row.materielDesignation }}</span>
  584. </template>
  585. </el-table-column>
  586. <el-table-column label="客户代号" prop="clientCode" width="130">
  587. <template slot-scope="{ row, $index }">
  588. <el-input
  589. v-if="!row.isPack"
  590. :ref="'packing_clientCode' + $index"
  591. @keyup.native="
  592. moveFocus($event, $index, 'packing_clientCode', '包装', row)
  593. "
  594. v-model="row.clientCode"
  595. ></el-input>
  596. <span v-else> {{ row.clientCode }}</span>
  597. </template>
  598. <!-- <template slot-scope="{ row, $index }" v-if="bizType == 2">
  599. <el-input v-if="!row.isPack" :ref="'packing_clientCode' + $index" @keyup.native="
  600. moveFocus($event, $index, 'packing_clientCode', '包装', row)
  601. " v-model="row.customerMark"></el-input>
  602. <span v-else> {{ row.customerMark }}</span>
  603. </template> -->
  604. </el-table-column>
  605. <el-table-column label="牌号" prop="brandNum" width="80">
  606. </el-table-column>
  607. <el-table-column
  608. label="发货条码"
  609. prop="barcodes"
  610. :show-overflow-tooltip="true"
  611. ></el-table-column>
  612. <el-table-column
  613. label="供应商"
  614. align="center"
  615. prop="supplierName"
  616. width="120"
  617. :show-overflow-tooltip="true"
  618. >
  619. </el-table-column>
  620. <el-table-column
  621. label="供应商代号"
  622. align="center"
  623. prop="supplierCode"
  624. width="120"
  625. :show-overflow-tooltip="true"
  626. >
  627. <template slot-scope="{ row, $index }">
  628. {{ row.supplierCode }}
  629. </template>
  630. </el-table-column>
  631. <!-- <el-table-column v-else-if="bizType == 2" label="供应商代号" align="center" prop="supplierMark" width="120"
  632. :show-overflow-tooltip="true">
  633. <template slot-scope="{ row, $index }">
  634. {{ row.supplierMark }}
  635. </template>
  636. </el-table-column> -->
  637. <el-table-column label="序列号" prop="engrave" width="140">
  638. <template slot-scope="{ row, $index }">
  639. <span> {{ row.productSequence }}</span>
  640. </template>
  641. </el-table-column>
  642. <el-table-column label="盘具" prop="reelSpecification" width="140">
  643. <template slot-scope="{ row, $index }">
  644. <span> {{ row.reelSpecification }}</span>
  645. </template>
  646. </el-table-column>
  647. <el-table-column label="刻码" prop="engrave" width="140">
  648. <template slot-scope="{ row, $index }">
  649. <el-input
  650. v-if="!row.isPack"
  651. :ref="'packing_engrave' + $index"
  652. @keyup.native="
  653. moveFocus($event, $index, 'packing_engrave', '包装', row)
  654. "
  655. v-model="row.engrave"
  656. ></el-input>
  657. <span v-else>{{ row.engrave }}</span>
  658. </template>
  659. </el-table-column>
  660. <el-table-column label="重量" prop="weight" width="100">
  661. <template slot-scope="{ row, $index }">
  662. <el-input
  663. v-if="!row.isPack && row.measureUnit != row.weightUnit"
  664. :ref="'packing_weight' + $index"
  665. @keyup.native="
  666. moveFocus($event, $index, 'packing_weight', '包装', row)
  667. "
  668. v-model.number="row.weight"
  669. @input="weightInput($event, row, '包装')"
  670. ></el-input>
  671. <span v-else>{{ row.weight }}</span>
  672. </template>
  673. </el-table-column>
  674. <el-table-column label="重量单位" prop="weightUnit">
  675. <template slot-scope="{ row }">
  676. {{ row.weightUnit }}
  677. </template>
  678. </el-table-column>
  679. <el-table-column label="机型" prop="modelKey" width="300">
  680. <template slot-scope="{ row, $index }">
  681. <DictSelection
  682. dictName="物品机型"
  683. clearable
  684. v-model="row.modelKey"
  685. :isOne="$index == 1"
  686. filterable
  687. allow-create
  688. default-first-option
  689. >
  690. </DictSelection>
  691. </template>
  692. </el-table-column>
  693. <el-table-column label="颜色" prop="colorKey" width="300">
  694. <template slot-scope="{ row, $index }">
  695. <DictSelection
  696. dictName="物品颜色"
  697. clearable
  698. v-model="row.colorKey"
  699. :isOne="$index == 1"
  700. filterable
  701. allow-create
  702. default-first-option
  703. >
  704. </DictSelection>
  705. </template>
  706. </el-table-column>
  707. <el-table-column label="序列号" prop="serialNumber">
  708. </el-table-column>
  709. <el-table-column label="质检结果" prop="result" width="120">
  710. <template slot-scope="{ row }">
  711. <el-select
  712. v-if="!row.isPack"
  713. @change="changeWrapStatus($event, row, '包装')"
  714. v-model="row.result"
  715. placeholder="请选择"
  716. >
  717. <el-option
  718. v-for="item in qualityResultsOptions"
  719. :label="item.label"
  720. :value="item.value"
  721. :key="item.value"
  722. >
  723. </el-option>
  724. </el-select>
  725. <span v-else>{{ qualityResults[row.result] }}</span>
  726. </template>
  727. </el-table-column>
  728. <el-table-column label="质检状态" prop="status" width="120">
  729. <template slot-scope="{ row }">
  730. <span>{{ qualityStatus[row.status] }}</span>
  731. </template>
  732. </el-table-column>
  733. <el-table-column
  734. label="是否质检"
  735. align="center"
  736. width="80"
  737. prop="qualityControl"
  738. :show-overflow-tooltip="true"
  739. v-if="bizType != 1 && bizType != 6 && bizType != 9"
  740. >
  741. <template slot-scope="{ row, $index }">
  742. {{
  743. row.qualityControl == 1
  744. ? '是'
  745. : row.qualityControl == 0
  746. ? '否'
  747. : ''
  748. }}
  749. </template>
  750. </el-table-column>
  751. <template v-if="formData.bizType == 5">
  752. <el-table-column
  753. label="生产日期"
  754. prop="productionDate"
  755. width="220"
  756. ></el-table-column>
  757. <el-table-column
  758. label="采购日期"
  759. prop="purchaseDate"
  760. width="220"
  761. ></el-table-column>
  762. </template>
  763. <template v-else>
  764. <el-table-column label="生产日期" prop="productionDate" width="220">
  765. <template slot-scope="{ row, $index }">
  766. <el-date-picker
  767. :disabled="row.isPack"
  768. size="small"
  769. v-model="row.productionDate"
  770. type="datetime"
  771. value-format="yyyy-MM-dd HH:mm:ss"
  772. placeholder="选择日期"
  773. >
  774. </el-date-picker
  775. ></template>
  776. </el-table-column>
  777. <el-table-column label="采购日期" prop="purchaseDate" width="220">
  778. <template slot-scope="{ row, $index }">
  779. <el-date-picker
  780. :disabled="row.isPack"
  781. size="small"
  782. v-model="row.purchaseDate"
  783. type="datetime"
  784. value-format="yyyy-MM-dd HH:mm:ss"
  785. placeholder="选择日期"
  786. >
  787. </el-date-picker
  788. ></template>
  789. </el-table-column>
  790. <el-table-column label="失效日期" prop="expireDate" width="220">
  791. <template slot-scope="{ row, $index }">
  792. <el-date-picker
  793. :disabled="row.isPack"
  794. size="small"
  795. v-model="row.expireDate"
  796. type="datetime"
  797. value-format="yyyy-MM-dd HH:mm:ss"
  798. placeholder="选择日期"
  799. >
  800. </el-date-picker
  801. ></template>
  802. </el-table-column>
  803. </template>
  804. <!-- <el-table-column label="生产日期" prop="" width="220">
  805. <template slot="header" slot-scope="scope">
  806. <el-select filterable v-model="curDateType">
  807. <el-option value="productionDate" label="生产日期"></el-option>
  808. <el-option value="purchaseDate" label="采购日期"></el-option>
  809. </el-select>
  810. </template>
  811. <template slot-scope="{ row }">
  812. <template v-if="formData.bizType == 5">
  813. {{ row[curDateType] }}
  814. </template>
  815. <el-date-picker
  816. v-else
  817. :disabled="row.isPack"
  818. size="small"
  819. v-model="row[curDateType]"
  820. type="datetime"
  821. value-format="yyyy-MM-dd HH:mm:ss"
  822. placeholder="选择日期"
  823. >
  824. </el-date-picker>
  825. </template>
  826. </el-table-column> -->
  827. <!-- <el-table-column label="操作" width="120" fixed="right">
  828. <template slot-scope="{ row, $index }">
  829. <el-button type="text" @click="wrapDelete(row, $index)">
  830. 删除
  831. </el-button>
  832. </template>
  833. </el-table-column> -->
  834. </el-table>
  835. </div>
  836. <div v-if="showMaterialList.length > 0" class="inbound_details">
  837. <!-- <header-title :title="`物料明细`"></header-title> -->
  838. <!-- <el-table ref="materialListTable" :data="showMaterialList" tooltip-effect="dark" :key="formData.bizType"
  839. :header-cell-style="rowClass" style="width: 100%" border stripe :max-height="300"
  840. v-el-table-infinite-scroll="materielHandleScroll">
  841. <el-table-column label="序号" type="index" width="50">
  842. </el-table-column>
  843. <el-table-column label="编码" prop="categoryCode" width="130" :show-overflow-tooltip="true"></el-table-column>
  844. <el-table-column label="名称" prop="categoryName" width="150" :show-overflow-tooltip="true"></el-table-column>
  845. <el-table-column label="批次号" prop="batchNo" width="70"></el-table-column>
  846. <el-table-column label="物料编码" prop="materialCode" width="200" :show-overflow-tooltip="true"></el-table-column>
  847. <el-table-column label="计量数量" prop="measureQuantity" width="90"
  848. :show-overflow-tooltip="true"></el-table-column>
  849. <el-table-column width="80" label="计量单位" prop="measureUnit"></el-table-column>
  850. <el-table-column label="物料代号" prop="materielDesignation" width="130">
  851. <template slot-scope="{ row, $index }">
  852. <el-input v-if="!row.isPack" :ref="'material_materielDesignation' + $index" @keyup.native="
  853. moveFocus(
  854. $event,
  855. $index,
  856. 'material_materielDesignation',
  857. '物料',
  858. row
  859. )
  860. " v-model="row.materielDesignation"></el-input>
  861. <span v-else>{{ row.materielDesignation }}</span>
  862. </template>
  863. </el-table-column>
  864. <el-table-column label="客户代号" prop="clientCode">
  865. <template slot-scope="{ row, $index }">
  866. <el-input v-if="!row.isPack" :ref="'material_clientCode' + $index" @keyup.native="
  867. moveFocus($event, $index, 'material_clientCode', '物料', row)
  868. " v-model="row.clientCode"></el-input>
  869. <span v-else>{{ row.clientCode }}</span>
  870. </template>
  871. </el-table-column>
  872. <el-table-column label="刻码" prop="engrave" width="140">
  873. <template slot-scope="{ row, $index }">
  874. <el-input v-if="!row.isPack" :ref="'material_engrave' + $index" @keyup.native="
  875. moveFocus($event, $index, 'material_engrave', '物料', row)
  876. " v-model="row.engrave"></el-input>
  877. <span v-else>{{ row.engrave }}</span>
  878. </template>
  879. </el-table-column>
  880. <el-table-column label="重量" prop="weight" width="100">
  881. <template slot-scope="{ row, $index }">
  882. <el-input v-if="!row.isPack && row.measureUnit != row.weightUnit" :ref="'material_weight' + $index"
  883. @keyup.native="
  884. moveFocus($event, $index, 'material_weight', '物料', row)
  885. " @input="weightInput($event, row, '物料')" v-model.number="row.weight"></el-input>
  886. <span v-else>{{ row.weight }}</span>
  887. </template>
  888. </el-table-column>
  889. <el-table-column label="重量单位" prop="weightUnit" width="100"></el-table-column>
  890. <el-table-column label="质检结果" prop="result" width="120">
  891. <template slot-scope="{ row }">
  892. <el-select v-if="!row.isPack" @change="changeWrapStatus($event, row, '物料')" v-model="row.result"
  893. placeholder="请选择">
  894. <el-option v-for="item in qualityResultsOptions" :label="item.label" :value="item.value"
  895. :key="item.value">
  896. </el-option>
  897. </el-select>
  898. <span v-else>{{ qualityResults[row.result] }}</span>
  899. </template>
  900. </el-table-column>
  901. <el-table-column label="质检状态" prop="status" width="120">
  902. <template slot-scope="{ row }">
  903. <span>{{ qualityStatus[row.status] }}</span>
  904. </template>
  905. </el-table-column>
  906. </el-table> -->
  907. </div>
  908. </el-card>
  909. <!-- 产品选择弹框 -->
  910. <selectType
  911. :visibleDialog.sync="visibleDialog"
  912. :title="title"
  913. :treeIds="formData.extInfo.assetType"
  914. :loadTree.sync="loadTree"
  915. @selectTableData="addGoods"
  916. />
  917. <!-- 仓库选择弹框 -->
  918. <WarehousingDialog
  919. ref="wareHouseDailogRef"
  920. @selection="wareHouseSelection"
  921. ></WarehousingDialog>
  922. <!-- 包装负责人 -->
  923. <head-list ref="headRef" @changeParent="changeHead"></head-list>
  924. <!-- 生产日期、采购日期弹框 -->
  925. <el-dialog
  926. :visible.sync="dateVisible"
  927. title="选择日期"
  928. width="400px"
  929. append-to-body
  930. >
  931. <el-date-picker
  932. size="small"
  933. v-model="batchTime"
  934. type="datetime"
  935. style="width: 320px"
  936. value-format="yyyy-MM-dd HH:mm:ss"
  937. placeholder="选择日期"
  938. >
  939. </el-date-picker>
  940. <div style="text-align: right; margin-top: 20px">
  941. <el-button @click="dateVisible = false">取消</el-button>
  942. <el-button type="primary" @click="dateConfirm" :disabled="!batchTime"
  943. >确认</el-button
  944. >
  945. </div>
  946. </el-dialog>
  947. </div>
  948. </template>
  949. <script>
  950. import elTableInfiniteScroll from 'el-table-infinite-scroll';
  951. import storageApi from '@/api/warehouseManagement/index.js';
  952. import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition.js';
  953. import WarehousingDialog from './components/WarehousingDialog.vue';
  954. import { getCode } from '@/api/codeManagement/index.js';
  955. import selectType from './components/selectType_new.vue';
  956. import {
  957. sceneState,
  958. qualityResultsOptions,
  959. qualityResults,
  960. qualityStatus
  961. } from '@/utils/dict/index';
  962. import { getTreeByGroup } from '@/api/classifyManage';
  963. import { deepClone } from '@/utils';
  964. import { mapActions, mapGetters } from 'vuex';
  965. import BigNumber from 'bignumber.js';
  966. import headList from '@/components/headList';
  967. import tabMixins from '@/mixins/tableColumnsMixin';
  968. import { parameterGetByCode } from '@/api/main/index.js';
  969. // import dictMixins from '@/mixins/dictMixins';
  970. export default {
  971. mixins: [tabMixins],
  972. components: {
  973. selectType,
  974. WarehousingDialog,
  975. headList
  976. },
  977. // mixins: [dictMixins],
  978. // 虚拟列表滚动方法
  979. directives: {
  980. 'el-table-infinite-scroll': elTableInfiniteScroll
  981. },
  982. props: {
  983. form: { type: Object, default: () => {} },
  984. bizType: { type: Number, default: 1 },
  985. sourceBizNo: { type: String, default: '' },
  986. detailList: { type: Array, default: () => [] },
  987. saleProductList: { type: Array, default: () => [] },
  988. detailProductList: { type: Array, default: () => [] },
  989. isMoreProduct: { type: Boolean, default: false }, //多产品包装明细
  990. processInstance: { type: Object, default: () => {} },
  991. isShowPackage: { type: Boolean, default: false } //售后退货单仓管审批显示
  992. },
  993. data() {
  994. return {
  995. cacheKeyUrl: '202605141434-storageTableColumns',
  996. newColumns: [], // 动态表头
  997. sceneState,
  998. saveLoading: false,
  999. dateVisible: false,
  1000. loadTree: true,
  1001. visibleDialog: false,
  1002. title: '选择产品',
  1003. goodsLists: [],
  1004. formData: {
  1005. bizType: '',
  1006. storageTime: '',
  1007. qualityControl: '',
  1008. extInfo: {
  1009. assetType: []
  1010. }
  1011. },
  1012. rules: {
  1013. 'extInfo.assetType': {
  1014. required: true,
  1015. message: '请选择物品类型',
  1016. trigger: 'blur'
  1017. },
  1018. bizType: {
  1019. required: true,
  1020. message: '请选择入库场景',
  1021. trigger: 'change'
  1022. },
  1023. storageTime: {
  1024. required: true,
  1025. message: '请选择入库时间',
  1026. trigger: 'change'
  1027. }
  1028. },
  1029. qualityResultsOptions, // 质检结果选项
  1030. qualityStatus, // 质检状态 0未检 1已检
  1031. qualityResults, // 质检结果 0无 1合格 2不合格
  1032. productList: [], // 产品列表
  1033. packingList: [], // 包装列表
  1034. showPackingList: [], // 包装列表(虚拟列表)
  1035. materialList: [], // 物料列表
  1036. showMaterialList: [], // 物料列表(虚拟列表)
  1037. curDateType: 'productionDate',
  1038. packingListSelected: [], // 包装选择列表
  1039. isWrapTable: true, // 解决表格不刷新问题(包装)
  1040. currentPackingQuantity: '', // 当前包装数量
  1041. batchTime: '', // 生产日期、采购日期
  1042. pageSize: 20, // 物料和包装列表条数
  1043. pickingPageNum: 1, // 包装虚拟分页页数
  1044. materielPageNum: 1, // 物料虚拟分页页数
  1045. isReelSpecification: 0
  1046. };
  1047. },
  1048. computed: {
  1049. ...mapGetters(['dict', 'getDict', 'getDictValue']),
  1050. clientEnvironmentId() {
  1051. return this.$store.state.user.info.clientEnvironmentId;
  1052. },
  1053. columns() {
  1054. return [
  1055. {
  1056. width: 50,
  1057. type: 'index',
  1058. columnKey: 'index',
  1059. align: 'center',
  1060. fixed: 'left'
  1061. },
  1062. {
  1063. label: '编码',
  1064. prop: 'categoryCode',
  1065. align: 'center',
  1066. width: 130,
  1067. showOverflowTooltip: true,
  1068. fixed: 'left'
  1069. },
  1070. {
  1071. label: '名称',
  1072. prop: 'categoryName',
  1073. align: 'center',
  1074. width: 200,
  1075. showOverflowTooltip: true,
  1076. fixed: 'left'
  1077. },
  1078. {
  1079. label: '牌号',
  1080. prop: 'brandNum',
  1081. align: 'center',
  1082. width: 100,
  1083. showOverflowTooltip: true
  1084. },
  1085. {
  1086. label: '型号',
  1087. prop: 'categoryModel',
  1088. align: 'center',
  1089. width: 100,
  1090. showOverflowTooltip: true
  1091. },
  1092. {
  1093. label: '规格',
  1094. prop: 'specification',
  1095. align: 'center',
  1096. width: 100,
  1097. showOverflowTooltip: true
  1098. },
  1099. ...this.newColumns.map((item) => ({
  1100. ...item,
  1101. prop: item.prop,
  1102. showOverflowTooltip: true
  1103. })),
  1104. // 包装完好与否
  1105. {
  1106. label: '包装完好与否',
  1107. prop: 'ifPackageOk',
  1108. slot: 'ifPackageOk',
  1109. align: 'center',
  1110. width: 100,
  1111. show: this.isShowPackage
  1112. },
  1113. // 拆包装责任人
  1114. {
  1115. label: '拆包装责任人',
  1116. prop: 'unpackUserName',
  1117. slot: 'unpackUserName',
  1118. align: 'center',
  1119. width: 100,
  1120. show: this.isShowPackage
  1121. },
  1122. // 批次号
  1123. {
  1124. label: '批次号',
  1125. prop: 'batchNo',
  1126. slot: 'batchNo',
  1127. align: 'center',
  1128. width: 100
  1129. },
  1130. // 数量
  1131. {
  1132. label: '数量',
  1133. prop: 'quantity',
  1134. slot: 'quantity',
  1135. align: 'center',
  1136. width: 100
  1137. },
  1138. // 单位
  1139. {
  1140. label: '单位',
  1141. prop: 'unit',
  1142. slot: 'unit',
  1143. align: 'center',
  1144. width: 100
  1145. },
  1146. // 数量
  1147. {
  1148. label: '包装数量',
  1149. prop: 'packingQuantity',
  1150. align: 'center',
  1151. width: 100
  1152. },
  1153. // 单位
  1154. {
  1155. label: '包装单位',
  1156. prop: 'packingUnit',
  1157. align: 'center',
  1158. width: 100
  1159. },
  1160. // 包装规格
  1161. {
  1162. label: '包装规格',
  1163. prop: 'packingSpecificationLabel',
  1164. slot: 'packingSpecificationLabel',
  1165. align: 'center',
  1166. width: 300,
  1167. showOverflowTooltip: true
  1168. },
  1169. // 允许拆包
  1170. {
  1171. label: '允许拆包',
  1172. prop: 'isUnpack',
  1173. align: 'center',
  1174. width: 80,
  1175. formatter: (row) => (row.isUnpack == 1 ? '是' : '否')
  1176. },
  1177. // 计量数量
  1178. {
  1179. label: '计量数量',
  1180. prop: 'measureQuantity',
  1181. align: 'center',
  1182. width: 100,
  1183. showOverflowTooltip: true
  1184. },
  1185. // 计量单位
  1186. {
  1187. label: '计量单位',
  1188. prop: 'measureUnit',
  1189. align: 'center',
  1190. width: 80,
  1191. showOverflowTooltip: true
  1192. },
  1193. // 单重
  1194. {
  1195. label: '单重',
  1196. prop: 'singleWeight',
  1197. slot: 'singleWeight',
  1198. align: 'center',
  1199. width: 120,
  1200. showOverflowTooltip: true
  1201. },
  1202. // 总重
  1203. {
  1204. label: '总重',
  1205. prop: 'weight',
  1206. slot: 'weight',
  1207. align: 'center',
  1208. width: 120,
  1209. showOverflowTooltip: true
  1210. },
  1211. // 重量单位
  1212. {
  1213. label: '重量单位',
  1214. prop: 'weightUnit',
  1215. align: 'center',
  1216. width: 80,
  1217. showOverflowTooltip: true
  1218. },
  1219. // 生产要求
  1220. {
  1221. label: '生产要求',
  1222. prop: 'productionRequirements',
  1223. align: 'center',
  1224. width: 200,
  1225. showOverflowTooltip: true
  1226. },
  1227. // 机型
  1228. {
  1229. label: '机型',
  1230. prop: 'modelKey',
  1231. slot: 'modelKey',
  1232. align: 'center',
  1233. width: 300
  1234. },
  1235. // 颜色
  1236. {
  1237. label: '颜色',
  1238. prop: 'colorKey',
  1239. slot: 'colorKey',
  1240. align: 'center',
  1241. width: 300
  1242. },
  1243. // 供应商
  1244. {
  1245. label: '供应商',
  1246. prop: 'supplierName',
  1247. align: 'center',
  1248. width: 200,
  1249. showOverflowTooltip: true
  1250. },
  1251. // 供应商代号
  1252. {
  1253. label: '供应商代号',
  1254. prop: 'supplierCode',
  1255. align: 'center',
  1256. width: 120,
  1257. showOverflowTooltip: true
  1258. },
  1259. // 盘具显示
  1260. {
  1261. label: '盘具',
  1262. prop: 'reelSpecification',
  1263. align: 'center',
  1264. width: 120,
  1265. showOverflowTooltip: true
  1266. },
  1267. // 产地
  1268. {
  1269. label: '产地',
  1270. prop: 'provenance',
  1271. align: 'center',
  1272. width: 120,
  1273. showOverflowTooltip: true,
  1274. show: this.bizType == 2,
  1275. formatter: (row) => {
  1276. if (row.provenance) {
  1277. return row.provenance
  1278. .map((item) => this.getDictValue('产地', item))
  1279. .join(',');
  1280. }
  1281. return '';
  1282. }
  1283. },
  1284. // 仓库
  1285. {
  1286. label: '仓库',
  1287. prop: 'warehouseName',
  1288. slot: 'warehouseName',
  1289. align: 'center',
  1290. width: 300,
  1291. showOverflowTooltip: true
  1292. },
  1293. // 采购原因
  1294. {
  1295. label: '采购原因',
  1296. prop: 'purpose',
  1297. slot: 'purpose',
  1298. align: 'center',
  1299. width: 200,
  1300. showOverflowTooltip: true
  1301. },
  1302. // 是否质检
  1303. {
  1304. label: '是否质检',
  1305. prop: 'qualityControl',
  1306. align: 'center',
  1307. width: 80,
  1308. showOverflowTooltip: true,
  1309. show: this.bizType != 1 && this.bizType != 6 && this.bizType != 9,
  1310. formatter: (row) => {
  1311. if (row.qualityControl == 1) return '是';
  1312. if (row.qualityControl == 0) return '否';
  1313. return '';
  1314. }
  1315. },
  1316. // 生产日期
  1317. {
  1318. label: '生产日期',
  1319. prop: 'detailProductionDate',
  1320. slot: 'detailProductionDate',
  1321. align: 'center',
  1322. width: 220
  1323. },
  1324. // 采购日期
  1325. {
  1326. label: '采购日期',
  1327. prop: 'detailPurchaseDate',
  1328. slot: 'detailPurchaseDate',
  1329. align: 'center',
  1330. width: 220
  1331. },
  1332. // 失效日期
  1333. {
  1334. label: '失效日期',
  1335. prop: 'detailExpireDate',
  1336. slot: 'detailExpireDate',
  1337. align: 'center',
  1338. width: 220
  1339. },
  1340. // 操作
  1341. {
  1342. label: '操作',
  1343. columnKey: 'action',
  1344. slot: 'action',
  1345. width: 140,
  1346. align: 'center',
  1347. fixed: 'right'
  1348. }
  1349. ].filter((col) => col.show !== false);
  1350. }
  1351. },
  1352. watch: {
  1353. packingList: {
  1354. handler(newVal) {
  1355. console.log(newVal);
  1356. this.showPackingList = newVal.slice(
  1357. 0,
  1358. this.pageSize * (this.pickingPageNum > 0 ? this.pickingPageNum : 1)
  1359. );
  1360. this.showPackingList.forEach((obj) => {
  1361. console.log(obj, '666666666');
  1362. obj.workOrderId = this.detailProductList[0]?.workOrderId;
  1363. obj.taskId = this.detailProductList[0]?.taskId;
  1364. obj.outsourceBatchNo = this.detailProductList[0]?.batchNo;
  1365. obj.outsourceCode = this.detailProductList[0]?.sourceCode;
  1366. obj.taskId = this.detailList[0]?.taskId;
  1367. obj.workOrderId = this.detailList[0]?.workOrderId;
  1368. });
  1369. this.pickingPageNum = Math.ceil(
  1370. this.showPackingList.length / this.pageSize
  1371. );
  1372. },
  1373. deep: true
  1374. },
  1375. materialList: {
  1376. handler(newVal) {
  1377. this.showMaterialList = newVal.slice(
  1378. 0,
  1379. this.pageSize *
  1380. (this.materielPageNum > 0 ? this.materielPageNum : 1)
  1381. );
  1382. },
  1383. deep: true
  1384. }
  1385. // detailList: {
  1386. // handler(newVal) {
  1387. // if (newVal.length) {
  1388. // this.initFormData();
  1389. // }
  1390. // },
  1391. // deep: true
  1392. // },
  1393. },
  1394. async created() {
  1395. // 生产报工是否有盘具的填写输入框 //0否 1是
  1396. parameterGetByCode({
  1397. code: 'dishware_specifications'
  1398. }).then((res) => {
  1399. this.isReelSpecification = res.value;
  1400. console.log('isReelSpecification', this.isReelSpecification);
  1401. });
  1402. await this.requestDict('产地');
  1403. await this.requestDict('不拆物料层规格');
  1404. await this.requestDict('物品颜色');
  1405. await this.requestDict('物品机型');
  1406. await this.getFieldModel();
  1407. await this.getListItems();
  1408. await this.initFormData();
  1409. await this.getNowFormatDate();
  1410. },
  1411. methods: {
  1412. ...mapActions('dict', ['requestDict']),
  1413. // 通过挂起状态设置行样式
  1414. tableRowClassName({ row }) {
  1415. // console.log('tableRowClassName', row)
  1416. if (row.isReversal == 1) {
  1417. return 'warning-row';
  1418. }
  1419. return '';
  1420. },
  1421. handleRowClick(row) {
  1422. // this.current = row;
  1423. console.log('handleRowClick', row);
  1424. if (row.isReversal == 1) {
  1425. this.$alert(`替代批次号:${row.suspendOrReverseDetail[0].batchNo}`, {
  1426. confirmButtonText: '知道了',
  1427. type: 'none'
  1428. }).catch(() => {
  1429. // 捕获用户取消操作时的Promise rejection
  1430. });
  1431. }
  1432. },
  1433. changeCount(number) {
  1434. return new BigNumber(number).toString();
  1435. },
  1436. selectSupplier(val, row) {
  1437. row.supplierId = val;
  1438. row.supplierName = row.supplierListOptions.filter(
  1439. (item) => item.id == val
  1440. )[0]?.name;
  1441. row.supplierCode = row.supplierListOptions.filter(
  1442. (item) => item.id == val
  1443. )[0].serialNo;
  1444. },
  1445. inputsingleWeight(row, index) {
  1446. if (row.measureUnit == row.weightUnit) {
  1447. row.weight = row.singleWeight * row.packingQuantity;
  1448. row.measureQuantity = row.weight;
  1449. } else {
  1450. row.weight = row.singleWeight * row.measureQuantity;
  1451. }
  1452. },
  1453. inputWeight(row, index) {
  1454. if (row.measureUnit == row.weightUnit) {
  1455. row.measureQuantity = row.weight;
  1456. row.singleWeight =
  1457. Math.trunc((row.measureQuantity / row.packingQuantity) * 10000) /
  1458. 10000;
  1459. } else {
  1460. row.singleWeight = row.measureQuantity
  1461. ? row.weight / row.measureQuantity
  1462. : 0;
  1463. }
  1464. },
  1465. // 计算最小单元数量
  1466. async computeNum(row, index, isClear) {
  1467. console.log('row, index', row, index);
  1468. let data = row.packingSpecificationOption.find(
  1469. (item) => item.id == row.unitId
  1470. );
  1471. row.unit = data.conversionUnit;
  1472. // 清空仓库(包装数量输入)
  1473. if (isClear) {
  1474. if (row.quantity < 0) {
  1475. this.$set(this.productList[index], 'quantity', 1);
  1476. }
  1477. }
  1478. //如果有包装数量和包装单位
  1479. if (row.quantity && row.unit) {
  1480. //获取仓库
  1481. const res = await warehouseDefinition.list({
  1482. // inventoryType: this.form.categoryLevelTopId
  1483. });
  1484. // 只有一个仓库自动显示出来
  1485. if (res.length == 1) {
  1486. let name = res[0]?.factoryName + '-' + res[0]?.name;
  1487. console.log('仓库-----------------------------', res);
  1488. this.$set(this.productList[index], 'warehouseId', res[0].id);
  1489. this.$set(this.productList[index], 'warehouseName', name);
  1490. let table1 = [];
  1491. table1.push({
  1492. measureQuantity: row.measureQuantity,
  1493. packingQuantity: row.quantity,
  1494. warehouseName: name,
  1495. warehouseId: res[0].id
  1496. });
  1497. this.wareHouseSelection(table1, index);
  1498. } else {
  1499. this.$set(this.productList[index], 'warehouseId', '');
  1500. this.$set(this.productList[index], 'warehouseName', '');
  1501. }
  1502. // -----------------------------------------------------------------
  1503. let startIndex = row.packingSpecificationOption.findIndex((ite) => {
  1504. return (
  1505. row.measuringUnit == ite.packingUnit &&
  1506. ite.packingUnit != ite.conversionUnit
  1507. );
  1508. });
  1509. let endIndex = row.packingSpecificationOption.findIndex(
  1510. (ite) => data.id == ite.id
  1511. );
  1512. console.log(row, 'rowwwwwwwwwwwwww');
  1513. let total = Number(row.quantity);
  1514. console.log(total, '111');
  1515. if (
  1516. row.unit == row.measureUnit &&
  1517. row.measureUnit == '立方' &&
  1518. row.netWeight
  1519. ) {
  1520. total = Number(row.quantity) * row.netWeight;
  1521. console.log(
  1522. total,
  1523. '单位是立方,计量单位也是立方,如果有单重,就计量数量x单重=总重'
  1524. );
  1525. console.log(total, '2222');
  1526. } else {
  1527. console.log(total, 333);
  1528. for (; 0 < endIndex; endIndex--) {
  1529. total = this.$math.format(
  1530. row.packingSpecificationOption[endIndex].packageCell * total,
  1531. 14
  1532. );
  1533. }
  1534. }
  1535. console.log(total, '444456');
  1536. //计量数量
  1537. row.measureQuantity = this.changeCount(total);
  1538. // 判断单位和计量单位是否为不拆物料层规格
  1539. let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
  1540. .dictValue;
  1541. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
  1542. .dictValue;
  1543. console.log(packingBoolen, 'packingBoolen');
  1544. console.log(measureBoolen, 'measureBoolen');
  1545. if (packingBoolen && measureBoolen && row.unit != 'L') {
  1546. row.weight = total;
  1547. console.log(total, '6');
  1548. }
  1549. let weight = 0;
  1550. if (row.measureUnit == row.weightUnit) {
  1551. weight = row.measureQuantity;
  1552. // 如果重量单位和包装单位一致,则单重0
  1553. if (row.weightUnit == row.unit) {
  1554. row.singleWeight = 0;
  1555. } else {
  1556. row.singleWeight =
  1557. Math.trunc((row.measureQuantity / row.quantity) * 10000) /
  1558. 10000;
  1559. }
  1560. } else if (row.singleWeight) {
  1561. weight = row.measureQuantity * Number(row.singleWeight);
  1562. }
  1563. this.$set(this.productList[index], 'weight', weight);
  1564. this.$set(
  1565. this.productList[index],
  1566. 'packingQuantity',
  1567. this.setPNum(row)
  1568. );
  1569. }
  1570. },
  1571. setPNum(row) {
  1572. let pNum = 0;
  1573. if (row.unitId) {
  1574. let splitIndex = row.packingSpecificationOption.findIndex(
  1575. (item) => item.id == row.unitId
  1576. );
  1577. if (splitIndex == 0) {
  1578. pNum = Math.ceil(
  1579. row.measureQuantity /
  1580. row.packingSpecificationOption[1]?.packageCell
  1581. );
  1582. }
  1583. if (splitIndex == 1) {
  1584. pNum = row.quantity;
  1585. }
  1586. for (; splitIndex > 1; splitIndex--) {
  1587. pNum = Math.ceil(
  1588. row.quantity *
  1589. row.packingSpecificationOption[splitIndex].packageCell
  1590. );
  1591. }
  1592. } else {
  1593. pNum = Math.ceil(
  1594. row.measureQuantity / row.packingSpecificationOption[1]?.packageCell
  1595. );
  1596. }
  1597. return pNum;
  1598. },
  1599. // 获取动态表头
  1600. getFieldModel() {
  1601. storageApi.fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  1602. let newRes = res.map((m) => {
  1603. return {
  1604. prop: 'extField.' + m.prop,
  1605. label: m.label,
  1606. align: 'center',
  1607. showOverflowTooltip: true
  1608. };
  1609. });
  1610. this.newColumns = [...newRes].filter(
  1611. (item) =>
  1612. item.prop != 'extField.packingSpecification' &&
  1613. item.prop != 'extField.packingSpecificationLabel'
  1614. );
  1615. });
  1616. },
  1617. // 初始化信息
  1618. async initFormData() {
  1619. console.log(this.form, 'form');
  1620. console.log(this.formData, 'formData');
  1621. console.log(this.sourceBizNo, 'sourceBizNo');
  1622. this.formData.type = 1;
  1623. this.formData.bizType = this.bizType;
  1624. if (this.sourceBizNo != null || this.sourceBizNo != '') {
  1625. // this.formData.sourceBizNo = this.sourceBizNo;
  1626. this.$set(this.formData, 'sourceBizNo', this.sourceBizNo);
  1627. } else {
  1628. this.$message.warning('未获取到单据来源!');
  1629. }
  1630. // 入库登记人
  1631. // this.formData.extInfo.createUserId = this.$store.state.user.info.userId;
  1632. // this.formData.extInfo.createUserName = this.$store.state.user.info.name;
  1633. // this.formData.extInfo.deliveryPhone = this.$store.state.user.info.phone;
  1634. // this.formData.createUserId = this.$store.state.user.info.userId;
  1635. // this.formData.extInfo.deptName = this.$store.state.user.info.deptName;
  1636. // 入库登记人
  1637. // const startUser = this.processInstance?.startUser || {};
  1638. const userInfo = this.$store.state.user.info || {};
  1639. // 确保所有值都是原始类型,防止对象被绑定到DOM属性
  1640. this.formData.extInfo.createUserId =
  1641. this.form.createUserId || userInfo.userId || '';
  1642. this.formData.extInfo.createUserName =
  1643. this.form.createUserName || userInfo.name || '';
  1644. this.formData.extInfo.deliveryPhone = userInfo.phone || '';
  1645. this.formData.createUserId =
  1646. this.form.createUserId || userInfo.userId || '';
  1647. this.formData.createUserName =
  1648. this.form.createUserName || userInfo.name || '';
  1649. this.formData.extInfo.deptName =
  1650. this.form.deptName || userInfo.deptName || '';
  1651. this.formData.approvalUserName =
  1652. this.form.approvalUserName || userInfo.name;
  1653. this.formData.approvalUserId =
  1654. this.form.approvalUserId || userInfo.userId;
  1655. // this.formData.extInfo.supplierName = this.form.supplierName;
  1656. // this.formData.extInfo.supplierId = this.form.supplierId; // this.formData.extInfo.supplierId = this.form.supplierId;
  1657. console.log('saleProductList-------------------', this.saleProductList);
  1658. if (this.saleProductList?.length > 0) {
  1659. let detailPurchaseDate;
  1660. if (this.formData.bizType == '2' || this.formData.bizType == '10') {
  1661. // 采购入库
  1662. const defaultTime = '00:00:00';
  1663. detailPurchaseDate =
  1664. this.form.purchaseDate ||
  1665. `${this.form.receiveDate} ${defaultTime}`;
  1666. }
  1667. // 物品列表
  1668. let codeList = this.saleProductList.map((item) => {
  1669. return item.productCode || item.categoryCode;
  1670. });
  1671. storageApi.getListByNameOrModeType({ codeList }).then(async (res) => {
  1672. if (res.length <= 0) {
  1673. this.$message.warning('未获取到物品信息!');
  1674. return;
  1675. }
  1676. this.formData.extInfo.assetType = Array.from(
  1677. new Set(res.map((item) => item.categoryLevelPathIdParent))
  1678. );
  1679. console.log(this.formData.extInfo.assetType, '类型类型');
  1680. // 获取批次号
  1681. const batchNo1 = await getCode('lot_number_code');
  1682. // 获取供应商
  1683. const supplierList = await storageApi.contactQueryByCategoryIdsAPI({
  1684. categoryIds: res.map((item) => item.id)
  1685. });
  1686. // 获取包装规格
  1687. let packingSpecification =
  1688. await storageApi.getCategoryPackageDisposition({
  1689. categoryIds: res.map((item) => item.id)
  1690. });
  1691. let packingSpecificationOption = res.map((item) => {
  1692. return {
  1693. id: item.id,
  1694. packingSpecification: packingSpecification
  1695. .filter((ite) => item.id == ite.categoryId)
  1696. .sort((a, b) => a.sort - b.sort)
  1697. };
  1698. });
  1699. console.log(
  1700. packingSpecificationOption,
  1701. 'packingSpecificationOption'
  1702. );
  1703. this.productList = this.saleProductList.map(
  1704. (filtersItem, index) => {
  1705. let item = res.find(
  1706. (detailItem) =>
  1707. detailItem.code == filtersItem.productCode ||
  1708. detailItem.code == filtersItem.categoryCode
  1709. );
  1710. const packingSpecificationItem =
  1711. packingSpecificationOption.find(
  1712. (packingSpecificationItem) =>
  1713. packingSpecificationItem.id == filtersItem.productId ||
  1714. packingSpecificationItem.id == filtersItem.categoryId
  1715. )?.packingSpecification;
  1716. // 显示规格
  1717. let packingSpecificationLabel = packingSpecificationItem
  1718. .map((item) => {
  1719. if (item.sort > 0) {
  1720. return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
  1721. }
  1722. })
  1723. .filter((item) => !!item);
  1724. const newSpecificationOption = packingSpecificationItem;
  1725. console.log(
  1726. newSpecificationOption,
  1727. '啵啵啵啵啵啵啵啵啵啵啵啵2'
  1728. );
  1729. console.log(filtersItem, 'filtersItemfiltersItemfiltersItem');
  1730. let warehouseId = filtersItem.warehouseId;
  1731. let warehouseName = filtersItem.warehouseName;
  1732. let measureQuantity =
  1733. filtersItem.totalCountNew || filtersItem.totalCount || 0;
  1734. // let measureQuantityOld = filtersItem.totalCount || 0;
  1735. if (
  1736. (filtersItem.sendTotalWeight ||
  1737. filtersItem.receiveTotalWeight) &&
  1738. item.weightUnit == item.measuringUnit
  1739. ) {
  1740. measureQuantity =
  1741. filtersItem.sendTotalWeight ||
  1742. filtersItem.receiveTotalWeight;
  1743. }
  1744. let quantity =
  1745. filtersItem.totalCountNew ||
  1746. filtersItem.purchaseCount ||
  1747. filtersItem.totalCount ||
  1748. 0;
  1749. let unit =
  1750. filtersItem.purchaseUnit || filtersItem.measuringUnit || '';
  1751. let unitPrice = filtersItem.singlePrice || 0;
  1752. let pricingWay = filtersItem.pricingWay || '';
  1753. let packingQuantity = this.setPNum({
  1754. unitId: filtersItem.purchaseUnitId || filtersItem.saleUnitId,
  1755. packingSpecificationOption: newSpecificationOption, // 包装规格选项
  1756. measureQuantity:
  1757. filtersItem &&
  1758. filtersItem.isAllPackageData &&
  1759. filtersItem.isAllPackageData == 1
  1760. ? filtersItem.quantity
  1761. : measureQuantity, // 计量数量
  1762. quantity
  1763. });
  1764. let singleWeight =
  1765. filtersItem.singleWeight ||
  1766. this.detailProductList[0]?.singleWeight ||
  1767. 0;
  1768. let weight =
  1769. filtersItem.sendTotalWeight ||
  1770. filtersItem.receiveTotalWeight ||
  1771. singleWeight * measureQuantity;
  1772. console.log(weight, 'weight');
  1773. // if(weight){
  1774. // }
  1775. // 获取相同仓库
  1776. let warehouseIds = [];
  1777. let warehouseNames = [];
  1778. for (let i = 0; i < filtersItem.totalCount; i++) {
  1779. warehouseIds.push(filtersItem.warehouseId);
  1780. warehouseNames.push(filtersItem.warehouseName);
  1781. }
  1782. let totalMoney = filtersItem.totalPrice || 0;
  1783. console.log(
  1784. filtersItem,
  1785. 'filtersItemfiltersItemfiltersItemfiltersItemfiltersItem'
  1786. );
  1787. let batchNo = '';
  1788. if (filtersItem.batchNo) {
  1789. batchNo = filtersItem.batchNo;
  1790. } else {
  1791. batchNo = batchNo1;
  1792. }
  1793. console.log(newSpecificationOption, 'dsd');
  1794. return {
  1795. index: this.productList.length + index,
  1796. purchaseReceiveProductId:
  1797. filtersItem.purchaseReceiveProductId,
  1798. categoryId: item.id, // 物品id
  1799. categoryName: item.name, // 物品名称
  1800. categoryCode: item.code, // 物品编码
  1801. categoryModel: item.modelType, // 物品型号
  1802. specification: item.specification, // 规格
  1803. brandNum: item.brandNum, // 牌号
  1804. batchNo: batchNo, // 批次号
  1805. supplierListOptions: supplierList[item.id], // 供应商列表
  1806. supplierId: this.form.supplierId, // 供应商id
  1807. productionRequirements: filtersItem.productionRequirements, //生产要求
  1808. supplierCode:
  1809. this.bizType == 2 || this.bizType == 7
  1810. ? filtersItem.supplierMark
  1811. : item.supplierCode, // 供应商代号
  1812. supplierName: this.form.supplierName, // 供应商名称
  1813. approvalNumber: item.approvalNumber, // 批准文号
  1814. packingSpecification: item.packingSpecification, // 包装规格
  1815. packingSpecificationOption: newSpecificationOption, // 包装规格选项
  1816. packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
  1817. quantity:
  1818. filtersItem &&
  1819. filtersItem.isAllPackageData &&
  1820. filtersItem.isAllPackageData == 1
  1821. ? filtersItem.packingCount
  1822. : quantity,
  1823. packingQuantity:
  1824. filtersItem &&
  1825. filtersItem.isAllPackageData &&
  1826. filtersItem.isAllPackageData == 1
  1827. ? filtersItem.packingCount
  1828. : packingQuantity, // 包装数量
  1829. packingUnit:
  1830. filtersItem &&
  1831. filtersItem.isAllPackageData &&
  1832. filtersItem.isAllPackageData == 1
  1833. ? filtersItem.packingUnit ||
  1834. newSpecificationOption[1]?.packingUnit
  1835. : item.packingUnit, // 单位
  1836. unit:
  1837. filtersItem &&
  1838. filtersItem.isAllPackageData &&
  1839. filtersItem.isAllPackageData == 1
  1840. ? filtersItem.packingUnit
  1841. : unit, // 单位
  1842. measureQuantity:
  1843. filtersItem &&
  1844. filtersItem.isAllPackageData &&
  1845. filtersItem.isAllPackageData == 1
  1846. ? filtersItem.quantity
  1847. : measureQuantity, // 计量数量
  1848. // measureQuantityOld,
  1849. measureUnit:
  1850. filtersItem &&
  1851. filtersItem.isAllPackageData &&
  1852. filtersItem.isAllPackageData == 1
  1853. ? filtersItem.measuringUnit
  1854. : item.measuringUnit, // 计量单位
  1855. unitId: filtersItem.purchaseUnitId || filtersItem.saleUnitId,
  1856. modelKey: filtersItem.modelKey
  1857. ? filtersItem.modelKey?.split(',')?.[0] || ''
  1858. : '', // 机型
  1859. colorKey: filtersItem.colorKey
  1860. ? filtersItem.colorKey?.split(',')?.[0] || ''
  1861. : '', // 颜色
  1862. measureType: item.measureType, // 计量方式
  1863. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  1864. singleWeight: singleWeight || 0, // 单重重量
  1865. weight: weight || 0, // 总重量
  1866. weightUnit: item.weightUnit, // 重量单位
  1867. totalMoney: totalMoney, // 总价
  1868. unitPrice: item.unitPrice || unitPrice, // 单价
  1869. pricingWay: pricingWay, //计价方式
  1870. purpose: '', // 用途
  1871. detailPurchaseDate,
  1872. detailExpireDate: this.saleProductList.find(
  1873. (product) => product.productId == item.id
  1874. )?.guaranteePeriodDeadline,
  1875. detailProductionDate: this.saleProductList.find(
  1876. (product) => product.productId == item.id
  1877. )?.productionDate,
  1878. provenance: filtersItem.provenance, //产地
  1879. isUnpack: item.isUnpack, // 是否允许拆包
  1880. warehouseId, // 仓库id
  1881. warehouseName, // 仓库名称
  1882. warehouseIds,
  1883. warehouseNames,
  1884. qualityControl: filtersItem?.isComeCheck // 是否需要质检
  1885. };
  1886. }
  1887. );
  1888. console.log(this.productList, 'this.productListtttttttttttt');
  1889. this.$nextTick(() => {
  1890. this.batchSave();
  1891. // this.listSaveArrs()
  1892. });
  1893. });
  1894. }
  1895. console.log('this.detailList-----------------', this.detailList);
  1896. if (this.detailList?.length > 0) {
  1897. if (
  1898. this.form != null &&
  1899. Object.keys(this.form).length > 0 &&
  1900. this.form.categoryLevelTopId != ''
  1901. ) {
  1902. this.formData.extInfo.assetType = Array.from(
  1903. new Set(this.form?.categoryLevelTopId?.split(','))
  1904. );
  1905. } else {
  1906. this.$message.warning('未获取到物品类型!');
  1907. }
  1908. const mergedList = [];
  1909. this.detailList.forEach((item) => {
  1910. const key = `${item.productCode}_${item.batchNo}_${item.colorKey}_${item.warehouseId}_${item.modelType}`;
  1911. const existIndex = mergedList.findIndex(
  1912. (m) =>
  1913. `${m.productCode}_${m.batchNo}_${m.colorKey}_${m.warehouseId}_${m.modelType}` ===
  1914. key
  1915. );
  1916. if (existIndex > -1) {
  1917. mergedList[existIndex].quantity += item.quantity;
  1918. mergedList[existIndex].packingWeight += item.packingWeight;
  1919. mergedList[existIndex].packingQuantity += item.packingQuantity;
  1920. } else {
  1921. mergedList.push({ ...item });
  1922. }
  1923. });
  1924. console.log(mergedList, 'mergedList');
  1925. // 包装列表 this.detailList
  1926. // 获取主数据物品详情
  1927. // let { category } = await getDetails(this.form.categoryId);
  1928. let codeList = this.detailList.map((item) => {
  1929. return item.productCode || item.categoryCode;
  1930. });
  1931. storageApi
  1932. .getListByNameOrModeType({
  1933. codeList
  1934. })
  1935. .then(async (res) => {
  1936. console.log(res, 'detailList-res');
  1937. console.log(this.form, 'this.form.warehouseId');
  1938. console.log(this.bizType, 'this.bizType~~~');
  1939. // 获取批次号
  1940. const batchNo = await getCode('lot_number_code');
  1941. // 获取供应商
  1942. const supplierList =
  1943. await storageApi.contactQueryByCategoryIdsAPI({
  1944. categoryIds: res.map((item) => item.id)
  1945. });
  1946. // 获取包装规格
  1947. let packingSpecification =
  1948. await storageApi.getCategoryPackageDisposition({
  1949. categoryIds: res.map((item) => item.id)
  1950. });
  1951. let packingSpecificationOptions = res.map((item) => {
  1952. return {
  1953. id: item.id,
  1954. packingSpecification: packingSpecification
  1955. .filter((ite) => item.id == ite.categoryId)
  1956. .sort((a, b) => a.sort - b.sort)
  1957. };
  1958. });
  1959. console.log(
  1960. packingSpecificationOptions,
  1961. 'packingSpecificationOptions'
  1962. );
  1963. // this.packingSpecificationOption = res.map((item) => {
  1964. // return packingSpecification
  1965. // .filter((ite) => item.id == ite.categoryId)
  1966. // .sort((a, b) => a.sort - b.sort);
  1967. // });
  1968. // 获取相同仓库
  1969. let warehouseIds = [];
  1970. let warehouseNames = [];
  1971. console.log(this.form.totalCount, 'this.form.warehouseId');
  1972. for (let index = 0; index < this.form.totalCount; index++) {
  1973. warehouseIds.push(this.form.warehouseId);
  1974. warehouseNames.push(this.form.warehouseName);
  1975. }
  1976. if (this.bizType == 4 || this.bizType == 1) {
  1977. warehouseIds.push(this.form.warehouseId);
  1978. warehouseNames.push(this.form.warehouseName);
  1979. }
  1980. if (this.isMoreProduct) {
  1981. this.formData.extInfo.assetType = [];
  1982. res.map((item) => {
  1983. this.formData.extInfo.assetType.push(
  1984. item.categoryLevelPathIdParent
  1985. );
  1986. });
  1987. this.formData.extInfo.assetType = Array.from(
  1988. new Set(...this.formData.extInfo.assetType)
  1989. );
  1990. }
  1991. // const newSpecificationOption = this.getNewSpecificationOption(
  1992. // this.packingSpecificationOption
  1993. // );
  1994. // 生成产品列表
  1995. let newSpecificationOption = [];
  1996. this.productList = mergedList.map((filtersItem, index) => {
  1997. let item = res.find(
  1998. (detailItem) =>
  1999. detailItem.code == filtersItem.productCode ||
  2000. detailItem.code == filtersItem.categoryCode
  2001. );
  2002. // 显示规格
  2003. // let packingSpecificationLabel = this.packingSpecificationOption[
  2004. // index
  2005. // ]
  2006. // .map((item) => {
  2007. // if (item.sort > 0) {
  2008. // return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
  2009. // }
  2010. // })
  2011. // .filter((item) => !!item);
  2012. const packingSpecificationItem =
  2013. packingSpecificationOptions.find(
  2014. (packingSpecificationItem) =>
  2015. packingSpecificationItem.id == filtersItem.productId
  2016. )?.packingSpecification;
  2017. console.log(
  2018. 'packingSpecificationLabel~~~~~~',
  2019. this.detailList,
  2020. res,
  2021. packingSpecification,
  2022. packingSpecificationOptions,
  2023. packingSpecificationItem
  2024. );
  2025. let packingQuantity =
  2026. filtersItem.totalCountNew ||
  2027. filtersItem.purchaseCount ||
  2028. filtersItem.totalCount ||
  2029. 0;
  2030. console.log(packingQuantity, 'packingQudasdasdantity');
  2031. // 显示规格
  2032. let packingSpecificationLabel = packingSpecificationItem
  2033. ?.map((item) => {
  2034. if (item.sort > 0) {
  2035. return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
  2036. }
  2037. })
  2038. .filter((item) => !!item);
  2039. newSpecificationOption = packingSpecificationItem;
  2040. // 换算重量
  2041. let weight = 0;
  2042. if (
  2043. this.form?.weightUnit?.toUpperCase() ==
  2044. item?.weightUnit.toUpperCase()
  2045. ) {
  2046. weight = this.form.totalWeight;
  2047. } else {
  2048. switch (filtersItem.weightUnit.toUpperCase()) {
  2049. case 'KG':
  2050. if (this.form.totalWeight > -1) {
  2051. weight = this.$math.format(
  2052. this.form.totalWeight / 1000,
  2053. 14
  2054. );
  2055. } else {
  2056. weight = 0;
  2057. }
  2058. break;
  2059. case 'G':
  2060. if (this.form.totalWeight > -1) {
  2061. weight = this.$math.format(
  2062. this.form.totalWeight * 1000,
  2063. 14
  2064. );
  2065. } else {
  2066. weight = 0;
  2067. }
  2068. break;
  2069. case 'L':
  2070. if (this.form.totalWeight > -1) {
  2071. weight = this.$math.format(
  2072. this.form.totalWeight * 1000,
  2073. 14
  2074. );
  2075. } else {
  2076. weight = 0;
  2077. }
  2078. break;
  2079. case 'l':
  2080. if (this.form.totalWeight > -1) {
  2081. weight = this.$math.format(
  2082. this.form.totalWeight * 1000,
  2083. 14
  2084. );
  2085. } else {
  2086. weight = 0;
  2087. }
  2088. break;
  2089. case 'ML':
  2090. if (this.form.totalWeight > -1) {
  2091. weight = this.$math.format(
  2092. this.form.totalWeight * 1000,
  2093. 14
  2094. );
  2095. } else {
  2096. weight = 0;
  2097. }
  2098. break;
  2099. case 'ml':
  2100. if (this.form.totalWeight > -1) {
  2101. weight = this.$math.format(
  2102. this.form.totalWeight * 1000,
  2103. 14
  2104. );
  2105. } else {
  2106. weight = 0;
  2107. }
  2108. break;
  2109. }
  2110. }
  2111. let packingUnit =
  2112. filtersItem.packingUnit ||
  2113. newSpecificationOption[1]?.conversionUnit ||
  2114. '';
  2115. let singleWeight = filtersItem.singleWeight || 0; // 单重重量
  2116. return {
  2117. index: this.productList.length + index,
  2118. isSave: true,
  2119. categoryId: item.id, // 物品id
  2120. categoryName: item.name, // 物品名称
  2121. categoryCode: item.code, // 物品编码
  2122. categoryModel: item.modelType, // 物品型号
  2123. specification: item.specification, // 规格
  2124. brandNum: item.brandNum, // 牌号
  2125. colorKey:
  2126. this.bizType == 1
  2127. ? this.form.colorKey?.split(',')?.[0] || ''
  2128. ? this.form.colorKey?.split(',')?.[0] || ''
  2129. : ''
  2130. : filtersItem.colorKey?.split(',')?.[0] || ''
  2131. ? filtersItem.colorKey?.split(',')?.[0] || ''
  2132. : '', // 颜色
  2133. modelKey:
  2134. this.bizType == 1
  2135. ? this.form.modelKey?.split(',')?.[0] || ''
  2136. ? this.form.modelKey?.split(',')?.[0] || ''
  2137. : ''
  2138. : filtersItem.modelKey?.split(',')?.[0] || ''
  2139. ? filtersItem.modelKey?.split(',')?.[0] || ''
  2140. : '', // 机型
  2141. batchNo: filtersItem?.batchNo || batchNo, // 批次号
  2142. supplierListOptions: supplierList[item.id], // 供应商列表
  2143. supplierId: filtersItem?.supplierId || item.supplierId, // 供应商id
  2144. supplierCode: filtersItem?.supplierCode || item.supplierCode,
  2145. supplierName: filtersItem?.supplierName || item.supplierName, // 供应商名称
  2146. approvalNumber: item.approvalNumber, // 批准文号
  2147. productionRequirements: filtersItem.productionRequirements,
  2148. packingSpecification: item.packingSpecification, // 包装规格
  2149. packingSpecificationOption: newSpecificationOption, // 包装规格选项
  2150. packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
  2151. // minPackingQuantity: 1, // 最小包装单元数量
  2152. // packingQuantity: this.isMoreProduct
  2153. // ? this.detailList.filter(
  2154. // (val) => val.productCode == item.code
  2155. // ).length
  2156. // : this.detailList.length || this.form.detailList.length, // 包装数量
  2157. packingQuantity: this.isMoreProduct
  2158. ? filtersItem.packingQuantity
  2159. : filtersItem.packingQuantity || this.detailList.length,
  2160. packingUnit: packingUnit, // 单位
  2161. measureQuantity: this.isMoreProduct
  2162. ? filtersItem.quantity
  2163. : filtersItem.quantity || this.form.totalCount, // 计量数量
  2164. measureUnit: filtersItem.measuringUnit, // 计量单位
  2165. quantity: this.isMoreProduct
  2166. ? filtersItem.quantity
  2167. : filtersItem.quantity || this.form.totalCount, // 数量
  2168. unit: filtersItem.measuringUnit, // 单位
  2169. measureType: item.measureType, // 计量方式
  2170. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  2171. weight: weight || 0, // 重量
  2172. singleWeight: singleWeight || 0,
  2173. weightUnit: item.weightUnit, // 重量单位
  2174. totalMoney: filtersItem.totalPrice, // 总价
  2175. unitPrice: filtersItem.unitPrice, // 单价
  2176. reelSpecification:
  2177. filtersItem.reelSpecification ||
  2178. filtersItem.extInfo?.reelSpecification, // 盘具
  2179. purpose: '', // 用途
  2180. isUnpack: item.isUnpack, // 是否允许拆包
  2181. warehouseId: this.isMoreProduct
  2182. ? filtersItem?.warehouseId
  2183. : this.form.warehouseId, // 仓库id
  2184. warehouseName: this.isMoreProduct
  2185. ? filtersItem?.warehouseName
  2186. : this.form.warehouseName, // 仓库名称
  2187. warehouseIds: this.isMoreProduct
  2188. ? mergedList
  2189. .filter((val) => val.productCode == item.code)
  2190. .map((item) => item.warehouseId)
  2191. : warehouseIds,
  2192. warehouseNames: this.isMoreProduct
  2193. ? mergedList
  2194. .filter((val) => val.productCode == item.code)
  2195. .map((item) => item.warehouseName)
  2196. : warehouseNames
  2197. };
  2198. });
  2199. console.log('this.isMoreProduct', this.isMoreProduct);
  2200. let getAssetNumPr = this.isMoreProduct
  2201. ? this.detailList.map((val) => {
  2202. console.log('val', val);
  2203. return {
  2204. assetCode: val.productCode,
  2205. batchNum: val.productBrand
  2206. ? val.productBrand
  2207. : val.batchNo,
  2208. num: 1
  2209. };
  2210. })
  2211. : [
  2212. {
  2213. assetCode:
  2214. this.productList[0].categoryCode +
  2215. this.productList[0].index,
  2216. batchNum: this.productList[0].batchNo,
  2217. num: this.detailList.length
  2218. }
  2219. ];
  2220. console.log(this.productList, 'this.productList');
  2221. console.log(this.detailList, 'this.detailList');
  2222. console.log(this.detailList.length, 'this.detailList');
  2223. console.log(getAssetNumPr, 'getAssetNumPr');
  2224. // 生成包装编码
  2225. const { data } = await storageApi.getAssetNum(getAssetNumPr);
  2226. let packingCodeList = data;
  2227. // 生产包装
  2228. this.packingList = this.detailList.map((item, index) => {
  2229. // if (item.isAllPackageData != 1) {
  2230. // console.log(item, 'itemitemitemitemitemitem1');
  2231. // console.log(item.packingUnit, 'itemitemitemitemitemitem2');
  2232. // 换算重量
  2233. let weight = 0;
  2234. if (
  2235. this.productList[0].weightUnit.toUpperCase() ==
  2236. item.weightUnit.toUpperCase()
  2237. ) {
  2238. weight = this.form.totalWeight;
  2239. } else {
  2240. switch (this.productList[0].weightUnit.toUpperCase()) {
  2241. case 'KG':
  2242. if (item.weightUnit > -1) {
  2243. weight = this.$math.format(item.weightUnit / 1000, 14);
  2244. } else {
  2245. weight = 0;
  2246. }
  2247. break;
  2248. case 'G':
  2249. if (item.weightUnit > -1) {
  2250. weight = this.$math.format(item.weightUnit * 1000, 14);
  2251. } else {
  2252. weight = 0;
  2253. }
  2254. break;
  2255. case 'L':
  2256. if (item.weightUnit > -1) {
  2257. weight = this.$math.format(item.weightUnit / 1000, 14);
  2258. } else {
  2259. weight = 0;
  2260. }
  2261. break;
  2262. case 'l':
  2263. if (item.weightUnit > -1) {
  2264. weight = this.$math.format(item.weightUnit / 1000, 14);
  2265. } else {
  2266. weight = 0;
  2267. }
  2268. break;
  2269. case 'ML':
  2270. if (item.weightUnit > -1) {
  2271. weight = this.$math.format(item.weightUnit / 1000, 14);
  2272. } else {
  2273. weight = 0;
  2274. }
  2275. break;
  2276. case 'ml':
  2277. if (item.weightUnit > -1) {
  2278. weight = this.$math.format(item.weightUnit / 1000, 14);
  2279. } else {
  2280. weight = 0;
  2281. }
  2282. break;
  2283. }
  2284. }
  2285. // 代入时间
  2286. let obj = this.getNowDate();
  2287. let productionDate = '';
  2288. let purchaseDate = '';
  2289. if (this.formData.bizType == '1') {
  2290. // 生产入库
  2291. productionDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  2292. // this.curDateType = 'productionDate';
  2293. } else if (this.formData.bizType == '2') {
  2294. // 采购入库
  2295. const defaultTime = '00:00:00';
  2296. purchaseDate =
  2297. this.form.purchaseDate ||
  2298. `${this.form.receiveDate} ${defaultTime}`;
  2299. // this.curDateType = 'purchaseDate';
  2300. }
  2301. let clientCode = '';
  2302. if (this.bizType == 2) {
  2303. clientCode = item.customerMark;
  2304. } else if (this.bizType != 2) {
  2305. clientCode = item.clientCode || item.extInfo?.clientCode;
  2306. }
  2307. return {
  2308. index: this.isMoreProduct
  2309. ? this.productList.find(
  2310. (val) => val.categoryCode == item.productCode
  2311. ).index +
  2312. '-' +
  2313. index
  2314. : this.productList[0].index + '-' + index, // 包装索引
  2315. warehouseId:
  2316. item.warehouseId || this.productList[0].warehouseIds[index], // 仓库id
  2317. warehouseName:
  2318. item.warehouseName ||
  2319. this.productList[0].warehouseNames[index], // 仓库名称
  2320. categoryName:
  2321. item.productName || this.productList[0].categoryName, // 产品名称
  2322. categoryCode:
  2323. item.productCode || this.productList[0].categoryCode, // 产品编码
  2324. categoryModel:
  2325. item.modelType || this.productList[0].categoryModel, // 物品型号
  2326. specification:
  2327. item.specification || this.productList[0].specification, // 规格
  2328. brandNum: item.productBrand || this.productList[0].brandNum, // 牌号
  2329. colorKey:
  2330. (item.colorKey
  2331. ? item.colorKey?.split(',')?.[0] || ''
  2332. : '') ||
  2333. this.productList[0].colorKey?.split(',')?.[0] ||
  2334. '', // 颜色
  2335. modelKey:
  2336. (item.modelKey
  2337. ? item.modelKey?.split(',')?.[0] || ''
  2338. : '') ||
  2339. this.productList[0].modelKey?.split(',')?.[0] ||
  2340. '', // 机型
  2341. parentIndex: this.isMoreProduct
  2342. ? this.productList.find(
  2343. (val) => val.categoryCode == item.productCode
  2344. ).index
  2345. : this.productList[0].index, // 产品索引
  2346. batchNo: item.batchNo || this.productList[0].batchNo, // 批次号
  2347. packageNo:
  2348. item.packageNo ||
  2349. item.packingCode ||
  2350. packingCodeList[index]?.onlyCode, // 包装编码
  2351. packingQuantity: 1, // 包装数量
  2352. packingUnit:
  2353. item.packingUnit ||
  2354. newSpecificationOption[1]?.conversionUnit, // 单位
  2355. measureQuantity: item.quantity || item.measureQuantity, // 计量数量
  2356. measureUnit: item.measuringUnit || item.measureUnit, // 计量单位
  2357. supplierCode: item.supplierCode,
  2358. supplierId: item.supplierId,
  2359. supplierName: item.supplierName,
  2360. weight: item.packingWeight || 0, // 重量
  2361. singleWeight: item.singleWeight || 0,
  2362. pricingWay: item.pricingWay,
  2363. weightUnit: item.weightUnit || this.productList[0].weightUnit, // 重量单位
  2364. packingSpecificationOption: this.isMoreProduct
  2365. ? this.productList.find(
  2366. (val) => val.categoryCode == item.productCode
  2367. )?.packingSpecificationOption
  2368. : this.productList[0].packingSpecificationOption, // 包装规格
  2369. netWeight: item.netWeight || this.productList[0].netWeight, // 净重
  2370. barcodes: item.barcodes || item.sendCode, // 发货条码
  2371. clientCode: clientCode, // 客户代号
  2372. materielDesignation:
  2373. item.materielDesignation || item.extInfo?.materielCode, // 物料代号
  2374. engrave: item.engrave || item.extInfo?.engrave, // 刻码
  2375. reelSpecification:
  2376. item.reelSpecification || item.extInfo?.reelSpecification, // 盘具
  2377. isUnpack: item.isUnpack || this.productList[0].isUnpack, // 是否允许拆包
  2378. productionDate: productionDate, // 生产日期
  2379. purchaseDate: purchaseDate, // 采购时间
  2380. result: 1, // 结果(1合格 2不合格)
  2381. status: 2, // 状态(0=未质检 1待检 2已检)
  2382. serialNumber: item.productSequence // 产品序号
  2383. };
  2384. // }
  2385. });
  2386. console.log(this.packingList, '包装明细列表');
  2387. this.packingList.forEach((item) => {
  2388. this.packingWeightCahnge('', item);
  2389. });
  2390. });
  2391. }
  2392. },
  2393. //获取计量数量
  2394. getMeasureQuantity(code) {
  2395. let measureQuantity = 0;
  2396. this.detailList.forEach((item) => {
  2397. if (code == item.productCode) {
  2398. measureQuantity += item.quantity;
  2399. }
  2400. });
  2401. return measureQuantity;
  2402. },
  2403. //多产品明细获取批次号 ys
  2404. // getBatch(code) {
  2405. // let batch=''
  2406. // console.log(this.productList,'this.productList')
  2407. // this.productList.forEach((item) => {
  2408. // if (code == item.) {
  2409. // batch =item.batchNo
  2410. // }
  2411. // });
  2412. // return batch
  2413. // },
  2414. //多产品明细数据转换
  2415. async getDetailsVal(code, productBrand) {
  2416. const { data } = await storageApi.getAssetNum([
  2417. {
  2418. assetCode: code,
  2419. batchNum: 1,
  2420. num: 1
  2421. }
  2422. ]);
  2423. return data[0].onlyCode;
  2424. },
  2425. // 获取当前时间函数
  2426. getNowDate() {
  2427. let date = new Date(),
  2428. obj = {
  2429. year: date.getFullYear(), //获取当前月份(0-11,0代表1月)
  2430. month: date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
  2431. strDate: date.getDate(), // 获取当前日(1-31)
  2432. hour: date.getHours(), //获取当前小时(0 ~ 23)
  2433. minute: date.getMinutes(), //获取当前分钟(0 ~ 59)
  2434. second: date.getSeconds() //获取当前秒数(0 ~ 59)
  2435. };
  2436. Object.keys(obj).forEach((key) => {
  2437. if (obj[key] < 10) obj[key] = `0${obj[key]}`;
  2438. });
  2439. return obj;
  2440. },
  2441. //选择负责人
  2442. handHead(row, index) {
  2443. let item = {
  2444. id: row.unpackUserId
  2445. };
  2446. this.$refs.headRef.open(item, index);
  2447. },
  2448. //选择负责人回调
  2449. changeHead(obj, index) {
  2450. this.$set(this.productList[index], 'unpackUserId', obj.id);
  2451. this.$set(this.productList[index], 'unpackUserName', obj.name);
  2452. },
  2453. // 赋值入库时间
  2454. getNowFormatDate() {
  2455. const obj = this.getNowDate();
  2456. const defaultTime = '00:00:00';
  2457. const currentTime = `${obj.hour}:${obj.minute}:${obj.second}`;
  2458. if (
  2459. this.bizType === 2 ||
  2460. this.bizType === '2' ||
  2461. this.bizType === 6 ||
  2462. this.bizType === '6'
  2463. ) {
  2464. this.formData.storageTime = this.form.receiveDate
  2465. ? `${this.form.receiveDate} ${defaultTime}`
  2466. : `${obj.year}-${obj.month}-${obj.strDate} ${currentTime}`;
  2467. } else {
  2468. this.formData.storageTime = `${obj.year}-${obj.month}-${obj.strDate} ${currentTime}`;
  2469. }
  2470. },
  2471. // 获取物品列表
  2472. async getListItems() {
  2473. const { data } = await getTreeByGroup({ type: 2 });
  2474. this.goodsLists = data;
  2475. },
  2476. // 打开单据来源弹窗
  2477. openDocumentSourceDialog() {
  2478. console.log('打开单据来源弹窗');
  2479. },
  2480. // 清除单据来源
  2481. clearDocumentSource() {
  2482. this.formData.sourceBizNo = '';
  2483. },
  2484. // 添加产品
  2485. addProduct() {
  2486. if (this.formData.extInfo.assetType.length <= 0) {
  2487. return this.$message.error('请选择物品类型');
  2488. }
  2489. if (!this.formData.bizType) {
  2490. return this.$message.error('请选择入库类型');
  2491. }
  2492. this.visibleDialog = true;
  2493. },
  2494. // 键盘移动
  2495. moveFocus(event, index, key, type, row) {
  2496. let keyfield = [];
  2497. let listLength = 0;
  2498. switch (type) {
  2499. case '产品':
  2500. listLength = this.productList.length;
  2501. keyfield = ['batchNo', 'quantity', 'unitPrice', 'purpose'];
  2502. break;
  2503. case '包装':
  2504. listLength = this.showPackingList.length;
  2505. if (row.measureUnit != row.weightUnit) {
  2506. keyfield = [
  2507. 'packing_materielDesignation',
  2508. 'packing_clientCode',
  2509. 'packing_engrave',
  2510. 'packing_weight'
  2511. ];
  2512. } else {
  2513. keyfield = [
  2514. 'packing_materielDesignation',
  2515. 'packing_clientCode',
  2516. 'packing_engrave'
  2517. ];
  2518. }
  2519. break;
  2520. case '物料':
  2521. listLength = this.showMaterialList.length;
  2522. if (row.measureUnit != row.weightUnit) {
  2523. keyfield = [
  2524. 'material_materielDesignation',
  2525. 'material_clientCode',
  2526. 'material_engrave',
  2527. 'material_weight'
  2528. ];
  2529. } else {
  2530. keyfield = [
  2531. 'material_materielDesignation',
  2532. 'material_clientCode',
  2533. 'material_engrave'
  2534. ];
  2535. }
  2536. break;
  2537. }
  2538. if (event.keyCode === 13) {
  2539. // 回车
  2540. if (
  2541. index === listLength - 1 &&
  2542. key === keyfield[keyfield.length - 1]
  2543. ) {
  2544. // 最后一行最后一个
  2545. return;
  2546. }
  2547. this.$refs[key + index].blur();
  2548. if (key === keyfield[keyfield.length - 1]) {
  2549. // 当前行最后一个,跳转下一行第一个
  2550. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  2551. this.$refs[keyfield[0] + (index + 1)].value = '';
  2552. }
  2553. this.$refs[keyfield[0] + (index + 1)].focus();
  2554. } else {
  2555. // 跳转下一个
  2556. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  2557. this.$nextTick(() => {
  2558. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  2559. this.$refs[keyfield[nextkeyindex] + index].value = '';
  2560. }
  2561. this.$refs[keyfield[nextkeyindex] + index].focus();
  2562. });
  2563. }
  2564. }
  2565. // 向上 =38
  2566. if (event.keyCode === 38) {
  2567. if (index === 0) {
  2568. // 第一行
  2569. return;
  2570. }
  2571. this.$refs[key + index].blur();
  2572. this.$nextTick(() => {
  2573. if (this.$refs[key + (index - 1)].value == 0) {
  2574. this.$refs[key + (index - 1)].value = '';
  2575. }
  2576. this.$refs[key + (index - 1)].focus();
  2577. });
  2578. }
  2579. // 下 = 40
  2580. if (event.keyCode === 40) {
  2581. if (index === listLength - 1) {
  2582. // 最后一行
  2583. return;
  2584. }
  2585. this.$refs[key + index].blur();
  2586. this.$nextTick(() => {
  2587. if (this.$refs[key + (index + 1)].value == 0) {
  2588. this.$refs[key + (index + 1)].value = '';
  2589. }
  2590. this.$refs[key + (index + 1)].focus();
  2591. });
  2592. }
  2593. // 左 = 37
  2594. if (event.keyCode === 37) {
  2595. console.log('向左');
  2596. if (index === 0 && key === keyfield[0]) {
  2597. // 第一行第一个
  2598. console.log('第一行第一个无法向左');
  2599. return;
  2600. }
  2601. this.$refs[key + index].blur();
  2602. if (key === keyfield[0]) {
  2603. if (
  2604. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value == 0
  2605. ) {
  2606. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value =
  2607. '';
  2608. }
  2609. // 当前行第一个,跳转上一行最后一个
  2610. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].focus();
  2611. } else {
  2612. // 跳转上一个
  2613. const prevkeyindex = keyfield.findIndex((k) => k === key) - 1;
  2614. this.$nextTick(() => {
  2615. if (this.$refs[keyfield[prevkeyindex] + index].value == 0) {
  2616. this.$refs[keyfield[prevkeyindex] + index].value = '';
  2617. }
  2618. this.$refs[keyfield[prevkeyindex] + index].focus();
  2619. });
  2620. }
  2621. }
  2622. // 右 = 39
  2623. if (event.keyCode === 39) {
  2624. if (
  2625. index === listLength - 1 &&
  2626. key === keyfield[keyfield.length - 1]
  2627. ) {
  2628. // 最后一行最后一个
  2629. return;
  2630. }
  2631. this.$refs[key + index].blur();
  2632. if (key === keyfield[keyfield.length - 1]) {
  2633. // 当前行最后一个,跳转下一行第一个
  2634. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  2635. this.$refs[keyfield[0] + (index + 1)].value = '';
  2636. }
  2637. this.$refs[keyfield[0] + (index + 1)].focus();
  2638. } else {
  2639. // 跳转下一个
  2640. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  2641. this.$nextTick(() => {
  2642. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  2643. this.$refs[keyfield[nextkeyindex] + index].value = '';
  2644. }
  2645. this.$refs[keyfield[nextkeyindex] + index].focus();
  2646. });
  2647. }
  2648. }
  2649. },
  2650. // 入库
  2651. async getReturnStorage() {
  2652. if (this.productList.length <= 0) {
  2653. this.$message.error('请先添加产品信息');
  2654. return;
  2655. }
  2656. let boolen = this.productList.every((item) => item.isSave);
  2657. if (!boolen) {
  2658. this.$message.error('请先保存所有产品信息');
  2659. return;
  2660. }
  2661. if (this.isShowPackage) {
  2662. const userNameLength = this.productList.filter(
  2663. (item) => !item.unpackUserName
  2664. ).length;
  2665. const packgeLength = this.productList.filter(
  2666. (item) => !item.ifPackageOk
  2667. ).length;
  2668. if (userNameLength || packgeLength) {
  2669. this.$message.error('请先填写拆包装责任人和包装完好与否');
  2670. return;
  2671. }
  2672. }
  2673. // 处理包装数据
  2674. let _packingList = [];
  2675. _packingList = this.packingList.map((packingItem) => {
  2676. let _taskId = null;
  2677. let _workOrderId = null;
  2678. if ([1].includes(this.bizType)) {
  2679. _workOrderId = this.detailList[0]?.workOrderId;
  2680. _taskId = this.detailList[0]?.taskId;
  2681. } else {
  2682. _workOrderId = this.detailProductList[0]?.workOrderId;
  2683. _taskId = this.detailProductList[0]?.taskId;
  2684. }
  2685. if (packingItem.modelKey) {
  2686. packingItem.modelKey = packingItem.modelKey;
  2687. }
  2688. if (packingItem.colorKey) {
  2689. packingItem.colorKey = packingItem.colorKey;
  2690. }
  2691. return {
  2692. ...packingItem,
  2693. workOrderId: _workOrderId,
  2694. taskId: _taskId,
  2695. outsourceBatchNo: this.detailProductList[0]?.batchNo,
  2696. outsourceCode: this.detailProductList[0]?.sourceCode,
  2697. materialDetailList: this.materialList.filter(
  2698. (item) => item.parentIndex === packingItem.index
  2699. )
  2700. };
  2701. });
  2702. // 处理产品数据
  2703. this.productList = this.productList.map((productItem) => {
  2704. if (productItem.modelKey) {
  2705. productItem.modelKey = productItem.modelKey;
  2706. }
  2707. if (productItem.colorKey) {
  2708. productItem.colorKey = productItem.colorKey;
  2709. }
  2710. return {
  2711. ...productItem,
  2712. outInDetailRecordRequestList: _packingList.filter(
  2713. (item) => item.parentIndex === productItem.index
  2714. )
  2715. };
  2716. });
  2717. this.formData.outInDetailList = this.productList;
  2718. let obj = deepClone(this.formData);
  2719. // 处理物品类型assetType
  2720. obj.extInfo.assetType = obj.extInfo.assetType.join(',');
  2721. obj.extInfo.documentSource = this.formData.sourceBizNo;
  2722. obj.extInfo.deptName = this.formData.extInfo.deptName;
  2723. obj.extInfo.supplierName = this.form.supplierName;
  2724. obj.extInfo.deliveryPhone = this.formData.extInfo.deliveryPhone;
  2725. // 处理仓库id
  2726. let warehouseId = [];
  2727. let warehouseName = [];
  2728. let warehouseIds = this.productList
  2729. .map((item) => item.warehouseIds)
  2730. .flat();
  2731. let warehouseNames = this.productList
  2732. .map((item) => item.warehouseNames)
  2733. .flat();
  2734. warehouseIds.forEach((item, index) => {
  2735. if (!warehouseId.includes(item)) {
  2736. warehouseId.push(item);
  2737. warehouseName.push(warehouseNames[index]);
  2738. }
  2739. });
  2740. obj.warehouseIds = warehouseId;
  2741. obj.warehouseNames = warehouseName;
  2742. obj._packingList = _packingList;
  2743. // setTimeout(() => {
  2744. // resolve(obj);
  2745. // }, 1000);
  2746. // if (productData.length) {
  2747. // this.$alert(
  2748. // `物料${productData.join(',')}没有维护供应商,${
  2749. // productData.length > 1 ? '会合并下发为一个采购订单,' : ''
  2750. // }是否继续下发!`,
  2751. // {
  2752. // confirmButtonText: '确定',
  2753. // callback: (action) => {
  2754. // if (action == 'confirm') {
  2755. // this.issuePurchaseOrderFn();
  2756. // }
  2757. // }
  2758. // }
  2759. // );
  2760. // } else {
  2761. // this.issuePurchaseOrderFn();
  2762. // }
  2763. const isVerifyData = await storageApi.isVerifyRepeatIsStock({
  2764. categoryCodes: this.productList.map((item) => item.categoryCode),
  2765. batchNos: this.productList.map((item) => item.batchNo)
  2766. });
  2767. return new Promise((resolve, reject) => {
  2768. if (isVerifyData?.length) {
  2769. this.$confirm(
  2770. `当前批次:${isVerifyData[0].batchNo},物品${isVerifyData
  2771. .map((item) => item.categoryName)
  2772. .join(',')}已有入库记录,是否继续入库!`,
  2773. {
  2774. confirmButtonText: '是',
  2775. cancelButtonText: '否'
  2776. }
  2777. )
  2778. .then(() => {
  2779. resolve(obj);
  2780. })
  2781. .catch(() => {
  2782. resolve(false);
  2783. });
  2784. } else {
  2785. resolve(obj);
  2786. }
  2787. });
  2788. },
  2789. pickingHandleScroll() {
  2790. if (this.showPackingList.length < this.packingList.length) {
  2791. if (this.packingList.length > this.pageSize) {
  2792. this.pickingPageNum += 1;
  2793. }
  2794. this.pickingFetchData();
  2795. }
  2796. },
  2797. pickingFetchData() {
  2798. const start = (this.pickingPageNum - 1) * this.pageSize;
  2799. const end = start + this.pageSize;
  2800. this.showPackingList = this.showPackingList.concat(
  2801. this.packingList.slice(start, end)
  2802. );
  2803. },
  2804. materielHandleScroll() {
  2805. if (this.showMaterialList.length < this.materialList.length) {
  2806. if (this.materialList.length > this.pageSize) {
  2807. this.materielPageNum += 1;
  2808. }
  2809. this.materielFetchData();
  2810. }
  2811. },
  2812. materielFetchData() {
  2813. const start = (this.materielPageNum - 1) * this.pageSize;
  2814. const end = start + this.pageSize;
  2815. this.showMaterialList = this.showMaterialList.concat(
  2816. this.materialList.slice(start, end)
  2817. );
  2818. },
  2819. // 日期选择
  2820. dateConfirm() {
  2821. this.packingListSelected.forEach((item) => {
  2822. this.$set(item, this.curDateType, this.batchTime);
  2823. });
  2824. this.batchTime = '';
  2825. this.dateVisible = false;
  2826. },
  2827. // 包装重量修改
  2828. packingWeightCahnge(value, row) {
  2829. // 修改物品重量
  2830. let filterPackingList = this.packingList.filter((item) => {
  2831. return item.parentIndex === row.parentIndex;
  2832. });
  2833. let productIndex = this.productList.findIndex((item) => {
  2834. return item.index === row.parentIndex;
  2835. });
  2836. let totalWeight = filterPackingList.reduce(
  2837. (accumulator, currentValue) => {
  2838. return this.$math.format(+accumulator + +currentValue.weight, 14);
  2839. },
  2840. 0
  2841. );
  2842. if (totalWeight != 'NaN') {
  2843. this.$set(this.productList[productIndex], 'weight', totalWeight);
  2844. } else {
  2845. this.$set(this.productList[productIndex], 'weight', 0);
  2846. }
  2847. this.$set(
  2848. this.productList[productIndex],
  2849. 'singleWeight',
  2850. totalWeight / this.productList[productIndex].measureQuantity || 0
  2851. );
  2852. // 修改拆分物料
  2853. // this.materialList.map((item, index) => {
  2854. // if (item.parentIndex === row.index) {
  2855. // this.$set(
  2856. // this.materialList[index],
  2857. // 'weight',
  2858. // this.$math.format(value / row.measureQuantity, 14) >= 0
  2859. // ? this.$math.format(value / row.measureQuantity, 14)
  2860. // : 0
  2861. // );
  2862. // }
  2863. // });
  2864. },
  2865. // 物料重量修改
  2866. materialWeightCahnge(row) {
  2867. // 修改包装重量
  2868. let filterMaterialList = this.materialList.filter((item) => {
  2869. return item.parentIndex === row.parentIndex;
  2870. });
  2871. let packingIndex = this.packingList.findIndex((item) => {
  2872. return item.index === row.parentIndex;
  2873. });
  2874. let totalMaterialWeight = filterMaterialList.reduce(
  2875. (accumulator, currentValue) => {
  2876. return this.$math.format(+accumulator + +currentValue.weight, 14);
  2877. },
  2878. 0
  2879. );
  2880. this.$set(
  2881. this.packingList[packingIndex],
  2882. 'weight',
  2883. totalMaterialWeight
  2884. );
  2885. // 修改物品重量
  2886. let filterPackingList = this.packingList.filter((item) => {
  2887. return (
  2888. item.parentIndex === this.packingList[packingIndex].parentIndex
  2889. );
  2890. });
  2891. let productIndex = this.productList.findIndex((item) => {
  2892. return item.index === this.packingList[packingIndex].parentIndex;
  2893. });
  2894. let totalWeight = filterPackingList.reduce(
  2895. (accumulator, currentValue) => {
  2896. return this.$math.format(+accumulator + +currentValue.weight, 14);
  2897. },
  2898. 0
  2899. );
  2900. this.$set(this.productList[productIndex], 'weight', totalWeight);
  2901. },
  2902. // 包装质检结果修改
  2903. packingResultCahnge(value, row) {
  2904. // 修改物料质检结果(0无 1合格 2不合格 3让步接收)
  2905. this.materialList.map((item, index) => {
  2906. if (item.parentIndex === row.index) {
  2907. this.$set(this.materialList[index], 'result', value);
  2908. this.$set(this.materialList[index], 'status', 2);
  2909. }
  2910. });
  2911. },
  2912. // 物料质量结果修改
  2913. materialResultCahnge(value, row) {
  2914. // 修改包装质检结果
  2915. let filterMaterialList = this.materialList.filter((item) => {
  2916. return item.parentIndex == row.parentIndex;
  2917. });
  2918. let packingIndex = this.packingList.findIndex((item) => {
  2919. return item.index == row.parentIndex;
  2920. });
  2921. let boolen = filterMaterialList.every((item) => {
  2922. return item.result == 1;
  2923. });
  2924. this.$set(this.packingList[packingIndex], 'result', boolen ? 1 : 2);
  2925. this.$set(this.packingList[packingIndex], 'status', 2);
  2926. },
  2927. // 重量限制
  2928. weightInput(value, row, type) {
  2929. const newValue = value.replace(/[^\d.]/g, ''); // 保留数字和小数点
  2930. const decimalCount = (newValue.match(/\./g) || []).length; // 计算小数点的个数
  2931. if (row.weight < 0) {
  2932. row.weight = 0;
  2933. } else if (row.weight > 9999) {
  2934. row.weight = 9999;
  2935. } else {
  2936. if (decimalCount > 1) {
  2937. // 如果小数点个数大于1,移除多余的小数点
  2938. const lastIndex = newValue.lastIndexOf('.');
  2939. row.weight =
  2940. newValue.slice(0, lastIndex) + newValue.slice(lastIndex + 1);
  2941. } else if (decimalCount === 1) {
  2942. // 如果小数点个数等于1,允许小数点的输入
  2943. row.weight = newValue;
  2944. } else {
  2945. row.weight = newValue === '' ? 0 : parseFloat(newValue); // 如果输入为空,则设为0
  2946. }
  2947. }
  2948. if (type === '包装') {
  2949. this.packingWeightCahnge(value, row);
  2950. } else {
  2951. this.materialWeightCahnge(row);
  2952. }
  2953. },
  2954. //计算金额
  2955. calcSumTotal(measureQuantity, unitPrice, row) {
  2956. //最小包装单元,包装数量,单价
  2957. if (this.bizType != 2) {
  2958. const total = {
  2959. measureQuantity: Number(measureQuantity > 0 ? measureQuantity : 0),
  2960. unitPrice: Number(unitPrice > 0 ? unitPrice : 0)
  2961. };
  2962. let number = Number(
  2963. this.$math.format(total.measureQuantity * total.unitPrice, 14)
  2964. );
  2965. row.totalMoney = number;
  2966. return number;
  2967. } else {
  2968. return row.totalMoney;
  2969. }
  2970. },
  2971. // 包装维度最小包装单元改变——>总重量
  2972. minPackingQuantityChange(row, value, index) {
  2973. if (row.measureUnit !== 'KG') {
  2974. if (value.replace(/^(0+)|[^\d]+/g, '') > 9999) {
  2975. this.$set(this.productList[index], 'minPackingQuantity', 9999);
  2976. } else {
  2977. this.$set(
  2978. this.productList[index],
  2979. 'minPackingQuantity',
  2980. value.replace(/^(0+)|[^\d]+/g, '')
  2981. );
  2982. }
  2983. } else {
  2984. if (value < 1) {
  2985. this.$set(this.productList[index], 'minPackingQuantity', 1);
  2986. } else if (value > 9999) {
  2987. this.$set(this.productList[index], 'minPackingQuantity', 9999);
  2988. }
  2989. }
  2990. if (row.packingQuantity >= 0 && value >= 0) {
  2991. this.packNum(row, row.packingQuantity, index);
  2992. }
  2993. },
  2994. // 包装数量过滤处理改变——>总重量
  2995. packNum(row, value, index) {
  2996. const total = {
  2997. minPackingQuantity: Number(
  2998. row.minPackingQuantity > 0
  2999. ? row.minPackingQuantity > 9999
  3000. ? 9999
  3001. : row.minPackingQuantity
  3002. : 0
  3003. ),
  3004. packingQuantity: Number(
  3005. row.packingQuantity > 0
  3006. ? row.packingQuantity > 9999
  3007. ? 9999
  3008. : row.packingQuantity
  3009. : 0
  3010. )
  3011. };
  3012. const totals = Number(
  3013. this.$math.format(
  3014. total.minPackingQuantity * total.packingQuantity,
  3015. 14
  3016. )
  3017. );
  3018. if (row.measureUnit == row.weightUnit) {
  3019. row.weight = Number(
  3020. this.$math.format(
  3021. total.minPackingQuantity *
  3022. 1 *
  3023. Number(total.packingQuantity).toFixed(2),
  3024. 14
  3025. )
  3026. );
  3027. } else {
  3028. row.weight = Number(
  3029. this.$math.format(
  3030. totals *
  3031. (row.netWeight > 0 ? Number(row.netWeight).toFixed(2) : 0),
  3032. 14
  3033. )
  3034. );
  3035. }
  3036. this.$set(this.productList[index], 'measureQuantity', totals);
  3037. // 清空仓库
  3038. this.$set(this.productList[index], 'warehouseId', '');
  3039. this.$set(this.productList[index], 'warehouseName', '');
  3040. if (value.replace(/^(0+)|[^\d]+/g, '') > 9999) {
  3041. this.$set(this.productList[index], 'packingQuantity', 9999);
  3042. } else {
  3043. this.$set(
  3044. this.productList[index],
  3045. 'packingQuantity',
  3046. value.replace(/^(0+)|[^\d]+/g, '')
  3047. );
  3048. }
  3049. // return (row.packingQuantity = value.replace(/^(0+)|[^\d]+/g, ''));
  3050. },
  3051. // 表格样式
  3052. rowClass({ row, column, rowIndex, columnIndex }) {
  3053. if (rowIndex === 1) {
  3054. return {
  3055. display: 'none',
  3056. background: '#EEEEEE'
  3057. };
  3058. }
  3059. return { background: '#0000' };
  3060. },
  3061. //过滤掉单位下拉框 相同的单位
  3062. getNewSpecificationOption(packingSpecificationOption) {
  3063. return packingSpecificationOption;
  3064. return packingSpecificationOption.map((arr) => {
  3065. return arr.reduce((acc, current) => {
  3066. const conversionUnit = current.conversionUnit;
  3067. if (!acc.some((item) => item.conversionUnit === conversionUnit)) {
  3068. acc.push(current);
  3069. }
  3070. return acc;
  3071. }, []);
  3072. });
  3073. },
  3074. // 添加物品明细
  3075. async addGoods(data) {
  3076. // 获取批次号
  3077. const batchNo = await getCode('lot_number_code');
  3078. // 获取供应商
  3079. const supplierList = await storageApi.contactQueryByCategoryIdsAPI({
  3080. categoryIds: data.map((item) => item.id)
  3081. });
  3082. // 获取包装规格
  3083. let packingSpecification =
  3084. await storageApi.getCategoryPackageDisposition({
  3085. categoryIds: data.map((item) => item.id)
  3086. });
  3087. this.packingSpecificationOption = data.map((item) => {
  3088. return packingSpecification
  3089. .filter((ite) => item.id == ite.categoryId)
  3090. .sort((a, b) => a.sort - b.sort);
  3091. });
  3092. const newSpecificationOption = this.getNewSpecificationOption(
  3093. this.packingSpecificationOption
  3094. );
  3095. let productList = data.map((item, index) => {
  3096. // 显示规格
  3097. let packingSpecificationLabel = this.packingSpecificationOption[index]
  3098. .map((item) => {
  3099. if (item.sort > 0) {
  3100. return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
  3101. }
  3102. })
  3103. .filter((item) => !!item);
  3104. return {
  3105. index:
  3106. this.productList.length - 1 > -1
  3107. ? this.productList[this.productList.length - 1].index +
  3108. index +
  3109. 1
  3110. : this.productList.length + index,
  3111. categoryId: item.id, // 物品id
  3112. categoryName: item.name, // 物品名称
  3113. categoryCode: item.code, // 物品编码
  3114. categoryModel: item.modelType, // 物品型号
  3115. specification: item.specification, // 规格
  3116. modelKey: item.modelKey ? item.modelKey?.split(',')?.[0] || '' : '', // 机型
  3117. colorKey: item.colorKey ? item.colorKey?.split(',')?.[0] || '' : '', // 颜色
  3118. brandNum: item.brandNum, // 牌号
  3119. batchNo: batchNo, // 批次号
  3120. supplierListOptions: supplierList[item.id], // 供应商列表
  3121. supplierId: '', // 供应商id
  3122. supplierCode: item.supplierCode, // 供应商代号
  3123. supplierName: item.supplierName, // 供应商名称
  3124. measureType: item.measureType, // 计量类型
  3125. approvalNumber: item.approvalNumber, // 批准文号
  3126. packingSpecification: item.packingSpecification, // 包装规格
  3127. packingSpecificationOption: newSpecificationOption[index], // 包装规格选项
  3128. packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
  3129. minPackingQuantity: '', // 最小包装单元数量
  3130. packingQuantity: '', // 包装数量
  3131. packingUnit: item.packingUnit, // 包装数量
  3132. unit: item.measuringUnit, // 单位
  3133. unitId: newSpecificationOption[index].find(
  3134. (v) => v.conversionUnit == item.measuringUnit
  3135. )?.id, // 单位
  3136. measureQuantity: 0, // 计量数量
  3137. measureUnit: item.measuringUnit, // 计量单位
  3138. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  3139. weight: 0, // 重量
  3140. singleWeight: item.measuringUnit != 'KG' ? item.netWeight : 0, // 单重
  3141. pricingWay: item.pricingWay,
  3142. weightUnit: item.weightUnit, // 重量单位
  3143. totalMoney: item.totalPrice, // 总价
  3144. unitPrice: item.unitPrice, // 单价
  3145. purpose: '', // 用途
  3146. isUnpack: item.isUnpack // 是否允许拆包
  3147. };
  3148. });
  3149. this.productList = this.productList.concat(productList);
  3150. },
  3151. // 物品保存验证表单(批量)
  3152. validateForm() {
  3153. return new Promise(async (resolve, reject) => {
  3154. let list = this.productList.map(async (row, index) => {
  3155. let fileds = [
  3156. `productList.${index}.batchNo`,
  3157. `productList.${index}.quantity`,
  3158. `productList.${index}.unit`,
  3159. `productList.${index}.warehouseId`
  3160. ];
  3161. if (row.isSave) {
  3162. return Promise.resolve(true);
  3163. } else {
  3164. return await Promise.all(
  3165. fileds.map(
  3166. (item) =>
  3167. new Promise(async (res, rej) => {
  3168. this.$refs.productListRef.validateField(item, (err) => {
  3169. if (err) {
  3170. rej(err);
  3171. } else {
  3172. res(true);
  3173. }
  3174. });
  3175. })
  3176. )
  3177. );
  3178. }
  3179. });
  3180. Promise.all(list)
  3181. .then(() => {
  3182. console.log('保存成功!');
  3183. resolve();
  3184. })
  3185. .catch((err) => {
  3186. console.log('保存失败!');
  3187. this.$message.error('请填入必填项!');
  3188. reject(err);
  3189. });
  3190. });
  3191. },
  3192. // 产品批量保存
  3193. async listSaveArrs() {
  3194. this.validateForm()
  3195. .then(async () => {
  3196. // 批量获取包装编码并处理
  3197. let packingCodePrams = this.productList.map((row) => {
  3198. // 判断单位和计量单位是否为不拆物料层规格
  3199. let packingBoolen = !!this.getDict(
  3200. '不拆物料层规格',
  3201. row.packingUnit
  3202. ).dictValue;
  3203. let measureBoolen = !!this.getDict(
  3204. '不拆物料层规格',
  3205. row.measureUnit
  3206. ).dictValue;
  3207. let num = 0;
  3208. if (packingBoolen) {
  3209. let filterArr = row.packingSpecificationOption.filter(
  3210. (item) => {
  3211. return (
  3212. item.packageUnit == row.packingUnit &&
  3213. item.packageUnit != item.conversionUnit
  3214. );
  3215. }
  3216. );
  3217. num = Math.ceil(row.packingQuantity / filterArr[0].packageCell);
  3218. }
  3219. if (row.isSave) {
  3220. return {};
  3221. } else {
  3222. // 处理单位为KG类的情况
  3223. if (packingBoolen) {
  3224. return {
  3225. assetCode: row.categoryCode + row.index,
  3226. batchNum: row.batchNo,
  3227. num
  3228. };
  3229. } else {
  3230. if (row.isUnpack == 1) {
  3231. if (measureBoolen) {
  3232. // 处理单位不为KG类,计量单位为KG类的情况
  3233. let num = row.packingQuantity;
  3234. let splitIndex = row.packingSpecificationOption.findIndex(
  3235. (item) =>
  3236. item.conversionUnit == row.packingUnit &&
  3237. item.packageUnit != item.conversionUnit
  3238. );
  3239. for (; splitIndex > 1; splitIndex--) {
  3240. num = this.$math.format(
  3241. num *
  3242. row.packingSpecificationOption[splitIndex]
  3243. .packageCell,
  3244. 14
  3245. );
  3246. }
  3247. return {
  3248. assetCode: row.categoryCode + row.index,
  3249. batchNum: row.batchNo,
  3250. num
  3251. };
  3252. } else {
  3253. // 处理拆包到最小包装单元数量的情况
  3254. return {
  3255. assetCode: row.categoryCode + row.index,
  3256. batchNum: row.batchNo,
  3257. num: row.measureQuantity
  3258. };
  3259. }
  3260. } else {
  3261. return {
  3262. assetCode: row.categoryCode + row.index,
  3263. batchNum: row.batchNo,
  3264. num
  3265. };
  3266. }
  3267. }
  3268. }
  3269. });
  3270. console.log('packingCodePrams', packingCodePrams);
  3271. let filterPackingCodePrams = packingCodePrams.filter(
  3272. (item) => item.assetCode
  3273. );
  3274. console.log('filterPackingCodePrams', filterPackingCodePrams);
  3275. let { data } = await storageApi.getAssetNum(filterPackingCodePrams);
  3276. let packingCodeList = [];
  3277. packingCodePrams.forEach((item, index) => {
  3278. packingCodeList[index] = data.filter(
  3279. (ite) => ite.assetCode == item.assetCode
  3280. );
  3281. });
  3282. // 批量生成包装
  3283. this.productList.map((row, index) => {
  3284. if (!row.isSave) {
  3285. this.generateWrappers(row, index, packingCodeList[index]);
  3286. this.$set(this.productList[index], 'isSave', true);
  3287. }
  3288. });
  3289. // 加载虚拟列表数据(分页)
  3290. // this.pickingFetchData();
  3291. // this.materielFetchData();
  3292. })
  3293. .catch((err) => {
  3294. console.log(err);
  3295. });
  3296. },
  3297. // 物品保存验证表单(单独)
  3298. validateFormIndividually(index) {
  3299. return new Promise(async (resolve) => {
  3300. let fileds = [
  3301. `productList.${index}.batchNo`,
  3302. `productList.${index}.quantity`,
  3303. `productList.${index}.unit`,
  3304. `productList.${index}.warehouseId`
  3305. ];
  3306. Promise.all(
  3307. fileds.map(
  3308. (item) =>
  3309. new Promise(async (res, rej) => {
  3310. this.$refs.productListRef.validateField(item, (err) => {
  3311. if (err) {
  3312. rej(err);
  3313. } else {
  3314. res(true);
  3315. }
  3316. });
  3317. })
  3318. )
  3319. )
  3320. .then(() => {
  3321. resolve();
  3322. })
  3323. .catch(() => {
  3324. this.$message.error('请填入必填项!');
  3325. });
  3326. });
  3327. },
  3328. // 产品编辑
  3329. listEdit(row) {
  3330. this.$set(row, 'isSave', false);
  3331. // // 重新计算重量
  3332. // const totals = Number(
  3333. // this.$math.format(row.minPackingQuantity * row.packingQuantity, 14)
  3334. // );
  3335. // if (row.measureUnit == row.weightUnit) {
  3336. // row.weight = Number(
  3337. // this.$math.format(
  3338. // row.minPackingQuantity *
  3339. // 1 *
  3340. // Number(row.packingQuantity).toFixed(2),
  3341. // 14
  3342. // )
  3343. // );
  3344. // } else {
  3345. // row.weight = Number(
  3346. // this.$math.format(
  3347. // totals *
  3348. // (row.netWeight > 0 ? Number(row.netWeight).toFixed(2) : 0),
  3349. // 14
  3350. // )
  3351. // );
  3352. // }
  3353. this.deletePackingAndMaterial(row);
  3354. },
  3355. // 根据产品信息删除包装和物料
  3356. deletePackingAndMaterial(row) {
  3357. // 删除包装(去掉不相同的包装)
  3358. this.packingList = this.packingList.filter(
  3359. (item) => item.parentIndex !== row.index
  3360. );
  3361. this.showPackingList = this.showPackingList.filter(
  3362. (item) => item.parentIndex !== row.index
  3363. );
  3364. this.pickingPageNum = Math.ceil(
  3365. this.showPackingList.length / this.pageSize
  3366. );
  3367. // 删除物料(获取相同物料)
  3368. let packingIndexs = this.packingList.map((item) => item.index);
  3369. this.materialList = this.materialList.filter((item) =>
  3370. packingIndexs.includes(item.parentIndex)
  3371. );
  3372. this.showMaterialList = this.showMaterialList.filter((item) =>
  3373. packingIndexs.includes(item.parentIndex)
  3374. );
  3375. this.materielPageNum = Math.ceil(
  3376. this.showMaterialList.length / this.pageSize
  3377. );
  3378. },
  3379. async batchSave() {
  3380. try {
  3381. // 验证所有未保存的表单
  3382. await this.validateForm();
  3383. // 遍历所有产品进行保存
  3384. for (let i = 0; i < this.productList.length; i++) {
  3385. const row = this.productList[i];
  3386. if (!row.isSave) {
  3387. // 执行单个保存逻辑
  3388. await this.listSave(row, i);
  3389. }
  3390. }
  3391. } catch (error) {
  3392. // this.$message.error('批量保存失败,请检查必填项');
  3393. }
  3394. },
  3395. listSave(row, index) {
  3396. console.log('row22222222', row);
  3397. this.validateFormIndividually(index).then(async () => {
  3398. // 判断单位和计量单位是否为不拆物料层规格
  3399. let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
  3400. .dictValue;
  3401. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
  3402. .dictValue;
  3403. console.log('packingBoolen---------', packingBoolen);
  3404. console.log('measureBoolen---------', measureBoolen);
  3405. let packingNum = 0;
  3406. // 处理单位为KG类的情况
  3407. if (packingBoolen) {
  3408. if (!row.isUnpack && row.unit == '立方') {
  3409. packingNum = 1;
  3410. } else {
  3411. let filterArr = row.packingSpecificationOption.filter((item) => {
  3412. return (
  3413. item.packageUnit == row.unit &&
  3414. item.packageUnit != item.conversionUnit
  3415. );
  3416. });
  3417. if (filterArr?.length) {
  3418. packingNum = Math.ceil(row.quantity / filterArr[0].packageCell);
  3419. }
  3420. }
  3421. }
  3422. // 处理单位不为KG类,计量单位为KG类的情况
  3423. let measureNum = row.quantity;
  3424. let num = 0;
  3425. if (measureBoolen) {
  3426. let splitIndex = row.packingSpecificationOption.findIndex(
  3427. (item) =>
  3428. item.conversionUnit == row.packingUnit &&
  3429. item.packageUnit != item.conversionUnit
  3430. );
  3431. for (; splitIndex > 1; splitIndex--) {
  3432. measureNum = this.$math.format(
  3433. measureNum *
  3434. row.packingSpecificationOption[splitIndex].packageCell,
  3435. 14
  3436. );
  3437. }
  3438. } else {
  3439. if (row.packingSpecificationOption[1]?.packageCell) {
  3440. num = Math.ceil(
  3441. row.measureQuantity /
  3442. row.packingSpecificationOption[1]?.packageCell
  3443. );
  3444. } else {
  3445. num = row.quantity;
  3446. }
  3447. }
  3448. console.log(packingNum, measureNum, num, '加油加油加油');
  3449. // return
  3450. if (row.packingSpecificationLabel?.length < 1) {
  3451. this.$message.error('请到主数据维护包装组信息!');
  3452. return;
  3453. }
  3454. // 不拆包
  3455. if (!row.isUnpack) {
  3456. if (row.unit != row.measureUnit) {
  3457. let pNum = row.quantity;
  3458. const { data } = await storageApi.getAssetNum([
  3459. {
  3460. assetCode: row.categoryCode + row.index,
  3461. batchNum: row.batchNo,
  3462. num: pNum
  3463. }
  3464. ]);
  3465. // this.generateWrappers(row, index, data)
  3466. } else {
  3467. let pNum = 0;
  3468. const { data } = await storageApi.getAssetNum([
  3469. {
  3470. assetCode: row.categoryCode + row.index,
  3471. batchNum: row.batchNo,
  3472. num: pNum
  3473. }
  3474. ]);
  3475. }
  3476. } else {
  3477. if (!packingNum) {
  3478. if (row.unitId) {
  3479. let splitIndex = row.packingSpecificationOption.findIndex(
  3480. (item) => item.id == row.unitId
  3481. );
  3482. if (splitIndex == 0) {
  3483. packingNum = Math.ceil(
  3484. row.measureQuantity /
  3485. row.packingSpecificationOption[1]?.packageCell
  3486. );
  3487. }
  3488. if (splitIndex == 1) {
  3489. packingNum = row.quantity;
  3490. }
  3491. for (; splitIndex > 1; splitIndex--) {
  3492. packingNum = Math.ceil(
  3493. row.quantity *
  3494. row.packingSpecificationOption[splitIndex].packageCell
  3495. );
  3496. }
  3497. } else {
  3498. packingNum = Math.ceil(
  3499. row.measureQuantity /
  3500. row.packingSpecificationOption[1]?.packageCell
  3501. );
  3502. }
  3503. }
  3504. console.log(packingNum, 'packingNum');
  3505. //拆包
  3506. console.log('拆包拆包拆包', row.batchNo);
  3507. const { data } = await storageApi.getAssetNum([
  3508. {
  3509. assetCode: row.categoryCode + row.index,
  3510. batchNum: row.batchNo,
  3511. num: packingNum
  3512. }
  3513. ]);
  3514. this.generateWrappers(row, index, data);
  3515. this.$set(this.productList[index], 'packingQuantity', data.length);
  3516. }
  3517. this.$set(this.productList[index], 'isSave', true);
  3518. this.$set(this.productList[index], 'warehouseId', row.warehouseId);
  3519. this.$set(
  3520. this.productList[index],
  3521. 'warehouseName',
  3522. row.warehouseName
  3523. );
  3524. this.$set(this.productList[index], 'warehouseIds', row.warehouseId);
  3525. this.$set(
  3526. this.productList[index],
  3527. 'warehouseNames',
  3528. row.warehouseName
  3529. );
  3530. });
  3531. },
  3532. //入库明细删除
  3533. listDel(row, index) {
  3534. this.productList.splice(index, 1);
  3535. this.deletePackingAndMaterial(row);
  3536. },
  3537. // 打开仓库弹框
  3538. handleWareHouse(row, idx, type) {
  3539. console.log(row, '踩踩踩踩踩踩踩踩踩踩踩', this.form);
  3540. if (row.packingSpecificationLabel?.length < 1) {
  3541. this.$message.error('请到主数据维护包装组信息!');
  3542. return;
  3543. }
  3544. if (row.isSave) {
  3545. return false;
  3546. }
  3547. let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
  3548. .dictValue;
  3549. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
  3550. .dictValue;
  3551. console.log(packingBoolen, 'packingBoolen');
  3552. console.log(measureBoolen, 'measureBoolen');
  3553. //行内选择仓库
  3554. if (idx > -1 && type != 'batch') {
  3555. if (row.quantity > 0) {
  3556. //不拆
  3557. if (!row.isUnpack) {
  3558. //计量和包装单位相同
  3559. if (row.measureUnit == row.unit) {
  3560. let pNum = 0;
  3561. let mNum = row.measureQuantity;
  3562. this.$refs.wareHouseDailogRef.open(
  3563. pNum,
  3564. mNum,
  3565. idx,
  3566. row.warehouseId,
  3567. row.warehouseName + ''
  3568. // this.form.categoryLevelTopId
  3569. );
  3570. } else {
  3571. let pNum = row.quantity;
  3572. let mNum = row.measureQuantity;
  3573. this.$refs.wareHouseDailogRef.open(
  3574. pNum,
  3575. mNum,
  3576. idx,
  3577. row.warehouseId,
  3578. row.warehouseName + ''
  3579. // this.form.categoryLevelTopId
  3580. );
  3581. }
  3582. } else {
  3583. let num = Math.ceil(
  3584. row.measureQuantity /
  3585. row.packingSpecificationOption[1]?.packageCell
  3586. );
  3587. this.$refs.wareHouseDailogRef.open(
  3588. num,
  3589. row.measureQuantity,
  3590. idx,
  3591. row.warehouseId,
  3592. row.warehouseName + ''
  3593. );
  3594. // if (packingBoolen) {
  3595. // console.log(
  3596. // packingBoolen,
  3597. // 'packingBoolen',
  3598. // row.packageUnit,
  3599. // row.isUnpack
  3600. // );
  3601. // let filterArr = row.packingSpecificationOption.filter(
  3602. // (item) => {
  3603. // return (
  3604. // item.packageUnit == row.unit &&
  3605. // item.packageUnit != item.conversionUnit
  3606. // );
  3607. // }
  3608. // );
  3609. // let num = Math.ceil(row.quantity / filterArr[0].packageCell);
  3610. // this.$refs.wareHouseDailogRef.open(
  3611. // num,
  3612. // row.measureQuantity,
  3613. // idx,
  3614. // row.warehouseId,
  3615. // row.warehouseName + ''
  3616. // // this.form.categoryLevelTopId
  3617. // );
  3618. // } else {
  3619. // console.log(measureBoolen, 'measureBoolen');
  3620. // let num = row.quantity;
  3621. // if (measureBoolen) {
  3622. // let splitIndex = row.packingSpecificationOption.findIndex(
  3623. // (item) =>
  3624. // item.conversionUnit == row.unit &&
  3625. // item.packageUnit != item.conversionUnit
  3626. // );
  3627. // for (; splitIndex > 1; splitIndex--) {
  3628. // num = this.$math.format(
  3629. // num *
  3630. // row.packingSpecificationOption[splitIndex].packageCell,
  3631. // 14
  3632. // );
  3633. // }
  3634. // this.$refs.wareHouseDailogRef.open(
  3635. // num,
  3636. // row.measureQuantity,
  3637. // idx,
  3638. // row.warehouseId,
  3639. // row.warehouseName + ''
  3640. // // this.form.categoryLevelTopId
  3641. // );
  3642. // } else {
  3643. // if (row.measureType != 1 && row.measureUnit == row.unit) {
  3644. // let pNum = 0;
  3645. // let mNum = row.measureQuantity;
  3646. // this.$refs.wareHouseDailogRef.open(
  3647. // pNum,
  3648. // mNum,
  3649. // idx,
  3650. // row.warehouseId,
  3651. // row.warehouseName + ''
  3652. // // this.form.categoryLevelTopId
  3653. // );
  3654. // } else {
  3655. // if (row.packingSpecificationOption[1]?.packageCell) {
  3656. // let num = Math.ceil(
  3657. // row.measureQuantity /
  3658. // row.packingSpecificationOption[1]?.packageCell
  3659. // );
  3660. // this.$refs.wareHouseDailogRef.open(
  3661. // num,
  3662. // row.measureQuantity,
  3663. // idx,
  3664. // row.warehouseId,
  3665. // row.warehouseName + ''
  3666. // );
  3667. // } else {
  3668. // this.$refs.wareHouseDailogRef.open(
  3669. // row.quantity,
  3670. // row.measureQuantity,
  3671. // idx,
  3672. // row.warehouseId,
  3673. // row.warehouseName + ''
  3674. // );
  3675. // }
  3676. // console.log(num, 'num');
  3677. // }
  3678. // }
  3679. // }
  3680. }
  3681. } else {
  3682. this.$message.error('请先填写包装数量!');
  3683. }
  3684. } else {
  3685. //批量
  3686. console.log(row, `row`);
  3687. console.log(idx, `idx`);
  3688. console.log(type, 'type');
  3689. // 批量设置
  3690. if (row.some((item) => !item.quantity)) {
  3691. this.$message.error('请先填写所有行的包装数量!');
  3692. return;
  3693. }
  3694. for (let i = 0; i < row.length; i++) {
  3695. //测量单位等于包装单位
  3696. if (row[i].measureType != 1 && row[i].measureUnit === row[i].unit) {
  3697. row[i].packingQuantity2 = 0;
  3698. console.log(row[i].packingQuantity2);
  3699. } else {
  3700. row[i].packingQuantity2 = Math.ceil(
  3701. row[i].measureQuantity /
  3702. row[i].packingSpecificationOption[1]?.packageCell
  3703. );
  3704. console.log(row[i].packingQuantity2, '单位不一样');
  3705. }
  3706. }
  3707. console.log(row, 'rowrowrowrowrowrow我看看');
  3708. const pNum = row.reduce((sum, item) => {
  3709. if (
  3710. item.packingQuantity2 !== undefined &&
  3711. item.packingQuantity2 !== null
  3712. ) {
  3713. return sum + Number(item.packingQuantity2);
  3714. }
  3715. return sum;
  3716. }, 0);
  3717. const mNum = row.reduce((sum, item) => {
  3718. if (
  3719. item.measureQuantity !== undefined &&
  3720. item.measureQuantity !== null
  3721. ) {
  3722. return sum + Number(item.measureQuantity);
  3723. }
  3724. return sum;
  3725. }, 0);
  3726. console.log(pNum, 'pppp');
  3727. console.log(mNum, 'mmmmm');
  3728. this.$refs.wareHouseDailogRef.open(
  3729. pNum,
  3730. mNum
  3731. // this.form.categoryLevelTopId
  3732. );
  3733. }
  3734. },
  3735. wareHouseSelection(argum, idx) {
  3736. console.log(argum, 'argumargumargumargumargumargum');
  3737. // 方便包装遍历获取仓库id和名称
  3738. let warehouseIds = [];
  3739. let warehouseNames = [];
  3740. argum.forEach((item) => {
  3741. console.log(item, 'itemitem');
  3742. for (let index = 0; index < item.packingQuantity; index++) {
  3743. warehouseIds.push(item.warehouseId);
  3744. warehouseNames.push(item.warehouseName);
  3745. }
  3746. });
  3747. console.log(idx, this.productList, 'idxidxidxidx');
  3748. if (idx > -1) {
  3749. this.$set(
  3750. this.productList[idx],
  3751. 'warehouseId',
  3752. argum.map((item) => item.warehouseId).join(',')
  3753. );
  3754. this.$set(
  3755. this.productList[idx],
  3756. 'warehouseName',
  3757. argum.map((item) => item.warehouseName).join(',')
  3758. );
  3759. this.$set(this.productList[idx], 'warehouseIds', warehouseIds);
  3760. this.$set(this.productList[idx], 'warehouseNames', warehouseNames);
  3761. console.log(this.productList, 'productList');
  3762. } else {
  3763. this.productList.map((item, index) => {
  3764. this.$set(
  3765. this.productList[index],
  3766. 'warehouseId',
  3767. argum.map((item) => item.warehouseId).join(',')
  3768. );
  3769. this.$set(
  3770. this.productList[index],
  3771. 'warehouseName',
  3772. argum.map((item) => item.warehouseName).join(',')
  3773. );
  3774. this.$set(this.productList[index], 'warehouseIds', warehouseIds);
  3775. this.$set(
  3776. this.productList[index],
  3777. 'warehouseNames',
  3778. warehouseNames
  3779. );
  3780. });
  3781. }
  3782. this.$forceUpdate();
  3783. },
  3784. // 生成包装
  3785. generateWrappers(row, productIndex, packingCodeList) {
  3786. console.log(packingCodeList, 'packingCodeList', row.measureType);
  3787. if (!row.measureType)
  3788. return this.$message.warning('请到主数据维计量类型!');
  3789. console.log('包装数据--------', row);
  3790. // console.log('包装规格----', row.packingSpecificationOption);
  3791. console.log('计量单位----', row.measureUnit);
  3792. let packingList = [];
  3793. let obj = this.getNowDate();
  3794. let productionDate = row.detailProductionDate || '';
  3795. let purchaseDate = row.detailPurchaseDate || '';
  3796. let expireDate = row.detailExpireDate || '';
  3797. console.log(expireDate, 'expireDate');
  3798. console.log(
  3799. this.formData.bizType,
  3800. 'bizTypebizTypebizTypebizTypebizTypebizTypebizTypebizTypebizTypebizTypebizType'
  3801. );
  3802. if (this.formData.bizType == '1') {
  3803. // 生产入库
  3804. productionDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  3805. // this.curDateType = 'productionDate';
  3806. }
  3807. // 判断单位和计量单位是否为不拆物料层规格
  3808. let packingBoolen = !!this.getDict('不拆物料层规格', row.unit)
  3809. .dictValue;
  3810. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
  3811. .dictValue;
  3812. let num = row.packingQuantity;
  3813. let filterArr = [];
  3814. // 处理单位为KG类的情况
  3815. if (packingBoolen) {
  3816. console.log(
  3817. packingBoolen,
  3818. 'packingBoolenpackingBoolenpackingBoolenpackingBoolenpackingBoolenpackingBoolen'
  3819. );
  3820. if (!row.isUnpack && row.unit == '立方') {
  3821. num = 1;
  3822. } else {
  3823. filterArr = row.packingSpecificationOption.filter((item) => {
  3824. return (
  3825. item.packageUnit == row.unit &&
  3826. item.packageUnit != item.conversionUnit
  3827. );
  3828. });
  3829. num = Math.ceil(row.packingQuantity / filterArr[0]?.packageCell);
  3830. }
  3831. } else {
  3832. // if (row.isUnpack == 1) {
  3833. if (measureBoolen) {
  3834. // 处理单位不为KG类,计量单位为KG类的情况
  3835. let splitIndex = row.packingSpecificationOption.findIndex(
  3836. (item) =>
  3837. item.conversionUnit == row.unit &&
  3838. item.packageUnit != item.conversionUnit
  3839. );
  3840. for (; splitIndex > 1; splitIndex--) {
  3841. num = this.$math.format(
  3842. num * row.packingSpecificationOption[splitIndex].packageCell,
  3843. 14
  3844. );
  3845. }
  3846. } else {
  3847. if (row.packingSpecificationOption[1]?.packageCell) {
  3848. num = Math.ceil(
  3849. row.measureQuantity /
  3850. row.packingSpecificationOption[1]?.packageCell
  3851. );
  3852. filterArr = row.packingSpecificationOption.filter((item) => {
  3853. return (
  3854. item.packageUnit == row.unit &&
  3855. item.packageUnit != item.conversionUnit
  3856. );
  3857. });
  3858. }
  3859. }
  3860. }
  3861. console.log('num-----------', num);
  3862. for (let index = 0; index < packingCodeList.length; index++) {
  3863. let measureQuantity = 1;
  3864. let packingQuantity = 1;
  3865. let packingUnit = row.packingUnit;
  3866. // 处理单位为KG类,计算每桶KG值
  3867. if (packingBoolen) {
  3868. measureQuantity =
  3869. Number(row.quantity) >
  3870. this.$math.format(filterArr[0].packageCell * (index + 1), 14)
  3871. ? filterArr[0].packageCell
  3872. : Number(row.quantity) -
  3873. this.$math.format(filterArr[0].packageCell * index, 14);
  3874. console.log(measureQuantity, 'measureQuantit1111y');
  3875. } else {
  3876. console.log('1 拆--------', measureBoolen);
  3877. //计量单位等于重量单位并且有总重 计量数量=总重/包装数
  3878. if (row.weightUnit == row.measureUnit && row.weight) {
  3879. measureQuantity =
  3880. Math.trunc((row.weight / packingCodeList.length) * 10000) /
  3881. 10000;
  3882. } else {
  3883. measureQuantity = row.packingSpecificationOption[1].packageCell;
  3884. }
  3885. console.log(measureQuantity, 'measureQuantity');
  3886. }
  3887. let clientCode = '';
  3888. if (this.bizType == 2) {
  3889. clientCode = row?.customerMark;
  3890. } else if (this.bizType != 2) {
  3891. clientCode = row.extInfo?.clientCode;
  3892. }
  3893. console.log(filterArr[0], 'filterArr[0]');
  3894. let status = null;
  3895. //通过委外发货单编码判断是不是委外 委外收货 质检状态显示已质检
  3896. // if (this.form.outsourceSendCode != '') {
  3897. // status = 2;
  3898. // } else {
  3899. // // 0未检 1待检 2 已检
  3900. // if (row.qualityControl == 1) {
  3901. // status = 0;
  3902. // } else {
  3903. // status = 2;
  3904. // }
  3905. // }
  3906. if (row.qualityControl == 1) {
  3907. status = 0;
  3908. } else {
  3909. status = 2;
  3910. }
  3911. let item = {
  3912. index: row.index + '-' + index, // 包装索引
  3913. warehouseId: row.warehouseId, // 仓库id
  3914. warehouseName: row.warehouseName, // 仓库名称
  3915. categoryName: row.categoryName, // 产品名称
  3916. categoryCode: row.categoryCode, // 产品编码
  3917. categoryModel: row.categoryModel, // 物品型号
  3918. specification: row.specification, // 规格
  3919. supplierCode: row.supplierCode, // 供应商编码
  3920. supplierName: row.supplierName, // 供应商名称
  3921. brandNum: row.brandNum, // 牌号
  3922. parentIndex: row.index, // 产品索引
  3923. batchNo: row.batchNo, // 批次号
  3924. packageNo: packingCodeList[index]?.onlyCode, // 包装编码
  3925. packingQuantity: packingQuantity, // 包装数量
  3926. modelKey: row.modelKey, // 机型
  3927. colorKey: row.colorKey, //颜色
  3928. // packingUnit: row.isUnpack ? packingBoolen ? filterArr[0].conversionUnit : measureBoolen ? row.packingSpecificationOption[1]
  3929. // ? row.packingSpecificationOption[1].conversionUnit
  3930. // : row.packingSpecificationOption[0].conversionUnit
  3931. // : row.measureUnit
  3932. // : packingBoolen
  3933. // ? row.packingUnit === '立方' ? row.packingUnit : filterArr[0]?.conversionUnit
  3934. // : row.packingUnit,
  3935. // packingUnit: row.isUnpack ? packingBoolen ? filterArr[0].conversionUnit : measureBoolen ? row.packingSpecificationOption[2] ?
  3936. // row.packingSpecificationOption[2].conversionUnit : row.packingSpecificationOption[1].conversionUnit: row.measureUnit: packingBoolen ? filterArr[0].conversionUnit : row.packingUnit,
  3937. //!row.isUnpack && row.packingUnit
  3938. measureQuantity: measureQuantity, // 计量数量
  3939. measureUnit: row.isUnpack
  3940. ? measureBoolen
  3941. ? row.packingSpecificationOption[1]
  3942. ? row.packingSpecificationOption[1].packageUnit
  3943. : row.packingSpecificationOption[0].packageUnit
  3944. : row.measureUnit
  3945. : row.measureUnit, // 计量单位
  3946. weight: 0, // 重量
  3947. packingSpecificationOption: row.packingSpecificationOption, // 包装规格
  3948. weightUnit: row.weightUnit, // 重量单位
  3949. netWeight: row.netWeight, // 净重
  3950. barcodes: '', // 发货条码
  3951. clientCode: clientCode, // 客户代号
  3952. materielDesignation: row.extInfo ? row.extInfo.materielCode : '', // 物料代号
  3953. engrave: '', // 刻码
  3954. isUnpack: row.isUnpack, // 是否允许拆包
  3955. productionDate: productionDate, // 生产日期
  3956. purchaseDate: purchaseDate, // 采购时间
  3957. expireDate: expireDate, //失效日期
  3958. result: 1, // 结果(1合格 2不合格)
  3959. qualityControl: row.qualityControl,
  3960. status: status // 状态(0=未质检 1待检 2已检)
  3961. };
  3962. /**
  3963. * packingUnit: row.isUnpack ? packingBoolen ? filterArr[0].conversionUnit : measureBoolen ? row.packingSpecificationOption[2] ? row.packingSpecificationOption[2].conversionUnit
  3964. * : row.packingSpecificationOption[1].conversionUnit: row.measureUnit: packingBoolen ? filterArr[0].conversionUnit : row.packingUnit,
  3965. */
  3966. if (row.isUnpack) {
  3967. item.packingUnit = row.packingSpecificationOption[1].conversionUnit;
  3968. // // 第二层条件: packingBoolen
  3969. // if (packingBoolen) {
  3970. // // 空值保护: 确保 filterArr[0] 存在
  3971. // item.packingUnit =
  3972. // row.packingSpecificationOption[1].conversionUnit;
  3973. // } else {
  3974. // // 第三层条件: measureBoolen
  3975. // if (measureBoolen) {
  3976. // // 处理 packingSpecificationOption 的索引
  3977. // const option =
  3978. // row.packingSpecificationOption?.[1] ||
  3979. // row.packingSpecificationOption?.[0];
  3980. // item.packingUnit = option?.conversionUnit;
  3981. // } else {
  3982. // item.packingUnit =
  3983. // row.packingSpecificationOption[1].conversionUnit;
  3984. // }
  3985. // }
  3986. }
  3987. let outBoolen = !!this.getDict('不拆物料层规格', item.measureUnit)
  3988. .dictValue;
  3989. //计量单位等于重量单位
  3990. if (row.weightUnit == row.measureUnit) {
  3991. item.weight = item.measureQuantity
  3992. ? Number(item.measureQuantity)
  3993. : 0;
  3994. } else {
  3995. item.weight = this.$math.format(
  3996. (row.singleWeight || 0) * item.measureQuantity,
  3997. 14
  3998. );
  3999. // console.log('计量单位为不为KG类======================');
  4000. // // 计量单位为不为KG类,重新统计计算
  4001. // let inBoolen = !!this.getDict(
  4002. // '不拆物料层规格',
  4003. // item.packingSpecificationOption[0].packageUnit
  4004. // ).dictValue;
  4005. // let startIndex = item.packingSpecificationOption.findIndex(
  4006. // (ite) => {
  4007. // return (
  4008. // item.measureUnit == ite.packingUnit &&
  4009. // ite.packingUnit != ite.conversionUnit
  4010. // );
  4011. // }
  4012. // );
  4013. // let endIndex = item.packingSpecificationOption.findIndex(
  4014. // (ite) => item.packingUnit == ite.conversionUnit
  4015. // );
  4016. // if (measureBoolen) {
  4017. // let total = item.packingQuantity
  4018. // ? Number(item.packingQuantity)
  4019. // : 0;
  4020. // for (; startIndex < endIndex; endIndex--) {
  4021. // total = this.$math.format(
  4022. // item.packingSpecificationOption[endIndex].packageCell * total,
  4023. // 14
  4024. // );
  4025. // }
  4026. // if (inBoolen) {
  4027. // // 第二层为KG类
  4028. // item.weight = total ? Number(total) : 0;
  4029. // } else {
  4030. // // 第二层不为KG类
  4031. // item.weight = this.$math.format(total * item.netWeight, 14);
  4032. // }
  4033. // } else if (!measureBoolen) {
  4034. // if (inBoolen) {
  4035. // // 第二层为KG类
  4036. // item.weight = item.measureQuantity
  4037. // ? Number(item.measureQuantity)
  4038. // : 0;
  4039. // } else {
  4040. // // 第二层不为KG类
  4041. // if (row.singleWeight && item.measureQuantity) {
  4042. // item.weight =
  4043. // Number(item.measureQuantity) * Number(row.singleWeight);
  4044. // } else {
  4045. // item.weight = 0;
  4046. // }
  4047. // }
  4048. // }
  4049. }
  4050. packingList.push(item);
  4051. console.log(
  4052. packingList,
  4053. 'packingList!!!!!!!!!!!!!!!!!!拆'
  4054. );
  4055. }
  4056. // 单独点击保存并插入对应位置(包装)
  4057. if (productIndex == 0) {
  4058. this.packingList.splice(productIndex, 0, ...packingList);
  4059. } else {
  4060. let packingIndex = this.packingList.findLastIndex(
  4061. (item) =>
  4062. item.parentIndex == this.productList[productIndex - 1].index
  4063. );
  4064. this.packingList.splice(packingIndex + 1, 0, ...packingList);
  4065. }
  4066. let remainder = 0;
  4067. if (row.weightUnit != row.measureUnit) {
  4068. remainder =
  4069. row.measureQuantity %
  4070. row.packingSpecificationOption[1]?.packageCell;
  4071. }
  4072. if (remainder > 0) {
  4073. let onlyCode = packingCodeList[packingCodeList.length - 1]?.onlyCode;
  4074. let index = this.packingList.findIndex(
  4075. (packingItem) => packingItem.packageNo == onlyCode
  4076. );
  4077. this.$set(this.packingList[index], 'measureQuantity', remainder);
  4078. if (row.singleWeight) {
  4079. this.$set(
  4080. this.packingList[index],
  4081. 'weight',
  4082. row.singleWeight * remainder
  4083. );
  4084. }
  4085. }
  4086. // 单独点击保存并插入对应位置(物料)
  4087. // let materialList = packingList
  4088. // .map((item) => {
  4089. // if (item.isUnpack) {
  4090. // return this.generateMaterial(item);
  4091. // } else {
  4092. // return [];
  4093. // }
  4094. // })
  4095. // .flat();
  4096. // console.log(materialList);
  4097. // if (materialList.length > 0) {
  4098. // if (productIndex == 0) {
  4099. // this.materialList.splice(0, 0, ...materialList);
  4100. // } else {
  4101. // let preLastPackingIndex = this.packingList.findLastIndex((ite) => {
  4102. // return ite.parentIndex <= productIndex - 1 && ite.isUnpack;
  4103. // });
  4104. // let preLastMaterialIndex = this.materialList.findLastIndex(
  4105. // (ite) => {
  4106. // return (
  4107. // ite.parentIndex == this.packingList[preLastPackingIndex].index
  4108. // );
  4109. // }
  4110. // );
  4111. // this.materialList.splice(
  4112. // preLastMaterialIndex + 1,
  4113. // 0,
  4114. // ...materialList
  4115. // );
  4116. // }
  4117. // }
  4118. },
  4119. // 生成物料
  4120. generateMaterial(row) {
  4121. let materialList = [];
  4122. for (let index = 0; index < row.measureQuantity; index++) {
  4123. materialList.push({
  4124. materialCode: row.packageNo + index.toString().padStart(4, '0'), // 物料编码
  4125. index: row.index + '——' + index, // 包装索引
  4126. warehouseId: row.warehouseId, // 仓库id
  4127. warehouseName: row.warehouseName, // 仓库名称
  4128. categoryName: row.categoryName, // 产品名称
  4129. categoryCode: row.categoryCode, // 产品编码
  4130. parentIndex: row.index, // 产品索引
  4131. batchNo: row.batchNo, // 批次号
  4132. packageNo: row.packageNo, // 包装编码
  4133. measureQuantity: 1, // 计量数量
  4134. measureUnit: row.measureUnit, // 计量单位
  4135. weight: Number(
  4136. this.$math.format(row.weight / row.packingQuantity, 14)
  4137. ), // 重量
  4138. weightUnit: row.weightUnit, // 重量单位
  4139. barcodes: '', // 发货条码
  4140. clientCode: '', // 客户代号
  4141. materielDesignation: '', // 物料代号
  4142. engrave: '', // 刻码
  4143. result: 1, // 结果(1合格 2不合格 3让步接收)
  4144. status: 2 // 状态(0=未质检 1待检 2已检)
  4145. });
  4146. }
  4147. return materialList;
  4148. },
  4149. // 设置时间
  4150. dateSetting(curDateType) {
  4151. if (!this.packingListSelected.length) {
  4152. return this.$message.error(`请选择${this.title}明细!`);
  4153. }
  4154. this.curDateType = curDateType;
  4155. this.dateVisible = true;
  4156. },
  4157. // 选择包装列表
  4158. handleSelectionChange(val) {
  4159. this.packingListSelected = val;
  4160. },
  4161. // 选择质检结果改变质检状态
  4162. changeWrapStatus(resultValue, row, type) {
  4163. switch (resultValue) {
  4164. case 0:
  4165. // 清空质检状态
  4166. row.status = 0;
  4167. break;
  4168. default:
  4169. // 默认已检质检状态
  4170. row.status = 2;
  4171. break;
  4172. }
  4173. if (type === '包装') {
  4174. this.packingResultCahnge(resultValue, row);
  4175. } else {
  4176. this.materialResultCahnge(resultValue, row);
  4177. }
  4178. }
  4179. }
  4180. };
  4181. </script>
  4182. <style lang="scss" scoped>
  4183. ::v-deep .el-table .warning-row {
  4184. background: #d9ecff;
  4185. }
  4186. .inbound_details {
  4187. margin-top: 10px;
  4188. .el-form-item {
  4189. margin-bottom: 0 !important;
  4190. }
  4191. }
  4192. .right_control {
  4193. display: flex;
  4194. > button {
  4195. margin-left: 20px;
  4196. }
  4197. }
  4198. .storage_btn {
  4199. margin-top: 20px;
  4200. display: flex;
  4201. align-content: center;
  4202. justify-content: center;
  4203. }
  4204. .el-date-editor.el-input,
  4205. .el-date-editor.el-input__inner {
  4206. width: 100% !important;
  4207. }
  4208. .red_color {
  4209. color: red;
  4210. }
  4211. .wareHouse_style {
  4212. text-overflow: ellipsis;
  4213. overflow: hidden;
  4214. word-break: break-all;
  4215. white-space: nowrap;
  4216. }
  4217. </style>