AssetsDialog.vue 17 KB

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