add.vue 115 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148
  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="weight"
  354. width="160"
  355. :show-overflow-tooltip="true"
  356. >
  357. <template slot-scope="{ row, $index }">
  358. <el-input
  359. :disabled="row.isSave"
  360. v-model="row.weight"
  361. placeholder="请输入"
  362. @input="inputWeight(row, $index)"
  363. ></el-input>
  364. <template slot="append">
  365. {{ row.measureUnit }}
  366. </template>
  367. </template>
  368. </el-table-column>
  369. <el-table-column
  370. label="单重"
  371. align="center"
  372. width="160"
  373. prop=""
  374. :show-overflow-tooltip="true"
  375. >
  376. <template slot-scope="{ row, $index }">
  377. <el-input-number
  378. :disabled="row.isSave"
  379. v-model="row.singleWeight"
  380. placeholder="请输入"
  381. :precision="2"
  382. :step="0.1"
  383. :min="0"
  384. @input="inputsingleWeight(row, $index)"
  385. ></el-input-number>
  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. console.log('startIndex-----', startIndex);
  1296. let endIndex = row.packingSpecificationOption.findIndex(
  1297. (ite) => row.packingUnit == ite.conversionUnit
  1298. );
  1299. console.log('endIndex-----', endIndex);
  1300. // 除了计量单位是KG以外计算总重 总重量 = 单重singleWeight * 数量measureQuantity(计量数量);
  1301. if (row.measuringUnit == 'KG') {
  1302. row.weight = row.singleWeight * row.measureQuantity;
  1303. }
  1304. // packingQuantity 包装数量
  1305. let total = row.packingQuantity;
  1306. for (; startIndex < endIndex; endIndex--) {
  1307. total = this.$math.format(
  1308. row.packingSpecificationOption[endIndex].packageCell * total,
  1309. 14
  1310. );
  1311. }
  1312. //计量数量
  1313. row.measureQuantity = this.changeCount(total);
  1314. // 判断单位和计量单位是否为不拆物料层规格
  1315. let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
  1316. .dictValue;
  1317. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
  1318. .dictValue;
  1319. if (packingBoolen || measureBoolen) {
  1320. row.weight = total;
  1321. } else {
  1322. row.weight = this.$math.format(total * row.netWeight, 14);
  1323. }
  1324. }
  1325. },
  1326. //出入库申请列表操作直接入库
  1327. getProduct() {
  1328. let aaa = [this.$route.query.inId];
  1329. console.log(aaa, 'abcabcabcabcabcabcabcabcabc');
  1330. storageApi.getApplystoragedetails(aaa).then(async (res) => {
  1331. if (this.$route.query.type == 2) {
  1332. // 出库
  1333. let data = await storageApi.getHierarchyFifo({
  1334. type: 1,
  1335. builders: res.map((item) => {
  1336. return {
  1337. categoryId: item.categoryId,
  1338. num: item.measureQuantity
  1339. };
  1340. })
  1341. });
  1342. if (data?.length > 0) {
  1343. this.outboundRequisitionSelection(data, 1, {
  1344. sourceBizNo: this.$route.query.code,
  1345. bizType: this.$route.query.sourceType,
  1346. assetType: Array.from(
  1347. new Set(res.map((item) => item.rootCategoryLevelId))
  1348. ).join(',')
  1349. });
  1350. } else {
  1351. this.$message.warning('该出库申请单无库存');
  1352. }
  1353. } else {
  1354. // 入库
  1355. const batchNo = await getCode('lot_number_code');
  1356. console.log(res, '入库');
  1357. let data = res.map((item, index) => {
  1358. return {
  1359. ...item,
  1360. index,
  1361. // packingQuantity: 1,
  1362. // minPackingQuantity: item.measureQuantity,
  1363. // measureUnit: item.measuringUnit,
  1364. batchNo,
  1365. id: '',
  1366. warehouseIds: [item.warehouseId],
  1367. warehouseNames: [item.warehouseName]
  1368. };
  1369. });
  1370. this.outboundRequisitionSelection(data, 1, {
  1371. sourceBizNo: this.$route.query.code,
  1372. bizType: this.$route.query.sourceType,
  1373. assetType: Array.from(
  1374. new Set(res.map((item) => item.rootCategoryLevelId))
  1375. ).join(',')
  1376. });
  1377. }
  1378. });
  1379. },
  1380. async outboundRequisitionSelection(data, dimension, query) {
  1381. console.log('data-----------', data);
  1382. console.log('query-----------', query);
  1383. if (this.formData.bizType != 10) {
  1384. this.formData.sourceBizNo = query.sourceBizNo;
  1385. this.formData.bizType = query.bizType;
  1386. this.formData.extInfo.assetType = query.assetType.split(',');
  1387. const batchNo = await getCode('lot_number_code');
  1388. // 获取包装规格
  1389. let packingSpecification =
  1390. await storageApi.getCategoryPackageDisposition({
  1391. categoryIds: data.map((item) => item.categoryId)
  1392. });
  1393. this.packingSpecificationOption = data.map((item) => {
  1394. return packingSpecification
  1395. .filter((ite) => item.categoryId == ite.categoryId)
  1396. .sort((a, b) => a.sort - b.sort);
  1397. });
  1398. console.log(
  1399. 'this.packingSpecificationOption-----------',
  1400. this.packingSpecificationOption
  1401. );
  1402. this.productList = data.map((productItem, productIndex) => {
  1403. // 显示规格
  1404. let packingSpecificationLabel = this.packingSpecificationOption[
  1405. productIndex
  1406. ]
  1407. .map((item) => {
  1408. if (item.sort > 0) {
  1409. return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
  1410. }
  1411. })
  1412. .filter((item) => !!item);
  1413. return {
  1414. ...productItem,
  1415. index: this.productList.length + productIndex,
  1416. isSave:
  1417. productItem.outInDetailRecordRequestList?.length > 0
  1418. ? true
  1419. : false,
  1420. netWeight: productItem.netWeight > 0 ? productItem.netWeight : 0,
  1421. batchNo: batchNo, // 批次号
  1422. warehouseIds: [productItem.warehouseId], // 仓库Id
  1423. warehouseNames: [productItem.warehouseName], // 仓库名称
  1424. packingSpecificationOption:
  1425. this.packingSpecificationOption[productIndex], // 包装规格选项
  1426. packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
  1427. outInDetailRecordRequestList:
  1428. productItem.outInDetailRecordRequestList?.length > 0
  1429. ? productItem.outInDetailRecordRequestList.map(
  1430. (packingItem, packingIndex) => {
  1431. return {
  1432. ...packingItem,
  1433. index:
  1434. this.productList.length +
  1435. productIndex +
  1436. '-' +
  1437. packingIndex, // 包装索引
  1438. batchNo: batchNo, // 批次号
  1439. parentIndex: this.productList.length + productIndex, // 物品索引
  1440. categoryName: productItem.categoryName,
  1441. categoryCode: productItem.categoryCode,
  1442. materialDetailList:
  1443. packingItem.materialDetailList.map(
  1444. (materialItem, materialIndex) => {
  1445. return {
  1446. ...materialItem,
  1447. index:
  1448. this.productList.length +
  1449. productIndex +
  1450. '-' +
  1451. packingIndex +
  1452. '——' +
  1453. materialIndex, // 包装索引
  1454. parentIndex:
  1455. this.productList.length +
  1456. productIndex +
  1457. '-' +
  1458. packingIndex, // 物品索引
  1459. batchNo: batchNo, // 批次号
  1460. categoryName: productItem.categoryName,
  1461. categoryCode: productItem.categoryCode
  1462. };
  1463. }
  1464. )
  1465. };
  1466. }
  1467. )
  1468. : []
  1469. };
  1470. });
  1471. console.log(
  1472. 'this.productList-----------------------',
  1473. this.productList
  1474. );
  1475. // 获取包装维度数据
  1476. const arr = [];
  1477. for (const key in this.productList) {
  1478. for (const k in this.productList[key]
  1479. .outInDetailRecordRequestList) {
  1480. arr.push({
  1481. ...this.productList[key].outInDetailRecordRequestList[k]
  1482. });
  1483. }
  1484. }
  1485. this.packingList = arr;
  1486. // 获取物料维度数据
  1487. let iArr = [];
  1488. arr.forEach((item) => {
  1489. item.materialDetailList.forEach((ele) => {
  1490. iArr.push({ ...ele });
  1491. });
  1492. });
  1493. this.materialList = iArr;
  1494. } else {
  1495. this.selWWData = query;
  1496. this.$set(this.formData, 'sourceBizNo', query.sourceBizNo);
  1497. }
  1498. },
  1499. // 获取动态表头
  1500. getFieldModel() {
  1501. storageApi.fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  1502. let newRes = res.map((m) => {
  1503. return {
  1504. prop: 'extField.' + m.prop,
  1505. label: m.label,
  1506. align: 'center',
  1507. showOverflowTooltip: true
  1508. };
  1509. });
  1510. this.newColumns = [...newRes];
  1511. });
  1512. },
  1513. // 初始化当前用户信息
  1514. async initUserInfo() {
  1515. const res = await warehouseDefinition.tree();
  1516. let info = JSON.parse(localStorage.getItem('info'));
  1517. let obj = res.find(
  1518. (item) => item.id === info.deptIds[info.deptIds.length - 1]
  1519. );
  1520. if (!obj) return;
  1521. this.formData.extInfo.deptCode = obj.id;
  1522. this.formData.extInfo.deptName = obj.name;
  1523. this.formData.extInfo.createUserName = info.name;
  1524. this.formData.createUserId = info.userId;
  1525. },
  1526. // 获取当前时间函数
  1527. getNowDate() {
  1528. let date = new Date(),
  1529. obj = {
  1530. year: date.getFullYear(), //获取完整的年份(4位)
  1531. month: date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
  1532. strDate: date.getDate(), // 获取当前日(1-31)
  1533. hour: date.getHours(), //获取当前小时(0 ~ 23)
  1534. minute: date.getMinutes(), //获取当前分钟(0 ~ 59)
  1535. second: date.getSeconds() //获取当前秒数(0 ~ 59)
  1536. };
  1537. Object.keys(obj).forEach((key) => {
  1538. if (obj[key] < 10) obj[key] = `0${obj[key]}`;
  1539. });
  1540. return obj;
  1541. },
  1542. // 赋值入库时间
  1543. getNowFormatDate() {
  1544. let obj = this.getNowDate();
  1545. this.formData.storageTime = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  1546. },
  1547. // 获取物品列表
  1548. async getListItems() {
  1549. const res2 = await warehouseDefinition.getTreeByGroup({ type: 1 });
  1550. this.goodsLists = res2;
  1551. },
  1552. // 打开单据来源弹窗
  1553. openDocumentSourceDialog() {
  1554. console.log('打开单据来源弹窗');
  1555. this.$refs.outboundRequisitionDialogRef.open();
  1556. },
  1557. // 清除单据来源
  1558. clearSourceBizNo() {
  1559. this.formData.sourceBizNo = '';
  1560. },
  1561. // 返回
  1562. back() {
  1563. this.$router.go(-1);
  1564. },
  1565. // 添加产品
  1566. addProduct() {
  1567. if (this.formData.extInfo.assetType.length <= 0) {
  1568. return this.$message.error('请选择物品类型');
  1569. }
  1570. if (!this.formData.bizType) {
  1571. return this.$message.error('请选择入库类型');
  1572. }
  1573. this.visibleDialog = true;
  1574. },
  1575. // 键盘移动
  1576. moveFocus(event, index, key, type, row) {
  1577. let keyfield = [];
  1578. let listLength = 0;
  1579. switch (type) {
  1580. case '产品':
  1581. listLength = this.productList.length;
  1582. keyfield = ['batchNo', 'packingQuantity', 'price', 'purpose'];
  1583. break;
  1584. case '包装':
  1585. listLength = this.showPackingList.length;
  1586. if (row.measureUnit != row.weightUnit) {
  1587. keyfield = [
  1588. 'packing_materielDesignation',
  1589. 'packing_clientCode',
  1590. 'packing_engrave',
  1591. 'packing_weight'
  1592. ];
  1593. } else {
  1594. keyfield = [
  1595. 'packing_materielDesignation',
  1596. 'packing_clientCode',
  1597. 'packing_engrave'
  1598. ];
  1599. }
  1600. break;
  1601. case '物料':
  1602. listLength = this.showMaterialList.length;
  1603. if (row.measureUnit != row.weightUnit) {
  1604. keyfield = [
  1605. 'material_materielDesignation',
  1606. 'material_clientCode',
  1607. 'material_engrave',
  1608. 'material_weight'
  1609. ];
  1610. } else {
  1611. keyfield = [
  1612. 'material_materielDesignation',
  1613. 'material_clientCode',
  1614. 'material_engrave'
  1615. ];
  1616. }
  1617. break;
  1618. }
  1619. if (event.keyCode === 13) {
  1620. // 回车
  1621. if (
  1622. index === listLength - 1 &&
  1623. key === keyfield[keyfield.length - 1]
  1624. ) {
  1625. // 最后一行最后一个
  1626. return;
  1627. }
  1628. this.$refs[key + index].blur();
  1629. if (key === keyfield[keyfield.length - 1]) {
  1630. // 当前行最后一个,跳转下一行第一个
  1631. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  1632. this.$refs[keyfield[0] + (index + 1)].value = '';
  1633. }
  1634. this.$refs[keyfield[0] + (index + 1)].focus();
  1635. } else {
  1636. // 跳转下一个
  1637. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  1638. this.$nextTick(() => {
  1639. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  1640. this.$refs[keyfield[nextkeyindex] + index].value = '';
  1641. }
  1642. this.$refs[keyfield[nextkeyindex] + index].focus();
  1643. });
  1644. }
  1645. }
  1646. // 向上 =38
  1647. if (event.keyCode === 38) {
  1648. console.log('向上');
  1649. if (index === 0) {
  1650. // 第一行
  1651. console.log('第一行无法向上');
  1652. return;
  1653. }
  1654. this.$refs[key + index].blur();
  1655. this.$nextTick(() => {
  1656. if (this.$refs[key + (index - 1)].value == 0) {
  1657. this.$refs[key + (index - 1)].value = '';
  1658. }
  1659. this.$refs[key + (index - 1)].focus();
  1660. });
  1661. }
  1662. // 下 = 40
  1663. if (event.keyCode === 40) {
  1664. console.log('向下');
  1665. if (index === listLength - 1) {
  1666. // 最后一行
  1667. console.log('最后一行无法向下');
  1668. return;
  1669. }
  1670. this.$refs[key + index].blur();
  1671. this.$nextTick(() => {
  1672. if (this.$refs[key + (index + 1)].value == 0) {
  1673. this.$refs[key + (index + 1)].value = '';
  1674. }
  1675. this.$refs[key + (index + 1)].focus();
  1676. });
  1677. }
  1678. // 左 = 37
  1679. if (event.keyCode === 37) {
  1680. console.log('向左');
  1681. if (index === 0 && key === keyfield[0]) {
  1682. // 第一行第一个
  1683. console.log('第一行第一个无法向左');
  1684. return;
  1685. }
  1686. this.$refs[key + index].blur();
  1687. if (key === keyfield[0]) {
  1688. if (
  1689. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value == 0
  1690. ) {
  1691. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value =
  1692. '';
  1693. }
  1694. // 当前行第一个,跳转上一行最后一个
  1695. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].focus();
  1696. } else {
  1697. // 跳转上一个
  1698. const prevkeyindex = keyfield.findIndex((k) => k === key) - 1;
  1699. this.$nextTick(() => {
  1700. if (this.$refs[keyfield[prevkeyindex] + index].value == 0) {
  1701. this.$refs[keyfield[prevkeyindex] + index].value = '';
  1702. }
  1703. this.$refs[keyfield[prevkeyindex] + index].focus();
  1704. });
  1705. }
  1706. }
  1707. // 右 = 39
  1708. if (event.keyCode === 39) {
  1709. console.log('向右');
  1710. if (
  1711. index === listLength - 1 &&
  1712. key === keyfield[keyfield.length - 1]
  1713. ) {
  1714. // 最后一行最后一个
  1715. console.log('最后一行最后一个无法向左');
  1716. return;
  1717. }
  1718. console.log(this.$refs);
  1719. this.$refs[key + index].blur();
  1720. if (key === keyfield[keyfield.length - 1]) {
  1721. // 当前行最后一个,跳转下一行第一个
  1722. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  1723. this.$refs[keyfield[0] + (index + 1)].value = '';
  1724. }
  1725. this.$refs[keyfield[0] + (index + 1)].focus();
  1726. } else {
  1727. // 跳转下一个
  1728. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  1729. this.$nextTick(() => {
  1730. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  1731. this.$refs[keyfield[nextkeyindex] + index].value = '';
  1732. }
  1733. this.$refs[keyfield[nextkeyindex] + index].focus();
  1734. });
  1735. }
  1736. }
  1737. },
  1738. handleAvatarSuccess() {
  1739. this.$refs.fileUploadBtn.clearFiles(); //上传成功之后清除历史记录**加粗样式**
  1740. },
  1741. async onChange(file) {
  1742. console.log(XLSX);
  1743. this.warehousingMaterialList = [];
  1744. this.resultArray = [];
  1745. const loading = this.$loading({
  1746. lock: true,
  1747. text: '加载中...'
  1748. });
  1749. /**
  1750. * 1. 使用原生api去读取好的文件
  1751. * */
  1752. // console.log("原始上传的文件", file);
  1753. // 读取文件不是立马能够读取到的,所以是异步的,使用Promise
  1754. let dataBinary = await new Promise((resolve) => {
  1755. // Web API构造函数FileReader,可实例化对象,去调用其身上方法,去读取解析文件信息
  1756. let reader = new FileReader(); // https://developer.mozilla.org/zh-CN/docs/Web/API/FileReader
  1757. // console.log("实例化对象有各种方法", reader);
  1758. reader.readAsBinaryString(file.raw); // 读取raw的File文件
  1759. reader.onload = (ev) => {
  1760. // console.log("文件解析流程进度事件", ev);
  1761. resolve(ev.target.result); // 将解析好的结果扔出去,以供使用
  1762. };
  1763. });
  1764. // console.log("读取出的流文件", dataBinary);
  1765. /**
  1766. * 2. 使用xlsx插件去解析已经读取好的二进制excel流文件
  1767. * */
  1768. let workBook = XLSX.read(dataBinary, {
  1769. type: 'binary',
  1770. cellDates: true
  1771. });
  1772. // excel中有很多的sheet,这里取了第一个sheet:workBook.SheetNames[0]
  1773. let firstWorkSheet = workBook.Sheets[workBook.SheetNames[0]];
  1774. // 分为第一行的数据,和第一行下方的数据
  1775. // const header = this.getHeaderRow(firstWorkSheet);
  1776. // console.log('读取的excel表头数据(第一行)', header);
  1777. const xlsxData = XLSX.utils.sheet_to_json(firstWorkSheet);
  1778. console.log('读取所有excel数据', xlsxData);
  1779. // let modelTypeList = xlsxData.map((item) => {
  1780. // return item['型号'];
  1781. // });
  1782. // let nameList = xlsxData.map((item) => {
  1783. // return item['物品名称'];
  1784. // });
  1785. let codeList = xlsxData.map((item) => {
  1786. return item['sap物料码'];
  1787. });
  1788. let functionType = {};
  1789. xlsxData.map((item) => {
  1790. functionType[item['sap物料码']] = item['采购原因'];
  1791. });
  1792. this.formData.extInfo.assetType = ['6']; //备品备件
  1793. this.formData.bizType = '2'; // 采购入库
  1794. outin
  1795. .getListByNameOrModeType({
  1796. // modelTypeList,
  1797. // nameList,
  1798. codeList,
  1799. categoryLevelId: '6'
  1800. })
  1801. .then(async (data) => {
  1802. console.log('查询到的备件数据', data);
  1803. const batchNo = await getCode('lot_number_code');
  1804. // 添加包装数量和最小包装单元
  1805. this.productList = data.map((item, index) => {
  1806. console.log(xlsxData);
  1807. let filterArray = xlsxData.filter(
  1808. (xlsxItem) => xlsxItem['sap物料码'] == item.code
  1809. );
  1810. console.log(filterArray);
  1811. return {
  1812. index: this.productList.length + index,
  1813. categoryId: item.id, // 物品id
  1814. categoryName: item.name, // 物品名称
  1815. categoryCode: item.code, // 物品编码
  1816. categoryModel: item.modelType, // 物品型号
  1817. specification: item.specification, // 规格
  1818. brandNum: item.brandNum, // 牌号
  1819. batchNo: batchNo, // 批次号
  1820. minPackingQuantity: 1, // 最小包装单元数量
  1821. packingQuantity: filterArray[0]['数量'], // 包装数量
  1822. packingUnit: item.packingUnit, // 单位
  1823. measureQuantity: 0, // 计量数量
  1824. measureUnit: item.measuringUnit, // 计量单位
  1825. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  1826. weight: 0, // 重量
  1827. weightUnit: item.weightUnit, // 重量单位
  1828. totalMoney: '', // 总价
  1829. price: item.price, // 单价
  1830. purpose: functionType[item.code], // 用途
  1831. isUnpack: item.isUnpack // 是否允许拆包
  1832. };
  1833. });
  1834. console.log(this.productList);
  1835. this.handleAvatarSuccess();
  1836. loading.close();
  1837. })
  1838. .catch(() => {
  1839. loading.close();
  1840. });
  1841. },
  1842. // 入库
  1843. storage() {
  1844. let boolen = this.productList.every((item) => item.isSave);
  1845. if (!boolen) {
  1846. this.$message.warning('请先保存所有产品信息');
  1847. return;
  1848. }
  1849. // 处理包装数据
  1850. this.packingList = this.packingList.map((packingItem) => {
  1851. return {
  1852. ...packingItem,
  1853. materialDetailList: this.materialList.filter(
  1854. (item) => item.parentIndex === packingItem.index
  1855. ),
  1856. taskId: this.selWWData?.taskId,
  1857. workOrderId: this.selWWData?.workOrderId
  1858. };
  1859. });
  1860. // 处理产品数据
  1861. this.productList = this.productList.map((productItem) => {
  1862. return {
  1863. ...productItem,
  1864. outInDetailRecordRequestList: this.packingList.filter(
  1865. (item) => item.parentIndex === productItem.index
  1866. )
  1867. };
  1868. });
  1869. this.formData.outInDetailList = this.productList;
  1870. let obj = deepClone(this.formData);
  1871. // 处理物品类型assetType
  1872. obj.extInfo.assetType = obj.extInfo.assetType.join(',');
  1873. // 处理仓库id
  1874. let warehouseId = [];
  1875. let warehouseName = [];
  1876. let warehouseIds = this.productList
  1877. .map((item) => item.warehouseIds)
  1878. .flat();
  1879. let warehouseNames = this.productList
  1880. .map((item) => item.warehouseNames)
  1881. .flat();
  1882. warehouseIds.forEach((item, index) => {
  1883. if (!warehouseId.includes(item)) {
  1884. warehouseId.push(item);
  1885. warehouseName.push(warehouseNames[index]);
  1886. }
  1887. });
  1888. obj.warehouseIds = warehouseId;
  1889. obj.warehouseNames = warehouseName;
  1890. console.log('入库数据', obj);
  1891. // 是否需要审核(0审核 1跳过审核)
  1892. if (obj.bizType == '12') {
  1893. obj.isSkip = 1;
  1894. } else {
  1895. obj.isSkip = 0;
  1896. }
  1897. // obj.isSkip = 1;
  1898. console.log(this.productList);
  1899. this.saveLoading = true;
  1900. storageApi
  1901. .storage(obj)
  1902. .then(async (res) => {
  1903. console.log('入库成功', res);
  1904. if (res.code == 0) {
  1905. try {
  1906. // 委外入库(非采购)
  1907. if (obj.bizType == '12') {
  1908. await storageApi.qualityInspectionTwo({
  1909. outInId: res.data[0]
  1910. });
  1911. } else {
  1912. await storageApi.submitTwo({ outInId: res.data[0] });
  1913. }
  1914. this.$message.success('入库成功');
  1915. this.saveLoading = false;
  1916. this.$router.push('/warehouseManagement/stockManagement');
  1917. } catch (error) {
  1918. this.saveLoading = false;
  1919. console.log('提交流程失败', error);
  1920. }
  1921. }
  1922. })
  1923. .catch((err) => {
  1924. console.log('入库失败', err);
  1925. this.saveLoading = false;
  1926. });
  1927. },
  1928. pickingHandleScroll() {
  1929. // console.log('---------pickingHandleScroll------------');
  1930. // console.log(this.packingList);
  1931. // console.log(this.showPackingList);
  1932. // console.log(this.pageSize);
  1933. if (this.showPackingList.length < this.packingList.length) {
  1934. if (this.packingList.length > this.pageSize) {
  1935. this.pickingPageNum += 1;
  1936. }
  1937. this.pickingFetchData();
  1938. }
  1939. },
  1940. pickingFetchData() {
  1941. const start = (this.pickingPageNum - 1) * this.pageSize;
  1942. const end = start + this.pageSize;
  1943. console.log(start);
  1944. console.log(end);
  1945. this.showPackingList = this.showPackingList.concat(
  1946. this.packingList.slice(start, end)
  1947. );
  1948. },
  1949. materielHandleScroll() {
  1950. console.log('---------materielHandleScroll------------');
  1951. if (this.showMaterialList.length < this.materialList.length) {
  1952. if (this.materialList.length > this.pageSize) {
  1953. this.materielPageNum += 1;
  1954. }
  1955. this.materielFetchData();
  1956. }
  1957. },
  1958. materielFetchData() {
  1959. const start = (this.materielPageNum - 1) * this.pageSize;
  1960. const end = start + this.pageSize;
  1961. this.showMaterialList = this.showMaterialList.concat(
  1962. this.materialList.slice(start, end)
  1963. );
  1964. console.log(this.showMaterialList);
  1965. },
  1966. // 日期选择
  1967. dateConfirm() {
  1968. this.packingListSelected.forEach((item) => {
  1969. this.$set(item, this.curDateType, this.batchTime);
  1970. });
  1971. this.batchTime = '';
  1972. this.dateVisible = false;
  1973. },
  1974. // 包装重量修改
  1975. packingWeightCahnge(value, row) {
  1976. // 修改物品重量
  1977. let filterPackingList = this.packingList.filter((item) => {
  1978. return item.parentIndex === row.parentIndex;
  1979. });
  1980. let productIndex = this.productList.findIndex((item) => {
  1981. return item.index === row.parentIndex;
  1982. });
  1983. let totalWeight = filterPackingList.reduce(
  1984. (accumulator, currentValue) => {
  1985. return this.$math.format(+accumulator + +currentValue.weight, 14);
  1986. },
  1987. 0
  1988. );
  1989. this.$set(this.productList[productIndex], 'weight', totalWeight);
  1990. this.$set(
  1991. this.productList[productIndex],
  1992. 'singleWeight',
  1993. totalWeight / this.productList[productIndex].measureQuantity
  1994. );
  1995. // 修改拆分物料
  1996. this.materialList.map((item, index) => {
  1997. if (item.parentIndex === row.index) {
  1998. console.log(value / row.measureQuantity);
  1999. this.$set(
  2000. this.materialList[index],
  2001. 'weight',
  2002. this.$math.format(value / row.measureQuantity, 14) >= 0
  2003. ? this.$math.format(value / row.measureQuantity, 14)
  2004. : 0
  2005. );
  2006. }
  2007. });
  2008. },
  2009. // 物料重量修改
  2010. materialWeightCahnge(row) {
  2011. // 修改包装重量
  2012. let filterMaterialList = this.materialList.filter((item) => {
  2013. return item.parentIndex === row.parentIndex;
  2014. });
  2015. let packingIndex = this.packingList.findIndex((item) => {
  2016. return item.index === row.parentIndex;
  2017. });
  2018. let totalMaterialWeight = filterMaterialList.reduce(
  2019. (accumulator, currentValue) => {
  2020. return this.$math.format(+accumulator + +currentValue.weight, 14);
  2021. },
  2022. 0
  2023. );
  2024. this.$set(
  2025. this.packingList[packingIndex],
  2026. 'weight',
  2027. totalMaterialWeight
  2028. );
  2029. // 修改物品重量
  2030. let filterPackingList = this.packingList.filter((item) => {
  2031. return (
  2032. item.parentIndex === this.packingList[packingIndex].parentIndex
  2033. );
  2034. });
  2035. let productIndex = this.productList.findIndex((item) => {
  2036. return item.index === this.packingList[packingIndex].parentIndex;
  2037. });
  2038. let totalWeight = filterPackingList.reduce(
  2039. (accumulator, currentValue) => {
  2040. return this.$math.format(+accumulator + +currentValue.weight, 14);
  2041. },
  2042. 0
  2043. );
  2044. this.$set(this.productList[productIndex], 'weight', totalWeight);
  2045. },
  2046. // 包装质检结果修改
  2047. packingResultCahnge(value, row) {
  2048. // 修改物料质检结果( 1合格 2不合格)
  2049. this.materialList.map((item, index) => {
  2050. if (item.parentIndex === row.index) {
  2051. this.$set(this.materialList[index], 'result', value);
  2052. }
  2053. });
  2054. },
  2055. // 物料质量结果修改
  2056. materialResultCahnge(value, row) {
  2057. // 修改包装质检结果
  2058. let filterMaterialList = this.materialList.filter((item) => {
  2059. return item.parentIndex == row.parentIndex;
  2060. });
  2061. let packingIndex = this.packingList.findIndex((item) => {
  2062. return item.index == row.parentIndex;
  2063. });
  2064. let boolen = filterMaterialList.every((item) => {
  2065. return item.result == 1;
  2066. });
  2067. this.$set(this.packingList[packingIndex], 'result', boolen ? 1 : 2);
  2068. },
  2069. // 重量限制
  2070. weightInput(value, row, type) {
  2071. console.log(row, 'rowrowrowrowrowrowrowrowrowrowrowrow222');
  2072. const newValue = value.replace(/[^\d.]/g, ''); // 保留数字和小数点
  2073. const decimalCount = (newValue.match(/\./g) || []).length; // 计算小数点的个数
  2074. if (row.weight < 0) {
  2075. row.weight = 0;
  2076. } else if (row.weight > 9999) {
  2077. row.weight = 9999;
  2078. } else {
  2079. if (decimalCount > 1) {
  2080. // 如果小数点个数大于1,移除多余的小数点
  2081. const lastIndex = newValue.lastIndexOf('.');
  2082. row.weight =
  2083. newValue.slice(0, lastIndex) + newValue.slice(lastIndex + 1);
  2084. } else if (decimalCount === 1) {
  2085. // 如果小数点个数等于1,允许小数点的输入
  2086. row.weight = newValue;
  2087. } else {
  2088. row.weight = newValue === '' ? 0 : parseFloat(newValue); // 如果输入为空,则设为0
  2089. }
  2090. }
  2091. if (type === '包装') {
  2092. this.packingWeightCahnge(value, row);
  2093. } else {
  2094. this.materialWeightCahnge(row);
  2095. }
  2096. },
  2097. //计算金额
  2098. calcSumTotal(measureQuantity, price, row) {
  2099. //最小包装单元,包装数量,单价
  2100. const total = {
  2101. measureQuantity: Number(measureQuantity > 0 ? measureQuantity : 0),
  2102. price: Number(price > 0 ? price : 0)
  2103. };
  2104. let number = Number(
  2105. this.$math.format(total.measureQuantity * total.price, 14)
  2106. );
  2107. row.totalMoney = number;
  2108. return number;
  2109. },
  2110. // 包装维度最小包装单元改变——>总重量
  2111. minPackingQuantityChange(row, value, index) {
  2112. console.log(value);
  2113. if (row.measureUnit !== 'KG') {
  2114. if (value.replace(/^(0+)|[^\d]+/g, '') > 9999) {
  2115. this.$set(this.productList[index], 'minPackingQuantity', 9999);
  2116. } else {
  2117. this.$set(
  2118. this.productList[index],
  2119. 'minPackingQuantity',
  2120. value.replace(/^(0+)|[^\d]+/g, '')
  2121. );
  2122. }
  2123. } else {
  2124. if (value < 1) {
  2125. this.$set(this.productList[index], 'minPackingQuantity', 1);
  2126. } else if (value > 9999) {
  2127. this.$set(this.productList[index], 'minPackingQuantity', 9999);
  2128. }
  2129. }
  2130. if (row.packingQuantity >= 0 && value >= 0) {
  2131. this.packNum(row, row.packingQuantity, index);
  2132. }
  2133. },
  2134. // 包装数量过滤处理改变——>总重量
  2135. packNum(row, value, index) {
  2136. const total = {
  2137. minPackingQuantity: Number(
  2138. row.minPackingQuantity > 0
  2139. ? row.minPackingQuantity > 9999
  2140. ? 9999
  2141. : row.minPackingQuantity
  2142. : 0
  2143. ),
  2144. packingQuantity: Number(
  2145. row.packingQuantity > 0
  2146. ? row.packingQuantity > 9999
  2147. ? 9999
  2148. : row.packingQuantity
  2149. : 0
  2150. )
  2151. };
  2152. const totals = Number(
  2153. this.$math.format(
  2154. total.minPackingQuantity * total.packingQuantity,
  2155. 14
  2156. )
  2157. );
  2158. if (row.measureUnit == row.weightUnit) {
  2159. row.weight = Number(
  2160. this.$math.format(
  2161. total.minPackingQuantity *
  2162. 1 *
  2163. Number(total.packingQuantity).toFixed(2),
  2164. 14
  2165. )
  2166. );
  2167. } else {
  2168. row.weight = Number(
  2169. this.$math.format(
  2170. totals *
  2171. (row.netWeight > 0 ? Number(row.netWeight).toFixed(2) : 0),
  2172. 14
  2173. )
  2174. );
  2175. }
  2176. this.$set(this.productList[index], 'measureQuantity', totals);
  2177. // 清空仓库
  2178. this.$set(this.productList[index], 'warehouseId', '');
  2179. this.$set(this.productList[index], 'warehouseName', '');
  2180. if (value.replace(/^(0+)|[^\d]+/g, '') > 9999) {
  2181. this.$set(this.productList[index], 'packingQuantity', 9999);
  2182. } else {
  2183. this.$set(
  2184. this.productList[index],
  2185. 'packingQuantity',
  2186. value.replace(/^(0+)|[^\d]+/g, '')
  2187. );
  2188. }
  2189. // return (row.packingQuantity = value.replace(/^(0+)|[^\d]+/g, ''));
  2190. },
  2191. // 表格样式
  2192. rowClass({ row, column, rowIndex, columnIndex }) {
  2193. if (rowIndex === 1) {
  2194. return {
  2195. display: 'none',
  2196. background: '#EEEEEE'
  2197. };
  2198. }
  2199. return { background: '#0000' };
  2200. },
  2201. // 添加物品明细
  2202. async addGoods(data) {
  2203. this.proData = data;
  2204. // 获取批次号
  2205. const batchNo = await getCode('lot_number_code');
  2206. // 获取供应商
  2207. const supplierList = await storageApi.contactQueryByCategoryIdsAPI({
  2208. categoryIds: data.map((item) => item.id)
  2209. });
  2210. console.log(supplierList, '供应商列表');
  2211. // 获取包装规格
  2212. let packingSpecification =
  2213. await storageApi.getCategoryPackageDisposition({
  2214. categoryIds: data.map((item) => item.id)
  2215. });
  2216. this.packingSpecificationOption = data.map((item) => {
  2217. return packingSpecification
  2218. .filter((ite) => item.id == ite.categoryId)
  2219. .sort((a, b) => a.sort - b.sort);
  2220. });
  2221. console.log('yeyyeyey----------------', data);
  2222. let productList = data.map((item, index) => {
  2223. // 显示规格
  2224. let packingSpecificationLabel = this.packingSpecificationOption[index]
  2225. .map((item) => {
  2226. if (item.sort > 0) {
  2227. return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
  2228. }
  2229. })
  2230. .filter((item) => !!item);
  2231. return {
  2232. index:
  2233. this.productList.length - 1 > -1
  2234. ? this.productList[this.productList.length - 1].index +
  2235. index +
  2236. 1
  2237. : this.productList.length + index,
  2238. categoryId: item.id, // 物品id
  2239. categoryName: item.name, // 物品名称
  2240. categoryCode: item.code, // 物品编码
  2241. categoryModel: item.modelType, // 物品型号
  2242. specification: item.specification, // 规格
  2243. brandNum: item.brandNum, // 牌号
  2244. batchNo: batchNo, // 批次号
  2245. supplierListOptions: supplierList[item.id], // 供应商列表
  2246. supplierId: '', // 供应商id
  2247. supplierName: '', // 供应商名称
  2248. supplierCode: '',
  2249. approvalNumber: item.approvalNumber, // 批准文号
  2250. packingSpecification: item.packingSpecification, // 包装规格
  2251. packingSpecificationOption: this.packingSpecificationOption[index], // 包装规格选项
  2252. packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
  2253. minPackingQuantity: '', // 最小包装单元数量
  2254. packingQuantity: '', // 包装数量
  2255. packingUnit: '', // 单位
  2256. measureQuantity: 0, // 计量数量
  2257. measureUnit: item.measuringUnit, // 计量单位
  2258. netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
  2259. weight: 0, // 重量
  2260. singleWeight: item.measuringUnit != 'KG' ? item.netWeight : 0, //单重 进来获取净重
  2261. weightUnit: item.weightUnit, // 重量单位
  2262. totalMoney: '', // 总价
  2263. price: item.price, // 单价
  2264. purpose: '', // 用途
  2265. isUnpack: item.isUnpack, // 是否允许拆包
  2266. categoryLevelPathIdParent: item.categoryLevelPathIdParent
  2267. };
  2268. });
  2269. this.productList = this.productList.concat(productList);
  2270. console.log('this.productList--------', this.productList);
  2271. },
  2272. // 物品保存验证表单(批量)
  2273. validateForm() {
  2274. return new Promise(async (resolve, reject) => {
  2275. let list = this.productList.map(async (row, index) => {
  2276. let fileds = [
  2277. `productList.${index}.batchNo`,
  2278. `productList.${index}.packingQuantity`,
  2279. `productList.${index}.packingUnit`,
  2280. `productList.${index}.warehouseId`
  2281. ];
  2282. console.log(fileds);
  2283. if (row.isSave) {
  2284. return Promise.resolve(true);
  2285. } else {
  2286. return await Promise.all(
  2287. fileds.map(
  2288. (item) =>
  2289. new Promise(async (res, rej) => {
  2290. this.$refs.productListRef.validateField(item, (err) => {
  2291. if (err) {
  2292. rej(err);
  2293. } else {
  2294. res(true);
  2295. }
  2296. });
  2297. })
  2298. )
  2299. );
  2300. }
  2301. });
  2302. console.log(list);
  2303. Promise.all(list)
  2304. .then(() => {
  2305. console.log('保存成功!');
  2306. resolve();
  2307. })
  2308. .catch((err) => {
  2309. console.log('保存失败!');
  2310. this.$message.error('请填入必填项!');
  2311. reject(err);
  2312. });
  2313. });
  2314. },
  2315. // 产品批量保存
  2316. async listSaveArrs() {
  2317. this.validateForm()
  2318. .then(async () => {
  2319. // 批量获取包装编码并处理
  2320. let packingCodePrams = this.productList.map((row) => {
  2321. // 判断单位和计量单位是否为不拆物料层规格
  2322. let packingBoolen = !!this.getDict(
  2323. '不拆物料层规格',
  2324. row.packingUnit
  2325. ).dictValue;
  2326. let measureBoolen = !!this.getDict(
  2327. '不拆物料层规格',
  2328. row.measureUnit
  2329. ).dictValue;
  2330. let num = 0;
  2331. if (packingBoolen) {
  2332. let filterArr = row.packingSpecificationOption.filter(
  2333. (item) => {
  2334. return (
  2335. item.packageUnit == row.packingUnit &&
  2336. item.packageUnit != item.conversionUnit
  2337. );
  2338. }
  2339. );
  2340. num = Math.ceil(row.packingQuantity / filterArr[0].packageCell);
  2341. }
  2342. if (row.isSave) {
  2343. return {};
  2344. } else {
  2345. // 处理单位为KG类的情况
  2346. if (packingBoolen) {
  2347. return {
  2348. assetCode: row.categoryCode + row.index,
  2349. batchNum: row.batchNo,
  2350. num
  2351. };
  2352. } else {
  2353. if (row.isUnpack) {
  2354. if (measureBoolen) {
  2355. // 处理单位不为KG类,计量单位为KG类的情况
  2356. let num = row.packingQuantity;
  2357. let splitIndex = row.packingSpecificationOption.findIndex(
  2358. (item) =>
  2359. item.conversionUnit == row.packingUnit &&
  2360. item.packageUnit != item.conversionUnit
  2361. );
  2362. for (; splitIndex > 1; splitIndex--) {
  2363. num = this.$math.format(
  2364. num *
  2365. row.packingSpecificationOption[splitIndex]
  2366. .packageCell,
  2367. 14
  2368. );
  2369. }
  2370. return {
  2371. assetCode: row.categoryCode + row.index,
  2372. batchNum: row.batchNo,
  2373. num
  2374. };
  2375. } else {
  2376. // 处理拆包到最小包装单元数量的情况
  2377. return {
  2378. assetCode: row.categoryCode + row.index,
  2379. batchNum: row.batchNo,
  2380. num: row.measureQuantity
  2381. };
  2382. }
  2383. } else {
  2384. return {
  2385. assetCode: row.categoryCode + row.index,
  2386. batchNum: row.batchNo,
  2387. num: row.packingQuantity
  2388. };
  2389. }
  2390. }
  2391. }
  2392. });
  2393. let filterPackingCodePrams = packingCodePrams.filter(
  2394. (item) => item.assetCode
  2395. );
  2396. let { data } = await storageApi.getAssetNum(filterPackingCodePrams);
  2397. console.log('data-----11111111111111111---', data);
  2398. let packingCodeList = [];
  2399. packingCodePrams.forEach((item, index) => {
  2400. packingCodeList[index] = data.filter(
  2401. (ite) => ite.assetCode == item.assetCode
  2402. );
  2403. });
  2404. // 批量生成包装
  2405. this.productList.map((row, index) => {
  2406. if (!row.isSave) {
  2407. this.generateWrappers(row, index, packingCodeList[index]);
  2408. this.$set(this.productList[index], 'isSave', true);
  2409. this.$set(
  2410. this.productList[index],
  2411. 'warehouseId',
  2412. row.warehouseId
  2413. );
  2414. this.$set(
  2415. this.productList[index],
  2416. 'warehouseName',
  2417. row.warehouseName
  2418. );
  2419. this.$set(
  2420. this.productList[index],
  2421. 'warehouseIds',
  2422. row.warehouseId
  2423. );
  2424. this.$set(
  2425. this.productList[index],
  2426. 'warehouseNames',
  2427. row.warehouseName
  2428. );
  2429. }
  2430. });
  2431. // 加载虚拟列表数据(分页)
  2432. // this.pickingFetchData();
  2433. // this.materielFetchData();
  2434. })
  2435. .catch((err) => {
  2436. console.log(err);
  2437. });
  2438. },
  2439. // 物品保存验证表单(单独)
  2440. validateFormIndividually(index) {
  2441. return new Promise(async (resolve) => {
  2442. console.log(index);
  2443. let fileds = [
  2444. `productList.${index}.batchNo`,
  2445. `productList.${index}.packingQuantity`,
  2446. `productList.${index}.packingUnit`,
  2447. `productList.${index}.warehouseId`
  2448. ];
  2449. Promise.all(
  2450. fileds.map(
  2451. (item) =>
  2452. new Promise(async (res, rej) => {
  2453. this.$refs.productListRef.validateField(item, (err) => {
  2454. if (err) {
  2455. rej(err);
  2456. } else {
  2457. res(true);
  2458. }
  2459. });
  2460. })
  2461. )
  2462. )
  2463. .then(() => {
  2464. resolve();
  2465. })
  2466. .catch(() => {
  2467. this.$message.error('请填入必填项!');
  2468. });
  2469. });
  2470. },
  2471. // 产品编辑
  2472. listEdit(row) {
  2473. console.log(row);
  2474. this.$set(row, 'isSave', false);
  2475. // // 重新计算重量
  2476. // const totals = Number(
  2477. // this.$math.format(row.minPackingQuantity * row.packingQuantity, 14)
  2478. // );
  2479. // if (row.measureUnit == row.weightUnit) {
  2480. // row.weight = Number(
  2481. // this.$math.format(
  2482. // row.minPackingQuantity *
  2483. // 1 *
  2484. // Number(row.packingQuantity).toFixed(2),
  2485. // 14
  2486. // )
  2487. // );
  2488. // } else {
  2489. // row.weight = Number(
  2490. // this.$math.format(
  2491. // totals *
  2492. // (row.netWeight > 0 ? Number(row.netWeight).toFixed(2) : 0),
  2493. // 14
  2494. // )
  2495. // );
  2496. // }
  2497. console.log(row);
  2498. this.deletePackingAndMaterial(row);
  2499. },
  2500. // 根据产品信息删除包装和物料
  2501. deletePackingAndMaterial(row) {
  2502. console.log('row--------', row);
  2503. console.log('packingList------', this.packingList);
  2504. // 删除包装(去掉不相同的包装)
  2505. this.packingList = this.packingList.filter(
  2506. (item) => item.parentIndex !== row.index
  2507. );
  2508. this.showPackingList = this.showPackingList.filter(
  2509. (item) => item.parentIndex !== row.index
  2510. );
  2511. this.pickingPageNum = Math.ceil(
  2512. this.showPackingList.length / this.pageSize
  2513. );
  2514. console.log('包装当前页数');
  2515. console.log(this.pickingPageNum);
  2516. // 删除物料(获取相同物料)
  2517. let packingIndexs = this.packingList.map((item) => item.index);
  2518. this.materialList = this.materialList.filter((item) =>
  2519. packingIndexs.includes(item.parentIndex)
  2520. );
  2521. this.showMaterialList = this.showMaterialList.filter((item) =>
  2522. packingIndexs.includes(item.parentIndex)
  2523. );
  2524. this.materielPageNum = Math.ceil(
  2525. this.showMaterialList.length / this.pageSize
  2526. );
  2527. console.log('物料当前页数');
  2528. console.log(this.showMaterialList.length);
  2529. console.log(this.pageSize);
  2530. console.log(this.materielPageNum);
  2531. },
  2532. // 产品保存操作
  2533. listSave(row, index) {
  2534. this.validateFormIndividually(index).then(async () => {
  2535. // 判断单位和计量单位是否为不拆物料层规格
  2536. let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
  2537. .dictValue;
  2538. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
  2539. .dictValue;
  2540. let packingNum = 0;
  2541. // 处理单位为KG类的情况
  2542. if (packingBoolen) {
  2543. let filterArr = row.packingSpecificationOption.filter((item) => {
  2544. return (
  2545. item.packageUnit == row.packingUnit &&
  2546. item.packageUnit != item.conversionUnit
  2547. );
  2548. });
  2549. packingNum = Math.ceil(
  2550. row.packingQuantity / filterArr[0].packageCell
  2551. );
  2552. }
  2553. // 处理单位不为KG类,计量单位为KG类的情况
  2554. let measureNum = row.packingQuantity;
  2555. if (measureBoolen) {
  2556. let splitIndex = row.packingSpecificationOption.findIndex(
  2557. (item) =>
  2558. item.conversionUnit == row.packingUnit &&
  2559. item.packageUnit != item.conversionUnit
  2560. );
  2561. for (; splitIndex > 1; splitIndex--) {
  2562. measureNum = this.$math.format(
  2563. measureNum *
  2564. row.packingSpecificationOption[splitIndex].packageCell,
  2565. 14
  2566. );
  2567. }
  2568. }
  2569. // 获取包装编码列表
  2570. const { data } = await storageApi.getAssetNum([
  2571. {
  2572. assetCode: row.categoryCode + row.index,
  2573. batchNum: row.batchNo,
  2574. num: packingBoolen
  2575. ? packingNum
  2576. : row.isUnpack
  2577. ? measureBoolen
  2578. ? measureNum
  2579. : row.measureQuantity
  2580. : row.packingQuantity
  2581. }
  2582. ]);
  2583. this.generateWrappers(row, index, data);
  2584. this.$set(this.productList[index], 'isSave', true);
  2585. this.$set(this.productList[index], 'warehouseId', row.warehouseId);
  2586. this.$set(
  2587. this.productList[index],
  2588. 'warehouseName',
  2589. row.warehouseName
  2590. );
  2591. this.$set(this.productList[index], 'warehouseIds', row.warehouseId);
  2592. this.$set(
  2593. this.productList[index],
  2594. 'warehouseNames',
  2595. row.warehouseName
  2596. );
  2597. // 加载虚拟列表数据(分页)
  2598. // this.pickingFetchData();
  2599. // this.materielFetchData();
  2600. });
  2601. },
  2602. //入库明细删除
  2603. listDel(row, index) {
  2604. this.productList.splice(index, 1);
  2605. this.deletePackingAndMaterial(row);
  2606. },
  2607. // 打开仓库弹框
  2608. handleWareHouse(row, idx) {
  2609. if (row.isSave) {
  2610. return false;
  2611. }
  2612. let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
  2613. .dictValue;
  2614. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
  2615. .dictValue;
  2616. if (idx > -1) {
  2617. if (row.packingQuantity > 0) {
  2618. if (packingBoolen) {
  2619. let filterArr = row.packingSpecificationOption.filter((item) => {
  2620. return (
  2621. item.packageUnit == row.packingUnit &&
  2622. item.packageUnit != item.conversionUnit
  2623. );
  2624. });
  2625. console.log(filterArr);
  2626. let num = Math.ceil(
  2627. row.packingQuantity / filterArr[0].packageCell
  2628. );
  2629. this.$refs.wareHouseDailogRef.open(
  2630. num,
  2631. idx,
  2632. row.warehouseId,
  2633. row.warehouseName + ''
  2634. );
  2635. } else {
  2636. let num = row.packingQuantity;
  2637. if (measureBoolen) {
  2638. let splitIndex = row.packingSpecificationOption.findIndex(
  2639. (item) =>
  2640. item.conversionUnit == row.packingUnit &&
  2641. item.packageUnit != item.conversionUnit
  2642. );
  2643. console.log(splitIndex);
  2644. for (; splitIndex > 1; splitIndex--) {
  2645. console.log(splitIndex);
  2646. num = this.$math.format(
  2647. num *
  2648. row.packingSpecificationOption[splitIndex].packageCell,
  2649. 14
  2650. );
  2651. }
  2652. }
  2653. this.$refs.wareHouseDailogRef.open(
  2654. row.isUnpack
  2655. ? measureBoolen
  2656. ? num
  2657. : row.measureQuantity
  2658. : row.packingQuantity,
  2659. idx,
  2660. row.warehouseId,
  2661. row.warehouseName + ''
  2662. );
  2663. }
  2664. } else {
  2665. this.$message.error('请先填写包装数量!');
  2666. }
  2667. } else {
  2668. // 批量设置
  2669. let boolen = this.productList.every(
  2670. (item) =>
  2671. item.packingQuantity == this.productList[0].packingQuantity
  2672. );
  2673. if (boolen) {
  2674. if (row.packingQuantity > 0) {
  2675. if (packingBoolen) {
  2676. let filterArr = row.packingSpecificationOption.filter(
  2677. (item) => {
  2678. return (
  2679. item.packingUnit == row.packingUnit &&
  2680. item.packingUnit != item.conversionUnit
  2681. );
  2682. }
  2683. );
  2684. let num = Math.ceil(
  2685. row.packingQuantity / filterArr[0].packageCell
  2686. );
  2687. this.$refs.wareHouseDailogRef.open(num, idx);
  2688. } else {
  2689. this.$refs.wareHouseDailogRef.open(
  2690. row.isUnpack
  2691. ? measureBoolen
  2692. ? row.packingQuantity
  2693. : row.measureQuantity
  2694. : row.packingQuantity,
  2695. idx
  2696. );
  2697. }
  2698. } else {
  2699. this.$message.error('请先填写包装数量!');
  2700. }
  2701. } else {
  2702. this.$message.error('请保证产品包装数量一致!');
  2703. }
  2704. }
  2705. },
  2706. wareHouseSelection(argum, idx) {
  2707. // 方便包装遍历获取仓库id和名称
  2708. let warehouseIds = [];
  2709. let warehouseNames = [];
  2710. argum.forEach((item) => {
  2711. for (let index = 0; index < item.packingQuantity; index++) {
  2712. warehouseIds.push(item.warehouseId);
  2713. warehouseNames.push(item.warehouseName);
  2714. }
  2715. });
  2716. console.log(argum, 'argumargumargumargumargumargum');
  2717. if (idx > -1) {
  2718. this.$set(
  2719. this.productList[idx],
  2720. 'warehouseId',
  2721. argum.map((item) => item.warehouseId).join(',')
  2722. );
  2723. this.$set(
  2724. this.productList[idx],
  2725. 'warehouseName',
  2726. argum.map((item) => item.warehouseName).join(',')
  2727. );
  2728. this.$set(this.productList[idx], 'warehouseIds', warehouseIds);
  2729. this.$set(this.productList[idx], 'warehouseNames', warehouseNames);
  2730. } else {
  2731. this.productList.map((item, index) => {
  2732. this.$set(
  2733. this.productList[index],
  2734. 'warehouseId',
  2735. argum.map((item) => item.warehouseId).join(',')
  2736. );
  2737. this.$set(
  2738. this.productList[index],
  2739. 'warehouseName',
  2740. argum.map((item) => item.warehouseName).join(',')
  2741. );
  2742. this.$set(this.productList[index], 'warehouseIds', warehouseIds);
  2743. this.$set(
  2744. this.productList[index],
  2745. 'warehouseNames',
  2746. warehouseNames
  2747. );
  2748. });
  2749. }
  2750. this.$forceUpdate();
  2751. },
  2752. // 生成包装
  2753. generateWrappers(row, productIndex, packingCodeList) {
  2754. console.log('包装数据--------', row);
  2755. // console.log('是否拆包----', row.isUnpack);
  2756. // console.log('包装规格----', row.packingSpecificationOption);
  2757. console.log('计量单位----', row.measureUnit);
  2758. console.log('包装编码----', packingCodeList);
  2759. let packingList = [];
  2760. let obj = this.getNowDate();
  2761. let productionDate = '';
  2762. let purchaseDate = '';
  2763. if (this.formData.bizType == '1') {
  2764. // 生产入库
  2765. productionDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  2766. this.curDateType = 'productionDate';
  2767. } else if (this.formData.bizType == '2') {
  2768. // 采购入库
  2769. purchaseDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
  2770. this.curDateType = 'purchaseDate';
  2771. }
  2772. // 判断单位和计量单位是否为不拆物料层规格
  2773. let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
  2774. .dictValue;
  2775. let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
  2776. .dictValue;
  2777. let num = row.packingQuantity;
  2778. let filterArr = [];
  2779. // 处理单位为KG类的情况
  2780. if (packingBoolen) {
  2781. filterArr = row.packingSpecificationOption.filter((item) => {
  2782. return (
  2783. item.packageUnit == row.packingUnit &&
  2784. item.packageUnit != item.conversionUnit
  2785. );
  2786. });
  2787. num = Math.ceil(row.packingQuantity / filterArr[0].packageCell);
  2788. } else {
  2789. if (row.isUnpack) {
  2790. if (measureBoolen) {
  2791. // 处理单位不为KG类,计量单位为KG类的情况
  2792. let splitIndex = row.packingSpecificationOption.findIndex(
  2793. (item) =>
  2794. item.conversionUnit == row.packingUnit &&
  2795. item.packageUnit != item.conversionUnit
  2796. );
  2797. for (; splitIndex > 1; splitIndex--) {
  2798. num = this.$math.format(
  2799. num * row.packingSpecificationOption[splitIndex].packageCell,
  2800. 14
  2801. );
  2802. }
  2803. } else {
  2804. console.log(row.packingSpecificationOption);
  2805. let splitIndex = row.packingSpecificationOption.findIndex(
  2806. (item) =>
  2807. item.conversionUnit == row.packingUnit &&
  2808. item.packageUnit != item.conversionUnit
  2809. );
  2810. console.log(splitIndex);
  2811. for (; splitIndex > 0; splitIndex--) {
  2812. console.log(splitIndex);
  2813. num = this.$math.format(
  2814. num * row.packingSpecificationOption[splitIndex].packageCell,
  2815. 14
  2816. );
  2817. }
  2818. }
  2819. } else {
  2820. num = row.packingQuantity;
  2821. }
  2822. }
  2823. console.log('num-----------', num);
  2824. for (let index = 0; index < num; index++) {
  2825. let measureQuantity = 1;
  2826. // 处理单位为KG类,计算每桶KG值
  2827. if (packingBoolen) {
  2828. measureQuantity =
  2829. Number(row.packingQuantity) >
  2830. this.$math.format(filterArr[0].packageCell * (index + 1), 14)
  2831. ? filterArr[0].packageCell
  2832. : Number(row.packingQuantity) -
  2833. this.$math.format(filterArr[0].packageCell * index, 14);
  2834. } else {
  2835. if (!row.isUnpack) {
  2836. if (measureBoolen) {
  2837. // 处理单位不为KG类,计量单位为KG类的情况
  2838. let splitIndex = row.packingSpecificationOption.findIndex(
  2839. (item) =>
  2840. item.conversionUnit == row.packingUnit &&
  2841. item.packageUnit != item.conversionUnit
  2842. );
  2843. for (; splitIndex > 0; splitIndex--) {
  2844. measureQuantity = this.$math.format(
  2845. measureQuantity *
  2846. row.packingSpecificationOption[splitIndex].packageCell,
  2847. 14
  2848. );
  2849. }
  2850. } else {
  2851. let splitIndex = row.packingSpecificationOption.findIndex(
  2852. (item) =>
  2853. item.conversionUnit == row.packingUnit &&
  2854. item.packageUnit != item.conversionUnit
  2855. );
  2856. for (; splitIndex > 0; splitIndex--) {
  2857. console.log(splitIndex);
  2858. measureQuantity = this.$math.format(
  2859. measureQuantity *
  2860. row.packingSpecificationOption[splitIndex].packageCell,
  2861. 14
  2862. );
  2863. }
  2864. }
  2865. }
  2866. }
  2867. let item = {
  2868. index: row.index + '-' + index, // 包装索引
  2869. warehouseId: row.warehouseIds
  2870. ? row.warehouseIds[index]
  2871. : row.warehouseIds, // 仓库id
  2872. warehouseName: row.warehouseNames
  2873. ? row.warehouseNames[index]
  2874. : row.warehouseNames, // 仓库名称
  2875. categoryName: row.categoryName, // 产品名称
  2876. categoryCode: row.categoryCode, // 产品编码
  2877. categoryModel: row.categoryModel, // 物品型号
  2878. specification: row.specification, // 规格
  2879. supplierCode: row.supplierCode, // 供应商编码
  2880. brandNum: row.brandNum, // 牌号
  2881. parentIndex: row.index, // 产品索引
  2882. batchNo: row.batchNo, // 批次号
  2883. packageNo: packingCodeList[index].onlyCode, // 包装编码
  2884. packingQuantity: 1, // 包装数量
  2885. packingUnit: row.isUnpack
  2886. ? packingBoolen
  2887. ? filterArr[0].conversionUnit
  2888. : measureBoolen
  2889. ? row.packingSpecificationOption[1]
  2890. ? row.packingSpecificationOption[1].conversionUnit
  2891. : row.packingSpecificationOption[0].conversionUnit
  2892. : row.measureUnit
  2893. : packingBoolen
  2894. ? filterArr[0].conversionUnit
  2895. : row.packingUnit,
  2896. measureQuantity: row.isUnpack
  2897. ? packingBoolen
  2898. ? measureQuantity
  2899. : measureBoolen
  2900. ? row.packingSpecificationOption[1]
  2901. ? row.packingSpecificationOption[1].packageCell
  2902. : row.packingSpecificationOption[0].packageCell
  2903. : measureQuantity
  2904. : measureQuantity, // 计量数量
  2905. measureUnit: row.isUnpack
  2906. ? measureBoolen
  2907. ? row.packingSpecificationOption[1]
  2908. ? row.packingSpecificationOption[1].packageUnit
  2909. : row.packingSpecificationOption[0].packageUnit
  2910. : row.measureUnit
  2911. : row.measureUnit, // 计量单位
  2912. weight: 0, // 重量
  2913. packingSpecificationOption: row.packingSpecificationOption, // 包装规格
  2914. weightUnit: row.weightUnit, // 重量单位
  2915. netWeight: row.netWeight, // 净重
  2916. barcodes: '', // 发货条码
  2917. clientCode: '', // 客户代号
  2918. materielDesignation: '', // 物料代号
  2919. engrave: '', // 刻码
  2920. isUnpack: row.isUnpack, // 是否允许拆包
  2921. productionDate: productionDate, // 生产日期
  2922. purchaseDate: purchaseDate, // 采购时间
  2923. result: 1, // 结果(1合格 2不合格)
  2924. status: 2 // 状态(0=未质检 1待检 2已检)
  2925. };
  2926. let outBoolen = !!this.getDict('不拆物料层规格', item.measureUnit)
  2927. .dictValue;
  2928. if (outBoolen) {
  2929. conosle.log(item.measureQuantity, '计量单位为KG类,包装数量');
  2930. // 计量单位为KG类,直接替换
  2931. item.weight = item.measureQuantity;
  2932. } else {
  2933. console.log('计量单位为不为KG类======================');
  2934. // 计量单位为不为KG类,重新统计计算
  2935. let inBoolen = !!this.getDict(
  2936. '不拆物料层规格',
  2937. item.packingSpecificationOption[0].packageUnit
  2938. ).dictValue;
  2939. let startIndex = item.packingSpecificationOption.findIndex(
  2940. (ite) => {
  2941. return (
  2942. item.measureUnit == ite.packingUnit &&
  2943. ite.packingUnit != ite.conversionUnit
  2944. );
  2945. }
  2946. );
  2947. console.log(startIndex);
  2948. let endIndex = item.packingSpecificationOption.findIndex(
  2949. (ite) => item.packingUnit == ite.conversionUnit
  2950. );
  2951. console.log(endIndex);
  2952. if (measureBoolen) {
  2953. let total = item.packingQuantity;
  2954. for (; startIndex < endIndex; endIndex--) {
  2955. total = this.$math.format(
  2956. item.packingSpecificationOption[endIndex].packageCell * total,
  2957. 14
  2958. );
  2959. }
  2960. if (inBoolen) {
  2961. // 第二层为KG类
  2962. item.weight = total;
  2963. } else {
  2964. // 第二层不为KG类
  2965. item.weight = this.$math.format(total * item.netWeight, 14);
  2966. }
  2967. } else if (!measureBoolen) {
  2968. if (inBoolen) {
  2969. // 第二层为KG类
  2970. item.weight = item.measureQuantity;
  2971. } else {
  2972. // 第二层不为KG类
  2973. item.weight = item.measureQuantity * row.singleWeight;
  2974. }
  2975. }
  2976. }
  2977. packingList.push(item);
  2978. console.log(
  2979. packingList,
  2980. 'packingList!!!!!!!!!!!!!!!!!!'
  2981. );
  2982. }
  2983. // 单独点击保存并插入对应位置(包装)
  2984. if (productIndex == 0) {
  2985. this.packingList.splice(productIndex, 0, ...packingList);
  2986. } else {
  2987. let packingIndex = this.packingList.findLastIndex(
  2988. (item) =>
  2989. item.parentIndex == this.productList[productIndex - 1].index
  2990. );
  2991. this.packingList.splice(packingIndex + 1, 0, ...packingList);
  2992. }
  2993. // 单独点击保存并插入对应位置(物料)
  2994. // let materialList = packingList
  2995. // .map((item) => {
  2996. // if (item.isUnpack) {
  2997. // return this.generateMaterial(item);
  2998. // } else {
  2999. // return [];
  3000. // }
  3001. // })
  3002. // .flat();
  3003. // console.log(materialList);
  3004. // if (materialList.length > 0) {
  3005. // if (productIndex == 0) {
  3006. // this.materialList.splice(0, 0, ...materialList);
  3007. // } else {
  3008. // let preLastPackingIndex = this.packingList.findLastIndex((ite) => {
  3009. // return ite.parentIndex <= productIndex - 1 && ite.isUnpack;
  3010. // });
  3011. // let preLastMaterialIndex = this.materialList.findLastIndex(
  3012. // (ite) => {
  3013. // return (
  3014. // ite.parentIndex == this.packingList[preLastPackingIndex].index
  3015. // );
  3016. // }
  3017. // );
  3018. // this.materialList.splice(
  3019. // preLastMaterialIndex + 1,
  3020. // 0,
  3021. // ...materialList
  3022. // );
  3023. // }
  3024. // }
  3025. },
  3026. // 生成物料
  3027. generateMaterial(row) {
  3028. let materialList = [];
  3029. for (let index = 0; index < row.measureQuantity; index++) {
  3030. materialList.push({
  3031. materialCode: row.packageNo + index.toString().padStart(4, '0'), // 物料编码
  3032. index: row.index + '——' + index, // 包装索引
  3033. warehouseId: row.warehouseId, // 仓库id
  3034. warehouseName: row.warehouseName, // 仓库名称
  3035. categoryName: row.categoryName, // 产品名称
  3036. categoryCode: row.categoryCode, // 产品编码
  3037. parentIndex: row.index, // 产品索引
  3038. batchNo: row.batchNo, // 批次号
  3039. packageNo: row.packageNo, // 包装编码
  3040. measureQuantity: 1, // 计量数量
  3041. measureUnit: row.measureUnit, // 计量单位
  3042. weight: Number(
  3043. this.$math.format(row.weight / row.packingQuantity, 14)
  3044. ), // 重量
  3045. weightUnit: row.weightUnit, // 重量单位
  3046. barcodes: '', // 发货条码
  3047. clientCode: '', // 客户代号
  3048. materielDesignation: '', // 物料代号
  3049. engrave: '', // 刻码
  3050. result: 1, // 结果(1合格 2不合格)
  3051. status: 2 // 状态(0=未质检 1待检 2已检)
  3052. });
  3053. }
  3054. return materialList;
  3055. },
  3056. // 设置时间
  3057. dateSetting() {
  3058. if (!this.packingListSelected.length) {
  3059. return this.$message.error(`请选择${this.title}明细!`);
  3060. }
  3061. this.dateVisible = true;
  3062. },
  3063. // 选择包装列表
  3064. handleSelectionChange(val) {
  3065. this.packingListSelected = val;
  3066. },
  3067. // 选择质检结果改变质检状态
  3068. changeWrapStatus(resultValue, row, type) {
  3069. console.log(resultValue);
  3070. switch (resultValue) {
  3071. case 0:
  3072. // 清空质检状态
  3073. row.status = 0;
  3074. break;
  3075. default:
  3076. // 默认已检质检状态
  3077. row.status = 2;
  3078. break;
  3079. }
  3080. if (type === '包装') {
  3081. this.packingResultCahnge(resultValue, row);
  3082. } else {
  3083. this.materialResultCahnge(resultValue, row);
  3084. }
  3085. }
  3086. }
  3087. };
  3088. </script>
  3089. <style lang="scss" scoped>
  3090. .inbound_details {
  3091. margin-top: 10px;
  3092. .el-form-item {
  3093. margin-bottom: 0 !important;
  3094. }
  3095. }
  3096. .el-form-item {
  3097. margin-bottom: 5px;
  3098. }
  3099. .right_control {
  3100. display: flex;
  3101. > button {
  3102. margin-left: 5px;
  3103. }
  3104. }
  3105. .storage_btn {
  3106. margin-top: 20px;
  3107. display: flex;
  3108. align-content: center;
  3109. justify-content: center;
  3110. }
  3111. .el-date-editor.el-input,
  3112. .el-date-editor.el-input__inner {
  3113. width: 100% !important;
  3114. }
  3115. .red_color {
  3116. color: red;
  3117. }
  3118. .wareHouse_style {
  3119. text-overflow: ellipsis;
  3120. overflow: hidden;
  3121. word-break: break-all;
  3122. white-space: nowrap;
  3123. }
  3124. </style>