AssetsDialog copy2.vue 22 KB

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