storage.vue 150 KB

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