storage.vue 160 KB

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