add.vue 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153
  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="6">
  13. <el-form-item label="出库场景" prop="bizType">
  14. <el-select
  15. filterable
  16. placeholder="请选择"
  17. v-model="formData.bizType"
  18. clearable
  19. @change="handleBizSceneChange"
  20. >
  21. <el-option
  22. v-for="item in outputSceneState"
  23. :key="item.code"
  24. :value="item.code + ''"
  25. :label="item.label"
  26. ></el-option>
  27. </el-select> </el-form-item
  28. ></el-col>
  29. <el-col :span="6">
  30. <el-form-item label="客户名称" prop="">
  31. <el-input
  32. placeholder="请选择"
  33. v-model="formData.clientName"
  34. style="width: calc(100% - 80px);"
  35. >
  36. </el-input>
  37. <openContactDialog style="margin-left: 3px;" @changeParent="contactDialogSuccess"></openContactDialog>
  38. </el-form-item>
  39. </el-col>
  40. <el-col :span="6">
  41. <el-form-item label="单据来源" prop="sourceBizNo">
  42. <el-input
  43. placeholder="请选择"
  44. v-model="formData.sourceBizNo"
  45. @click.native="openDocumentSourceDialog"
  46. >
  47. <el-button
  48. @click.stop="clearDocumentSource"
  49. slot="append"
  50. icon="el-icon-circle-close"
  51. ></el-button>
  52. </el-input>
  53. </el-form-item>
  54. </el-col>
  55. <el-col :span="6">
  56. <el-form-item label="出库物品类型" prop="extInfo.assetType">
  57. <el-select
  58. style="width: 100%"
  59. multiple
  60. v-model="formData.extInfo.assetType"
  61. placeholder="请选择"
  62. >
  63. <el-option
  64. v-for="item in goodsLists"
  65. :key="item.id"
  66. :label="item.name"
  67. :value="item.id"
  68. >
  69. </el-option>
  70. </el-select>
  71. </el-form-item>
  72. </el-col>
  73. <el-col :span="6">
  74. <el-form-item label="出库登记人">
  75. <el-input
  76. placeholder="登记人"
  77. disabled
  78. v-model="formData.extInfo.createUserName"
  79. clearable /></el-form-item
  80. ></el-col>
  81. <el-col :span="6">
  82. <el-form-item label="领料人部门" prop="extInfo.verifyDeptCode">
  83. <selectTree
  84. ref="tree"
  85. class="form-ipt"
  86. size="medium"
  87. style="width: 100%"
  88. :value="formData.extInfo.verifyDeptCode"
  89. clearable
  90. :options="treeList"
  91. :props="{
  92. value: 'id',
  93. label: 'name',
  94. children: 'children'
  95. }"
  96. @getValue="auditorDeptClick"
  97. />
  98. </el-form-item>
  99. </el-col>
  100. <el-col :span="6">
  101. <el-form-item label="领料人" prop="fromId">
  102. <el-select
  103. v-model="formData.fromId"
  104. filterable
  105. placeholder="请选择领料人"
  106. >
  107. <el-option
  108. v-for="item in llrLsit"
  109. :key="item.id"
  110. :label="item.name"
  111. :value="item.id"
  112. @click.native="userSlected(item)"
  113. >
  114. </el-option>
  115. </el-select> </el-form-item
  116. ></el-col>
  117. <!-- <el-col :span="6">
  118. <el-form-item label="领料人联系方式" prop="fromUserPhone">
  119. <el-input
  120. placeholder="请输入"
  121. disabled
  122. v-model="formData.extInfo.fromUserPhone"
  123. clearable /></el-form-item
  124. ></el-col> -->
  125. <el-col :span="12">
  126. <el-form-item label="备注" prop="remark">
  127. <el-input
  128. v-model="formData.remark"
  129. placeholder="请详细说明"
  130. ></el-input>
  131. </el-form-item>
  132. </el-col>
  133. </el-row>
  134. </el-form>
  135. <div>
  136. <el-button
  137. style="margin-bottom: 20px; float: right; margin-right: 20px"
  138. type="primary"
  139. @click="addStock"
  140. >添加</el-button
  141. >
  142. </div>
  143. <div class="material">
  144. <div>
  145. <header-title title="物品清单"></header-title>
  146. <div class="mt10 form-table">
  147. <el-table
  148. ref="productListTable"
  149. :data="productList"
  150. border
  151. tooltip-effect="dark"
  152. :max-height="300"
  153. :header-cell-style="rowClass"
  154. >
  155. <el-table-column label="序号" type="index" width="50">
  156. </el-table-column>
  157. <el-table-column
  158. label="编码"
  159. prop="categoryCode"
  160. align="center"
  161. :show-overflow-tooltip="true"
  162. ></el-table-column>
  163. <el-table-column
  164. label="名称"
  165. align="center"
  166. prop="categoryName"
  167. :show-overflow-tooltip="true"
  168. ></el-table-column>
  169. <el-table-column
  170. v-if="clientEnvironmentId == 4"
  171. label="级别"
  172. prop="level"
  173. align="center"
  174. >
  175. </el-table-column>
  176. <el-table-column
  177. label="型号"
  178. align="center"
  179. prop="categoryModel"
  180. :show-overflow-tooltip="true"
  181. ></el-table-column>
  182. <el-table-column
  183. label="规格"
  184. align="center"
  185. prop="specification"
  186. :show-overflow-tooltip="true"
  187. ></el-table-column>
  188. <el-table-column
  189. label="牌号"
  190. align="center"
  191. prop="brandNum"
  192. :show-overflow-tooltip="true"
  193. ></el-table-column>
  194. <el-table-column
  195. v-for="(item, index) in newColumns"
  196. :label="item.label"
  197. :align="item.align"
  198. :prop="item.prop"
  199. :show-overflow-tooltip="item.showOverflowTooltip"
  200. ></el-table-column>
  201. <el-table-column
  202. label="批次号"
  203. prop="batchNo"
  204. width="150"
  205. align="center"
  206. :show-overflow-tooltip="true"
  207. >
  208. </el-table-column>
  209. <el-table-column
  210. label="包装数量"
  211. v-if="clientEnvironmentId == 3"
  212. prop="packingQuantity"
  213. align="center"
  214. >
  215. <template slot-scope="{ row, $index }">
  216. {{ row.packingQuantity }} {{ row.packingUnit }}
  217. </template>
  218. </el-table-column>
  219. <el-table-column
  220. v-else
  221. label="包装数量"
  222. prop="packingQuantity"
  223. width="80"
  224. ></el-table-column>
  225. <el-table-column
  226. v-if="clientEnvironmentId == 3"
  227. label="最小包装单元"
  228. align="center"
  229. width="120"
  230. prop="minPackingQuantity"
  231. >
  232. <template slot-scope="{ row, $index }">
  233. {{ row.minPackingQuantity }} {{ row.measureUnit }} /{{
  234. row.packingUnit
  235. }}
  236. </template>
  237. </el-table-column>
  238. <el-table-column
  239. v-else
  240. label="包装单位"
  241. prop="packingUnit"
  242. ></el-table-column>
  243. <el-table-column
  244. label="计量数量"
  245. prop="measureQuantity"
  246. width="100"
  247. align="center"
  248. >
  249. </el-table-column>
  250. <el-table-column
  251. label="计量单位"
  252. prop="measureUnit"
  253. align="center"
  254. >
  255. <template slot-scope="{ row, $index }">
  256. <template>
  257. {{ row.measureUnit }}
  258. </template>
  259. </template>
  260. </el-table-column>
  261. <el-table-column
  262. label="重量"
  263. prop="weight"
  264. align="center"
  265. :show-overflow-tooltip="true"
  266. >
  267. </el-table-column>
  268. <el-table-column
  269. label="重量单位"
  270. prop="weightUnit"
  271. align="center"
  272. :show-overflow-tooltip="true"
  273. >
  274. </el-table-column>
  275. <el-table-column label="单价" prop="price" align="center">
  276. <template slot-scope="{ row }">
  277. <template>
  278. {{ row.price ? row.price : '-' + '元' }}/{{
  279. row.measureUnit
  280. }}
  281. </template>
  282. </template>
  283. </el-table-column>
  284. <el-table-column
  285. label="金额"
  286. align="center"
  287. prop="totalMoney"
  288. :show-overflow-tooltip="true"
  289. >
  290. <template slot-scope="{ row, $index }">
  291. {{ row.totalMoney ? row.totalMoney : 0 }}
  292. </template>
  293. </el-table-column>
  294. <el-table-column
  295. v-if="clientEnvironmentId == 4"
  296. label="采购原因"
  297. align="center"
  298. prop="purpose"
  299. :show-overflow-tooltip="true"
  300. ></el-table-column>
  301. <el-table-column
  302. label="仓库"
  303. prop="warehouseName"
  304. :show-overflow-tooltip="true"
  305. >
  306. </el-table-column>
  307. <el-table-column
  308. prop="supplierName"
  309. label="供应商"
  310. min-width="200"
  311. :show-overflow-tooltip="true"
  312. ></el-table-column>
  313. <el-table-column
  314. prop="supplierCode"
  315. label="供应商代号"
  316. min-width="200"
  317. :show-overflow-tooltip="true"
  318. ></el-table-column>
  319. </el-table>
  320. </div>
  321. <header-title class="mt20" title="包装清单"></header-title>
  322. <div class="mt10 form-table">
  323. <el-table
  324. ref="showPackingListTable"
  325. :data="showPackingList"
  326. tooltip-effect="dark"
  327. :max-height="300"
  328. border
  329. :row-class-name="tableRowClassName"
  330. :header-cell-style="rowClass"
  331. v-el-table-infinite-scroll="pickingHandleScroll"
  332. >
  333. <el-table-column label="序号" type="index" width="50">
  334. </el-table-column>
  335. <el-table-column
  336. label="编码"
  337. prop="categoryCode"
  338. :show-overflow-tooltip="true"
  339. ></el-table-column>
  340. <el-table-column
  341. label="名称"
  342. prop="categoryName"
  343. :show-overflow-tooltip="true"
  344. ></el-table-column>
  345. <el-table-column
  346. label="批次号"
  347. prop="batchNo"
  348. width="150"
  349. :show-overflow-tooltip="true"
  350. ></el-table-column>
  351. <el-table-column
  352. label="发货条码"
  353. prop="barcodes"
  354. :show-overflow-tooltip="true"
  355. ></el-table-column>
  356. <el-table-column
  357. label="包装编码"
  358. prop="packageNo"
  359. :show-overflow-tooltip="true"
  360. ></el-table-column>
  361. <el-table-column
  362. label="包装数量"
  363. prop="packingQuantity"
  364. :show-overflow-tooltip="true"
  365. ></el-table-column>
  366. <el-table-column
  367. label="包装单位"
  368. prop="packingUnit"
  369. :show-overflow-tooltip="true"
  370. ></el-table-column>
  371. <el-table-column
  372. label="计量数量"
  373. prop="measureQuantity"
  374. :show-overflow-tooltip="true"
  375. ></el-table-column>
  376. <el-table-column
  377. label="计量单位"
  378. prop="measureUnit"
  379. :show-overflow-tooltip="true"
  380. ></el-table-column>
  381. <el-table-column
  382. label="物料代号"
  383. prop="materielDesignation"
  384. :show-overflow-tooltip="true"
  385. >
  386. </el-table-column>
  387. <el-table-column
  388. label="客户代号"
  389. prop="clientCode"
  390. :show-overflow-tooltip="true"
  391. >
  392. </el-table-column>
  393. <el-table-column
  394. label="刻码"
  395. prop="engrave"
  396. :show-overflow-tooltip="true"
  397. >
  398. </el-table-column>
  399. <el-table-column
  400. label="重量"
  401. prop="weight"
  402. :show-overflow-tooltip="true"
  403. >
  404. </el-table-column>
  405. <el-table-column
  406. label="重量单位"
  407. prop="weightUnit"
  408. :show-overflow-tooltip="true"
  409. >
  410. </el-table-column>
  411. <el-table-column
  412. label="质检结果"
  413. prop="result"
  414. :show-overflow-tooltip="true"
  415. >
  416. <template slot-scope="{ row }">
  417. <span>{{ qualityResults[row.result] }}</span>
  418. </template>
  419. </el-table-column>
  420. <el-table-column
  421. label="质检状态"
  422. prop="status"
  423. :show-overflow-tooltip="true"
  424. >
  425. <template slot-scope="{ row }">
  426. <span>{{ qualityStatus[row.status] }}</span>
  427. </template>
  428. </el-table-column>
  429. <el-table-column
  430. label="生产日期"
  431. prop="productionDate"
  432. :show-overflow-tooltip="true"
  433. >
  434. </el-table-column>
  435. <el-table-column
  436. label="采购日期"
  437. prop="purchaseDate"
  438. :show-overflow-tooltip="true"
  439. >
  440. </el-table-column>
  441. <el-table-column
  442. prop="supplierName"
  443. label="供应商"
  444. min-width="200"
  445. :show-overflow-tooltip="true"
  446. ></el-table-column>
  447. <el-table-column
  448. prop="supplierCode"
  449. label="供应商代号"
  450. min-width="200"
  451. :show-overflow-tooltip="true"
  452. ></el-table-column>
  453. </el-table>
  454. </div>
  455. </div>
  456. <!-- <div class="mt20">
  457. <header-title class="mt20" title="物料明细"></header-title>
  458. <el-table ref="multipleTable" :data="showMaterialList" tooltip-effect="dark" :max-height="300"
  459. :row-class-name="tableRowClassName" :header-cell-style="rowClass" border style="width: 100%" stripe
  460. height="300px" v-el-table-infinite-scroll="materielHandleScroll">
  461. <el-table-column label="序号" type="index" width="50">
  462. </el-table-column>
  463. <el-table-column label="编码" prop="categoryCode" :show-overflow-tooltip="true"></el-table-column>
  464. <el-table-column label="名称" prop="categoryName" :show-overflow-tooltip="true"></el-table-column>
  465. <el-table-column label="批次号" prop="batchNo"></el-table-column>
  466. <el-table-column label="物料编码" prop="materialCode" :show-overflow-tooltip="true"></el-table-column>
  467. <el-table-column label="发货条码" prop="barcodes" :show-overflow-tooltip="true"></el-table-column>
  468. <el-table-column label="计量数量" prop="minPackingCount"></el-table-column>
  469. <el-table-column label="计量单位" prop="measuringUnit"></el-table-column>
  470. <el-table-column label="物料代号" prop="materielDesignation">
  471. </el-table-column>
  472. <el-table-column label="客户代号" prop="clientCode">
  473. </el-table-column>
  474. <el-table-column label="刻码" prop="engrave"> </el-table-column>
  475. <el-table-column width="100" label="重量" prop="weight">
  476. </el-table-column>
  477. <el-table-column label="重量单位" prop="weightUnit">
  478. </el-table-column>
  479. <el-table-column label="质检结果" prop="result" width="120">
  480. <template slot-scope="{ row }">
  481. <span>{{ qualityResults[row.result] }}</span>
  482. </template>
  483. </el-table-column>
  484. <el-table-column label="质检状态" prop="status" width="120">
  485. <template slot-scope="{ row }">
  486. <span>{{ qualityStatus[row.status] }}</span>
  487. </template>
  488. </el-table-column>
  489. </el-table>
  490. </div> -->
  491. </div>
  492. <div class="center mt20">
  493. <el-button
  494. type="primary"
  495. @click="handleSave('save')"
  496. :loading="saveLoading"
  497. >保存</el-button
  498. >
  499. <el-button type="primary" @click="handleSave" :loading="saveLoading"
  500. >出库</el-button
  501. >
  502. <el-button @click="$router.go(-1)">返回</el-button>
  503. </div>
  504. </el-card>
  505. <AssetsDialog
  506. ref="assetsDialogRef"
  507. :treeIds="formData.extInfo.assetType"
  508. @detailData="detailData"
  509. />
  510. <outboundRequisitionDialog
  511. ref="outboundRequisitionDialogRef"
  512. @detailData="outboundRequisitionSelection"
  513. type="2"
  514. />
  515. </div>
  516. </template>
  517. <script>
  518. import storageApi from '@/api/warehouseManagement/index.js';
  519. import elTableInfiniteScroll from 'el-table-infinite-scroll';
  520. import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
  521. import { getTreeByGroup } from '@/api/classifyManage';
  522. import openContactDialog from '@/components/contactDialog/openContactDialog.vue';
  523. import {
  524. outputSceneState,
  525. qualityStatus,
  526. qualityResults
  527. } from '@/utils/dict/index';
  528. import outboundRequisitionDialog from '../components/outboundRequisitionDialog.vue';
  529. import selectTree from '@/components/selectTree';
  530. import AssetsDialog from '../components/AssetsDialog.vue';
  531. import { deepClone } from '@/utils';
  532. export default {
  533. name: 'outgoingManagementAdd',
  534. components: {
  535. selectTree,
  536. AssetsDialog,
  537. outboundRequisitionDialog,openContactDialog
  538. },
  539. directives: {
  540. 'el-table-infinite-scroll': elTableInfiniteScroll
  541. },
  542. data() {
  543. return {
  544. newColumns: [], // 动态表头
  545. goodsLists: [], // 商品列表
  546. qualityStatus, // 质检状态 0未检 1待检 2已检
  547. qualityResults, // 质检结果 0无 1合格 2不合格
  548. productList: [], // 产品列表
  549. showPackingList: [], // 展示的包装列表
  550. packingList: [], // 包装列表
  551. showMaterialList: [], // 展示物料列表
  552. materialList: [], // 物料列表
  553. extInfo: {}, // 扩展信息
  554. pageSize: 20,
  555. pickingPageNum: 1,
  556. materielPageNum: 1,
  557. dimension: '3',
  558. outputSceneState: outputSceneState.filter(
  559. (item) => item.code != '4' && item.code != '11'
  560. ), // 出库场景状态
  561. saveLoading: false,
  562. treeList: [],
  563. formData: {
  564. extInfo: {
  565. assetType: [], //物品类型id
  566. assetTypeName: '', //物品类型名称
  567. deptCode: '', //部门code
  568. deptName: '', //部门名称
  569. verifyDeptCode: '', //审核部门编码
  570. verifyDeptName: '', //审核部门名称
  571. deliveryName: '', //送货人名称
  572. fromUserPhone: '', //送货人电话
  573. sourceBizNo: '', //销售订单
  574. urgent: '', //紧急状态
  575. supplierId: '', //供应商ID
  576. supplierName: '', //供应商名称
  577. createUserName: '', //创建人名字
  578. contentImage: [] //图片数组
  579. },
  580. fromUser: '', //送货人
  581. bizType: '', //物品类型
  582. verifyId: '', //审核人Id
  583. verifyName: '', //审核人名称
  584. createUserId: '',
  585. remark: ''
  586. },
  587. rules: {
  588. bizType: {
  589. required: true,
  590. message: '请选择出库场景',
  591. trigger: 'change'
  592. },
  593. 'extInfo.assetType': {
  594. required: true,
  595. message: '请选择物品类型',
  596. trigger: ['change', 'blur']
  597. },
  598. fromId: {
  599. required: true,
  600. message: '请选择领料人',
  601. trigger: 'change'
  602. },
  603. 'extInfo.verifyDeptCode': {
  604. required: true,
  605. message: '请选择领料人部门',
  606. trigger: ['change', 'blur']
  607. }
  608. },
  609. llrLsit: []
  610. };
  611. },
  612. computed: {
  613. clientEnvironmentId() {
  614. return this.$store.state.user.info.clientEnvironmentId;
  615. }
  616. },
  617. async created() {
  618. this.getFieldModel();
  619. this.getListItems();
  620. this.initUserInfo();
  621. this.initDeptData();
  622. let queryObj = this.$route.query;
  623. console.log('queryObj------', queryObj);
  624. if (queryObj.ids) {
  625. this.formData.bizType = queryObj.bizType;
  626. this.formData.extInfo.assetType = queryObj.assetType.split(',');
  627. let data = await storageApi.getHierarchyList({
  628. ids: this.$route.query.ids,
  629. type: 3
  630. });
  631. this.detailData(data, 3);
  632. }
  633. if (queryObj.type) {
  634. this.formData.sourceBizNo = queryObj.code;
  635. this.$nextTick(() => {
  636. this.$refs.outboundRequisitionDialogRef.handleMine([queryObj]);
  637. });
  638. }
  639. console.log(queryObj, 'queryObj.detailId');
  640. if (queryObj.detailId) {
  641. this._getInfo(queryObj.detailId);
  642. }
  643. },
  644. methods: {
  645. outboundRequisitionSelection(data, dimension, query) {
  646. console.log(data, dimension, query);
  647. this.formData.sourceBizNo = query.sourceBizNo;
  648. this.formData.bizType = query.bizType;
  649. this.formData.extInfo.assetType = query.assetType.split(',');
  650. this.detailData(data, dimension);
  651. },
  652. // 获取动态表头
  653. getFieldModel() {
  654. storageApi.fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  655. let newRes = res.map((m) => {
  656. return {
  657. prop: 'extField.' + m.prop,
  658. label: m.label,
  659. align: 'center',
  660. showOverflowTooltip: true
  661. };
  662. });
  663. this.newColumns = [...newRes];
  664. });
  665. },
  666. userSlected(data) {
  667. console.log(data);
  668. this.formData.fromId = data.id;
  669. this.formData.fromUser = data.name;
  670. this.formData.fromUserPhone = data.phone;
  671. },
  672. clearDocumentSource() {
  673. console.log('清空');
  674. },
  675. pickingHandleScroll() {
  676. console.log('---------pickingHandleScroll------------');
  677. if (this.showPackingList.length < this.packingList.length) {
  678. if (this.packingList.length > this.pageSize) {
  679. this.pickingPageNum += 1;
  680. }
  681. this.pickingFetchData();
  682. }
  683. },
  684. pickingFetchData() {
  685. const start = (this.pickingPageNum - 1) * this.pageSize;
  686. const end = start + this.pageSize;
  687. this.showPackingList = this.showPackingList.concat(
  688. this.packingList.slice(start, end)
  689. );
  690. },
  691. materielHandleScroll() {
  692. console.log('---------materielHandleScroll------------');
  693. if (this.showMaterialList.length < this.materialList.length) {
  694. if (this.materialList.length > this.pageSize) {
  695. this.materielPageNum += 1;
  696. }
  697. this.materielFetchData();
  698. }
  699. },
  700. materielFetchData() {
  701. const start = (this.materielPageNum - 1) * this.pageSize;
  702. const end = start + this.pageSize;
  703. this.showMaterialList = this.showMaterialList.concat(
  704. this.materialList.slice(start, end)
  705. );
  706. console.log(this.showMaterialList);
  707. },
  708. // 获取物品列表
  709. async getListItems() {
  710. const { data } = await getTreeByGroup({ type: 2 });
  711. this.goodsLists = data;
  712. },
  713. // 打开单据来源弹窗
  714. openDocumentSourceDialog() {
  715. this.$refs.outboundRequisitionDialogRef.open();
  716. },
  717. tableRowClassName({ row, rowIndex }) {
  718. console.log(row);
  719. if (row.result == 1) {
  720. return 'warning-row';
  721. } else {
  722. return '';
  723. }
  724. },
  725. // getDeptName() {
  726. // if (this.formData?.extInfo?.createUserId) {
  727. // storageApi.getGroupById(this.formData.extInfo.createUserId).then((res) => {
  728. // this.formData.extInfo.deptName = res?.groupName
  729. // });
  730. // }
  731. // },
  732. async _getInfo(detailId) {
  733. let res = await storageApi.getInboundDetailsById(detailId);
  734. this.formData = res;
  735. this.formData.extInfo.assetType = res.extInfo?.assetType?.split(',');
  736. this.formData.bizType = res.bizType + '';
  737. console.log(this.formData.extInfo, '');
  738. this.auditorDeptClick({
  739. id: this.formData.extInfo?.verifyDeptCode,
  740. name: this.formData.extInfo?.verifyDeptName
  741. });
  742. // this.getDeptName()
  743. this.productList = res.outInDetailList.map(
  744. (productItem, productIndex) => {
  745. return {
  746. ...productItem,
  747. outInDetailRecordRequestList:
  748. productItem.outInDetailRecordRequestList.map((packingItem) => {
  749. return {
  750. ...packingItem,
  751. categoryName: productItem.categoryName,
  752. categoryCode: productItem.categoryCode,
  753. materialDetailList: packingItem.materialDetailList.map(
  754. (materialItem) => {
  755. return {
  756. ...materialItem,
  757. categoryName: productItem.categoryName,
  758. categoryCode: productItem.categoryCode
  759. };
  760. }
  761. )
  762. };
  763. })
  764. };
  765. }
  766. );
  767. // 获取包装维度数据
  768. const arr = [];
  769. for (const key in this.productList) {
  770. for (const k in this.productList[key].outInDetailRecordRequestList) {
  771. arr.push({
  772. ...this.productList[key].outInDetailRecordRequestList[k]
  773. });
  774. }
  775. }
  776. this.packingList = arr;
  777. // 获取物料维度数据
  778. let iArr = [];
  779. arr.forEach((item) => {
  780. item.materialDetailList.forEach((ele) => {
  781. iArr.push({ ...ele });
  782. });
  783. });
  784. this.materialList = iArr;
  785. console.log(this.packingList);
  786. console.log(this.materialList);
  787. this.pickingFetchData();
  788. this.materielFetchData();
  789. },
  790. detailData(data, dimension) {
  791. this.dimension = dimension;
  792. const mergedData = [...(this.formData.outInDetailList || []), ...data];
  793. this.formData.outInDetailList = mergedData;
  794. this.productList = mergedData.map((productItem) => {
  795. console.log(productItem, 'productItem');
  796. return {
  797. ...productItem,
  798. outInDetailRecordRequestList:
  799. productItem.outInDetailRecordRequestList.map((packingItem) => {
  800. return {
  801. ...packingItem,
  802. categoryName: productItem.categoryName,
  803. categoryCode: productItem.categoryCode,
  804. supplierCode: productItem.supplierCode,
  805. supplierName: productItem.supplierName,
  806. materialDetailList: packingItem.materialDetailList.map(
  807. (materialItem) => {
  808. return {
  809. ...materialItem,
  810. categoryName: productItem.categoryName,
  811. categoryCode: productItem.categoryCode
  812. };
  813. }
  814. )
  815. };
  816. })
  817. };
  818. });
  819. const newProducts = mergedData.map((productItem) => ({
  820. ...productItem,
  821. outInDetailRecordRequestList:
  822. productItem.outInDetailRecordRequestList.map((packingItem) => ({
  823. ...packingItem,
  824. categoryName: productItem.categoryName,
  825. categoryCode: productItem.categoryCode,
  826. supplierCode: productItem.supplierCode,
  827. supplierName: productItem.supplierName,
  828. materialDetailList: packingItem.materialDetailList.map(
  829. (materialItem) => ({
  830. ...materialItem,
  831. categoryName: productItem.categoryName,
  832. categoryCode: productItem.categoryCode,
  833. supplierCode: productItem.supplierCode,
  834. supplierName: productItem.supplierName
  835. })
  836. )
  837. }))
  838. }));
  839. // 去重合并产品列表和新产品列表
  840. const uniqueProducts = [
  841. ...new Map(
  842. [...this.productList, ...newProducts].map((item) => [item.id, item])
  843. ).values()
  844. ];
  845. this.productList = uniqueProducts;
  846. //排序
  847. this.productList.sort((a, b) => a.categoryCode - b.categoryCode);
  848. console.log(this.productList, '物品清单');
  849. // 获取包装维度数据
  850. const arr = [];
  851. for (const key in this.productList) {
  852. for (const k in this.productList[key].outInDetailRecordRequestList) {
  853. arr.push({
  854. ...this.productList[key].outInDetailRecordRequestList[k]
  855. });
  856. }
  857. }
  858. this.packingList = arr;
  859. const newPacking = [];
  860. newProducts.forEach((item) => {
  861. newPacking.push(...item.outInDetailRecordRequestList);
  862. });
  863. //去重
  864. const newPackingList = [
  865. ...new Map(
  866. [...this.packingList, ...newPacking].map((item) => [item.id, item])
  867. ).values()
  868. ];
  869. this.packingList = newPackingList;
  870. this.packingList.sort((a, b) => a.categoryCode - b.categoryCode);
  871. console.log(this.packingList, '包装');
  872. // 获取物料维度数据
  873. let iArr = [];
  874. arr.forEach((item) => {
  875. item.materialDetailList.forEach((ele) => {
  876. iArr.push({ ...ele });
  877. });
  878. });
  879. this.materialList = iArr;
  880. const newMaterial = [];
  881. newPacking.forEach((item) => {
  882. newMaterial.push(...item.materialDetailList);
  883. });
  884. this.materialList = [...this.materialList, ...newMaterial];
  885. // 触发分页更新
  886. this.pickingPageNum = 1;
  887. this.materielPageNum = 1;
  888. this.pickingFetchData();
  889. this.materielFetchData();
  890. },
  891. handleSave(type) {
  892. this.$refs.formName.validate(async (valid) => {
  893. if (valid) {
  894. if (!this.productList?.length) {
  895. return this.$message.error('请添加出库明细!');
  896. }
  897. let obj = deepClone({ ...this.formData, type: 2 });
  898. obj.extInfo.sourceBizNo = obj.sourceBizNo;
  899. obj.fromType = obj.type;
  900. this.saveLoading = true;
  901. // 处理物品类型assetType
  902. obj.extInfo.assetType = obj.extInfo.assetType.join(',');
  903. // 处理仓库id
  904. let warehouseId = [];
  905. let warehouseName = [];
  906. let warehouseIds = this.productList
  907. .map((item) => item.warehouseId)
  908. .flat();
  909. let warehouseNames = this.productList
  910. .map((item) => item.warehouseName)
  911. .flat();
  912. warehouseIds.forEach((item, index) => {
  913. if (!warehouseId.includes(item)) {
  914. warehouseId.push(item);
  915. warehouseName.push(warehouseNames[index]);
  916. }
  917. });
  918. obj.warehouseIds = warehouseId;
  919. obj.warehouseNames = warehouseName;
  920. try {
  921. let api = obj.id ? storageApi.outUpdate : storageApi.outStorage;
  922. const res = await api(obj);
  923. if (res.code == 0) {
  924. if (type != 'save') {
  925. await storageApi.submitInsideTwo({ outInIds: res.data });
  926. this.$message.success('出库成功!');
  927. } else {
  928. this.$message.success('保存成功!');
  929. }
  930. this.$router.push('/warehouseManagement/outgoingManagement');
  931. }
  932. this.saveLoading = false;
  933. } catch (error) {
  934. this.saveLoading = false;
  935. this.$router.push('/warehouseManagement/outgoingManagement');
  936. this.$message.error('保存失败!');
  937. }
  938. } else {
  939. this.$message.error('请选择领料人!');
  940. }
  941. });
  942. },
  943. contactDialogSuccess(data){
  944. this.$set(this.formData,'clientName',data.name)
  945. this.$set(this.formData,'clientCode',data.code)
  946. },
  947. onClear() {
  948. this.formData.sourceBizNo = '';
  949. this.warehousingMaterialList = [];
  950. this.$refs.trees.valueTitle = '';
  951. this.formData.clientName = '';
  952. this.formData.clientUser = '';
  953. this.formData.clientPhone = '';
  954. this.$forceUpdate();
  955. },
  956. rowClass({ row, column, rowIndex, columnIndex }) {
  957. if (rowIndex === 1) {
  958. return {
  959. display: 'none',
  960. background: '#EEEEEE'
  961. };
  962. }
  963. return { background: '#0000' };
  964. },
  965. // 部门点击事件
  966. async auditorDeptClick(data) {
  967. console.log(data);
  968. this.formData.extInfo.verifyDeptCode = data?.id;
  969. this.formData.extInfo.verifyDeptName = data?.name;
  970. this.$set(this.formData.extInfo, 'verifyDeptCode', data?.id);
  971. this.$set(this.formData.extInfo, 'verifyDeptName', data?.name);
  972. this.formData.verifyId = '';
  973. this.formData.verifyName = '';
  974. this.$refs.formName.validateField('verifyDeptName');
  975. if (data) {
  976. this.getStaffList(data);
  977. }
  978. },
  979. async getStaffList(data) {
  980. let res = await warehouseDefinition.getUserPage({
  981. groupId: data.id,
  982. size: 9999,
  983. page: 1
  984. });
  985. this.llrLsit = res.list;
  986. },
  987. // 初始化用户信息
  988. async initUserInfo() {
  989. const res = await warehouseDefinition.tree();
  990. let info = JSON.parse(localStorage.getItem('info'));
  991. let obj = res.find(
  992. (item) => item.id === info.deptIds[info.deptIds.length - 1]
  993. );
  994. // if (!obj) return;
  995. if (obj) {
  996. this.formData.extInfo.deptCode = obj.id;
  997. this.formData.extInfo.deptName = obj.name;
  998. } else {
  999. this.formData.extInfo.deptName = info.deptName
  1000. ? info.deptName
  1001. : info.groupName
  1002. ? info.groupName
  1003. : '';
  1004. }
  1005. this.formData.extInfo.createUserName = info.name;
  1006. this.formData.createUserId = info.userId;
  1007. },
  1008. // 初始化部门数据
  1009. async initDeptData() {
  1010. const res = await warehouseDefinition.tree();
  1011. this.treeList = this.$util.toTreeData({
  1012. data: res,
  1013. idField: 'id',
  1014. parentIdField: 'parentId'
  1015. });
  1016. },
  1017. addStock() {
  1018. if (
  1019. !(
  1020. this.formData.extInfo.assetType &&
  1021. this.formData.extInfo.assetType.length > 0
  1022. )
  1023. )
  1024. return this.$message.error('请选择出库产品类型');
  1025. if (!this.formData.bizType && this.formData.bizType !== 0)
  1026. return this.$message.error('请选择出库场景');
  1027. this.$refs.assetsDialogRef.open(this.productList);
  1028. },
  1029. handleBizSceneChange() {
  1030. if (this.formData.extInfo.assetType == 7) {
  1031. this.formData.extInfo.sourceBizNo = '';
  1032. }
  1033. this.formData.sourceBizNo = '';
  1034. }
  1035. },
  1036. watch: {
  1037. packingList: {
  1038. handler(newVal) {
  1039. console.log('包装列表', newVal);
  1040. console.log('当前包装列表加载页数', this.pickingPageNum);
  1041. this.showPackingList = newVal.slice(
  1042. 0,
  1043. this.pageSize * (this.pickingPageNum > 0 ? this.pickingPageNum : 1)
  1044. );
  1045. },
  1046. deep: true
  1047. },
  1048. materialList: {
  1049. handler(newVal) {
  1050. console.log('物料列表', newVal);
  1051. console.log('当前物料列表加载页数', this.materielPageNum);
  1052. this.showMaterialList = newVal.slice(
  1053. 0,
  1054. this.pageSize *
  1055. (this.materielPageNum > 0 ? this.materielPageNum : 1)
  1056. );
  1057. },
  1058. deep: true
  1059. },
  1060. '$route.query': {
  1061. handler(newQuery, oldQuery) {
  1062. if (newQuery?.detailId) {
  1063. this._getInfo(newQuery.detailId);
  1064. }
  1065. },
  1066. deep: true // 确保对象内部的属性变化也能被监听到
  1067. }
  1068. }
  1069. };
  1070. </script>
  1071. <style lang="scss" scoped>
  1072. ::v-deep .el-row {
  1073. display: flex;
  1074. flex-wrap: wrap;
  1075. }
  1076. ::v-deep.form-table {
  1077. .el-form-item {
  1078. margin-bottom: 0;
  1079. }
  1080. .el-input__inner {
  1081. padding: 0 10px;
  1082. }
  1083. }
  1084. .p20 {
  1085. padding: 20px;
  1086. }
  1087. .el-select,
  1088. .el-date-editor {
  1089. width: 100%;
  1090. }
  1091. .el-form-item {
  1092. margin-bottom: 22px;
  1093. }
  1094. .material {
  1095. margin-top: 20px;
  1096. .flex {
  1097. display: flex;
  1098. justify-content: space-between;
  1099. font-size: 14px;
  1100. align-items: center;
  1101. .red {
  1102. color: #ff4949;
  1103. }
  1104. }
  1105. }
  1106. .mt10 {
  1107. margin-top: 10px;
  1108. }
  1109. .mt20 {
  1110. margin-top: 20px;
  1111. }
  1112. .center {
  1113. text-align: center;
  1114. }
  1115. </style>