storage.vue 120 KB

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