add.vue 137 KB

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