storage_3.vue 97 KB

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