storage.vue 119 KB

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