storage.vue 151 KB

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