storage.vue 160 KB

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