add.vue 40 KB

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