add.vue 127 KB

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