AssetsDialog.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. <template>
  2. <el-dialog
  3. :visible.sync="visible"
  4. :append-to-body="true"
  5. :title="`${title}信息`"
  6. width="80vw"
  7. >
  8. <el-form :model="searchForm" label-width="100px">
  9. <el-row>
  10. <!-- <el-col :span="6">
  11. <el-form-item label="仓库:" prop="warehouseId">
  12. <el-select
  13. style="width: 100%"
  14. clearable
  15. v-model="searchForm.warehouseId"
  16. placeholder="请选择"
  17. >
  18. <el-option
  19. v-for="item in warehouseList"
  20. :label="item.name"
  21. :value="item.id"
  22. :key="item.id"
  23. >
  24. </el-option>
  25. </el-select>
  26. </el-form-item>
  27. </el-col> -->
  28. <!-- <el-col :span="6">
  29. <el-form-item label="货位:" prop="cargoSpaceCode">
  30. <el-input
  31. v-model.trim="searchForm.cargoSpaceCode"
  32. placeholder="请输入"
  33. ></el-input>
  34. </el-form-item>
  35. </el-col>
  36. <el-col :span="6">
  37. <el-form-item label="批次号:" prop="batchNum">
  38. <el-input
  39. v-model.trim="searchForm.batchNum"
  40. placeholder="请输入"
  41. ></el-input>
  42. </el-form-item>
  43. </el-col> -->
  44. <!-- <el-col :span="6">
  45. <el-form-item label="包装编码:" prop="num">
  46. <el-input
  47. v-model.trim="searchForm.num"
  48. placeholder="请输入"
  49. ></el-input>
  50. </el-form-item>
  51. </el-col> -->
  52. <el-col :span="6">
  53. <el-form-item label="列表维度:" prop="dimension">
  54. <template>
  55. <el-select
  56. style="width: 100%"
  57. @change="changeDimensionHandler"
  58. v-model="dimension"
  59. placeholder="请选择"
  60. >
  61. <el-option label="物料维度" value="4"> </el-option>
  62. <el-option label="包装维度" value="3"> </el-option>
  63. <el-option label="批次维度" value="2"> </el-option>
  64. <!-- <el-option label="物品维度" value="1"> </el-option> -->
  65. </el-select>
  66. </template>
  67. </el-form-item>
  68. </el-col>
  69. <el-col :span="6">
  70. <el-form-item label="物品编码">
  71. <el-input
  72. type="text"
  73. placeholder="搜索物品编码"
  74. v-model="searchForm.code"
  75. ></el-input>
  76. </el-form-item>
  77. </el-col>
  78. <el-col :span="6">
  79. <el-form-item label="物品名称">
  80. <el-input
  81. type="text"
  82. placeholder="搜索物品名称"
  83. v-model="searchForm.name"
  84. ></el-input>
  85. </el-form-item>
  86. </el-col>
  87. <el-col :span="6">
  88. <el-form-item label="批次号">
  89. <el-input
  90. type="text"
  91. placeholder="搜索物品批次号"
  92. v-model="searchForm.batchNo"
  93. ></el-input>
  94. </el-form-item>
  95. </el-col>
  96. <el-col :span="6">
  97. <el-form-item label="刻码">
  98. <el-input
  99. type="text"
  100. placeholder="搜索物品刻码"
  101. v-model="searchForm.engrave"
  102. ></el-input>
  103. </el-form-item>
  104. </el-col>
  105. <el-col style="text-align: right">
  106. <el-button type="primary" @click="doSearch">搜索</el-button>
  107. <el-button icon="el-icon-refresh-left" @click="reset">重置</el-button>
  108. </el-col>
  109. </el-row>
  110. </el-form>
  111. <el-container>
  112. <el-aside width="200px" class="wrapper-assets">
  113. <AssetTree
  114. @handleNodeClick="handleNodeClick"
  115. :type="assetType"
  116. ref="treeList"
  117. :init="true"
  118. paramsType="type"
  119. />
  120. </el-aside>
  121. <el-main>
  122. <el-table
  123. ref="multipleTable"
  124. :data="tableData"
  125. tooltip-effect="dark"
  126. height="50vh"
  127. border
  128. row-key="oid"
  129. style="width: 100%"
  130. :header-cell-style="{ background: '#F0F3F3', border: 'none' }"
  131. @selection-change="handleSelectionChange"
  132. >
  133. <el-table-column
  134. type="selection"
  135. :reserve-selection="true"
  136. width="55"
  137. align="center"
  138. fixed="left"
  139. :selectable="selectable"
  140. >
  141. </el-table-column>
  142. <el-table-column
  143. prop="assetCode"
  144. label="编码"
  145. min-width="120"
  146. v-if="dimension != 3 || dimension != 4"
  147. ></el-table-column>
  148. <el-table-column
  149. prop="name"
  150. width="200"
  151. label="名称"
  152. ></el-table-column>
  153. <el-table-column
  154. width="200"
  155. :prop="item.prop"
  156. :label="item.label"
  157. v-for="(item, index) in tableHeader"
  158. :key="index"
  159. >
  160. <template slot-scope="{ row }">
  161. <template v-if="item.formatter">{{
  162. item.formatter(row)
  163. }}</template>
  164. <template v-else>{{ row[item.prop] }}</template>
  165. </template></el-table-column
  166. >
  167. <el-table-column
  168. prop="manualBatchNo"
  169. label="批号"
  170. min-width="100"
  171. ></el-table-column>
  172. <el-table-column
  173. v-if="dimension == 2 || dimension == 3 || dimension == 4"
  174. prop="batchNo"
  175. label="批次号"
  176. min-width="120"
  177. ></el-table-column>
  178. <el-table-column
  179. label="发货条码"
  180. prop="barcodes"
  181. width="80"
  182. :show-overflow-tooltip="true"
  183. ></el-table-column>
  184. <el-table-column
  185. v-if="dimension == 3 || dimension == 4"
  186. prop="onlyCode"
  187. label="包装编码"
  188. min-width="120"
  189. ></el-table-column>
  190. <el-table-column
  191. v-if="dimension == 4"
  192. prop="no"
  193. label="物料编码"
  194. min-width="120"
  195. ></el-table-column>
  196. <el-table-column
  197. v-if="dimension == 4"
  198. prop="meterielCode"
  199. label="物料代号"
  200. min-width="120"
  201. ></el-table-column>
  202. <el-table-column
  203. v-if="dimension == 4"
  204. prop="clientCode"
  205. label="客户代号"
  206. min-width="120"
  207. ></el-table-column>
  208. <el-table-column
  209. v-if="dimension == 4"
  210. prop="engrave"
  211. label="刻码"
  212. min-width="120"
  213. ></el-table-column>
  214. <el-table-column
  215. prop="packingCountBase"
  216. label="包装库存数量"
  217. width="120"
  218. v-if="dimension != 4"
  219. ></el-table-column>
  220. <el-table-column
  221. prop="minUnit"
  222. label="包装单位"
  223. v-if="dimension != 4"
  224. width="90"
  225. ></el-table-column>
  226. <el-table-column
  227. prop="availableCountBase"
  228. label="计量库存数量"
  229. width="120"
  230. ></el-table-column>
  231. <el-table-column
  232. prop="measuringUnit"
  233. label="计量单位"
  234. width="90"
  235. ></el-table-column>
  236. <el-table-column
  237. v-if="dimension == 4 || dimension == 3"
  238. prop="weight"
  239. label="重量"
  240. min-width="120"
  241. ></el-table-column>
  242. <el-table-column
  243. v-if="dimension == 4 || dimension == 3"
  244. prop="weightUnit"
  245. label="重量单位"
  246. min-width="120"
  247. ></el-table-column>
  248. <el-table-column
  249. prop="expirationTime"
  250. label="周期倒计时"
  251. min-width="120"
  252. ></el-table-column>
  253. <el-table-column prop="weightUnit" label="质检状态" min-width="120">
  254. <template slot-scope="{ row }">
  255. <span v-if="row.qualityStatus == 0">未质检</span>
  256. <span v-else-if="row.qualityStatus == 1">已质检</span>
  257. <span v-else>-</span>
  258. </template>
  259. </el-table-column>
  260. <el-table-column prop="weightUnit" label="质检结果" min-width="120">
  261. <template slot-scope="{ row }">
  262. <span v-if="row.qualityResult == 0">合格</span>
  263. <span v-else-if="row.qualityResult == 1">不合格</span>
  264. <span v-else>-</span>
  265. </template>
  266. </el-table-column>
  267. <el-table-column
  268. prop="pathName"
  269. label="仓库"
  270. min-width="120"
  271. ></el-table-column>
  272. <!-- <el-table-column prop="pathName" label="仓库"> </el-table-column> -->
  273. </el-table>
  274. <div style="text-align: right; padding: 10px">
  275. <el-pagination
  276. background
  277. layout="total, sizes, prev, pager, next, jumper"
  278. :total="total"
  279. :page-sizes="[5, 10, 20, 50]"
  280. :page-size.sync="pages.size"
  281. :current-page.sync="pages.pageNum"
  282. @current-change="handleCurrentChange"
  283. @size-change="handleSizeChange"
  284. >
  285. </el-pagination>
  286. </div>
  287. </el-main>
  288. </el-container>
  289. <div slot="footer">
  290. <el-button type="primary" @click="confirm()">确定</el-button>
  291. <el-button @click="cancel">关闭</el-button>
  292. </div>
  293. </el-dialog>
  294. </template>
  295. <script>
  296. import AssetTree from '@/components/AssetTree/wms.vue';
  297. // import { detailSelect } from '@/api/stockManagement/stockLedger';
  298. // import { deepClone } from '@/utils';
  299. import { tableHeader } from '../../handleTask/components/inoutBound/common';
  300. import outin from '@/api/warehouseManagement/outin';
  301. import { login } from '@/api/login';
  302. import { getWarehouseList } from '@/api/classifyManage/itemInformation';
  303. import {
  304. getBatchDetails,
  305. getDetailById,
  306. getDetailByCode
  307. } from '@/api/classifyManage';
  308. export default {
  309. components: { AssetTree },
  310. props: {
  311. title: String,
  312. assetType: {
  313. type: [String, Number],
  314. default: ''
  315. },
  316. warehousingMaterialList: {
  317. type: Array,
  318. default: () => []
  319. }
  320. },
  321. computed: {
  322. tableHeader() {
  323. return tableHeader(this.assetType);
  324. }
  325. },
  326. watch: {
  327. // 解决右侧悬浮操作栏不对称问题
  328. tableData: {
  329. handler() {
  330. this.$nextTick(() => {
  331. this.$refs.multipleTable.doLayout();
  332. });
  333. },
  334. deep: true
  335. }
  336. },
  337. data() {
  338. return {
  339. visible: false,
  340. tableData: [],
  341. total: 0,
  342. pages: {
  343. pageNum: 1,
  344. size: 10
  345. },
  346. searchForm: {
  347. code: '',
  348. name: '',
  349. batchNo: '',
  350. engrave: ''
  351. },
  352. selectionList: [],
  353. materialType: '',
  354. warehouseList: [],
  355. dimension: '4'
  356. };
  357. },
  358. created() {},
  359. methods: {
  360. changeDimensionHandler(e) {
  361. this.pages.pageNum = 1;
  362. this.changeDimension(e);
  363. },
  364. async changeDimension(e, is) {
  365. // await this.$refs.multipleTable.clearSelection();
  366. // this.selectionList = [];
  367. console.log('===1', this.warehousingMaterialList);
  368. console.log('===2', e);
  369. // if (is != 'page') {
  370. // this.$refs.multipleTable.clearSelection();
  371. // }
  372. this.dimension = e;
  373. let res = {};
  374. const params = {
  375. ...this.pages,
  376. ...this.searchForm,
  377. dimension: e
  378. };
  379. if (this.materialType) {
  380. params.categoryLevelId = this.materialType;
  381. }
  382. if (e == 2) {
  383. res = await getBatchDetails(params);
  384. this.tableData = res.list.map((item) => {
  385. return {
  386. ...item,
  387. minUnit: item.packingUnit,
  388. oid: item.stockBatchId,
  389. assetCode: item.code
  390. };
  391. });
  392. } else if (e == 3) {
  393. res = await outin.getInventoryDetails(params);
  394. this.tableData = res.list.map((item) => {
  395. return {
  396. ...item,
  397. batchNo: item.batchNum,
  398. minUnit: item.packingUnit,
  399. // availableCountBase: 1,
  400. packingCountBase: 1,
  401. oid: item.id,
  402. assetCode: item.code
  403. };
  404. });
  405. this.total = res.count;
  406. return this.tableData;
  407. } else if (e == 4) {
  408. res = await outin.getMaterielDetails(params);
  409. this.tableData = res.list.map((item, index) => {
  410. return {
  411. ...item,
  412. availableCountBase: 1,
  413. packingCountBase: 1,
  414. minUnit: item.packingUnit,
  415. oid: item.id + this.pages.pageNum + (index + 1)
  416. };
  417. });
  418. console.log('===', this.tableData);
  419. } else {
  420. res = await outin.getRealTimeInventory(params);
  421. this.tableData = res.list.map((item) => {
  422. return { ...item, oid: item.id, assetCode: item.code };
  423. });
  424. }
  425. if (res) {
  426. this.total = res.count;
  427. // this.selectionList = deepClone(this.warehousingMaterialList);
  428. this.$nextTick(() => {
  429. this.tableData.forEach((item) => {
  430. const index = this.warehousingMaterialList.findIndex((i) =>
  431. this.dimension == 1 || this.dimension == 3
  432. ? item.id == i.id
  433. : this.dimension == 2
  434. ? item.stockBatchId == i.stockBatchId
  435. : item.oid == i.oid
  436. );
  437. if (index > -1) {
  438. // 删除还给 multipleSelection
  439. this.$refs.multipleTable.toggleRowSelection(item, true);
  440. }
  441. });
  442. });
  443. }
  444. },
  445. selectable(row, index) {
  446. if (row.canUsedCount != 0) {
  447. return true;
  448. } else {
  449. return false;
  450. }
  451. },
  452. open() {
  453. this.visible = true;
  454. this.$nextTick(() => {
  455. this.$refs.treeList.getTreeData();
  456. // this.doSearch()
  457. });
  458. },
  459. async handleExit(arr) {
  460. console.log('arr=====', arr);
  461. console.log('this.dimension', this.dimension);
  462. let ids = null;
  463. let batchIds = null;
  464. let materielIds = null;
  465. if (this.dimension == 3) {
  466. ids = arr.map((item) => {
  467. return item.id;
  468. });
  469. } else if (this.dimension == 2) {
  470. ids = arr.map((item) => {
  471. return item.recordId;
  472. });
  473. batchIds = arr.map((item) => {
  474. return item.stockBatchId;
  475. });
  476. } else if (this.dimension == 4) {
  477. materielIds = arr.map((item) => {
  478. return item.materielId;
  479. });
  480. ids = arr.map((item) => {
  481. return item.recordId;
  482. });
  483. } else {
  484. ids = arr.map((item) => {
  485. return item.recordId;
  486. });
  487. }
  488. let categoryIds = arr.map((item) => {
  489. return item.id;
  490. });
  491. let batchNos = arr.map((item) => {
  492. return item.batchNo;
  493. });
  494. let outInDetailIds = arr.map((item) => {
  495. return item.outInDetailId;
  496. });
  497. const parmas = {
  498. categoryLevelId: this.materialType,
  499. type: this.dimension,
  500. categoryIds,
  501. batchNos,
  502. batchIds,
  503. ids,
  504. outInDetailIds,
  505. materielIds
  506. };
  507. console.log(parmas);
  508. const data = await getDetailById(parmas);
  509. return data;
  510. },
  511. async getSelectionList(list) {
  512. let ajax = [];
  513. let arr = [];
  514. list.forEach((item) => {
  515. this.searchForm.code = item.productCode;
  516. ajax.push(this.changeDimension(this.dimension));
  517. });
  518. (await Promise.all(ajax)).forEach((item) => {
  519. arr.push(...item);
  520. });
  521. return arr;
  522. },
  523. async confirm(list, dimension) {
  524. if (dimension) {
  525. const data = await getDetailByCode(
  526. list.map((item) => {
  527. return {
  528. categoryLevelId: item.productCategoryId,
  529. code: item.productCode,
  530. count: item.totalCount
  531. };
  532. })
  533. );
  534. this.$emit('detailData', { ...data, wlList: [] }, dimension);
  535. this.visible = false;
  536. return;
  537. }
  538. if (!this.selectionList.length) {
  539. this.$message.error('请至少选择一条数据!');
  540. return;
  541. }
  542. const data = await this.handleExit(this.selectionList);
  543. let arr = [];
  544. if (this.dimension == 4) {
  545. arr = this.selectionList.map((item) => {
  546. return { ...item, assetName: item.name };
  547. });
  548. }
  549. this.$emit('detailData', { ...data, wlList: arr }, this.dimension);
  550. // this.$emit('selectTableData', this.selectionList);
  551. this.cancel();
  552. },
  553. cancel() {
  554. this.multipleSelection = [];
  555. this.$refs.multipleTable.clearSelection();
  556. this.visible = false;
  557. },
  558. handleSelectionChange(val) {
  559. for (const key in val) {
  560. val[key].categoryId = val[key].id;
  561. }
  562. this.selectionList = val;
  563. },
  564. handleNodeClick(data) {
  565. this.materialType = data.id === data.originId ? '' : data.id;
  566. this.doSearch();
  567. },
  568. handleCurrentChange() {
  569. // this.getList();
  570. this.changeDimension(this.dimension, 'page');
  571. },
  572. reset() {
  573. this.searchForm.code = '';
  574. this.searchForm.name = '';
  575. this.searchForm.batchNo = '';
  576. this.searchForm.engrave = '';
  577. this.doSearch();
  578. },
  579. doSearch() {
  580. this.pages.pageNum = 1;
  581. // this.getList();
  582. this.changeDimension(this.dimension);
  583. },
  584. handleSizeChange() {
  585. this.pages.pageNum = 1;
  586. // this.getList();
  587. this.changeDimension(this.dimension, 'page');
  588. }
  589. // async getList() {
  590. // const params = {
  591. // ...this.pages,
  592. // ...this.searchForm,
  593. // dimension: this.dimension
  594. // // code: 5
  595. // };
  596. // if (this.materialType) {
  597. // params.categoryLevelId = this.materialType;
  598. // }
  599. // const res = await outin.getMaterielDetails(params);
  600. // if (res) {
  601. // this.tableData = res.list.map((item, index) => {
  602. // return {
  603. // ...item,
  604. // oid: index + 1 + (this.pages.pageNum - 1) * this.pages.size
  605. // };
  606. // });
  607. // this.total = res.count;
  608. // // this.selectionList = deepClone(this.warehousingMaterialList);
  609. // console.log(' this.tableData==', this.tableData);
  610. // this.$nextTick(() => {
  611. // this.tableData.forEach((item) => {
  612. // const index = this.warehousingMaterialList.findIndex((i) =>
  613. // this.dimension == 1 || this.dimension == 3
  614. // ? item.id == i.id
  615. // : this.dimension == 2
  616. // ? item.stockBatchId == i.stockBatchId
  617. // : item.meterielId == i.meterielId
  618. // );
  619. // if (index > -1) {
  620. // // 删除还给 multipleSelection
  621. // this.$refs.multipleTable.toggleRowSelection(item, true);
  622. // }
  623. // });
  624. // });
  625. // }
  626. // }
  627. }
  628. };
  629. </script>
  630. <style lang="scss" scoped>
  631. .el-dialog__wrapper {
  632. ::v-deep .el-aside {
  633. background-color: #fff !important;
  634. border: 1px solid #ccc;
  635. }
  636. }
  637. .wrapper-assets {
  638. max-height: 53vh;
  639. overflow: auto;
  640. }
  641. </style>