storage.vue 125 KB

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