storage.vue 126 KB

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