storage.vue 159 KB

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