add.vue 129 KB

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