storage.vue 106 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <header-title title="基本信息"> </header-title>
  5. <el-form
  6. :model="formData"
  7. ref="formName"
  8. label-width="110px"
  9. :rules="rules"
  10. >
  11. <el-row :gutter="20">
  12. <el-col :span="6">
  13. <el-form-item label="物品类型" prop="extInfo.assetType">
  14. <el-select
  15. style="width: 100%"
  16. disabled
  17. multiple
  18. v-model="formData.extInfo.assetType"
  19. placeholder="请选择"
  20. >
  21. <el-option
  22. v-for="item in goodsLists"
  23. :key="item.id"
  24. :label="item.name"
  25. :value="item.id"
  26. >
  27. </el-option>
  28. </el-select>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :span="6">
  32. <el-form-item label="入库类型" prop="bizType">
  33. <el-select
  34. style="width: 100%"
  35. disabled
  36. filterable
  37. placeholder="请选择"
  38. v-model="formData.bizType"
  39. clearable
  40. >
  41. <el-option
  42. v-for="item in sceneState"
  43. :key="item.code"
  44. :value="item.code"
  45. :label="item.label"
  46. ></el-option>
  47. </el-select> </el-form-item
  48. ></el-col>
  49. <el-col :span="6">
  50. <el-form-item label="单据来源" prop="documentSource">
  51. <el-input
  52. placeholder="请选择"
  53. disabled
  54. v-model="formData.sourceBizNo"
  55. @click.native="openDocumentSourceDialog"
  56. >
  57. </el-input>
  58. </el-form-item>
  59. </el-col>
  60. <!-- <el-col :span="6">
  61. <el-form-item label="权属部门" prop="deptName">
  62. <el-input
  63. placeholder="权属部门"
  64. disabled
  65. v-model="formData.extInfo.deptName"
  66. clearable
  67. />
  68. </el-form-item>
  69. </el-col> -->
  70. <el-col :span="6">
  71. <el-form-item label="入库时间">
  72. <el-date-picker
  73. v-model="formData.storageTime"
  74. type="datetime"
  75. value-format="yyyy-MM-dd HH:mm:ss"
  76. placeholder="选择日期时间"
  77. >
  78. </el-date-picker></el-form-item
  79. ></el-col>
  80. <el-col :span="6">
  81. <el-form-item label="入库登记人">
  82. <el-input
  83. placeholder="登记人"
  84. disabled
  85. v-model="formData.extInfo.createUserName"
  86. clearable /></el-form-item
  87. ></el-col>
  88. <!-- <el-col :span="6" v-if="formData.bizType == 2">
  89. <el-form-item label="供应商" prop="supplierName">
  90. <el-input
  91. placeholder="请输入"
  92. clearable
  93. v-model="formData.extInfo.supplierName"
  94. />
  95. </el-form-item>
  96. </el-col> -->
  97. <el-col :span="6">
  98. <el-form-item label="送货人" prop="fromUser">
  99. <el-input
  100. placeholder="请输入"
  101. v-model="formData.fromUser"
  102. clearable
  103. /> </el-form-item
  104. ></el-col>
  105. <el-col :span="6">
  106. <el-form-item label="送货人联系方式" prop="deliveryPhone">
  107. <el-input
  108. placeholder="请输入"
  109. v-model="formData.extInfo.deliveryPhone"
  110. clearable /></el-form-item
  111. ></el-col>
  112. <el-col :span="6">
  113. <el-form-item label="备注" prop="remark">
  114. <el-input
  115. v-model="formData.remark"
  116. clearable
  117. type="textarea"
  118. placeholder="请详细说明"
  119. :rows="1"
  120. ></el-input>
  121. </el-form-item>
  122. </el-col>
  123. </el-row>
  124. </el-form>
  125. <div class="inbound_details">
  126. <header-title title="产品信息">
  127. <el-button type="primary" @click="addProduct">添加</el-button>
  128. </header-title>
  129. <div class="form_table">
  130. <el-form
  131. ref="productListRef"
  132. :model="{ productList: productList }"
  133. :show-message="false"
  134. >
  135. <el-button
  136. v-if="productList.length != 0"
  137. type="success"
  138. plain
  139. style="margin-bottom: 20px; float: right; margin-right: 20px"
  140. size="mini"
  141. @click="listSaveArrs"
  142. >批量保存</el-button
  143. >
  144. <el-button
  145. v-if="productList.length != 0 && this.packingList.length == 0"
  146. type="success"
  147. plain
  148. style="margin-bottom: 20px; float: right; margin-right: 20px"
  149. size="mini"
  150. @click="handleWareHouse(productList[0])"
  151. >批量选择仓库</el-button
  152. >
  153. <el-table
  154. :header-cell-style="rowClass"
  155. :max-height="300"
  156. border
  157. ref="productListTable"
  158. :data="productList"
  159. tooltip-effect="dark"
  160. >
  161. <el-table-column
  162. label="序号"
  163. type="index"
  164. width="50"
  165. align="center"
  166. >
  167. </el-table-column>
  168. <el-table-column
  169. label="编码"
  170. prop="categoryCode"
  171. align="center"
  172. width="130"
  173. :show-overflow-tooltip="true"
  174. ></el-table-column>
  175. <el-table-column
  176. label="名称"
  177. align="center"
  178. width="200"
  179. prop="categoryName"
  180. :show-overflow-tooltip="true"
  181. ></el-table-column>
  182. <el-table-column
  183. label="型号"
  184. align="center"
  185. width="100"
  186. prop="categoryModel"
  187. :show-overflow-tooltip="true"
  188. ></el-table-column>
  189. <el-table-column
  190. label="规格"
  191. align="center"
  192. width="100"
  193. prop="specification"
  194. :show-overflow-tooltip="true"
  195. ></el-table-column>
  196. <el-table-column
  197. label="牌号"
  198. align="center"
  199. width="100"
  200. prop="brandNum"
  201. :show-overflow-tooltip="true"
  202. ></el-table-column>
  203. <el-table-column
  204. v-for="(item, index) in newColumns"
  205. :label="item.label"
  206. :align="item.align"
  207. :prop="item.prop"
  208. :show-overflow-tooltip="item.showOverflowTooltip"
  209. ></el-table-column>
  210. <el-table-column
  211. label="批次号"
  212. align="center"
  213. width="100"
  214. prop="batchNo"
  215. >
  216. <template slot-scope="{ row, $index }">
  217. <template v-if="row.isSave">
  218. {{ row.batchNo }}
  219. </template>
  220. <el-form-item
  221. v-else
  222. :prop="`productList.${$index}.batchNo`"
  223. required
  224. >
  225. <el-input
  226. :ref="'batchNo' + $index"
  227. @keyup.native="
  228. moveFocus($event, $index, 'batchNo', '产品', row)
  229. "
  230. v-model.number="row.batchNo"
  231. >
  232. </el-input>
  233. </el-form-item>
  234. </template>
  235. </el-table-column>
  236. <el-table-column
  237. label="数量"
  238. align="center"
  239. width="100"
  240. prop="packingQuantity"
  241. >
  242. <template slot-scope="{ row, $index }">
  243. <template v-if="row.isSave">
  244. {{ row.packingQuantity }}
  245. </template>
  246. <el-form-item
  247. v-else
  248. :prop="`productList.${$index}.packingQuantity`"
  249. required
  250. >
  251. <el-input
  252. :ref="'packingQuantity' + $index"
  253. type="number"
  254. @keyup.native="
  255. moveFocus(
  256. $event,
  257. $index,
  258. 'packingQuantity',
  259. '产品',
  260. row
  261. )
  262. "
  263. v-model="row.packingQuantity"
  264. @input="computeNum(row, $index, true)"
  265. >
  266. </el-input>
  267. </el-form-item>
  268. </template>
  269. </el-table-column>
  270. <el-table-column
  271. label="单位"
  272. align="center"
  273. prop="packingUnit"
  274. width="100"
  275. >
  276. <template slot-scope="{ row, $index }">
  277. <template v-if="row.isSave">
  278. {{ row.packingUnit }}
  279. </template>
  280. <el-form-item
  281. v-else
  282. :prop="`productList.${$index}.packingUnit`"
  283. required
  284. >
  285. <el-select
  286. v-model="row.packingUnit"
  287. placeholder="请选择"
  288. @change="computeNum(row, $index)"
  289. >
  290. <el-option
  291. v-for="item in row.packingSpecificationOption"
  292. :label="`${item.conversionUnit}`"
  293. :value="item.conversionUnit"
  294. :key="item.id"
  295. >
  296. </el-option>
  297. </el-select>
  298. </el-form-item>
  299. </template>
  300. </el-table-column>
  301. <el-table-column
  302. label="包装规格"
  303. align="center"
  304. prop="packingSpecificationLabel"
  305. width="300"
  306. :show-overflow-tooltip="true"
  307. >
  308. <template slot-scope="{ row, $index }">
  309. <el-tag v-for="item in row.packingSpecificationLabel">{{
  310. item
  311. }}</el-tag>
  312. </template>
  313. </el-table-column>
  314. <el-table-column label="允许拆包" prop="isUnpack">
  315. <template slot-scope="{ row, $index }">
  316. {{ row.isUnpack ? '是' : '否' }}
  317. </template>
  318. </el-table-column>
  319. <el-table-column
  320. label="计量数量"
  321. align="center"
  322. prop="measureQuantity"
  323. :show-overflow-tooltip="true"
  324. ></el-table-column>
  325. <el-table-column
  326. label="计量单位"
  327. align="center"
  328. prop="measureUnit"
  329. :show-overflow-tooltip="true"
  330. ></el-table-column>
  331. <el-table-column
  332. label="重量"
  333. align="center"
  334. prop="weight"
  335. :show-overflow-tooltip="true"
  336. >
  337. <template slot-scope="{ row, $index }">
  338. {{ row.weight }}
  339. <template slot="append">
  340. {{ row.measureUnit }}
  341. </template>
  342. </template>
  343. </el-table-column>
  344. <el-table-column
  345. label="重量单位"
  346. align="center"
  347. prop="weightUnit"
  348. :show-overflow-tooltip="true"
  349. >
  350. <template slot-scope="{ row, $index }">
  351. {{ row.weightUnit }}
  352. <template slot="append"> </template>
  353. </template>
  354. </el-table-column>
  355. <el-table-column
  356. label="单价"
  357. prop="price"
  358. width="200"
  359. align="center"
  360. >
  361. <template slot-scope="{ row, $index }">
  362. <template v-if="row.isSave">
  363. {{ row.price }}元/{{ row.measureUnit }}
  364. </template>
  365. <el-form-item v-else>
  366. <el-input
  367. type="number"
  368. :ref="'price' + $index"
  369. @keyup.native="
  370. moveFocus($event, $index, 'price', '产品', row)
  371. "
  372. v-model.number="row.price"
  373. placeholder="非必填"
  374. @input="
  375. (value) => (row.price = value.replace(/[^0-9.]+/g, ''))
  376. "
  377. >
  378. <template slot="append">
  379. 元/{{ row.measureUnit }}
  380. </template>
  381. </el-input>
  382. </el-form-item>
  383. </template>
  384. </el-table-column>
  385. <el-table-column
  386. label="金额"
  387. align="center"
  388. prop="totalMoney"
  389. :show-overflow-tooltip="true"
  390. >
  391. <template slot-scope="{ row, $index }">
  392. {{
  393. changeCount(
  394. calcSumTotal(row.measureQuantity, row.price, row)
  395. )
  396. }}
  397. </template>
  398. </el-table-column>
  399. <el-table-column
  400. label="供应商"
  401. align="center"
  402. prop="supplierId"
  403. width="200"
  404. :show-overflow-tooltip="true"
  405. >
  406. <template slot-scope="{ row, $index }">
  407. <template v-if="row.isSave">
  408. {{ row.supplierName }}
  409. </template>
  410. <el-select
  411. v-else
  412. @change="selectSupplier($event, row)"
  413. v-model="row.supplierId"
  414. placeholder="请选择"
  415. >
  416. <el-option
  417. v-for="item in row.supplierListOptions"
  418. :label="item.name"
  419. :value="item.id"
  420. :key="item.id"
  421. >
  422. </el-option>
  423. </el-select>
  424. </template>
  425. </el-table-column>
  426. <el-table-column
  427. label="仓库"
  428. align="center"
  429. prop="warehouseName"
  430. :show-overflow-tooltip="true"
  431. width="300"
  432. >
  433. <template slot-scope="{ row, $index }">
  434. <el-form-item
  435. :prop="`productList.${$index}.warehouseId`"
  436. required
  437. >
  438. <div
  439. :class="
  440. row.warehouseName
  441. ? 'wareHouse_style'
  442. : 'wareHouse_style red_color'
  443. "
  444. @click="handleWareHouse(row, $index)"
  445. >
  446. <span>
  447. {{
  448. row.warehouseName ? row.warehouseName : '请选择仓库'
  449. }}
  450. </span>
  451. </div>
  452. </el-form-item>
  453. </template>
  454. </el-table-column>
  455. <el-table-column
  456. label="采购原因"
  457. align="center"
  458. width="200"
  459. prop="purpose"
  460. :show-overflow-tooltip="true"
  461. >
  462. <template slot-scope="{ row, $index }">
  463. <template v-if="row.isSave">
  464. {{ row.purpose }}
  465. </template>
  466. <el-input
  467. v-else
  468. :ref="'purpose' + $index"
  469. @keyup.native="
  470. moveFocus($event, $index, 'purpose', '产品', row)
  471. "
  472. v-model="row.purpose"
  473. >
  474. </el-input>
  475. </template>
  476. </el-table-column>
  477. <el-table-column
  478. label="操作"
  479. width="200"
  480. fixed="right"
  481. align="center"
  482. >
  483. <template slot="header" slot-scope="scope"> 操作 </template>
  484. <template slot-scope="{ row, $index }">
  485. <el-button
  486. type="text"
  487. v-show="!row.isSave"
  488. @click="listSave(row, $index)"
  489. >保存</el-button
  490. >
  491. <el-button
  492. type="text"
  493. v-show="row.isSave"
  494. @click="listEdit(row, $index)"
  495. >编辑</el-button
  496. >
  497. <el-button type="text" @click="listDel(row, $index)"
  498. >删除</el-button
  499. >
  500. </template>
  501. </el-table-column>
  502. </el-table>
  503. </el-form>
  504. </div>
  505. </div>
  506. <div v-if="showPackingList.length > 0" class="inbound_details">
  507. <header-title :title="`包装明细`">
  508. <div class="switch_right">
  509. <el-button
  510. style="margin-left: 20px"
  511. type="text"
  512. @click="dateSetting"
  513. >批量设置{{
  514. curDateType === 'productionDate' ? '生产日期' : '采购日期'
  515. }}</el-button
  516. >
  517. </div>
  518. </header-title>
  519. <el-table
  520. v-if="isWrapTable"
  521. ref="packingListTable"
  522. :data="showPackingList"
  523. tooltip-effect="dark"
  524. :key="formData.bizType"
  525. :header-cell-style="rowClass"
  526. style="width: 100%"
  527. border
  528. stripe
  529. :max-height="300"
  530. v-el-table-infinite-scroll="pickingHandleScroll"
  531. @selection-change="handleSelectionChange"
  532. >
  533. <el-table-column type="selection" align="center" width="50">
  534. </el-table-column>
  535. <el-table-column label="序号" type="index" width="50">
  536. </el-table-column>
  537. <el-table-column
  538. label="编码"
  539. prop="categoryCode"
  540. width="130"
  541. :show-overflow-tooltip="true"
  542. ></el-table-column>
  543. <el-table-column
  544. label="名称"
  545. prop="categoryName"
  546. width="150"
  547. :show-overflow-tooltip="true"
  548. ></el-table-column>
  549. <el-table-column
  550. label="批次号"
  551. prop="batchNo"
  552. width="70"
  553. ></el-table-column>
  554. <el-table-column
  555. :label="`包装编码`"
  556. prop="packageNo"
  557. width="200"
  558. :show-overflow-tooltip="true"
  559. ></el-table-column>
  560. <el-table-column
  561. label="包装数量"
  562. prop="packingQuantity"
  563. width="80"
  564. ></el-table-column>
  565. <el-table-column label="单位" prop="packingUnit"></el-table-column>
  566. <el-table-column
  567. label="计量数量"
  568. prop="measureQuantity"
  569. :show-overflow-tooltip="true"
  570. ></el-table-column>
  571. <el-table-column
  572. label="计量单位"
  573. prop="measureUnit"
  574. ></el-table-column>
  575. <!-- <el-table-column label="允许拆包" prop="isUnpack">
  576. <template slot-scope="{ row, $index }">
  577. {{ row.isUnpack ? '是' : '否' }}
  578. </template>
  579. </el-table-column> -->
  580. <el-table-column
  581. label="仓库"
  582. :show-overflow-tooltip="true"
  583. prop="warehouseName"
  584. width="200"
  585. ></el-table-column>
  586. <el-table-column
  587. label="物料代号"
  588. prop="materielDesignation"
  589. width="130"
  590. >
  591. <template slot-scope="{ row, $index }">
  592. <el-input
  593. v-if="!row.isPack"
  594. :ref="'packing_materielDesignation' + $index"
  595. @keyup.native="
  596. moveFocus(
  597. $event,
  598. $index,
  599. 'packing_materielDesignation',
  600. '包装',
  601. row
  602. )
  603. "
  604. v-model="row.materielDesignation"
  605. ></el-input>
  606. <span v-else>{{ row.materielDesignation }}</span>
  607. </template>
  608. </el-table-column>
  609. <el-table-column label="客户代号" prop="clientCode">
  610. <template slot-scope="{ row, $index }">
  611. <el-input
  612. v-if="!row.isPack"
  613. :ref="'packing_clientCode' + $index"
  614. @keyup.native="
  615. moveFocus($event, $index, 'packing_clientCode', '包装', row)
  616. "
  617. v-model="row.clientCode"
  618. ></el-input>
  619. <span v-else> {{ row.clientCode }}</span>
  620. </template>
  621. </el-table-column>
  622. <el-table-column label="刻码" prop="engrave" width="140">
  623. <template slot-scope="{ row, $index }">
  624. <el-input
  625. v-if="!row.isPack"
  626. :ref="'packing_engrave' + $index"
  627. @keyup.native="
  628. moveFocus($event, $index, 'packing_engrave', '包装', row)
  629. "
  630. v-model="row.engrave"
  631. ></el-input>
  632. <span v-else>{{ row.engrave }}</span>
  633. </template>
  634. </el-table-column>
  635. <el-table-column label="重量" prop="weight" width="100">
  636. <template slot-scope="{ row, $index }">
  637. <el-input
  638. v-if="!row.isPack && row.measureUnit != row.weightUnit"
  639. :ref="'packing_weight' + $index"
  640. @keyup.native="
  641. moveFocus($event, $index, 'packing_weight', '包装', row)
  642. "
  643. v-model.number="row.weight"
  644. @input="weightInput($event, row, '包装')"
  645. ></el-input>
  646. <span v-else>{{ row.weight }}</span>
  647. </template>
  648. </el-table-column>
  649. <el-table-column label="重量单位" prop="weightUnit">
  650. <template slot-scope="{ row }">
  651. {{ row.weightUnit }}
  652. </template>
  653. </el-table-column>
  654. <el-table-column
  655. v-if="form.isQmsCheck == 0"
  656. label="质检结果"
  657. prop="result"
  658. width="120"
  659. >
  660. <template slot-scope="{ row }">
  661. <el-select
  662. v-if="!row.isPack"
  663. @change="changeWrapStatus($event, row, '包装')"
  664. v-model="row.result"
  665. placeholder="请选择"
  666. >
  667. <el-option
  668. v-for="item in qualityResultsOptions"
  669. :label="item.label"
  670. :value="item.value"
  671. :key="item.value"
  672. >
  673. </el-option>
  674. </el-select>
  675. <span v-else>{{ qualityResults[row.result] }}</span>
  676. </template>
  677. </el-table-column>
  678. <el-table-column label="质检状态" prop="status" width="120">
  679. <template slot-scope="{ row }">
  680. <span>{{ qualityStatus[row.status] }}</span>
  681. </template>
  682. </el-table-column>
  683. <el-table-column label="生产日期" prop="" width="220">
  684. <template slot="header" slot-scope="scope">
  685. <el-select filterable v-model="curDateType">
  686. <el-option value="productionDate" label="生产日期"></el-option>
  687. <el-option value="purchaseDate" label="采购日期"></el-option>
  688. </el-select>
  689. </template>
  690. <template slot-scope="{ row }">
  691. <template v-if="formData.bizType == 5">
  692. {{ row[curDateType] }}
  693. </template>
  694. <el-date-picker
  695. v-else
  696. :disabled="row.isPack"
  697. size="small"
  698. v-model="row[curDateType]"
  699. type="datetime"
  700. value-format="yyyy-MM-dd HH:mm:ss"
  701. placeholder="选择日期"
  702. >
  703. </el-date-picker>
  704. </template>
  705. </el-table-column>
  706. <!-- <el-table-column label="操作" width="120" fixed="right">
  707. <template slot-scope="{ row, $index }">
  708. <el-button type="text" @click="wrapDelete(row, $index)">
  709. 删除
  710. </el-button>
  711. </template>
  712. </el-table-column> -->
  713. </el-table>
  714. </div>
  715. <div v-if="showMaterialList.length > 0" class="inbound_details">
  716. <header-title :title="`物料明细`"></header-title>
  717. <el-table
  718. ref="materialListTable"
  719. :data="showMaterialList"
  720. tooltip-effect="dark"
  721. :key="formData.bizType"
  722. :header-cell-style="rowClass"
  723. style="width: 100%"
  724. border
  725. stripe
  726. :max-height="300"
  727. v-el-table-infinite-scroll="materielHandleScroll"
  728. >
  729. <el-table-column label="序号" type="index" width="50">
  730. </el-table-column>
  731. <el-table-column
  732. label="编码"
  733. prop="categoryCode"
  734. width="130"
  735. :show-overflow-tooltip="true"
  736. ></el-table-column>
  737. <el-table-column
  738. label="名称"
  739. prop="categoryName"
  740. width="150"
  741. :show-overflow-tooltip="true"
  742. ></el-table-column>
  743. <el-table-column
  744. label="批次号"
  745. prop="batchNo"
  746. width="70"
  747. ></el-table-column>
  748. <el-table-column
  749. label="物料编码"
  750. prop="materialCode"
  751. width="200"
  752. :show-overflow-tooltip="true"
  753. ></el-table-column>
  754. <el-table-column
  755. label="计量数量"
  756. prop="measureQuantity"
  757. width="90"
  758. :show-overflow-tooltip="true"
  759. ></el-table-column>
  760. <el-table-column
  761. width="80"
  762. label="计量单位"
  763. prop="measureUnit"
  764. ></el-table-column>
  765. <el-table-column
  766. label="物料代号"
  767. prop="materielDesignation"
  768. width="130"
  769. >
  770. <template slot-scope="{ row, $index }">
  771. <el-input
  772. v-if="!row.isPack"
  773. :ref="'material_materielDesignation' + $index"
  774. @keyup.native="
  775. moveFocus(
  776. $event,
  777. $index,
  778. 'material_materielDesignation',
  779. '物料',
  780. row
  781. )
  782. "
  783. v-model="row.materielDesignation"
  784. ></el-input>
  785. <span v-else>{{ row.materielDesignation }}</span>
  786. </template>
  787. </el-table-column>
  788. <el-table-column label="客户代号" prop="clientCode">
  789. <template slot-scope="{ row, $index }">
  790. <el-input
  791. v-if="!row.isPack"
  792. :ref="'material_clientCode' + $index"
  793. @keyup.native="
  794. moveFocus($event, $index, 'material_clientCode', '物料', row)
  795. "
  796. v-model="row.clientCode"
  797. ></el-input>
  798. <span v-else>{{ row.clientCode }}</span>
  799. </template>
  800. </el-table-column>
  801. <el-table-column label="刻码" prop="engrave" width="140">
  802. <template slot-scope="{ row, $index }">
  803. <el-input
  804. v-if="!row.isPack"
  805. :ref="'material_engrave' + $index"
  806. @keyup.native="
  807. moveFocus($event, $index, 'material_engrave', '物料', row)
  808. "
  809. v-model="row.engrave"
  810. ></el-input>
  811. <span v-else>{{ row.engrave }}</span>
  812. </template>
  813. </el-table-column>
  814. <el-table-column label="重量" prop="weight" width="100">
  815. <template slot-scope="{ row, $index }">
  816. <el-input
  817. v-if="!row.isPack && row.measureUnit != row.weightUnit"
  818. :ref="'material_weight' + $index"
  819. @keyup.native="
  820. moveFocus($event, $index, 'material_weight', '物料', row)
  821. "
  822. @input="weightInput($event, row, '物料')"
  823. v-model.number="row.weight"
  824. ></el-input>
  825. <span v-else>{{ row.weight }}</span>
  826. </template>
  827. </el-table-column>
  828. <el-table-column
  829. label="重量单位"
  830. prop="weightUnit"
  831. width="100"
  832. ></el-table-column>
  833. <el-table-column label="质检结果" prop="result" width="120">
  834. <template slot-scope="{ row }">
  835. <el-select
  836. v-if="!row.isPack"
  837. @change="changeWrapStatus($event, row, '物料')"
  838. v-model="row.result"
  839. placeholder="请选择"
  840. >
  841. <el-option
  842. v-for="item in qualityResultsOptions"
  843. :label="item.label"
  844. :value="item.value"
  845. :key="item.value"
  846. >
  847. </el-option>
  848. </el-select>
  849. <span v-else>{{ qualityResults[row.result] }}</span>
  850. </template>
  851. </el-table-column>
  852. <el-table-column label="质检状态" prop="status" width="120">
  853. <template slot-scope="{ row }">
  854. <span>{{ qualityStatus[row.status] }}</span>
  855. </template>
  856. </el-table-column>
  857. <!-- <el-table-column label="操作" width="120" fixed="right">
  858. <template slot-scope="{ row, $index }">
  859. <el-button type="text" @click="materialDelete(row, $index)">
  860. 删除
  861. </el-button>
  862. </template>
  863. </el-table-column> -->
  864. </el-table>
  865. </div>
  866. </el-card>
  867. <!-- 产品选择弹框 -->
  868. <selectType
  869. :visibleDialog.sync="visibleDialog"
  870. :title="title"
  871. :treeIds="formData.extInfo.assetType"
  872. :loadTree.sync="loadTree"
  873. @selectTableData="addGoods"
  874. />
  875. <!-- 仓库选择弹框 -->
  876. <WarehousingDialog
  877. ref="wareHouseDailogRef"
  878. @selection="wareHouseSelection"
  879. ></WarehousingDialog>
  880. <!-- 生产日期、采购日期弹框 -->
  881. <el-dialog :visible.sync="dateVisible" title="选择日期" width="400px">
  882. <el-date-picker
  883. size="small"
  884. v-model="batchTime"
  885. type="datetime"
  886. style="width: 320px"
  887. value-format="yyyy-MM-dd HH:mm:ss"
  888. placeholder="选择日期"
  889. >
  890. </el-date-picker>
  891. <div style="text-align: right; margin-top: 20px">
  892. <el-button @click="dateVisible = false">取消</el-button>
  893. <el-button type="primary" @click="dateConfirm" :disabled="!batchTime"
  894. >确认</el-button
  895. >
  896. </div>
  897. </el-dialog>
  898. </div>
  899. </template>
  900. <script>
  901. import elTableInfiniteScroll from 'el-table-infinite-scroll';
  902. import storageApi from '@/api/warehouseManagement/index.js';
  903. import WarehousingDialog from './components/WarehousingDialog.vue';
  904. import { getCode } from '@/api/codeManagement/index.js';
  905. import selectType from './components/selectType_new.vue';
  906. import {
  907. sceneState,
  908. qualityResultsOptions,
  909. qualityResults,
  910. qualityStatus
  911. } from '@/utils/dict/index';
  912. import { getTreeByGroup } from '@/api/classifyManage';
  913. import { deepClone } from '@/utils';
  914. import { getDetails } from '@/api/classifyManage/itemInformation';
  915. import { mapActions, mapGetters } from 'vuex';
  916. import BigNumber from 'bignumber.js';
  917. export default {
  918. components: {
  919. selectType,
  920. WarehousingDialog
  921. },
  922. // 虚拟列表滚动方法
  923. directives: {
  924. 'el-table-infinite-scroll': elTableInfiniteScroll
  925. },
  926. props: {
  927. form: { type: Object, default: () => {} },
  928. bizType: { type: Number, default: 1 },
  929. sourceBizNo: { type: String, default: '' },
  930. detailList: { type: Array, default: () => [] },
  931. saleProductList: { type: Array, default: () => [] },
  932. detailProductList: { type: Array, default: () => [] }
  933. },
  934. data() {
  935. return {
  936. newColumns: [], // 动态表头
  937. sceneState,
  938. saveLoading: false,
  939. dateVisible: false,
  940. loadTree: true,
  941. visibleDialog: false,
  942. title: '选择产品',
  943. goodsLists: [],
  944. formData: {
  945. bizType: '',
  946. storageTime: '',
  947. extInfo: {
  948. assetType: []
  949. }
  950. },
  951. rules: {
  952. 'extInfo.assetType': {
  953. required: true,
  954. message: '请选择物品类型',
  955. trigger: 'blur'
  956. },
  957. bizType: {
  958. required: true,
  959. message: '请选择入库场景',
  960. trigger: 'change'
  961. }
  962. },
  963. qualityResultsOptions, // 质检结果选项
  964. qualityStatus, // 质检状态 0未检 1已检
  965. qualityResults, // 质检结果 0无 1合格 2不合格
  966. productList: [], // 产品列表
  967. packingList: [], // 包装列表
  968. showPackingList: [], // 包装列表(虚拟列表)
  969. materialList: [], // 物料列表
  970. showMaterialList: [], // 物料列表(虚拟列表)
  971. curDateType: 'productionDate',
  972. packingListSelected: [], // 包装选择列表
  973. isWrapTable: true, // 解决表格不刷新问题(包装)
  974. currentPackingQuantity: '', // 当前包装数量
  975. batchTime: '', // 生产日期、采购日期
  976. pageSize: 20, // 物料和包装列表条数
  977. pickingPageNum: 1, // 包装虚拟分页页数
  978. materielPageNum: 1 // 物料虚拟分页页数
  979. };
  980. },
  981. computed: {
  982. ...mapGetters(['dict', 'getDict']),
  983. clientEnvironmentId() {
  984. return this.$store.state.user.info.clientEnvironmentId;
  985. }
  986. },
  987. watch: {
  988. packingList: {
  989. handler(newVal) {
  990. console.log('包装列表', newVal);
  991. console.log('当前包装列表加载页数7', this.pickingPageNum);
  992. this.showPackingList = newVal.slice(
  993. 0,
  994. this.pageSize * (this.pickingPageNum > 0 ? this.pickingPageNum : 1)
  995. );
  996. this.showPackingList.forEach((obj) => {
  997. obj.workOrderId = this.detailProductList[0]?.workOrderId;
  998. obj.taskId = this.detailProductList[0]?.taskId;
  999. obj.outsourceBatchNo = this.detailProductList[0]?.batchNo;
  1000. obj.outsourceCode = this.detailProductList[0]?.sourceCode;
  1001. obj.taskId = this.detailList[0]?.taskId;
  1002. obj.workOrderId = this.detailList[0]?.workOrderId;
  1003. console.log('obj-------------------------------------', obj);
  1004. });
  1005. this.pickingPageNum = Math.ceil(
  1006. this.showPackingList.length / this.pageSize
  1007. );
  1008. },
  1009. deep: true
  1010. },
  1011. materialList: {
  1012. handler(newVal) {
  1013. console.log('物料列表', newVal);
  1014. console.log('当前物料列表加载页数', this.materielPageNum);
  1015. this.showMaterialList = newVal.slice(
  1016. 0,
  1017. this.pageSize *
  1018. (this.materielPageNum > 0 ? this.materielPageNum : 1)
  1019. );
  1020. },
  1021. deep: true
  1022. },
  1023. detailList: {
  1024. handler(newVal) {
  1025. if(newVal.length){
  1026. this.initFormData()
  1027. }
  1028. },
  1029. deep: true
  1030. }
  1031. },
  1032. async created() {
  1033. await this.requestDict('不拆物料层规格');
  1034. await this.getFieldModel();
  1035. await this.getListItems();
  1036. await this.initFormData();
  1037. await this.getNowFormatDate();
  1038. },
  1039. methods: {
  1040. ...mapActions('dict', ['requestDict']),
  1041. changeCount(number) {
  1042. return new BigNumber(number).toString();
  1043. },
  1044. selectSupplier(val, row) {
  1045. row.supplierId = val;
  1046. row.supplierName = row.supplierListOptions.filter(
  1047. (item) => item.id == val
  1048. )[0].name;
  1049. },
  1050. // 计算最小单元数量
  1051. computeNum(row, index, isClear) {
  1052. console.log(row);
  1053. console.log(row.packingQuantity);
  1054. console.log(row.packingUnit);
  1055. // 清空仓库(包装数量输入)
  1056. if (isClear) {
  1057. this.$set(this.productList[index], 'warehouseId', '');
  1058. this.$set(this.productList[index], 'warehouseName', '');
  1059. if (row.packingQuantity < 0) {
  1060. this.$set(this.productList[index], 'packingQuantity', 1);
  1061. } else if (row.packingQuantity > 9999) {
  1062. this.$set(this.productList[index], 'packingQuantity', 9999);
  1063. }
  1064. // else {
  1065. // this.$set(
  1066. // this.productList[index],
  1067. // 'packingQuantity',
  1068. // row.packingQuantity.replace(/[^\d\.{2,}]/g, '')
  1069. // );
  1070. // }
  1071. }
  1072. if (row.packingQuantity && row.packingUnit) {
  1073. console.log(index);
  1074. console.log(row.packingSpecificationOption);
  1075. let startIndex = row.packingSpecificationOption.findIndex((ite) => {
  1076. return (
  1077. row.measuringUnit == ite.packingUnit &&
  1078. ite.packingUnit != ite.conversionUnit
  1079. );
  1080. });
  1081. console.log(startIndex);
  1082. let endIndex = row.packingSpecificationOption.findIndex(
  1083. (ite) => row.packingUnit == ite.conversionUnit
  1084. );
  1085. console.log(endIndex);
  1086. let total = row.packingQuantity;
  1087. for (; startIndex < endIndex; endIndex--) {
  1088. total = this.$math.format(
  1089. row.packingSpecificationOption[endIndex].packageCell * total,
  1090. 14
  1091. );
  1092. }
  1093. row.measureQuantity = this.changeCount(total);
  1094. // 判断单位和计量单位是否为不拆物料层规格
  1095. let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
  1096. .dictValue;
  1097. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
  1098. .dictValue;
  1099. if (packingBoolen || measureBoolen) {
  1100. row.weight = total;
  1101. } else {
  1102. row.weight = this.$math.format(total * row.netWeight, 14);
  1103. }
  1104. }
  1105. },
  1106. // 获取动态表头
  1107. getFieldModel() {
  1108. storageApi.fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  1109. let newRes = res.map((m) => {
  1110. return {
  1111. prop: 'extField.' + m.prop,
  1112. label: m.label,
  1113. align: 'center',
  1114. showOverflowTooltip: true
  1115. };
  1116. });
  1117. this.newColumns = [...newRes];
  1118. });
  1119. },
  1120. // 初始化信息
  1121. async initFormData() {
  1122. console.log(4)
  1123. this.formData.type = 1;
  1124. this.formData.bizType = this.bizType;
  1125. this.formData.extInfo.assetType = Array.from(
  1126. new Set(this.form.categoryLevelTopId.split(','))
  1127. );
  1128. console.log('this.form---------------', this.form);
  1129. console.log('this.sourceBizNo---------', this.sourceBizNo);
  1130. console.log('this.saleProductList---------', this.saleProductList);
  1131. console.log('this.detailList---------', this.detailList);
  1132. this.formData.sourceBizNo = this.sourceBizNo;
  1133. // 入库登记人
  1134. this.formData.extInfo.createUserName = this.$store.state.user.info.name;
  1135. this.formData.createUserId = this.$store.state.user.info.userId;
  1136. // this.formData.extInfo.supplierName = this.form.supplierName;
  1137. // this.formData.extInfo.supplierId = this.form.supplierId;
  1138. if (this.saleProductList?.length > 0) {
  1139. // 物品列表 this.saleProductList
  1140. let codeList = this.saleProductList.map((item) => {
  1141. return item.productCode;
  1142. });
  1143. storageApi.getListByNameOrModeType({ codeList }).then(async (res) => {
  1144. console.log('res------------------', res);
  1145. // 获取批次号
  1146. const batchNo = await getCode('lot_number_code');
  1147. // 获取供应商
  1148. const supplierList = await storageApi.contactQueryByCategoryIdsAPI({
  1149. categoryIds: res.map((item) => item.id)
  1150. });
  1151. // 获取包装规格
  1152. let packingSpecification =
  1153. await storageApi.getCategoryPackageDisposition({
  1154. categoryIds: res.map((item) => item.id)
  1155. });
  1156. this.packingSpecificationOption = res.map((item) => {
  1157. return packingSpecification
  1158. .filter((ite) => item.id == ite.categoryId)
  1159. .sort((a, b) => a.sort - b.sort);
  1160. });
  1161. this.productList = res.map((item, index) => {
  1162. let filtersItem = this.saleProductList.filter(
  1163. (detailItem) => detailItem.productCode == item.code
  1164. )[0];
  1165. // 显示规格
  1166. let packingSpecificationLabel = this.packingSpecificationOption[
  1167. index
  1168. ]
  1169. .map((item) => {
  1170. if (item.sort > 0) {
  1171. return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
  1172. }
  1173. })
  1174. .filter((item) => !!item);
  1175. console.log('filtersItem---------', filtersItem);
  1176. let warehouseId = filtersItem.warehouseId;
  1177. let warehouseName = filtersItem.warehouseName;
  1178. let measureQuantity = filtersItem.totalCount || 0;
  1179. let packingQuantity = filtersItem.totalCount || 0;
  1180. let packingUnit = filtersItem.measuringUnit || '';
  1181. let price = filtersItem.singlePrice || 0;
  1182. let weight = filtersItem.sendTotalWeight || 0;
  1183. // 获取相同仓库
  1184. let warehouseIds = [];
  1185. let warehouseNames = [];
  1186. for (let i = 0; i < filtersItem.totalCount; i++) {
  1187. warehouseIds.push(filtersItem.warehouseId);
  1188. warehouseNames.push(filtersItem.warehouseName);
  1189. }
  1190. return {
  1191. index: this.productList.length + index,
  1192. categoryId: item.id, // 物品id
  1193. categoryName: item.name, // 物品名称
  1194. categoryCode: item.code, // 物品编码
  1195. categoryModel: item.modelType, // 物品型号
  1196. specification: item.specification, // 规格
  1197. brandNum: item.brandNum, // 牌号
  1198. batchNo: batchNo, // 批次号
  1199. supplierListOptions: supplierList[item.id], // 供应商列表
  1200. supplierId: this.form.supplierId, // 供应商id
  1201. supplierName: this.form.supplierName, // 供应商名称
  1202. approvalNumber: item.approvalNumber, // 批准文号
  1203. packingSpecification: item.packingSpecification, // 包装规格
  1204. packingSpecificationOption:
  1205. this.packingSpecificationOption[index], // 包装规格选项
  1206. packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
  1207. // minPackingQuantity: minPackingQuantity, // 最小包装单元数量
  1208. packingQuantity: packingQuantity, // 包装数量
  1209. packingUnit: packingUnit, // 单位
  1210. measureQuantity: measureQuantity, // 计量数量
  1211. measureUnit: item.measuringUnit, // 计量单位
  1212. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  1213. weight: weight, // 重量
  1214. weightUnit: item.weightUnit, // 重量单位
  1215. totalMoney: '', // 总价
  1216. price: item.price || price, // 单价
  1217. purpose: '', // 用途
  1218. isUnpack: item.isUnpack, // 是否允许拆包
  1219. warehouseId, // 仓库id
  1220. warehouseName, // 仓库名称
  1221. warehouseIds,
  1222. warehouseNames
  1223. };
  1224. });
  1225. this.$nextTick(() => {
  1226. this.listSaveArrs();
  1227. });
  1228. });
  1229. }
  1230. if (this.detailList?.length > 0) {
  1231. // 包装列表 this.detailList
  1232. // 获取主数据物品详情
  1233. // let { category } = await getDetails(this.form.categoryId);
  1234. // console.log(category);
  1235. console.log('this.form------------', this.form);
  1236. let codeList = this.detailList.map((item) => {
  1237. return item.productCode || item.categoryCode;
  1238. });
  1239. console.log('codeList-----------', codeList);
  1240. storageApi.getListByNameOrModeType({ codeList }).then(async (res) => {
  1241. console.log(
  1242. res,
  1243. 'ddddddddddddddddddddddddddddddddddddddddddddddddres'
  1244. );
  1245. // 获取批次号
  1246. const batchNo = await getCode('lot_number_code');
  1247. // 获取供应商
  1248. const supplierList = await storageApi.contactQueryByCategoryIdsAPI({
  1249. categoryIds: res.map((item) => item.id)
  1250. });
  1251. // 获取包装规格
  1252. let packingSpecification =
  1253. await storageApi.getCategoryPackageDisposition({
  1254. categoryIds: res.map((item) => item.id)
  1255. });
  1256. this.packingSpecificationOption = res.map((item) => {
  1257. return packingSpecification
  1258. .filter((ite) => item.id == ite.categoryId)
  1259. .sort((a, b) => a.sort - b.sort);
  1260. });
  1261. // 获取相同仓库
  1262. let warehouseIds = [];
  1263. let warehouseNames = [];
  1264. for (let index = 0; index < this.form.totalCount; index++) {
  1265. warehouseIds.push(this.form.warehouseId);
  1266. warehouseNames.push(this.form.warehouseName);
  1267. }
  1268. // 生成产品列表
  1269. this.productList = res.map((item, index) => {
  1270. // 显示规格
  1271. let packingSpecificationLabel = this.packingSpecificationOption[
  1272. index
  1273. ]
  1274. .map((item) => {
  1275. if (item.sort > 0) {
  1276. return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
  1277. }
  1278. })
  1279. .filter((item) => !!item);
  1280. // 换算重量
  1281. let weight = 0;
  1282. if (
  1283. this.form?.weightUnit?.toUpperCase() ==
  1284. item?.weightUnit.toUpperCase()
  1285. ) {
  1286. weight = this.form.totalWeight;
  1287. } else {
  1288. switch (item.weightUnit.toUpperCase()) {
  1289. case 'KG':
  1290. if (this.form.totalWeight > -1) {
  1291. weight = this.$math.format(
  1292. this.form.totalWeight / 1000,
  1293. 14
  1294. );
  1295. } else {
  1296. weight = 0;
  1297. }
  1298. break;
  1299. case 'G':
  1300. if (this.form.totalWeight > -1) {
  1301. weight = this.$math.format(
  1302. this.form.totalWeight * 1000,
  1303. 14
  1304. );
  1305. } else {
  1306. weight = 0;
  1307. }
  1308. break;
  1309. }
  1310. }
  1311. return {
  1312. index: this.productList.length + index,
  1313. isSave: true,
  1314. categoryId: item.id, // 物品id
  1315. categoryName: item.name, // 物品名称
  1316. categoryCode: item.code, // 物品编码
  1317. categoryModel: item.modelType, // 物品型号
  1318. specification: item.specification, // 规格
  1319. brandNum: item.brandNum, // 牌号
  1320. batchNo: batchNo, // 批次号
  1321. supplierListOptions: supplierList[item.id], // 供应商列表
  1322. supplierId: '', // 供应商id
  1323. supplierName: '', // 供应商名称
  1324. approvalNumber: item.approvalNumber, // 批准文号
  1325. packingSpecification: item.packingSpecification, // 包装规格
  1326. packingSpecificationOption:
  1327. this.packingSpecificationOption[index], // 包装规格选项
  1328. packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
  1329. // minPackingQuantity: 1, // 最小包装单元数量
  1330. packingQuantity:
  1331. this.detailList.length || this.form.detailList.length, // 包装数量
  1332. packingUnit: item.packingUnit, // 单位
  1333. measureQuantity: this.form.totalCount, // 计量数量
  1334. measureUnit: item.measuringUnit, // 计量单位
  1335. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  1336. weight: weight, // 重量
  1337. weightUnit: item.weightUnit, // 重量单位
  1338. totalMoney: '', // 总价
  1339. price: item.price, // 单价
  1340. purpose: '', // 用途
  1341. isUnpack: item.isUnpack, // 是否允许拆包
  1342. warehouseId: this.form.warehouseId, // 仓库id
  1343. warehouseName: this.form.warehouseName, // 仓库名称
  1344. warehouseIds,
  1345. warehouseNames
  1346. };
  1347. });
  1348. console.log(this.productList);
  1349. // 生成包装编码
  1350. const { data } = await storageApi.getAssetNum([
  1351. {
  1352. assetCode:
  1353. this.productList[0].categoryCode + this.productList[0].index,
  1354. batchNum: this.productList[0].batchNo,
  1355. num: this.detailList.length
  1356. }
  1357. ]);
  1358. let packingCodeList = data;
  1359. console.log('包装编码-------------------------', packingCodeList);
  1360. // 生产包装
  1361. this.packingList = this.detailList.map((item, index) => {
  1362. // 换算重量
  1363. let weight = 0;
  1364. if (
  1365. this.productList[0].weightUnit.toUpperCase() ==
  1366. item.weightUnit.toUpperCase()
  1367. ) {
  1368. weight = this.form.totalWeight;
  1369. } else {
  1370. switch (this.productList[0].weightUnit.toUpperCase()) {
  1371. case 'KG':
  1372. if (item.weightUnit > -1) {
  1373. weight = this.$math.format(item.weightUnit / 1000, 14);
  1374. } else {
  1375. weight = 0;
  1376. }
  1377. break;
  1378. case 'G':
  1379. if (item.weightUnit > -1) {
  1380. weight = this.$math.format(item.weightUnit * 1000, 14);
  1381. } else {
  1382. weight = 0;
  1383. }
  1384. break;
  1385. }
  1386. }
  1387. // 代入时间
  1388. let obj = this.getNowDate();
  1389. let productionDate = '';
  1390. let purchaseDate = '';
  1391. if (this.formData.bizType == '1') {
  1392. // 生产入库
  1393. productionDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  1394. this.curDateType = 'productionDate';
  1395. } else if (this.formData.bizType == '2') {
  1396. // 采购入库
  1397. purchaseDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  1398. this.curDateType = 'purchaseDate';
  1399. }
  1400. return {
  1401. index: this.productList[0].index + '-' + index, // 包装索引
  1402. warehouseId: this.productList[0].warehouseIds[index], // 仓库id
  1403. warehouseName: this.productList[0].warehouseNames[index], // 仓库名称
  1404. categoryName: this.productList[0].categoryName, // 产品名称
  1405. categoryCode: this.productList[0].categoryCode, // 产品编码
  1406. categoryModel: this.productList[0].categoryModel, // 物品型号
  1407. specification: this.productList[0].specification, // 规格
  1408. brandNum: this.productList[0].brandNum, // 牌号
  1409. parentIndex: this.productList[0].index, // 产品索引
  1410. batchNo: this.productList[0].batchNo, // 批次号
  1411. packageNo: packingCodeList[index].onlyCode, // 包装编码
  1412. packingQuantity: 1, // 包装数量
  1413. packingUnit: item.packingUnit, // 单位
  1414. measureQuantity: item.quantity, // 计量数量
  1415. measureUnit: item.measuringUnit, // 计量单位
  1416. weight: item.packingWeight, // 重量
  1417. weightUnit: this.productList[0].weightUnit, // 重量单位
  1418. packingSpecificationOption:
  1419. this.productList[0].packingSpecificationOption, // 包装规格
  1420. netWeight: this.productList[0].netWeight, // 净重
  1421. barcodes: item.sendCode, // 发货条码
  1422. clientCode: item.extInfo.clientCode, // 客户代号
  1423. materielDesignation: item.extInfo.materielCode, // 物料代号
  1424. engrave: item.extInfo.engrave, // 刻码
  1425. isUnpack: this.productList[0].isUnpack, // 是否允许拆包
  1426. productionDate: productionDate, // 生产日期
  1427. purchaseDate: purchaseDate, // 采购时间
  1428. result: 1, // 结果(1合格 2不合格)
  1429. status: 2 // 状态(0=未质检 1待检 2已检)
  1430. };
  1431. });
  1432. console.log('this.packingList--------', this.packingList);
  1433. });
  1434. }
  1435. },
  1436. // 获取当前时间函数
  1437. getNowDate() {
  1438. let date = new Date(),
  1439. obj = {
  1440. year: date.getFullYear(), //获取完整的年份(4位)
  1441. month: date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
  1442. strDate: date.getDate(), // 获取当前日(1-31)
  1443. hour: date.getHours(), //获取当前小时(0 ~ 23)
  1444. minute: date.getMinutes(), //获取当前分钟(0 ~ 59)
  1445. second: date.getSeconds() //获取当前秒数(0 ~ 59)
  1446. };
  1447. Object.keys(obj).forEach((key) => {
  1448. if (obj[key] < 10) obj[key] = `0${obj[key]}`;
  1449. });
  1450. return obj;
  1451. },
  1452. // 赋值入库时间
  1453. getNowFormatDate() {
  1454. let obj = this.getNowDate();
  1455. this.formData.storageTime = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  1456. },
  1457. // 获取物品列表
  1458. async getListItems() {
  1459. const { data } = await getTreeByGroup({ type: 2 });
  1460. this.goodsLists = data;
  1461. },
  1462. // 打开单据来源弹窗
  1463. openDocumentSourceDialog() {
  1464. console.log('打开单据来源弹窗');
  1465. },
  1466. // 清除单据来源
  1467. clearDocumentSource() {
  1468. this.formData.sourceBizNo = '';
  1469. },
  1470. // 添加产品
  1471. addProduct() {
  1472. if (this.formData.extInfo.assetType.length <= 0) {
  1473. return this.$message.error('请选择物品类型');
  1474. }
  1475. if (!this.formData.bizType) {
  1476. return this.$message.error('请选择入库类型');
  1477. }
  1478. this.visibleDialog = true;
  1479. },
  1480. // 键盘移动
  1481. moveFocus(event, index, key, type, row) {
  1482. let keyfield = [];
  1483. let listLength = 0;
  1484. switch (type) {
  1485. case '产品':
  1486. listLength = this.productList.length;
  1487. keyfield = ['batchNo', 'packingQuantity', 'price', 'purpose'];
  1488. break;
  1489. case '包装':
  1490. listLength = this.showPackingList.length;
  1491. if (row.measureUnit != row.weightUnit) {
  1492. keyfield = [
  1493. 'packing_materielDesignation',
  1494. 'packing_clientCode',
  1495. 'packing_engrave',
  1496. 'packing_weight'
  1497. ];
  1498. } else {
  1499. keyfield = [
  1500. 'packing_materielDesignation',
  1501. 'packing_clientCode',
  1502. 'packing_engrave'
  1503. ];
  1504. }
  1505. break;
  1506. case '物料':
  1507. listLength = this.showMaterialList.length;
  1508. if (row.measureUnit != row.weightUnit) {
  1509. keyfield = [
  1510. 'material_materielDesignation',
  1511. 'material_clientCode',
  1512. 'material_engrave',
  1513. 'material_weight'
  1514. ];
  1515. } else {
  1516. keyfield = [
  1517. 'material_materielDesignation',
  1518. 'material_clientCode',
  1519. 'material_engrave'
  1520. ];
  1521. }
  1522. break;
  1523. }
  1524. if (event.keyCode === 13) {
  1525. // 回车
  1526. if (
  1527. index === listLength - 1 &&
  1528. key === keyfield[keyfield.length - 1]
  1529. ) {
  1530. // 最后一行最后一个
  1531. return;
  1532. }
  1533. this.$refs[key + index].blur();
  1534. if (key === keyfield[keyfield.length - 1]) {
  1535. // 当前行最后一个,跳转下一行第一个
  1536. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  1537. this.$refs[keyfield[0] + (index + 1)].value = '';
  1538. }
  1539. this.$refs[keyfield[0] + (index + 1)].focus();
  1540. } else {
  1541. // 跳转下一个
  1542. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  1543. this.$nextTick(() => {
  1544. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  1545. this.$refs[keyfield[nextkeyindex] + index].value = '';
  1546. }
  1547. this.$refs[keyfield[nextkeyindex] + index].focus();
  1548. });
  1549. }
  1550. }
  1551. // 向上 =38
  1552. if (event.keyCode === 38) {
  1553. console.log('向上');
  1554. if (index === 0) {
  1555. // 第一行
  1556. console.log('第一行无法向上');
  1557. return;
  1558. }
  1559. this.$refs[key + index].blur();
  1560. this.$nextTick(() => {
  1561. if (this.$refs[key + (index - 1)].value == 0) {
  1562. this.$refs[key + (index - 1)].value = '';
  1563. }
  1564. this.$refs[key + (index - 1)].focus();
  1565. });
  1566. }
  1567. // 下 = 40
  1568. if (event.keyCode === 40) {
  1569. console.log('向下');
  1570. if (index === listLength - 1) {
  1571. // 最后一行
  1572. console.log('最后一行无法向下');
  1573. return;
  1574. }
  1575. this.$refs[key + index].blur();
  1576. this.$nextTick(() => {
  1577. if (this.$refs[key + (index + 1)].value == 0) {
  1578. this.$refs[key + (index + 1)].value = '';
  1579. }
  1580. this.$refs[key + (index + 1)].focus();
  1581. });
  1582. }
  1583. // 左 = 37
  1584. if (event.keyCode === 37) {
  1585. console.log('向左');
  1586. if (index === 0 && key === keyfield[0]) {
  1587. // 第一行第一个
  1588. console.log('第一行第一个无法向左');
  1589. return;
  1590. }
  1591. this.$refs[key + index].blur();
  1592. if (key === keyfield[0]) {
  1593. if (
  1594. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value == 0
  1595. ) {
  1596. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value =
  1597. '';
  1598. }
  1599. // 当前行第一个,跳转上一行最后一个
  1600. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].focus();
  1601. } else {
  1602. // 跳转上一个
  1603. const prevkeyindex = keyfield.findIndex((k) => k === key) - 1;
  1604. this.$nextTick(() => {
  1605. if (this.$refs[keyfield[prevkeyindex] + index].value == 0) {
  1606. this.$refs[keyfield[prevkeyindex] + index].value = '';
  1607. }
  1608. this.$refs[keyfield[prevkeyindex] + index].focus();
  1609. });
  1610. }
  1611. }
  1612. // 右 = 39
  1613. if (event.keyCode === 39) {
  1614. console.log('向右');
  1615. if (
  1616. index === listLength - 1 &&
  1617. key === keyfield[keyfield.length - 1]
  1618. ) {
  1619. // 最后一行最后一个
  1620. console.log('最后一行最后一个无法向左');
  1621. return;
  1622. }
  1623. console.log(this.$refs);
  1624. this.$refs[key + index].blur();
  1625. if (key === keyfield[keyfield.length - 1]) {
  1626. // 当前行最后一个,跳转下一行第一个
  1627. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  1628. this.$refs[keyfield[0] + (index + 1)].value = '';
  1629. }
  1630. this.$refs[keyfield[0] + (index + 1)].focus();
  1631. } else {
  1632. // 跳转下一个
  1633. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  1634. this.$nextTick(() => {
  1635. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  1636. this.$refs[keyfield[nextkeyindex] + index].value = '';
  1637. }
  1638. this.$refs[keyfield[nextkeyindex] + index].focus();
  1639. });
  1640. }
  1641. }
  1642. },
  1643. // 入库
  1644. getReturnStorage() {
  1645. return new Promise((resolve) => {
  1646. console.log(this.productList);
  1647. if (this.productList.length <= 0) {
  1648. this.$message.error('请先添加产品信息');
  1649. return;
  1650. }
  1651. let boolen = this.productList.every((item) => item.isSave);
  1652. if (!boolen) {
  1653. this.$message.error('请先保存所有产品信息');
  1654. return;
  1655. }
  1656. console.log('ysy_ bizType', this.bizType);
  1657. console.log('ysy_初始 detailList', this.detailList[0]);
  1658. console.log('ysy_初始 detailProductList', this.detailProductList[0]);
  1659. // 处理包装数据
  1660. let _packingList = [];
  1661. _packingList = this.packingList.map((packingItem) => {
  1662. let _taskId = null;
  1663. let _workOrderId = null;
  1664. if ([1].includes(this.bizType)) {
  1665. _workOrderId = this.detailList[0]?.workOrderId;
  1666. _taskId = this.detailList[0]?.taskId;
  1667. } else {
  1668. _workOrderId = this.detailProductList[0]?.workOrderId;
  1669. _taskId = this.detailProductList[0]?.taskId;
  1670. }
  1671. // workOrderId: this.detailProductList[0]?.workOrderId,
  1672. // taskId: this.detailProductList[0]?.taskId,
  1673. // taskId: this.detailList[0]?.taskId,
  1674. // workOrderId: this.detailList[0]?.workOrderId,
  1675. return {
  1676. ...packingItem,
  1677. workOrderId: _workOrderId,
  1678. taskId: _taskId,
  1679. outsourceBatchNo: this.detailProductList[0]?.batchNo,
  1680. outsourceCode: this.detailProductList[0]?.sourceCode,
  1681. materialDetailList: this.materialList.filter(
  1682. (item) => item.parentIndex === packingItem.index
  1683. )
  1684. };
  1685. });
  1686. console.log('ysy_处理后 _packingList', _packingList);
  1687. // 处理产品数据
  1688. this.productList = this.productList.map((productItem) => {
  1689. return {
  1690. ...productItem,
  1691. outInDetailRecordRequestList: _packingList.filter(
  1692. (item) => item.parentIndex === productItem.index
  1693. )
  1694. };
  1695. });
  1696. this.formData.outInDetailList = this.productList;
  1697. let obj = deepClone(this.formData);
  1698. // 处理物品类型assetType
  1699. obj.extInfo.assetType = obj.extInfo.assetType.join(',');
  1700. // 处理仓库id
  1701. let warehouseId = [];
  1702. let warehouseName = [];
  1703. let warehouseIds = this.productList
  1704. .map((item) => item.warehouseIds)
  1705. .flat();
  1706. let warehouseNames = this.productList
  1707. .map((item) => item.warehouseNames)
  1708. .flat();
  1709. warehouseIds.forEach((item, index) => {
  1710. if (!warehouseId.includes(item)) {
  1711. warehouseId.push(item);
  1712. warehouseName.push(warehouseNames[index]);
  1713. }
  1714. });
  1715. obj.warehouseIds = warehouseId;
  1716. obj.warehouseNames = warehouseName;
  1717. console.log('yyyyy', obj);
  1718. setTimeout(() => {
  1719. resolve(obj);
  1720. }, 1000);
  1721. });
  1722. },
  1723. pickingHandleScroll() {
  1724. console.log('---------pickingHandleScroll------------');
  1725. if (this.showPackingList.length < this.packingList.length) {
  1726. if (this.packingList.length > this.pageSize) {
  1727. this.pickingPageNum += 1;
  1728. }
  1729. this.pickingFetchData();
  1730. }
  1731. },
  1732. pickingFetchData() {
  1733. const start = (this.pickingPageNum - 1) * this.pageSize;
  1734. const end = start + this.pageSize;
  1735. this.showPackingList = this.showPackingList.concat(
  1736. this.packingList.slice(start, end)
  1737. );
  1738. console.log(
  1739. this.showPackingList,
  1740. '999999999999999999999999999999999999'
  1741. );
  1742. },
  1743. materielHandleScroll() {
  1744. console.log('---------materielHandleScroll------------');
  1745. if (this.showMaterialList.length < this.materialList.length) {
  1746. if (this.materialList.length > this.pageSize) {
  1747. this.materielPageNum += 1;
  1748. }
  1749. this.materielFetchData();
  1750. }
  1751. },
  1752. materielFetchData() {
  1753. const start = (this.materielPageNum - 1) * this.pageSize;
  1754. const end = start + this.pageSize;
  1755. this.showMaterialList = this.showMaterialList.concat(
  1756. this.materialList.slice(start, end)
  1757. );
  1758. console.log(this.showMaterialList);
  1759. },
  1760. // 日期选择
  1761. dateConfirm() {
  1762. this.packingListSelected.forEach((item) => {
  1763. this.$set(item, this.curDateType, this.batchTime);
  1764. });
  1765. this.batchTime = '';
  1766. this.dateVisible = false;
  1767. },
  1768. // 包装重量修改
  1769. packingWeightCahnge(value, row) {
  1770. // 修改物品重量
  1771. let filterPackingList = this.packingList.filter((item) => {
  1772. return item.parentIndex === row.parentIndex;
  1773. });
  1774. let productIndex = this.productList.findIndex((item) => {
  1775. return item.index === row.parentIndex;
  1776. });
  1777. let totalWeight = filterPackingList.reduce(
  1778. (accumulator, currentValue) => {
  1779. return this.$math.format(+accumulator + +currentValue.weight, 14);
  1780. },
  1781. 0
  1782. );
  1783. this.$set(this.productList[productIndex], 'weight', totalWeight);
  1784. // 修改拆分物料
  1785. this.materialList.map((item, index) => {
  1786. if (item.parentIndex === row.index) {
  1787. console.log(value / row.measureQuantity);
  1788. this.$set(
  1789. this.materialList[index],
  1790. 'weight',
  1791. this.$math.format(value / row.measureQuantity, 14) >= 0
  1792. ? this.$math.format(value / row.measureQuantity, 14)
  1793. : 0
  1794. );
  1795. }
  1796. });
  1797. },
  1798. // 物料重量修改
  1799. materialWeightCahnge(row) {
  1800. // 修改包装重量
  1801. let filterMaterialList = this.materialList.filter((item) => {
  1802. return item.parentIndex === row.parentIndex;
  1803. });
  1804. let packingIndex = this.packingList.findIndex((item) => {
  1805. return item.index === row.parentIndex;
  1806. });
  1807. let totalMaterialWeight = filterMaterialList.reduce(
  1808. (accumulator, currentValue) => {
  1809. return this.$math.format(+accumulator + +currentValue.weight, 14);
  1810. },
  1811. 0
  1812. );
  1813. this.$set(
  1814. this.packingList[packingIndex],
  1815. 'weight',
  1816. totalMaterialWeight
  1817. );
  1818. // 修改物品重量
  1819. let filterPackingList = this.packingList.filter((item) => {
  1820. return (
  1821. item.parentIndex === this.packingList[packingIndex].parentIndex
  1822. );
  1823. });
  1824. let productIndex = this.productList.findIndex((item) => {
  1825. return item.index === this.packingList[packingIndex].parentIndex;
  1826. });
  1827. let totalWeight = filterPackingList.reduce(
  1828. (accumulator, currentValue) => {
  1829. return this.$math.format(+accumulator + +currentValue.weight, 14);
  1830. },
  1831. 0
  1832. );
  1833. this.$set(this.productList[productIndex], 'weight', totalWeight);
  1834. },
  1835. // 包装质检结果修改
  1836. packingResultCahnge(value, row) {
  1837. // 修改物料质检结果(0无 1合格 2不合格)
  1838. this.materialList.map((item, index) => {
  1839. if (item.parentIndex === row.index) {
  1840. this.$set(this.materialList[index], 'result', value);
  1841. this.$set(this.materialList[index], 'status', 2);
  1842. }
  1843. });
  1844. },
  1845. // 物料质量结果修改
  1846. materialResultCahnge(value, row) {
  1847. // 修改包装质检结果
  1848. let filterMaterialList = this.materialList.filter((item) => {
  1849. return item.parentIndex == row.parentIndex;
  1850. });
  1851. let packingIndex = this.packingList.findIndex((item) => {
  1852. return item.index == row.parentIndex;
  1853. });
  1854. let boolen = filterMaterialList.every((item) => {
  1855. return item.result == 1;
  1856. });
  1857. this.$set(this.packingList[packingIndex], 'result', boolen ? 1 : 2);
  1858. this.$set(this.packingList[packingIndex], 'status', 2);
  1859. },
  1860. // 重量限制
  1861. weightInput(value, row, type) {
  1862. const newValue = value.replace(/[^\d.]/g, ''); // 保留数字和小数点
  1863. const decimalCount = (newValue.match(/\./g) || []).length; // 计算小数点的个数
  1864. if (row.weight < 0) {
  1865. row.weight = 0;
  1866. } else if (row.weight > 9999) {
  1867. row.weight = 9999;
  1868. } else {
  1869. if (decimalCount > 1) {
  1870. // 如果小数点个数大于1,移除多余的小数点
  1871. const lastIndex = newValue.lastIndexOf('.');
  1872. row.weight =
  1873. newValue.slice(0, lastIndex) + newValue.slice(lastIndex + 1);
  1874. } else if (decimalCount === 1) {
  1875. // 如果小数点个数等于1,允许小数点的输入
  1876. row.weight = newValue;
  1877. } else {
  1878. row.weight = newValue === '' ? 0 : parseFloat(newValue); // 如果输入为空,则设为0
  1879. }
  1880. }
  1881. if (type === '包装') {
  1882. this.packingWeightCahnge(value, row);
  1883. } else {
  1884. this.materialWeightCahnge(row);
  1885. }
  1886. },
  1887. //计算金额
  1888. calcSumTotal(measureQuantity, price, row) {
  1889. //最小包装单元,包装数量,单价
  1890. const total = {
  1891. measureQuantity: Number(measureQuantity > 0 ? measureQuantity : 0),
  1892. price: Number(price > 0 ? price : 0)
  1893. };
  1894. let number = Number(
  1895. this.$math.format(total.measureQuantity * total.price, 14)
  1896. );
  1897. row.totalMoney = number;
  1898. return number;
  1899. },
  1900. // 包装维度最小包装单元改变——>总重量
  1901. minPackingQuantityChange(row, value, index) {
  1902. console.log(value);
  1903. if (row.measureUnit !== 'KG') {
  1904. if (value.replace(/^(0+)|[^\d]+/g, '') > 9999) {
  1905. this.$set(this.productList[index], 'minPackingQuantity', 9999);
  1906. } else {
  1907. this.$set(
  1908. this.productList[index],
  1909. 'minPackingQuantity',
  1910. value.replace(/^(0+)|[^\d]+/g, '')
  1911. );
  1912. }
  1913. } else {
  1914. if (value < 1) {
  1915. this.$set(this.productList[index], 'minPackingQuantity', 1);
  1916. } else if (value > 9999) {
  1917. this.$set(this.productList[index], 'minPackingQuantity', 9999);
  1918. }
  1919. }
  1920. if (row.packingQuantity >= 0 && value >= 0) {
  1921. this.packNum(row, row.packingQuantity, index);
  1922. }
  1923. },
  1924. // 包装数量过滤处理改变——>总重量
  1925. packNum(row, value, index) {
  1926. const total = {
  1927. minPackingQuantity: Number(
  1928. row.minPackingQuantity > 0
  1929. ? row.minPackingQuantity > 9999
  1930. ? 9999
  1931. : row.minPackingQuantity
  1932. : 0
  1933. ),
  1934. packingQuantity: Number(
  1935. row.packingQuantity > 0
  1936. ? row.packingQuantity > 9999
  1937. ? 9999
  1938. : row.packingQuantity
  1939. : 0
  1940. )
  1941. };
  1942. const totals = Number(
  1943. this.$math.format(
  1944. total.minPackingQuantity * total.packingQuantity,
  1945. 14
  1946. )
  1947. );
  1948. if (row.measureUnit == row.weightUnit) {
  1949. row.weight = Number(
  1950. this.$math.format(
  1951. total.minPackingQuantity *
  1952. 1 *
  1953. Number(total.packingQuantity).toFixed(2),
  1954. 14
  1955. )
  1956. );
  1957. } else {
  1958. row.weight = Number(
  1959. this.$math.format(
  1960. totals *
  1961. (row.netWeight > 0 ? Number(row.netWeight).toFixed(2) : 0),
  1962. 14
  1963. )
  1964. );
  1965. }
  1966. this.$set(this.productList[index], 'measureQuantity', totals);
  1967. // 清空仓库
  1968. this.$set(this.productList[index], 'warehouseId', '');
  1969. this.$set(this.productList[index], 'warehouseName', '');
  1970. if (value.replace(/^(0+)|[^\d]+/g, '') > 9999) {
  1971. this.$set(this.productList[index], 'packingQuantity', 9999);
  1972. } else {
  1973. this.$set(
  1974. this.productList[index],
  1975. 'packingQuantity',
  1976. value.replace(/^(0+)|[^\d]+/g, '')
  1977. );
  1978. }
  1979. // return (row.packingQuantity = value.replace(/^(0+)|[^\d]+/g, ''));
  1980. },
  1981. // 表格样式
  1982. rowClass({ row, column, rowIndex, columnIndex }) {
  1983. if (rowIndex === 1) {
  1984. return {
  1985. display: 'none',
  1986. background: '#EEEEEE'
  1987. };
  1988. }
  1989. return { background: '#0000' };
  1990. },
  1991. // 添加物品明细
  1992. async addGoods(data) {
  1993. // 获取批次号
  1994. const batchNo = await getCode('lot_number_code');
  1995. // 获取供应商
  1996. const supplierList = await storageApi.contactQueryByCategoryIdsAPI({
  1997. categoryIds: data.map((item) => item.id)
  1998. });
  1999. // 获取包装规格
  2000. let packingSpecification =
  2001. await storageApi.getCategoryPackageDisposition({
  2002. categoryIds: data.map((item) => item.id)
  2003. });
  2004. this.packingSpecificationOption = data.map((item) => {
  2005. return packingSpecification
  2006. .filter((ite) => item.id == ite.categoryId)
  2007. .sort((a, b) => a.sort - b.sort);
  2008. });
  2009. console.log(
  2010. 'this.packingSpecificationOption-------',
  2011. this.packingSpecificationOption
  2012. );
  2013. console.log('this.productList.length------', this.productList.length);
  2014. let productList = data.map((item, index) => {
  2015. // 显示规格
  2016. let packingSpecificationLabel = this.packingSpecificationOption[index]
  2017. .map((item) => {
  2018. if (item.sort > 0) {
  2019. return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
  2020. }
  2021. })
  2022. .filter((item) => !!item);
  2023. return {
  2024. index:
  2025. this.productList.length - 1 > -1
  2026. ? this.productList[this.productList.length - 1].index +
  2027. index +
  2028. 1
  2029. : this.productList.length + index,
  2030. categoryId: item.id, // 物品id
  2031. categoryName: item.name, // 物品名称
  2032. categoryCode: item.code, // 物品编码
  2033. categoryModel: item.modelType, // 物品型号
  2034. specification: item.specification, // 规格
  2035. brandNum: item.brandNum, // 牌号
  2036. batchNo: batchNo, // 批次号
  2037. supplierListOptions: supplierList[item.id], // 供应商列表
  2038. supplierId: '', // 供应商id
  2039. supplierName: '', // 供应商名称
  2040. approvalNumber: item.approvalNumber, // 批准文号
  2041. packingSpecification: item.packingSpecification, // 包装规格
  2042. packingSpecificationOption: this.packingSpecificationOption[index], // 包装规格选项
  2043. packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
  2044. minPackingQuantity: '', // 最小包装单元数量
  2045. packingQuantity: '', // 包装数量
  2046. packingUnit: '', // 单位
  2047. measureQuantity: 0, // 计量数量
  2048. measureUnit: item.measuringUnit, // 计量单位
  2049. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  2050. weight: 0, // 重量
  2051. weightUnit: item.weightUnit, // 重量单位
  2052. totalMoney: '', // 总价
  2053. price: item.price, // 单价
  2054. purpose: '', // 用途
  2055. isUnpack: item.isUnpack // 是否允许拆包
  2056. };
  2057. });
  2058. this.productList = this.productList.concat(productList);
  2059. console.log('this.productList--------', this.productList);
  2060. },
  2061. // 物品保存验证表单(批量)
  2062. validateForm() {
  2063. return new Promise(async (resolve, reject) => {
  2064. let list = this.productList.map(async (row, index) => {
  2065. let fileds = [
  2066. `productList.${index}.batchNo`,
  2067. `productList.${index}.packingQuantity`,
  2068. `productList.${index}.packingUnit`,
  2069. `productList.${index}.warehouseId`
  2070. ];
  2071. console.log(fileds);
  2072. if (row.isSave) {
  2073. return Promise.resolve(true);
  2074. } else {
  2075. return await Promise.all(
  2076. fileds.map(
  2077. (item) =>
  2078. new Promise(async (res, rej) => {
  2079. this.$refs.productListRef.validateField(item, (err) => {
  2080. if (err) {
  2081. rej(err);
  2082. } else {
  2083. res(true);
  2084. }
  2085. });
  2086. })
  2087. )
  2088. );
  2089. }
  2090. });
  2091. console.log(list);
  2092. Promise.all(list)
  2093. .then(() => {
  2094. console.log('保存成功!');
  2095. resolve();
  2096. })
  2097. .catch((err) => {
  2098. console.log('保存失败!');
  2099. this.$message.error('请填入必填项!');
  2100. reject(err);
  2101. });
  2102. });
  2103. },
  2104. // 产品批量保存
  2105. async listSaveArrs() {
  2106. this.validateForm()
  2107. .then(async () => {
  2108. // 批量获取包装编码并处理
  2109. let packingCodePrams = this.productList.map((row) => {
  2110. // 判断单位和计量单位是否为不拆物料层规格
  2111. let packingBoolen = !!this.getDict(
  2112. '不拆物料层规格',
  2113. row.packingUnit
  2114. ).dictValue;
  2115. let measureBoolen = !!this.getDict(
  2116. '不拆物料层规格',
  2117. row.measureUnit
  2118. ).dictValue;
  2119. let num = 0;
  2120. if (packingBoolen) {
  2121. let filterArr = row.packingSpecificationOption.filter(
  2122. (item) => {
  2123. return (
  2124. item.packageUnit == row.packingUnit &&
  2125. item.packageUnit != item.conversionUnit
  2126. );
  2127. }
  2128. );
  2129. num = Math.ceil(row.packingQuantity / filterArr[0].packageCell);
  2130. }
  2131. if (row.isSave) {
  2132. return {};
  2133. } else {
  2134. // 处理单位为KG类的情况
  2135. if (packingBoolen) {
  2136. return {
  2137. assetCode: row.categoryCode + row.index,
  2138. batchNum: row.batchNo,
  2139. num
  2140. };
  2141. } else {
  2142. if (row.isUnpack) {
  2143. if (measureBoolen) {
  2144. // 处理单位不为KG类,计量单位为KG类的情况
  2145. let num = row.packingQuantity;
  2146. let splitIndex = row.packingSpecificationOption.findIndex(
  2147. (item) =>
  2148. item.conversionUnit == row.packingUnit &&
  2149. item.packageUnit != item.conversionUnit
  2150. );
  2151. for (; splitIndex > 1; splitIndex--) {
  2152. num = this.$math.format(
  2153. num *
  2154. row.packingSpecificationOption[splitIndex]
  2155. .packageCell,
  2156. 14
  2157. );
  2158. }
  2159. return {
  2160. assetCode: row.categoryCode + row.index,
  2161. batchNum: row.batchNo,
  2162. num
  2163. };
  2164. } else {
  2165. // 处理拆包到最小包装单元数量的情况
  2166. return {
  2167. assetCode: row.categoryCode + row.index,
  2168. batchNum: row.batchNo,
  2169. num: row.measureQuantity
  2170. };
  2171. }
  2172. } else {
  2173. return {
  2174. assetCode: row.categoryCode + row.index,
  2175. batchNum: row.batchNo,
  2176. num: row.packingQuantity
  2177. };
  2178. }
  2179. }
  2180. }
  2181. });
  2182. let filterPackingCodePrams = packingCodePrams.filter(
  2183. (item) => item.assetCode
  2184. );
  2185. let { data } = await storageApi.getAssetNum(filterPackingCodePrams);
  2186. console.log('data-----11111111111111111---', data);
  2187. let packingCodeList = [];
  2188. packingCodePrams.forEach((item, index) => {
  2189. packingCodeList[index] = data.filter(
  2190. (ite) => ite.assetCode == item.assetCode
  2191. );
  2192. });
  2193. // 批量生成包装
  2194. this.productList.map((row, index) => {
  2195. if (!row.isSave) {
  2196. this.generateWrappers(row, index, packingCodeList[index]);
  2197. this.$set(this.productList[index], 'isSave', true);
  2198. }
  2199. });
  2200. // 加载虚拟列表数据(分页)
  2201. // this.pickingFetchData();
  2202. // this.materielFetchData();
  2203. })
  2204. .catch((err) => {
  2205. console.log(err);
  2206. });
  2207. },
  2208. // 物品保存验证表单(单独)
  2209. validateFormIndividually(index) {
  2210. return new Promise(async (resolve) => {
  2211. console.log(index);
  2212. let fileds = [
  2213. `productList.${index}.batchNo`,
  2214. `productList.${index}.packingQuantity`,
  2215. `productList.${index}.packingUnit`,
  2216. `productList.${index}.warehouseId`
  2217. ];
  2218. Promise.all(
  2219. fileds.map(
  2220. (item) =>
  2221. new Promise(async (res, rej) => {
  2222. this.$refs.productListRef.validateField(item, (err) => {
  2223. if (err) {
  2224. rej(err);
  2225. } else {
  2226. res(true);
  2227. }
  2228. });
  2229. })
  2230. )
  2231. )
  2232. .then(() => {
  2233. resolve();
  2234. })
  2235. .catch(() => {
  2236. this.$message.error('请填入必填项!');
  2237. });
  2238. });
  2239. },
  2240. // 产品编辑
  2241. listEdit(row) {
  2242. console.log(row);
  2243. this.$set(row, 'isSave', false);
  2244. // // 重新计算重量
  2245. // const totals = Number(
  2246. // this.$math.format(row.minPackingQuantity * row.packingQuantity, 14)
  2247. // );
  2248. // if (row.measureUnit == row.weightUnit) {
  2249. // row.weight = Number(
  2250. // this.$math.format(
  2251. // row.minPackingQuantity *
  2252. // 1 *
  2253. // Number(row.packingQuantity).toFixed(2),
  2254. // 14
  2255. // )
  2256. // );
  2257. // } else {
  2258. // row.weight = Number(
  2259. // this.$math.format(
  2260. // totals *
  2261. // (row.netWeight > 0 ? Number(row.netWeight).toFixed(2) : 0),
  2262. // 14
  2263. // )
  2264. // );
  2265. // }
  2266. console.log(row);
  2267. this.deletePackingAndMaterial(row);
  2268. },
  2269. // 根据产品信息删除包装和物料
  2270. deletePackingAndMaterial(row) {
  2271. console.log('row--------', row);
  2272. console.log('packingList------', this.packingList);
  2273. // 删除包装(去掉不相同的包装)
  2274. this.packingList = this.packingList.filter(
  2275. (item) => item.parentIndex !== row.index
  2276. );
  2277. this.showPackingList = this.showPackingList.filter(
  2278. (item) => item.parentIndex !== row.index
  2279. );
  2280. this.pickingPageNum = Math.ceil(
  2281. this.showPackingList.length / this.pageSize
  2282. );
  2283. console.log('包装当前页数');
  2284. console.log(this.pickingPageNum);
  2285. // 删除物料(获取相同物料)
  2286. let packingIndexs = this.packingList.map((item) => item.index);
  2287. this.materialList = this.materialList.filter((item) =>
  2288. packingIndexs.includes(item.parentIndex)
  2289. );
  2290. this.showMaterialList = this.showMaterialList.filter((item) =>
  2291. packingIndexs.includes(item.parentIndex)
  2292. );
  2293. this.materielPageNum = Math.ceil(
  2294. this.showMaterialList.length / this.pageSize
  2295. );
  2296. console.log('物料当前页数');
  2297. console.log(this.showMaterialList.length);
  2298. console.log(this.pageSize);
  2299. console.log(this.materielPageNum);
  2300. },
  2301. // 产品保存操作
  2302. listSave(row, index) {
  2303. console.log('row', row);
  2304. this.validateFormIndividually(index).then(async () => {
  2305. // 判断单位和计量单位是否为不拆物料层规格
  2306. let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
  2307. .dictValue;
  2308. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
  2309. .dictValue;
  2310. let packingNum = 0;
  2311. // 处理单位为KG类的情况
  2312. if (packingBoolen) {
  2313. let filterArr = row.packingSpecificationOption.filter((item) => {
  2314. return (
  2315. item.packageUnit == row.packingUnit &&
  2316. item.packageUnit != item.conversionUnit
  2317. );
  2318. });
  2319. packingNum = Math.ceil(
  2320. row.packingQuantity / filterArr[0].packageCell
  2321. );
  2322. }
  2323. // 处理单位不为KG类,计量单位为KG类的情况
  2324. let measureNum = row.packingQuantity;
  2325. if (measureBoolen) {
  2326. let splitIndex = row.packingSpecificationOption.findIndex(
  2327. (item) =>
  2328. item.conversionUnit == row.packingUnit &&
  2329. item.packageUnit != item.conversionUnit
  2330. );
  2331. for (; splitIndex > 1; splitIndex--) {
  2332. measureNum = this.$math.format(
  2333. measureNum *
  2334. row.packingSpecificationOption[splitIndex].packageCell,
  2335. 14
  2336. );
  2337. }
  2338. }
  2339. // 获取包装编码列表
  2340. const { data } = await storageApi.getAssetNum([
  2341. {
  2342. assetCode: row.categoryCode + row.index,
  2343. batchNum: row.batchNo,
  2344. num: packingBoolen
  2345. ? packingNum
  2346. : row.isUnpack
  2347. ? measureBoolen
  2348. ? measureNum
  2349. : row.measureQuantity
  2350. : row.packingQuantity
  2351. }
  2352. ]);
  2353. this.generateWrappers(row, index, data);
  2354. this.$set(this.productList[index], 'isSave', true);
  2355. // 加载虚拟列表数据(分页)
  2356. // this.pickingFetchData();
  2357. // this.materielFetchData();
  2358. });
  2359. },
  2360. //入库明细删除
  2361. listDel(row, index) {
  2362. this.productList.splice(index, 1);
  2363. this.deletePackingAndMaterial(row);
  2364. },
  2365. // 打开仓库弹框
  2366. handleWareHouse(row, idx) {
  2367. if (row.isSave) {
  2368. return false;
  2369. }
  2370. let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
  2371. .dictValue;
  2372. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
  2373. .dictValue;
  2374. if (idx > -1) {
  2375. if (row.packingQuantity > 0) {
  2376. if (packingBoolen) {
  2377. let filterArr = row.packingSpecificationOption.filter((item) => {
  2378. return (
  2379. item.packageUnit == row.packingUnit &&
  2380. item.packageUnit != item.conversionUnit
  2381. );
  2382. });
  2383. console.log(filterArr);
  2384. let num = Math.ceil(
  2385. row.packingQuantity / filterArr[0].packageCell
  2386. );
  2387. this.$refs.wareHouseDailogRef.open(num, idx);
  2388. } else {
  2389. let num = row.packingQuantity;
  2390. if (measureBoolen) {
  2391. let splitIndex = row.packingSpecificationOption.findIndex(
  2392. (item) =>
  2393. item.conversionUnit == row.packingUnit &&
  2394. item.packageUnit != item.conversionUnit
  2395. );
  2396. console.log(splitIndex);
  2397. for (; splitIndex > 1; splitIndex--) {
  2398. console.log(splitIndex);
  2399. num = this.$math.format(
  2400. num *
  2401. row.packingSpecificationOption[splitIndex].packageCell,
  2402. 14
  2403. );
  2404. }
  2405. }
  2406. this.$refs.wareHouseDailogRef.open(
  2407. row.isUnpack
  2408. ? measureBoolen
  2409. ? num
  2410. : row.measureQuantity
  2411. : row.packingQuantity,
  2412. idx
  2413. );
  2414. }
  2415. } else {
  2416. this.$message.error('请先填写包装数量!');
  2417. }
  2418. } else {
  2419. // 批量设置
  2420. let boolen = this.productList.every(
  2421. (item) =>
  2422. item.packingQuantity == this.productList[0].packingQuantity
  2423. );
  2424. if (boolen) {
  2425. if (row.packingQuantity > 0) {
  2426. if (packingBoolen) {
  2427. let filterArr = row.packingSpecificationOption.filter(
  2428. (item) => {
  2429. return (
  2430. item.packingUnit == row.packingUnit &&
  2431. item.packingUnit != item.conversionUnit
  2432. );
  2433. }
  2434. );
  2435. let num = Math.ceil(
  2436. row.packingQuantity / filterArr[0].packageCell
  2437. );
  2438. this.$refs.wareHouseDailogRef.open(num, idx);
  2439. } else {
  2440. this.$refs.wareHouseDailogRef.open(
  2441. row.isUnpack
  2442. ? measureBoolen
  2443. ? row.packingQuantity
  2444. : row.measureQuantity
  2445. : row.packingQuantity,
  2446. idx
  2447. );
  2448. }
  2449. } else {
  2450. this.$message.error('请先填写包装数量!');
  2451. }
  2452. } else {
  2453. this.$message.error('请保证产品包装数量一致!');
  2454. }
  2455. }
  2456. },
  2457. wareHouseSelection(argum, idx) {
  2458. console.log(argum);
  2459. console.log(idx);
  2460. // 方便包装遍历获取仓库id和名称
  2461. let warehouseIds = [];
  2462. let warehouseNames = [];
  2463. argum.forEach((item) => {
  2464. for (let index = 0; index < item.packingQuantity; index++) {
  2465. warehouseIds.push(item.warehouseId);
  2466. warehouseNames.push(item.warehouseName);
  2467. }
  2468. });
  2469. console.log(warehouseIds);
  2470. console.log(warehouseNames);
  2471. if (idx > -1) {
  2472. this.$set(
  2473. this.productList[idx],
  2474. 'warehouseId',
  2475. argum.map((item) => item.warehouseId).join(',')
  2476. );
  2477. this.$set(
  2478. this.productList[idx],
  2479. 'warehouseName',
  2480. argum.map((item) => item.warehouseName).join(',')
  2481. );
  2482. this.$set(this.productList[idx], 'warehouseIds', warehouseIds);
  2483. this.$set(this.productList[idx], 'warehouseNames', warehouseNames);
  2484. } else {
  2485. this.productList.map((item, index) => {
  2486. this.$set(
  2487. this.productList[index],
  2488. 'warehouseId',
  2489. argum.map((item) => item.warehouseId).join(',')
  2490. );
  2491. this.$set(
  2492. this.productList[index],
  2493. 'warehouseName',
  2494. argum.map((item) => item.warehouseName).join(',')
  2495. );
  2496. this.$set(this.productList[index], 'warehouseIds', warehouseIds);
  2497. this.$set(
  2498. this.productList[index],
  2499. 'warehouseNames',
  2500. warehouseNames
  2501. );
  2502. });
  2503. }
  2504. this.$forceUpdate();
  2505. },
  2506. // 生成包装
  2507. generateWrappers(row, productIndex, packingCodeList) {
  2508. console.log('是否拆包----', row.isUnpack);
  2509. console.log('包装规格----', row.packingSpecificationOption);
  2510. console.log('计量单位----', row.measureUnit);
  2511. console.log('包装数量----', row.packingQuantity);
  2512. console.log('包装编码----', packingCodeList);
  2513. console.log('包装数据----', row);
  2514. let packingList = [];
  2515. let obj = this.getNowDate();
  2516. let productionDate = '';
  2517. let purchaseDate = '';
  2518. if (this.formData.bizType == '1') {
  2519. // 生产入库
  2520. productionDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  2521. this.curDateType = 'productionDate';
  2522. } else if (this.formData.bizType == '2') {
  2523. // 采购入库
  2524. purchaseDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  2525. this.curDateType = 'purchaseDate';
  2526. }
  2527. // 判断单位和计量单位是否为不拆物料层规格
  2528. let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
  2529. .dictValue;
  2530. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
  2531. .dictValue;
  2532. console.log('packingBoolen----', packingBoolen);
  2533. console.log('measureBoolen----', measureBoolen);
  2534. let num = row.packingQuantity;
  2535. let filterArr = [];
  2536. // 处理单位为KG类的情况
  2537. if (packingBoolen) {
  2538. filterArr = row.packingSpecificationOption.filter((item) => {
  2539. return (
  2540. item.packageUnit == row.packingUnit &&
  2541. item.packageUnit != item.conversionUnit
  2542. );
  2543. });
  2544. num = Math.ceil(row.packingQuantity / filterArr[0].packageCell);
  2545. } else {
  2546. if (row.isUnpack) {
  2547. if (measureBoolen) {
  2548. // 处理单位不为KG类,计量单位为KG类的情况
  2549. let splitIndex = row.packingSpecificationOption.findIndex(
  2550. (item) =>
  2551. item.conversionUnit == row.packingUnit &&
  2552. item.packageUnit != item.conversionUnit
  2553. );
  2554. for (; splitIndex > 1; splitIndex--) {
  2555. num = this.$math.format(
  2556. num * row.packingSpecificationOption[splitIndex].packageCell,
  2557. 14
  2558. );
  2559. }
  2560. } else {
  2561. console.log(row.packingSpecificationOption);
  2562. let splitIndex = row.packingSpecificationOption.findIndex(
  2563. (item) =>
  2564. item.conversionUnit == row.packingUnit &&
  2565. item.packageUnit != item.conversionUnit
  2566. );
  2567. console.log(splitIndex);
  2568. for (; splitIndex > 0; splitIndex--) {
  2569. console.log(splitIndex);
  2570. num = this.$math.format(
  2571. num * row.packingSpecificationOption[splitIndex].packageCell,
  2572. 14
  2573. );
  2574. }
  2575. }
  2576. } else {
  2577. num = row.packingQuantity;
  2578. }
  2579. }
  2580. console.log('num-----------', num);
  2581. for (let index = 0; index < num; index++) {
  2582. let measureQuantity = 1;
  2583. // 处理单位为KG类,计算每桶KG值
  2584. if (packingBoolen) {
  2585. console.log(
  2586. this.$math.format(filterArr[0].packageCell * (index + 1), 14)
  2587. );
  2588. console.log(row.packingQuantity);
  2589. measureQuantity =
  2590. Number(row.packingQuantity) >
  2591. this.$math.format(filterArr[0].packageCell * (index + 1), 14)
  2592. ? filterArr[0].packageCell
  2593. : Number(row.packingQuantity) -
  2594. this.$math.format(filterArr[0].packageCell * index, 14);
  2595. } else {
  2596. if (!row.isUnpack) {
  2597. if (measureBoolen) {
  2598. // 处理单位不为KG类,计量单位为KG类的情况
  2599. let splitIndex = row.packingSpecificationOption.findIndex(
  2600. (item) =>
  2601. item.conversionUnit == row.packingUnit &&
  2602. item.packageUnit != item.conversionUnit
  2603. );
  2604. for (; splitIndex > 0; splitIndex--) {
  2605. measureQuantity = this.$math.format(
  2606. measureQuantity *
  2607. row.packingSpecificationOption[splitIndex].packageCell,
  2608. 14
  2609. );
  2610. }
  2611. } else {
  2612. let splitIndex = row.packingSpecificationOption.findIndex(
  2613. (item) =>
  2614. item.conversionUnit == row.packingUnit &&
  2615. item.packageUnit != item.conversionUnit
  2616. );
  2617. for (; splitIndex > 0; splitIndex--) {
  2618. console.log(splitIndex);
  2619. measureQuantity = this.$math.format(
  2620. measureQuantity *
  2621. row.packingSpecificationOption[splitIndex].packageCell,
  2622. 14
  2623. );
  2624. }
  2625. }
  2626. }
  2627. }
  2628. let item = {
  2629. index: row.index + '-' + index, // 包装索引
  2630. warehouseId: row.warehouseIds[index], // 仓库id
  2631. warehouseName: row.warehouseNames[index], // 仓库名称
  2632. categoryName: row.categoryName, // 产品名称
  2633. categoryCode: row.categoryCode, // 产品编码
  2634. categoryModel: row.categoryModel, // 物品型号
  2635. specification: row.specification, // 规格
  2636. brandNum: row.brandNum, // 牌号
  2637. parentIndex: row.index, // 产品索引
  2638. batchNo: row.batchNo, // 批次号
  2639. packageNo: packingCodeList[index].onlyCode, // 包装编码
  2640. packingQuantity: 1, // 包装数量
  2641. packingUnit: row.isUnpack
  2642. ? packingBoolen
  2643. ? filterArr[0].conversionUnit
  2644. : measureBoolen
  2645. ? row.packingSpecificationOption[1]
  2646. ? row.packingSpecificationOption[1].conversionUnit
  2647. : row.packingSpecificationOption[0].conversionUnit
  2648. : row.measureUnit
  2649. : packingBoolen
  2650. ? filterArr[0].conversionUnit
  2651. : row.packingUnit,
  2652. measureQuantity: row.isUnpack
  2653. ? packingBoolen
  2654. ? measureQuantity
  2655. : measureBoolen
  2656. ? row.packingSpecificationOption[1]
  2657. ? row.packingSpecificationOption[1].packageCell
  2658. : row.packingSpecificationOption[0].packageCell
  2659. : measureQuantity
  2660. : measureQuantity, // 计量数量
  2661. measureUnit: row.isUnpack
  2662. ? measureBoolen
  2663. ? row.packingSpecificationOption[1]
  2664. ? row.packingSpecificationOption[1].packageUnit
  2665. : row.packingSpecificationOption[0].packageUnit
  2666. : row.measureUnit
  2667. : row.measureUnit, // 计量单位
  2668. weight: 0, // 重量
  2669. packingSpecificationOption: row.packingSpecificationOption, // 包装规格
  2670. weightUnit: row.weightUnit, // 重量单位
  2671. netWeight: row.netWeight, // 净重
  2672. barcodes: '', // 发货条码
  2673. clientCode: '', // 客户代号
  2674. materielDesignation: '', // 物料代号
  2675. engrave: '', // 刻码
  2676. isUnpack: row.isUnpack, // 是否允许拆包
  2677. productionDate: productionDate, // 生产日期
  2678. purchaseDate: purchaseDate, // 采购时间
  2679. result: this.formData.bizType == 2 && this.form.isQmsCheck ? 0 : 1, // 结果(0无 1合格 2不合格) 是否质检isQmsCheck(0否 1是) bizType(2采购入库)
  2680. status: this.formData.bizType == 2 && this.form.isQmsCheck ? 0 : 2 // 状态(0未质检 1待检 2已质检)
  2681. };
  2682. let outBoolen = !!this.getDict('不拆物料层规格', item.measureUnit)
  2683. .dictValue;
  2684. if (outBoolen) {
  2685. // 计量单位为KG类,直接替换
  2686. item.weight = item.measureQuantity;
  2687. } else {
  2688. // 计量单位为不为KG类,重新统计计算
  2689. let inBoolen = !!this.getDict(
  2690. '不拆物料层规格',
  2691. item.packingSpecificationOption[0].packageUnit
  2692. ).dictValue;
  2693. let startIndex = item.packingSpecificationOption.findIndex(
  2694. (ite) => {
  2695. return (
  2696. item.measureUnit == ite.packingUnit &&
  2697. ite.packingUnit != ite.conversionUnit
  2698. );
  2699. }
  2700. );
  2701. console.log(startIndex);
  2702. let endIndex = item.packingSpecificationOption.findIndex(
  2703. (ite) => item.packingUnit == ite.conversionUnit
  2704. );
  2705. console.log(endIndex);
  2706. let total = item.packingQuantity;
  2707. for (; startIndex < endIndex; endIndex--) {
  2708. total = this.$math.format(
  2709. item.packingSpecificationOption[endIndex].packageCell * total,
  2710. 14
  2711. );
  2712. }
  2713. if (inBoolen) {
  2714. // 第二层为KG类
  2715. item.weight = total;
  2716. } else {
  2717. // 第二层不为KG类
  2718. item.weight = this.$math.format(total * item.netWeight, 14);
  2719. }
  2720. }
  2721. packingList.push(item);
  2722. }
  2723. // 单独点击保存并插入对应位置(包装)
  2724. if (productIndex == 0) {
  2725. this.packingList.splice(productIndex, 0, ...packingList);
  2726. } else {
  2727. let packingIndex = this.packingList.findLastIndex(
  2728. (item) =>
  2729. item.parentIndex == this.productList[productIndex - 1].index
  2730. );
  2731. this.packingList.splice(packingIndex + 1, 0, ...packingList);
  2732. }
  2733. // 单独点击保存并插入对应位置(物料)
  2734. // let materialList = packingList
  2735. // .map((item) => {
  2736. // if (item.isUnpack) {
  2737. // return this.generateMaterial(item);
  2738. // } else {
  2739. // return [];
  2740. // }
  2741. // })
  2742. // .flat();
  2743. // console.log(materialList);
  2744. // if (materialList.length > 0) {
  2745. // if (productIndex == 0) {
  2746. // this.materialList.splice(0, 0, ...materialList);
  2747. // } else {
  2748. // let preLastPackingIndex = this.packingList.findLastIndex((ite) => {
  2749. // return ite.parentIndex <= productIndex - 1 && ite.isUnpack;
  2750. // });
  2751. // let preLastMaterialIndex = this.materialList.findLastIndex(
  2752. // (ite) => {
  2753. // return (
  2754. // ite.parentIndex == this.packingList[preLastPackingIndex].index
  2755. // );
  2756. // }
  2757. // );
  2758. // this.materialList.splice(
  2759. // preLastMaterialIndex + 1,
  2760. // 0,
  2761. // ...materialList
  2762. // );
  2763. // }
  2764. // }
  2765. },
  2766. // 生成物料
  2767. generateMaterial(row) {
  2768. let materialList = [];
  2769. for (let index = 0; index < row.measureQuantity; index++) {
  2770. materialList.push({
  2771. materialCode: row.packageNo + index.toString().padStart(4, '0'), // 物料编码
  2772. index: row.index + '——' + index, // 包装索引
  2773. warehouseId: row.warehouseId, // 仓库id
  2774. warehouseName: row.warehouseName, // 仓库名称
  2775. categoryName: row.categoryName, // 产品名称
  2776. categoryCode: row.categoryCode, // 产品编码
  2777. parentIndex: row.index, // 产品索引
  2778. batchNo: row.batchNo, // 批次号
  2779. packageNo: row.packageNo, // 包装编码
  2780. measureQuantity: 1, // 计量数量
  2781. measureUnit: row.measureUnit, // 计量单位
  2782. weight: Number(
  2783. this.$math.format(row.weight / row.packingQuantity, 14)
  2784. ), // 重量
  2785. weightUnit: row.weightUnit, // 重量单位
  2786. barcodes: '', // 发货条码
  2787. clientCode: '', // 客户代号
  2788. materielDesignation: '', // 物料代号
  2789. engrave: '', // 刻码
  2790. result: 1, // 结果(1合格 2不合格)
  2791. status: 2 // 状态(0=未质检 1待检 2已检)
  2792. });
  2793. }
  2794. return materialList;
  2795. },
  2796. // 设置时间
  2797. dateSetting() {
  2798. if (!this.packingListSelected.length) {
  2799. return this.$message.error(`请选择${this.title}明细!`);
  2800. }
  2801. this.dateVisible = true;
  2802. },
  2803. // 选择包装列表
  2804. handleSelectionChange(val) {
  2805. this.packingListSelected = val;
  2806. },
  2807. // 选择质检结果改变质检状态
  2808. changeWrapStatus(resultValue, row, type) {
  2809. console.log('resultValue--------------', resultValue);
  2810. switch (resultValue) {
  2811. case 0:
  2812. // 清空质检状态
  2813. row.status = 0;
  2814. break;
  2815. default:
  2816. // 默认已检质检状态
  2817. row.status = 2;
  2818. break;
  2819. }
  2820. if (type === '包装') {
  2821. this.packingResultCahnge(resultValue, row);
  2822. } else {
  2823. this.materialResultCahnge(resultValue, row);
  2824. }
  2825. }
  2826. }
  2827. };
  2828. </script>
  2829. <style lang="scss" scoped>
  2830. .inbound_details {
  2831. margin-top: 10px;
  2832. .el-form-item {
  2833. margin-bottom: 0 !important;
  2834. }
  2835. }
  2836. .right_control {
  2837. display: flex;
  2838. > button {
  2839. margin-left: 20px;
  2840. }
  2841. }
  2842. .storage_btn {
  2843. margin-top: 20px;
  2844. display: flex;
  2845. align-content: center;
  2846. justify-content: center;
  2847. }
  2848. .el-date-editor.el-input,
  2849. .el-date-editor.el-input__inner {
  2850. width: 100% !important;
  2851. }
  2852. .red_color {
  2853. color: red;
  2854. }
  2855. .wareHouse_style {
  2856. text-overflow: ellipsis;
  2857. overflow: hidden;
  2858. word-break: break-all;
  2859. white-space: nowrap;
  2860. }
  2861. </style>