add.vue 115 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <header-title title="基本信息"></header-title>
  5. <el-form
  6. :model="formData"
  7. ref="formName"
  8. label-width="110px"
  9. :rules="rules"
  10. >
  11. <el-row :gutter="20">
  12. <!-- <el-col :span="8">
  13. <el-form-item label="入库单号" prop="bizNum">
  14. <el-input :value="formData.bizNum" disabled /></el-form-item
  15. ></el-col> -->
  16. <!-- <el-col :span="8">
  17. <el-form-item label="仓库" prop="warehouseId">
  18. <el-select
  19. filterable
  20. v-model="formData.warehouseId"
  21. clearable
  22. :disabled="
  23. !!(warehousingMaterialList && warehousingMaterialList.length)
  24. "
  25. >
  26. <el-option
  27. v-for="(item, index) in warehouseList"
  28. :key="index"
  29. :label="item.name"
  30. :value="item.id"
  31. @click.native="warehouse = item"
  32. ></el-option>
  33. </el-select>
  34. </el-form-item>
  35. </el-col> -->
  36. <el-col :span="8">
  37. <el-form-item label="物品类型" prop="extInfo.assetType">
  38. <!-- <DictSelection
  39. dictName="类型用途"
  40. :disabled="
  41. !!(warehousingMaterialList && warehousingMaterialList.length)
  42. "
  43. clearable
  44. v-model="formData.extInfo.assetType"
  45. @itemChange="handleChange"
  46. /> -->
  47. <!-- <el-select
  48. :disabled="
  49. !!(warehousingMaterialList && warehousingMaterialList.length)
  50. "
  51. clearable
  52. v-model="formData.extInfo.assetType"
  53. @change="handleChanges"
  54. >
  55. <el-option
  56. v-for="(item, index) in codeList"
  57. :key="index"
  58. :label="item.dictValue"
  59. :value="item.dictCode"
  60. ></el-option>
  61. </el-select> -->
  62. <selectTree
  63. ref="tree"
  64. class="form-ipt"
  65. size="medium"
  66. style="width: 100%"
  67. clearable
  68. :value="formData.extInfo.assetType"
  69. :options="codeList"
  70. :props="{
  71. value: 'id',
  72. label: 'name',
  73. children: 'children'
  74. }"
  75. @getValue="codeListValue"
  76. :isAll="false"
  77. />
  78. </el-form-item>
  79. </el-col>
  80. <el-col :span="8">
  81. <el-form-item label="入库类型" prop="bizType">
  82. <el-select
  83. @change="onClear"
  84. filterable
  85. placeholder="请选择"
  86. v-model="formData.bizType"
  87. clearable
  88. :disabled="
  89. !!(warehousingMaterialList && warehousingMaterialList.length)
  90. "
  91. >
  92. <el-option
  93. v-for="item in sceneState"
  94. :key="item.code"
  95. :value="item.code + ''"
  96. :label="item.label"
  97. ></el-option>
  98. </el-select> </el-form-item
  99. ></el-col>
  100. <el-col v-if="formData.bizType == 12" :span="8">
  101. <el-form-item label="关联出库单" prop="documentSource">
  102. <el-input
  103. placeholder="请输入"
  104. v-model="stockOutOrders"
  105. @click.native="handleStockOutOrder()"
  106. >
  107. </el-input>
  108. </el-form-item>
  109. </el-col>
  110. <el-col :span="8">
  111. <el-form-item
  112. v-if="formData.bizType == 12"
  113. label="委外申请单"
  114. prop="documentSource"
  115. >
  116. <el-input
  117. placeholder="请输入"
  118. v-model="formData.extInfo.documentSource"
  119. @click.native="handleOutsourcedOrders()"
  120. >
  121. <el-button
  122. slot="append"
  123. icon="el-icon-circle-close"
  124. @click.stop="onClear"
  125. ></el-button>
  126. </el-input>
  127. </el-form-item>
  128. <el-form-item
  129. v-if="formData.bizType == 2"
  130. label="采购收货单"
  131. prop="documentSource"
  132. >
  133. <el-input
  134. placeholder="请输入"
  135. v-model="formData.extInfo.documentSource"
  136. @click.native="handlePicker()"
  137. >
  138. <el-button
  139. slot="append"
  140. icon="el-icon-circle-close"
  141. @click.stop="onClear"
  142. ></el-button>
  143. </el-input>
  144. </el-form-item>
  145. <el-form-item
  146. v-if="formData.bizType == 1"
  147. label="生产工单"
  148. prop="documentSource"
  149. >
  150. <el-input
  151. placeholder="请输入"
  152. clearable
  153. v-model="formData.extInfo.documentSource"
  154. /></el-form-item>
  155. <el-form-item
  156. v-if="formData.bizType == 10"
  157. label="委外订单"
  158. prop="documentSource"
  159. >
  160. <el-input
  161. placeholder="请输入"
  162. clearable
  163. v-model="formData.extInfo.documentSource"
  164. /></el-form-item>
  165. <el-form-item
  166. v-if="
  167. formData.bizType != 1 &&
  168. formData.bizType != 2 &&
  169. formData.bizType != 3 &&
  170. formData.bizType != 10 &&
  171. formData.bizType != 12
  172. "
  173. label="销售订单"
  174. prop="documentSource"
  175. >
  176. <el-input
  177. placeholder="请输入"
  178. clearable
  179. v-model="formData.extInfo.documentSource"
  180. /></el-form-item>
  181. <el-form-item
  182. v-if="formData.bizType == 3"
  183. label="出库单"
  184. prop="documentSource"
  185. >
  186. <el-input
  187. placeholder="请输入"
  188. clearable
  189. v-model="formData.extInfo.documentSource"
  190. /></el-form-item>
  191. </el-col>
  192. <el-col :span="8">
  193. <el-form-item label="权属部门" prop="deptName">
  194. <el-input
  195. placeholder="权属部门"
  196. disabled
  197. v-model="formData.extInfo.deptName"
  198. clearable
  199. />
  200. </el-form-item>
  201. </el-col>
  202. <el-col :span="8">
  203. <el-form-item label="入库登记人">
  204. <el-input
  205. placeholder="登记人"
  206. disabled
  207. v-model="formData.extInfo.createUserName"
  208. clearable /></el-form-item
  209. ></el-col>
  210. <!-- <el-col :span="8">
  211. <el-form-item label="入库时间" prop="outInTime">
  212. <el-date-picker
  213. v-model="formData.outInTime"
  214. clearable
  215. type="datetime"
  216. value-format="yyyy-MM-dd HH:mm:ss"
  217. placeholder="选择日期"
  218. >
  219. </el-date-picker></el-form-item
  220. ></el-col> -->
  221. <el-col :span="8" v-if="formData.bizType == 2">
  222. <el-form-item label="供应商" prop="supplierName">
  223. <!-- <DictSelection
  224. dictName="经销商列表"
  225. clearable
  226. v-model="formData.extInfo.supplierId"
  227. @itemChange="ChangeSupplier"
  228. /> -->
  229. <el-input
  230. placeholder="请输入"
  231. clearable
  232. v-model="formData.extInfo.supplierName"
  233. />
  234. </el-form-item>
  235. </el-col>
  236. <!-- <el-col :span="8" v-if="formData.bizType == 2">
  237. <el-form-item label="物料代号" prop="supplierCode">
  238. <el-input
  239. placeholder="请输入"
  240. v-model="formData.supplierCode"
  241. clearable /></el-form-item
  242. ></el-col> -->
  243. <!-- <el-col :span="8" v-if="formData.bizType == 2">
  244. <el-form-item label="客户" prop="clientName">
  245. <el-input
  246. placeholder="请输入"
  247. clearable
  248. v-model="formData.clientName"
  249. />
  250. </el-form-item>
  251. </el-col> -->
  252. <!-- <el-col :span="8" v-if="formData.bizType == 2">
  253. <el-form-item label="客户代号" prop="clientCode">
  254. <el-input
  255. placeholder="请输入"
  256. v-model="formData.clientCode"
  257. clearable /></el-form-item
  258. ></el-col> -->
  259. <!-- <el-col :span="8">
  260. <el-form-item label="送货人" prop="fromUser">
  261. <el-input
  262. placeholder="请输入"
  263. v-model="formData.fromUser"
  264. clearable /></el-form-item
  265. ></el-col> -->
  266. <el-col :span="8">
  267. <el-form-item label="送货人" prop="fromUser">
  268. <el-input
  269. placeholder="请输入"
  270. v-model="formData.fromUser"
  271. clearable
  272. />
  273. <!-- <el-select
  274. v-model="formData.fromUser"
  275. filterable
  276. placeholder="请选择送货人"
  277. >
  278. <el-option
  279. v-for="item in contactList"
  280. :key="item.id"
  281. :label="item.linkName"
  282. :value="item.id"
  283. @click.native="
  284. () => (formData.extInfo.deliveryPhone = item.mobilePhone)
  285. "
  286. >
  287. </el-option>
  288. </el-select> -->
  289. </el-form-item></el-col
  290. >
  291. <el-col :span="8">
  292. <el-form-item label="送货人联系方式" prop="deliveryPhone">
  293. <el-input
  294. placeholder="请输入"
  295. v-model="formData.extInfo.deliveryPhone"
  296. clearable /></el-form-item
  297. ></el-col>
  298. <!-- <el-col :span="8">
  299. <el-form-item label="紧急状态" prop="urgent">
  300. <el-select
  301. filterable
  302. placeholder="请选择"
  303. v-model="formData.extInfo.urgent"
  304. clearable
  305. >
  306. <el-option
  307. v-for="item in emergencyState"
  308. :key="item.code"
  309. :value="item.code"
  310. :label="item.label"
  311. ></el-option>
  312. </el-select> </el-form-item
  313. ></el-col> -->
  314. <!-- <el-col :span="8">
  315. <el-form-item label="审核人部门" prop="verifyDeptName">
  316. <selectTree
  317. ref="tree"
  318. class="form-ipt"
  319. size="medium"
  320. style="width: 100%"
  321. clearable
  322. :options="treeList"
  323. :props="{
  324. value: 'code',
  325. label: 'name',
  326. children: 'children'
  327. }"
  328. @getValue="auditorDeptClick"
  329. />
  330. </el-form-item>
  331. </el-col>
  332. <el-col :span="8">
  333. <el-form-item label="审核人" prop="verifyId">
  334. <el-select
  335. filterable
  336. class="form-ipt"
  337. style="width: 100%"
  338. v-model="formData.verifyId"
  339. placeholder="请选择"
  340. >
  341. <el-option
  342. v-for="item in staffList"
  343. :key="item.id"
  344. :label="item.name"
  345. :value="item.id"
  346. @click.native="changeVerfy(item)"
  347. >
  348. </el-option>
  349. </el-select>
  350. </el-form-item>
  351. </el-col> -->
  352. <!-- <el-col :span="24">
  353. <el-form-item label="附件" prop="contentImage">
  354. <selectUpload @getImgs="upload" :initData="uploadList" />
  355. </el-form-item>
  356. </el-col> -->
  357. <el-col :span="24">
  358. <el-form-item label="备注" prop="remark">
  359. <el-input
  360. v-model="formData.remark"
  361. clearable
  362. type="textarea"
  363. placeholder="请详细说明"
  364. :rows="4"
  365. ></el-input>
  366. </el-form-item>
  367. </el-col>
  368. </el-row>
  369. </el-form>
  370. <div class="material">
  371. <header-title title="产品信息">
  372. <el-button v-if="!isOutsourcing" type="primary" @click="addStock"
  373. >添加</el-button
  374. >
  375. </header-title>
  376. <div class="mt10 form-table">
  377. <el-form
  378. ref="warehousingMaterialListRef"
  379. :model="{ warehousingMaterialList: warehousingMaterialList }"
  380. :show-message="false"
  381. >
  382. <el-button
  383. v-if="warehousingMaterialList.length != 0"
  384. type="success"
  385. plain
  386. style="margin-bottom: 20px; float: right; margin-right: 20px"
  387. size="mini"
  388. @click="listSaveArrs"
  389. >批量保存</el-button
  390. >
  391. <el-table
  392. v-if="isWeight"
  393. :header-cell-style="rowClass"
  394. :max-height="300"
  395. ref="warehousingMaterialListTable"
  396. :key="formData.extInfo.assetType"
  397. :data="warehousingMaterialList"
  398. tooltip-effect="dark"
  399. style="width: 100%"
  400. stripe
  401. >
  402. <el-table-column
  403. label="序号"
  404. type="index"
  405. width="50"
  406. align="center"
  407. >
  408. </el-table-column>
  409. <el-table-column
  410. label="编码"
  411. prop="assetCode"
  412. align="center"
  413. width="130"
  414. :show-overflow-tooltip="true"
  415. ></el-table-column>
  416. <el-table-column
  417. label="名称"
  418. align="center"
  419. width="200"
  420. prop="assetName"
  421. :show-overflow-tooltip="true"
  422. ></el-table-column>
  423. <!-- <el-table-column
  424. label="客户编码"
  425. align="center"
  426. width="150"
  427. prop="customCode"
  428. v-if="formData.bizType == 1"
  429. >
  430. <template slot-scope="{ row, $index }">
  431. <template v-if="row.isSave">
  432. {{ row.customCode }}
  433. </template>
  434. <el-form-item
  435. v-else
  436. :prop="`warehousingMaterialList.${$index}.customCode`"
  437. required
  438. >
  439. <el-input v-model="row.customCode"> </el-input>
  440. </el-form-item>
  441. </template>
  442. </el-table-column>
  443. <el-table-column
  444. label="供应商编码"
  445. align="center"
  446. width="150"
  447. prop="customCode"
  448. v-if="formData.bizType == 2"
  449. >
  450. <template slot-scope="{ row, $index }">
  451. <template v-if="row.isSave">
  452. {{ row.supplierCode }}
  453. </template>
  454. <el-form-item
  455. v-else
  456. :prop="`warehousingMaterialList.${$index}.supplierCode`"
  457. required
  458. >
  459. <el-input v-model="row.supplierCode"> </el-input>
  460. </el-form-item>
  461. </template>
  462. </el-table-column> -->
  463. <el-table-column
  464. v-for="(item, index) in tableHeader"
  465. :key="index"
  466. align="center"
  467. :label="item.label"
  468. :width="item.width"
  469. :prop="item.prop"
  470. :show-overflow-tooltip="true"
  471. >
  472. <template slot-scope="{ row }">
  473. <template v-if="item.formatter">{{
  474. item.formatter(row)
  475. }}</template>
  476. <template v-else>{{ row[item.prop] }}</template>
  477. </template>
  478. </el-table-column>
  479. <el-table-column label="批号" width="100" prop="manualBatchNo">
  480. <template slot-scope="{ row, $index }">
  481. <template v-if="row.isSave">
  482. {{ row.manualBatchNo }}
  483. </template>
  484. <el-form-item v-else>
  485. <el-input
  486. :ref="'manualBatchNo' + $index"
  487. @keyup.native="
  488. moveFocus($event, $index, 'manualBatchNo', '产品', row)
  489. "
  490. v-model="row.manualBatchNo"
  491. >
  492. </el-input>
  493. </el-form-item>
  494. </template>
  495. </el-table-column>
  496. <el-table-column
  497. v-if="clientEnvironmentId != 2"
  498. label="批次号"
  499. prop="batchNo"
  500. width="70"
  501. align="center"
  502. >
  503. <template slot-scope="{ row, $index }">
  504. <template v-if="row.isSave">
  505. {{ row.batchNo }}
  506. </template>
  507. <el-form-item
  508. v-else
  509. :prop="`warehousingMaterialList.${$index}.batchNo`"
  510. required
  511. >
  512. <!-- <el-input v-model="row.batchNo"></el-input> -->
  513. {{ row.batchNo }}
  514. </el-form-item>
  515. </template>
  516. </el-table-column>
  517. <el-table-column
  518. label="最小包装单元"
  519. align="center"
  520. prop="minPackingCount"
  521. width="100"
  522. >
  523. <el-table-column label="" prop="minPackingCount" width="100">
  524. <template slot-scope="{ row, $index }">
  525. <template v-if="row.isSave">
  526. {{ row.minPackingCount }}
  527. </template>
  528. <el-form-item
  529. v-else
  530. :prop="`warehousingMaterialList.${$index}.minPackingCount`"
  531. required
  532. >
  533. <el-input
  534. :ref="'minPackingCount' + $index"
  535. @keyup.native="
  536. moveFocus(
  537. $event,
  538. $index,
  539. 'minPackingCount',
  540. '产品',
  541. row
  542. )
  543. "
  544. type="number"
  545. v-model="row.minPackingCount"
  546. @input="minPackingCountChange(row, $event)"
  547. >
  548. </el-input>
  549. </el-form-item>
  550. </template>
  551. </el-table-column>
  552. <el-table-column label="" prop="minPackingCount">
  553. <template slot-scope="{ row, $index }">
  554. {{ handleRowUnit(row) }} /{{ row.minPackUnit }}
  555. </template>
  556. </el-table-column>
  557. </el-table-column>
  558. <el-table-column
  559. label="包装数量"
  560. prop="outInNum"
  561. width="150"
  562. align="center"
  563. >
  564. <template slot-scope="{ row, $index }">
  565. <template v-if="row.isSave || formData.bizType == 5">
  566. {{ row.outInNum }} {{ row.minPackUnit }}
  567. </template>
  568. <el-form-item
  569. v-else
  570. :prop="`warehousingMaterialList.${$index}.outInNum`"
  571. required
  572. >
  573. <el-input
  574. :ref="'outInNum' + $index"
  575. @keyup.native="
  576. moveFocus($event, $index, 'outInNum', '产品', row)
  577. "
  578. v-model="row.outInNum"
  579. @input="packNum(row, $event)"
  580. >
  581. <template slot="append">
  582. {{ row.minPackUnit ? row.minPackUnit : '/' }}
  583. </template>
  584. </el-input>
  585. </el-form-item>
  586. </template>
  587. </el-table-column>
  588. <el-table-column label="计量数量" prop="counts">
  589. <template slot-scope="{ row, $index }">
  590. {{ $math.format(row.minPackingCount * row.outInNum, 14) }}
  591. </template>
  592. </el-table-column>
  593. <el-table-column
  594. label="计量单位"
  595. prop="batchNo"
  596. width="100"
  597. align="center"
  598. >
  599. <!-- v-if="formData.extInfo.assetType == 1" -->
  600. <template slot-scope="{ row, $index }">
  601. <template>
  602. {{ row.measuringUnit }}
  603. </template>
  604. </template>
  605. </el-table-column>
  606. <!-- <el-table-column
  607. label="计量单位"
  608. prop="batchNo"
  609. width="100"
  610. align="center"
  611. v-if="formData.extInfo.assetType == 4"
  612. >
  613. <template slot-scope="{ row, $index }">
  614. <template>
  615. {{ row.measuringUnit }}
  616. </template>
  617. </template>
  618. </el-table-column> -->
  619. <!-- <el-table-column
  620. label="数量"
  621. prop="batchNo"
  622. width="150"
  623. align="center"
  624. v-if="formData.extInfo.assetType == 1"
  625. >
  626. <template slot-scope="{ row, $index }">
  627. <template> {{ row.outInNum }} </template>
  628. </template>
  629. </el-table-column>
  630. <el-table-column
  631. label="数量"
  632. prop="batchNo"
  633. width="150"
  634. align="center"
  635. v-if="formData.extInfo.assetType == 4"
  636. >
  637. <template slot-scope="{ row, $index }">
  638. <template>
  639. {{ row.minPackingCount * row.outInNum }}
  640. </template>
  641. </template>
  642. </el-table-column> -->
  643. <el-table-column
  644. label="重量"
  645. align="center"
  646. prop="contentImage"
  647. :show-overflow-tooltip="true"
  648. >
  649. <!-- v-if="formData.extInfo.assetType == 1" -->
  650. <template slot-scope="{ row, $index }">
  651. {{ row.weight }}
  652. <template slot="append">
  653. {{ handleRowUnit(row) }}
  654. <!-- {{
  655. { yuan: '元', wanyuan: '万元' }[row.univalenceUnit]
  656. }} -->
  657. </template>
  658. </template>
  659. </el-table-column>
  660. <!-- <el-table-column
  661. label="重量"
  662. align="center"
  663. prop="contentImage"
  664. :show-overflow-tooltip="true"
  665. v-if="formData.extInfo.assetType == 4"
  666. >
  667. <template slot-scope="{ row, $index }">
  668. {{
  669. deviceWeight(
  670. row.roughWeight,
  671. row.minPackingCount * row.outInNum
  672. )
  673. }}
  674. <template slot="append"> -->
  675. <!-- {{ handleRowUnit(row) }} -->
  676. <!-- {{
  677. { yuan: '元', wanyuan: '万元' }[row.univalenceUnit]
  678. }} -->
  679. <!-- </template>
  680. </template>
  681. </el-table-column> -->
  682. <el-table-column
  683. label="重量单位"
  684. align="center"
  685. prop="contentImage"
  686. :show-overflow-tooltip="true"
  687. >
  688. <template slot-scope="{ row, $index }">
  689. {{ row.weightUnit }}
  690. <template slot="append"> </template>
  691. </template>
  692. </el-table-column>
  693. <el-table-column
  694. label="单价"
  695. prop="univalence"
  696. width="150"
  697. align="center"
  698. >
  699. <template slot-scope="{ row, $index }">
  700. <!-- <template v-if="row.isSave || formData.bizType == 5">
  701. <template v-if="row.univalence || row.univalence === 0">
  702. {{ row.univalence
  703. }}{{
  704. { yuan: '元', wanyuan: '万元' }[row.univalenceUnit]
  705. }}
  706. </template>
  707. </template> -->
  708. <!-- v-else -->
  709. <el-form-item
  710. :prop="`warehousingMaterialList.${$index}.univalence`"
  711. >
  712. <el-input
  713. :ref="'univalence' + $index"
  714. @keyup.native="
  715. moveFocus($event, $index, 'univalence', '产品', row)
  716. "
  717. v-model="row.univalence"
  718. placeholder="非必填"
  719. @input="
  720. (value) =>
  721. (row.univalence = value.replace(/[^0-9.]+/g, ''))
  722. "
  723. >
  724. <template slot="append">
  725. 元/{{ handleRowUnit(row) }}
  726. <!-- {{
  727. { yuan: '元', wanyuan: '万元' }[row.univalenceUnit]
  728. }} -->
  729. </template>
  730. </el-input>
  731. </el-form-item>
  732. </template>
  733. </el-table-column>
  734. <el-table-column
  735. label="金额"
  736. align="center"
  737. prop="contentImage"
  738. :show-overflow-tooltip="true"
  739. >
  740. <template slot-scope="{ row, $index }">
  741. {{
  742. calcSumTotal(
  743. row.outInNum,
  744. row.minPackingCount,
  745. row.univalence,
  746. row
  747. )
  748. }}
  749. </template>
  750. </el-table-column>
  751. <el-table-column
  752. v-if="clientEnvironmentId == 4"
  753. label="采购原因"
  754. align="center"
  755. width="200"
  756. prop="purpose"
  757. :show-overflow-tooltip="true"
  758. >
  759. <template slot-scope="{ row, $index }">
  760. <el-input
  761. :ref="'purpose' + $index"
  762. @keyup.native="
  763. moveFocus($event, $index, 'purpose', '产品', row)
  764. "
  765. v-model="row.purpose"
  766. >
  767. </el-input>
  768. </template>
  769. </el-table-column>
  770. <el-table-column
  771. label="货位"
  772. prop="warehouseName"
  773. :show-overflow-tooltip="true"
  774. width="250"
  775. required
  776. >
  777. <template slot-scope="{ row, $index }">
  778. <el-form-item
  779. :prop="`warehousingMaterialList.${$index}.houseList`"
  780. :required="true"
  781. >
  782. <div @click="handleWareHouse(row, $index)">
  783. <div
  784. style="color: #ff4949"
  785. v-if="row.houseList.length == 0"
  786. >
  787. ---(必填)
  788. </div>
  789. <div v-else>
  790. <div
  791. class="fontOmitted"
  792. v-for="(item, index) in row.houseList"
  793. :key="index"
  794. >
  795. {{ item.warehouseName }}- {{ item.areaName }}-
  796. {{ item.shelfCode }}- {{ item.cargoSpaceCode
  797. }}<span style="color: #ff4949" v-if="item.num">
  798. - {{ item.num }}(数)</span
  799. >
  800. <br />
  801. </div>
  802. </div>
  803. </div>
  804. </el-form-item>
  805. </template>
  806. </el-table-column>
  807. <el-table-column
  808. label="质检单"
  809. v-if="formData.extInfo.assetType === 3"
  810. prop="contentImage"
  811. :show-overflow-tooltip="true"
  812. >
  813. <template slot-scope="{ row, $index }">
  814. <upload @on-success="(data) => (row.contentImage = [data])"
  815. ><template slot="placeholder">上传</template></upload
  816. >
  817. </template>
  818. </el-table-column>
  819. <el-table-column
  820. label="操作"
  821. width="200"
  822. fixed="right"
  823. align="center"
  824. >
  825. <template slot="header" slot-scope="scope"> 操作 </template>
  826. <template slot-scope="{ row, $index }">
  827. <el-button
  828. type="text"
  829. v-show="!row.isSave"
  830. @click="listSave(row, $index)"
  831. >保存</el-button
  832. >
  833. <el-button
  834. type="text"
  835. v-show="row.isSave"
  836. @click="listEdit(row, $index)"
  837. >编辑</el-button
  838. >
  839. <el-button
  840. type="text"
  841. v-if="formData.bizType == 5"
  842. v-show="!row.isSave"
  843. @click="chooseAssets(row, $index)"
  844. >选择资产编号</el-button
  845. >
  846. <el-button type="text" @click="listDel(row, $index)"
  847. >删除</el-button
  848. >
  849. </template>
  850. </el-table-column>
  851. </el-table>
  852. </el-form>
  853. </div>
  854. <div class="mt20">
  855. <header-title :title="`包装明细`">
  856. <div class="switch_right">
  857. <span v-if="materialCodeReqList.length != 0 && !isDisableSplit">
  858. 分拆<el-switch
  859. v-model="isSplit"
  860. active-color="#13ce66"
  861. inactive-color="#ff4949"
  862. @change="handleIsDetail"
  863. style="margin-left: 10px"
  864. >
  865. </el-switch>
  866. </span>
  867. <el-button
  868. style="margin-left: 20px"
  869. type="text"
  870. @click="dateSetting"
  871. v-if="!isSplit && formData.bizType != 5"
  872. >批量设置{{
  873. curDateType === 'manufactureTime' ? '生产日期' : '采购日期'
  874. }}</el-button
  875. >
  876. </div>
  877. </header-title>
  878. <el-button
  879. v-if="materialCodeReqList.length != 0"
  880. type="success"
  881. plain
  882. style="margin-bottom: 20px; float: right; margin-right: 20px"
  883. size="mini"
  884. @click="wrapListSave"
  885. >批量保存</el-button
  886. >
  887. <el-table
  888. v-if="isWrapTable"
  889. ref="materialCodeReqListTable"
  890. :data="materialCodeReqList"
  891. tooltip-effect="dark"
  892. :key="formData.bizType"
  893. :header-cell-style="rowClass"
  894. style="width: 100%"
  895. stripe
  896. :max-height="300"
  897. @selection-change="handleSelectionChange"
  898. >
  899. <el-table-column
  900. v-if="formData.bizType != 5"
  901. type="selection"
  902. align="center"
  903. width="50"
  904. fixed="left"
  905. >
  906. </el-table-column>
  907. <el-table-column label="序号" type="index" width="50">
  908. </el-table-column>
  909. <el-table-column
  910. label="编码"
  911. prop="assetCode"
  912. width="130"
  913. :show-overflow-tooltip="true"
  914. ></el-table-column>
  915. <el-table-column
  916. label="名称"
  917. prop="assetName"
  918. width="150"
  919. :show-overflow-tooltip="true"
  920. ></el-table-column>
  921. <el-table-column
  922. label="批号"
  923. prop="manualBatchNo"
  924. width="100"
  925. ></el-table-column>
  926. <el-table-column
  927. v-if="clientEnvironmentId != 2"
  928. label="批次号"
  929. prop="batchNo"
  930. width="70"
  931. ></el-table-column>
  932. <el-table-column
  933. :label="`包装编码`"
  934. prop="onlyCode"
  935. width="200"
  936. :show-overflow-tooltip="true"
  937. ></el-table-column>
  938. <el-table-column
  939. label="包装数量"
  940. prop="packingCount"
  941. width="80"
  942. ></el-table-column>
  943. <el-table-column
  944. label="包装单位"
  945. prop="packingUnit"
  946. ></el-table-column>
  947. <el-table-column
  948. label="计量数量"
  949. prop="minPackingCount"
  950. ></el-table-column>
  951. <el-table-column
  952. label="计量单位"
  953. prop="measuringUnit"
  954. ></el-table-column>
  955. <el-table-column label="物料代号" prop="materielCode" width="130">
  956. <template slot-scope="{ row, $index }">
  957. <el-input
  958. v-if="!row.isPack"
  959. :ref="'materielCode' + $index"
  960. @keyup.native="
  961. moveFocus($event, $index, 'materielCode', '包装', row)
  962. "
  963. v-model="row.materielCode"
  964. ></el-input>
  965. <span v-else>{{ row.materielCode }}</span>
  966. </template>
  967. </el-table-column>
  968. <el-table-column label="客户代号" prop="clientCode">
  969. <template slot-scope="{ row, $index }">
  970. <el-input
  971. v-if="!row.isPack"
  972. :ref="'clientCode' + $index"
  973. @keyup.native="
  974. moveFocus($event, $index, 'clientCode', '包装', row)
  975. "
  976. v-model="row.clientCode"
  977. ></el-input>
  978. <span v-else> {{ row.clientCode }}</span>
  979. </template>
  980. </el-table-column>
  981. <el-table-column label="刻码" prop="engrave" width="140">
  982. <template slot-scope="{ row, $index }">
  983. <el-input
  984. v-if="!row.isPack"
  985. :ref="'engrave' + $index"
  986. @keyup.native="
  987. moveFocus($event, $index, 'engrave', '包装', row)
  988. "
  989. v-model="row.engrave"
  990. ></el-input>
  991. <span v-else>{{ row.engrave }}</span>
  992. </template>
  993. </el-table-column>
  994. <el-table-column label="重量" prop="weight" width="100">
  995. <template slot-scope="{ row, $index }">
  996. <el-input
  997. v-if="!row.isPack && row.measuringUnit != row.weightUtil"
  998. :ref="'weight' + $index"
  999. @keyup.native="
  1000. moveFocus($event, $index, 'weight', '包装', row)
  1001. "
  1002. v-model="row.weight"
  1003. @input="weightInput($event, row)"
  1004. ></el-input>
  1005. <span v-else>{{ row.weight }}</span>
  1006. </template>
  1007. </el-table-column>
  1008. <el-table-column label="重量单位" prop="weightUtil">
  1009. <template slot-scope="{ row }">
  1010. {{ row.weightUtil }}
  1011. </template>
  1012. </el-table-column>
  1013. <el-table-column label="质检结果" prop="result" width="120">
  1014. <template slot-scope="{ row }">
  1015. <DictSelection
  1016. v-if="!row.isPack"
  1017. @updateVal="changeWrapStatus($event, row)"
  1018. dictName="质检结果"
  1019. clearable
  1020. v-model="row.result"
  1021. />
  1022. <span v-else>{{ qualityResults[row.result] }}</span>
  1023. </template>
  1024. </el-table-column>
  1025. <el-table-column label="质检状态" prop="status" width="120">
  1026. <template slot-scope="{ row }">
  1027. <!-- <DictSelection
  1028. dictName="质检状态"
  1029. clearable
  1030. v-model="row.status"
  1031. ></DictSelection> -->
  1032. <span>{{ qualityStatus[row.status] }}</span>
  1033. </template>
  1034. </el-table-column>
  1035. <el-table-column
  1036. v-if="formData.bizType != 5"
  1037. label="生产日期"
  1038. prop=""
  1039. width="220"
  1040. >
  1041. <template slot="header" slot-scope="scope">
  1042. <el-select :disabled="isSplit" filterable v-model="curDateType">
  1043. <el-option
  1044. value="manufactureTime"
  1045. label="生产日期"
  1046. ></el-option>
  1047. <el-option
  1048. value="procurementTime"
  1049. label="采购日期"
  1050. ></el-option>
  1051. </el-select>
  1052. </template>
  1053. <template slot-scope="{ row }">
  1054. <template v-if="formData.bizType == 5">
  1055. {{ row[curDateType] }}
  1056. </template>
  1057. <el-date-picker
  1058. v-else
  1059. :disabled="row.isPack"
  1060. size="small"
  1061. v-model="row[curDateType]"
  1062. type="datetime"
  1063. value-format="yyyy-MM-dd HH:mm:ss"
  1064. placeholder="选择日期"
  1065. >
  1066. </el-date-picker>
  1067. </template>
  1068. </el-table-column>
  1069. <template v-else>
  1070. <el-table-column
  1071. label="生产日期"
  1072. prop="manufactureTime"
  1073. width="200"
  1074. ></el-table-column>
  1075. <el-table-column
  1076. label="采购日期"
  1077. prop="procurementTime"
  1078. width="200"
  1079. ></el-table-column>
  1080. </template>
  1081. <el-table-column
  1082. v-if="!isSplit"
  1083. label="操作"
  1084. width="120"
  1085. fixed="right"
  1086. >
  1087. <template slot-scope="{ row, $index }">
  1088. <el-button type="text" @click="packCout(row)">
  1089. {{ !row.isPack ? '保存' : '编辑' }}
  1090. </el-button>
  1091. <el-button
  1092. v-if="isOutsourcing"
  1093. type="text"
  1094. @click="wrapDelete(row, $index)"
  1095. >
  1096. 删除
  1097. </el-button>
  1098. </template>
  1099. </el-table-column>
  1100. </el-table>
  1101. <!-- </el-tab-pane>
  1102. </el-tabs> -->
  1103. </div>
  1104. <div class="mt20" v-if="isSplit">
  1105. <header-title :title="`物料明细`"> </header-title>
  1106. <el-button
  1107. v-if="resultArray.length != 0"
  1108. type="success"
  1109. plain
  1110. style="margin-bottom: 20px; float: right; margin-right: 20px"
  1111. size="mini"
  1112. @click="materialListSave"
  1113. >批量保存</el-button
  1114. >
  1115. <el-table
  1116. v-if="isMaterialTable"
  1117. ref="resultArrayTable"
  1118. :data="resultArray"
  1119. tooltip-effect="dark"
  1120. :key="formData.bizType"
  1121. :header-cell-style="rowClass"
  1122. style="width: 100%"
  1123. stripe
  1124. :max-height="300"
  1125. @selection-change="handleSelectionChange"
  1126. >
  1127. <el-table-column label="序号" type="index" width="50">
  1128. </el-table-column>
  1129. <el-table-column
  1130. label="编码"
  1131. width="150"
  1132. prop="assetCode"
  1133. :show-overflow-tooltip="true"
  1134. ></el-table-column>
  1135. <el-table-column
  1136. label="名称"
  1137. prop="assetName"
  1138. width="200"
  1139. :show-overflow-tooltip="true"
  1140. ></el-table-column>
  1141. <el-table-column
  1142. label="批号"
  1143. prop="manualBatchNo"
  1144. width="100"
  1145. ></el-table-column>
  1146. <el-table-column
  1147. v-if="clientEnvironmentId != 2"
  1148. label="批次号"
  1149. prop="batchNo"
  1150. width="80"
  1151. ></el-table-column>
  1152. <el-table-column
  1153. label="物料编码"
  1154. prop="no"
  1155. width="200"
  1156. :show-overflow-tooltip="true"
  1157. ></el-table-column>
  1158. <el-table-column
  1159. label="计量数量"
  1160. prop="minPackingCount"
  1161. width="90"
  1162. ></el-table-column>
  1163. <el-table-column
  1164. width="80"
  1165. label="计量单位"
  1166. prop="measuringUnit"
  1167. ></el-table-column>
  1168. <el-table-column label="物料代号" prop="materielCode" width="130">
  1169. <template slot-scope="{ row, $index }">
  1170. <el-input
  1171. v-if="!row.isPack"
  1172. :ref="'materielCode' + $index"
  1173. @keyup.native="
  1174. moveFocus($event, $index, 'materielCode', '物料', row)
  1175. "
  1176. v-model="row.materielCode"
  1177. ></el-input>
  1178. <span v-else>{{ row.materielCode }}</span>
  1179. </template>
  1180. </el-table-column>
  1181. <el-table-column label="客户代号" prop="clientCode">
  1182. <template slot-scope="{ row, $index }">
  1183. <el-input
  1184. v-if="!row.isPack"
  1185. :ref="'clientCode' + $index"
  1186. @keyup.native="
  1187. moveFocus($event, $index, 'clientCode', '物料', row)
  1188. "
  1189. v-model="row.clientCode"
  1190. ></el-input>
  1191. <span v-else>{{ row.clientCode }}</span>
  1192. </template>
  1193. </el-table-column>
  1194. <el-table-column label="刻码" prop="engrave" width="140">
  1195. <template slot-scope="{ row, $index }">
  1196. <el-input
  1197. v-if="!row.isPack"
  1198. :ref="'engrave' + $index"
  1199. @keyup.native="
  1200. moveFocus($event, $index, 'engrave', '物料', row)
  1201. "
  1202. v-model="row.engrave"
  1203. ></el-input>
  1204. <span v-else>{{ row.engrave }}</span>
  1205. </template>
  1206. </el-table-column>
  1207. <el-table-column label="重量" prop="weight" width="100">
  1208. <template slot-scope="{ row, $index }">
  1209. <el-input
  1210. v-if="!row.isPack && row.measuringUnit != row.weightUnit"
  1211. :ref="'weight' + $index"
  1212. @keyup.native="
  1213. moveFocus($event, $index, 'weight', '物料', row)
  1214. "
  1215. v-model="row.weight"
  1216. ></el-input>
  1217. <span v-else>{{ row.weight }}</span>
  1218. </template>
  1219. </el-table-column>
  1220. <el-table-column
  1221. label="重量单位"
  1222. prop="weightUnit"
  1223. width="100"
  1224. ></el-table-column>
  1225. <el-table-column label="质检结果" prop="result" width="120">
  1226. <template slot-scope="{ row }">
  1227. <DictSelection
  1228. v-if="!row.isPack"
  1229. @updateVal="changeWrapStatus($event, row)"
  1230. dictName="质检结果"
  1231. clearable
  1232. v-model="row.result"
  1233. />
  1234. <span v-else>{{ qualityResults[row.result] }}</span>
  1235. </template>
  1236. </el-table-column>
  1237. <el-table-column label="质检状态" prop="status" width="120">
  1238. <template slot-scope="{ row }">
  1239. <span>{{ qualityStatus[row.status] }}</span>
  1240. </template>
  1241. </el-table-column>
  1242. <el-table-column label="操作" width="120" fixed="right">
  1243. <template slot-scope="{ row, $index }">
  1244. <el-button type="text" @click="materialBtn(row)">
  1245. {{ !row.isPack ? '保存' : '编辑' }}
  1246. </el-button>
  1247. <el-button
  1248. v-if="isOutsourcing"
  1249. type="text"
  1250. @click="materialDelete(row, $index)"
  1251. >
  1252. 删除
  1253. </el-button>
  1254. </template>
  1255. </el-table-column>
  1256. </el-table>
  1257. </div>
  1258. </div>
  1259. <div class="center mt20">
  1260. <el-button type="primary" @click="handleSave" :loading="saveLoading"
  1261. >保存</el-button
  1262. >
  1263. <el-button @click="$router.go(-1)">返回</el-button>
  1264. </div>
  1265. </el-card>
  1266. <selectType
  1267. :visibleDialog.sync="visibleDialog"
  1268. :title="title"
  1269. :tableHeader="tableHeader"
  1270. :bizScene="formData.bizType"
  1271. :type="[selectEquiType]"
  1272. :loadTree.sync="loadTree"
  1273. @selectTableData="addProduct"
  1274. />
  1275. <WareHouseDailog
  1276. ref="wareHouseDailogRef"
  1277. @houseData="houseData"
  1278. ></WareHouseDailog>
  1279. <ReturnSelect
  1280. ref="returnSelectRef"
  1281. :tableHeader="tableHeader"
  1282. :curDateType="curDateType"
  1283. ></ReturnSelect>
  1284. <el-dialog :visible.sync="dateVisible" title="选择日期" width="400px">
  1285. <el-date-picker
  1286. size="small"
  1287. v-model="batchTime"
  1288. type="datetime"
  1289. style="width: 320px"
  1290. value-format="yyyy-MM-dd HH:mm:ss"
  1291. placeholder="选择日期"
  1292. >
  1293. </el-date-picker>
  1294. <div style="text-align: right; margin-top: 20px">
  1295. <el-button @click="dateVisible = false">取消</el-button>
  1296. <el-button type="primary" @click="dateConfirm" :disabled="!batchTime"
  1297. >确认</el-button
  1298. >
  1299. </div>
  1300. </el-dialog>
  1301. <!-- 出库单 -->
  1302. <stockOutOrder ref="stockOutOrderRef" @success="stockOutOrderSuccess" />
  1303. <!-- 销售订单 -->
  1304. <picker ref="pickerRef" @success="pickerSuccess" />
  1305. <!-- 委外订单 -->
  1306. <outsourcedOrders
  1307. ref="outsourcedOrdersRef"
  1308. @success="outsourcedOrdersSuccess"
  1309. />
  1310. </div>
  1311. </template>
  1312. <script>
  1313. import { add, bignumber } from 'mathjs';
  1314. import picker from './components/picker.vue';
  1315. import stockOutOrder from './components/stockOutOrder.vue';
  1316. import outsourcedOrders from './components/outsourcedOrders.vue';
  1317. import outin from '@/api/warehouseManagement/outin';
  1318. import {
  1319. getTreeByPid,
  1320. getTreeByGroup,
  1321. getProductList
  1322. } from '@/api/classifyManage';
  1323. import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
  1324. import selectUpload from '@/components/selectUpload';
  1325. import upload from '@/components/uploadImg';
  1326. import {
  1327. warehousingType,
  1328. sceneState,
  1329. emergencyState,
  1330. materialType
  1331. } from '@/utils/dict/index';
  1332. // import { getInfo, warehousingAdd, getAssetNum } from '@/api/stockManagement';
  1333. import selectTree from '@/components/selectTree';
  1334. import selectType from '../components/selectType.vue';
  1335. import WareHouseDailog from '../components/WareHouseDailog.vue';
  1336. import ReturnSelect from './components/ReturnSelect.vue';
  1337. // import supplier from '@/api/main/supplier';
  1338. // import org from '@/api/main/org';
  1339. // import user from '@/api/main/user';
  1340. import { tableHeader } from '../common';
  1341. import { getCode } from '@/api/codeManagement/index.js';
  1342. import { number } from 'echarts/core';
  1343. import { purchaseorderGetById, contactlink, oneId } from '@/api/mes';
  1344. export default {
  1345. components: {
  1346. selectUpload,
  1347. selectTree,
  1348. selectType,
  1349. WareHouseDailog,
  1350. upload,
  1351. ReturnSelect,
  1352. picker,
  1353. outsourcedOrders,
  1354. stockOutOrder
  1355. },
  1356. data() {
  1357. return {
  1358. isWrapTable: true, // 包装表格显隐
  1359. isMaterialTable: true, // 物料表格显隐
  1360. isOutsourcing: false, // 是否委外
  1361. stockOutOrders: '',
  1362. isSplit: false, // 是否拆分到物料明细
  1363. qualityStatus: {
  1364. 0: '未检',
  1365. 1: '已检',
  1366. 2: '部分检'
  1367. }, // 质检状态 0未检 1已检
  1368. qualityResults: {
  1369. 0: '合格',
  1370. 1: '不合格',
  1371. 3: '让步接收'
  1372. }, // 质检结果 0合格 1不合格 3让步接收
  1373. isWeight: true,
  1374. resultArray: [],
  1375. contactList: [],
  1376. pickerRow: {},
  1377. outsourcedOrdersRow: {},
  1378. fromUserList: [],
  1379. codeList: [],
  1380. materialType,
  1381. warehousingType,
  1382. sceneState,
  1383. emergencyState,
  1384. saveLoading: false,
  1385. visibleDialog: false,
  1386. curDateType: 'manufactureTime',
  1387. materialCodeReqListSelected: [],
  1388. // warehouseList: [], //仓库数组
  1389. // warehouse: {},
  1390. title: '',
  1391. tableData2: [],
  1392. uploadList: [],
  1393. supplierList: [],
  1394. warehousingMaterialList: [],
  1395. activeName: 'a',
  1396. loadTree: true,
  1397. selectEquiType: '',
  1398. batchTime: '',
  1399. dateVisible: false,
  1400. treeList: [],
  1401. staffList: [],
  1402. formData: {
  1403. extInfo: {
  1404. assetType: '', //物品类型
  1405. deptCode: '', //部门code
  1406. deptName: '', //部门名称
  1407. verifyDeptCode: '', //审核部门编码
  1408. verifyDeptName: '', //审核部门名称
  1409. deliveryName: '', //送货人名称
  1410. deliveryPhone: '', //送货人电话
  1411. documentSource: '', //销售订单
  1412. urgent: '', //紧急状态
  1413. supplierId: '', //供应商ID
  1414. supplierName: '', //供应商名称
  1415. createUserName: '', //创建人名字
  1416. contentImage: [] //图片数组
  1417. },
  1418. fromUser: '', //送货人
  1419. bizType: '', //物品类型
  1420. verifyId: '', //审核人Id
  1421. verifyName: '', //审核人名称
  1422. createUserId: '',
  1423. remark: ''
  1424. },
  1425. rules: {
  1426. 'extInfo.assetType': {
  1427. required: true,
  1428. message: '请选择物品类型',
  1429. trigger: 'change'
  1430. },
  1431. bizType: {
  1432. required: true,
  1433. message: '请选择入库场景',
  1434. trigger: 'change'
  1435. }
  1436. }
  1437. };
  1438. },
  1439. computed: {
  1440. // 是否允许分拆
  1441. isDisableSplit() {
  1442. return this.warehousingMaterialList.some(
  1443. (item) => item.weightUnit == item.measuringUnit
  1444. );
  1445. },
  1446. // 条码信息
  1447. materialCodeReqList() {
  1448. return this.warehousingMaterialList
  1449. .map((i) => i.warehouseLedgerDetails || [])
  1450. .flat();
  1451. },
  1452. tableHeader() {
  1453. return tableHeader(this.selectEquiType);
  1454. },
  1455. clientEnvironmentId() {
  1456. return this.$store.state.user.info.clientEnvironmentId;
  1457. }
  1458. },
  1459. created() {
  1460. if (this.$route.query.id) {
  1461. // this._getInfo()
  1462. } else {
  1463. let obj = localStorage.getItem('orgInfo')
  1464. ? JSON.parse(localStorage.getItem('orgInfo'))
  1465. : {};
  1466. this.formData.createUserName = obj.name;
  1467. this.formData.extInfo.deptName = obj.dept?.name;
  1468. this.formData.deptCode = obj.dept?.code;
  1469. }
  1470. this.initData();
  1471. },
  1472. methods: {
  1473. // 键盘移动
  1474. moveFocus(event, index, key, type, row) {
  1475. let keyfield = [];
  1476. let listLength = 0;
  1477. switch (type) {
  1478. case '产品':
  1479. listLength = this.warehousingMaterialList.length;
  1480. if (this.clientEnvironmentId == 4) {
  1481. keyfield = [
  1482. 'manualBatchNo',
  1483. 'minPackingCount',
  1484. 'outInNum',
  1485. 'univalence',
  1486. 'purpose'
  1487. ];
  1488. } else {
  1489. keyfield = [
  1490. 'manualBatchNo',
  1491. 'minPackingCount',
  1492. 'outInNum',
  1493. 'univalence'
  1494. ];
  1495. }
  1496. break;
  1497. case '包装':
  1498. listLength = this.materialCodeReqList.length;
  1499. if (row.measuringUnit != row.weightUtil) {
  1500. keyfield = ['materielCode', 'clientCode', 'engrave', 'weight'];
  1501. } else {
  1502. keyfield = ['materielCode', 'clientCode', 'engrave'];
  1503. }
  1504. break;
  1505. case '物料':
  1506. listLength = this.resultArray.length;
  1507. if (row.measuringUnit != row.weightUnit) {
  1508. keyfield = ['materielCode', 'clientCode', 'engrave', 'weight'];
  1509. } else {
  1510. keyfield = ['materielCode', 'clientCode', 'engrave'];
  1511. }
  1512. break;
  1513. }
  1514. if (event.keyCode === 13) {
  1515. // 回车
  1516. if (
  1517. index === listLength - 1 &&
  1518. key === keyfield[keyfield.length - 1]
  1519. ) {
  1520. // 最后一行最后一个
  1521. return;
  1522. }
  1523. this.$refs[key + index].blur();
  1524. if (key === keyfield[keyfield.length - 1]) {
  1525. // 当前行最后一个,跳转下一行第一个
  1526. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  1527. this.$refs[keyfield[0] + (index + 1)].value = '';
  1528. }
  1529. this.$refs[keyfield[0] + (index + 1)].focus();
  1530. } else {
  1531. // 跳转下一个
  1532. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  1533. this.$nextTick(() => {
  1534. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  1535. this.$refs[keyfield[nextkeyindex] + index].value = '';
  1536. }
  1537. this.$refs[keyfield[nextkeyindex] + index].focus();
  1538. });
  1539. }
  1540. }
  1541. // 向上 =38
  1542. if (event.keyCode === 38) {
  1543. console.log('向上');
  1544. if (index === 0) {
  1545. // 第一行
  1546. console.log('第一行无法向上');
  1547. return;
  1548. }
  1549. this.$refs[key + index].blur();
  1550. this.$nextTick(() => {
  1551. if (this.$refs[key + (index - 1)].value == 0) {
  1552. this.$refs[key + (index - 1)].value = '';
  1553. }
  1554. this.$refs[key + (index - 1)].focus();
  1555. });
  1556. }
  1557. // 下 = 40
  1558. if (event.keyCode === 40) {
  1559. console.log('向下');
  1560. if (index === listLength - 1) {
  1561. // 最后一行
  1562. console.log('最后一行无法向下');
  1563. return;
  1564. }
  1565. this.$refs[key + index].blur();
  1566. this.$nextTick(() => {
  1567. if (this.$refs[key + (index + 1)].value == 0) {
  1568. this.$refs[key + (index + 1)].value = '';
  1569. }
  1570. this.$refs[key + (index + 1)].focus();
  1571. });
  1572. }
  1573. // 左 = 37
  1574. if (event.keyCode === 37) {
  1575. console.log('向左');
  1576. if (index === 0 && key === keyfield[0]) {
  1577. // 第一行第一个
  1578. console.log('第一行第一个无法向左');
  1579. return;
  1580. }
  1581. this.$refs[key + index].blur();
  1582. if (key === keyfield[0]) {
  1583. if (
  1584. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value == 0
  1585. ) {
  1586. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].value =
  1587. '';
  1588. }
  1589. // 当前行第一个,跳转上一行最后一个
  1590. this.$refs[keyfield[keyfield.length - 1] + (index - 1)].focus();
  1591. } else {
  1592. // 跳转上一个
  1593. const prevkeyindex = keyfield.findIndex((k) => k === key) - 1;
  1594. this.$nextTick(() => {
  1595. if (this.$refs[keyfield[prevkeyindex] + index].value == 0) {
  1596. this.$refs[keyfield[prevkeyindex] + index].value = '';
  1597. }
  1598. this.$refs[keyfield[prevkeyindex] + index].focus();
  1599. });
  1600. }
  1601. }
  1602. // 右 = 39
  1603. if (event.keyCode === 39) {
  1604. console.log('向右');
  1605. if (
  1606. index === listLength - 1 &&
  1607. key === keyfield[keyfield.length - 1]
  1608. ) {
  1609. // 最后一行最后一个
  1610. console.log('最后一行最后一个无法向左');
  1611. return;
  1612. }
  1613. this.$refs[key + index].blur();
  1614. if (key === keyfield[keyfield.length - 1]) {
  1615. // 当前行最后一个,跳转下一行第一个
  1616. if (this.$refs[keyfield[0] + (index + 1)].value == 0) {
  1617. this.$refs[keyfield[0] + (index + 1)].value = '';
  1618. }
  1619. this.$refs[keyfield[0] + (index + 1)].focus();
  1620. } else {
  1621. // 跳转下一个
  1622. const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
  1623. this.$nextTick(() => {
  1624. if (this.$refs[keyfield[nextkeyindex] + index].value == 0) {
  1625. this.$refs[keyfield[nextkeyindex] + index].value = '';
  1626. }
  1627. this.$refs[keyfield[nextkeyindex] + index].focus();
  1628. });
  1629. }
  1630. }
  1631. },
  1632. // 包装维度最小包装单元改变——>总重量
  1633. minPackingCountChange(row, value) {
  1634. if (value >= 0) {
  1635. row.minPackingCount = value.replace(/^[0]+/, '');
  1636. } else {
  1637. row.minPackingCount = 0;
  1638. }
  1639. // row.minPackingCount = value.replace(/^(0+)|[^\d]+/g, '');
  1640. if (row.outInNum >= 0 && value >= 0) {
  1641. this.packNum(row, row.outInNum);
  1642. }
  1643. },
  1644. // 选择质检结果改变质检状态
  1645. changeWrapStatus(resultValue, row) {
  1646. switch (resultValue) {
  1647. case '':
  1648. // 清空质检状态
  1649. row.status = '0';
  1650. break;
  1651. default:
  1652. // 默认已检质检状态
  1653. row.status = '1';
  1654. break;
  1655. }
  1656. },
  1657. // 包装批量保存
  1658. wrapListSave() {
  1659. // 批量修改包装明细
  1660. this.isWeight = false;
  1661. this.bulkEditingWrap();
  1662. this.$nextTick(() => {
  1663. this.isWeight = true;
  1664. });
  1665. },
  1666. // 物料批量保存
  1667. materialListSave() {
  1668. this.resultArray.forEach((item) => {
  1669. if (!item.isPack) {
  1670. this.materialBtn(item);
  1671. }
  1672. });
  1673. },
  1674. weightInput(value, row) {
  1675. const newValue = value.replace(/[^\d.]/g, ''); // 保留数字和小数点
  1676. const decimalCount = (newValue.match(/\./g) || []).length; // 计算小数点的个数
  1677. if (decimalCount > 1) {
  1678. // 如果小数点个数大于1,移除多余的小数点
  1679. const lastIndex = newValue.lastIndexOf('.');
  1680. row.weight =
  1681. newValue.slice(0, lastIndex) + newValue.slice(lastIndex + 1);
  1682. } else if (decimalCount === 1) {
  1683. // 如果小数点个数等于1,允许小数点的输入
  1684. row.weight = newValue;
  1685. } else {
  1686. row.weight = newValue === '' ? 0 : parseFloat(newValue); // 如果输入为空,则设为0
  1687. }
  1688. },
  1689. handleIsDetail(event) {
  1690. this.isSplit = event;
  1691. const list = this.materialCodeReqList;
  1692. if (event) {
  1693. let resultArray = [];
  1694. list.forEach((item) => {
  1695. // 包装维度改成已保存状态
  1696. item.isPack = true;
  1697. // 拆分物料维度并生成列表
  1698. for (let i = 1; i <= Number(item.minPackingCount); i++) {
  1699. console.log(item.weight);
  1700. console.log(item.minPackingCount);
  1701. resultArray.push({
  1702. onlyCode: item.onlyCode,
  1703. no: item.onlyCode + i.toString().padStart(4, '0'),
  1704. assetCode: item.assetCode,
  1705. assetName: item.assetName,
  1706. manualBatchNo: item.manualBatchNo,
  1707. batchNo: item.batchNo,
  1708. minPackingCount: 1,
  1709. measuringUnit: item.measuringUnit,
  1710. materielCode: item.materielCode,
  1711. clientCode: item.clientCode,
  1712. weight: this.$math.format(
  1713. item.weight / Number(item.minPackingCount),
  1714. 14
  1715. ),
  1716. initWeight: this.$math.format(
  1717. item.weight / Number(item.minPackingCount),
  1718. 14
  1719. ),
  1720. weightUnit: item.weightUnit,
  1721. engrave: item.engrave,
  1722. result: item.result,
  1723. status: item.status,
  1724. isPack: false
  1725. });
  1726. }
  1727. });
  1728. this.resultArray = resultArray;
  1729. // 批量修改包装明细
  1730. this.isWeight = false;
  1731. this.bulkEditingWrap();
  1732. this.$nextTick(() => {
  1733. this.isWeight = true;
  1734. });
  1735. } else {
  1736. // 包装维度改成编辑状态
  1737. list.forEach((item) => {
  1738. item.isPack = false;
  1739. });
  1740. // 清空物料维度列表
  1741. this.resultArray = [];
  1742. }
  1743. },
  1744. //包装明细保存
  1745. packCout(row) {
  1746. //true保存==》反之
  1747. if (!row.isPack) {
  1748. row.isPack = true;
  1749. const code = row.assetCode;
  1750. const batchNo = row.batchNo;
  1751. //做防护,防止weight字符串类型
  1752. this.materialCodeReqList.forEach((ele) => {
  1753. ele.weight = Number(ele.weight);
  1754. });
  1755. // const count = this.materialCodeReqList.reduce(
  1756. // (acc, curr) => acc + curr.weight,
  1757. // 0
  1758. // );
  1759. // 修改产品信息重量(包装维度累计)
  1760. this.isWeight = false;
  1761. this.warehousingMaterialList.forEach((item) => {
  1762. if (item.assetCode == code && item.batchNo == batchNo) {
  1763. let arr = [];
  1764. for (const key in this.materialCodeReqList) {
  1765. if (
  1766. this.materialCodeReqList[key].assetCode == item.assetCode &&
  1767. this.materialCodeReqList[key].batchNo == item.batchNo
  1768. ) {
  1769. arr.push({ ...this.materialCodeReqList[key] });
  1770. }
  1771. }
  1772. const count = arr.reduce((acc, curr) => {
  1773. if (curr.isPack) {
  1774. this.$set(curr, 'initWeight', +curr.weight);
  1775. return Number(this.$math.format(+acc + +curr.weight, 14));
  1776. } else {
  1777. return Number(this.$math.format(+acc + +curr.initWeight, 14));
  1778. }
  1779. }, 0);
  1780. this.$set(item, 'weight', count);
  1781. }
  1782. });
  1783. this.$nextTick(() => {
  1784. this.isWeight = true;
  1785. });
  1786. } else {
  1787. row.isPack = false;
  1788. }
  1789. this.$nextTick(() => {
  1790. this.isWrapTable = false;
  1791. this.$nextTick(() => {
  1792. this.isWrapTable = true;
  1793. });
  1794. });
  1795. },
  1796. // 批量修改包装明细
  1797. bulkEditingWrap() {
  1798. // 批量修改包装明细列表状态(已保存)
  1799. this.materialCodeReqList.forEach((item) => {
  1800. item.isPack = true;
  1801. });
  1802. // 改变产品明细重量
  1803. this.warehousingMaterialList.forEach((outItem) => {
  1804. let arr = [];
  1805. this.materialCodeReqList.forEach((inneritem) => {
  1806. if (
  1807. inneritem.assetCode == outItem.assetCode &&
  1808. inneritem.batchNo == outItem.batchNo
  1809. ) {
  1810. arr.push(inneritem);
  1811. }
  1812. });
  1813. const count = arr.reduce((acc, curr) => {
  1814. if (curr.isPack) {
  1815. this.$set(curr, 'initWeight', +curr.weight);
  1816. return Number(this.$math.format(+acc + +curr.weight, 14));
  1817. } else {
  1818. return Number(this.$math.format(+acc + +curr.initWeight, 14));
  1819. }
  1820. }, 0);
  1821. this.$set(outItem, 'weight', count);
  1822. });
  1823. },
  1824. // 批量修改物料明细
  1825. bulkEditingMaterial() {
  1826. // 批量修改物料明细列表状态(已保存)
  1827. this.resultArray.forEach((item) => {
  1828. item.isPack = true;
  1829. });
  1830. // 改变包装明细重量
  1831. this.materialCodeReqList.forEach((outItem) => {
  1832. let arr = [];
  1833. this.resultArray.forEach((inneritem) => {
  1834. if (
  1835. inneritem.assetCode == outItem.assetCode &&
  1836. inneritem.batchNo == outItem.batchNo
  1837. ) {
  1838. arr.push(inneritem);
  1839. }
  1840. });
  1841. const count = arr.reduce((acc, curr) => {
  1842. if (curr.isPack) {
  1843. this.$set(curr, 'initWeight', +curr.weight);
  1844. return Number(this.$math.format(+acc + +curr.weight, 14));
  1845. } else {
  1846. return Number(this.$math.format(+acc + +curr.initWeight, 14));
  1847. }
  1848. }, 0);
  1849. this.$set(outItem, 'weight', count);
  1850. });
  1851. },
  1852. // 物料明细保存
  1853. materialBtn(row) {
  1854. console.log(row);
  1855. console.log(this.resultArray);
  1856. console.log(this.materialCodeReqList);
  1857. // true保存 false编辑
  1858. if (!row.isPack) {
  1859. row.isPack = true;
  1860. // 物料维度修改质检改变包装维度质检(结果和状态)
  1861. this.materialCodeReqList.forEach((outItem) => {
  1862. let arr = [];
  1863. this.resultArray.forEach((inneritem) => {
  1864. if (inneritem.onlyCode == outItem.onlyCode) {
  1865. arr.push(inneritem);
  1866. }
  1867. });
  1868. console.log(arr);
  1869. // 首先判断是未填/合格不合格
  1870. let boolen = arr.every((item) => {
  1871. return item.result === '' || item.result === undefined;
  1872. });
  1873. // 判断只要物料全部质检结果(未填)——>包装质检结果(未填) 状态(未检)
  1874. if (boolen) {
  1875. this.$set(outItem, 'result', '');
  1876. this.$set(outItem, 'status', '0');
  1877. } else {
  1878. // 判断只要物料有一个质检结果(不合格)——>包装质检结果(不合格) 状态(已检)
  1879. let boolen = arr.some((item) => {
  1880. return item.result === '1';
  1881. });
  1882. if (boolen) {
  1883. this.$set(outItem, 'result', '1');
  1884. this.$set(outItem, 'status', '1');
  1885. } else {
  1886. // 判断只要物料有一个质检结果(让步接收)——>包装质检结果(让步接收) 状态(已检)
  1887. let boolen = arr.some((item) => {
  1888. return item.result === '3';
  1889. });
  1890. if (boolen) {
  1891. // 让步接收 已检
  1892. this.$set(outItem, 'result', '3');
  1893. this.$set(outItem, 'status', '1');
  1894. } else {
  1895. // 判断只要物料有全部质检结果(合格)——>包装质检结果(合格) 状态(已检)
  1896. let boolen = arr.every((item) => {
  1897. return item.result === '0';
  1898. });
  1899. if (boolen) {
  1900. // 合格 已检
  1901. this.$set(outItem, 'result', '0');
  1902. this.$set(outItem, 'status', '1');
  1903. } else {
  1904. // 合格 部分检
  1905. this.$set(outItem, 'result', '0');
  1906. this.$set(outItem, 'status', '2');
  1907. }
  1908. }
  1909. }
  1910. }
  1911. // this.$set(outItem, 'result', boolen ? '1' : '0');
  1912. });
  1913. // 物料维度修改重量改变包装维度重量
  1914. let onlyCode = row.onlyCode;
  1915. this.materialCodeReqList.forEach((item) => {
  1916. if (item.onlyCode === onlyCode) {
  1917. let arr = [];
  1918. for (const key in this.resultArray) {
  1919. if (this.resultArray[key].onlyCode == item.onlyCode) {
  1920. arr.push(this.resultArray[key]);
  1921. }
  1922. }
  1923. const count = arr.reduce((acc, curr) => {
  1924. if (curr.isPack) {
  1925. this.$set(curr, 'initWeight', +curr.weight);
  1926. return Number(this.$math.format(+acc + +curr.weight, 14));
  1927. } else {
  1928. return Number(this.$math.format(+acc + +curr.initWeight, 14));
  1929. }
  1930. }, 0);
  1931. this.$set(item, 'weight', count);
  1932. }
  1933. });
  1934. // 包装维度修改重量改变产品信息
  1935. this.isWeight = false;
  1936. // 批量修改包装明细
  1937. this.bulkEditingWrap();
  1938. this.$nextTick(() => {
  1939. this.isWeight = true;
  1940. });
  1941. } else {
  1942. row.isPack = false;
  1943. }
  1944. this.$nextTick(() => {
  1945. this.isWrapTable = false;
  1946. this.isMaterialTable = false;
  1947. this.$nextTick(() => {
  1948. this.isWrapTable = true;
  1949. this.isMaterialTable = true;
  1950. });
  1951. });
  1952. },
  1953. packNum(row, value) {
  1954. const total = {
  1955. packingCount: Number(
  1956. row.minPackingCount > 0 ? row.minPackingCount : 0
  1957. ),
  1958. outInNum: Number(row.outInNum > 0 ? row.outInNum : 0)
  1959. };
  1960. if (row.measuringUnit == row.weightUnit) {
  1961. row.weight = Number(
  1962. this.$math.format(
  1963. total.packingCount * 1 * total.outInNum.toFixed(2),
  1964. 14
  1965. )
  1966. );
  1967. } else {
  1968. const totals = Number(
  1969. this.$math.format(total.packingCount * total.outInNum, 14)
  1970. );
  1971. row.weight = Number(
  1972. this.$math.format(
  1973. totals * (row.netWeight > 0 ? row.netWeight.toFixed(2) : 0),
  1974. 14
  1975. )
  1976. );
  1977. }
  1978. return (row.outInNum = value.replace(/^(0+)|[^\d]+/g, ''));
  1979. },
  1980. async searchContact(id) {
  1981. const data = await contactlink({ contactId: id });
  1982. this.contactList = data.data;
  1983. },
  1984. outsourcedOrdersSuccess(row) {
  1985. this.outsourcedOrdersRow = row;
  1986. this.formData.extInfo.documentSource = row.code;
  1987. this.$forceUpdate();
  1988. },
  1989. // 包装删除
  1990. wrapDelete(row, index) {
  1991. // 删除包装
  1992. this.materialCodeReqList.splice(index, 1);
  1993. let outIndex = 0;
  1994. let arr = this.warehousingMaterialList.filter((item, index) => {
  1995. if (item.assetCode == row.assetCode && item.batchNo == row.batchNo) {
  1996. outIndex = index;
  1997. return true;
  1998. }
  1999. });
  2000. // 修改产品
  2001. if (arr[0].minPackingCount * arr[0].outInNum === row.minPackingCount) {
  2002. this.warehousingMaterialList.splice(outIndex, 1);
  2003. } else {
  2004. this.$set(
  2005. this.warehousingMaterialList[outIndex],
  2006. 'outInNum',
  2007. this.warehousingMaterialList[outIndex].outInNum - 1
  2008. );
  2009. }
  2010. // 删除物料
  2011. if (this.resultArray.length > 0) {
  2012. let indexs = [];
  2013. let arr = this.resultArray.filter((item, index) => {
  2014. if (
  2015. item.assetCode == row.assetCode &&
  2016. item.batchNo == row.batchNo
  2017. ) {
  2018. indexs.push(index);
  2019. return true;
  2020. }
  2021. });
  2022. console.log(indexs);
  2023. console.log(arr);
  2024. this.resultArray = this.resultArray.filter((item, index) => {
  2025. return !indexs.includes(index);
  2026. });
  2027. }
  2028. },
  2029. // 物料删除
  2030. materialDelete(row, index) {
  2031. console.log('row---------------');
  2032. console.log(index);
  2033. console.log(row);
  2034. let isBoolen = false;
  2035. // 删除物料
  2036. this.resultArray.splice(index, 1);
  2037. // 过滤物料对应包装
  2038. let wrapOutIndex = 0;
  2039. let wrapArr = this.materialCodeReqList.filter((item, index) => {
  2040. if (
  2041. item.assetCode == row.assetCode &&
  2042. item.batchNo == row.batchNo &&
  2043. item.onlyCode == row.onlyCode
  2044. ) {
  2045. wrapOutIndex = index;
  2046. return true;
  2047. }
  2048. });
  2049. console.log('wrapArr------------------');
  2050. console.log(wrapArr);
  2051. // 包装和物料数量一致(相同删除列/不同-1)
  2052. if (wrapArr[0].minPackingCount === row.minPackingCount) {
  2053. isBoolen = true;
  2054. // 修改产品
  2055. let materialOutIndex = 0;
  2056. let materialArr = this.warehousingMaterialList.filter(
  2057. (item, index) => {
  2058. console.log(wrapOutIndex);
  2059. console.log(this.materialCodeReqList);
  2060. console.log(item.assetCode);
  2061. console.log(this.materialCodeReqList[wrapOutIndex]);
  2062. console.log(this.materialCodeReqList[wrapOutIndex].assetCode);
  2063. console.log('----------------');
  2064. if (
  2065. item.assetCode ==
  2066. this.materialCodeReqList[wrapOutIndex].assetCode &&
  2067. item.batchNo == this.materialCodeReqList[wrapOutIndex].batchNo
  2068. ) {
  2069. materialOutIndex = index;
  2070. return true;
  2071. }
  2072. }
  2073. );
  2074. // 产品和包装数量一致(相同删除列/不同-1)———— 产品
  2075. if (
  2076. materialArr[0].minPackingCount * materialArr[0].outInNum ===
  2077. this.materialCodeReqList[wrapOutIndex].minPackingCount
  2078. ) {
  2079. this.warehousingMaterialList.splice(materialOutIndex, 1);
  2080. } else {
  2081. this.$set(
  2082. this.warehousingMaterialList[materialOutIndex],
  2083. 'outInNum',
  2084. this.warehousingMaterialList[materialOutIndex].outInNum - 1
  2085. );
  2086. }
  2087. this.materialCodeReqList.splice(wrapOutIndex, 1);
  2088. } else {
  2089. // 包装数量-1
  2090. this.$set(
  2091. this.materialCodeReqList[wrapOutIndex],
  2092. 'minPackingCount',
  2093. this.materialCodeReqList[wrapOutIndex].minPackingCount - 1
  2094. );
  2095. }
  2096. if (!isBoolen) {
  2097. // 修改产品
  2098. let materialOutIndex = 0;
  2099. // 找到包装对应产品
  2100. let materialArr = this.warehousingMaterialList.filter(
  2101. (item, index) => {
  2102. console.log(wrapOutIndex);
  2103. console.log(this.materialCodeReqList);
  2104. console.log(item.assetCode);
  2105. console.log(this.materialCodeReqList[wrapOutIndex]);
  2106. console.log(this.materialCodeReqList[wrapOutIndex].assetCode);
  2107. console.log('----------------');
  2108. if (
  2109. item.assetCode ==
  2110. this.materialCodeReqList[wrapOutIndex].assetCode &&
  2111. item.batchNo == this.materialCodeReqList[wrapOutIndex].batchNo
  2112. ) {
  2113. materialOutIndex = index;
  2114. return true;
  2115. }
  2116. }
  2117. );
  2118. // 产品和包装数量一致(相同删除列/不同-1)———— 产品
  2119. if (
  2120. materialArr[0].minPackingCount * materialArr[0].outInNum ===
  2121. this.materialCodeReqList[wrapOutIndex].minPackingCount
  2122. ) {
  2123. this.warehousingMaterialList.splice(materialOutIndex, 1);
  2124. } else {
  2125. this.$set(
  2126. this.warehousingMaterialList[materialOutIndex],
  2127. 'outInNum',
  2128. this.warehousingMaterialList[materialOutIndex].outInNum - 1
  2129. );
  2130. }
  2131. }
  2132. },
  2133. async stockOutOrderSuccess(row) {
  2134. console.log('--------------------------');
  2135. console.log(row);
  2136. this.stockOutOrders = row.bizNo;
  2137. this.formData.bizType = '2';
  2138. this.formData.extInfo = row.extInfo;
  2139. this.selectEquiType = row.categoryLevelTopId;
  2140. this.formData.sourceBizNo = row.receiveNo;
  2141. this.formData.fromId = row.id;
  2142. this.formData.clientName = row.partaName;
  2143. this.formData.clientCode = row.partaId;
  2144. // const data = await oneId(row.id);
  2145. // if (this.warehousingMaterialList.length == 0) {
  2146. // let list = data.productList.map((item) => {
  2147. // return {
  2148. // ...item,
  2149. // assetName: item.productName,
  2150. // assetCode: item.productCode,
  2151. // categoryId: item.productCategoryId,
  2152. // minPackUnit: item.packingUnit
  2153. // };
  2154. // });
  2155. // await this.onSelectTableData(await this.serachMainCode(list));
  2156. // }
  2157. // // 委外发货入库(出库再入库)
  2158. // if (row.outsourceSendCode) {
  2159. this.isOutsourcing = true;
  2160. this.formData.bizType = '12';
  2161. this.title = '委外入库(非采购)';
  2162. console.log('-------this.formData----');
  2163. console.log(this.formData);
  2164. outin.getById(row.id).then(async (res) => {
  2165. console.log('-------res--------res-------');
  2166. console.log(res);
  2167. if (res.outInDetailVOList && res.outInDetailVOList.length > 0) {
  2168. const batchNo = await getCode('lot_number_code');
  2169. this.warehousingMaterialList = [];
  2170. this.resultArray = [];
  2171. let arr = res.outInDetailVOList.map(async (goodsiItem) => {
  2172. return new Promise(async (outResolve) => {
  2173. goodsiItem.isSave = true;
  2174. goodsiItem.houseList = [];
  2175. goodsiItem.batchNo = batchNo;
  2176. goodsiItem.assetName = goodsiItem.name;
  2177. goodsiItem.assetCode = goodsiItem.categoryCode;
  2178. goodsiItem.outInNum =
  2179. goodsiItem.packingCount < 1 ? 1 : goodsiItem.packingCount;
  2180. goodsiItem.minPackingCount = goodsiItem.minPackingCount;
  2181. goodsiItem.minPackUnit = goodsiItem.packingUnit;
  2182. this.warehousingMaterialList.push(goodsiItem);
  2183. let res = await outin.getAssetNum({
  2184. assetCode: goodsiItem.assetCode,
  2185. batchNum: goodsiItem.batchNo,
  2186. num: goodsiItem.outInNum < 1 ? 1 : goodsiItem.outInNum
  2187. });
  2188. let arr = goodsiItem.outInDetailRecordVOList.map(
  2189. (wrapItem, index) => {
  2190. return new Promise(async (resolve) => {
  2191. wrapItem.onlyCode = res.shift().onlyCode;
  2192. wrapItem.packingCount =
  2193. wrapItem.packingCount < 1 ? 1 : wrapItem.packingCount;
  2194. wrapItem.isPack = true;
  2195. wrapItem.minPackingCount = wrapItem.totalCount;
  2196. wrapItem.assetName = goodsiItem.name;
  2197. wrapItem.assetCode = goodsiItem.categoryCode;
  2198. wrapItem.batchNo = batchNo;
  2199. wrapItem.result =
  2200. wrapItem.result === null ? '' : String(wrapItem.result);
  2201. // wrapItem.count =
  2202. // wrapItem.outInDetailRecordMaterialDetailVOList.length; // 增加包装计量数量
  2203. // 增加内部重量(解决重量未保存同时参与计算问题)
  2204. wrapItem.initWeight = wrapItem.weight;
  2205. if (
  2206. wrapItem.outInDetailRecordMaterialDetailVOList?.length >
  2207. 0
  2208. ) {
  2209. wrapItem.outInDetailRecordMaterialDetailVOList.forEach(
  2210. (materialItem, index) => {
  2211. materialItem.id = '';
  2212. materialItem.onlyCode = wrapItem.onlyCode;
  2213. materialItem.no =
  2214. materialItem.onlyCode +
  2215. index.toString().padStart(4, '0');
  2216. materialItem.result =
  2217. materialItem.result === null
  2218. ? ''
  2219. : String(materialItem.result);
  2220. materialItem.batchNo = batchNo;
  2221. materialItem.minPackingCount = 1;
  2222. materialItem.isPack = true;
  2223. // 增加内部重量(解决重量未保存同时参与计算问题)
  2224. materialItem.initWeight = materialItem.weight;
  2225. this.resultArray.push(materialItem);
  2226. }
  2227. );
  2228. }
  2229. resolve(wrapItem);
  2230. });
  2231. }
  2232. );
  2233. Promise.all(arr).then((data) => {
  2234. console.log(goodsiItem);
  2235. goodsiItem.warehouseLedgerDetails = data;
  2236. outResolve(goodsiItem);
  2237. });
  2238. });
  2239. });
  2240. Promise.all(arr).then((data) => {
  2241. console.log(this.warehousingMaterialList);
  2242. console.log(this.resultArray);
  2243. this.warehousingMaterialList = data;
  2244. if (this.resultArray.length > 0) {
  2245. this.isSplit = true;
  2246. }
  2247. });
  2248. }
  2249. });
  2250. // } else {
  2251. // this.formData.bizType = '2';
  2252. // this.title = '采购入库';
  2253. // }
  2254. },
  2255. async pickerSuccess(row) {
  2256. this.pickerRow = row;
  2257. this.formData.extInfo.documentSource = row.orderNo;
  2258. this.formData.clientName = row.partaName;
  2259. this.formData.clientCode = row.partaId;
  2260. this.formData.extInfo.supplierName = row.partbName;
  2261. this.formData.extInfo.supplierId = row.partbId;
  2262. await this.searchContact(row.partbId);
  2263. const data = await oneId(row.id);
  2264. if (this.warehousingMaterialList.length == 0) {
  2265. console.log('data===', data);
  2266. let list = data.data.productList.map((item) => {
  2267. return {
  2268. ...item,
  2269. assetName: item.productName,
  2270. assetCode: item.productCode,
  2271. categoryId: item.productCategoryId,
  2272. minPackUnit: item.packingUnit
  2273. };
  2274. });
  2275. this.onSelectTableData(await this.serachMainCode(list));
  2276. }
  2277. },
  2278. async serachMainCode(arr) {
  2279. let newArr = [];
  2280. // 使用 Promise.all 来等待所有异步操作完成
  2281. await Promise.all(
  2282. arr.map(async (item) => {
  2283. const data = await getProductList({
  2284. pageNum: 1,
  2285. size: 10,
  2286. categoryLevelId: item.categoryLevelPathIdParent,
  2287. code: item.assetCode
  2288. });
  2289. newArr.push(data.list); // 将结果存储到 newArr 中
  2290. })
  2291. );
  2292. let re = [];
  2293. for (const item of newArr) {
  2294. for (const it of item) {
  2295. re.push(it);
  2296. }
  2297. }
  2298. return re.map((item) => {
  2299. return {
  2300. ...item,
  2301. minPackUnit: item.packingUnit,
  2302. assetCode: item.code,
  2303. assetName: item.name
  2304. };
  2305. });
  2306. },
  2307. onClear() {
  2308. this.formData.extInfo.documentSource = '';
  2309. this.pickerRow = {};
  2310. this.outsourcedOrdersRow = {};
  2311. this.formData.clientName = '';
  2312. this.formData.clientCode = '';
  2313. this.formData.extInfo.supplierName = '';
  2314. this.formData.extInfo.supplierId = '';
  2315. this.$forceUpdate();
  2316. },
  2317. handleStockOutOrder() {
  2318. this.$refs.stockOutOrderRef.open();
  2319. },
  2320. handleOutsourcedOrders() {
  2321. this.$refs.outsourcedOrdersRef.open();
  2322. },
  2323. handlePicker() {
  2324. this.$refs.pickerRef.open();
  2325. },
  2326. codeListValue(val) {
  2327. this.formData.extInfo.assetType = val.id;
  2328. this.$forceUpdate();
  2329. this.title = val?.name;
  2330. this.selectEquiType = val?.id;
  2331. },
  2332. //计算生产设备重量
  2333. deviceWeight(row, num) {
  2334. if (row) {
  2335. return Number(row * num);
  2336. } else {
  2337. return row;
  2338. }
  2339. },
  2340. //计算金额
  2341. calcSumTotal(PackingCount, outInNum, univalence) {
  2342. //最小包装单元,包装数量,单价
  2343. const total = {
  2344. PackingCount: Number(PackingCount > 0 ? PackingCount : 0),
  2345. outInNum: Number(outInNum > 0 ? outInNum : 0),
  2346. univalence: Number(univalence > 0 ? univalence : 0)
  2347. };
  2348. return Number(
  2349. this.$math.format(
  2350. total.PackingCount * total.outInNum * total.univalence,
  2351. 14
  2352. )
  2353. );
  2354. },
  2355. handleRowUnit(row) {
  2356. return row.measuringUnit;
  2357. // if (this.formData.extInfo.assetType == 1) {
  2358. // return row.weightUnit;
  2359. // } else if (this.formData.extInfo.assetType == 4) {
  2360. // return row.measuringUnit;
  2361. // } else {
  2362. // return row.measuringUnit;
  2363. // }
  2364. },
  2365. changeVerfy(it) {
  2366. this.formData.verifyName = it.name;
  2367. },
  2368. //选择供应啥的操作
  2369. ChangeSupplier(data) {
  2370. this.formData.extInfo.supplierName = data.dictValue;
  2371. },
  2372. ChangeSuppliers(data) {
  2373. this.formData.clientName = data.dictValue;
  2374. },
  2375. rowClass({ row, column, rowIndex, columnIndex }) {
  2376. if (rowIndex === 1) {
  2377. return {
  2378. display: 'none',
  2379. background: '#EEEEEE',
  2380. border: 'none'
  2381. };
  2382. }
  2383. return { background: '#EEEEEE', border: 'none' };
  2384. },
  2385. calcSum(a, b, c, row) {
  2386. if (
  2387. (Number.isNaN(+a) && a !== '') ||
  2388. (Number.isNaN(+b) && b !== '') ||
  2389. (Number.isNaN(+c) && c !== '')
  2390. ) {
  2391. return '';
  2392. }
  2393. return a * b * c + { yuan: '元', wanyuan: '万元' }[row.univalenceUnit];
  2394. // return a * b * c;
  2395. },
  2396. // 部门 点击事件
  2397. async auditorDeptClick(data) {
  2398. this.formData.extInfo.verifyDeptCode = data?.id;
  2399. this.formData.extInfo.verifyDeptName = data?.name;
  2400. this.formData.verifyId = '';
  2401. this.formData.verifyName = '';
  2402. this.$refs.formName.validateField('verifyDeptName');
  2403. if (data) {
  2404. this.getStaffList(data);
  2405. }
  2406. },
  2407. async getStaffList(data) {
  2408. let res = await warehouseDefinition.getUserPage({
  2409. groupId: data.id,
  2410. size: 9999,
  2411. page: 1
  2412. });
  2413. this.staffList = res.list;
  2414. },
  2415. // 详情接口
  2416. // async _getInfo () {
  2417. // const res = await getInfo({ id: this.$route.query.id })
  2418. // if (res?.success) {
  2419. // this.warehousingMaterialList = res.data.warehouseLedgerInfos.map(i => {
  2420. // i.isSave = true
  2421. // return i
  2422. // })
  2423. // this.formData = res.data.outInWarehouse
  2424. // this.uploadList = this.formData.contentImage
  2425. // }
  2426. // },
  2427. chooseAssets(row, index) {
  2428. this.$refs.returnSelectRef.open(row, (res) => {
  2429. row.outInNum = res.length;
  2430. this.$set(
  2431. row,
  2432. 'selfWarehouseLedgerDetails',
  2433. res.map((i) => {
  2434. delete i.updateTime;
  2435. delete i.createTime;
  2436. return i;
  2437. })
  2438. );
  2439. });
  2440. },
  2441. // 仓库编辑
  2442. handleWareHouse(row, idx) {
  2443. this.$refs.wareHouseDailogRef.open(row, idx);
  2444. },
  2445. // 入库操作
  2446. listEdit(row) {
  2447. this.$set(row, 'isSave', false);
  2448. row.selfWarehouseLedgerDetails = row.warehouseLedgerDetails;
  2449. row.warehouseLedgerDetails = [];
  2450. // 重置重量
  2451. this.packNum(row, row.outInNum);
  2452. // 清空物料明细防止数据错乱
  2453. if (this.isSplit && this.resultArray?.length > 0) {
  2454. this.handleIsDetail(false);
  2455. }
  2456. },
  2457. listSave(row, index) {
  2458. console.log('---------');
  2459. if (this.isSplit && this.resultArray?.length > 0) {
  2460. this.handleIsDetail(false);
  2461. }
  2462. let fileds = [];
  2463. if (this.clientEnvironmentId != 2) {
  2464. fileds = [
  2465. // `warehousingMaterialList.${index}.cargoSpaceCode`,
  2466. `warehousingMaterialList.${index}.batchNo`,
  2467. `warehousingMaterialList.${index}.houseList`
  2468. ];
  2469. } else {
  2470. fileds = [`warehousingMaterialList.${index}.houseList`];
  2471. }
  2472. if (this.formData.bizType == 1) {
  2473. // fileds.push(...[`warehousingMaterialList.${index}.customCode`]);
  2474. } else if (this.formData.bizType == 2) {
  2475. // fileds.push(...[`warehousingMaterialList.${index}.supplierCode`]);
  2476. }
  2477. if (this.formData.bizType != 5) {
  2478. fileds.push(
  2479. ...[
  2480. `warehousingMaterialList.${index}.outInNum`,
  2481. `warehousingMaterialList.${index}.minPackingCount`
  2482. ]
  2483. );
  2484. } else if (
  2485. this.warehousingMaterialList.some(
  2486. (i) => !i.selfWarehouseLedgerDetails?.length
  2487. )
  2488. ) {
  2489. this.$message.error('请选择资产编号!');
  2490. return;
  2491. }
  2492. console.log('---------------------');
  2493. Promise.all(
  2494. fileds.map(
  2495. (item) =>
  2496. new Promise(async (resolve, rej) => {
  2497. this.$refs.warehousingMaterialListRef.validateField(
  2498. item,
  2499. (err) => {
  2500. if (err) {
  2501. rej(err);
  2502. } else {
  2503. resolve();
  2504. }
  2505. }
  2506. );
  2507. })
  2508. )
  2509. )
  2510. .then((res) => {
  2511. this.$set(row, 'isSave', true);
  2512. if (this.formData.bizType != 5) {
  2513. this.createMaterialCode(row);
  2514. } else {
  2515. // 退还
  2516. this.createMaterialCodeReturn(row);
  2517. }
  2518. })
  2519. .catch((err) => {
  2520. this.$message.error('请填入必填项!');
  2521. });
  2522. },
  2523. listSaveArrs() {
  2524. // 已经拆分(还原到未拆封编辑状态)
  2525. if (this.isSplit && this.resultArray.length > 0) {
  2526. this.handleIsDetail(false);
  2527. }
  2528. const rows = this.warehousingMaterialList;
  2529. const indexes = Array.from(
  2530. { length: this.warehousingMaterialList.length },
  2531. (_, index) => index
  2532. );
  2533. let showMessage = true;
  2534. rows.forEach((row, i) => {
  2535. const index = indexes[i];
  2536. let fileds = [];
  2537. if (this.clientEnvironmentId != 2) {
  2538. fileds = [
  2539. // `warehousingMaterialList.${index}.cargoSpaceCode`,
  2540. `warehousingMaterialList.${index}.batchNo`,
  2541. `warehousingMaterialList.${index}.houseList`
  2542. ];
  2543. } else {
  2544. fileds = [`warehousingMaterialList.${index}.houseList`];
  2545. }
  2546. if (this.formData.bizType == 1) {
  2547. // fileds.push(...[`warehousingMaterialList.${index}.customCode`]);
  2548. } else if (this.formData.bizType == 2) {
  2549. // fileds.push(...[`warehousingMaterialList.${index}.supplierCode`]);
  2550. }
  2551. if (this.formData.bizType != 5) {
  2552. fileds.push(
  2553. ...[
  2554. `warehousingMaterialList.${index}.outInNum`,
  2555. `warehousingMaterialList.${index}.minPackingCount`
  2556. ]
  2557. );
  2558. } else if (
  2559. this.warehousingMaterialList.some(
  2560. (i) => !i.selfWarehouseLedgerDetails?.length
  2561. )
  2562. ) {
  2563. this.$message.error('请选择资产编号!');
  2564. return;
  2565. }
  2566. Promise.all(
  2567. fileds.map(
  2568. (item) =>
  2569. new Promise(async (resolve, rej) => {
  2570. this.$refs.warehousingMaterialListRef.validateField(
  2571. item,
  2572. (err) => {
  2573. if (err) {
  2574. rej(err);
  2575. } else {
  2576. resolve();
  2577. }
  2578. }
  2579. );
  2580. })
  2581. )
  2582. )
  2583. .then((res) => {
  2584. this.$set(row, 'isSave', true);
  2585. if (this.formData.bizType != 5) {
  2586. this.createMaterialCode(row);
  2587. } else {
  2588. // 退还
  2589. this.createMaterialCodeReturn(row);
  2590. }
  2591. })
  2592. .catch((err) => {
  2593. if (showMessage) {
  2594. showMessage = false;
  2595. this.$message.error('请填入必填项!');
  2596. }
  2597. });
  2598. });
  2599. },
  2600. // listSaveArrs() {
  2601. // console.log(this.warehousingMaterialList);
  2602. // },
  2603. // 批量设置生产日期
  2604. handleSelectionChange(val) {
  2605. this.materialCodeReqListSelected = val;
  2606. },
  2607. dateSetting() {
  2608. if (!this.materialCodeReqListSelected.length) {
  2609. return this.$message.error(`请选择${this.title}明细!`);
  2610. }
  2611. this.dateVisible = true;
  2612. },
  2613. dateConfirm() {
  2614. this.materialCodeReqListSelected.forEach((item) => {
  2615. this.$set(item, this.curDateType, this.batchTime);
  2616. });
  2617. this.dateVisible = false;
  2618. },
  2619. //入库明细删除
  2620. listDel(row, index) {
  2621. this.warehousingMaterialList.splice(index, 1);
  2622. if (this.isSplit && this.resultArray?.length > 0) {
  2623. this.handleIsDetail(false);
  2624. }
  2625. },
  2626. // 入库明细生成条码信息
  2627. async createMaterialCode(row) {
  2628. // 添加相同物品、批次号重新更新明细 原料编码
  2629. const list = this.warehousingMaterialList.filter(
  2630. (i) =>
  2631. i.assetCode === row.assetCode &&
  2632. i.batchNo === row.batchNo &&
  2633. i.isSave
  2634. );
  2635. const num = list.reduce((num, pre) => {
  2636. num += row.isUnpack
  2637. ? Number(this.$math.format(pre.outInNum * pre.minPackingCount, 14))
  2638. : pre.outInNum - 0;
  2639. return num;
  2640. }, 0);
  2641. const nums = list.reduce((num, pre) => {
  2642. num += Number(
  2643. this.$math.format(pre.outInNum * pre.minPackingCount, 14)
  2644. );
  2645. return num;
  2646. }, 0);
  2647. const res = await outin.getAssetNum({
  2648. assetCode: row.assetCode,
  2649. batchNum: row.batchNo,
  2650. num: num
  2651. });
  2652. // row.measuringUnit == 'PCS' ? nums :
  2653. list.forEach((item) => {
  2654. if (item.warehouseLedgerDetails?.length) {
  2655. item.warehouseLedgerDetails.forEach((i) => {
  2656. i.onlyCode = res.shift().onlyCode;
  2657. });
  2658. } else {
  2659. this.$set(
  2660. item,
  2661. 'warehouseLedgerDetails',
  2662. Array.from(
  2663. new Array(
  2664. item.isUnpack
  2665. ? Number(
  2666. this.$math.format(
  2667. item.outInNum * item.minPackingCount,
  2668. 14
  2669. )
  2670. )
  2671. : // : item.measuringUnit == 'PCS'
  2672. // ? +item.outInNum * parseInt(item.minPackingCount)
  2673. +item.outInNum
  2674. ),
  2675. (val, idx) => {
  2676. return {
  2677. ...item,
  2678. onlyCode: res.shift().onlyCode,
  2679. bizStatus: 1,
  2680. contentImage: []
  2681. };
  2682. }
  2683. )
  2684. );
  2685. }
  2686. });
  2687. // 添加相同物品,重复批次号 重新更新明细 包装编码
  2688. const batchList = this.warehousingMaterialList.filter(
  2689. (i) => i.batchNo === row.batchNo && i.isSave
  2690. );
  2691. if (batchList.length) {
  2692. const num = batchList.reduce((num, pre) => {
  2693. num += +pre.outInNum;
  2694. return num;
  2695. }, 0);
  2696. const res1 = await outin.getAssetNum({
  2697. batchNum: row.batchNo,
  2698. num
  2699. });
  2700. if (res1) {
  2701. batchList.forEach((item) => {
  2702. let num = res1.shift()?.num;
  2703. let minPackingCount = item.minPackingCount;
  2704. if (item.warehouseLedgerDetails?.length) {
  2705. item.warehouseLedgerDetails.forEach((i, index) => {
  2706. this.$set(i, 'num', num);
  2707. console.log('i---', i);
  2708. console.log('row---', row);
  2709. if (row.code == i.code) {
  2710. if (item.measuringUnit == item.weightUnit) {
  2711. this.$set(i, 'weight', item.minPackingCount);
  2712. this.$set(i, 'initWeight', item.minPackingCount);
  2713. } else {
  2714. this.$set(
  2715. i,
  2716. 'weight',
  2717. Number(
  2718. this.$math.format(
  2719. 1 * item.minPackingCount * item.netWeight,
  2720. 14
  2721. )
  2722. )
  2723. );
  2724. this.$set(
  2725. i,
  2726. 'initWeight',
  2727. Number(
  2728. this.$math.format(
  2729. 1 * item.minPackingCount * item.netWeight,
  2730. 14
  2731. )
  2732. )
  2733. );
  2734. }
  2735. }
  2736. this.$set(i, 'weightUtil', item.weightUnit);
  2737. this.$set(i, 'packingCount', 1);
  2738. this.$set(i, 'packingUnit ', item.packingUnit);
  2739. this.$set(i, 'minPackingCount ', item.minPackingCount);
  2740. this.$set(i, 'measuringUnit', item.measuringUnit);
  2741. this.$set(i, 'isPack', false);
  2742. this.$set(i, 'result', '0');
  2743. this.$set(i, 'status', '1');
  2744. // if (this.formData.extInfo.assetType == 1) {
  2745. // this.$set(i, 'status', '0');
  2746. // } else {
  2747. // this.$set(i, 'result', '0');
  2748. // this.$set(i, 'status', '1');
  2749. // }
  2750. if (!item.isUnpack) {
  2751. if (index < item.warehouseLedgerDetails.length - 1) {
  2752. num = res1.shift()?.num;
  2753. }
  2754. } else {
  2755. // 拆包的包装编码一致
  2756. minPackingCount--;
  2757. if (
  2758. minPackingCount === 0 &&
  2759. index < item.warehouseLedgerDetails.length - 1
  2760. ) {
  2761. minPackingCount = item.minPackingCount;
  2762. num = res1.shift()?.num;
  2763. }
  2764. }
  2765. });
  2766. }
  2767. });
  2768. }
  2769. }
  2770. },
  2771. // 入库明细生成条码信息 退还
  2772. async createMaterialCodeReturn(row) {
  2773. // 添加相同物品重新更新明细 原料编码
  2774. const list = this.warehousingMaterialList.filter(
  2775. (i) => i.batchNo === row.batchNo && i.isSave
  2776. );
  2777. // 退还
  2778. const res = await getAssetNum({
  2779. batchNo: row.batchNo,
  2780. num: list.reduce((num, pre) => {
  2781. num += pre.selfWarehouseLedgerDetails.length;
  2782. return num;
  2783. }, 0)
  2784. });
  2785. if (res?.success) {
  2786. list.forEach((item) => {
  2787. let num = res.data.shift().num;
  2788. let minPackingCount = item.minPackingCount;
  2789. if (item.warehouseLedgerDetails?.length) {
  2790. item.warehouseLedgerDetails.forEach((i, index) => {
  2791. Object.assign(i, {
  2792. num,
  2793. manualBatchNo: item.manualBatchNo,
  2794. batchNo: item.batchNo,
  2795. cargoSpaceCode: item.cargoSpaceCode, //货位编码
  2796. cargoSpaceId: item.cargoSpaceId, //货位id
  2797. shelfId: item.shelfId, //货架id
  2798. shelfCode: item.shelfCode, //货架名称
  2799. areaId: item.areaId, //库区id
  2800. areaName: item.areaName, //库区名称
  2801. warehouseId: item.warehouseId, //仓库id
  2802. warehouseName: item.warehouseName //仓库名称
  2803. });
  2804. if (!item.isUnpack) {
  2805. // 拆包的包装编码一致
  2806. if (index < item.warehouseLedgerDetails.length - 1) {
  2807. num = res.data.shift()?.num;
  2808. }
  2809. } else {
  2810. minPackingCount--;
  2811. if (
  2812. minPackingCount === 0 &&
  2813. index < item.warehouseLedgerDetails.length - 1
  2814. ) {
  2815. minPackingCount = item.minPackingCount;
  2816. num = res1.data.shift()?.num;
  2817. }
  2818. }
  2819. });
  2820. } else {
  2821. this.$set(
  2822. item,
  2823. 'warehouseLedgerDetails',
  2824. item.selfWarehouseLedgerDetails.map((val, idx) => {
  2825. let obj = {
  2826. ...val,
  2827. bizStatus: 1,
  2828. minPackingCount: item.minPackingCount,
  2829. batchNo: item.batchNo,
  2830. cargoSpaceCode: item.cargoSpaceCode, //货位编码
  2831. cargoSpaceId: item.cargoSpaceId, //货位id
  2832. shelfId: item.shelfId, //货架id
  2833. shelfCode: item.shelfCode, //货架名称
  2834. areaId: item.areaId, //库区id
  2835. areaName: item.areaName, //库区名称
  2836. warehouseId: item.warehouseId, //仓库id
  2837. warehouseName: item.warehouseName, //仓库名称
  2838. materialId: item.materialId,
  2839. num
  2840. };
  2841. if (!item.isUnpack) {
  2842. // 拆包的包装编码一致
  2843. if (idx < item.warehouseLedgerDetails.length - 1) {
  2844. num = res.data.shift()?.num;
  2845. }
  2846. } else {
  2847. minPackingCount--;
  2848. if (
  2849. minPackingCount === 0 &&
  2850. idx < item.warehouseLedgerDetails.length - 1
  2851. ) {
  2852. minPackingCount = item.minPackingCount;
  2853. num = res1.data.shift()?.num;
  2854. }
  2855. }
  2856. return obj;
  2857. })
  2858. );
  2859. }
  2860. });
  2861. }
  2862. },
  2863. handleSave() {
  2864. if (this.isOutsourcing) {
  2865. if (!this.formData.extInfo.documentSource) {
  2866. this.$message.error('请选择委外申请单!');
  2867. return false;
  2868. }
  2869. let boolen = this.warehousingMaterialList.every(
  2870. (item) => item.houseList.length > 0
  2871. );
  2872. if (!boolen) {
  2873. this.$message.error('请选择产品仓库!');
  2874. return false;
  2875. }
  2876. }
  2877. this.$refs.formName.validate(async (valid) => {
  2878. if (valid) {
  2879. if (!this.warehousingMaterialList?.length) {
  2880. return this.$message.error('请添加入库明细!');
  2881. } else if (
  2882. this.warehousingMaterialList.some((item) => !item.isSave)
  2883. ) {
  2884. return this.$message.error('请保存入库明细!');
  2885. }
  2886. // 默认全部保存
  2887. if (this.resultArray?.length > 0) {
  2888. // 物料批量保存
  2889. this.materialListSave();
  2890. } else {
  2891. // 包装批量保存
  2892. this.wrapListSave();
  2893. }
  2894. this.formatWarehouseMaterialList();
  2895. let arr = this.warehousingMaterialList.map((item) => {
  2896. return {
  2897. netWeight: item.netWeight > 0 ? item.netWeight : 0,
  2898. num: item.num > 0 ? item.num : 0,
  2899. manualBatchNo: item.manualBatchNo,
  2900. batchNo: item.batchNo,
  2901. categoryId:
  2902. this.formData.bizType == 2 || this.formData.bizType == 12
  2903. ? item.categoryId
  2904. ? item.categoryId
  2905. : item.id
  2906. : item.id,
  2907. count:
  2908. item.outInNum > 0 && item.minPackingCount > 0
  2909. ? this.$math.format(
  2910. parseInt(item.outInNum) *
  2911. parseInt(item.minPackingCount),
  2912. 14
  2913. )
  2914. : 0,
  2915. minPackingCount:
  2916. item.minPackingCount > 0 ? item.minPackingCount : 0,
  2917. packingCount: item.outInNum > 0 ? item.outInNum : 0,
  2918. price: item.univalence > 0 ? item.univalence : 0,
  2919. outInDetailRecordAddPOList: item.warehouseLedgerDetails,
  2920. position: `${item.warehouseName}-${item.areaName}-${item.shelfCode}-${item.cargoSpaceCode}`,
  2921. remark: '',
  2922. pathIds: `${item.warehouseId},${item.areaId},${item.shelfId},${item.cargoSpaceId}`,
  2923. pathName: `${item.warehouseName},${item.areaName},${item.shelfCode},${item.cargoSpaceCode}`,
  2924. totalMoney:
  2925. item.outInNum > 0 &&
  2926. item.minPackingCount > 0 &&
  2927. item.univalence > 0
  2928. ? this.$math.format(
  2929. item.outInNum * item.minPackingCount * item.univalence,
  2930. 14
  2931. )
  2932. : 0,
  2933. weightUnit: item.weightUnit,
  2934. customCode: item.customCode,
  2935. supplierCode: item.supplierCode,
  2936. weight: item.weight > 0 ? item.weight : 0
  2937. };
  2938. });
  2939. arr.forEach((item) => {
  2940. if (item.outInDetailRecordAddPOList.length > 0) {
  2941. let list = item.outInDetailRecordAddPOList.map((it) => {
  2942. return this.formatOutInDetailRecordAddPO(it, item);
  2943. });
  2944. item.outInDetailRecordAddPOList = list;
  2945. }
  2946. });
  2947. let obj = { ...this.formData, type: 1 };
  2948. obj.sourceBizNo = this.formData.extInfo.documentSource;
  2949. obj.outInDetailAddPOList = arr;
  2950. console.log('=====>', obj);
  2951. this.saveLoading = true;
  2952. try {
  2953. if (obj.bizType == '12') {
  2954. obj.storageSource = 1;
  2955. }
  2956. const res = await outin.save(obj);
  2957. if (res.code == 0) {
  2958. // 委外入库(非采购)
  2959. if (obj.bizType == '12') {
  2960. await outin.outApproveQuality({ outInId: res.data[0] });
  2961. } else {
  2962. await outin.outApproves({ outInId: res.data[0] });
  2963. }
  2964. this.$message.success('保存成功!');
  2965. }
  2966. } catch (error) {
  2967. console.error('保存失败:', error);
  2968. }
  2969. this.saveLoading = false;
  2970. this.$router.push('/warehouseManagement/stockManagement');
  2971. }
  2972. });
  2973. },
  2974. formatWarehouseMaterialList() {
  2975. for (let key in this.warehousingMaterialList) {
  2976. for (let k in this.warehousingMaterialList[key].houseList) {
  2977. let house = this.warehousingMaterialList[key].houseList[k];
  2978. this.warehousingMaterialList[key].warehouseName =
  2979. house.warehouseName;
  2980. this.warehousingMaterialList[key].areaName = house.areaName;
  2981. this.warehousingMaterialList[key].shelfCode = house.shelfCode;
  2982. this.warehousingMaterialList[key].cargoSpaceCode =
  2983. house.cargoSpaceCode;
  2984. this.warehousingMaterialList[key].warehouseId = house.warehouseId;
  2985. this.warehousingMaterialList[key].areaId = house.areaId;
  2986. this.warehousingMaterialList[key].shelfId = house.shelfId;
  2987. this.warehousingMaterialList[key].cargoSpaceId = house.cargoSpaceId;
  2988. this.warehousingMaterialList[key].num = house.num;
  2989. }
  2990. }
  2991. },
  2992. formatOutInDetailRecordAddPO(it, item) {
  2993. return {
  2994. code: it.onlyCode,
  2995. dateType: this.curDateType === 'manufactureTime' ? 2 : 1,
  2996. dateValue: it[this.curDateType],
  2997. minUnit: it.minPackingCount,
  2998. minPackingCount: it.minPackingCount,
  2999. minPositionId: it.cargoSpaceId,
  3000. name: it.assetName,
  3001. pathIds: item.pathIds,
  3002. unit: it.unit,
  3003. packageNo: it.num,
  3004. clientCode: it.clientCode,
  3005. materielCode: it.materielCode,
  3006. weight: it.weight,
  3007. weightUtil: it.weightUtil,
  3008. engrave: it.engrave,
  3009. materialDetails: this.materialDetails(it.onlyCode),
  3010. packingCount: it.packingCount,
  3011. status: it.status,
  3012. result: it.result
  3013. };
  3014. },
  3015. materialDetails(onlyCode) {
  3016. return this.resultArray.filter((item) => item.onlyCode === onlyCode);
  3017. },
  3018. async getOrderCode() {
  3019. const data = await getCode('in_warehouse');
  3020. return data;
  3021. },
  3022. // 添加物品明细
  3023. addProduct(val) {
  3024. // 已经拆分(还原到未拆封编辑状态)
  3025. if (this.isSplit && this.resultArray.length > 0) {
  3026. this.handleIsDetail(false);
  3027. }
  3028. this.onSelectTableData(val);
  3029. },
  3030. //添加明细
  3031. async onSelectTableData(val) {
  3032. console.log('val-----------', val);
  3033. const res = await getCode('lot_number_code');
  3034. this.warehousingMaterialList.push(
  3035. ...val.map((next) => {
  3036. next.batchNo = res;
  3037. let cur = {};
  3038. next.realInventoryAmount = next.realInventoryAmount || 0;
  3039. cur = {
  3040. ...next,
  3041. cargoSpaceCode: '', //货位编码
  3042. cargoSpaceId: '', //货位id
  3043. shelfId: '', //货架id
  3044. shelfCode: '', //货架名称
  3045. areaId: '', //库区id
  3046. areaName: '', //库区名称
  3047. warehouseId: '', //仓库id
  3048. warehouseName: '', //仓库名称
  3049. assetType: this.formData.extInfo.assetType,
  3050. expirationDate: '',
  3051. outInNum: '',
  3052. minPackingCount: '',
  3053. bizStatus: 1,
  3054. contentImage: [],
  3055. warehouseLedgerDetails: [],
  3056. houseList: []
  3057. };
  3058. return cur;
  3059. })
  3060. );
  3061. },
  3062. async initData() {
  3063. const { data } = await getTreeByGroup({ type: 2 });
  3064. this.codeList = data;
  3065. // .map((item) => {
  3066. // return { dictCode: item.id, dictValue: item.name };
  3067. // });
  3068. const res = await warehouseDefinition.tree();
  3069. this.treeList = this.$util.toTreeData({
  3070. data: res,
  3071. idField: 'id',
  3072. parentIdField: 'parentId'
  3073. });
  3074. // const res111 = await warehouseDefinition.list();
  3075. // this.warehouseList = res111.list;
  3076. let res22 = await warehouseDefinition.getUserPage({
  3077. size: -1,
  3078. page: 1
  3079. });
  3080. this.fromUserList = res22.list;
  3081. const info = JSON.parse(localStorage.getItem('info'));
  3082. let obj = res.find(
  3083. (item) => item.id === info.deptId[info.deptId.length - 1]
  3084. );
  3085. if (!obj) return;
  3086. this.formData.extInfo.deptCode = obj.id;
  3087. this.formData.extInfo.deptName = obj.name;
  3088. this.formData.extInfo.createUserName = info.name;
  3089. this.formData.createUserId = info.id;
  3090. // this.treeList = res;
  3091. // this.formData.extInfo.deptCode =
  3092. // this.getTreeList().then((res) => {
  3093. // if (res?.success) {
  3094. // this.treeList = res.data;
  3095. // }
  3096. // });
  3097. // this.getSupplier().then((res) => {
  3098. // if (res?.success) {
  3099. // this.supplierList = res.data.items;
  3100. // }
  3101. // });
  3102. // this.getStaffList();
  3103. },
  3104. addStock() {
  3105. // this.$refs.wareHouseDailogRef.open({});
  3106. // return;
  3107. if (!this.title) return this.$message.error('请选择入库产品类型');
  3108. if (!this.formData.bizType)
  3109. return this.$message.error('请选择入库场景');
  3110. if (
  3111. this.formData.bizType == 12 &&
  3112. !this.formData.extInfo.documentSource
  3113. ) {
  3114. return this.$message.error('请选择委外申请单');
  3115. }
  3116. this.visibleDialog = true;
  3117. },
  3118. handleChange(data) {
  3119. this.title = data?.dictValue;
  3120. this.selectEquiType = data?.dictCode;
  3121. },
  3122. handleChanges(code) {
  3123. const data = this.codeList.find((item) => item.dictCode == code);
  3124. this.title = data?.dictValue;
  3125. this.selectEquiType = data?.dictCode;
  3126. },
  3127. getSupplier() {
  3128. return new Promise((resolve, reject) => {
  3129. supplier.list({ page: 1, size: 999 }).then((res) => {
  3130. if (res.success) {
  3131. resolve(res);
  3132. }
  3133. });
  3134. });
  3135. },
  3136. getTreeList() {
  3137. return new Promise((resolve, reject) => {
  3138. org.tree().then((res) => {
  3139. if (res.success) {
  3140. resolve(res);
  3141. }
  3142. });
  3143. });
  3144. },
  3145. upload(data) {
  3146. this.formData.contentImage = data;
  3147. this.$refs.formName.validateField('contentImage');
  3148. },
  3149. houseData(argum, idx) {
  3150. this.$set(this.warehousingMaterialList[idx], 'houseList', argum);
  3151. }
  3152. },
  3153. watch: {
  3154. // 解决右侧悬浮操作栏不对称问题
  3155. warehousingMaterialList: {
  3156. handler() {
  3157. this.$nextTick(() => {
  3158. this.$refs.warehousingMaterialListTable?.doLayout();
  3159. });
  3160. },
  3161. deep: true
  3162. },
  3163. // 解决右侧悬浮操作栏不对称问题
  3164. materialCodeReqList: {
  3165. handler() {
  3166. this.$nextTick(() => {
  3167. this.$refs.materialCodeReqListTable?.doLayout();
  3168. });
  3169. },
  3170. deep: true
  3171. },
  3172. // 解决右侧悬浮操作栏不对称问题
  3173. resultArray: {
  3174. handler() {
  3175. this.$nextTick(() => {
  3176. this.$refs.resultArrayTable?.doLayout();
  3177. });
  3178. },
  3179. deep: true
  3180. }
  3181. }
  3182. };
  3183. </script>
  3184. <style lang="scss" scoped>
  3185. ::v-deep .el-row {
  3186. display: flex;
  3187. flex-wrap: wrap;
  3188. }
  3189. ::v-deep.form-table {
  3190. .el-form-item {
  3191. margin-bottom: 0;
  3192. }
  3193. .el-input__inner {
  3194. padding: 0 10px;
  3195. }
  3196. ::-webkit-scrollbar {
  3197. width: 8px;
  3198. height: 8px;
  3199. background-color: transparent;
  3200. }
  3201. }
  3202. .p20 {
  3203. padding: 20px;
  3204. }
  3205. .el-select,
  3206. .el-date-editor {
  3207. width: 100%;
  3208. }
  3209. .el-form-item {
  3210. margin-bottom: 22px;
  3211. }
  3212. .material {
  3213. margin-top: 20px;
  3214. .flex {
  3215. display: flex;
  3216. justify-content: space-between;
  3217. font-size: 14px;
  3218. align-items: center;
  3219. .red {
  3220. color: #ff4949;
  3221. }
  3222. }
  3223. }
  3224. .mt10 {
  3225. margin-top: 10px;
  3226. }
  3227. .mt20 {
  3228. margin-top: 20px;
  3229. }
  3230. .center {
  3231. text-align: center;
  3232. }
  3233. .switch_left li {
  3234. border-right: 1px solid rgba(222, 222, 222, 1);
  3235. border-left: 1px solid rgba(222, 222, 222, 1);
  3236. }
  3237. .fontOmitted {
  3238. text-overflow: ellipsis;
  3239. overflow: hidden;
  3240. word-break: break-all;
  3241. white-space: nowrap;
  3242. }
  3243. .table-fixed {
  3244. .el-table__fixed-right {
  3245. height: 100% !important;
  3246. }
  3247. .el-table__fixed-left {
  3248. height: 100% !important;
  3249. }
  3250. .el-table__fixed {
  3251. height: 100% !important;
  3252. }
  3253. }
  3254. </style>