storage.vue 154 KB

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