storage.vue 145 KB

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