AssetsDialog.vue 21 KB

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