storage_2.vue 86 KB

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