add.vue 115 KB

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