add_2.vue 90 KB

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