storage.vue 154 KB

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