procurementStorage_new.vue 66 KB

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