storage.vue 105 KB

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