add.vue 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <header-title title="基本信息">
  5. <div class="right_control">
  6. <el-upload
  7. ref="fileUploadBtn"
  8. action="#"
  9. :auto-upload="false"
  10. :on-change="onChange"
  11. :limit="1"
  12. :show-file-list="false"
  13. accept=".xls,.xlsx"
  14. >
  15. <el-button type="primary">备品备件导入excel</el-button>
  16. </el-upload>
  17. <el-button type="primary" @click="back">返回</el-button>
  18. </div>
  19. </header-title>
  20. <el-form
  21. :model="formData"
  22. ref="formName"
  23. label-width="110px"
  24. :rules="rules"
  25. >
  26. <el-row :gutter="20">
  27. <el-col :span="6">
  28. <el-form-item label="物品类型" prop="extInfo.assetType">
  29. <el-select
  30. style="width: 100%"
  31. multiple
  32. v-model="formData.extInfo.assetType"
  33. placeholder="请选择"
  34. >
  35. <el-option
  36. v-for="item in goodsLists"
  37. :key="item.id"
  38. :label="item.name"
  39. :value="item.id"
  40. >
  41. </el-option>
  42. </el-select>
  43. </el-form-item>
  44. </el-col>
  45. <el-col :span="6">
  46. <el-form-item label="入库类型" prop="bizType">
  47. <el-select
  48. style="width: 100%"
  49. filterable
  50. placeholder="请选择"
  51. v-model="formData.bizType"
  52. clearable
  53. >
  54. <el-option
  55. v-for="item in sceneState"
  56. :key="item.code"
  57. :value="item.code + ''"
  58. :label="item.label"
  59. ></el-option>
  60. </el-select> </el-form-item
  61. ></el-col>
  62. <el-col :span="6">
  63. <el-form-item label="单据来源" prop="documentSource">
  64. <el-input
  65. placeholder="请选择"
  66. v-model="formData.extInfo.documentSource"
  67. @click.native="openDocumentSourceDialog"
  68. >
  69. <el-button
  70. @click="clearDocumentSource"
  71. slot="append"
  72. icon="el-icon-circle-close"
  73. ></el-button>
  74. </el-input>
  75. </el-form-item>
  76. </el-col>
  77. <!-- <el-col :span="6">
  78. <el-form-item label="权属部门" prop="deptName">
  79. <el-input
  80. placeholder="权属部门"
  81. disabled
  82. v-model="formData.extInfo.deptName"
  83. clearable
  84. />
  85. </el-form-item>
  86. </el-col> -->
  87. <el-col :span="6">
  88. <el-form-item label="入库登记人">
  89. <el-input
  90. placeholder="登记人"
  91. disabled
  92. v-model="formData.extInfo.createUserName"
  93. clearable /></el-form-item
  94. ></el-col>
  95. <el-col :span="6" v-if="formData.bizType == 2">
  96. <el-form-item label="供应商" prop="supplierName">
  97. <el-input
  98. placeholder="请输入"
  99. clearable
  100. v-model="formData.extInfo.supplierName"
  101. />
  102. </el-form-item>
  103. </el-col>
  104. <el-col :span="6">
  105. <el-form-item label="送货人" prop="fromUser">
  106. <el-input
  107. placeholder="请输入"
  108. v-model="formData.fromUser"
  109. clearable
  110. /> </el-form-item
  111. ></el-col>
  112. <el-col :span="6">
  113. <el-form-item label="送货人联系方式" prop="deliveryPhone">
  114. <el-input
  115. placeholder="请输入"
  116. v-model="formData.extInfo.deliveryPhone"
  117. clearable /></el-form-item
  118. ></el-col>
  119. <el-col :span="12">
  120. <el-form-item label="备注" prop="remark">
  121. <el-input
  122. v-model="formData.remark"
  123. placeholder="请详细说明"
  124. ></el-input>
  125. </el-form-item>
  126. </el-col>
  127. </el-row>
  128. </el-form>
  129. <div class="inbound_details">
  130. <header-title title="产品信息">
  131. <el-button type="primary" @click="addProduct">添加</el-button>
  132. </header-title>
  133. <div class="form_table">
  134. <el-form
  135. ref="productListRef"
  136. :model="{ productList: productList }"
  137. :show-message="false"
  138. >
  139. <el-button
  140. v-if="productList.length != 0"
  141. type="success"
  142. plain
  143. style="margin-bottom: 20px; float: right; margin-right: 20px"
  144. size="mini"
  145. @click="listSaveArrs"
  146. >批量保存</el-button
  147. >
  148. <el-button
  149. v-if="productList.length != 0 && this.packingList.length == 0"
  150. type="success"
  151. plain
  152. style="margin-bottom: 20px; float: right; margin-right: 20px"
  153. size="mini"
  154. @click="handleWareHouse(productList[0])"
  155. >批量选择仓库</el-button
  156. >
  157. <el-table
  158. :header-cell-style="rowClass"
  159. :max-height="300"
  160. border
  161. ref="productListTable"
  162. :data="productList"
  163. tooltip-effect="dark"
  164. >
  165. <el-table-column
  166. label="序号"
  167. type="index"
  168. width="50"
  169. align="center"
  170. >
  171. </el-table-column>
  172. <el-table-column
  173. label="编码"
  174. prop="categoryCode"
  175. align="center"
  176. width="130"
  177. :show-overflow-tooltip="true"
  178. ></el-table-column>
  179. <el-table-column
  180. label="名称"
  181. align="center"
  182. width="200"
  183. prop="categoryName"
  184. :show-overflow-tooltip="true"
  185. ></el-table-column>
  186. <el-table-column
  187. label="型号"
  188. align="center"
  189. width="100"
  190. prop="categoryModel"
  191. :show-overflow-tooltip="true"
  192. ></el-table-column>
  193. <el-table-column
  194. label="规格"
  195. align="center"
  196. width="100"
  197. prop="specification"
  198. :show-overflow-tooltip="true"
  199. ></el-table-column>
  200. <el-table-column
  201. label="牌号"
  202. align="center"
  203. width="100"
  204. prop="brandNum"
  205. :show-overflow-tooltip="true"
  206. ></el-table-column>
  207. <el-table-column
  208. label="批次号"
  209. align="center"
  210. width="100"
  211. prop="batchNo"
  212. >
  213. <template slot-scope="{ row, $index }">
  214. <template v-if="row.isSave">
  215. {{ row.batchNo }}
  216. </template>
  217. <el-form-item
  218. v-else
  219. :prop="`productList.${$index}.batchNo`"
  220. required
  221. >
  222. <el-input
  223. :ref="'batchNo' + $index"
  224. @keyup.native="
  225. moveFocus($event, $index, 'batchNo', '产品', row)
  226. "
  227. v-model.number="row.batchNo"
  228. >
  229. </el-input>
  230. </el-form-item>
  231. </template>
  232. </el-table-column>
  233. <el-table-column
  234. label="最小包装单元"
  235. align="center"
  236. prop="minPackingQuantity"
  237. width="200"
  238. >
  239. <template slot-scope="{ row, $index }">
  240. <template v-if="row.isSave">
  241. {{ row.minPackingQuantity }}
  242. </template>
  243. <el-form-item
  244. v-else
  245. :prop="`productList.${$index}.minPackingQuantity`"
  246. required
  247. >
  248. <el-input
  249. type="number"
  250. :ref="'minPackingQuantity' + $index"
  251. @keyup.native="
  252. moveFocus(
  253. $event,
  254. $index,
  255. 'minPackingQuantity',
  256. '产品',
  257. row
  258. )
  259. "
  260. v-model="row.minPackingQuantity"
  261. @input="minPackingQuantityChange(row, $event, $index)"
  262. >
  263. <template slot="append">
  264. {{ row.measureUnit }} /{{ row.packingUnit }}
  265. </template>
  266. </el-input>
  267. </el-form-item>
  268. </template>
  269. </el-table-column>
  270. <el-table-column
  271. label="包装数量"
  272. prop="packingQuantity"
  273. width="150"
  274. align="center"
  275. >
  276. <template slot-scope="{ row, $index }">
  277. <template v-if="row.isSave">
  278. {{ row.packingQuantity }} {{ row.packingUnit }}
  279. </template>
  280. <el-form-item
  281. v-else
  282. :prop="`productList.${$index}.packingQuantity`"
  283. required
  284. >
  285. <el-input
  286. :ref="'packingQuantity' + $index"
  287. @keyup.native="
  288. moveFocus(
  289. $event,
  290. $index,
  291. 'packingQuantity',
  292. '产品',
  293. row
  294. )
  295. "
  296. v-model.number="row.packingQuantity"
  297. @input="packNum(row, $event, $index)"
  298. >
  299. <template slot="append">
  300. {{ row.packingUnit ? row.packingUnit : '/' }}
  301. </template>
  302. </el-input>
  303. </el-form-item>
  304. </template>
  305. </el-table-column>
  306. <el-table-column
  307. label="计量数量"
  308. prop="measureQuantity"
  309. :show-overflow-tooltip="true"
  310. >
  311. <template slot-scope="{ row, $index }">
  312. {{
  313. $math.format(
  314. row.minPackingQuantity * row.packingQuantity,
  315. 14
  316. )
  317. }}
  318. </template>
  319. </el-table-column>
  320. <el-table-column
  321. label="计量单位"
  322. prop="measureUnit"
  323. width="100"
  324. align="center"
  325. >
  326. <template slot-scope="{ row, $index }">
  327. <template>
  328. {{ row.measureUnit }}
  329. </template>
  330. </template>
  331. </el-table-column>
  332. <el-table-column
  333. label="重量"
  334. align="center"
  335. prop="weight"
  336. :show-overflow-tooltip="true"
  337. >
  338. <template slot-scope="{ row, $index }">
  339. {{ row.weight }}
  340. <template slot="append">
  341. {{ row.measureUnit }}
  342. </template>
  343. </template>
  344. </el-table-column>
  345. <el-table-column
  346. label="重量单位"
  347. align="center"
  348. prop="weightUnit"
  349. :show-overflow-tooltip="true"
  350. >
  351. <template slot-scope="{ row, $index }">
  352. {{ row.weightUnit }}
  353. <template slot="append"> </template>
  354. </template>
  355. </el-table-column>
  356. <el-table-column
  357. label="单价"
  358. prop="price"
  359. width="200"
  360. align="center"
  361. >
  362. <template slot-scope="{ row, $index }">
  363. <template v-if="row.isSave">
  364. {{ row.price }}元/{{ row.measureUnit }}
  365. </template>
  366. <el-form-item v-else>
  367. <el-input
  368. type="number"
  369. :ref="'price' + $index"
  370. @keyup.native="
  371. moveFocus($event, $index, 'price', '产品', row)
  372. "
  373. v-model.number="row.price"
  374. placeholder="非必填"
  375. @input="
  376. (value) => (row.price = value.replace(/[^0-9.]+/g, ''))
  377. "
  378. >
  379. <template slot="append">
  380. 元/{{ row.measureUnit }}
  381. </template>
  382. </el-input>
  383. </el-form-item>
  384. </template>
  385. </el-table-column>
  386. <el-table-column
  387. label="金额"
  388. align="center"
  389. prop="contentImage"
  390. :show-overflow-tooltip="true"
  391. >
  392. <template slot-scope="{ row, $index }">
  393. {{
  394. calcSumTotal(
  395. row.packingQuantity,
  396. row.minPackingQuantity,
  397. row.price,
  398. row
  399. )
  400. }}
  401. </template>
  402. </el-table-column>
  403. <el-table-column
  404. label="仓库"
  405. align="center"
  406. prop="warehouseName"
  407. :show-overflow-tooltip="true"
  408. width="300"
  409. >
  410. <template slot-scope="{ row, $index }">
  411. <el-form-item
  412. :prop="`productList.${$index}.warehouseId`"
  413. required
  414. >
  415. <div
  416. :class="
  417. row.warehouseName
  418. ? 'wareHouse_style'
  419. : 'wareHouse_style red_color'
  420. "
  421. @click="handleWareHouse(row, $index)"
  422. >
  423. <span>
  424. {{
  425. row.warehouseName ? row.warehouseName : '请选择仓库'
  426. }}
  427. </span>
  428. </div>
  429. </el-form-item>
  430. </template>
  431. </el-table-column>
  432. <el-table-column
  433. label="采购原因"
  434. align="center"
  435. width="200"
  436. prop="purpose"
  437. :show-overflow-tooltip="true"
  438. >
  439. <template slot-scope="{ row, $index }">
  440. <template v-if="row.isSave">
  441. {{ row.purpose }}
  442. </template>
  443. <el-input
  444. v-else
  445. :ref="'purpose' + $index"
  446. @keyup.native="
  447. moveFocus($event, $index, 'purpose', '产品', row)
  448. "
  449. v-model="row.purpose"
  450. >
  451. </el-input>
  452. </template>
  453. </el-table-column>
  454. <el-table-column
  455. label="操作"
  456. width="200"
  457. fixed="right"
  458. align="center"
  459. >
  460. <template slot="header" slot-scope="scope"> 操作 </template>
  461. <template slot-scope="{ row, $index }">
  462. <el-button
  463. type="text"
  464. v-show="!row.isSave"
  465. @click="listSave(row, $index)"
  466. >保存</el-button
  467. >
  468. <el-button
  469. type="text"
  470. v-show="row.isSave"
  471. @click="listEdit(row, $index)"
  472. >编辑</el-button
  473. >
  474. <el-button type="text" @click="listDel(row, $index)"
  475. >删除</el-button
  476. >
  477. </template>
  478. </el-table-column>
  479. </el-table>
  480. </el-form>
  481. </div>
  482. </div>
  483. <div v-if="showPackingList.length > 0" class="inbound_details">
  484. <header-title :title="`包装明细`">
  485. <div class="switch_right">
  486. <el-button
  487. style="margin-left: 20px"
  488. type="text"
  489. @click="dateSetting"
  490. >批量设置{{
  491. curDateType === 'productionDate' ? '生产日期' : '采购日期'
  492. }}</el-button
  493. >
  494. </div>
  495. </header-title>
  496. <el-table
  497. v-if="isWrapTable"
  498. ref="packingListTable"
  499. :data="showPackingList"
  500. tooltip-effect="dark"
  501. :key="formData.bizType"
  502. :header-cell-style="rowClass"
  503. style="width: 100%"
  504. border
  505. stripe
  506. :max-height="300"
  507. v-el-table-infinite-scroll="pickingHandleScroll"
  508. @selection-change="handleSelectionChange"
  509. >
  510. <el-table-column
  511. fixed="left"
  512. type="selection"
  513. align="center"
  514. width="50"
  515. >
  516. </el-table-column>
  517. <el-table-column label="序号" type="index" width="50">
  518. </el-table-column>
  519. <el-table-column
  520. label="编码"
  521. prop="categoryCode"
  522. width="130"
  523. :show-overflow-tooltip="true"
  524. ></el-table-column>
  525. <el-table-column
  526. label="名称"
  527. prop="categoryName"
  528. width="150"
  529. :show-overflow-tooltip="true"
  530. ></el-table-column>
  531. <el-table-column
  532. label="批次号"
  533. prop="batchNo"
  534. width="70"
  535. ></el-table-column>
  536. <el-table-column
  537. :label="`包装编码`"
  538. prop="packageNo"
  539. width="200"
  540. :show-overflow-tooltip="true"
  541. ></el-table-column>
  542. <el-table-column
  543. label="包装数量"
  544. prop="packingQuantity"
  545. width="80"
  546. ></el-table-column>
  547. <el-table-column
  548. label="包装单位"
  549. prop="packingUnit"
  550. ></el-table-column>
  551. <el-table-column
  552. label="计量数量"
  553. prop="measureQuantity"
  554. :show-overflow-tooltip="true"
  555. ></el-table-column>
  556. <el-table-column
  557. label="计量单位"
  558. prop="measureUnit"
  559. ></el-table-column>
  560. <el-table-column label="允许拆包" prop="isUnpack">
  561. <template slot-scope="{ row, $index }">
  562. {{ row.isUnpack ? '是' : '否' }}
  563. </template>
  564. </el-table-column>
  565. <el-table-column
  566. label="仓库"
  567. :show-overflow-tooltip="true"
  568. prop="warehouseName"
  569. width="200"
  570. ></el-table-column>
  571. <el-table-column
  572. label="物料代号"
  573. prop="materielDesignation"
  574. width="130"
  575. >
  576. <template slot-scope="{ row, $index }">
  577. <el-input
  578. v-if="!row.isPack"
  579. :ref="'packing_materielDesignation' + $index"
  580. @keyup.native="
  581. moveFocus(
  582. $event,
  583. $index,
  584. 'packing_materielDesignation',
  585. '包装',
  586. row
  587. )
  588. "
  589. v-model="row.materielDesignation"
  590. ></el-input>
  591. <span v-else>{{ row.materielDesignation }}</span>
  592. </template>
  593. </el-table-column>
  594. <el-table-column label="客户代号" prop="clientCode">
  595. <template slot-scope="{ row, $index }">
  596. <el-input
  597. v-if="!row.isPack"
  598. :ref="'packing_clientCode' + $index"
  599. @keyup.native="
  600. moveFocus($event, $index, 'packing_clientCode', '包装', row)
  601. "
  602. v-model="row.clientCode"
  603. ></el-input>
  604. <span v-else> {{ row.clientCode }}</span>
  605. </template>
  606. </el-table-column>
  607. <el-table-column label="刻码" prop="engrave" width="140">
  608. <template slot-scope="{ row, $index }">
  609. <el-input
  610. v-if="!row.isPack"
  611. :ref="'packing_engrave' + $index"
  612. @keyup.native="
  613. moveFocus($event, $index, 'packing_engrave', '包装', row)
  614. "
  615. v-model="row.engrave"
  616. ></el-input>
  617. <span v-else>{{ row.engrave }}</span>
  618. </template>
  619. </el-table-column>
  620. <el-table-column label="重量" prop="weight" width="100">
  621. <template slot-scope="{ row, $index }">
  622. <el-input
  623. v-if="!row.isPack && row.measureUnit != row.weightUnit"
  624. :ref="'packing_weight' + $index"
  625. @keyup.native="
  626. moveFocus($event, $index, 'packing_weight', '包装', row)
  627. "
  628. v-model.number="row.weight"
  629. @input="weightInput($event, row, '包装')"
  630. ></el-input>
  631. <span v-else>{{ row.weight }}</span>
  632. </template>
  633. </el-table-column>
  634. <el-table-column label="重量单位" prop="weightUnit">
  635. <template slot-scope="{ row }">
  636. {{ row.weightUnit }}
  637. </template>
  638. </el-table-column>
  639. <el-table-column label="质检结果" prop="result" width="120">
  640. <template slot-scope="{ row }">
  641. <el-select
  642. v-if="!row.isPack"
  643. @change="changeWrapStatus($event, row, '包装')"
  644. v-model="row.result"
  645. placeholder="请选择"
  646. >
  647. <el-option
  648. v-for="item in qualityResultsOptions"
  649. :label="item.label"
  650. :value="item.value"
  651. :key="item.value"
  652. >
  653. </el-option>
  654. </el-select>
  655. <span v-else>{{ qualityResults[row.result] }}</span>
  656. </template>
  657. </el-table-column>
  658. <el-table-column label="质检状态" prop="status" width="120">
  659. <template slot-scope="{ row }">
  660. <span>{{ qualityStatus[row.status] }}</span>
  661. </template>
  662. </el-table-column>
  663. <el-table-column label="生产日期" prop="" width="220">
  664. <template slot="header" slot-scope="scope">
  665. <el-select filterable v-model="curDateType">
  666. <el-option value="productionDate" label="生产日期"></el-option>
  667. <el-option value="purchaseDate" label="采购日期"></el-option>
  668. </el-select>
  669. </template>
  670. <template slot-scope="{ row }">
  671. <template v-if="formData.bizType == 5">
  672. {{ row[curDateType] }}
  673. </template>
  674. <el-date-picker
  675. v-else
  676. :disabled="row.isPack"
  677. size="small"
  678. v-model="row[curDateType]"
  679. type="datetime"
  680. value-format="yyyy-MM-dd HH:mm:ss"
  681. placeholder="选择日期"
  682. >
  683. </el-date-picker>
  684. </template>
  685. </el-table-column>
  686. <!-- <el-table-column label="操作" width="120" fixed="right">
  687. <template slot-scope="{ row, $index }">
  688. <el-button type="text" @click="wrapDelete(row, $index)">
  689. 删除
  690. </el-button>
  691. </template>
  692. </el-table-column> -->
  693. </el-table>
  694. </div>
  695. <div v-if="showMaterialList.length > 0" class="inbound_details">
  696. <header-title :title="`物料明细`"></header-title>
  697. <el-table
  698. ref="materialListTable"
  699. :data="showMaterialList"
  700. tooltip-effect="dark"
  701. :key="formData.bizType"
  702. :header-cell-style="rowClass"
  703. style="width: 100%"
  704. border
  705. stripe
  706. :max-height="300"
  707. v-el-table-infinite-scroll="materielHandleScroll"
  708. >
  709. <el-table-column label="序号" type="index" width="50">
  710. </el-table-column>
  711. <el-table-column
  712. label="编码"
  713. prop="categoryCode"
  714. width="130"
  715. :show-overflow-tooltip="true"
  716. ></el-table-column>
  717. <el-table-column
  718. label="名称"
  719. prop="categoryName"
  720. width="150"
  721. :show-overflow-tooltip="true"
  722. ></el-table-column>
  723. <el-table-column
  724. label="批次号"
  725. prop="batchNo"
  726. width="70"
  727. ></el-table-column>
  728. <el-table-column
  729. label="物料编码"
  730. prop="materialCode"
  731. width="200"
  732. :show-overflow-tooltip="true"
  733. ></el-table-column>
  734. <el-table-column
  735. label="计量数量"
  736. prop="measureQuantity"
  737. width="90"
  738. :show-overflow-tooltip="true"
  739. ></el-table-column>
  740. <el-table-column
  741. width="80"
  742. label="计量单位"
  743. prop="measureUnit"
  744. ></el-table-column>
  745. <el-table-column
  746. label="物料代号"
  747. prop="materielDesignation"
  748. width="130"
  749. >
  750. <template slot-scope="{ row, $index }">
  751. <el-input
  752. v-if="!row.isPack"
  753. :ref="'material_materielDesignation' + $index"
  754. @keyup.native="
  755. moveFocus(
  756. $event,
  757. $index,
  758. 'material_materielDesignation',
  759. '物料',
  760. row
  761. )
  762. "
  763. v-model="row.materielDesignation"
  764. ></el-input>
  765. <span v-else>{{ row.materielDesignation }}</span>
  766. </template>
  767. </el-table-column>
  768. <el-table-column label="客户代号" prop="clientCode">
  769. <template slot-scope="{ row, $index }">
  770. <el-input
  771. v-if="!row.isPack"
  772. :ref="'material_clientCode' + $index"
  773. @keyup.native="
  774. moveFocus($event, $index, 'material_clientCode', '物料', row)
  775. "
  776. v-model="row.clientCode"
  777. ></el-input>
  778. <span v-else>{{ row.clientCode }}</span>
  779. </template>
  780. </el-table-column>
  781. <el-table-column label="刻码" prop="engrave" width="140">
  782. <template slot-scope="{ row, $index }">
  783. <el-input
  784. v-if="!row.isPack"
  785. :ref="'material_engrave' + $index"
  786. @keyup.native="
  787. moveFocus($event, $index, 'material_engrave', '物料', row)
  788. "
  789. v-model="row.engrave"
  790. ></el-input>
  791. <span v-else>{{ row.engrave }}</span>
  792. </template>
  793. </el-table-column>
  794. <el-table-column label="重量" prop="weight" width="100">
  795. <template slot-scope="{ row, $index }">
  796. <el-input
  797. v-if="!row.isPack && row.measureUnit != row.weightUnit"
  798. :ref="'material_weight' + $index"
  799. @keyup.native="
  800. moveFocus($event, $index, 'material_weight', '物料', row)
  801. "
  802. @input="weightInput($event, row, '物料')"
  803. v-model.number="row.weight"
  804. ></el-input>
  805. <span v-else>{{ row.weight }}</span>
  806. </template>
  807. </el-table-column>
  808. <el-table-column
  809. label="重量单位"
  810. prop="weightUnit"
  811. width="100"
  812. ></el-table-column>
  813. <el-table-column label="质检结果" prop="result" width="120">
  814. <template slot-scope="{ row }">
  815. <el-select
  816. v-if="!row.isPack"
  817. @change="changeWrapStatus($event, row, '物料')"
  818. v-model="row.result"
  819. placeholder="请选择"
  820. >
  821. <el-option
  822. v-for="item in qualityResultsOptions"
  823. :label="item.label"
  824. :value="item.value"
  825. :key="item.value"
  826. >
  827. </el-option>
  828. </el-select>
  829. <span v-else>{{ qualityResults[row.result] }}</span>
  830. </template>
  831. </el-table-column>
  832. <el-table-column label="质检状态" prop="status" width="120">
  833. <template slot-scope="{ row }">
  834. <span>{{ qualityStatus[row.status] }}</span>
  835. </template>
  836. </el-table-column>
  837. <!-- <el-table-column label="操作" width="120" fixed="right">
  838. <template slot-scope="{ row, $index }">
  839. <el-button type="text" @click="materialDelete(row, $index)">
  840. 删除
  841. </el-button>
  842. </template>
  843. </el-table-column> -->
  844. </el-table>
  845. </div>
  846. <div v-if="showPackingList.length > 0" class="storage_btn">
  847. <el-button type="primary" :loading="saveLoading" @click="storage"
  848. >入库</el-button
  849. >
  850. </div>
  851. </el-card>
  852. <!-- 产品选择弹框 -->
  853. <selectType
  854. :visibleDialog.sync="visibleDialog"
  855. :title="title"
  856. :bizScene="formData.bizType"
  857. :treeIds="formData.extInfo.assetType"
  858. :loadTree.sync="loadTree"
  859. @selectTableData="addGoods"
  860. />
  861. <!-- 仓库选择弹框 -->
  862. <WarehousingDialog
  863. ref="wareHouseDailogRef"
  864. @selection="wareHouseSelection"
  865. ></WarehousingDialog>
  866. <!-- 生产日期、采购日期弹框 -->
  867. <el-dialog :visible.sync="dateVisible" title="选择日期" width="400px">
  868. <el-date-picker
  869. size="small"
  870. v-model="batchTime"
  871. type="datetime"
  872. style="width: 320px"
  873. value-format="yyyy-MM-dd HH:mm:ss"
  874. placeholder="选择日期"
  875. >
  876. </el-date-picker>
  877. <div style="text-align: right; margin-top: 20px">
  878. <el-button @click="dateVisible = false">取消</el-button>
  879. <el-button type="primary" @click="dateConfirm" :disabled="!batchTime"
  880. >确认</el-button
  881. >
  882. </div>
  883. </el-dialog>
  884. </div>
  885. </template>
  886. <script>
  887. import XLSX from 'xlsx';
  888. import elTableInfiniteScroll from 'el-table-infinite-scroll';
  889. import storageApi from '@/api/warehouseManagement/index.js';
  890. import WarehousingDialog from '../components/WarehousingDialog.vue';
  891. import { getCode } from '@/api/codeManagement/index.js';
  892. import selectType from './components/selectType';
  893. import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
  894. import { sceneState } from '@/utils/dict/index';
  895. import { getTreeByGroup } from '@/api/classifyManage';
  896. import outin from '@/api/warehouseManagement/outin';
  897. import { deepClone } from '@/utils';
  898. export default {
  899. components: {
  900. selectType,
  901. WarehousingDialog
  902. },
  903. // 虚拟列表滚动方法
  904. directives: {
  905. 'el-table-infinite-scroll': elTableInfiniteScroll
  906. },
  907. data() {
  908. return {
  909. sceneState,
  910. saveLoading: false,
  911. dateVisible: false,
  912. loadTree: true,
  913. visibleDialog: false,
  914. title: '选择产品',
  915. goodsLists: [],
  916. formData: {
  917. bizType: '',
  918. extInfo: {
  919. assetType: []
  920. }
  921. },
  922. rules: {
  923. 'extInfo.assetType': {
  924. required: true,
  925. message: '请选择物品类型',
  926. trigger: 'blur'
  927. },
  928. bizType: {
  929. required: true,
  930. message: '请选择入库场景',
  931. trigger: 'change'
  932. }
  933. },
  934. qualityResultsOptions: [
  935. {
  936. label: '合格',
  937. value: 1
  938. },
  939. {
  940. label: '不合格',
  941. value: 2
  942. }
  943. ],
  944. qualityStatus: {
  945. 0: '未质检',
  946. 1: '已质检'
  947. }, // 质检状态 0未检 1已检
  948. qualityResults: {
  949. 1: '合格',
  950. 2: '不合格'
  951. }, // 质检结果 1合格 2不合格
  952. productList: [], // 产品列表
  953. packingList: [], // 包装列表
  954. showPackingList: [], // 包装列表(虚拟列表)
  955. materialList: [], // 物料列表
  956. showMaterialList: [], // 物料列表(虚拟列表)
  957. curDateType: 'productionDate',
  958. packingListSelected: [], // 包装选择列表
  959. isWrapTable: true, // 解决表格不刷新问题(包装)
  960. currentPackingQuantity: '', // 当前包装数量
  961. batchTime: '', // 生产日期、采购日期
  962. pageSize: 20, // 物料和包装列表条数
  963. pickingPageNum: 1, // 包装虚拟分页页数
  964. materielPageNum: 1 // 物料虚拟分页页数
  965. };
  966. },
  967. computed: {
  968. clientEnvironmentId() {
  969. return this.$store.state.user.info.clientEnvironmentId;
  970. }
  971. },
  972. watch: {
  973. packingList: {
  974. handler(newVal) {
  975. console.log('包装列表', newVal);
  976. console.log('当前包装列表加载页数', this.pickingPageNum);
  977. this.showPackingList = newVal.slice(
  978. 0,
  979. this.pageSize * (this.pickingPageNum > 0 ? this.pickingPageNum : 1)
  980. );
  981. },
  982. deep: true
  983. },
  984. materialList: {
  985. handler(newVal) {
  986. console.log('物料列表', newVal);
  987. console.log('当前物料列表加载页数', this.materielPageNum);
  988. this.showMaterialList = newVal.slice(
  989. 0,
  990. this.pageSize *
  991. (this.materielPageNum > 0 ? this.materielPageNum : 1)
  992. );
  993. },
  994. deep: true
  995. }
  996. },
  997. created() {
  998. this.getListItems();
  999. this.initUserInfo();
  1000. if (this.$route.query.id) {
  1001. storageApi
  1002. .getApplystorageDetailById(this.$route.query.id)
  1003. .then(async (data) => {
  1004. console.log(data);
  1005. this.formData.extInfo.assetType = [data.rootCategoryLevelId];
  1006. this.formData.bizType = String(data.type);
  1007. this.formData.extInfo.documentSource = data.code;
  1008. const batchNo = await getCode('lot_number_code');
  1009. this.productList = data.detailList.map((item, index) => {
  1010. return {
  1011. index: this.productList.length + index,
  1012. categoryId: item.categoryId, // 物品id
  1013. categoryName: item.categoryName, // 物品名称
  1014. categoryCode: item.categoryCode, // 物品编码
  1015. categoryModel: item.modelType, // 物品型号
  1016. specification: item.specification, // 规格
  1017. brandNum: item.brandNum, // 牌号
  1018. batchNo: batchNo, // 批次号
  1019. minPackingQuantity: item.quantity, // 最小包装单元数量
  1020. packingQuantity: 1, // 包装数量
  1021. packingUnit: item.packingUnit, // 包装单位
  1022. measureQuantity: 0, // 计量数量
  1023. measureUnit: item.measuringUnit, // 计量单位
  1024. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  1025. weight: item.packingWeight, // 重量
  1026. weightUnit: item.weightUnit, // 重量单位
  1027. totalMoney: '', // 总价
  1028. price: item.price, // 单价
  1029. purpose: item.purpose, // 用途
  1030. isUnpack: item.isUnpack, // 是否允许拆包
  1031. warehouseId: item.warehouseId, // 仓库Id
  1032. warehouseName: item.warehouseName, // 仓库名称
  1033. warehouseIds: [item.warehouseId],
  1034. warehouseNames: [item.warehouseName]
  1035. };
  1036. });
  1037. this.$nextTick(() => {
  1038. this.listSaveArrs();
  1039. });
  1040. });
  1041. }
  1042. },
  1043. methods: {
  1044. // 初始化当前用户信息
  1045. async initUserInfo() {
  1046. const res = await warehouseDefinition.tree();
  1047. let info = JSON.parse(localStorage.getItem('info'));
  1048. let obj = res.find(
  1049. (item) => item.id === info.deptIds[info.deptIds.length - 1]
  1050. );
  1051. if (!obj) return;
  1052. this.formData.extInfo.deptCode = obj.id;
  1053. this.formData.extInfo.deptName = obj.name;
  1054. this.formData.extInfo.createUserName = info.name;
  1055. this.formData.createUserId = info.userId;
  1056. },
  1057. // 获取物品列表
  1058. async getListItems() {
  1059. const { data } = await getTreeByGroup({ type: 2 });
  1060. this.goodsLists = data;
  1061. },
  1062. // 打开单据来源弹窗
  1063. openDocumentSourceDialog() {
  1064. console.log('打开单据来源弹窗');
  1065. },
  1066. // 清除单据来源
  1067. clearDocumentSource() {
  1068. this.formData.extInfo.documentSource = '';
  1069. },
  1070. // 返回
  1071. back() {
  1072. this.$router.go(-1);
  1073. },
  1074. // 添加产品
  1075. addProduct() {
  1076. if (this.formData.extInfo.assetType.length <= 0) {
  1077. return this.$message.error('请选择物品类型');
  1078. }
  1079. if (!this.formData.bizType) {
  1080. return this.$message.error('请选择入库类型');
  1081. }
  1082. this.visibleDialog = true;
  1083. },
  1084. // 键盘移动
  1085. moveFocus(event, index, key, type, row) {
  1086. let keyfield = [];
  1087. let listLength = 0;
  1088. switch (type) {
  1089. case '产品':
  1090. listLength = this.productList.length;
  1091. keyfield = [
  1092. 'batchNo',
  1093. 'minPackingQuantity',
  1094. 'packingQuantity',
  1095. 'price',
  1096. 'purpose'
  1097. ];
  1098. break;
  1099. case '包装':
  1100. listLength = this.showPackingList.length;
  1101. if (row.measureUnit != row.weightUnit) {
  1102. keyfield = [
  1103. 'packing_materielDesignation',
  1104. 'packing_clientCode',
  1105. 'packing_engrave',
  1106. 'packing_weight'
  1107. ];
  1108. } else {
  1109. keyfield = [
  1110. 'packing_materielDesignation',
  1111. 'packing_clientCode',
  1112. 'packing_engrave'
  1113. ];
  1114. }
  1115. break;
  1116. case '物料':
  1117. listLength = this.showMaterialList.length;
  1118. if (row.measureUnit != row.weightUnit) {
  1119. keyfield = [
  1120. 'material_materielDesignation',
  1121. 'material_clientCode',
  1122. 'material_engrave',
  1123. 'material_weight'
  1124. ];
  1125. } else {
  1126. keyfield = [
  1127. 'material_materielDesignation',
  1128. 'material_clientCode',
  1129. 'material_engrave'
  1130. ];
  1131. }
  1132. break;
  1133. }
  1134. if (event.keyCode === 13) {
  1135. // 回车
  1136. if (
  1137. index === listLength - 1 &&
  1138. key === keyfield[keyfield.length - 1]
  1139. ) {
  1140. // 最后一行最后一个
  1141. return;
  1142. }
  1143. this.$refs[key + index].blur();
  1144. if (key === keyfield[keyfield.length - 1]) {
  1145. // 当前行最后一个,跳转下一行第一个
  1146. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  1147. this.$refs[keyfield[0] + (index + 1)].value = '';
  1148. }
  1149. this.$refs[keyfield[0] + (index + 1)].focus();
  1150. } else {
  1151. // 跳转下一个
  1152. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  1153. this.$nextTick(() => {
  1154. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  1155. this.$refs[keyfield[nextkeyindex] + index].value = '';
  1156. }
  1157. this.$refs[keyfield[nextkeyindex] + index].focus();
  1158. });
  1159. }
  1160. }
  1161. // 向上 =38
  1162. if (event.keyCode === 38) {
  1163. console.log('向上');
  1164. if (index === 0) {
  1165. // 第一行
  1166. console.log('第一行无法向上');
  1167. return;
  1168. }
  1169. this.$refs[key + index].blur();
  1170. this.$nextTick(() => {
  1171. if (this.$refs[key + (index - 1)].value == 0) {
  1172. this.$refs[key + (index - 1)].value = '';
  1173. }
  1174. this.$refs[key + (index - 1)].focus();
  1175. });
  1176. }
  1177. // 下 = 40
  1178. if (event.keyCode === 40) {
  1179. console.log('向下');
  1180. if (index === listLength - 1) {
  1181. // 最后一行
  1182. console.log('最后一行无法向下');
  1183. return;
  1184. }
  1185. this.$refs[key + index].blur();
  1186. this.$nextTick(() => {
  1187. if (this.$refs[key + (index + 1)].value == 0) {
  1188. this.$refs[key + (index + 1)].value = '';
  1189. }
  1190. this.$refs[key + (index + 1)].focus();
  1191. });
  1192. }
  1193. // 左 = 37
  1194. if (event.keyCode === 37) {
  1195. console.log('向左');
  1196. if (index === 0 && key === keyfield[0]) {
  1197. // 第一行第一个
  1198. console.log('第一行第一个无法向左');
  1199. return;
  1200. }
  1201. this.$refs[key + index].blur();
  1202. if (key === keyfield[0]) {
  1203. if (
  1204. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value == 0
  1205. ) {
  1206. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value =
  1207. '';
  1208. }
  1209. // 当前行第一个,跳转上一行最后一个
  1210. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].focus();
  1211. } else {
  1212. // 跳转上一个
  1213. const prevkeyindex = keyfield.findIndex((k) => k === key) - 1;
  1214. this.$nextTick(() => {
  1215. if (this.$refs[keyfield[prevkeyindex] + index].value == 0) {
  1216. this.$refs[keyfield[prevkeyindex] + index].value = '';
  1217. }
  1218. this.$refs[keyfield[prevkeyindex] + index].focus();
  1219. });
  1220. }
  1221. }
  1222. // 右 = 39
  1223. if (event.keyCode === 39) {
  1224. console.log('向右');
  1225. if (
  1226. index === listLength - 1 &&
  1227. key === keyfield[keyfield.length - 1]
  1228. ) {
  1229. // 最后一行最后一个
  1230. console.log('最后一行最后一个无法向左');
  1231. return;
  1232. }
  1233. console.log(this.$refs);
  1234. this.$refs[key + index].blur();
  1235. if (key === keyfield[keyfield.length - 1]) {
  1236. // 当前行最后一个,跳转下一行第一个
  1237. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  1238. this.$refs[keyfield[0] + (index + 1)].value = '';
  1239. }
  1240. this.$refs[keyfield[0] + (index + 1)].focus();
  1241. } else {
  1242. // 跳转下一个
  1243. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  1244. this.$nextTick(() => {
  1245. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  1246. this.$refs[keyfield[nextkeyindex] + index].value = '';
  1247. }
  1248. this.$refs[keyfield[nextkeyindex] + index].focus();
  1249. });
  1250. }
  1251. }
  1252. },
  1253. handleAvatarSuccess() {
  1254. this.$refs.fileUploadBtn.clearFiles(); //上传成功之后清除历史记录**加粗样式**
  1255. },
  1256. async onChange(file) {
  1257. console.log(XLSX);
  1258. this.warehousingMaterialList = [];
  1259. this.resultArray = [];
  1260. const loading = this.$loading({
  1261. lock: true,
  1262. text: '加载中...'
  1263. });
  1264. /**
  1265. * 1. 使用原生api去读取好的文件
  1266. * */
  1267. // console.log("原始上传的文件", file);
  1268. // 读取文件不是立马能够读取到的,所以是异步的,使用Promise
  1269. let dataBinary = await new Promise((resolve) => {
  1270. // Web API构造函数FileReader,可实例化对象,去调用其身上方法,去读取解析文件信息
  1271. let reader = new FileReader(); // https://developer.mozilla.org/zh-CN/docs/Web/API/FileReader
  1272. // console.log("实例化对象有各种方法", reader);
  1273. reader.readAsBinaryString(file.raw); // 读取raw的File文件
  1274. reader.onload = (ev) => {
  1275. // console.log("文件解析流程进度事件", ev);
  1276. resolve(ev.target.result); // 将解析好的结果扔出去,以供使用
  1277. };
  1278. });
  1279. // console.log("读取出的流文件", dataBinary);
  1280. /**
  1281. * 2. 使用xlsx插件去解析已经读取好的二进制excel流文件
  1282. * */
  1283. let workBook = XLSX.read(dataBinary, {
  1284. type: 'binary',
  1285. cellDates: true
  1286. });
  1287. // excel中有很多的sheet,这里取了第一个sheet:workBook.SheetNames[0]
  1288. let firstWorkSheet = workBook.Sheets[workBook.SheetNames[0]];
  1289. // 分为第一行的数据,和第一行下方的数据
  1290. // const header = this.getHeaderRow(firstWorkSheet);
  1291. // console.log('读取的excel表头数据(第一行)', header);
  1292. const xlsxData = XLSX.utils.sheet_to_json(firstWorkSheet);
  1293. console.log('读取所有excel数据', xlsxData);
  1294. // let modelTypeList = xlsxData.map((item) => {
  1295. // return item['型号'];
  1296. // });
  1297. // let nameList = xlsxData.map((item) => {
  1298. // return item['物品名称'];
  1299. // });
  1300. let codeList = xlsxData.map((item) => {
  1301. return item['sap物料码'];
  1302. });
  1303. let functionType = {};
  1304. xlsxData.map((item) => {
  1305. functionType[item['sap物料码']] = item['采购原因'];
  1306. });
  1307. this.formData.extInfo.assetType = ['6']; //备品备件
  1308. this.formData.bizType = '2'; // 采购入库
  1309. outin
  1310. .getListByNameOrModeType({
  1311. // modelTypeList,
  1312. // nameList,
  1313. codeList,
  1314. categoryLevelId: '6'
  1315. })
  1316. .then(async (data) => {
  1317. console.log('查询到的备件数据', data);
  1318. const batchNo = await getCode('lot_number_code');
  1319. // 添加包装数量和最小包装单元
  1320. this.productList = data.map((item, index) => {
  1321. console.log(xlsxData);
  1322. let filterArray = xlsxData.filter(
  1323. (xlsxItem) => xlsxItem['sap物料码'] == item.code
  1324. );
  1325. console.log(filterArray);
  1326. return {
  1327. index: this.productList.length + index,
  1328. categoryId: item.id, // 物品id
  1329. categoryName: item.name, // 物品名称
  1330. categoryCode: item.code, // 物品编码
  1331. categoryModel: item.modelType, // 物品型号
  1332. specification: item.specification, // 规格
  1333. brandNum: item.brandNum, // 牌号
  1334. batchNo: batchNo, // 批次号
  1335. minPackingQuantity: filterArray[0]['数量'], // 最小包装单元数量
  1336. packingQuantity: 1, // 包装数量
  1337. packingUnit: item.packingUnit, // 包装单位
  1338. measureQuantity: 0, // 计量数量
  1339. measureUnit: item.measuringUnit, // 计量单位
  1340. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  1341. weight: 0, // 重量
  1342. weightUnit: item.weightUnit, // 重量单位
  1343. totalMoney: '', // 总价
  1344. price: item.price, // 单价
  1345. purpose: functionType[item.code], // 用途
  1346. isUnpack: item.isUnpack // 是否允许拆包
  1347. };
  1348. });
  1349. console.log(this.productList);
  1350. this.handleAvatarSuccess();
  1351. loading.close();
  1352. })
  1353. .catch(() => {
  1354. loading.close();
  1355. });
  1356. },
  1357. // 入库
  1358. storage() {
  1359. let boolen = this.productList.every((item) => item.isSave);
  1360. if (!boolen) {
  1361. this.$message.warning('请先保存所有产品信息');
  1362. return;
  1363. }
  1364. // 处理包装数据
  1365. this.packingList = this.packingList.map((packingItem) => {
  1366. return {
  1367. ...packingItem,
  1368. materialDetailList: this.materialList.filter(
  1369. (item) => item.parentIndex === packingItem.index
  1370. )
  1371. };
  1372. });
  1373. // 处理产品数据
  1374. this.productList = this.productList.map((productItem) => {
  1375. return {
  1376. ...productItem,
  1377. outInDetailRecordRequestList: this.packingList.filter(
  1378. (item) => item.parentIndex === productItem.index
  1379. )
  1380. };
  1381. });
  1382. this.formData.outInDetailList = this.productList;
  1383. let obj = deepClone(this.formData);
  1384. // 处理物品类型assetType
  1385. obj.extInfo.assetType = obj.extInfo.assetType.join(',');
  1386. // 处理仓库id
  1387. let warehouseId = [];
  1388. let warehouseName = [];
  1389. let warehouseIds = this.productList
  1390. .map((item) => item.warehouseIds)
  1391. .flat();
  1392. let warehouseNames = this.productList
  1393. .map((item) => item.warehouseNames)
  1394. .flat();
  1395. warehouseIds.forEach((item, index) => {
  1396. if (!warehouseId.includes(item)) {
  1397. warehouseId.push(item);
  1398. warehouseName.push(warehouseNames[index]);
  1399. }
  1400. });
  1401. obj.warehouseIds = warehouseId;
  1402. obj.warehouseNames = warehouseName;
  1403. // 是否需要审核(0审核 1跳过审核)
  1404. if (obj.bizType == '12') {
  1405. obj.isSkip = 1;
  1406. } else {
  1407. obj.isSkip = 0;
  1408. }
  1409. // obj.isSkip = 1;
  1410. console.log(obj);
  1411. this.saveLoading = true;
  1412. storageApi
  1413. .storage(obj)
  1414. .then(async (res) => {
  1415. console.log('入库成功', res);
  1416. if (res.code == 0) {
  1417. try {
  1418. // 委外入库(非采购)
  1419. if (obj.bizType == '12') {
  1420. await storageApi.qualityInspectionTwo({
  1421. outInId: res.data[0]
  1422. });
  1423. } else {
  1424. await storageApi.submitTwo({ outInId: res.data[0] });
  1425. }
  1426. this.$message.success('入库成功');
  1427. this.saveLoading = false;
  1428. this.$router.push('/warehouseManagement/stockManagement');
  1429. } catch (error) {
  1430. this.saveLoading = false;
  1431. console.log('提交流程失败', error);
  1432. }
  1433. }
  1434. })
  1435. .catch((err) => {
  1436. console.log('入库失败', err);
  1437. this.saveLoading = false;
  1438. });
  1439. },
  1440. pickingHandleScroll() {
  1441. console.log('---------pickingHandleScroll------------');
  1442. if (this.showPackingList.length < this.packingList.length) {
  1443. if (this.packingList.length > this.pageSize) {
  1444. this.pickingPageNum += 1;
  1445. }
  1446. this.pickingFetchData();
  1447. }
  1448. },
  1449. pickingFetchData() {
  1450. const start = (this.pickingPageNum - 1) * this.pageSize;
  1451. const end = start + this.pageSize;
  1452. this.showPackingList = this.showPackingList.concat(
  1453. this.packingList.slice(start, end)
  1454. );
  1455. },
  1456. materielHandleScroll() {
  1457. console.log('---------materielHandleScroll------------');
  1458. if (this.showMaterialList.length < this.materialList.length) {
  1459. if (this.materialList.length > this.pageSize) {
  1460. this.materielPageNum += 1;
  1461. }
  1462. this.materielFetchData();
  1463. }
  1464. },
  1465. materielFetchData() {
  1466. const start = (this.materielPageNum - 1) * this.pageSize;
  1467. const end = start + this.pageSize;
  1468. this.showMaterialList = this.showMaterialList.concat(
  1469. this.materialList.slice(start, end)
  1470. );
  1471. console.log(this.showMaterialList);
  1472. },
  1473. // 日期选择
  1474. dateConfirm() {
  1475. this.packingListSelected.forEach((item) => {
  1476. this.$set(item, this.curDateType, this.batchTime);
  1477. });
  1478. this.batchTime = '';
  1479. this.dateVisible = false;
  1480. },
  1481. // 包装重量修改
  1482. packingWeightCahnge(value, row) {
  1483. // 修改物品重量
  1484. let filterPackingList = this.packingList.filter((item) => {
  1485. return item.parentIndex === row.parentIndex;
  1486. });
  1487. let productIndex = this.productList.findIndex((item) => {
  1488. return item.index === row.parentIndex;
  1489. });
  1490. let totalWeight = filterPackingList.reduce(
  1491. (accumulator, currentValue) => {
  1492. return this.$math.format(+accumulator + +currentValue.weight, 14);
  1493. },
  1494. 0
  1495. );
  1496. this.$set(this.productList[productIndex], 'weight', totalWeight);
  1497. // 修改拆分物料
  1498. this.materialList.map((item, index) => {
  1499. if (item.parentIndex === row.index) {
  1500. console.log(value / row.measureQuantity);
  1501. this.$set(
  1502. this.materialList[index],
  1503. 'weight',
  1504. this.$math.format(value / row.measureQuantity, 14) >= 0
  1505. ? this.$math.format(value / row.measureQuantity, 14)
  1506. : 0
  1507. );
  1508. }
  1509. });
  1510. },
  1511. // 物料重量修改
  1512. materialWeightCahnge(row) {
  1513. // 修改包装重量
  1514. let filterMaterialList = this.materialList.filter((item) => {
  1515. return item.parentIndex === row.parentIndex;
  1516. });
  1517. let packingIndex = this.packingList.findIndex((item) => {
  1518. return item.index === row.parentIndex;
  1519. });
  1520. let totalMaterialWeight = filterMaterialList.reduce(
  1521. (accumulator, currentValue) => {
  1522. return this.$math.format(+accumulator + +currentValue.weight, 14);
  1523. },
  1524. 0
  1525. );
  1526. this.$set(
  1527. this.packingList[packingIndex],
  1528. 'weight',
  1529. totalMaterialWeight
  1530. );
  1531. // 修改物品重量
  1532. let filterPackingList = this.packingList.filter((item) => {
  1533. return (
  1534. item.parentIndex === this.packingList[packingIndex].parentIndex
  1535. );
  1536. });
  1537. let productIndex = this.productList.findIndex((item) => {
  1538. return item.index === this.packingList[packingIndex].parentIndex;
  1539. });
  1540. let totalWeight = filterPackingList.reduce(
  1541. (accumulator, currentValue) => {
  1542. return this.$math.format(+accumulator + +currentValue.weight, 14);
  1543. },
  1544. 0
  1545. );
  1546. this.$set(this.productList[productIndex], 'weight', totalWeight);
  1547. },
  1548. // 包装质检结果修改
  1549. packingResultCahnge(value, row) {
  1550. // 修改物料质检结果( 1合格 2不合格)
  1551. this.materialList.map((item, index) => {
  1552. if (item.parentIndex === row.index) {
  1553. this.$set(this.materialList[index], 'result', value);
  1554. }
  1555. });
  1556. },
  1557. // 物料质量结果修改
  1558. materialResultCahnge(value, row) {
  1559. // 修改包装质检结果
  1560. let filterMaterialList = this.materialList.filter((item) => {
  1561. return item.parentIndex === row.parentIndex;
  1562. });
  1563. let packingIndex = this.packingList.findIndex((item) => {
  1564. return item.index === row.parentIndex;
  1565. });
  1566. let boolen = filterMaterialList.every((item) => {
  1567. return item.result === 1;
  1568. });
  1569. this.$set(this.packingList[packingIndex], 'result', boolen ? 1 : 2);
  1570. },
  1571. // 重量限制
  1572. weightInput(value, row, type) {
  1573. const newValue = value.replace(/[^\d.]/g, ''); // 保留数字和小数点
  1574. const decimalCount = (newValue.match(/\./g) || []).length; // 计算小数点的个数
  1575. if (row.weight < 0) {
  1576. row.weight = 0;
  1577. } else if (row.weight > 9999) {
  1578. row.weight = 9999;
  1579. } else {
  1580. if (decimalCount > 1) {
  1581. // 如果小数点个数大于1,移除多余的小数点
  1582. const lastIndex = newValue.lastIndexOf('.');
  1583. row.weight =
  1584. newValue.slice(0, lastIndex) + newValue.slice(lastIndex + 1);
  1585. } else if (decimalCount === 1) {
  1586. // 如果小数点个数等于1,允许小数点的输入
  1587. row.weight = newValue;
  1588. } else {
  1589. row.weight = newValue === '' ? 0 : parseFloat(newValue); // 如果输入为空,则设为0
  1590. }
  1591. }
  1592. if (type === '包装') {
  1593. this.packingWeightCahnge(value, row);
  1594. } else {
  1595. this.materialWeightCahnge(row);
  1596. }
  1597. },
  1598. //计算金额
  1599. calcSumTotal(packingQuantity, minPackingQuantity, price, row) {
  1600. //最小包装单元,包装数量,单价
  1601. const total = {
  1602. packingQuantity: Number(packingQuantity > 0 ? packingQuantity : 0),
  1603. minPackingQuantity: Number(
  1604. minPackingQuantity > 0 ? minPackingQuantity : 0
  1605. ),
  1606. price: Number(price > 0 ? price : 0)
  1607. };
  1608. let number = Number(
  1609. this.$math.format(
  1610. total.packingQuantity * total.minPackingQuantity * total.price,
  1611. 14
  1612. )
  1613. );
  1614. row.totalMoney = number;
  1615. return number;
  1616. },
  1617. // 包装维度最小包装单元改变——>总重量
  1618. minPackingQuantityChange(row, value, index) {
  1619. console.log(value);
  1620. if (row.measureUnit !== 'KG') {
  1621. if (value.replace(/^(0+)|[^\d]+/g, '') > 9999) {
  1622. this.$set(this.productList[index], 'minPackingQuantity', 9999);
  1623. } else {
  1624. this.$set(
  1625. this.productList[index],
  1626. 'minPackingQuantity',
  1627. value.replace(/^(0+)|[^\d]+/g, '')
  1628. );
  1629. }
  1630. } else {
  1631. if (value < 1) {
  1632. this.$set(this.productList[index], 'minPackingQuantity', 1);
  1633. } else if (value > 9999) {
  1634. this.$set(this.productList[index], 'minPackingQuantity', 9999);
  1635. }
  1636. }
  1637. if (row.packingQuantity >= 0 && value >= 0) {
  1638. this.packNum(row, row.packingQuantity, index);
  1639. }
  1640. },
  1641. // 包装数量过滤处理改变——>总重量
  1642. packNum(row, value, index) {
  1643. const total = {
  1644. minPackingQuantity: Number(
  1645. row.minPackingQuantity > 0
  1646. ? row.minPackingQuantity > 9999
  1647. ? 9999
  1648. : row.minPackingQuantity
  1649. : 0
  1650. ),
  1651. packingQuantity: Number(
  1652. row.packingQuantity > 0
  1653. ? row.packingQuantity > 9999
  1654. ? 9999
  1655. : row.packingQuantity
  1656. : 0
  1657. )
  1658. };
  1659. const totals = Number(
  1660. this.$math.format(
  1661. total.minPackingQuantity * total.packingQuantity,
  1662. 14
  1663. )
  1664. );
  1665. if (row.measureUnit == row.weightUnit) {
  1666. row.weight = Number(
  1667. this.$math.format(
  1668. total.minPackingQuantity *
  1669. 1 *
  1670. Number(total.packingQuantity).toFixed(2),
  1671. 14
  1672. )
  1673. );
  1674. } else {
  1675. row.weight = Number(
  1676. this.$math.format(
  1677. totals *
  1678. (row.netWeight > 0 ? Number(row.netWeight).toFixed(2) : 0),
  1679. 14
  1680. )
  1681. );
  1682. }
  1683. this.$set(this.productList[index], 'measureQuantity', totals);
  1684. // 清空仓库
  1685. this.$set(this.productList[index], 'warehouseId', '');
  1686. this.$set(this.productList[index], 'warehouseName', '');
  1687. if (value.replace(/^(0+)|[^\d]+/g, '') > 9999) {
  1688. this.$set(this.productList[index], 'packingQuantity', 9999);
  1689. } else {
  1690. this.$set(
  1691. this.productList[index],
  1692. 'packingQuantity',
  1693. value.replace(/^(0+)|[^\d]+/g, '')
  1694. );
  1695. }
  1696. // return (row.packingQuantity = value.replace(/^(0+)|[^\d]+/g, ''));
  1697. },
  1698. // 表格样式
  1699. rowClass({ row, column, rowIndex, columnIndex }) {
  1700. if (rowIndex === 1) {
  1701. return {
  1702. display: 'none',
  1703. background: '#EEEEEE'
  1704. };
  1705. }
  1706. return { background: '#0000' };
  1707. },
  1708. // 添加物品明细
  1709. async addGoods(data) {
  1710. const batchNo = await getCode('lot_number_code');
  1711. let productList = data.map((item, index) => {
  1712. return {
  1713. index: this.productList.length + index,
  1714. categoryId: item.id, // 物品id
  1715. categoryName: item.name, // 物品名称
  1716. categoryCode: item.code, // 物品编码
  1717. categoryModel: item.listSavemodelType, // 物品型号
  1718. specification: item.specification, // 规格
  1719. brandNum: item.brandNum, // 牌号
  1720. batchNo: batchNo, // 批次号
  1721. minPackingQuantity: '', // 最小包装单元数量
  1722. packingQuantity: '', // 包装数量
  1723. packingUnit: item.packingUnit, // 包装单位
  1724. measureQuantity: 0, // 计量数量
  1725. measureUnit: item.measuringUnit, // 计量单位
  1726. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  1727. weight: 0, // 重量
  1728. weightUnit: item.weightUnit, // 重量单位
  1729. totalMoney: '', // 总价
  1730. price: item.price, // 单价
  1731. purpose: '', // 用途
  1732. isUnpack: item.isUnpack // 是否允许拆包
  1733. };
  1734. });
  1735. this.productList = this.productList.concat(productList);
  1736. },
  1737. // 物品保存验证表单(批量)
  1738. validateForm() {
  1739. return new Promise(async (resolve, reject) => {
  1740. let list = this.productList.map(async (row, index) => {
  1741. let fileds = [
  1742. `productList.${index}.batchNo`,
  1743. `productList.${index}.minPackingQuantity`,
  1744. `productList.${index}.packingQuantity`,
  1745. `productList.${index}.warehouseId`
  1746. ];
  1747. console.log(fileds);
  1748. if (row.isSave) {
  1749. return Promise.resolve(true);
  1750. } else {
  1751. return await Promise.all(
  1752. fileds.map(
  1753. (item) =>
  1754. new Promise(async (res, rej) => {
  1755. this.$refs.productListRef.validateField(item, (err) => {
  1756. if (err) {
  1757. rej(err);
  1758. } else {
  1759. res(true);
  1760. }
  1761. });
  1762. })
  1763. )
  1764. );
  1765. }
  1766. });
  1767. console.log(list);
  1768. Promise.all(list)
  1769. .then(() => {
  1770. console.log('保存成功!');
  1771. resolve();
  1772. })
  1773. .catch((err) => {
  1774. console.log('保存失败!');
  1775. this.$message.error('请填入必填项!');
  1776. reject(err);
  1777. });
  1778. });
  1779. },
  1780. // 产品批量保存
  1781. async listSaveArrs() {
  1782. this.validateForm()
  1783. .then(async () => {
  1784. // 批量获取包装编码并处理
  1785. let packingCodePrams = this.productList.map((row) => {
  1786. if (row.isSave) {
  1787. return {};
  1788. } else {
  1789. return {
  1790. assetCode: row.categoryCode + row.index,
  1791. batchNum: row.batchNo,
  1792. num: row.packingQuantity
  1793. };
  1794. }
  1795. });
  1796. let filterPackingCodePrams = packingCodePrams.filter(
  1797. (item) => item.assetCode
  1798. );
  1799. let { data } = await storageApi.getAssetNum(filterPackingCodePrams);
  1800. let packingCodeList = [];
  1801. packingCodePrams.forEach((item, index) => {
  1802. packingCodeList[index] = data.filter(
  1803. (ite) => ite.assetCode == item.assetCode
  1804. );
  1805. });
  1806. // 批量生成包装
  1807. this.productList.map((row, index) => {
  1808. if (!row.isSave) {
  1809. this.generateWrappers(row, index, packingCodeList[index]);
  1810. this.$set(this.productList[index], 'isSave', true);
  1811. }
  1812. });
  1813. // 加载虚拟列表数据(分页)
  1814. // this.pickingFetchData();
  1815. // this.materielFetchData();
  1816. })
  1817. .catch((err) => {
  1818. console.log(err);
  1819. });
  1820. },
  1821. // 物品保存验证表单(单独)
  1822. validateFormIndividually(index) {
  1823. return new Promise(async (resolve) => {
  1824. console.log(index);
  1825. let fileds = [
  1826. `productList.${index}.batchNo`,
  1827. `productList.${index}.minPackingQuantity`,
  1828. `productList.${index}.packingQuantity`,
  1829. `productList.${index}.warehouseId`
  1830. ];
  1831. Promise.all(
  1832. fileds.map(
  1833. (item) =>
  1834. new Promise(async (res, rej) => {
  1835. this.$refs.productListRef.validateField(item, (err) => {
  1836. if (err) {
  1837. rej(err);
  1838. } else {
  1839. res(true);
  1840. }
  1841. });
  1842. })
  1843. )
  1844. )
  1845. .then(() => {
  1846. resolve();
  1847. })
  1848. .catch(() => {
  1849. this.$message.error('请填入必填项!');
  1850. });
  1851. });
  1852. },
  1853. // 产品编辑
  1854. listEdit(row) {
  1855. console.log(row);
  1856. this.$set(row, 'isSave', false);
  1857. // 重新计算重量
  1858. const totals = Number(
  1859. this.$math.format(row.minPackingQuantity * row.packingQuantity, 14)
  1860. );
  1861. if (row.measureUnit == row.weightUnit) {
  1862. row.weight = Number(
  1863. this.$math.format(
  1864. row.minPackingQuantity *
  1865. 1 *
  1866. Number(row.packingQuantity).toFixed(2),
  1867. 14
  1868. )
  1869. );
  1870. } else {
  1871. row.weight = Number(
  1872. this.$math.format(
  1873. totals *
  1874. (row.netWeight > 0 ? Number(row.netWeight).toFixed(2) : 0),
  1875. 14
  1876. )
  1877. );
  1878. }
  1879. console.log(row);
  1880. this.deletePackingAndMaterial(row);
  1881. },
  1882. // 根据产品信息删除包装和物料
  1883. deletePackingAndMaterial(row) {
  1884. // 删除包装(去掉不相同的包装)
  1885. this.packingList = this.packingList.filter(
  1886. (item) => item.parentIndex !== row.index
  1887. );
  1888. this.showPackingList = this.showPackingList.filter(
  1889. (item) => item.parentIndex !== row.index
  1890. );
  1891. this.pickingPageNum = Math.ceil(
  1892. this.showPackingList.length / this.pageSize
  1893. );
  1894. console.log('包装当前页数');
  1895. console.log(this.pickingPageNum);
  1896. // 删除物料(获取相同物料)
  1897. let packingIndexs = this.packingList.map((item) => item.index);
  1898. this.materialList = this.materialList.filter((item) =>
  1899. packingIndexs.includes(item.parentIndex)
  1900. );
  1901. this.showMaterialList = this.showMaterialList.filter((item) =>
  1902. packingIndexs.includes(item.parentIndex)
  1903. );
  1904. this.materielPageNum = Math.ceil(
  1905. this.showMaterialList.length / this.pageSize
  1906. );
  1907. console.log('物料当前页数');
  1908. console.log(this.showMaterialList.length);
  1909. console.log(this.pageSize);
  1910. console.log(this.materielPageNum);
  1911. },
  1912. // 产品保存操作
  1913. listSave(row, index) {
  1914. this.validateFormIndividually(index).then(async () => {
  1915. console.log('保存成功');
  1916. // 获取包装编码列表
  1917. const { data } = await storageApi.getAssetNum([
  1918. {
  1919. assetCode: row.categoryCode + row.index,
  1920. batchNum: row.batchNo,
  1921. num: row.packingQuantity
  1922. }
  1923. ]);
  1924. this.generateWrappers(row, index, data);
  1925. this.$set(this.productList[index], 'isSave', true);
  1926. // 加载虚拟列表数据(分页)
  1927. // this.pickingFetchData();
  1928. // this.materielFetchData();
  1929. });
  1930. },
  1931. //入库明细删除
  1932. listDel(row, index) {
  1933. this.productList.splice(index, 1);
  1934. this.deletePackingAndMaterial(row);
  1935. },
  1936. // 打开仓库弹框
  1937. handleWareHouse(row, idx) {
  1938. if (idx > -1) {
  1939. if (row.packingQuantity > 0) {
  1940. this.$refs.wareHouseDailogRef.open(row.packingQuantity, idx);
  1941. } else {
  1942. this.$message.error('请先填写包装数量!');
  1943. }
  1944. } else {
  1945. let boolen = this.productList.every(
  1946. (item) =>
  1947. item.packingQuantity == this.productList[0].packingQuantity
  1948. );
  1949. if (boolen) {
  1950. if (row.packingQuantity > 0) {
  1951. this.$refs.wareHouseDailogRef.open(row.packingQuantity, idx);
  1952. } else {
  1953. this.$message.error('请先填写包装数量!');
  1954. }
  1955. } else {
  1956. this.$message.error('请保证产品包装数量一致!');
  1957. }
  1958. }
  1959. },
  1960. wareHouseSelection(argum, idx) {
  1961. console.log(argum);
  1962. console.log(idx);
  1963. // 方便包装遍历获取仓库id和名称
  1964. let warehouseIds = [];
  1965. let warehouseNames = [];
  1966. argum.forEach((item) => {
  1967. for (let index = 0; index < item.packingQuantity; index++) {
  1968. warehouseIds.push(item.warehouseId);
  1969. warehouseNames.push(item.warehouseName);
  1970. }
  1971. });
  1972. console.log(warehouseIds);
  1973. console.log(warehouseNames);
  1974. if (idx > -1) {
  1975. this.$set(
  1976. this.productList[idx],
  1977. 'warehouseId',
  1978. argum.map((item) => item.warehouseId).join(',')
  1979. );
  1980. this.$set(
  1981. this.productList[idx],
  1982. 'warehouseName',
  1983. argum.map((item) => item.warehouseName).join(',')
  1984. );
  1985. this.$set(this.productList[idx], 'warehouseIds', warehouseIds);
  1986. this.$set(this.productList[idx], 'warehouseNames', warehouseNames);
  1987. } else {
  1988. this.productList.map((item, index) => {
  1989. this.$set(
  1990. this.productList[index],
  1991. 'warehouseId',
  1992. argum.map((item) => item.warehouseId).join(',')
  1993. );
  1994. this.$set(
  1995. this.productList[index],
  1996. 'warehouseName',
  1997. argum.map((item) => item.warehouseName).join(',')
  1998. );
  1999. this.$set(this.productList[index], 'warehouseIds', warehouseIds);
  2000. this.$set(
  2001. this.productList[index],
  2002. 'warehouseNames',
  2003. warehouseNames
  2004. );
  2005. });
  2006. }
  2007. this.$forceUpdate();
  2008. },
  2009. // 生成包装
  2010. generateWrappers(row, productIndex, packingCodeList) {
  2011. let packingList = [];
  2012. for (let index = 0; index < row.packingQuantity; index++) {
  2013. let item = {
  2014. index: row.index + '-' + index, // 包装索引
  2015. warehouseId: row.warehouseIds[index], // 仓库id
  2016. warehouseName: row.warehouseNames[index], // 仓库名称
  2017. categoryName: row.categoryName, // 产品名称
  2018. categoryCode: row.categoryCode, // 产品编码
  2019. parentIndex: row.index, // 产品索引
  2020. batchNo: row.batchNo, // 批次号
  2021. packageNo: packingCodeList[index].onlyCode, // 包装编码
  2022. packingQuantity: 1, // 包装数量
  2023. packingUnit: row.packingUnit, // 包装单位
  2024. measureQuantity: row.minPackingQuantity, // 计量数量
  2025. measureUnit: row.measureUnit, // 计量单位
  2026. weight: Number(
  2027. this.$math.format(row.weight / row.packingQuantity, 14)
  2028. ), // 重量
  2029. weightUnit: row.weightUnit, // 重量单位
  2030. barcodes: '', // 发货条码
  2031. clientCode: '', // 客户代号
  2032. materielDesignation: '', // 物料代号
  2033. engrave: '', // 刻码
  2034. isUnpack: row.isUnpack, // 是否允许拆包
  2035. productionDate: '', // 生产日期
  2036. purchaseDate: '', // 采购时间
  2037. result: 1, // 结果(1合格 2不合格)
  2038. status: 1 // 状态(0=未质检 1已质检)
  2039. };
  2040. packingList.push(item);
  2041. }
  2042. // 单独点击保存并插入对应位置(包装)
  2043. // if (productIndex > -1) {
  2044. if (productIndex == 0) {
  2045. this.packingList.splice(productIndex, 0, ...packingList);
  2046. } else {
  2047. let packingIndex = this.packingList.findLastIndex(
  2048. (item) => item.parentIndex === productIndex - 1
  2049. );
  2050. this.packingList.splice(packingIndex + 1, 0, ...packingList);
  2051. }
  2052. // } else {
  2053. // // 批量点击生成包装
  2054. // this.packingList = this.packingList.concat(packingList);
  2055. // }
  2056. // 单独点击保存并插入对应位置(物料)
  2057. let materialList = packingList
  2058. .map((item) => {
  2059. if (item.isUnpack) {
  2060. return this.generateMaterial(item);
  2061. } else {
  2062. return [];
  2063. }
  2064. })
  2065. .flat();
  2066. console.log(materialList);
  2067. if (materialList.length > 0) {
  2068. // if (productIndex > -1) {
  2069. if (productIndex == 0) {
  2070. this.materialList.splice(0, 0, ...materialList);
  2071. } else {
  2072. let preLastPackingIndex = this.packingList.findLastIndex((ite) => {
  2073. return ite.parentIndex <= productIndex - 1 && ite.isUnpack;
  2074. });
  2075. // console.log('preLastPackingIndex-------', preLastPackingIndex);
  2076. // console.log(this.packingList);
  2077. // console.log(this.packingList[preLastPackingIndex]);
  2078. // console.log(this.materialList);
  2079. // console.log(this.packingList[preLastPackingIndex].index);
  2080. let preLastMaterialIndex = this.materialList.findLastIndex(
  2081. (ite) => {
  2082. return (
  2083. ite.parentIndex == this.packingList[preLastPackingIndex].index
  2084. );
  2085. }
  2086. );
  2087. // console.log('preLastMaterialIndex-------', preLastMaterialIndex);
  2088. this.materialList.splice(
  2089. preLastMaterialIndex + 1,
  2090. 0,
  2091. ...materialList
  2092. );
  2093. }
  2094. // } else {
  2095. // this.materialList = this.materialList.concat(materialList);
  2096. // }
  2097. console.log(this.materialList);
  2098. }
  2099. },
  2100. // 生成物料
  2101. generateMaterial(row) {
  2102. let materialList = [];
  2103. for (let index = 0; index < row.measureQuantity; index++) {
  2104. materialList.push({
  2105. materialCode: row.packageNo + index.toString().padStart(4, '0'), // 物料编码
  2106. index: row.index + '——' + index, // 包装索引
  2107. warehouseId: row.warehouseId, // 仓库id
  2108. warehouseName: row.warehouseName, // 仓库名称
  2109. categoryName: row.categoryName, // 产品名称
  2110. categoryCode: row.categoryCode, // 产品编码
  2111. parentIndex: row.index, // 产品索引
  2112. batchNo: row.batchNo, // 批次号
  2113. packageNo: row.packageNo, // 包装编码
  2114. measureQuantity: 1, // 计量数量
  2115. measureUnit: row.measureUnit, // 计量单位
  2116. weight: Number(
  2117. this.$math.format(row.weight / row.packingQuantity, 14)
  2118. ), // 重量
  2119. weightUnit: row.weightUnit, // 重量单位
  2120. barcodes: '', // 发货条码
  2121. clientCode: '', // 客户代号
  2122. materielDesignation: '', // 物料代号
  2123. engrave: '', // 刻码
  2124. result: 1, // 结果(1合格 2不合格)
  2125. status: 1 // 状态(0=未质检 1已质检)
  2126. });
  2127. }
  2128. return materialList;
  2129. },
  2130. // 设置时间
  2131. dateSetting() {
  2132. if (!this.packingListSelected.length) {
  2133. return this.$message.error(`请选择${this.title}明细!`);
  2134. }
  2135. this.dateVisible = true;
  2136. },
  2137. // 选择包装列表
  2138. handleSelectionChange(val) {
  2139. this.packingListSelected = val;
  2140. },
  2141. // 选择质检结果改变质检状态
  2142. changeWrapStatus(resultValue, row, type) {
  2143. console.log(resultValue);
  2144. switch (resultValue) {
  2145. case '0':
  2146. // 清空质检状态
  2147. row.status = 0;
  2148. break;
  2149. default:
  2150. // 默认已检质检状态
  2151. row.status = 1;
  2152. break;
  2153. }
  2154. if (type === '包装') {
  2155. this.packingResultCahnge(resultValue, row);
  2156. } else {
  2157. this.materialResultCahnge(resultValue, row);
  2158. }
  2159. }
  2160. }
  2161. };
  2162. </script>
  2163. <style lang="scss" scoped>
  2164. .inbound_details {
  2165. margin-top: 10px;
  2166. .el-form-item {
  2167. margin-bottom: 0 !important;
  2168. }
  2169. }
  2170. .right_control {
  2171. display: flex;
  2172. > button {
  2173. margin-left: 20px;
  2174. }
  2175. }
  2176. .storage_btn {
  2177. margin-top: 20px;
  2178. display: flex;
  2179. align-content: center;
  2180. justify-content: center;
  2181. }
  2182. .el-date-editor.el-input,
  2183. .el-date-editor.el-input__inner {
  2184. width: 200px !important;
  2185. }
  2186. .red_color {
  2187. color: red;
  2188. }
  2189. .wareHouse_style {
  2190. text-overflow: ellipsis;
  2191. overflow: hidden;
  2192. word-break: break-all;
  2193. white-space: nowrap;
  2194. }
  2195. </style>