storage.vue 154 KB

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