add copy.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. <template>
  2. <div id="inventoryAllocate">
  3. <el-card class="box-card">
  4. <div class="selectBox">
  5. <el-form
  6. label-width="80px"
  7. label-position="left"
  8. class="ele-form-search"
  9. >
  10. <el-row :gutter="15">
  11. <el-col :span="6">
  12. <el-form-item label="调拨类型:" prop="warehouseId">
  13. <template>
  14. <el-select
  15. clearable
  16. @change="allocateChange"
  17. style="width: 100%"
  18. v-model="allocateId"
  19. placeholder="请选择"
  20. >
  21. <el-option
  22. v-for="item in typeOptions"
  23. :label="item.label"
  24. :value="item.value"
  25. :key="item.value"
  26. >
  27. </el-option>
  28. </el-select>
  29. </template>
  30. </el-form-item>
  31. </el-col>
  32. <el-col :span="6">
  33. <el-form-item label="调出仓库:" prop="warehouseId">
  34. <template>
  35. <el-select
  36. clearable
  37. style="width: 100%"
  38. v-model="params.outWarehouseId"
  39. @change="warehouseChange($event, '调出')"
  40. placeholder="请选择"
  41. >
  42. <el-option
  43. v-for="item in outWarehouseList"
  44. :label="item.name"
  45. :value="item.id"
  46. :key="item.id"
  47. >
  48. </el-option>
  49. </el-select>
  50. </template>
  51. </el-form-item>
  52. </el-col>
  53. <el-col :span="6">
  54. <el-form-item label="调入仓库:" prop="warehouseId">
  55. <template>
  56. <el-select
  57. :disabled="allocateId == 1"
  58. clearable
  59. style="width: 100%"
  60. v-model="params.inWarehouseId"
  61. @change="warehouseChange($event, '调入')"
  62. placeholder="请选择"
  63. >
  64. <el-option
  65. v-for="item in inWarehouseList"
  66. :label="item.name"
  67. :value="item.id"
  68. :key="item.id"
  69. >
  70. </el-option>
  71. </el-select>
  72. </template>
  73. </el-form-item>
  74. </el-col>
  75. </el-row>
  76. </el-form>
  77. </div>
  78. <div class="reservoirArea">
  79. <div>
  80. <div
  81. >调出库区{{
  82. currentPullAreaName ? `(${currentPullAreaName})` : '(未选)'
  83. }}</div
  84. >
  85. <div class="box">
  86. <div
  87. :class="currentPullAreaId == item.id ? 'click_border' : ''"
  88. v-for="item in pullLibrary"
  89. @click="pullClick(item.id, item.name)"
  90. >{{ item.name }}</div
  91. >
  92. </div>
  93. </div>
  94. <div>
  95. <div
  96. >调入库区{{
  97. currentTuneAreaName ? `(${currentTuneAreaName})` : '(未选)'
  98. }}</div
  99. >
  100. <div class="box">
  101. <div
  102. :class="
  103. allocateId == 1 && currentPullAreaId === item.id
  104. ? 'unClick_color'
  105. : currentTuneAreaId === item.id
  106. ? 'click_border'
  107. : ''
  108. "
  109. v-for="item in tuneLibrary"
  110. @click="
  111. tuneClick(
  112. item.id,
  113. item.name,
  114. allocateId == 1 && currentPullAreaId === item.id
  115. )
  116. "
  117. >{{ item.name }}</div
  118. >
  119. </div>
  120. </div>
  121. </div>
  122. </el-card>
  123. <el-card class="box-card">
  124. <div class="productsList">
  125. <header-title
  126. :title="`物品信息${
  127. currentPullAreaName ? `(${currentPullAreaName})` : '(未选)'
  128. }`"
  129. ><el-button type="primary" @click="merge"
  130. >调入</el-button
  131. ></header-title
  132. >
  133. <el-table
  134. ref="table"
  135. :data="productList"
  136. @selection-change="selecctedRow"
  137. tooltip-effect="dark"
  138. :max-height="500"
  139. border
  140. >
  141. <el-table-column
  142. align="center"
  143. width="50"
  144. :selectable="checkSelectable"
  145. type="selection"
  146. ></el-table-column>
  147. <el-table-column label="序号" type="index" width="50">
  148. </el-table-column>
  149. <el-table-column
  150. label="物品编码"
  151. prop="categoryCode"
  152. :show-overflow-tooltip="true"
  153. ></el-table-column>
  154. <el-table-column
  155. label="物品名称"
  156. prop="categoryName"
  157. :show-overflow-tooltip="true"
  158. ></el-table-column>
  159. <el-table-column
  160. label="牌号"
  161. prop="brandNum"
  162. :show-overflow-tooltip="true"
  163. ></el-table-column>
  164. <el-table-column
  165. label="型号"
  166. prop="categoryModel"
  167. :show-overflow-tooltip="true"
  168. ></el-table-column>
  169. <el-table-column
  170. label="规格"
  171. prop="specification"
  172. :show-overflow-tooltip="true"
  173. ></el-table-column>
  174. <el-table-column
  175. label="包装编码"
  176. prop="packageNo"
  177. :show-overflow-tooltip="true"
  178. ></el-table-column>
  179. <el-table-column
  180. label="包装数量"
  181. prop="packingQuantity"
  182. :show-overflow-tooltip="true"
  183. ></el-table-column>
  184. <el-table-column
  185. label="包装单位"
  186. prop="packingUnit"
  187. :show-overflow-tooltip="true"
  188. ></el-table-column>
  189. <el-table-column
  190. label="计量数量"
  191. prop="measureQuantity"
  192. :show-overflow-tooltip="true"
  193. ></el-table-column>
  194. <el-table-column
  195. label="计量单位"
  196. prop="measureUnit"
  197. :show-overflow-tooltip="true"
  198. ></el-table-column>
  199. <el-table-column
  200. label="重量"
  201. prop="weight"
  202. :show-overflow-tooltip="true"
  203. >
  204. </el-table-column>
  205. <el-table-column
  206. label="重量单位"
  207. prop="weightUnit"
  208. :show-overflow-tooltip="true"
  209. >
  210. </el-table-column>
  211. <el-table-column
  212. label="仓库"
  213. prop="warehouseName"
  214. :show-overflow-tooltip="true"
  215. >
  216. </el-table-column>
  217. <el-table-column
  218. label="货区"
  219. prop="areaName"
  220. :show-overflow-tooltip="true"
  221. >
  222. </el-table-column>
  223. <el-table-column
  224. label="货架"
  225. prop="goodsAllocationName"
  226. :show-overflow-tooltip="true"
  227. >
  228. </el-table-column>
  229. <el-table-column
  230. label="货位"
  231. prop="goodsShelfName"
  232. :show-overflow-tooltip="true"
  233. >
  234. </el-table-column>
  235. <el-table-column
  236. label="生产日期"
  237. prop="productionDate"
  238. :show-overflow-tooltip="true"
  239. >
  240. </el-table-column>
  241. <el-table-column
  242. label="采购日期"
  243. prop="purchaseDate"
  244. :show-overflow-tooltip="true"
  245. >
  246. </el-table-column>
  247. <el-table-column
  248. label="发货条码"
  249. prop="barcodes"
  250. :show-overflow-tooltip="true"
  251. >
  252. </el-table-column>
  253. <el-table-column
  254. label="客户代号"
  255. prop="clientCode"
  256. :show-overflow-tooltip="true"
  257. >
  258. </el-table-column>
  259. <el-table-column
  260. label="刻码"
  261. prop="engrave"
  262. :show-overflow-tooltip="true"
  263. >
  264. </el-table-column>
  265. <el-table-column
  266. label="物料代号"
  267. prop="materielDesignation"
  268. :show-overflow-tooltip="true"
  269. >
  270. </el-table-column>
  271. </el-table>
  272. </div>
  273. <div class="allocateDetails">
  274. <header-title :title="`调拨明细`"
  275. ><el-button type="primary" @click="submit"
  276. >保存</el-button
  277. ></header-title
  278. >
  279. <el-table
  280. ref="detailTable"
  281. :data="tableData"
  282. tooltip-effect="dark"
  283. :max-height="500"
  284. border
  285. >
  286. <el-table-column label="序号" type="index" width="50">
  287. </el-table-column>
  288. <el-table-column
  289. label="物品编码"
  290. prop="categoryCode"
  291. :show-overflow-tooltip="true"
  292. ></el-table-column>
  293. <el-table-column
  294. label="物品名称"
  295. prop="categoryName"
  296. :show-overflow-tooltip="true"
  297. ></el-table-column>
  298. <el-table-column
  299. label="牌号"
  300. prop="brandNum"
  301. :show-overflow-tooltip="true"
  302. ></el-table-column>
  303. <el-table-column
  304. label="型号"
  305. prop="categoryModel"
  306. :show-overflow-tooltip="true"
  307. ></el-table-column>
  308. <el-table-column
  309. label="规格"
  310. prop="specification"
  311. :show-overflow-tooltip="true"
  312. ></el-table-column>
  313. <el-table-column
  314. label="包装编码"
  315. prop="packageNo"
  316. :show-overflow-tooltip="true"
  317. ></el-table-column>
  318. <el-table-column
  319. label="包装数量"
  320. prop="packingQuantity"
  321. :show-overflow-tooltip="true"
  322. ></el-table-column>
  323. <el-table-column
  324. label="包装单位"
  325. prop="packingUnit"
  326. :show-overflow-tooltip="true"
  327. ></el-table-column>
  328. <el-table-column
  329. label="计量数量"
  330. prop="measureQuantity"
  331. :show-overflow-tooltip="true"
  332. ></el-table-column>
  333. <el-table-column
  334. label="计量单位"
  335. prop="measureUnit"
  336. :show-overflow-tooltip="true"
  337. ></el-table-column>
  338. <el-table-column
  339. label="重量"
  340. prop="weight"
  341. :show-overflow-tooltip="true"
  342. >
  343. </el-table-column>
  344. <el-table-column
  345. label="重量单位"
  346. prop="weightUnit"
  347. :show-overflow-tooltip="true"
  348. >
  349. </el-table-column>
  350. <el-table-column
  351. label="调出库区"
  352. prop="outWarehouseAreaName"
  353. :show-overflow-tooltip="true"
  354. >
  355. </el-table-column>
  356. <el-table-column
  357. label="调入库区"
  358. prop="inWarehouseName"
  359. :show-overflow-tooltip="true"
  360. >
  361. </el-table-column>
  362. <el-table-column label="操作" width="100">
  363. <template slot-scope="{ row, $index }">
  364. <el-button @click="deleted(row, $index)" type="text" size="small"
  365. >删除</el-button
  366. >
  367. </template>
  368. </el-table-column>
  369. </el-table>
  370. </div>
  371. </el-card>
  372. </div>
  373. </template>
  374. <script>
  375. import storageApi from '@/api/warehouseManagement/index.js';
  376. import { getWarehouseList } from '@/api/classifyManage/itemInformation';
  377. export default {
  378. data() {
  379. return {
  380. typeOptions: [
  381. { label: '库内调拨', value: 1 },
  382. { label: '库外调拨', value: 2 }
  383. ],
  384. selectionIds: [],
  385. selection: [],
  386. tableData: [],
  387. productList: [],
  388. allocateId: 1,
  389. currentPullAreaId: '',
  390. currentPullAreaName: '',
  391. currentTuneAreaId: '',
  392. currentTuneAreaName: '',
  393. pullLibrary: [], // 调出库
  394. tuneLibrary: [], // 调入库
  395. outWarehouseList: [],
  396. inWarehouseList: [],
  397. params: {
  398. outWarehouseId: '',
  399. outWarehouseName: '',
  400. inWarehouseId: '',
  401. inWarehouseName: ''
  402. }
  403. };
  404. },
  405. created() {
  406. this.getWarehouseOptions();
  407. },
  408. methods: {
  409. deleted(row, index) {
  410. this.tableData.splice(index, 1);
  411. console.log(this.selectionIds);
  412. this.selectionIds = this.selectionIds.filter((item) => item !== row.id);
  413. },
  414. submit() {
  415. if (this.tableData.length > 0) {
  416. let params = {
  417. categoryCode: this.tableData
  418. .map((item) => item.categoryCode)
  419. .join(','),
  420. categoryName: this.tableData
  421. .map((item) => item.categoryName)
  422. .join(','),
  423. outInDetailRecordId: this.tableData.map((item) => item.id),
  424. sourceWarehouse: this.params.outWarehouseName,
  425. sourceWarehouseId: this.params.outWarehouseId,
  426. sourceWarehouseArea: this.currentPullAreaName,
  427. sourceWarehouseAreaId: this.currentPullAreaId,
  428. targetWarehouse: this.params.inWarehouseName,
  429. targetWarehouseId: this.params.inWarehouseId,
  430. targetWarehouseArea: this.currentTuneAreaName,
  431. targetWarehouseAreaId: this.currentTuneAreaId,
  432. status: 0,
  433. type: this.allocateId
  434. };
  435. console.log('params------------', params);
  436. storageApi.allotApplySave(params).then(() => {
  437. this.$message.success('保存成功');
  438. this.$router.go(-1);
  439. });
  440. } else {
  441. this.$message.error('请调入相关数据');
  442. }
  443. },
  444. checkSelectable(row) {
  445. return !this.selectionIds.includes(row.id);
  446. },
  447. allocateChange(val) {
  448. this.allocateId = val;
  449. this.params = {
  450. outWarehouseId: '',
  451. outWarehouseName: '',
  452. inWarehouseId: '',
  453. inWarehouseName: ''
  454. };
  455. this.currentPullAreaId = '';
  456. this.currentPullAreaName = '';
  457. this.currentTuneAreaId = '';
  458. this.currentTuneAreaName = '';
  459. this.pullLibrary = [];
  460. this.tuneLibrary = [];
  461. this.productList = [];
  462. this.tableData = [];
  463. this.productList = [];
  464. this.getWarehouseOptions();
  465. },
  466. pullClick(id, name) {
  467. if (this.currentPullAreaId == id) {
  468. return false;
  469. } else {
  470. console.log('-------------');
  471. this.currentPullAreaId = id;
  472. this.currentPullAreaName = name;
  473. this.currentTuneAreaId = '';
  474. this.currentTuneAreaName = '';
  475. }
  476. storageApi
  477. .getPackingList({
  478. warehouseAreaId: id,
  479. pageNum: 1,
  480. size: 9999
  481. })
  482. .then(({ list }) => {
  483. this.productList = list;
  484. });
  485. },
  486. tuneClick(id, name, boolen) {
  487. if (!this.currentPullAreaId) {
  488. return this.$message.error('请先选择调出库');
  489. }
  490. if (boolen) {
  491. return false;
  492. }
  493. this.currentTuneAreaId = id;
  494. this.currentTuneAreaName = name;
  495. },
  496. selecctedRow(val) {
  497. this.selection = val;
  498. },
  499. async warehouseChange(val, type) {
  500. console.log(val);
  501. console.log(type);
  502. storageApi.getListByWarehouseId(val).then((data) => {
  503. console.log(data);
  504. if (this.allocateId == 1) {
  505. // 库内调拨同步选择仓库
  506. this.params.inWarehouseId = val;
  507. this.pullLibrary = data;
  508. this.tuneLibrary = data;
  509. this.params = {
  510. outWarehouseId: val,
  511. outWarehouseName: this.outWarehouseList.filter(
  512. (item) => item.id == val
  513. )[0].name,
  514. inWarehouseId: val,
  515. inWarehouseName: this.inWarehouseList.filter(
  516. (item) => item.id == val
  517. )[0].name
  518. };
  519. console.log(this.params);
  520. } else {
  521. if (type === '调出') {
  522. this.pullLibrary = data;
  523. this.currentPullAreaId = '';
  524. this.currentPullAreaName = '';
  525. this.currentTuneAreaId = '';
  526. this.currentTuneAreaName = '';
  527. this.inWarehouseList = this.inWarehouseList.filter(
  528. (item) => item.id !== val
  529. );
  530. this.params.outWarehouseId = val;
  531. this.params.outWarehouseName = this.outWarehouseList.filter(
  532. (item) => item.id === val
  533. )[0].name;
  534. this.productList = [];
  535. } else {
  536. this.tuneLibrary = data;
  537. this.outWarehouseList = this.outWarehouseList.filter(
  538. (item) => item.id !== val
  539. );
  540. this.params.inWarehouseId = val;
  541. this.params.inWarehouseName = this.inWarehouseList.filter(
  542. (item) => item.id === val
  543. )[0].name;
  544. }
  545. }
  546. });
  547. },
  548. async getWarehouseOptions() {
  549. const { data } = await storageApi.getWarehouseTrees();
  550. this.outWarehouseList = data;
  551. this.inWarehouseList = data;
  552. },
  553. getAreaData() {
  554. console.log('this.current----', this.current.data);
  555. params = {
  556. warehouseId:
  557. this.current.data?.level == 0 ? this.current.data.id : '',
  558. warehouseAreaId:
  559. this.current.data?.level == 1 ? this.current.data.id : '',
  560. warehouseAreaGoodsId:
  561. this.current.data?.level == 2 ? this.current.data.id : '',
  562. ...where,
  563. ...order
  564. };
  565. const data = storageApi.getPackingList({
  566. ...params,
  567. pageNum: page,
  568. size: limit
  569. });
  570. },
  571. async merge() {
  572. if (
  573. this.selection.length > 0 &&
  574. this.currentPullAreaId &&
  575. this.currentTuneAreaId
  576. ) {
  577. console.log(this.selection);
  578. console.log(this.selectionIds);
  579. let boolen = this.selection.every((item) =>
  580. this.selectionIds.includes(item.id)
  581. );
  582. if (this.selection.length > 0 && !boolen) {
  583. this.selection = this.selection.filter(
  584. (item) => !this.selectionIds.includes(item.id)
  585. );
  586. this.selectionIds = this.selectionIds.concat(
  587. this.selection.map((item) => item.id)
  588. );
  589. console.log('this.selection---------', this.selection);
  590. console.log('this.selectionIds---', this.selectionIds);
  591. this.tableData = this.tableData.concat(
  592. this.selection.map((item) => {
  593. return {
  594. ...item,
  595. outWarehouseAreaId: this.currentPullAreaId,
  596. outWarehouseAreaName: this.currentPullAreaName,
  597. inWarehouseId: this.currentTuneAreaId,
  598. inWarehouseName: this.currentTuneAreaName
  599. };
  600. })
  601. );
  602. console.log('this.tableData---------', this.tableData);
  603. } else {
  604. this.$message.error('请选择正确的行');
  605. }
  606. } else {
  607. this.$message.error('请选择调入库和调出库以及物品信息');
  608. }
  609. }
  610. }
  611. };
  612. </script>
  613. <style lang="scss" scoped>
  614. #inventoryAllocate {
  615. .selectBox {
  616. padding: 20px;
  617. }
  618. .box-card {
  619. margin: 20px;
  620. }
  621. .click_border {
  622. box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 4px,
  623. rgb(51, 51, 51) 0px 0px 0px 5px;
  624. }
  625. .unClick_color {
  626. background-color: #ccc !important;
  627. }
  628. .reservoirArea {
  629. display: flex;
  630. padding: 5px 20px;
  631. > div {
  632. flex: 1;
  633. .box {
  634. > div {
  635. display: inline-block;
  636. width: 120px;
  637. height: 80px;
  638. margin: 10px;
  639. margin-left: 0;
  640. display: flex;
  641. align-items: center;
  642. justify-content: center;
  643. border-radius: 10px;
  644. color: #fff;
  645. background-color: #409eff;
  646. cursor: pointer;
  647. }
  648. }
  649. }
  650. }
  651. .allocateDetails {
  652. padding: 5px 20px;
  653. > div {
  654. padding: 10px;
  655. }
  656. }
  657. .productsList {
  658. padding: 5px 20px;
  659. > div {
  660. padding: 10px;
  661. }
  662. }
  663. }
  664. </style>