storage.vue 104 KB

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