add.vue 117 KB

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