AssetsDialog.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  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. v-if="dimension == 3 || dimension == 4"
  180. prop="onlyCode"
  181. label="包装编码"
  182. min-width="120"
  183. ></el-table-column>
  184. <el-table-column
  185. v-if="dimension == 4"
  186. prop="no"
  187. label="物料编码"
  188. min-width="120"
  189. ></el-table-column>
  190. <el-table-column
  191. v-if="dimension == 4"
  192. prop="meterielCode"
  193. label="物料代号"
  194. min-width="120"
  195. ></el-table-column>
  196. <el-table-column
  197. v-if="dimension == 4"
  198. prop="clientCode"
  199. label="客户代号"
  200. min-width="120"
  201. ></el-table-column>
  202. <el-table-column
  203. v-if="dimension == 4"
  204. prop="engrave"
  205. label="刻码"
  206. min-width="120"
  207. ></el-table-column>
  208. <el-table-column
  209. prop="packingCountBase"
  210. label="包装库存数量"
  211. width="120"
  212. v-if="dimension != 4"
  213. ></el-table-column>
  214. <el-table-column
  215. prop="minUnit"
  216. label="包装单位"
  217. v-if="dimension != 4"
  218. width="90"
  219. ></el-table-column>
  220. <el-table-column
  221. prop="availableCountBase"
  222. label="计量库存数量"
  223. width="120"
  224. ></el-table-column>
  225. <el-table-column
  226. prop="measuringUnit"
  227. label="计量单位"
  228. width="90"
  229. ></el-table-column>
  230. <el-table-column
  231. v-if="dimension == 4"
  232. prop="weight"
  233. label="重量"
  234. min-width="120"
  235. ></el-table-column>
  236. <el-table-column
  237. v-if="dimension == 4"
  238. prop="weightUnit"
  239. label="重量单位"
  240. min-width="120"
  241. ></el-table-column>
  242. <el-table-column
  243. prop="expirationTime"
  244. label="周期倒计时"
  245. min-width="120"
  246. ></el-table-column>
  247. <el-table-column prop="weightUnit" label="质检状态" min-width="120">
  248. <template slot-scope="{ row }">
  249. <span v-if="row.qualityStatus == 0">未质检</span>
  250. <span v-else-if="row.qualityStatus == 1">已质检</span>
  251. <span v-else>-</span>
  252. </template>
  253. </el-table-column>
  254. <el-table-column prop="weightUnit" label="质检结果" min-width="120">
  255. <template slot-scope="{ row }">
  256. <span v-if="row.qualityResult == 0">合格</span>
  257. <span v-else-if="row.qualityResult == 1">不合格</span>
  258. <span v-else>-</span>
  259. </template>
  260. </el-table-column>
  261. <el-table-column
  262. prop="pathName"
  263. label="仓库"
  264. min-width="120"
  265. ></el-table-column>
  266. <!-- <el-table-column prop="pathName" label="仓库"> </el-table-column> -->
  267. </el-table>
  268. <div style="text-align: right; padding: 10px">
  269. <el-pagination
  270. background
  271. layout="total, sizes, prev, pager, next, jumper"
  272. :total="total"
  273. :page-sizes="[5, 10, 20, 50]"
  274. :page-size.sync="pages.size"
  275. :current-page.sync="pages.pageNum"
  276. @current-change="handleCurrentChange"
  277. @size-change="handleSizeChange"
  278. >
  279. </el-pagination>
  280. </div>
  281. </el-main>
  282. </el-container>
  283. <div slot="footer">
  284. <el-button type="primary" @click="confirm()">确定</el-button>
  285. <el-button @click="cancel">关闭</el-button>
  286. </div>
  287. </el-dialog>
  288. </template>
  289. <script>
  290. import AssetTree from '@/components/AssetTree/wms.vue';
  291. // import { detailSelect } from '@/api/stockManagement/stockLedger';
  292. // import { deepClone } from '@/utils';
  293. import { tableHeader } from '../../handleTask/components/inoutBound/common';
  294. import outin from '@/api/warehouseManagement/outin';
  295. import { login } from '@/api/login';
  296. import { getWarehouseList } from '@/api/classifyManage/itemInformation';
  297. import {
  298. getBatchDetails,
  299. getDetailById,
  300. getDetailByCode
  301. } from '@/api/classifyManage';
  302. export default {
  303. components: { AssetTree },
  304. props: {
  305. title: String,
  306. assetType: {
  307. type: [String, Number],
  308. default: ''
  309. },
  310. warehousingMaterialList: {
  311. type: Array,
  312. default: () => []
  313. }
  314. },
  315. computed: {
  316. tableHeader() {
  317. return tableHeader(this.assetType);
  318. }
  319. },
  320. watch: {
  321. // 解决右侧悬浮操作栏不对称问题
  322. tableData: {
  323. handler() {
  324. this.$nextTick(() => {
  325. this.$refs.multipleTable.doLayout();
  326. });
  327. },
  328. deep: true
  329. }
  330. },
  331. data() {
  332. return {
  333. visible: false,
  334. tableData: [],
  335. total: 0,
  336. pages: {
  337. pageNum: 1,
  338. size: 10
  339. },
  340. searchForm: {
  341. code: '',
  342. name: '',
  343. batchNo: '',
  344. engrave: ''
  345. },
  346. selectionList: [],
  347. materialType: '',
  348. warehouseList: [],
  349. dimension: '4'
  350. };
  351. },
  352. created() {},
  353. methods: {
  354. changeDimensionHandler(e) {
  355. this.pages.pageNum = 1;
  356. this.changeDimension(e);
  357. },
  358. async changeDimension(e, is) {
  359. // await this.$refs.multipleTable.clearSelection();
  360. // this.selectionList = [];
  361. console.log('===1', this.warehousingMaterialList);
  362. console.log('===2', e);
  363. // if (is != 'page') {
  364. // this.$refs.multipleTable.clearSelection();
  365. // }
  366. this.dimension = e;
  367. let res = {};
  368. const params = {
  369. ...this.pages,
  370. ...this.searchForm,
  371. dimension: e
  372. };
  373. if (this.materialType) {
  374. params.categoryLevelId = this.materialType;
  375. }
  376. if (e == 2) {
  377. res = await getBatchDetails(params);
  378. this.tableData = res.list.map((item) => {
  379. return {
  380. ...item,
  381. minUnit: item.packingUnit,
  382. oid: item.stockBatchId,
  383. assetCode: item.code
  384. };
  385. });
  386. } else if (e == 3) {
  387. res = await outin.getInventoryDetails(params);
  388. this.tableData = res.list.map((item) => {
  389. return {
  390. ...item,
  391. batchNo: item.batchNum,
  392. minUnit: item.packingUnit,
  393. // availableCountBase: 1,
  394. packingCountBase: 1,
  395. oid: item.id,
  396. assetCode: item.code
  397. };
  398. });
  399. return this.tableData;
  400. } else if (e == 4) {
  401. res = await outin.getMaterielDetails(params);
  402. this.tableData = res.list.map((item, index) => {
  403. return {
  404. ...item,
  405. availableCountBase: 1,
  406. packingCountBase: 1,
  407. minUnit: item.packingUnit,
  408. oid: item.id + this.pages.pageNum + (index + 1)
  409. };
  410. });
  411. console.log('===', this.tableData);
  412. } else {
  413. res = await outin.getRealTimeInventory(params);
  414. this.tableData = res.list.map((item) => {
  415. return { ...item, oid: item.id, assetCode: item.code };
  416. });
  417. }
  418. if (res) {
  419. this.total = res.count;
  420. // this.selectionList = deepClone(this.warehousingMaterialList);
  421. this.$nextTick(() => {
  422. this.tableData.forEach((item) => {
  423. const index = this.warehousingMaterialList.findIndex((i) =>
  424. this.dimension == 1 || this.dimension == 3
  425. ? item.id == i.id
  426. : this.dimension == 2
  427. ? item.stockBatchId == i.stockBatchId
  428. : item.oid == i.oid
  429. );
  430. if (index > -1) {
  431. // 删除还给 multipleSelection
  432. this.$refs.multipleTable.toggleRowSelection(item, true);
  433. }
  434. });
  435. });
  436. }
  437. },
  438. selectable(row, index) {
  439. if (row.canUsedCount != 0) {
  440. return true;
  441. } else {
  442. return false;
  443. }
  444. },
  445. open() {
  446. this.visible = true;
  447. this.$nextTick(() => {
  448. this.$refs.treeList.getTreeData();
  449. // this.doSearch()
  450. });
  451. },
  452. async handleExit(arr) {
  453. let ids = null;
  454. if (this.dimension == 3) {
  455. ids = arr.map((item) => {
  456. return item.id;
  457. });
  458. } else if (this.dimension == 2 || this.dimension == 1) {
  459. ids = arr.map((item) => {
  460. return item.recordId;
  461. });
  462. // this.dimension = 2;
  463. } else {
  464. ids = arr.map((item) => {
  465. return item.recordId;
  466. });
  467. }
  468. const parmas = {
  469. categoryLevelId: this.materialType,
  470. type: this.dimension,
  471. ids: ids
  472. };
  473. const data = await getDetailById(parmas);
  474. return data;
  475. },
  476. async getSelectionList(list) {
  477. let ajax = [];
  478. let arr = [];
  479. list.forEach((item) => {
  480. this.searchForm.code = item.productCode;
  481. ajax.push(this.changeDimension(this.dimension));
  482. });
  483. (await Promise.all(ajax)).forEach((item) => {
  484. arr.push(...item);
  485. });
  486. return arr;
  487. },
  488. async confirm(list, dimension) {
  489. if (dimension) {
  490. const data = await getDetailByCode(
  491. list.map((item) => {
  492. return {
  493. categoryLevelId: item.productCategoryId,
  494. code: item.productCode,
  495. count: item.totalCount
  496. };
  497. })
  498. );
  499. this.$emit('detailData', { ...data, wlList: [] }, dimension);
  500. this.visible = false;
  501. return;
  502. }
  503. if (!this.selectionList.length) {
  504. this.$message.error('请至少选择一条数据!');
  505. return;
  506. }
  507. const data = await this.handleExit(this.selectionList);
  508. let arr = [];
  509. if (this.dimension == 4) {
  510. arr = this.selectionList.map((item) => {
  511. return { ...item, assetName: item.name };
  512. });
  513. }
  514. this.$emit('detailData', { ...data, wlList: arr }, this.dimension);
  515. // this.$emit('selectTableData', this.selectionList);
  516. this.cancel();
  517. },
  518. cancel() {
  519. this.multipleSelection = [];
  520. this.$refs.multipleTable.clearSelection();
  521. this.visible = false;
  522. },
  523. handleSelectionChange(val) {
  524. for (const key in val) {
  525. val[key].categoryId = val[key].id;
  526. }
  527. this.selectionList = val;
  528. },
  529. handleNodeClick(data) {
  530. this.materialType = data.id === data.originId ? '' : data.id;
  531. this.doSearch();
  532. },
  533. handleCurrentChange() {
  534. // this.getList();
  535. this.changeDimension(this.dimension, 'page');
  536. },
  537. reset() {
  538. this.searchForm.code = '';
  539. this.searchForm.name = '';
  540. this.searchForm.batchNo = '';
  541. this.searchForm.engrave = '';
  542. this.doSearch();
  543. },
  544. doSearch() {
  545. this.pages.pageNum = 1;
  546. // this.getList();
  547. this.changeDimension(this.dimension);
  548. },
  549. handleSizeChange() {
  550. this.pages.pageNum = 1;
  551. // this.getList();
  552. this.changeDimension(this.dimension, 'page');
  553. }
  554. // async getList() {
  555. // const params = {
  556. // ...this.pages,
  557. // ...this.searchForm,
  558. // dimension: this.dimension
  559. // // code: 5
  560. // };
  561. // if (this.materialType) {
  562. // params.categoryLevelId = this.materialType;
  563. // }
  564. // const res = await outin.getMaterielDetails(params);
  565. // if (res) {
  566. // this.tableData = res.list.map((item, index) => {
  567. // return {
  568. // ...item,
  569. // oid: index + 1 + (this.pages.pageNum - 1) * this.pages.size
  570. // };
  571. // });
  572. // this.total = res.count;
  573. // // this.selectionList = deepClone(this.warehousingMaterialList);
  574. // console.log(' this.tableData==', this.tableData);
  575. // this.$nextTick(() => {
  576. // this.tableData.forEach((item) => {
  577. // const index = this.warehousingMaterialList.findIndex((i) =>
  578. // this.dimension == 1 || this.dimension == 3
  579. // ? item.id == i.id
  580. // : this.dimension == 2
  581. // ? item.stockBatchId == i.stockBatchId
  582. // : item.meterielId == i.meterielId
  583. // );
  584. // if (index > -1) {
  585. // // 删除还给 multipleSelection
  586. // this.$refs.multipleTable.toggleRowSelection(item, true);
  587. // }
  588. // });
  589. // });
  590. // }
  591. // }
  592. }
  593. };
  594. </script>
  595. <style lang="scss" scoped>
  596. .el-dialog__wrapper {
  597. ::v-deep .el-aside {
  598. background-color: #fff !important;
  599. border: 1px solid #ccc;
  600. }
  601. }
  602. .wrapper-assets {
  603. max-height: 53vh;
  604. overflow: auto;
  605. }
  606. </style>