storage.vue 64 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891
  1. <template>
  2. <ele-modal :visible.sync="visible" title="生产入库" width="80%" :maxable="true">
  3. <div class="productionWarehousing">
  4. <el-card shadow="never">
  5. <header-title title="基本信息"></header-title>
  6. <el-form
  7. :model="formData"
  8. ref="formName"
  9. label-width="110px"
  10. :rules="rules"
  11. >
  12. <el-row :gutter="20">
  13. <el-col :span="8">
  14. <el-form-item label="物品类型" prop="extInfo.assetType">
  15. <selectTree
  16. ref="tree"
  17. class="form-ipt"
  18. size="medium"
  19. style="width: 100%"
  20. :isBindPlan="true"
  21. :value="formData.extInfo.assetType"
  22. clearable
  23. :options="codeList"
  24. :props="{
  25. value: 'id',
  26. label: 'name',
  27. children: 'children'
  28. }"
  29. @getValue="codeListValue"
  30. :isAll="false"
  31. />
  32. </el-form-item>
  33. </el-col>
  34. <el-col :span="8">
  35. <el-form-item label="入库类型" prop="bizType">
  36. <span>生产入库</span>
  37. </el-form-item></el-col
  38. >
  39. <el-col :span="8">
  40. <el-form-item label="生产工单" prop="documentSource">
  41. <el-input
  42. v-model="formData.extInfo.documentSource"
  43. disabled
  44. ></el-input>
  45. </el-form-item>
  46. </el-col>
  47. <el-col :span="8">
  48. <el-form-item label="权属部门" prop="deptName">
  49. <el-input
  50. placeholder="权属部门"
  51. disabled
  52. v-model="formData.extInfo.deptName"
  53. clearable
  54. />
  55. </el-form-item>
  56. </el-col>
  57. <el-col :span="8">
  58. <el-form-item label="入库登记人">
  59. <el-input
  60. placeholder="登记人"
  61. disabled
  62. v-model="formData.extInfo.createUserName"
  63. clearable /></el-form-item
  64. ></el-col>
  65. <el-col :span="8">
  66. <el-form-item label="送货人" prop="fromUser">
  67. <el-input
  68. placeholder="请输入"
  69. v-model="formData.fromUser"
  70. clearable
  71. /> </el-form-item
  72. ></el-col>
  73. <el-col :span="8">
  74. <el-form-item label="送货人联系方式" prop="deliveryPhone">
  75. <el-input
  76. placeholder="请输入"
  77. v-model="formData.extInfo.deliveryPhone"
  78. clearable /></el-form-item
  79. ></el-col>
  80. <el-col :span="24">
  81. <el-form-item label="备注" prop="remark">
  82. <el-input
  83. v-model="formData.remark"
  84. clearable
  85. type="textarea"
  86. placeholder="请详细说明"
  87. :rows="4"
  88. ></el-input>
  89. </el-form-item>
  90. </el-col>
  91. </el-row>
  92. </el-form>
  93. <div class="material">
  94. <header-title title="产品信息">
  95. <el-button type="primary" @click="addStock" v-if="!isTask"
  96. >添加</el-button
  97. >
  98. </header-title>
  99. <div class="mt10 form-table">
  100. <el-form
  101. ref="warehousingMaterialListRef"
  102. :model="{ warehousingMaterialList: warehousingMaterialList }"
  103. :show-message="false"
  104. >
  105. <el-button
  106. v-if="warehousingMaterialList.length != 0"
  107. type="success"
  108. plain
  109. style="margin-bottom: 20px; float: right; margin-right: 20px"
  110. size="mini"
  111. @click="listSaveArrs"
  112. >批量保存</el-button
  113. >
  114. <el-table
  115. v-if="isWeight"
  116. :header-cell-style="rowClass"
  117. ref="warehousingMaterialListTable"
  118. :key="formData.extInfo.assetType"
  119. :data="warehousingMaterialList"
  120. tooltip-effect="dark"
  121. style="width: 100%"
  122. stripe
  123. >
  124. <el-table-column
  125. label="序号"
  126. type="index"
  127. width="50"
  128. align="center"
  129. >
  130. </el-table-column>
  131. <el-table-column
  132. label="编码"
  133. prop="assetCode"
  134. align="center"
  135. width="130"
  136. ></el-table-column>
  137. <el-table-column
  138. label="名称"
  139. align="center"
  140. width="200"
  141. prop="assetName"
  142. ></el-table-column>
  143. <el-table-column
  144. v-for="(item, index) in tableHeader"
  145. :key="index"
  146. align="center"
  147. :label="item.label"
  148. width="150"
  149. :prop="item.prop"
  150. >
  151. <template slot-scope="{ row }">
  152. <template v-if="item.formatter">{{
  153. item.formatter(row)
  154. }}</template>
  155. <template v-else>{{ row[item.prop] }}</template>
  156. </template>
  157. </el-table-column>
  158. <el-table-column label="批次号" width="100" prop="assetName">
  159. <template slot-scope="{ row, $index }">
  160. <template>
  161. {{ row.manualBatchNo }}
  162. </template>
  163. </template>
  164. </el-table-column>
  165. <el-table-column
  166. label="批次号"
  167. prop="batchNo"
  168. width="70"
  169. align="center"
  170. >
  171. <template slot-scope="{ row, $index }">
  172. <template v-if="row.isSave">
  173. {{ row.batchNo }}
  174. </template>
  175. <el-form-item
  176. v-else
  177. :prop="`warehousingMaterialList.${$index}.batchNo`"
  178. required
  179. >
  180. {{ row.batchNo }}
  181. </el-form-item>
  182. </template>
  183. </el-table-column>
  184. <el-table-column
  185. label="最小包装单元"
  186. align="center"
  187. prop="minPackingCount"
  188. width="100"
  189. >
  190. <el-table-column label="" prop="minPackingCount" width="100">
  191. <template slot-scope="{ row, $index }">
  192. <template>
  193. {{ row.minPackingCount }}
  194. </template>
  195. </template>
  196. </el-table-column>
  197. <el-table-column label="" prop="minPackingCount">
  198. <template slot-scope="{ row, $index }">
  199. {{ handleRowUnit(row) }} /{{ row.minPackUnit }}
  200. </template>
  201. </el-table-column>
  202. </el-table-column>
  203. <el-table-column
  204. label="包装数量"
  205. prop="outInNum"
  206. width="150"
  207. align="center"
  208. >
  209. <template slot-scope="{ row, $index }">
  210. <template>
  211. {{ row.outInNum }} {{ row.minPackUnit }}
  212. </template>
  213. </template>
  214. </el-table-column>
  215. <el-table-column label="计量数量" prop="counts">
  216. <template slot-scope="{ row, $index }">
  217. {{ isBaoyue?tableHandle(row):$math.format(row.minPackingCount * row.outInNum, 14) }}
  218. </template>
  219. </el-table-column>
  220. <el-table-column
  221. label="计量单位"
  222. prop="batchNo"
  223. width="100"
  224. align="center"
  225. >
  226. <!-- v-if="formData.extInfo.assetType == 1" -->
  227. <template slot-scope="{ row, $index }">
  228. <template>
  229. {{ row.measuringUnit }}
  230. </template>
  231. </template>
  232. </el-table-column>
  233. <el-table-column
  234. label="重量"
  235. align="center"
  236. prop="contentImage"
  237. :show-overflow-tooltip="true"
  238. >
  239. <template slot-scope="{ row, $index }">
  240. {{ row.weight }}
  241. <template slot="append">
  242. {{ handleRowUnit(row) }}
  243. </template>
  244. </template>
  245. </el-table-column>
  246. <el-table-column
  247. label="重量单位"
  248. align="center"
  249. prop="contentImage"
  250. :show-overflow-tooltip="true"
  251. >
  252. <template slot-scope="{ row, $index }">
  253. {{ row.weightUnit }}
  254. <template slot="append"> </template>
  255. </template>
  256. </el-table-column>
  257. <el-table-column
  258. label="单价"
  259. prop="univalence"
  260. width="150"
  261. align="center"
  262. >
  263. <template slot-scope="{ row, $index }">
  264. <div v-if="row.isSave"
  265. >{{ row.univalence }}元/{{ handleRowUnit(row) }}</div
  266. >
  267. <el-form-item
  268. v-else
  269. :prop="`warehousingMaterialList.${$index}.univalence`"
  270. >
  271. <el-input
  272. v-model="row.univalence"
  273. placeholder="非必填"
  274. @input="
  275. (value) =>
  276. (row.univalence = value.replace(/[^0-9.]+/g, ''))
  277. "
  278. >
  279. <template slot="append">
  280. 元/{{ handleRowUnit(row) }}
  281. </template>
  282. </el-input>
  283. </el-form-item>
  284. </template>
  285. </el-table-column>
  286. <el-table-column
  287. label="金额"
  288. align="center"
  289. prop="contentImage"
  290. :show-overflow-tooltip="true"
  291. >
  292. <template slot-scope="{ row, $index }">
  293. {{
  294. calcSumTotal(
  295. row.outInNum,
  296. row.minPackingCount,
  297. row.univalence,
  298. row
  299. )
  300. }}
  301. </template>
  302. </el-table-column>
  303. <el-table-column
  304. label="货位"
  305. prop="warehouseName"
  306. :show-overflow-tooltip="true"
  307. width="250"
  308. required
  309. >
  310. <template slot-scope="{ row, $index }">
  311. <el-form-item
  312. :prop="`warehousingMaterialList.${$index}.houseList`"
  313. :required="true"
  314. >
  315. <div @click="handleWareHouse(row, $index)">
  316. <div
  317. style="color: #ff4949"
  318. v-if="row.houseList.length == 0"
  319. >
  320. ---(必填)
  321. </div>
  322. <div v-else>
  323. <div
  324. class="fontOmitted"
  325. v-for="(item, index) in row.houseList"
  326. :key="index"
  327. >
  328. {{ item.warehouseName }}- {{ item.areaName }}-
  329. {{ item.shelfCode }}- {{ item.cargoSpaceCode
  330. }}<span style="color: #ff4949" v-if="item.num">
  331. - {{ item.num }}(数)</span
  332. >
  333. <br />
  334. </div>
  335. </div>
  336. </div>
  337. </el-form-item>
  338. </template>
  339. </el-table-column>
  340. <el-table-column
  341. label="操作"
  342. width="200"
  343. fixed="right"
  344. align="center"
  345. >
  346. <template slot="header" slot-scope="scope"> 操作 </template>
  347. <template slot-scope="{ row, $index }">
  348. <el-button
  349. type="text"
  350. v-show="!row.isSave"
  351. @click="listSave(row, $index)"
  352. >保存</el-button
  353. >
  354. <el-button
  355. type="text"
  356. v-show="row.isSave"
  357. @click="listEdit(row, $index)"
  358. >编辑</el-button
  359. >
  360. <el-button
  361. type="text"
  362. @click="listDel(row, $index)"
  363. v-if="!isTask"
  364. >删除</el-button
  365. >
  366. </template>
  367. </el-table-column>
  368. </el-table>
  369. </el-form>
  370. </div>
  371. <div class="mt20">
  372. <header-title :title="`包装明细`">
  373. <div class="switch_right">
  374. <span v-if="materialCodeReqList.length != 0">
  375. 分拆<el-switch
  376. v-model="isSplit"
  377. active-color="#13ce66"
  378. inactive-color="#ff4949"
  379. @change="handleIsDetail"
  380. style="margin-left: 10px"
  381. >
  382. </el-switch>
  383. </span>
  384. <!-- <el-button
  385. style="margin-left: 20px"
  386. type="text"
  387. @click="dateSetting"
  388. v-if="formData.bizType != 5"
  389. >批量设置{{
  390. curDateType === 'manufactureTime' ? '生产日期' : '采购日期'
  391. }}</el-button
  392. > -->
  393. </div>
  394. </header-title>
  395. <!-- <el-button
  396. v-if="materialCodeReqList.length != 0"
  397. type="success"
  398. plain
  399. style="margin-bottom: 20px; float: right; margin-right: 20px"
  400. size="mini"
  401. @click="wrapListSave"
  402. >批量保存</el-button
  403. > -->
  404. <el-table
  405. ref="materialCodeReqListTable"
  406. :data="materialCodeReqList"
  407. tooltip-effect="dark"
  408. :key="formData.bizType"
  409. :header-cell-style="rowClass"
  410. style="width: 100%"
  411. stripe
  412. height="300px"
  413. @selection-change="handleSelectionChange"
  414. >
  415. <el-table-column
  416. label=""
  417. type="selection"
  418. align="center"
  419. width="50"
  420. v-if="formData.bizType != 5"
  421. >
  422. </el-table-column>
  423. <el-table-column label="序号" type="index" width="50">
  424. </el-table-column>
  425. <el-table-column
  426. label="编码"
  427. prop="assetCode"
  428. width="130"
  429. :show-overflow-tooltip="true"
  430. ></el-table-column>
  431. <el-table-column
  432. label="名称"
  433. prop="assetName"
  434. width="150"
  435. :show-overflow-tooltip="true"
  436. ></el-table-column>
  437. <el-table-column
  438. label="批次号"
  439. prop="manualBatchNo"
  440. width="100"
  441. ></el-table-column>
  442. <el-table-column
  443. label="批次号"
  444. prop="batchNo"
  445. width="70"
  446. ></el-table-column>
  447. <el-table-column
  448. label="发货条码"
  449. prop="barcodes"
  450. width="80"
  451. :show-overflow-tooltip="true"
  452. ></el-table-column>
  453. <el-table-column
  454. :label="`包装编码`"
  455. prop="onlyCode"
  456. width="130"
  457. :show-overflow-tooltip="true"
  458. ></el-table-column>
  459. <el-table-column
  460. label="包装数量"
  461. prop="packingCount"
  462. width="80"
  463. ></el-table-column>
  464. <el-table-column
  465. label="包装单位"
  466. prop="packingUnit"
  467. ></el-table-column>
  468. <el-table-column
  469. label="计量数量"
  470. prop="minPackingCount"
  471. ></el-table-column>
  472. <el-table-column
  473. label="计量单位"
  474. prop="measuringUnit"
  475. ></el-table-column>
  476. <el-table-column label="物料代号" prop="materielCode" width="130">
  477. <template slot-scope="{ row }">
  478. <span>{{ row.materielCode }}</span>
  479. </template>
  480. </el-table-column>
  481. <el-table-column label="客户代号" prop="clientCode">
  482. <template slot-scope="{ row }">
  483. <span> {{ row.clientCode }}</span>
  484. </template>
  485. </el-table-column>
  486. <el-table-column label="刻码" prop="engrave">
  487. <template slot-scope="{ row }">
  488. <span>{{ row.engrave }}</span>
  489. </template>
  490. </el-table-column>
  491. <el-table-column label="重量" prop="weight" width="100">
  492. <template slot-scope="{ row }">
  493. <span>{{ row.weight }}</span>
  494. </template>
  495. </el-table-column>
  496. <el-table-column label="重量单位" prop="weightUtil">
  497. <template slot-scope="{ row }">
  498. {{ row.weightUtil }}
  499. </template>
  500. </el-table-column>
  501. <el-table-column label="质检结果" prop="result" width="120">
  502. <template slot-scope="{ row }">
  503. <span>{{ qualityResults[row.result] }}</span>
  504. </template>
  505. </el-table-column>
  506. <el-table-column label="质检状态" prop="status" width="120">
  507. <template slot-scope="{ row }">
  508. <span>{{ qualityStatus[row.status] }}</span>
  509. </template>
  510. </el-table-column>
  511. <el-table-column
  512. label="生产日期"
  513. width="150"
  514. prop="createTime"
  515. ></el-table-column>
  516. </el-table>
  517. <!-- </el-tab-pane>
  518. </el-tabs> -->
  519. </div>
  520. <div class="mt20" v-if="isSplit">
  521. <header-title :title="`物料明细`"> </header-title>
  522. <el-table
  523. ref="resultArrayTable"
  524. :data="resultArray"
  525. tooltip-effect="dark"
  526. :key="formData.bizType"
  527. :header-cell-style="rowClass"
  528. style="width: 100%"
  529. stripe
  530. height="300px"
  531. @selection-change="handleSelectionChange"
  532. >
  533. <el-table-column label="序号" type="index" width="50">
  534. </el-table-column>
  535. <el-table-column
  536. label="编码"
  537. prop="assetCode"
  538. :show-overflow-tooltip="true"
  539. ></el-table-column>
  540. <el-table-column
  541. label="名称"
  542. prop="assetName"
  543. width="200"
  544. :show-overflow-tooltip="true"
  545. ></el-table-column>
  546. <el-table-column
  547. label="批次号"
  548. prop="manualBatchNo"
  549. width="100"
  550. ></el-table-column>
  551. <el-table-column
  552. label="批次号"
  553. prop="batchNo"
  554. width="80"
  555. ></el-table-column>
  556. <el-table-column
  557. label="物料编码"
  558. prop="no"
  559. width="200"
  560. :show-overflow-tooltip="true"
  561. ></el-table-column>
  562. <el-table-column
  563. label="发货条码"
  564. prop="barcodes"
  565. width="80"
  566. :show-overflow-tooltip="true"
  567. ></el-table-column>
  568. <el-table-column
  569. label="计量数量"
  570. prop="minPackingCount"
  571. width="90"
  572. ></el-table-column>
  573. <el-table-column
  574. width="80"
  575. label="计量单位"
  576. prop="measuringUnit"
  577. ></el-table-column>
  578. <el-table-column label="物料代号" prop="meterielCode" width="130">
  579. <template slot-scope="{ row }">
  580. <span>{{ row.materialCode }}</span>
  581. </template>
  582. </el-table-column>
  583. <el-table-column label="客户代号" prop="clientCode">
  584. <template slot-scope="{ row }">
  585. <span> {{ row.clientCode }}</span>
  586. </template>
  587. </el-table-column>
  588. <el-table-column label="刻码" prop="engrave">
  589. <template slot-scope="{ row }">
  590. <span> {{ row.engrave }}</span>
  591. </template>
  592. </el-table-column>
  593. <el-table-column width="100" label="重量" prop="weight">
  594. <template slot-scope="{ row }">
  595. <span>{{ row.weight }}</span>
  596. </template>
  597. </el-table-column>
  598. <el-table-column label="重量单位" prop="weightUnit" width="100">
  599. </el-table-column>
  600. <el-table-column label="质检结果" prop="result" width="120">
  601. <template slot-scope="{ row }">
  602. <span>{{ qualityResults[row.result] }}</span>
  603. </template>
  604. </el-table-column>
  605. <el-table-column label="质检状态" prop="status" width="120">
  606. <template slot-scope="{ row }">
  607. <span>{{ qualityStatus[row.status] }}</span>
  608. </template>
  609. </el-table-column>
  610. </el-table>
  611. </div>
  612. </div>
  613. </el-card>
  614. <selectType
  615. :visibleDialog.sync="visibleDialog"
  616. :title="title"
  617. :tableHeader="tableHeader"
  618. :bizScene="formData.bizType"
  619. :type="[selectEquiType]"
  620. :loadTree.sync="loadTree"
  621. @selectTableData="addProduct"
  622. />
  623. <WareHouseDailog
  624. ref="wareHouseDailogRef"
  625. @houseData="houseData"
  626. ></WareHouseDailog>
  627. <el-dialog :visible.sync="dateVisible" title="选择日期" width="400px">
  628. <el-date-picker
  629. size="small"
  630. v-model="batchTime"
  631. type="datetime"
  632. style="width: 320px"
  633. value-format="yyyy-MM-dd HH:mm:ss"
  634. placeholder="选择日期"
  635. >
  636. </el-date-picker>
  637. <div style="text-align: right; margin-top: 20px">
  638. <el-button @click="dateVisible = false">取消</el-button>
  639. <el-button type="primary" @click="dateConfirm" :disabled="!batchTime"
  640. >确认</el-button
  641. >
  642. </div>
  643. </el-dialog>
  644. </div>
  645. <div style="text-align: right; margin-top: 20px">
  646. <el-button @click="visible = false">取消</el-button>
  647. <el-button type="primary" @click="save" :loading="isLoading"
  648. >入库</el-button
  649. >
  650. </div>
  651. </ele-modal>
  652. </template>
  653. <script>
  654. import { getLoginUser } from '@/api/login';
  655. import outin from '@/api/warehouseManagement/outin';
  656. import { allCategoryLevel } from '@/api/classifyManage';
  657. import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
  658. import { sceneState } from '@/utils/dict/index';
  659. import selectTree from './selectTree';
  660. import selectType from './selectType.vue';
  661. import WareHouseDailog from './WareHouseDailog.vue';
  662. import { tableHeader } from './common';
  663. import { getCode } from '@/api/codeManagement/index.js';
  664. import { deepClone } from 'ele-admin/lib/utils/core';
  665. import { updateApprovalStatus } from '@/api/warehousing/index.js';
  666. export default {
  667. components: {
  668. selectTree,
  669. selectType,
  670. WareHouseDailog
  671. },
  672. data() {
  673. return {
  674. visible: false,
  675. isLoading: false,
  676. isSplit: false, // 是否拆分到物料明细
  677. qualityStatus: {
  678. 0: '未检',
  679. 1: '已检',
  680. 2: '部分检'
  681. }, // 质检状态 0未检 1已检
  682. qualityResults: {
  683. 0: '合格',
  684. 1: '不合格',
  685. 3: '让步接收'
  686. }, // 质检结果 0合格 1不合格 3让步接收
  687. isTask: false,
  688. isWeight: true,
  689. resultArray: [],
  690. pickerRow: {},
  691. codeList: [],
  692. sceneState,
  693. isBaoyue: false, //是否是宝悦
  694. visibleDialog: false,
  695. curDateType: 'manufactureTime',
  696. materialCodeReqListSelected: [],
  697. title: '',
  698. warehousingMaterialList: [],
  699. loadTree: true,
  700. selectEquiType: '',
  701. batchTime: '',
  702. dateVisible: false,
  703. formData: {
  704. extInfo: {
  705. assetType: '', //物品类型
  706. deptCode: '', //部门code
  707. deptName: '', //部门名称
  708. verifyDeptCode: '', //审核部门编码
  709. verifyDeptName: '', //审核部门名称
  710. deliveryName: '', //送货人名称
  711. deliveryPhone: '', //送货人电话
  712. documentSource: '', //销售订单
  713. urgent: '', //紧急状态
  714. supplierId: '', //供应商ID
  715. supplierName: '', //供应商名称
  716. createUserName: '', //创建人名字
  717. contentImage: [] //图片数组
  718. },
  719. fromUser: '', //送货人
  720. bizType: '', //物品类型
  721. verifyId: '', //审核人Id
  722. verifyName: '', //审核人名称
  723. createUserId: '',
  724. remark: ''
  725. },
  726. rules: {
  727. 'extInfo.assetType': {
  728. required: true,
  729. message: '请选择物品类型',
  730. trigger: 'change'
  731. },
  732. bizType: {
  733. required: true,
  734. message: '请选择入库场景',
  735. trigger: 'change'
  736. }
  737. }
  738. };
  739. },
  740. props: ['inboundType'],
  741. computed: {
  742. // 条码信息
  743. materialCodeReqList() {
  744. console.log(this.warehousingMaterialList, 'fdfdf');
  745. return this.warehousingMaterialList
  746. .map((i) => i.warehouseLedgerDetails || [])
  747. .flat();
  748. },
  749. tableHeader() {
  750. return tableHeader(this.selectEquiType);
  751. }
  752. },
  753. methods: {
  754. // 包装维度最小包装单元改变——>总重量
  755. minPackingCountChange(row, value) {
  756. if (value >= 0) {
  757. row.minPackingCount = value;
  758. } else {
  759. row.minPackingCount = 0;
  760. }
  761. // row.minPackingCount = value.replace(/^(0+)|[^\d]+/g, '');
  762. if (row.outInNum >= 0 && value >= 0) {
  763. this.packNum(row, row.outInNum);
  764. }
  765. },
  766. // 选择质检结果改变质检状态
  767. changeWrapStatus(resultValue, row) {
  768. switch (resultValue) {
  769. case '':
  770. // 清空质检状态
  771. row.status = '0';
  772. break;
  773. default:
  774. // 默认已检质检状态
  775. row.status = '1';
  776. break;
  777. }
  778. },
  779. weightInput(value, row) {
  780. const newValue = value.replace(/[^\d.]/g, ''); // 保留数字和小数点
  781. const decimalCount = (newValue.match(/\./g) || []).length; // 计算小数点的个数
  782. if (decimalCount > 1) {
  783. // 如果小数点个数大于1,移除多余的小数点
  784. const lastIndex = newValue.lastIndexOf('.');
  785. row.weight =
  786. newValue.slice(0, lastIndex) + newValue.slice(lastIndex + 1);
  787. } else if (decimalCount === 1) {
  788. // 如果小数点个数等于1,允许小数点的输入
  789. row.weight = newValue;
  790. } else {
  791. row.weight = newValue === '' ? 0 : parseFloat(newValue); // 如果输入为空,则设为0
  792. }
  793. },
  794. // 拆分物料
  795. handleIsDetail(event) {
  796. this.isSplit = event;
  797. const list = this.materialCodeReqList;
  798. if (event) {
  799. let resultArray = [];
  800. list.forEach((item) => {
  801. // 包装维度改成已保存状态
  802. item.isPack = true;
  803. // 拆分物料维度并生成列表
  804. for (let i = 1; i <= Number(item.minPackingCount); i++) {
  805. resultArray.push({
  806. onlyCode: item.onlyCode,
  807. no: item.onlyCode + i.toString().padStart(4, '0'),
  808. assetCode: item.assetCode,
  809. assetName: item.assetName,
  810. barcodes: item.barcodes,
  811. manualBatchNo: item.manualBatchNo,
  812. batchNo: item.batchNo,
  813. minPackingCount: 1,
  814. measuringUnit: item.measuringUnit,
  815. materielCode: item.materielCode,
  816. clientCode: item.clientCode,
  817. weight: this.$math.format(
  818. item.weight / Number(item.minPackingCount),
  819. 14
  820. ),
  821. initWeight: this.$math.format(
  822. item.weight / Number(item.minPackingCount),
  823. 14
  824. ),
  825. weightUnit: item.weightUnit,
  826. engrave: item.engrave,
  827. result: item.result,
  828. status: item.status,
  829. isPack: false
  830. });
  831. }
  832. });
  833. this.resultArray = resultArray;
  834. // 批量修改包装明细
  835. this.isWeight = false;
  836. this.bulkEditingWrap();
  837. this.$nextTick(() => {
  838. this.isWeight = true;
  839. });
  840. } else {
  841. // 包装维度改成编辑状态
  842. list.forEach((item) => {
  843. item.isPack = false;
  844. });
  845. // 清空物料维度列表
  846. this.resultArray = [];
  847. }
  848. },
  849. //包装明细保存
  850. packCout(row) {
  851. //true保存==》反之
  852. if (!row.isPack) {
  853. row.isPack = true;
  854. const code = row.assetCode;
  855. const batchNo = row.batchNo;
  856. //做防护,防止weight字符串类型
  857. this.materialCodeReqList.forEach((ele) => {
  858. ele.weight = Number(ele.weight);
  859. });
  860. // 修改产品信息重量(包装维度累计)
  861. this.isWeight = false;
  862. this.warehousingMaterialList.forEach((item) => {
  863. if (item.assetCode == code && item.batchNo == batchNo) {
  864. let arr = [];
  865. for (const key in this.materialCodeReqList) {
  866. if (
  867. this.materialCodeReqList[key].assetCode == item.assetCode &&
  868. this.materialCodeReqList[key].batchNo == item.batchNo
  869. ) {
  870. arr.push({ ...this.materialCodeReqList[key] });
  871. }
  872. }
  873. const count = arr.reduce((acc, curr) => {
  874. if (curr.isPack) {
  875. this.$set(curr, 'initWeight', +curr.weight);
  876. return Number(this.$math.format(+acc + +curr.weight, 14));
  877. } else {
  878. return Number(this.$math.format(+acc + +curr.initWeight, 14));
  879. }
  880. }, 0);
  881. this.$set(item, 'weight', count);
  882. }
  883. });
  884. this.$nextTick(() => {
  885. this.isWeight = true;
  886. });
  887. } else {
  888. row.isPack = false;
  889. }
  890. },
  891. // 批量修改包装明细
  892. bulkEditingWrap() {
  893. // 批量修改包装明细列表状态(已保存)
  894. this.materialCodeReqList.forEach((item) => {
  895. item.isPack = true;
  896. });
  897. // 改变产品明细重量
  898. this.warehousingMaterialList.forEach((outItem) => {
  899. let arr = [];
  900. this.materialCodeReqList.forEach((inneritem) => {
  901. if (
  902. inneritem.assetCode == outItem.assetCode &&
  903. inneritem.batchNo == outItem.batchNo
  904. ) {
  905. arr.push(inneritem);
  906. }
  907. });
  908. const count = arr.reduce((acc, curr) => {
  909. if (curr.isPack) {
  910. this.$set(curr, 'initWeight', +curr.weight);
  911. return Number(this.$math.format(+acc + +curr.weight, 14));
  912. } else {
  913. return Number(this.$math.format(+acc + +curr.initWeight, 14));
  914. }
  915. }, 0);
  916. this.$set(outItem, 'weight', count);
  917. });
  918. },
  919. // 批量修改物料明细
  920. bulkEditingMaterial() {
  921. // 批量修改物料明细列表状态(已保存)
  922. this.resultArray.forEach((item) => {
  923. item.isPack = true;
  924. });
  925. // 改变包装明细重量
  926. this.materialCodeReqList.forEach((outItem) => {
  927. let arr = [];
  928. this.resultArray.forEach((inneritem) => {
  929. if (
  930. inneritem.assetCode == outItem.assetCode &&
  931. inneritem.batchNo == outItem.batchNo
  932. ) {
  933. arr.push(inneritem);
  934. }
  935. });
  936. const count = arr.reduce((acc, curr) => {
  937. if (curr.isPack) {
  938. this.$set(curr, 'initWeight', +curr.weight);
  939. return Number(this.$math.format(+acc + +curr.weight, 14));
  940. } else {
  941. return Number(this.$math.format(+acc + +curr.initWeight, 14));
  942. }
  943. }, 0);
  944. this.$set(outItem, 'weight', count);
  945. });
  946. },
  947. // 物料明细保存
  948. materialBtn(row) {
  949. console.log(row);
  950. console.log(this.resultArray);
  951. console.log(this.materialCodeReqList);
  952. // true保存 false编辑
  953. if (!row.isPack) {
  954. row.isPack = true;
  955. // 物料维度修改质检改变包装维度质检(结果和状态)
  956. this.materialCodeReqList.forEach((outItem) => {
  957. let arr = [];
  958. this.resultArray.forEach((inneritem) => {
  959. if (inneritem.onlyCode == outItem.onlyCode) {
  960. arr.push(inneritem);
  961. }
  962. });
  963. console.log(arr);
  964. // 首先判断是未填/合格不合格
  965. let boolen = arr.every((item) => {
  966. return (
  967. item.result === '' ||
  968. item.result === undefined ||
  969. item.result === null
  970. );
  971. });
  972. // 判断只要物料全部质检结果(未填)——>包装质检结果(未填) 状态(未检)
  973. if (boolen) {
  974. this.$set(outItem, 'result', '');
  975. this.$set(outItem, 'status', '0');
  976. } else {
  977. // 判断只要物料有一个质检结果(不合格)——>包装质检结果(不合格) 状态(已检)
  978. let boolen = arr.some((item) => {
  979. return item.result === '1';
  980. });
  981. if (boolen) {
  982. this.$set(outItem, 'result', '1');
  983. this.$set(outItem, 'status', '1');
  984. } else {
  985. // 判断只要物料有一个质检结果(让步接收)——>包装质检结果(让步接收) 状态(已检)
  986. let boolen = arr.some((item) => {
  987. return item.result === '3';
  988. });
  989. if (boolen) {
  990. // 让步接收 已检
  991. this.$set(outItem, 'result', '3');
  992. this.$set(outItem, 'status', '1');
  993. } else {
  994. // 判断只要物料有全部质检结果(合格)——>包装质检结果(合格) 状态(已检)
  995. let boolen = arr.every((item) => {
  996. return item.result === '0';
  997. });
  998. if (boolen) {
  999. // 合格 已检
  1000. this.$set(outItem, 'result', '0');
  1001. this.$set(outItem, 'status', '1');
  1002. } else {
  1003. // 合格 部分检
  1004. this.$set(outItem, 'result', '0');
  1005. this.$set(outItem, 'status', '2');
  1006. }
  1007. }
  1008. }
  1009. }
  1010. // this.$set(outItem, 'result', boolen ? '1' : '0');
  1011. });
  1012. // 物料维度修改重量改变包装维度重量
  1013. let onlyCode = row.onlyCode;
  1014. this.materialCodeReqList.forEach((item) => {
  1015. if (item.onlyCode === onlyCode) {
  1016. let arr = [];
  1017. for (const key in this.resultArray) {
  1018. if (this.resultArray[key].onlyCode == item.onlyCode) {
  1019. arr.push(this.resultArray[key]);
  1020. }
  1021. }
  1022. const count = arr.reduce((acc, curr) => {
  1023. if (curr.isPack) {
  1024. this.$set(curr, 'initWeight', +curr.weight);
  1025. return Number(this.$math.format(+acc + +curr.weight, 14));
  1026. } else {
  1027. return Number(this.$math.format(+acc + +curr.initWeight, 14));
  1028. }
  1029. }, 0);
  1030. this.$set(item, 'weight', count);
  1031. }
  1032. });
  1033. // 包装维度修改重量改变产品信息
  1034. this.isWeight = false;
  1035. // 批量修改包装明细
  1036. this.bulkEditingWrap();
  1037. this.$nextTick(() => {
  1038. this.isWeight = true;
  1039. });
  1040. } else {
  1041. row.isPack = false;
  1042. }
  1043. },
  1044. // 重量计算
  1045. packNum(row, value) {
  1046. const total = {
  1047. packingCount: Number(row.minPackingCount > 0 ? row.minPackingCount : 0),
  1048. outInNum: Number(row.outInNum > 0 ? row.outInNum : 0)
  1049. };
  1050. if (row.measuringUnit == row.weightUnit) {
  1051. row.weight = Number(
  1052. this.$math.format(
  1053. total.packingCount * 1 * total.outInNum.toFixed(2),
  1054. 14
  1055. )
  1056. );
  1057. } else {
  1058. const totals = Number(
  1059. this.$math.format(total.packingCount * total.outInNum, 14)
  1060. );
  1061. row.weight = Number(
  1062. this.$math.format(
  1063. totals * (row.netWeight > 0 ? row.netWeight.toFixed(2) : 0),
  1064. 14
  1065. )
  1066. );
  1067. }
  1068. return (row.outInNum = value.replace(/^(0+)|[^\d]+/g, ''));
  1069. },
  1070. // 根据单据信息初始化产品信息(外部调用)
  1071. async pickerSuccess(row) {
  1072. this.warehousingMaterialList=[]
  1073. this.isBaoyue = false;
  1074. if (
  1075. row.categoryName.includes('砌块') ||
  1076. row.categoryName.includes('板材')
  1077. ) {
  1078. this.isBaoyue = true;
  1079. }
  1080. this.visible = true;
  1081. await this.initData();
  1082. this.formData.bizType = '1'; // 生产入库
  1083. this.formData.extInfo.assetType = row.rootCategoryLevelId;
  1084. this.title = row.categoryLevelName;
  1085. this.selectEquiType = row.rootCategoryLevelId;
  1086. this.isTask = true;
  1087. this.pickerRow = row;
  1088. this.formData.sourceBizNo = row.code;
  1089. if (this.warehousingMaterialList.length == 0) {
  1090. this.createDataByWrap(row);
  1091. }
  1092. },
  1093. async createDataByWrap(wrapData) {
  1094. let list = deepClone(wrapData);
  1095. const batchNo = await getCode('lot_number_code'); // 生成批次号
  1096. let sameItemWraplist = []; // 储存分类数据
  1097. let sameItemWrapInfolist = []; // 用来判断去重
  1098. // 先过滤同一种物品下面包装
  1099. list.detailList.forEach((item) => {
  1100. if (sameItemWraplist.length > 0) {
  1101. let filterArr = sameItemWrapInfolist.filter(
  1102. (it) =>
  1103. item.categoryCode == it.categoryCode &&
  1104. item.quantity == it.quantity
  1105. );
  1106. if (filterArr.length > 0) {
  1107. sameItemWraplist[filterArr[0].index].push(item);
  1108. } else {
  1109. sameItemWraplist.push([item]);
  1110. sameItemWrapInfolist.push({
  1111. categoryCode: item.categoryCode,
  1112. quantity: item.quantity,
  1113. index: sameItemWrapInfolist.length
  1114. });
  1115. }
  1116. } else {
  1117. sameItemWraplist.push([item]);
  1118. sameItemWrapInfolist.push({
  1119. categoryCode: item.categoryCode,
  1120. quantity: item.quantity,
  1121. index: 0
  1122. });
  1123. }
  1124. });
  1125. // 添加包装批次号丶包装编码丶包装数量
  1126. const onlyCodeList = await outin.getAssetNum({
  1127. assetCode: list.detailList[0].categoryCode,
  1128. batchNum: batchNo,
  1129. num: list.detailList.length
  1130. });
  1131. Promise.all(
  1132. sameItemWraplist.map(async (goodsItem) => {
  1133. goodsItem = goodsItem.map((wrapItem) => {
  1134. return {
  1135. ...wrapItem,
  1136. assetCode: wrapData.categoryCode,
  1137. assetName: wrapData.categoryName,
  1138. manualBatchNo: wrapData.manualBatchNo,
  1139. batchNo,
  1140. barcodes: wrapItem.sendCode,
  1141. weight: this.isBaoyue?0:wrapItem.packingWeight,
  1142. initWeight: wrapItem.packingWeight,
  1143. weightUtil: wrapItem.weightUnit,
  1144. engrave: wrapItem.extInfo.engrave,
  1145. materielCode: wrapItem.extInfo.materielCode,
  1146. clientCode: wrapItem.extInfo.clientCode,
  1147. num: this.isBaoyue ?this.tableHandle(wrapItem):wrapItem.quantity,
  1148. isPack: false,
  1149. packingCount: this.isBaoyue ? wrapItem.quantity : 1,
  1150. minPackingCount:this.isBaoyue?this.tableHandle(wrapItem):wrapItem.quantity,
  1151. onlyCode: onlyCodeList.shift().onlyCode,
  1152. result: '0',
  1153. status: '1',
  1154. modelType: wrapData.modelType,
  1155. specification: wrapData.specification,
  1156. brandNum: wrapData.brandNum
  1157. };
  1158. });
  1159. console.log(goodsItem);
  1160. return goodsItem;
  1161. })
  1162. ).then((sameItemWraplist) => {
  1163. console.log(sameItemWraplist.flat());
  1164. console.log(sameItemWraplist);
  1165. console.log(sameItemWrapInfolist);
  1166. this.warehousingMaterialList = sameItemWraplist.map((goodsItem) => {
  1167. return {
  1168. assetCode: wrapData.categoryCode,
  1169. assetName: wrapData.categoryName,
  1170. manualBatchNo: wrapData.manualBatchNo,
  1171. modelType: wrapData.modelType,
  1172. specification: wrapData.specification,
  1173. brandNum: wrapData.brandNum,
  1174. batchNo,
  1175. categoryId: goodsItem[0].categoryId,
  1176. minPackingCount: this.isBaoyue ?( this.tableHandle(wrapData)/wrapData.totalPackage).toFixed(5) : goodsItem[0].num,
  1177. outInNum: this.isBaoyue ?wrapData.totalPackage:goodsItem.length,
  1178. minPackUnit: goodsItem[0].packingUnit,
  1179. measuringUnit: goodsItem[0].measuringUnit,
  1180. weight: this.isBaoyue?0:goodsItem.reduce((num, pre) => (num += pre.weight), 0),
  1181. weightUnit: goodsItem[0].weightUnit,
  1182. univalence: wrapData.univalence > 0 ? wrapData.univalence : '',
  1183. warehouseId: goodsItem[0].warehouseId,
  1184. houseList: [],
  1185. warehouseLedgerDetails: goodsItem
  1186. };
  1187. });
  1188. });
  1189. },
  1190. // //宝悦换算
  1191. tableHandle(data) {
  1192. console.log(data,'dsdsds')
  1193. let modelArr = data.specification.split('*');
  1194. let modelLong = modelArr[0]; // model规格长度
  1195. let modeWide = modelArr[1]; // model规格宽度
  1196. let modeHight = modelArr[2].substr(0, modelArr[2].indexOf('cm')); // model规格高度
  1197. return (
  1198. (Number(data.quantity||data.outInNum||data.totalPackage) * modelLong * modeWide * modeHight) /
  1199. 1000000
  1200. ).toFixed(5);
  1201. },
  1202. // 物品类型选择
  1203. codeListValue(val) {
  1204. this.formData.extInfo.assetType = val.id || val;
  1205. this.$forceUpdate();
  1206. this.title = val?.name;
  1207. this.selectEquiType = val?.id || val;
  1208. },
  1209. //计算金额
  1210. calcSumTotal(PackingCount, outInNum, univalence) {
  1211. //最小包装单元,包装数量,单价
  1212. const total = {
  1213. PackingCount: Number(PackingCount > 0 ? PackingCount : 0),
  1214. outInNum: Number(outInNum > 0 ? outInNum : 0),
  1215. univalence: Number(univalence == undefined ? 0 : univalence)
  1216. };
  1217. return Number(
  1218. this.$math.format(
  1219. total.PackingCount * total.outInNum * total.univalence,
  1220. 14
  1221. )
  1222. );
  1223. },
  1224. handleRowUnit(row) {
  1225. return row.measuringUnit;
  1226. },
  1227. rowClass({ row, column, rowIndex, columnIndex }) {
  1228. if (rowIndex === 1) {
  1229. return {
  1230. display: 'none',
  1231. background: '#EEEEEE',
  1232. border: 'none'
  1233. };
  1234. }
  1235. return { background: '#EEEEEE', border: 'none' };
  1236. },
  1237. // 仓库编辑
  1238. handleWareHouse(row, idx) {
  1239. this.$refs.wareHouseDailogRef.open(row, idx, true);
  1240. },
  1241. // 入库操作
  1242. listEdit(row) {
  1243. this.$set(row, 'isSave', false);
  1244. // row.selfWarehouseLedgerDetails = row.warehouseLedgerDetails;
  1245. // row.warehouseLedgerDetails = [];
  1246. // // 重置重量
  1247. // this.packNum(row, row.outInNum);
  1248. // // 清空物料明细防止数据错乱
  1249. // if (this.isSplit && this.resultArray?.length > 0) {
  1250. // this.handleIsDetail(false);
  1251. // }
  1252. },
  1253. // 产品单个保存
  1254. listSave(row, index) {
  1255. // 清空物料明细防止数据错乱
  1256. if (this.isSplit && this.resultArray?.length > 0) {
  1257. this.handleIsDetail(false);
  1258. }
  1259. const fileds = [
  1260. // `warehousingMaterialList.${index}.cargoSpaceCode`,
  1261. // `warehousingMaterialList.${index}.batchNo`,
  1262. `warehousingMaterialList.${index}.houseList`
  1263. ];
  1264. if (this.formData.bizType == 1) {
  1265. // fileds.push(...[`warehousingMaterialList.${index}.customCode`]);
  1266. } else if (this.formData.bizType == 2) {
  1267. // fileds.push(...[`warehousingMaterialList.${index}.supplierCode`]);
  1268. }
  1269. if (this.formData.bizType != 5) {
  1270. // fileds.push(
  1271. // ...[
  1272. // `warehousingMaterialList.${index}.outInNum`,
  1273. // `warehousingMaterialList.${index}.minPackingCount`
  1274. // ]
  1275. // );
  1276. } else if (
  1277. this.warehousingMaterialList.some(
  1278. (i) => !i.selfWarehouseLedgerDetails?.length
  1279. )
  1280. ) {
  1281. this.$message.error('请选择资产编号!');
  1282. return;
  1283. }
  1284. Promise.all(
  1285. fileds.map(
  1286. (item) =>
  1287. new Promise(async (resolve, rej) => {
  1288. this.$refs.warehousingMaterialListRef.validateField(
  1289. item,
  1290. (err) => {
  1291. if (err) {
  1292. rej(err);
  1293. } else {
  1294. resolve();
  1295. }
  1296. }
  1297. );
  1298. })
  1299. )
  1300. )
  1301. .then((res) => {
  1302. console.log('-------------');
  1303. this.$set(row, 'isSave', true);
  1304. // this.createMaterialCode(row);
  1305. })
  1306. .catch((err) => {
  1307. this.$message.error('请填入必填项!');
  1308. });
  1309. },
  1310. // 产品批量保存
  1311. listSaveArrs() {
  1312. // 已经拆分(还原到未拆封编辑状态)
  1313. if (this.isSplit && this.resultArray.length > 0) {
  1314. this.handleIsDetail(false);
  1315. }
  1316. const rows = this.warehousingMaterialList;
  1317. const indexes = Array.from(
  1318. { length: this.warehousingMaterialList.length },
  1319. (_, index) => index
  1320. );
  1321. let showMessage = true;
  1322. rows.forEach((row, i) => {
  1323. const index = indexes[i];
  1324. const fileds = [
  1325. // `warehousingMaterialList.${index}.cargoSpaceCode`,
  1326. // `warehousingMaterialList.${index}.batchNo`,
  1327. `warehousingMaterialList.${index}.houseList`
  1328. ];
  1329. if (this.formData.bizType == 1) {
  1330. // fileds.push(...[`warehousingMaterialList.${index}.customCode`]);
  1331. } else if (this.formData.bizType == 2) {
  1332. // fileds.push(...[`warehousingMaterialList.${index}.supplierCode`]);
  1333. }
  1334. if (this.formData.bizType != 5) {
  1335. // fileds.push(
  1336. // ...[
  1337. // `warehousingMaterialList.${index}.outInNum`,
  1338. // `warehousingMaterialList.${index}.minPackingCount`
  1339. // ]
  1340. // );
  1341. } else if (
  1342. this.warehousingMaterialList.some(
  1343. (i) => !i.selfWarehouseLedgerDetails?.length
  1344. )
  1345. ) {
  1346. this.$message.error('请选择资产编号!');
  1347. return;
  1348. }
  1349. Promise.all(
  1350. fileds.map(
  1351. (item) =>
  1352. new Promise(async (resolve, rej) => {
  1353. this.$refs.warehousingMaterialListRef.validateField(
  1354. item,
  1355. (err) => {
  1356. if (err) {
  1357. rej(err);
  1358. } else {
  1359. resolve();
  1360. }
  1361. }
  1362. );
  1363. })
  1364. )
  1365. )
  1366. .then((res) => {
  1367. this.$set(row, 'isSave', true);
  1368. // this.createMaterialCode(row);
  1369. })
  1370. .catch((err) => {
  1371. if (showMessage) {
  1372. showMessage = false;
  1373. this.$message.error('请填入必填项!');
  1374. }
  1375. });
  1376. });
  1377. },
  1378. // 批量设置生产日期
  1379. handleSelectionChange(val) {
  1380. this.materialCodeReqListSelected = val;
  1381. },
  1382. dateSetting() {
  1383. if (!this.materialCodeReqListSelected.length) {
  1384. return this.$message.error(`请选择${this.title}明细!`);
  1385. }
  1386. this.dateVisible = true;
  1387. },
  1388. dateConfirm() {
  1389. this.materialCodeReqListSelected.forEach((item) => {
  1390. this.$set(item, this.curDateType, this.batchTime);
  1391. });
  1392. this.dateVisible = false;
  1393. },
  1394. //入库明细删除
  1395. listDel(row, index) {
  1396. this.warehousingMaterialList.splice(index, 1);
  1397. if (this.isSplit && this.resultArray?.length > 0) {
  1398. this.handleIsDetail(false);
  1399. }
  1400. },
  1401. // 入库明细生成条码信息
  1402. async createMaterialCode(row) {
  1403. // 添加相同物品、批次号重新更新明细 原料编码
  1404. const list = this.warehousingMaterialList.filter(
  1405. (i) =>
  1406. i.assetCode === row.assetCode && i.batchNo === row.batchNo && i.isSave
  1407. );
  1408. const num = list.reduce((num, pre) => {
  1409. num += row.isUnpack
  1410. ? pre.outInNum * pre.minPackingCount
  1411. : pre.outInNum - 0;
  1412. return num;
  1413. }, 0);
  1414. const nums = list.reduce((num, pre) => {
  1415. num += pre.outInNum * pre.minPackingCount;
  1416. return num;
  1417. }, 0);
  1418. const res = await outin.getAssetNum({
  1419. assetCode: row.assetCode,
  1420. batchNum: row.batchNo,
  1421. num: num
  1422. });
  1423. // row.measuringUnit == 'PCS' ? nums :
  1424. list.forEach((item) => {
  1425. if (item.warehouseLedgerDetails?.length) {
  1426. item.warehouseLedgerDetails.forEach((i) => {
  1427. i.onlyCode = res.shift().onlyCode;
  1428. });
  1429. } else {
  1430. this.$set(
  1431. item,
  1432. 'warehouseLedgerDetails',
  1433. Array.from(
  1434. new Array(
  1435. item.isUnpack
  1436. ? item.outInNum * item.minPackingCount
  1437. : // : item.measuringUnit == 'PCS'
  1438. // ? +item.outInNum * parseInt(item.minPackingCount)
  1439. +item.outInNum
  1440. ),
  1441. (val, idx) => {
  1442. return {
  1443. ...item,
  1444. onlyCode: res.shift().onlyCode,
  1445. bizStatus: 1,
  1446. contentImage: []
  1447. };
  1448. }
  1449. )
  1450. );
  1451. }
  1452. });
  1453. // 添加相同物品,重复批次号 重新更新明细 包装编码
  1454. const batchList = this.warehousingMaterialList.filter(
  1455. (i) => i.batchNo === row.batchNo && i.isSave
  1456. );
  1457. if (batchList.length) {
  1458. const num = batchList.reduce((num, pre) => {
  1459. num += +pre.outInNum;
  1460. return num;
  1461. }, 0);
  1462. const res1 = await outin.getAssetNum({
  1463. batchNum: row.batchNo,
  1464. num
  1465. });
  1466. if (res1) {
  1467. batchList.forEach((item) => {
  1468. let num = res1.shift()?.num;
  1469. let minPackingCount = item.minPackingCount;
  1470. if (item.warehouseLedgerDetails?.length) {
  1471. item.warehouseLedgerDetails.forEach((i, index) => {
  1472. this.$set(i, 'num', num);
  1473. if (row.code == i.code) {
  1474. if (item.measuringUnit == item.weightUnit) {
  1475. this.$set(i, 'weight', item.minPackingCount);
  1476. this.$set(i, 'initWeight', item.minPackingCount);
  1477. } else {
  1478. this.$set(
  1479. i,
  1480. 'weight',
  1481. Number(
  1482. this.$math.format(
  1483. 1 * item.minPackingCount * item.netWeight,
  1484. 14
  1485. )
  1486. )
  1487. );
  1488. this.$set(
  1489. i,
  1490. 'initWeight',
  1491. Number(
  1492. this.$math.format(
  1493. 1 * item.minPackingCount * item.netWeight,
  1494. 14
  1495. )
  1496. )
  1497. );
  1498. }
  1499. }
  1500. this.$set(i, 'weightUtil', item.weightUnit);
  1501. this.$set(i, 'packingCount', 1);
  1502. this.$set(i, 'packingUnit ', item.packingUnit);
  1503. this.$set(i, 'minPackingCount ', item.minPackingCount);
  1504. this.$set(i, 'measuringUnit', item.measuringUnit);
  1505. this.$set(i, 'isPack', false);
  1506. console.log('inboundType------------', this.inboundType);
  1507. if (this.inboundType == '1') {
  1508. // 生产性采购(未检)
  1509. this.$set(i, 'result', '');
  1510. this.$set(i, 'status', '0');
  1511. } else {
  1512. // 非生产性采购(已检合格)
  1513. this.$set(i, 'result', '0');
  1514. this.$set(i, 'status', '1');
  1515. }
  1516. if (!item.isUnpack) {
  1517. if (index < item.warehouseLedgerDetails.length - 1) {
  1518. num = res1.shift()?.num;
  1519. }
  1520. } else {
  1521. // 拆包的包装编码一致
  1522. minPackingCount--;
  1523. if (
  1524. minPackingCount === 0 &&
  1525. index < item.warehouseLedgerDetails.length - 1
  1526. ) {
  1527. minPackingCount = item.minPackingCount;
  1528. num = res1.shift()?.num;
  1529. }
  1530. }
  1531. });
  1532. }
  1533. });
  1534. }
  1535. }
  1536. },
  1537. // 包装批量保存
  1538. wrapListSave() {
  1539. // 批量修改包装明细
  1540. this.isWeight = false;
  1541. this.bulkEditingWrap();
  1542. this.$nextTick(() => {
  1543. this.isWeight = true;
  1544. });
  1545. },
  1546. // 物料批量保存
  1547. materialListSave() {
  1548. this.resultArray.forEach((item) => {
  1549. if (!item.isPack) {
  1550. this.materialBtn(item);
  1551. }
  1552. });
  1553. },
  1554. // 入库
  1555. save() {
  1556. this.$refs.formName.validate(async (valid) => {
  1557. if (valid) {
  1558. if (!this.warehousingMaterialList?.length) {
  1559. return this.$message.error('请添加入库明细!');
  1560. } else if (
  1561. this.warehousingMaterialList.some((item) => !item.isSave)
  1562. ) {
  1563. return this.$message.error('请保存入库明细!');
  1564. }
  1565. // 默认全部保存
  1566. // if (this.resultArray?.length > 0) {
  1567. // // 物料批量保存
  1568. // this.materialListSave();
  1569. // } else {
  1570. // // 包装批量保存
  1571. // this.wrapListSave();
  1572. // }
  1573. this.formatWarehouseMaterialList();
  1574. let arr = this.warehousingMaterialList.map((item) => {
  1575. console.log(item, 'item');
  1576. return {
  1577. netWeight: item.netWeight > 0 ? item.netWeight : 0,
  1578. num: item.num > 0 ? item.num : 0,
  1579. manualBatchNo: item.manualBatchNo,
  1580. batchNo: item.batchNo,
  1581. categoryId: item.categoryId,
  1582. count:
  1583. item.outInNum > 0 && item.minPackingCount > 0
  1584. ? this.$math.format(
  1585. parseInt(item.outInNum) * parseInt(item.minPackingCount),
  1586. 14
  1587. )
  1588. : 0,
  1589. minPackingCount:
  1590. item.minPackingCount > 0 ? item.minPackingCount : 0,
  1591. packingCount: item.outInNum > 0 ? item.outInNum : 0,
  1592. price: item.univalence > 0 ? item.univalence : 0,
  1593. outInDetailRecordAddPOList: item.warehouseLedgerDetails,
  1594. manualBatchNo: item.manualBatchNo,
  1595. position: `${item.warehouseName}-${item.areaName}-${item.shelfCode}-${item.cargoSpaceCode}`,
  1596. remark: '',
  1597. pathIds: `${item.warehouseId},${item.areaId},${item.shelfId},${item.cargoSpaceId}`,
  1598. pathName: `${item.warehouseName},${item.areaName},${item.shelfCode},${item.cargoSpaceCode}`,
  1599. totalMoney:
  1600. item.outInNum > 0 &&
  1601. item.minPackingCount > 0 &&
  1602. item.univalence > 0
  1603. ? this.$math.format(
  1604. item.outInNum * item.minPackingCount * item.univalence,
  1605. 14
  1606. )
  1607. : 0,
  1608. weightUnit: item.weightUnit,
  1609. customCode: item.customCode,
  1610. supplierCode: item.supplierCode,
  1611. weight: item.weight > 0 ? item.weight : 0,
  1612. houseList: [
  1613. `${item.warehouseName},${item.areaName},${item.shelfCode},${item.cargoSpaceCode}`
  1614. ]
  1615. };
  1616. });
  1617. arr.forEach((item) => {
  1618. if (item.outInDetailRecordAddPOList.length > 0) {
  1619. let list = item.outInDetailRecordAddPOList.map((it) => {
  1620. return this.formatOutInDetailRecordAddPO(it, item);
  1621. });
  1622. item.outInDetailRecordAddPOList = list;
  1623. }
  1624. });
  1625. let obj = { ...this.formData, type: 1 };
  1626. obj.outInDetailAddPOList = arr;
  1627. obj.storageSource = 1;
  1628. this.isLoading = true;
  1629. outin
  1630. .save(obj)
  1631. .then( async (res) => {
  1632. if (res.code == 0) {
  1633. await updateApprovalStatus(this.pickerRow.id)
  1634. this.$emit('success')
  1635. this.isLoading = false;
  1636. this.visible = false;
  1637. this.$message.success('入库成功!');
  1638. }
  1639. })
  1640. .catch((err) => {
  1641. this.isLoading = false;
  1642. });
  1643. }
  1644. });
  1645. },
  1646. // 格式化产品信息入库数据
  1647. formatWarehouseMaterialList() {
  1648. for (let key in this.warehousingMaterialList) {
  1649. for (let k in this.warehousingMaterialList[key].houseList) {
  1650. let house = this.warehousingMaterialList[key].houseList[k];
  1651. this.warehousingMaterialList[key].warehouseName = house.warehouseName;
  1652. this.warehousingMaterialList[key].areaName = house.areaName;
  1653. this.warehousingMaterialList[key].shelfCode = house.shelfCode;
  1654. this.warehousingMaterialList[key].cargoSpaceCode =
  1655. house.cargoSpaceCode;
  1656. this.warehousingMaterialList[key].warehouseId = house.warehouseId;
  1657. this.warehousingMaterialList[key].areaId = house.areaId;
  1658. this.warehousingMaterialList[key].shelfId = house.shelfId;
  1659. this.warehousingMaterialList[key].cargoSpaceId = house.cargoSpaceId;
  1660. this.warehousingMaterialList[key].num = house.num;
  1661. }
  1662. }
  1663. },
  1664. // 格式化包装明细入库数据
  1665. formatOutInDetailRecordAddPO(it, item) {
  1666. return {
  1667. code: it.onlyCode,
  1668. dateType: this.curDateType === 'manufactureTime' ? 2 : 1,
  1669. dateValue: it[this.curDateType],
  1670. minUnit: it.minPackingCount,
  1671. minPositionId: it.cargoSpaceId,
  1672. minPackingCount: it.minPackingCount,
  1673. name: it.assetName,
  1674. pathIds: item.pathIds,
  1675. unit: it.unit,
  1676. barcodes: it.barcodes,
  1677. manualBatchNo: it.manualBatchNo,
  1678. packageNo: it.num,
  1679. clientCode: it.clientCode,
  1680. materielCode: it.materielCode,
  1681. weight: it.weight,
  1682. weightUtil: it.weightUtil,
  1683. engrave: it.engrave,
  1684. materialDetails: this.materialDetails(it.onlyCode),
  1685. packingCount: it.packingCount,
  1686. status: it.status,
  1687. result: it.result
  1688. };
  1689. },
  1690. // 过滤物料明细入库数据
  1691. materialDetails(onlyCode) {
  1692. return this.resultArray.filter((item) => item.onlyCode === onlyCode);
  1693. },
  1694. // 添加物品明细
  1695. addProduct(val) {
  1696. // 已经拆分(还原到未拆封编辑状态)
  1697. if (this.isSplit && this.resultArray.length > 0) {
  1698. this.handleIsDetail(false);
  1699. }
  1700. this.onSelectTableData(val);
  1701. },
  1702. //添加产品明细
  1703. async onSelectTableData(val) {
  1704. const res = await getCode('lot_number_code');
  1705. this.warehousingMaterialList.push(
  1706. ...val.map((next) => {
  1707. next.batchNo = res;
  1708. let cur = {};
  1709. next.realInventoryAmount = next.realInventoryAmount || 0;
  1710. cur = {
  1711. ...next,
  1712. cargoSpaceCode: '', //货位编码
  1713. cargoSpaceId: '', //货位id
  1714. shelfId: '', //货架id
  1715. shelfCode: '', //货架名称
  1716. areaId: '', //库区id
  1717. areaName: '', //库区名称
  1718. warehouseId: '', //仓库id
  1719. warehouseName: '', //仓库名称
  1720. assetType: this.formData.extInfo.assetType,
  1721. expirationDate: '',
  1722. outInNum: '',
  1723. minPackingCount: '',
  1724. bizStatus: 1,
  1725. contentImage: [],
  1726. warehouseLedgerDetails: [],
  1727. houseList: []
  1728. };
  1729. return cur;
  1730. })
  1731. );
  1732. },
  1733. async initData() {
  1734. const { data } = await allCategoryLevel();
  1735. this.codeList = data;
  1736. console.log(this.codeList, 'codeList--------------');
  1737. const res = await warehouseDefinition.tree();
  1738. const info = await getLoginUser();
  1739. let obj = res.find(
  1740. (item) => item.id === info.deptIds[info.deptIds.length - 1]
  1741. );
  1742. if (!obj) return;
  1743. this.formData.extInfo.deptCode = obj.id;
  1744. this.formData.extInfo.deptName = obj.name;
  1745. this.formData.extInfo.createUserName = info.name;
  1746. this.formData.createUserId = info.id;
  1747. },
  1748. // 添加产品信息
  1749. addStock() {
  1750. if (!this.title) {
  1751. return this.$message.error('请选择入库产品类型');
  1752. }
  1753. if (!this.formData.bizType) {
  1754. return this.$message.error('请选择入库场景');
  1755. }
  1756. this.visibleDialog = true;
  1757. },
  1758. upload(data) {
  1759. this.formData.contentImage = data;
  1760. this.$refs.formName.validateField('contentImage');
  1761. },
  1762. houseData(argum, idx) {
  1763. this.$set(this.warehousingMaterialList[idx], 'houseList', argum);
  1764. },
  1765. },
  1766. watch: {
  1767. // 解决右侧悬浮操作栏不对称问题
  1768. warehousingMaterialList: {
  1769. handler() {
  1770. this.$nextTick(() => {
  1771. this.$refs.warehousingMaterialListTable?.doLayout();
  1772. });
  1773. },
  1774. deep: true
  1775. },
  1776. // 解决右侧悬浮操作栏不对称问题
  1777. materialCodeReqList: {
  1778. handler() {
  1779. this.$nextTick(() => {
  1780. this.$refs.materialCodeReqListTable?.doLayout();
  1781. });
  1782. },
  1783. deep: true
  1784. },
  1785. // 解决右侧悬浮操作栏不对称问题
  1786. resultArray: {
  1787. handler() {
  1788. this.$nextTick(() => {
  1789. this.$refs.resultArrayTable?.doLayout();
  1790. });
  1791. },
  1792. deep: true
  1793. }
  1794. }
  1795. };
  1796. </script>
  1797. <style lang="scss" scoped>
  1798. ::v-deep.form-table {
  1799. .el-form-item {
  1800. margin-bottom: 0;
  1801. }
  1802. .el-input__inner {
  1803. padding: 0 10px;
  1804. }
  1805. ::-webkit-scrollbar {
  1806. width: 8px;
  1807. height: 8px;
  1808. background-color: transparent;
  1809. }
  1810. }
  1811. .p20 {
  1812. padding: 20px;
  1813. }
  1814. .el-select,
  1815. .el-date-editor {
  1816. width: 100%;
  1817. }
  1818. .el-form-item {
  1819. margin-bottom: 22px;
  1820. }
  1821. .material {
  1822. margin-top: 20px;
  1823. .flex {
  1824. display: flex;
  1825. justify-content: space-between;
  1826. font-size: 14px;
  1827. align-items: center;
  1828. .red {
  1829. color: #ff4949;
  1830. }
  1831. }
  1832. }
  1833. .mt10 {
  1834. margin-top: 10px;
  1835. }
  1836. .mt20 {
  1837. margin-top: 20px;
  1838. }
  1839. .center {
  1840. text-align: center;
  1841. }
  1842. .switch_left li {
  1843. border-right: 1px solid rgba(222, 222, 222, 1);
  1844. border-left: 1px solid rgba(222, 222, 222, 1);
  1845. }
  1846. .fontOmitted {
  1847. text-overflow: ellipsis;
  1848. overflow: hidden;
  1849. word-break: break-all;
  1850. white-space: nowrap;
  1851. }
  1852. .table-fixed {
  1853. .el-table__fixed-right {
  1854. height: 100% !important;
  1855. }
  1856. .el-table__fixed-left {
  1857. height: 100% !important;
  1858. }
  1859. .el-table__fixed {
  1860. height: 100% !important;
  1861. }
  1862. }
  1863. </style>