storage.vue 106 KB

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