storage.vue 156 KB

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