storage.vue 155 KB

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