storage.vue 115 KB

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