storage.vue 153 KB

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