storage.vue 150 KB

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