add.vue 86 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554
  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. :options="codeList"
  69. :props="{
  70. value: 'id',
  71. label: 'name',
  72. children: 'children'
  73. }"
  74. @getValue="codeListValue"
  75. :isAll="false"
  76. />
  77. </el-form-item>
  78. </el-col>
  79. <el-col :span="8">
  80. <el-form-item label="入库类型" prop="bizType">
  81. <el-select
  82. @change="onClear"
  83. filterable
  84. placeholder="请选择"
  85. v-model="formData.bizType"
  86. clearable
  87. :disabled="
  88. !!(warehousingMaterialList && warehousingMaterialList.length)
  89. "
  90. >
  91. <el-option
  92. v-for="item in sceneState"
  93. :key="item.code"
  94. :value="item.code + ''"
  95. :label="item.label"
  96. ></el-option>
  97. </el-select> </el-form-item
  98. ></el-col>
  99. <el-col :span="8">
  100. <el-form-item
  101. v-if="formData.bizType == 2"
  102. label="采购收货单"
  103. prop="documentSource"
  104. >
  105. <el-input
  106. placeholder="请输入"
  107. v-model="formData.extInfo.documentSource"
  108. @click.native="handlePicker()"
  109. >
  110. <el-button
  111. slot="append"
  112. icon="el-icon-circle-close"
  113. @click.stop="onClear"
  114. ></el-button>
  115. </el-input>
  116. </el-form-item>
  117. <el-form-item
  118. v-if="formData.bizType == 1"
  119. label="生产工单"
  120. prop="documentSource"
  121. >
  122. <el-input
  123. placeholder="请输入"
  124. clearable
  125. v-model="formData.extInfo.documentSource"
  126. /></el-form-item>
  127. <el-form-item
  128. v-if="
  129. formData.bizType != 1 &&
  130. formData.bizType != 2 &&
  131. formData.bizType != 3
  132. "
  133. label="销售订单"
  134. prop="documentSource"
  135. >
  136. <el-input
  137. placeholder="请输入"
  138. clearable
  139. v-model="formData.extInfo.documentSource"
  140. /></el-form-item>
  141. <el-form-item
  142. v-if="formData.bizType == 3"
  143. label="出库单"
  144. prop="documentSource"
  145. >
  146. <el-input
  147. placeholder="请输入"
  148. clearable
  149. v-model="formData.extInfo.documentSource"
  150. /></el-form-item>
  151. </el-col>
  152. <el-col :span="8">
  153. <el-form-item label="权属部门" prop="deptName">
  154. <el-input
  155. placeholder="权属部门"
  156. disabled
  157. v-model="formData.extInfo.deptName"
  158. clearable
  159. />
  160. </el-form-item>
  161. </el-col>
  162. <el-col :span="8">
  163. <el-form-item label="入库登记人">
  164. <el-input
  165. placeholder="登记人"
  166. disabled
  167. v-model="formData.extInfo.createUserName"
  168. clearable /></el-form-item
  169. ></el-col>
  170. <!-- <el-col :span="8">
  171. <el-form-item label="入库时间" prop="outInTime">
  172. <el-date-picker
  173. v-model="formData.outInTime"
  174. clearable
  175. type="datetime"
  176. value-format="yyyy-MM-dd HH:mm:ss"
  177. placeholder="选择日期"
  178. >
  179. </el-date-picker></el-form-item
  180. ></el-col> -->
  181. <el-col :span="8" v-if="formData.bizType == 2">
  182. <el-form-item label="供应商" prop="supplierName">
  183. <!-- <DictSelection
  184. dictName="经销商列表"
  185. clearable
  186. v-model="formData.extInfo.supplierId"
  187. @itemChange="ChangeSupplier"
  188. /> -->
  189. <el-input
  190. placeholder="请输入"
  191. clearable
  192. v-model="formData.extInfo.supplierName"
  193. />
  194. </el-form-item>
  195. </el-col>
  196. <!-- <el-col :span="8" v-if="formData.bizType == 2">
  197. <el-form-item label="物料代号" prop="supplierCode">
  198. <el-input
  199. placeholder="请输入"
  200. v-model="formData.supplierCode"
  201. clearable /></el-form-item
  202. ></el-col> -->
  203. <!-- <el-col :span="8" v-if="formData.bizType == 2">
  204. <el-form-item label="客户" prop="clientName">
  205. <el-input
  206. placeholder="请输入"
  207. clearable
  208. v-model="formData.clientName"
  209. />
  210. </el-form-item>
  211. </el-col> -->
  212. <!-- <el-col :span="8" v-if="formData.bizType == 2">
  213. <el-form-item label="客户代号" prop="clientCode">
  214. <el-input
  215. placeholder="请输入"
  216. v-model="formData.clientCode"
  217. clearable /></el-form-item
  218. ></el-col> -->
  219. <!-- <el-col :span="8">
  220. <el-form-item label="送货人" prop="fromUser">
  221. <el-input
  222. placeholder="请输入"
  223. v-model="formData.fromUser"
  224. clearable /></el-form-item
  225. ></el-col> -->
  226. <el-col :span="8">
  227. <el-form-item label="送货人" prop="fromUser">
  228. <el-input
  229. placeholder="请输入"
  230. v-model="formData.fromUser"
  231. clearable
  232. />
  233. <!-- <el-select
  234. v-model="formData.fromUser"
  235. filterable
  236. placeholder="请选择送货人"
  237. >
  238. <el-option
  239. v-for="item in contactList"
  240. :key="item.id"
  241. :label="item.linkName"
  242. :value="item.id"
  243. @click.native="
  244. () => (formData.extInfo.deliveryPhone = item.mobilePhone)
  245. "
  246. >
  247. </el-option>
  248. </el-select> -->
  249. </el-form-item></el-col
  250. >
  251. <el-col :span="8">
  252. <el-form-item label="送货人联系方式" prop="deliveryPhone">
  253. <el-input
  254. placeholder="请输入"
  255. v-model="formData.extInfo.deliveryPhone"
  256. clearable /></el-form-item
  257. ></el-col>
  258. <!-- <el-col :span="8">
  259. <el-form-item label="紧急状态" prop="urgent">
  260. <el-select
  261. filterable
  262. placeholder="请选择"
  263. v-model="formData.extInfo.urgent"
  264. clearable
  265. >
  266. <el-option
  267. v-for="item in emergencyState"
  268. :key="item.code"
  269. :value="item.code"
  270. :label="item.label"
  271. ></el-option>
  272. </el-select> </el-form-item
  273. ></el-col> -->
  274. <!-- <el-col :span="8">
  275. <el-form-item label="审核人部门" prop="verifyDeptName">
  276. <selectTree
  277. ref="tree"
  278. class="form-ipt"
  279. size="medium"
  280. style="width: 100%"
  281. clearable
  282. :options="treeList"
  283. :props="{
  284. value: 'code',
  285. label: 'name',
  286. children: 'children'
  287. }"
  288. @getValue="auditorDeptClick"
  289. />
  290. </el-form-item>
  291. </el-col>
  292. <el-col :span="8">
  293. <el-form-item label="审核人" prop="verifyId">
  294. <el-select
  295. filterable
  296. class="form-ipt"
  297. style="width: 100%"
  298. v-model="formData.verifyId"
  299. placeholder="请选择"
  300. >
  301. <el-option
  302. v-for="item in staffList"
  303. :key="item.id"
  304. :label="item.name"
  305. :value="item.id"
  306. @click.native="changeVerfy(item)"
  307. >
  308. </el-option>
  309. </el-select>
  310. </el-form-item>
  311. </el-col> -->
  312. <!-- <el-col :span="24">
  313. <el-form-item label="附件" prop="contentImage">
  314. <selectUpload @getImgs="upload" :initData="uploadList" />
  315. </el-form-item>
  316. </el-col> -->
  317. <el-col :span="24">
  318. <el-form-item label="备注" prop="remark">
  319. <el-input
  320. v-model="formData.remark"
  321. clearable
  322. type="textarea"
  323. placeholder="请详细说明"
  324. :rows="4"
  325. ></el-input>
  326. </el-form-item>
  327. </el-col>
  328. </el-row>
  329. </el-form>
  330. <div class="material">
  331. <header-title title="产品信息">
  332. <el-button type="primary" @click="addStock">添加</el-button>
  333. </header-title>
  334. <div class="mt10 form-table">
  335. <el-form
  336. ref="warehousingMaterialListRef"
  337. :model="{ warehousingMaterialList: warehousingMaterialList }"
  338. :show-message="false"
  339. >
  340. <el-button
  341. v-if="warehousingMaterialList.length != 0"
  342. type="success"
  343. plain
  344. style="margin-bottom: 20px; float: right; margin-right: 20px"
  345. size="mini"
  346. @click="listSaveArrs"
  347. >批量保存</el-button
  348. >
  349. <el-table
  350. v-if="isWeight"
  351. :header-cell-style="rowClass"
  352. :max-height="300"
  353. ref="warehousingMaterialListTable"
  354. :key="formData.extInfo.assetType"
  355. :data="warehousingMaterialList"
  356. tooltip-effect="dark"
  357. style="width: 100%"
  358. stripe
  359. >
  360. <el-table-column
  361. label="序号"
  362. type="index"
  363. width="50"
  364. align="center"
  365. >
  366. </el-table-column>
  367. <el-table-column
  368. label="编码"
  369. prop="assetCode"
  370. align="center"
  371. width="130"
  372. :show-overflow-tooltip="true"
  373. ></el-table-column>
  374. <el-table-column
  375. label="名称"
  376. align="center"
  377. width="200"
  378. prop="assetName"
  379. :show-overflow-tooltip="true"
  380. ></el-table-column>
  381. <!-- <el-table-column
  382. label="客户编码"
  383. align="center"
  384. width="150"
  385. prop="customCode"
  386. v-if="formData.bizType == 1"
  387. >
  388. <template slot-scope="{ row, $index }">
  389. <template v-if="row.isSave">
  390. {{ row.customCode }}
  391. </template>
  392. <el-form-item
  393. v-else
  394. :prop="`warehousingMaterialList.${$index}.customCode`"
  395. required
  396. >
  397. <el-input v-model="row.customCode"> </el-input>
  398. </el-form-item>
  399. </template>
  400. </el-table-column>
  401. <el-table-column
  402. label="供应商编码"
  403. align="center"
  404. width="150"
  405. prop="customCode"
  406. v-if="formData.bizType == 2"
  407. >
  408. <template slot-scope="{ row, $index }">
  409. <template v-if="row.isSave">
  410. {{ row.supplierCode }}
  411. </template>
  412. <el-form-item
  413. v-else
  414. :prop="`warehousingMaterialList.${$index}.supplierCode`"
  415. required
  416. >
  417. <el-input v-model="row.supplierCode"> </el-input>
  418. </el-form-item>
  419. </template>
  420. </el-table-column> -->
  421. <el-table-column
  422. v-for="(item, index) in tableHeader"
  423. :key="index"
  424. align="center"
  425. :label="item.label"
  426. :width="item.width"
  427. :prop="item.prop"
  428. :show-overflow-tooltip="true"
  429. >
  430. <template slot-scope="{ row }">
  431. <template v-if="item.formatter">{{
  432. item.formatter(row)
  433. }}</template>
  434. <template v-else>{{ row[item.prop] }}</template>
  435. </template>
  436. </el-table-column>
  437. <el-table-column
  438. label="批次号"
  439. prop="batchNo"
  440. width="70"
  441. align="center"
  442. >
  443. <template slot-scope="{ row, $index }">
  444. <template v-if="row.isSave">
  445. {{ row.batchNo }}
  446. </template>
  447. <el-form-item
  448. v-else
  449. :prop="`warehousingMaterialList.${$index}.batchNo`"
  450. required
  451. >
  452. <!-- <el-input v-model="row.batchNo"></el-input> -->
  453. {{ row.batchNo }}
  454. </el-form-item>
  455. </template>
  456. </el-table-column>
  457. <el-table-column
  458. label="最小包装单元"
  459. align="center"
  460. prop="minPackingCount"
  461. width="100"
  462. >
  463. <el-table-column label="" prop="minPackingCount" width="100">
  464. <template slot-scope="{ row, $index }">
  465. <template v-if="row.isSave">
  466. {{ row.minPackingCount }}
  467. </template>
  468. <el-form-item
  469. v-else
  470. :prop="`warehousingMaterialList.${$index}.minPackingCount`"
  471. required
  472. >
  473. <el-input
  474. v-model="row.minPackingCount"
  475. @input="minPackingCountChange(row, $event)"
  476. >
  477. </el-input>
  478. </el-form-item>
  479. </template>
  480. </el-table-column>
  481. <el-table-column label="" prop="minPackingCount">
  482. <template slot-scope="{ row, $index }">
  483. {{ handleRowUnit(row) }} /{{ row.minPackUnit }}
  484. </template>
  485. </el-table-column>
  486. </el-table-column>
  487. <el-table-column
  488. label="包装数量"
  489. prop="outInNum"
  490. width="150"
  491. align="center"
  492. >
  493. <template slot-scope="{ row, $index }">
  494. <template v-if="row.isSave || formData.bizType == 5">
  495. {{ row.outInNum }} {{ row.minPackUnit }}
  496. </template>
  497. <el-form-item
  498. v-else
  499. :prop="`warehousingMaterialList.${$index}.outInNum`"
  500. required
  501. >
  502. <el-input
  503. v-model="row.outInNum"
  504. @input="packNum(row, $event)"
  505. >
  506. <template slot="append">
  507. {{ row.minPackUnit ? row.minPackUnit : '/' }}
  508. </template>
  509. </el-input>
  510. </el-form-item>
  511. </template>
  512. </el-table-column>
  513. <el-table-column label="计量数量" prop="counts">
  514. <template slot-scope="{ row, $index }">
  515. {{ row.minPackingCount * row.outInNum }}
  516. </template>
  517. </el-table-column>
  518. <el-table-column
  519. label="计量单位"
  520. prop="batchNo"
  521. width="100"
  522. align="center"
  523. >
  524. <!-- v-if="formData.extInfo.assetType == 1" -->
  525. <template slot-scope="{ row, $index }">
  526. <template>
  527. {{ row.measuringUnit }}
  528. </template>
  529. </template>
  530. </el-table-column>
  531. <!-- <el-table-column
  532. label="计量单位"
  533. prop="batchNo"
  534. width="100"
  535. align="center"
  536. v-if="formData.extInfo.assetType == 4"
  537. >
  538. <template slot-scope="{ row, $index }">
  539. <template>
  540. {{ row.measuringUnit }}
  541. </template>
  542. </template>
  543. </el-table-column> -->
  544. <!-- <el-table-column
  545. label="数量"
  546. prop="batchNo"
  547. width="150"
  548. align="center"
  549. v-if="formData.extInfo.assetType == 1"
  550. >
  551. <template slot-scope="{ row, $index }">
  552. <template> {{ row.outInNum }} </template>
  553. </template>
  554. </el-table-column>
  555. <el-table-column
  556. label="数量"
  557. prop="batchNo"
  558. width="150"
  559. align="center"
  560. v-if="formData.extInfo.assetType == 4"
  561. >
  562. <template slot-scope="{ row, $index }">
  563. <template>
  564. {{ row.minPackingCount * row.outInNum }}
  565. </template>
  566. </template>
  567. </el-table-column> -->
  568. <el-table-column
  569. label="重量"
  570. align="center"
  571. prop="contentImage"
  572. :show-overflow-tooltip="true"
  573. >
  574. <!-- v-if="formData.extInfo.assetType == 1" -->
  575. <template slot-scope="{ row, $index }">
  576. {{ row.weight }}
  577. <template slot="append">
  578. {{ handleRowUnit(row) }}
  579. <!-- {{
  580. { yuan: '元', wanyuan: '万元' }[row.univalenceUnit]
  581. }} -->
  582. </template>
  583. </template>
  584. </el-table-column>
  585. <!-- <el-table-column
  586. label="重量"
  587. align="center"
  588. prop="contentImage"
  589. :show-overflow-tooltip="true"
  590. v-if="formData.extInfo.assetType == 4"
  591. >
  592. <template slot-scope="{ row, $index }">
  593. {{
  594. deviceWeight(
  595. row.roughWeight,
  596. row.minPackingCount * row.outInNum
  597. )
  598. }}
  599. <template slot="append"> -->
  600. <!-- {{ handleRowUnit(row) }} -->
  601. <!-- {{
  602. { yuan: '元', wanyuan: '万元' }[row.univalenceUnit]
  603. }} -->
  604. <!-- </template>
  605. </template>
  606. </el-table-column> -->
  607. <el-table-column
  608. label="重量单位"
  609. align="center"
  610. prop="contentImage"
  611. :show-overflow-tooltip="true"
  612. >
  613. <template slot-scope="{ row, $index }">
  614. {{ row.weightUnit }}
  615. <template slot="append"> </template>
  616. </template>
  617. </el-table-column>
  618. <el-table-column
  619. label="单价"
  620. prop="univalence"
  621. width="150"
  622. align="center"
  623. >
  624. <template slot-scope="{ row, $index }">
  625. <!-- <template v-if="row.isSave || formData.bizType == 5">
  626. <template v-if="row.univalence || row.univalence === 0">
  627. {{ row.univalence
  628. }}{{
  629. { yuan: '元', wanyuan: '万元' }[row.univalenceUnit]
  630. }}
  631. </template>
  632. </template> -->
  633. <!-- v-else -->
  634. <el-form-item
  635. :prop="`warehousingMaterialList.${$index}.univalence`"
  636. >
  637. <el-input
  638. v-model="row.univalence"
  639. placeholder="非必填"
  640. @input="
  641. (value) =>
  642. (row.univalence = value.replace(/[^0-9.]+/g, ''))
  643. "
  644. >
  645. <template slot="append">
  646. 元/{{ handleRowUnit(row) }}
  647. <!-- {{
  648. { yuan: '元', wanyuan: '万元' }[row.univalenceUnit]
  649. }} -->
  650. </template>
  651. </el-input>
  652. </el-form-item>
  653. </template>
  654. </el-table-column>
  655. <el-table-column
  656. label="金额"
  657. align="center"
  658. prop="contentImage"
  659. :show-overflow-tooltip="true"
  660. >
  661. <template slot-scope="{ row, $index }">
  662. {{
  663. calcSumTotal(
  664. row.outInNum,
  665. row.minPackingCount,
  666. row.univalence,
  667. row
  668. )
  669. }}
  670. </template>
  671. </el-table-column>
  672. <el-table-column
  673. label="货位"
  674. prop="warehouseName"
  675. :show-overflow-tooltip="true"
  676. width="250"
  677. required
  678. >
  679. <template slot-scope="{ row, $index }">
  680. <el-form-item
  681. :prop="`warehousingMaterialList.${$index}.houseList`"
  682. :required="true"
  683. >
  684. <div @click="handleWareHouse(row, $index)">
  685. <div
  686. style="color: #ff4949"
  687. v-if="row.houseList.length == 0"
  688. >
  689. ---(必填)
  690. </div>
  691. <div v-else>
  692. <div
  693. class="fontOmitted"
  694. v-for="(item, index) in row.houseList"
  695. :key="index"
  696. >
  697. {{ item.warehouseName }}- {{ item.areaName }}-
  698. {{ item.shelfCode }}- {{ item.cargoSpaceCode
  699. }}<span style="color: #ff4949" v-if="item.num">
  700. - {{ item.num }}(数)</span
  701. >
  702. <br />
  703. </div>
  704. </div>
  705. </div>
  706. </el-form-item>
  707. </template>
  708. </el-table-column>
  709. <el-table-column
  710. label="质检单"
  711. v-if="formData.extInfo.assetType === 3"
  712. prop="contentImage"
  713. :show-overflow-tooltip="true"
  714. >
  715. <template slot-scope="{ row, $index }">
  716. <upload @on-success="(data) => (row.contentImage = [data])"
  717. ><template slot="placeholder">上传</template></upload
  718. >
  719. </template>
  720. </el-table-column>
  721. <el-table-column
  722. label="操作"
  723. width="200"
  724. fixed="right"
  725. align="center"
  726. >
  727. <template slot="header" slot-scope="scope"> 操作 </template>
  728. <template slot-scope="{ row, $index }">
  729. <el-button
  730. type="text"
  731. v-show="!row.isSave"
  732. @click="listSave(row, $index)"
  733. >保存</el-button
  734. >
  735. <el-button
  736. type="text"
  737. v-show="row.isSave"
  738. @click="listEdit(row, $index)"
  739. >编辑</el-button
  740. >
  741. <el-button
  742. type="text"
  743. v-if="formData.bizType == 5"
  744. v-show="!row.isSave"
  745. @click="chooseAssets(row, $index)"
  746. >选择资产编号</el-button
  747. >
  748. <el-button type="text" @click="listDel(row, $index)"
  749. >删除</el-button
  750. >
  751. </template>
  752. </el-table-column>
  753. </el-table>
  754. </el-form>
  755. </div>
  756. <div class="mt20">
  757. <header-title :title="`包装明细`">
  758. <div class="switch_right">
  759. <span v-if="materialCodeReqList.length != 0">
  760. 分拆<el-switch
  761. v-model="isDetail"
  762. active-color="#13ce66"
  763. inactive-color="#ff4949"
  764. @change="handleIsDetail"
  765. style="margin-left: 10px"
  766. >
  767. </el-switch>
  768. </span>
  769. <el-button
  770. style="margin-left: 20px"
  771. type="text"
  772. @click="dateSetting"
  773. v-if="!isSplit && formData.bizType != 5"
  774. >批量设置{{
  775. curDateType === 'manufactureTime' ? '生产日期' : '采购日期'
  776. }}</el-button
  777. >
  778. </div>
  779. </header-title>
  780. <el-button
  781. v-if="materialCodeReqList.length != 0"
  782. type="success"
  783. plain
  784. style="margin-bottom: 20px; float: right; margin-right: 20px"
  785. size="mini"
  786. @click="wrapListSave"
  787. >批量保存</el-button
  788. >
  789. <el-table
  790. v-if="showMaterialTable"
  791. ref="materialCodeReqListTable"
  792. :data="materialCodeReqList"
  793. tooltip-effect="dark"
  794. :key="formData.bizType"
  795. :header-cell-style="rowClass"
  796. style="width: 100%"
  797. stripe
  798. :max-height="300"
  799. @selection-change="handleSelectionChange"
  800. >
  801. <el-table-column
  802. v-if="formData.bizType != 5"
  803. type="selection"
  804. align="center"
  805. width="50"
  806. fixed="left"
  807. >
  808. </el-table-column>
  809. <el-table-column label="序号" type="index" width="50">
  810. </el-table-column>
  811. <el-table-column
  812. label="编码"
  813. prop="assetCode"
  814. width="130"
  815. :show-overflow-tooltip="true"
  816. ></el-table-column>
  817. <el-table-column
  818. label="名称"
  819. prop="assetName"
  820. width="150"
  821. :show-overflow-tooltip="true"
  822. ></el-table-column>
  823. <el-table-column
  824. label="批次号"
  825. prop="batchNo"
  826. width="70"
  827. ></el-table-column>
  828. <el-table-column
  829. :label="`包装编码`"
  830. prop="onlyCode"
  831. width="200"
  832. :show-overflow-tooltip="true"
  833. ></el-table-column>
  834. <el-table-column
  835. label="包装数量"
  836. prop="packingCount"
  837. width="80"
  838. ></el-table-column>
  839. <el-table-column
  840. label="包装单位"
  841. prop="packingUnit"
  842. ></el-table-column>
  843. <el-table-column
  844. label="计量数量"
  845. prop="minPackingCount"
  846. ></el-table-column>
  847. <el-table-column
  848. label="计量单位"
  849. prop="measuringUnit"
  850. ></el-table-column>
  851. <el-table-column
  852. v-if="formData.bizType == 2 || formData.bizType == 1"
  853. label="物料代号"
  854. prop="materielCode"
  855. >
  856. <template slot-scope="{ row }">
  857. <el-input
  858. v-if="!row.isPack"
  859. v-model="row.materielCode"
  860. ></el-input>
  861. <span v-else>{{ row.materielCode }}</span>
  862. </template>
  863. </el-table-column>
  864. <el-table-column
  865. v-if="formData.bizType == 2 || formData.bizType == 1"
  866. label="客户代号"
  867. prop="clientCode"
  868. >
  869. <template slot-scope="{ row }">
  870. <el-input
  871. v-if="!row.isPack"
  872. v-model="row.clientCode"
  873. ></el-input>
  874. <span v-else> {{ row.clientCode }}</span>
  875. </template>
  876. </el-table-column>
  877. <el-table-column
  878. v-if="formData.bizType == 1"
  879. label="刻码"
  880. prop="engrave"
  881. >
  882. <template slot-scope="{ row }">
  883. <el-input v-if="!row.isPack" v-model="row.engrave"></el-input>
  884. <span v-else>{{ row.engrave }}</span>
  885. </template>
  886. </el-table-column>
  887. <el-table-column
  888. v-if="formData.bizType == 2 || formData.bizType == 1"
  889. label="重量"
  890. prop="weight"
  891. width="100"
  892. >
  893. <template slot-scope="{ row }">
  894. <el-input
  895. v-if="!row.isPack"
  896. v-model="row.weight"
  897. @input="weightInput($event, row)"
  898. ></el-input>
  899. <span v-else>{{ row.weight }}</span>
  900. </template>
  901. </el-table-column>
  902. <el-table-column label="重量单位" prop="weightUtil">
  903. <template slot-scope="{ row }">
  904. {{ row.weightUtil }}
  905. </template>
  906. </el-table-column>
  907. <el-table-column label="质检结果" prop="result" width="120">
  908. <template slot-scope="{ row }">
  909. <DictSelection
  910. v-if="!row.isPack"
  911. @updateVal="changeWrapStatus($event, row)"
  912. dictName="质检结果"
  913. clearable
  914. v-model="row.result"
  915. />
  916. <span v-else>{{ qualityResults[row.result] }}</span>
  917. </template>
  918. </el-table-column>
  919. <el-table-column label="质检状态" prop="status" width="120">
  920. <template slot-scope="{ row }">
  921. <!-- <DictSelection
  922. dictName="质检状态"
  923. clearable
  924. v-model="row.status"
  925. ></DictSelection> -->
  926. <span>{{ qualityStatus[row.status] }}</span>
  927. </template>
  928. </el-table-column>
  929. <el-table-column
  930. v-if="formData.bizType != 5"
  931. label="生产日期"
  932. prop=""
  933. width="220"
  934. >
  935. <template slot="header" slot-scope="scope">
  936. <el-select :disabled="isSplit" filterable v-model="curDateType">
  937. <el-option
  938. value="manufactureTime"
  939. label="生产日期"
  940. ></el-option>
  941. <el-option
  942. value="procurementTime"
  943. label="采购日期"
  944. ></el-option>
  945. </el-select>
  946. </template>
  947. <template slot-scope="{ row }">
  948. <template v-if="formData.bizType == 5">
  949. {{ row[curDateType] }}
  950. </template>
  951. <el-date-picker
  952. v-else
  953. :disabled="row.isPack"
  954. size="small"
  955. v-model="row[curDateType]"
  956. type="datetime"
  957. value-format="yyyy-MM-dd HH:mm:ss"
  958. placeholder="选择日期"
  959. >
  960. </el-date-picker>
  961. </template>
  962. </el-table-column>
  963. <template v-else>
  964. <el-table-column
  965. label="生产日期"
  966. prop="manufactureTime"
  967. width="200"
  968. ></el-table-column>
  969. <el-table-column
  970. label="采购日期"
  971. prop="procurementTime"
  972. width="200"
  973. ></el-table-column>
  974. </template>
  975. <el-table-column
  976. v-if="!isSplit"
  977. label="操作"
  978. width="80"
  979. fixed="right"
  980. >
  981. <template slot-scope="{ row }">
  982. <el-button type="text" @click="packCout(row)">
  983. {{ !row.isPack ? '保存' : '编辑' }}
  984. </el-button>
  985. </template>
  986. </el-table-column>
  987. </el-table>
  988. <!-- </el-tab-pane>
  989. </el-tabs> -->
  990. </div>
  991. <div class="mt20" v-if="isDetail">
  992. <header-title :title="`物料明细`"> </header-title>
  993. <el-button
  994. v-if="resultArray.length != 0"
  995. type="success"
  996. plain
  997. style="margin-bottom: 20px; float: right; margin-right: 20px"
  998. size="mini"
  999. @click="materialListSave"
  1000. >批量保存</el-button
  1001. >
  1002. <el-table
  1003. ref="resultArrayTable"
  1004. :data="resultArray"
  1005. tooltip-effect="dark"
  1006. :key="formData.bizType"
  1007. :header-cell-style="rowClass"
  1008. style="width: 100%"
  1009. stripe
  1010. :max-height="300"
  1011. @selection-change="handleSelectionChange"
  1012. >
  1013. <el-table-column label="序号" type="index" width="50">
  1014. </el-table-column>
  1015. <el-table-column
  1016. label="编码"
  1017. width="150"
  1018. prop="assetCode"
  1019. :show-overflow-tooltip="true"
  1020. ></el-table-column>
  1021. <el-table-column
  1022. label="名称"
  1023. prop="assetName"
  1024. width="200"
  1025. :show-overflow-tooltip="true"
  1026. ></el-table-column>
  1027. <el-table-column
  1028. label="批次号"
  1029. prop="batchNo"
  1030. width="80"
  1031. ></el-table-column>
  1032. <el-table-column
  1033. label="物料编码"
  1034. prop="no"
  1035. width="200"
  1036. :show-overflow-tooltip="true"
  1037. ></el-table-column>
  1038. <el-table-column
  1039. label="计量数量"
  1040. prop="minPackingCount"
  1041. width="90"
  1042. ></el-table-column>
  1043. <el-table-column
  1044. width="80"
  1045. label="计量单位"
  1046. prop="measuringUnit"
  1047. ></el-table-column>
  1048. <el-table-column label="物料代号" prop="materielCode">
  1049. <template slot-scope="{ row }">
  1050. <el-input
  1051. v-if="!row.isPack"
  1052. v-model="row.materielCode"
  1053. ></el-input>
  1054. <span v-else>{{ row.materielCode }}</span>
  1055. </template>
  1056. </el-table-column>
  1057. <el-table-column label="客户代号" prop="clientCode">
  1058. <template slot-scope="{ row }">
  1059. <el-input
  1060. v-if="!row.isPack"
  1061. v-model="row.clientCode"
  1062. ></el-input>
  1063. <span v-else>{{ row.clientCode }}</span>
  1064. </template>
  1065. </el-table-column>
  1066. <el-table-column label="刻码" prop="engrave">
  1067. <template slot-scope="{ row }">
  1068. <el-input v-if="!row.isPack" v-model="row.engrave"></el-input>
  1069. <span v-else>{{ row.engrave }}</span>
  1070. </template>
  1071. </el-table-column>
  1072. <el-table-column
  1073. label="重量"
  1074. prop="weight"
  1075. width="100"
  1076. v-if="formData.bizType == 2 || formData.bizType == 1"
  1077. >
  1078. <template slot-scope="{ row }">
  1079. <el-input v-if="!row.isPack" v-model="row.weight"></el-input>
  1080. <span v-else>{{ row.weight }}</span>
  1081. </template>
  1082. </el-table-column>
  1083. <el-table-column
  1084. v-if="formData.bizType == 2 || formData.bizType == 1"
  1085. label="重量单位"
  1086. prop="weightUnit"
  1087. width="100"
  1088. ></el-table-column>
  1089. <el-table-column label="质检结果" prop="result" width="120">
  1090. <template slot-scope="{ row }">
  1091. <DictSelection
  1092. v-if="!row.isPack"
  1093. @updateVal="changeWrapStatus($event, row)"
  1094. dictName="质检结果"
  1095. clearable
  1096. v-model="row.result"
  1097. />
  1098. <span v-else>{{ qualityResults[row.result] }}</span>
  1099. </template>
  1100. </el-table-column>
  1101. <el-table-column label="质检状态" prop="status" width="120">
  1102. <template slot-scope="{ row }">
  1103. <span>{{ qualityStatus[row.status] }}</span>
  1104. </template>
  1105. </el-table-column>
  1106. <el-table-column label="操作" width="80" fixed="right">
  1107. <template slot-scope="{ row }">
  1108. <el-button type="text" @click="materialBtn(row)">
  1109. {{ !row.isPack ? '保存' : '编辑' }}
  1110. </el-button>
  1111. </template>
  1112. </el-table-column>
  1113. </el-table>
  1114. </div>
  1115. </div>
  1116. <div class="center mt20">
  1117. <el-button type="primary" @click="handleSave" :loading="saveLoading"
  1118. >保存</el-button
  1119. >
  1120. <el-button @click="$router.go(-1)">返回</el-button>
  1121. </div>
  1122. </el-card>
  1123. <selectType
  1124. :visibleDialog.sync="visibleDialog"
  1125. :title="title"
  1126. :tableHeader="tableHeader"
  1127. :bizScene="formData.bizType"
  1128. :type="[selectEquiType]"
  1129. :loadTree.sync="loadTree"
  1130. @selectTableData="onSelectTableData"
  1131. />
  1132. <WareHouseDailog
  1133. ref="wareHouseDailogRef"
  1134. @houseData="houseData"
  1135. ></WareHouseDailog>
  1136. <ReturnSelect
  1137. ref="returnSelectRef"
  1138. :tableHeader="tableHeader"
  1139. :curDateType="curDateType"
  1140. ></ReturnSelect>
  1141. <el-dialog :visible.sync="dateVisible" title="选择日期" width="400px">
  1142. <el-date-picker
  1143. size="small"
  1144. v-model="batchTime"
  1145. type="datetime"
  1146. style="width: 320px"
  1147. value-format="yyyy-MM-dd HH:mm:ss"
  1148. placeholder="选择日期"
  1149. >
  1150. </el-date-picker>
  1151. <div style="text-align: right; margin-top: 20px">
  1152. <el-button @click="dateVisible = false">取消</el-button>
  1153. <el-button type="primary" @click="dateConfirm" :disabled="!batchTime"
  1154. >确认</el-button
  1155. >
  1156. </div>
  1157. </el-dialog>
  1158. <!-- 销售订单 -->
  1159. <picker ref="pickerRef" @success="pickerSuccess" />
  1160. </div>
  1161. </template>
  1162. <script>
  1163. import { add, bignumber } from 'mathjs';
  1164. import picker from './components/picker.vue';
  1165. import outin from '@/api/warehouseManagement/outin';
  1166. import {
  1167. getTreeByPid,
  1168. getTreeByGroup,
  1169. getProductList
  1170. } from '@/api/classifyManage';
  1171. import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
  1172. import selectUpload from '@/components/selectUpload';
  1173. import upload from '@/components/uploadImg';
  1174. import {
  1175. warehousingType,
  1176. sceneState,
  1177. emergencyState,
  1178. materialType
  1179. } from '@/utils/dict/index';
  1180. // import { getInfo, warehousingAdd, getAssetNum } from '@/api/stockManagement';
  1181. import selectTree from '@/components/selectTree';
  1182. import selectType from '../components/selectType.vue';
  1183. import WareHouseDailog from '../components/WareHouseDailog.vue';
  1184. import ReturnSelect from './components/ReturnSelect.vue';
  1185. // import supplier from '@/api/main/supplier';
  1186. // import org from '@/api/main/org';
  1187. // import user from '@/api/main/user';
  1188. import { tableHeader } from '../common';
  1189. import { getCode } from '@/api/codeManagement/index.js';
  1190. import { number } from 'echarts/core';
  1191. import { purchaseorderGetById, contactlink, oneId } from '@/api/mes';
  1192. export default {
  1193. components: {
  1194. selectUpload,
  1195. selectTree,
  1196. selectType,
  1197. WareHouseDailog,
  1198. upload,
  1199. ReturnSelect,
  1200. picker
  1201. },
  1202. data() {
  1203. return {
  1204. showMaterialTable: true, // 缓存包装明细列表
  1205. isSplit: false, // 是否拆分到物料明细
  1206. qualityStatus: {
  1207. 0: '未检',
  1208. 1: '已检',
  1209. 2: '部分检'
  1210. }, // 质检状态 0未检 1已检
  1211. qualityResults: {
  1212. 0: '合格',
  1213. 1: '不合格',
  1214. 3: '让步接收'
  1215. }, // 质检结果 0合格 1不合格 3让步接收
  1216. isWeight: true,
  1217. resultArray: [],
  1218. isDetail: false,
  1219. contactList: [],
  1220. pickerRow: {},
  1221. fromUserList: [],
  1222. codeList: [],
  1223. materialType,
  1224. warehousingType,
  1225. sceneState,
  1226. emergencyState,
  1227. saveLoading: false,
  1228. visibleDialog: false,
  1229. curDateType: 'manufactureTime',
  1230. materialCodeReqListSelected: [],
  1231. // warehouseList: [], //仓库数组
  1232. // warehouse: {},
  1233. title: '',
  1234. tableData2: [],
  1235. uploadList: [],
  1236. supplierList: [],
  1237. warehousingMaterialList: [],
  1238. activeName: 'a',
  1239. loadTree: true,
  1240. selectEquiType: '',
  1241. batchTime: '',
  1242. dateVisible: false,
  1243. treeList: [],
  1244. staffList: [],
  1245. formData: {
  1246. extInfo: {
  1247. assetType: '', //物品类型
  1248. deptCode: '', //部门code
  1249. deptName: '', //部门名称
  1250. verifyDeptCode: '', //审核部门编码
  1251. verifyDeptName: '', //审核部门名称
  1252. deliveryName: '', //送货人名称
  1253. deliveryPhone: '', //送货人电话
  1254. documentSource: '', //销售订单
  1255. urgent: '', //紧急状态
  1256. supplierId: '', //供应商ID
  1257. supplierName: '', //供应商名称
  1258. createUserName: '', //创建人名字
  1259. contentImage: [] //图片数组
  1260. },
  1261. fromUser: '', //送货人
  1262. bizType: '', //物品类型
  1263. verifyId: '', //审核人Id
  1264. verifyName: '', //审核人名称
  1265. createUserId: '',
  1266. remark: ''
  1267. },
  1268. rules: {
  1269. 'extInfo.assetType': {
  1270. required: true,
  1271. message: '请选择物品类型',
  1272. trigger: 'change'
  1273. },
  1274. bizType: {
  1275. required: true,
  1276. message: '请选择入库场景',
  1277. trigger: 'change'
  1278. }
  1279. }
  1280. };
  1281. },
  1282. computed: {
  1283. // 条码信息
  1284. materialCodeReqList() {
  1285. return this.warehousingMaterialList
  1286. .map((i) => i.warehouseLedgerDetails || [])
  1287. .flat();
  1288. },
  1289. tableHeader() {
  1290. return tableHeader(this.selectEquiType);
  1291. }
  1292. },
  1293. created() {
  1294. if (this.$route.query.id) {
  1295. // this._getInfo()
  1296. } else {
  1297. let obj = localStorage.getItem('orgInfo')
  1298. ? JSON.parse(localStorage.getItem('orgInfo'))
  1299. : {};
  1300. this.formData.createUserName = obj.name;
  1301. this.formData.extInfo.deptName = obj.dept?.name;
  1302. this.formData.deptCode = obj.dept?.code;
  1303. }
  1304. this.initData();
  1305. },
  1306. methods: {
  1307. // 包装维度最小包装单元改变——>总重量
  1308. minPackingCountChange(row, value) {
  1309. row.minPackingCount = value.replace(/^(0+)|[^\d]+/g, '');
  1310. if (row.outInNum >= 0 && value >= 0) {
  1311. this.packNum(row, row.outInNum);
  1312. }
  1313. },
  1314. // 选择质检结果改变质检状态
  1315. changeWrapStatus(resultValue, row) {
  1316. switch (resultValue) {
  1317. case '':
  1318. // 清空质检状态
  1319. row.status = '0';
  1320. break;
  1321. default:
  1322. // 默认已检质检状态
  1323. row.status = '1';
  1324. break;
  1325. }
  1326. },
  1327. // 包装批量保存
  1328. wrapListSave() {
  1329. // 批量修改包装明细
  1330. this.isWeight = false;
  1331. this.bulkEditingWrap();
  1332. this.$nextTick(() => {
  1333. this.isWeight = true;
  1334. });
  1335. },
  1336. // 物料批量保存
  1337. materialListSave() {
  1338. this.resultArray.forEach((item) => {
  1339. if (!item.isPack) {
  1340. this.materialBtn(item);
  1341. }
  1342. });
  1343. },
  1344. weightInput(value, row) {
  1345. const newValue = value.replace(/[^\d.]/g, ''); // 保留数字和小数点
  1346. const decimalCount = (newValue.match(/\./g) || []).length; // 计算小数点的个数
  1347. if (decimalCount > 1) {
  1348. // 如果小数点个数大于1,移除多余的小数点
  1349. const lastIndex = newValue.lastIndexOf('.');
  1350. row.weight =
  1351. newValue.slice(0, lastIndex) + newValue.slice(lastIndex + 1);
  1352. } else if (decimalCount === 1) {
  1353. // 如果小数点个数等于1,允许小数点的输入
  1354. row.weight = newValue;
  1355. } else {
  1356. row.weight = newValue === '' ? 0 : parseFloat(newValue); // 如果输入为空,则设为0
  1357. }
  1358. },
  1359. handleIsDetail(event) {
  1360. this.isSplit = event;
  1361. const list = this.materialCodeReqList;
  1362. if (event) {
  1363. let resultArray = [];
  1364. list.forEach((item) => {
  1365. // 包装维度改成已保存状态
  1366. item.isPack = true;
  1367. // 拆分物料维度并生成列表
  1368. for (let i = 1; i <= Number(item.minPackingCount); i++) {
  1369. resultArray.push({
  1370. onlyCode: item.onlyCode,
  1371. no: item.onlyCode + i.toString().padStart(4, '0'),
  1372. assetCode: item.assetCode,
  1373. assetName: item.assetName,
  1374. batchNo: item.batchNo,
  1375. minPackingCount: 1,
  1376. measuringUnit: item.measuringUnit,
  1377. materielCode: item.materielCode,
  1378. clientCode: item.clientCode,
  1379. weight: item.weight / Number(item.minPackingCount),
  1380. weightUnit: item.weightUnit,
  1381. engrave: item.engrave,
  1382. result: item.result,
  1383. status: item.status,
  1384. isPack: false
  1385. });
  1386. }
  1387. });
  1388. this.resultArray = resultArray;
  1389. // 批量修改包装明细
  1390. this.isWeight = false;
  1391. this.bulkEditingWrap();
  1392. this.$nextTick(() => {
  1393. this.isWeight = true;
  1394. });
  1395. } else {
  1396. // 包装维度改成编辑状态
  1397. list.forEach((item) => {
  1398. item.isPack = false;
  1399. });
  1400. // 清空物料维度列表
  1401. this.resultArray = [];
  1402. }
  1403. },
  1404. //包装明细保存
  1405. packCout(row) {
  1406. //true保存==》反之
  1407. if (!row.isPack) {
  1408. row.isPack = true;
  1409. const code = row.assetCode;
  1410. const batchNo = row.batchNo;
  1411. //做防护,防止weight字符串类型
  1412. this.materialCodeReqList.forEach((ele) => {
  1413. ele.weight = Number(ele.weight);
  1414. });
  1415. // const count = this.materialCodeReqList.reduce(
  1416. // (acc, curr) => acc + curr.weight,
  1417. // 0
  1418. // );
  1419. // 修改产品信息重量(包装维度累计)
  1420. this.isWeight = false;
  1421. this.warehousingMaterialList.forEach((item) => {
  1422. if (item.assetCode == code && item.batchNo == batchNo) {
  1423. let arr = [];
  1424. for (const key in this.materialCodeReqList) {
  1425. if (
  1426. this.materialCodeReqList[key].assetCode == item.assetCode &&
  1427. this.materialCodeReqList[key].batchNo == item.batchNo
  1428. ) {
  1429. arr.push({ ...this.materialCodeReqList[key] });
  1430. }
  1431. }
  1432. const count = arr.reduce(
  1433. (acc, curr) =>
  1434. Number(this.$math.format(+acc + +curr.weight, 14)),
  1435. 0
  1436. );
  1437. this.$set(item, 'weight', count);
  1438. }
  1439. });
  1440. this.$nextTick(() => {
  1441. this.isWeight = true;
  1442. });
  1443. } else {
  1444. row.isPack = false;
  1445. }
  1446. // setTimeout(() => {
  1447. // }, 100);
  1448. },
  1449. // 批量修改包装明细
  1450. bulkEditingWrap() {
  1451. // 批量修改包装明细列表状态(已保存)
  1452. this.materialCodeReqList.forEach((item) => {
  1453. item.isPack = true;
  1454. });
  1455. // 改变产品明细重量
  1456. this.warehousingMaterialList.forEach((outItem) => {
  1457. let arr = [];
  1458. this.materialCodeReqList.forEach((inneritem) => {
  1459. if (
  1460. inneritem.assetCode == outItem.assetCode &&
  1461. inneritem.batchNo == outItem.batchNo
  1462. ) {
  1463. arr.push(inneritem);
  1464. }
  1465. });
  1466. const count = arr.reduce(
  1467. (acc, curr) => Number(this.$math.format(+acc + +curr.weight, 14)),
  1468. 0
  1469. );
  1470. this.$set(outItem, 'weight', count);
  1471. });
  1472. },
  1473. // 批量修改物料明细
  1474. bulkEditingMaterial() {
  1475. // 批量修改物料明细列表状态(已保存)
  1476. this.resultArray.forEach((item) => {
  1477. item.isPack = true;
  1478. });
  1479. // 改变包装明细重量
  1480. this.materialCodeReqList.forEach((outItem) => {
  1481. let arr = [];
  1482. this.resultArray.forEach((inneritem) => {
  1483. if (
  1484. inneritem.assetCode == outItem.assetCode &&
  1485. inneritem.batchNo == outItem.batchNo
  1486. ) {
  1487. arr.push(inneritem);
  1488. }
  1489. });
  1490. const count = arr.reduce(
  1491. (acc, curr) => Number(this.$math.format(+acc + +curr.weight, 14)),
  1492. 0
  1493. );
  1494. this.$set(outItem, 'weight', count);
  1495. });
  1496. },
  1497. // 物料明细保存
  1498. materialBtn(row) {
  1499. console.log(row);
  1500. console.log(this.resultArray);
  1501. console.log(this.materialCodeReqList);
  1502. // true保存 false编辑
  1503. if (!row.isPack) {
  1504. row.isPack = true;
  1505. // 物料维度修改质检改变包装维度质检(结果和状态)
  1506. this.materialCodeReqList.forEach((outItem) => {
  1507. let arr = [];
  1508. this.resultArray.forEach((inneritem) => {
  1509. if (inneritem.onlyCode == outItem.onlyCode) {
  1510. arr.push(inneritem);
  1511. }
  1512. });
  1513. console.log(arr);
  1514. // 首先判断是未填/合格不合格
  1515. let boolen = arr.every((item) => {
  1516. return item.result === '' || item.result === undefined;
  1517. });
  1518. // 判断只要物料全部质检结果(未填)——>包装质检结果(未填) 状态(未检)
  1519. if (boolen) {
  1520. this.$set(outItem, 'result', '');
  1521. this.$set(outItem, 'status', '0');
  1522. } else {
  1523. // 判断只要物料有一个质检结果(不合格)——>包装质检结果(不合格) 状态(已检)
  1524. let boolen = arr.some((item) => {
  1525. return item.result === '1';
  1526. });
  1527. if (boolen) {
  1528. this.$set(outItem, 'result', '1');
  1529. this.$set(outItem, 'status', '1');
  1530. } else {
  1531. // 判断只要物料有一个质检结果(让步接收)——>包装质检结果(让步接收) 状态(已检)
  1532. let boolen = arr.some((item) => {
  1533. return item.result === '3';
  1534. });
  1535. if (boolen) {
  1536. // 让步接收 已检
  1537. this.$set(outItem, 'result', '3');
  1538. this.$set(outItem, 'status', '1');
  1539. } else {
  1540. // 判断只要物料有全部质检结果(合格)——>包装质检结果(合格) 状态(已检)
  1541. let boolen = arr.every((item) => {
  1542. return item.result === '0';
  1543. });
  1544. if (boolen) {
  1545. // 合格 已检
  1546. this.$set(outItem, 'result', '0');
  1547. this.$set(outItem, 'status', '1');
  1548. } else {
  1549. // 合格 部分检
  1550. this.$set(outItem, 'result', '0');
  1551. this.$set(outItem, 'status', '2');
  1552. }
  1553. }
  1554. }
  1555. }
  1556. // this.$set(outItem, 'result', boolen ? '1' : '0');
  1557. });
  1558. // 物料维度修改重量改变包装维度重量
  1559. let onlyCode = row.onlyCode;
  1560. this.materialCodeReqList.forEach((item) => {
  1561. if (item.onlyCode === onlyCode) {
  1562. let arr = [];
  1563. for (const key in this.resultArray) {
  1564. if (this.resultArray[key].onlyCode == item.onlyCode) {
  1565. arr.push({ ...this.resultArray[key] });
  1566. }
  1567. }
  1568. const count = arr.reduce(
  1569. (acc, curr) =>
  1570. Number(this.$math.format(+acc + +curr.weight, 14)),
  1571. 0
  1572. );
  1573. this.$set(item, 'weight', count);
  1574. }
  1575. });
  1576. // 包装维度修改重量改变产品信息
  1577. this.isWeight = false;
  1578. // 批量修改包装明细
  1579. this.bulkEditingWrap();
  1580. this.$nextTick(() => {
  1581. this.isWeight = true;
  1582. });
  1583. } else {
  1584. row.isPack = false;
  1585. }
  1586. },
  1587. packNum(row, value) {
  1588. const total = {
  1589. packingCount: Number(row.minPackingCount),
  1590. outInNum: Number(row.outInNum)
  1591. };
  1592. if (row.measuringUnit == row.weightUnit) {
  1593. row.weight = Number(
  1594. this.$math.format(
  1595. total.packingCount * 1 * total.outInNum.toFixed(2),
  1596. 14
  1597. )
  1598. );
  1599. } else {
  1600. const totals = Number(
  1601. this.$math.format(total.packingCount * total.outInNum, 14)
  1602. );
  1603. row.weight = Number(
  1604. this.$math.format(totals * row.netWeight.toFixed(2), 14)
  1605. );
  1606. }
  1607. return (row.outInNum = value.replace(/^(0+)|[^\d]+/g, ''));
  1608. },
  1609. async searchContact(id) {
  1610. const data = await contactlink({ contactId: id });
  1611. this.contactList = data.data;
  1612. },
  1613. async pickerSuccess(row) {
  1614. this.pickerRow = row;
  1615. this.formData.extInfo.documentSource = row.orderNo;
  1616. this.formData.clientName = row.partaName;
  1617. this.formData.clientCode = row.partaId;
  1618. this.formData.extInfo.supplierName = row.partbName;
  1619. this.formData.extInfo.supplierId = row.partbId;
  1620. await this.searchContact(row.partbId);
  1621. const data = await oneId(row.id);
  1622. if (this.warehousingMaterialList.length == 0) {
  1623. console.log('data===', data);
  1624. let list = data.data.productList.map((item) => {
  1625. return {
  1626. ...item,
  1627. assetName: item.productName,
  1628. assetCode: item.productCode,
  1629. categoryId: item.productCategoryId,
  1630. minPackUnit: item.packingUnit
  1631. };
  1632. });
  1633. this.onSelectTableData(await this.serachMainCode(list));
  1634. }
  1635. },
  1636. async serachMainCode(arr) {
  1637. let newArr = [];
  1638. // 使用 Promise.all 来等待所有异步操作完成
  1639. await Promise.all(
  1640. arr.map(async (item) => {
  1641. const data = await getProductList({
  1642. pageNum: 1,
  1643. size: 10,
  1644. categoryLevelId: item.categoryLevelPathIdParent,
  1645. code: item.assetCode
  1646. });
  1647. newArr.push(data.list); // 将结果存储到 newArr 中
  1648. })
  1649. );
  1650. let re = [];
  1651. for (const item of newArr) {
  1652. for (const it of item) {
  1653. re.push(it);
  1654. }
  1655. }
  1656. return re.map((item) => {
  1657. return {
  1658. ...item,
  1659. minPackUnit: item.packingUnit,
  1660. assetCode: item.code,
  1661. assetName: item.name
  1662. };
  1663. });
  1664. },
  1665. onClear() {
  1666. this.formData.extInfo.documentSource = '';
  1667. this.pickerRow = {};
  1668. this.formData.clientName = '';
  1669. this.formData.clientCode = '';
  1670. this.formData.extInfo.supplierName = '';
  1671. this.formData.extInfo.supplierId = '';
  1672. this.$forceUpdate();
  1673. },
  1674. handlePicker() {
  1675. this.$refs.pickerRef.open();
  1676. },
  1677. codeListValue(val) {
  1678. this.formData.extInfo.assetType = val.id;
  1679. this.$forceUpdate();
  1680. this.title = val?.name;
  1681. this.selectEquiType = val?.id;
  1682. },
  1683. //计算生产设备重量
  1684. deviceWeight(row, num) {
  1685. if (row) {
  1686. return Number(row * num);
  1687. } else {
  1688. return row;
  1689. }
  1690. },
  1691. //计算金额
  1692. calcSumTotal(PackingCount, outInNum, univalence) {
  1693. //最小包装单元,包装数量,单价
  1694. const total = {
  1695. PackingCount: Number(PackingCount),
  1696. outInNum: Number(outInNum),
  1697. univalence: Number(univalence == undefined ? 0 : univalence)
  1698. };
  1699. return total.PackingCount * total.outInNum * total.univalence;
  1700. },
  1701. handleRowUnit(row) {
  1702. return row.measuringUnit;
  1703. // if (this.formData.extInfo.assetType == 1) {
  1704. // return row.weightUnit;
  1705. // } else if (this.formData.extInfo.assetType == 4) {
  1706. // return row.measuringUnit;
  1707. // } else {
  1708. // return row.measuringUnit;
  1709. // }
  1710. },
  1711. changeVerfy(it) {
  1712. this.formData.verifyName = it.name;
  1713. },
  1714. //选择供应啥的操作
  1715. ChangeSupplier(data) {
  1716. this.formData.extInfo.supplierName = data.dictValue;
  1717. },
  1718. ChangeSuppliers(data) {
  1719. this.formData.clientName = data.dictValue;
  1720. },
  1721. rowClass({ row, column, rowIndex, columnIndex }) {
  1722. if (rowIndex === 1) {
  1723. return {
  1724. display: 'none',
  1725. background: '#EEEEEE',
  1726. border: 'none'
  1727. };
  1728. }
  1729. return { background: '#EEEEEE', border: 'none' };
  1730. },
  1731. calcSum(a, b, c, row) {
  1732. if (
  1733. (Number.isNaN(+a) && a !== '') ||
  1734. (Number.isNaN(+b) && b !== '') ||
  1735. (Number.isNaN(+c) && c !== '')
  1736. ) {
  1737. return '';
  1738. }
  1739. return a * b * c + { yuan: '元', wanyuan: '万元' }[row.univalenceUnit];
  1740. // return a * b * c;
  1741. },
  1742. // 部门 点击事件
  1743. async auditorDeptClick(data) {
  1744. this.formData.extInfo.verifyDeptCode = data?.id;
  1745. this.formData.extInfo.verifyDeptName = data?.name;
  1746. this.formData.verifyId = '';
  1747. this.formData.verifyName = '';
  1748. this.$refs.formName.validateField('verifyDeptName');
  1749. if (data) {
  1750. this.getStaffList(data);
  1751. }
  1752. },
  1753. async getStaffList(data) {
  1754. let res = await warehouseDefinition.getUserPage({
  1755. groupId: data.id,
  1756. size: 9999,
  1757. page: 1
  1758. });
  1759. this.staffList = res.list;
  1760. },
  1761. // 详情接口
  1762. // async _getInfo () {
  1763. // const res = await getInfo({ id: this.$route.query.id })
  1764. // if (res?.success) {
  1765. // this.warehousingMaterialList = res.data.warehouseLedgerInfos.map(i => {
  1766. // i.isSave = true
  1767. // return i
  1768. // })
  1769. // this.formData = res.data.outInWarehouse
  1770. // this.uploadList = this.formData.contentImage
  1771. // }
  1772. // },
  1773. chooseAssets(row, index) {
  1774. this.$refs.returnSelectRef.open(row, (res) => {
  1775. row.outInNum = res.length;
  1776. this.$set(
  1777. row,
  1778. 'selfWarehouseLedgerDetails',
  1779. res.map((i) => {
  1780. delete i.updateTime;
  1781. delete i.createTime;
  1782. return i;
  1783. })
  1784. );
  1785. });
  1786. },
  1787. // 仓库编辑
  1788. handleWareHouse(row, idx) {
  1789. this.$refs.wareHouseDailogRef.open(row, idx);
  1790. },
  1791. // 入库操作
  1792. listEdit(row) {
  1793. this.$set(row, 'isSave', false);
  1794. row.selfWarehouseLedgerDetails = row.warehouseLedgerDetails;
  1795. row.warehouseLedgerDetails = [];
  1796. // 清空物料明细防止数据错乱
  1797. this.resultArray = [];
  1798. this.isDetail = false;
  1799. },
  1800. listSave(row, index) {
  1801. const fileds = [
  1802. // `warehousingMaterialList.${index}.cargoSpaceCode`,
  1803. `warehousingMaterialList.${index}.batchNo`,
  1804. `warehousingMaterialList.${index}.houseList`
  1805. ];
  1806. if (this.formData.bizType == 1) {
  1807. // fileds.push(...[`warehousingMaterialList.${index}.customCode`]);
  1808. } else if (this.formData.bizType == 2) {
  1809. // fileds.push(...[`warehousingMaterialList.${index}.supplierCode`]);
  1810. }
  1811. if (this.formData.bizType != 5) {
  1812. fileds.push(
  1813. ...[
  1814. `warehousingMaterialList.${index}.outInNum`,
  1815. `warehousingMaterialList.${index}.minPackingCount`
  1816. ]
  1817. );
  1818. } else if (
  1819. this.warehousingMaterialList.some(
  1820. (i) => !i.selfWarehouseLedgerDetails?.length
  1821. )
  1822. ) {
  1823. this.$message.error('请选择资产编号!');
  1824. return;
  1825. }
  1826. Promise.all(
  1827. fileds.map(
  1828. (item) =>
  1829. new Promise(async (resolve, rej) => {
  1830. this.$refs.warehousingMaterialListRef.validateField(
  1831. item,
  1832. (err) => {
  1833. if (err) {
  1834. rej(err);
  1835. } else {
  1836. resolve();
  1837. }
  1838. }
  1839. );
  1840. })
  1841. )
  1842. )
  1843. .then((res) => {
  1844. this.$set(row, 'isSave', true);
  1845. if (this.formData.bizType != 5) {
  1846. this.createMaterialCode(row);
  1847. } else {
  1848. // 退还
  1849. this.createMaterialCodeReturn(row);
  1850. }
  1851. })
  1852. .catch((err) => {
  1853. this.$message.error('请填入必填项!');
  1854. });
  1855. },
  1856. listSaveArrs() {
  1857. const rows = this.warehousingMaterialList;
  1858. const indexes = Array.from(
  1859. { length: this.warehousingMaterialList.length },
  1860. (_, index) => index
  1861. );
  1862. rows.forEach((row, i) => {
  1863. const index = indexes[i];
  1864. const fileds = [
  1865. // `warehousingMaterialList.${index}.cargoSpaceCode`,
  1866. `warehousingMaterialList.${index}.batchNo`,
  1867. `warehousingMaterialList.${index}.houseList`
  1868. ];
  1869. if (this.formData.bizType == 1) {
  1870. // fileds.push(...[`warehousingMaterialList.${index}.customCode`]);
  1871. } else if (this.formData.bizType == 2) {
  1872. // fileds.push(...[`warehousingMaterialList.${index}.supplierCode`]);
  1873. }
  1874. if (this.formData.bizType != 5) {
  1875. fileds.push(
  1876. ...[
  1877. `warehousingMaterialList.${index}.outInNum`,
  1878. `warehousingMaterialList.${index}.minPackingCount`
  1879. ]
  1880. );
  1881. } else if (
  1882. this.warehousingMaterialList.some(
  1883. (i) => !i.selfWarehouseLedgerDetails?.length
  1884. )
  1885. ) {
  1886. this.$message.error('请选择资产编号!');
  1887. return;
  1888. }
  1889. Promise.all(
  1890. fileds.map(
  1891. (item) =>
  1892. new Promise(async (resolve, rej) => {
  1893. this.$refs.warehousingMaterialListRef.validateField(
  1894. item,
  1895. (err) => {
  1896. if (err) {
  1897. rej(err);
  1898. } else {
  1899. resolve();
  1900. }
  1901. }
  1902. );
  1903. })
  1904. )
  1905. )
  1906. .then((res) => {
  1907. this.$set(row, 'isSave', true);
  1908. if (this.formData.bizType != 5) {
  1909. this.createMaterialCode(row);
  1910. } else {
  1911. // 退还
  1912. this.createMaterialCodeReturn(row);
  1913. }
  1914. })
  1915. .catch((err) => {
  1916. // this.$message.error('请填入必填项!');
  1917. });
  1918. });
  1919. },
  1920. // listSaveArrs() {
  1921. // console.log(this.warehousingMaterialList);
  1922. // },
  1923. // 批量设置生产日期
  1924. handleSelectionChange(val) {
  1925. this.materialCodeReqListSelected = val;
  1926. },
  1927. dateSetting() {
  1928. if (!this.materialCodeReqListSelected.length) {
  1929. return this.$message.error(`请选择${this.title}明细!`);
  1930. }
  1931. this.dateVisible = true;
  1932. },
  1933. dateConfirm() {
  1934. this.materialCodeReqListSelected.forEach((item) => {
  1935. this.$set(item, this.curDateType, this.batchTime);
  1936. });
  1937. this.dateVisible = false;
  1938. },
  1939. //入库明细删除
  1940. listDel(row, index) {
  1941. this.warehousingMaterialList.splice(index, 1);
  1942. this.resultArray = [];
  1943. this.isDetail = false;
  1944. },
  1945. // 入库明细生成条码信息
  1946. async createMaterialCode(row) {
  1947. // 添加相同物品、批次号重新更新明细 原料编码
  1948. const list = this.warehousingMaterialList.filter(
  1949. (i) =>
  1950. i.assetCode === row.assetCode &&
  1951. i.batchNo === row.batchNo &&
  1952. i.isSave
  1953. );
  1954. const num = list.reduce((num, pre) => {
  1955. num += row.isUnpack
  1956. ? Number(this.$math.format(pre.outInNum * pre.minPackingCount, 14))
  1957. : pre.outInNum - 0;
  1958. return num;
  1959. }, 0);
  1960. const nums = list.reduce((num, pre) => {
  1961. num += Number(
  1962. this.$math.format(pre.outInNum * pre.minPackingCount, 14)
  1963. );
  1964. return num;
  1965. }, 0);
  1966. const res = await outin.getAssetNum({
  1967. assetCode: row.assetCode,
  1968. batchNum: row.batchNo,
  1969. num: num
  1970. });
  1971. // row.measuringUnit == 'PCS' ? nums :
  1972. list.forEach((item) => {
  1973. if (item.warehouseLedgerDetails?.length) {
  1974. item.warehouseLedgerDetails.forEach((i) => {
  1975. i.onlyCode = res.shift().onlyCode;
  1976. });
  1977. } else {
  1978. this.$set(
  1979. item,
  1980. 'warehouseLedgerDetails',
  1981. Array.from(
  1982. new Array(
  1983. item.isUnpack
  1984. ? Number(
  1985. this.$math.format(
  1986. item.outInNum * item.minPackingCount,
  1987. 14
  1988. )
  1989. )
  1990. : // : item.measuringUnit == 'PCS'
  1991. // ? +item.outInNum * parseInt(item.minPackingCount)
  1992. +item.outInNum
  1993. ),
  1994. (val, idx) => {
  1995. return {
  1996. ...item,
  1997. onlyCode: res.shift().onlyCode,
  1998. bizStatus: 1,
  1999. contentImage: []
  2000. };
  2001. }
  2002. )
  2003. );
  2004. }
  2005. });
  2006. // 添加相同物品,重复批次号 重新更新明细 包装编码
  2007. const batchList = this.warehousingMaterialList.filter(
  2008. (i) => i.batchNo === row.batchNo && i.isSave
  2009. );
  2010. if (batchList.length) {
  2011. const num = batchList.reduce((num, pre) => {
  2012. num += +pre.outInNum;
  2013. return num;
  2014. }, 0);
  2015. const res1 = await outin.getAssetNum({
  2016. batchNum: row.batchNo,
  2017. num
  2018. });
  2019. if (res1) {
  2020. batchList.forEach((item) => {
  2021. let num = res1.shift()?.num;
  2022. let minPackingCount = item.minPackingCount;
  2023. if (item.warehouseLedgerDetails?.length) {
  2024. item.warehouseLedgerDetails.forEach((i, index) => {
  2025. this.$set(i, 'num', num);
  2026. if (item.measuringUnit == item.weightUnit) {
  2027. this.$set(i, 'weight', item.minPackingCount);
  2028. } else {
  2029. this.$set(
  2030. i,
  2031. 'weight',
  2032. Number(
  2033. this.$math.format(
  2034. 1 * item.minPackingCount * item.netWeight,
  2035. 14
  2036. )
  2037. )
  2038. );
  2039. }
  2040. this.$set(i, 'weightUtil', item.weightUnit);
  2041. this.$set(i, 'packingCount', 1);
  2042. this.$set(i, 'packingUnit ', item.packingUnit);
  2043. this.$set(i, 'minPackingCount ', item.minPackingCount);
  2044. this.$set(i, 'measuringUnit', item.measuringUnit);
  2045. this.$set(i, 'isPack', false);
  2046. if (this.formData.extInfo.assetType == 1) {
  2047. this.$set(i, 'status', '0');
  2048. } else {
  2049. this.$set(i, 'result', '0');
  2050. this.$set(i, 'status', '1');
  2051. }
  2052. if (!item.isUnpack) {
  2053. if (index < item.warehouseLedgerDetails.length - 1) {
  2054. num = res1.shift()?.num;
  2055. }
  2056. } else {
  2057. // 拆包的包装编码一致
  2058. minPackingCount--;
  2059. if (
  2060. minPackingCount === 0 &&
  2061. index < item.warehouseLedgerDetails.length - 1
  2062. ) {
  2063. minPackingCount = item.minPackingCount;
  2064. num = res1.shift()?.num;
  2065. }
  2066. }
  2067. });
  2068. }
  2069. });
  2070. }
  2071. }
  2072. },
  2073. // 入库明细生成条码信息 退还
  2074. async createMaterialCodeReturn(row) {
  2075. // 添加相同物品重新更新明细 原料编码
  2076. const list = this.warehousingMaterialList.filter(
  2077. (i) => i.batchNo === row.batchNo && i.isSave
  2078. );
  2079. // 退还
  2080. const res = await getAssetNum({
  2081. batchNo: row.batchNo,
  2082. num: list.reduce((num, pre) => {
  2083. num += pre.selfWarehouseLedgerDetails.length;
  2084. return num;
  2085. }, 0)
  2086. });
  2087. if (res?.success) {
  2088. list.forEach((item) => {
  2089. let num = res.data.shift().num;
  2090. let minPackingCount = item.minPackingCount;
  2091. if (item.warehouseLedgerDetails?.length) {
  2092. item.warehouseLedgerDetails.forEach((i, index) => {
  2093. Object.assign(i, {
  2094. num,
  2095. batchNo: item.batchNo,
  2096. cargoSpaceCode: item.cargoSpaceCode, //货位编码
  2097. cargoSpaceId: item.cargoSpaceId, //货位id
  2098. shelfId: item.shelfId, //货架id
  2099. shelfCode: item.shelfCode, //货架名称
  2100. areaId: item.areaId, //库区id
  2101. areaName: item.areaName, //库区名称
  2102. warehouseId: item.warehouseId, //仓库id
  2103. warehouseName: item.warehouseName //仓库名称
  2104. });
  2105. if (!item.isUnpack) {
  2106. // 拆包的包装编码一致
  2107. if (index < item.warehouseLedgerDetails.length - 1) {
  2108. num = res.data.shift()?.num;
  2109. }
  2110. } else {
  2111. minPackingCount--;
  2112. if (
  2113. minPackingCount === 0 &&
  2114. index < item.warehouseLedgerDetails.length - 1
  2115. ) {
  2116. minPackingCount = item.minPackingCount;
  2117. num = res1.data.shift()?.num;
  2118. }
  2119. }
  2120. });
  2121. } else {
  2122. this.$set(
  2123. item,
  2124. 'warehouseLedgerDetails',
  2125. item.selfWarehouseLedgerDetails.map((val, idx) => {
  2126. let obj = {
  2127. ...val,
  2128. bizStatus: 1,
  2129. minPackingCount: item.minPackingCount,
  2130. batchNo: item.batchNo,
  2131. cargoSpaceCode: item.cargoSpaceCode, //货位编码
  2132. cargoSpaceId: item.cargoSpaceId, //货位id
  2133. shelfId: item.shelfId, //货架id
  2134. shelfCode: item.shelfCode, //货架名称
  2135. areaId: item.areaId, //库区id
  2136. areaName: item.areaName, //库区名称
  2137. warehouseId: item.warehouseId, //仓库id
  2138. warehouseName: item.warehouseName, //仓库名称
  2139. materialId: item.materialId,
  2140. num
  2141. };
  2142. if (!item.isUnpack) {
  2143. // 拆包的包装编码一致
  2144. if (idx < item.warehouseLedgerDetails.length - 1) {
  2145. num = res.data.shift()?.num;
  2146. }
  2147. } else {
  2148. minPackingCount--;
  2149. if (
  2150. minPackingCount === 0 &&
  2151. idx < item.warehouseLedgerDetails.length - 1
  2152. ) {
  2153. minPackingCount = item.minPackingCount;
  2154. num = res1.data.shift()?.num;
  2155. }
  2156. }
  2157. return obj;
  2158. })
  2159. );
  2160. }
  2161. });
  2162. }
  2163. },
  2164. handleSave() {
  2165. this.$refs.formName.validate(async (valid) => {
  2166. if (valid) {
  2167. if (!this.warehousingMaterialList?.length) {
  2168. return this.$message.error('请添加入库明细!');
  2169. } else if (
  2170. this.warehousingMaterialList.some((item) => !item.isSave)
  2171. ) {
  2172. return this.$message.error('请保存入库明细!');
  2173. }
  2174. // 默认全部保存
  2175. if (this.resultArray?.length > 0) {
  2176. // 物料批量保存
  2177. this.materialListSave();
  2178. } else {
  2179. // 包装批量保存
  2180. this.wrapListSave();
  2181. }
  2182. this.formatWarehouseMaterialList();
  2183. let arr = this.warehousingMaterialList.map((item) => {
  2184. return {
  2185. netWeight: item.netWeight,
  2186. num: item.num,
  2187. batchNo: item.batchNo,
  2188. categoryId:
  2189. this.formData.bizType == 2
  2190. ? item.categoryId
  2191. ? item.categoryId
  2192. : item.id
  2193. : item.id,
  2194. count: parseInt(item.outInNum) * parseInt(item.minPackingCount),
  2195. minPackingCount: item.minPackingCount,
  2196. packingCount: item.outInNum,
  2197. price: item.univalence,
  2198. outInDetailRecordAddPOList: item.warehouseLedgerDetails,
  2199. position: `${item.warehouseName}-${item.areaName}-${item.shelfCode}-${item.cargoSpaceCode}`,
  2200. remark: '',
  2201. pathIds: `${item.warehouseId},${item.areaId},${item.shelfId},${item.cargoSpaceId}`,
  2202. pathName: `${item.warehouseName},${item.areaName},${item.shelfCode},${item.cargoSpaceCode}`,
  2203. totalMoney:
  2204. item.outInNum * item.minPackingCount * item.univalence,
  2205. weightUnit: item.weightUnit,
  2206. customCode: item.customCode,
  2207. supplierCode: item.supplierCode,
  2208. weight: item.weight
  2209. };
  2210. });
  2211. arr.forEach((item) => {
  2212. if (item.outInDetailRecordAddPOList.length > 0) {
  2213. let list = item.outInDetailRecordAddPOList.map((it) => {
  2214. return this.formatOutInDetailRecordAddPO(it, item);
  2215. });
  2216. item.outInDetailRecordAddPOList = list;
  2217. }
  2218. });
  2219. let obj = { ...this.formData, type: 1 };
  2220. obj.sourceBizNo = this.formData.extInfo.documentSource;
  2221. obj.outInDetailAddPOList = arr;
  2222. console.log('=====>', obj);
  2223. this.saveLoading = true;
  2224. try {
  2225. const res = await outin.save(obj);
  2226. if (res.code == 0) {
  2227. await outin.outApproves({ outInId: res.data });
  2228. this.$message.success('保存成功!');
  2229. }
  2230. } catch (error) {
  2231. console.error('保存失败:', error);
  2232. }
  2233. this.saveLoading = false;
  2234. this.$router.push('/warehouseManagement/stockManagement');
  2235. }
  2236. });
  2237. },
  2238. formatWarehouseMaterialList() {
  2239. for (let key in this.warehousingMaterialList) {
  2240. for (let k in this.warehousingMaterialList[key].houseList) {
  2241. let house = this.warehousingMaterialList[key].houseList[k];
  2242. this.warehousingMaterialList[key].warehouseName =
  2243. house.warehouseName;
  2244. this.warehousingMaterialList[key].areaName = house.areaName;
  2245. this.warehousingMaterialList[key].shelfCode = house.shelfCode;
  2246. this.warehousingMaterialList[key].cargoSpaceCode =
  2247. house.cargoSpaceCode;
  2248. this.warehousingMaterialList[key].warehouseId = house.warehouseId;
  2249. this.warehousingMaterialList[key].areaId = house.areaId;
  2250. this.warehousingMaterialList[key].shelfId = house.shelfId;
  2251. this.warehousingMaterialList[key].cargoSpaceId = house.cargoSpaceId;
  2252. this.warehousingMaterialList[key].num = house.num;
  2253. }
  2254. }
  2255. },
  2256. formatOutInDetailRecordAddPO(it, item) {
  2257. return {
  2258. code: it.onlyCode,
  2259. dateType: this.curDateType === 'manufactureTime' ? 2 : 1,
  2260. dateValue: it[this.curDateType],
  2261. minUnit: it.minPackingCount,
  2262. minPackingCount: it.minPackingCount,
  2263. minPositionId: it.cargoSpaceId,
  2264. name: it.assetName,
  2265. pathIds: item.pathIds,
  2266. unit: it.unit,
  2267. packageNo: it.num,
  2268. clientCode: it.clientCode,
  2269. materielCode: it.materielCode,
  2270. weight: it.weight,
  2271. weightUtil: it.weightUtil,
  2272. engrave: it.engrave,
  2273. materialDetails: this.materialDetails(it.onlyCode),
  2274. packingCount: it.packingCount,
  2275. status: it.status,
  2276. result: it.result
  2277. };
  2278. },
  2279. materialDetails(onlyCode) {
  2280. return this.resultArray.filter((item) => item.onlyCode === onlyCode);
  2281. },
  2282. async getOrderCode() {
  2283. const data = await getCode('in_warehouse');
  2284. return data;
  2285. },
  2286. //添加明细
  2287. async onSelectTableData(val) {
  2288. const res = await getCode('lot_number_code');
  2289. this.warehousingMaterialList.push(
  2290. ...val.map((next) => {
  2291. next.batchNo = res;
  2292. let cur = {};
  2293. next.realInventoryAmount = next.realInventoryAmount || 0;
  2294. cur = {
  2295. ...next,
  2296. cargoSpaceCode: '', //货位编码
  2297. cargoSpaceId: '', //货位id
  2298. shelfId: '', //货架id
  2299. shelfCode: '', //货架名称
  2300. areaId: '', //库区id
  2301. areaName: '', //库区名称
  2302. warehouseId: '', //仓库id
  2303. warehouseName: '', //仓库名称
  2304. assetType: this.formData.extInfo.assetType,
  2305. expirationDate: '',
  2306. outInNum: '',
  2307. minPackingCount: '',
  2308. bizStatus: 1,
  2309. contentImage: [],
  2310. warehouseLedgerDetails: [],
  2311. houseList: []
  2312. };
  2313. return cur;
  2314. })
  2315. );
  2316. },
  2317. async initData() {
  2318. const { data } = await getTreeByGroup({ type: 2 });
  2319. this.codeList = data;
  2320. // .map((item) => {
  2321. // return { dictCode: item.id, dictValue: item.name };
  2322. // });
  2323. const res = await warehouseDefinition.tree();
  2324. this.treeList = this.$util.toTreeData({
  2325. data: res,
  2326. idField: 'id',
  2327. parentIdField: 'parentId'
  2328. });
  2329. // const res111 = await warehouseDefinition.list();
  2330. // this.warehouseList = res111.list;
  2331. let res22 = await warehouseDefinition.getUserPage({
  2332. size: -1,
  2333. page: 1
  2334. });
  2335. this.fromUserList = res22.list;
  2336. const info = JSON.parse(localStorage.getItem('info'));
  2337. let obj = res.find(
  2338. (item) => item.id === info.deptId[info.deptId.length - 1]
  2339. );
  2340. if (!obj) return;
  2341. this.formData.extInfo.deptCode = obj.id;
  2342. this.formData.extInfo.deptName = obj.name;
  2343. this.formData.extInfo.createUserName = info.name;
  2344. this.formData.createUserId = info.id;
  2345. // this.treeList = res;
  2346. // this.formData.extInfo.deptCode =
  2347. // this.getTreeList().then((res) => {
  2348. // if (res?.success) {
  2349. // this.treeList = res.data;
  2350. // }
  2351. // });
  2352. // this.getSupplier().then((res) => {
  2353. // if (res?.success) {
  2354. // this.supplierList = res.data.items;
  2355. // }
  2356. // });
  2357. // this.getStaffList();
  2358. },
  2359. addStock() {
  2360. // this.$refs.wareHouseDailogRef.open({});
  2361. // return;
  2362. if (!this.title) return this.$message.error('请选择入库产品类型');
  2363. if (!this.formData.bizType)
  2364. return this.$message.error('请选择入库场景');
  2365. this.visibleDialog = true;
  2366. },
  2367. handleChange(data) {
  2368. this.title = data?.dictValue;
  2369. this.selectEquiType = data?.dictCode;
  2370. },
  2371. handleChanges(code) {
  2372. const data = this.codeList.find((item) => item.dictCode == code);
  2373. this.title = data?.dictValue;
  2374. this.selectEquiType = data?.dictCode;
  2375. },
  2376. getSupplier() {
  2377. return new Promise((resolve, reject) => {
  2378. supplier.list({ page: 1, size: 999 }).then((res) => {
  2379. if (res.success) {
  2380. resolve(res);
  2381. }
  2382. });
  2383. });
  2384. },
  2385. getTreeList() {
  2386. return new Promise((resolve, reject) => {
  2387. org.tree().then((res) => {
  2388. if (res.success) {
  2389. resolve(res);
  2390. }
  2391. });
  2392. });
  2393. },
  2394. upload(data) {
  2395. this.formData.contentImage = data;
  2396. this.$refs.formName.validateField('contentImage');
  2397. },
  2398. houseData(argum, idx) {
  2399. this.$set(this.warehousingMaterialList[idx], 'houseList', argum);
  2400. }
  2401. },
  2402. watch: {
  2403. // 解决右侧悬浮操作栏不对称问题
  2404. warehousingMaterialList: {
  2405. handler() {
  2406. this.$nextTick(() => {
  2407. this.$refs.warehousingMaterialListTable.doLayout();
  2408. });
  2409. },
  2410. deep: true
  2411. },
  2412. // 解决右侧悬浮操作栏不对称问题
  2413. materialCodeReqList: {
  2414. handler() {
  2415. this.$nextTick(() => {
  2416. this.$refs.materialCodeReqListTable.doLayout();
  2417. });
  2418. },
  2419. deep: true
  2420. },
  2421. // 解决右侧悬浮操作栏不对称问题
  2422. resultArray: {
  2423. handler() {
  2424. this.$nextTick(() => {
  2425. this.$refs.resultArrayTable.doLayout();
  2426. });
  2427. },
  2428. deep: true
  2429. }
  2430. }
  2431. };
  2432. </script>
  2433. <style lang="scss" scoped>
  2434. ::v-deep.form-table {
  2435. .el-form-item {
  2436. margin-bottom: 0;
  2437. }
  2438. .el-input__inner {
  2439. padding: 0 10px;
  2440. }
  2441. ::-webkit-scrollbar {
  2442. width: 8px;
  2443. height: 8px;
  2444. background-color: transparent;
  2445. }
  2446. }
  2447. .p20 {
  2448. padding: 20px;
  2449. }
  2450. .el-select,
  2451. .el-date-editor {
  2452. width: 100%;
  2453. }
  2454. .el-form-item {
  2455. margin-bottom: 22px;
  2456. }
  2457. .material {
  2458. margin-top: 20px;
  2459. .flex {
  2460. display: flex;
  2461. justify-content: space-between;
  2462. font-size: 14px;
  2463. align-items: center;
  2464. .red {
  2465. color: #ff4949;
  2466. }
  2467. }
  2468. }
  2469. .mt10 {
  2470. margin-top: 10px;
  2471. }
  2472. .mt20 {
  2473. margin-top: 20px;
  2474. }
  2475. .center {
  2476. text-align: center;
  2477. }
  2478. .switch_left li {
  2479. border-right: 1px solid rgba(222, 222, 222, 1);
  2480. border-left: 1px solid rgba(222, 222, 222, 1);
  2481. }
  2482. .fontOmitted {
  2483. text-overflow: ellipsis;
  2484. overflow: hidden;
  2485. word-break: break-all;
  2486. white-space: nowrap;
  2487. }
  2488. .table-fixed {
  2489. .el-table__fixed-right {
  2490. height: 100% !important;
  2491. }
  2492. .el-table__fixed-left {
  2493. height: 100% !important;
  2494. }
  2495. .el-table__fixed {
  2496. height: 100% !important;
  2497. }
  2498. }
  2499. </style>