You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

690 lines
22 KiB

11 months ago
  1. <script>
  2. import {getWareHouseList} from "../../../api/partspare/wareHouseEntity";
  3. import {getAllBuList} from "../../../api/factory/site";
  4. import {getInventoryStockList} from "../../../api/partspare/inventorystock";
  5. import {saveBatchPurchaseOrder} from "../../../api/partspare/purchaseOrder";
  6. import {Decimal} from "decimal.js";
  7. export default {
  8. name: "inventoryStockPurchasing",
  9. data(){
  10. return{
  11. span:3,
  12. queryParams: {
  13. site: this.$store.state.user.site,
  14. limit: 50,
  15. page: 1,
  16. partNo: '',
  17. partDescription: '',
  18. spec: '',
  19. batchNo: '',
  20. warehouseId: '',
  21. locationId: '',
  22. startFirstInDate: '',
  23. endFirstInDate: '',
  24. startQtyOnHand: '',
  25. endQtyOnHand: '',
  26. groupType: '0',
  27. active: 'Y',
  28. safetyStock: '不安全',
  29. buNo: '',
  30. securityMethod:'库存和在途',
  31. },
  32. buList:[],
  33. wareHouseList:[],
  34. dataList: [],
  35. queryLoading: false,
  36. total:0,
  37. columns:[
  38. {
  39. userId: this.$store.state.user.name,
  40. functionId: 200101106,
  41. serialNumber: '200101106Table1BuDesc',
  42. tableId: '200101106Table1',
  43. tableName: '备品备件采购表',
  44. columnProp: 'buDesc',
  45. headerAlign: 'center',
  46. align: 'center',
  47. columnLabel: 'BU',
  48. columnHidden: false,
  49. columnImage: false,
  50. columnSortable: false,
  51. sortLv: 0,
  52. status: true,
  53. fixed: '',
  54. columnWidth: 80
  55. },
  56. {
  57. userId: this.$store.state.user.name,
  58. functionId: 200101106,
  59. serialNumber: '200101106Table1PartNo',
  60. tableId: '200101106Table1',
  61. tableName: '备品备件采购表',
  62. columnProp: 'partNo',
  63. headerAlign: 'center',
  64. align: 'left',
  65. columnLabel: '备品备件编码',
  66. columnHidden: false,
  67. columnImage: false,
  68. columnSortable: false,
  69. sortLv: 0,
  70. status: true,
  71. fixed: '',
  72. columnWidth: 120
  73. },
  74. {
  75. userId: this.$store.state.user.name,
  76. functionId: 200101106,
  77. serialNumber: '200101106Table1PartDescription',
  78. tableId: '200101106Table1',
  79. tableName: '备品备件采购表',
  80. columnProp: 'partDescription',
  81. headerAlign: 'center',
  82. align: 'left',
  83. columnLabel: '备品备件名称',
  84. columnHidden: false,
  85. columnImage: false,
  86. columnSortable: false,
  87. sortLv: 0,
  88. status: true,
  89. fixed: '',
  90. columnWidth: 160
  91. },
  92. {
  93. userId: this.$store.state.user.name,
  94. functionId: 200101106,
  95. serialNumber: '200101106Table1BatchNo',
  96. tableId: '200101106Table1',
  97. tableName: '备品备件采购表',
  98. columnProp: 'batchNo',
  99. headerAlign: 'center',
  100. align: 'left',
  101. columnLabel: '序列号',
  102. columnHidden: false,
  103. columnImage: false,
  104. columnSortable: false,
  105. sortLv: 0,
  106. status: true,
  107. fixed: '',
  108. columnWidth: 100
  109. },
  110. {
  111. userId: this.$store.state.user.name,
  112. functionId: 200101106,
  113. serialNumber: '200101106Table1WarehouseId',
  114. tableId: '200101106Table1',
  115. tableName: '备品备件采购表',
  116. columnProp: 'warehouseId',
  117. headerAlign: 'center',
  118. align: 'left',
  119. columnLabel: '仓库编码',
  120. columnHidden: false,
  121. columnImage: false,
  122. columnSortable: false,
  123. sortLv: 0,
  124. status: true,
  125. fixed: '',
  126. columnWidth: 100
  127. },
  128. {
  129. userId: this.$store.state.user.name,
  130. functionId: 200101106,
  131. serialNumber: '200101106Table1LocationId',
  132. tableId: '200101106Table1',
  133. tableName: '备品备件采购表',
  134. columnProp: 'locationId',
  135. headerAlign: 'center',
  136. align: 'left',
  137. columnLabel: '货位编码',
  138. columnHidden: false,
  139. columnImage: false,
  140. columnSortable: false,
  141. sortLv: 0,
  142. status: true,
  143. fixed: '',
  144. columnWidth: 100
  145. },
  146. {
  147. userId: this.$store.state.user.name,
  148. functionId: 200101106,
  149. serialNumber: '200101106Table1UmId',
  150. tableId: '200101106Table1',
  151. tableName: '备品备件采购表',
  152. columnProp: 'umid',
  153. headerAlign: 'center',
  154. align: 'left',
  155. columnLabel: '单位',
  156. columnHidden: false,
  157. columnImage: false,
  158. columnSortable: false,
  159. sortLv: 0,
  160. status: true,
  161. fixed: '',
  162. columnWidth: 80
  163. },
  164. {
  165. userId: this.$store.state.user.name,
  166. functionId: 200101106,
  167. serialNumber: '200101106Table1QtyOnHand',
  168. tableId: '200101106Table1',
  169. tableName: '备品备件采购表',
  170. columnProp: 'qtyOnHand',
  171. headerAlign: 'center',
  172. align: 'right',
  173. columnLabel: '在库数量',
  174. columnHidden: false,
  175. columnImage: false,
  176. columnSortable: false,
  177. sortLv: 0,
  178. status: true,
  179. fixed: '',
  180. columnWidth: 80
  181. },
  182. {
  183. userId: this.$store.state.user.name,
  184. functionId: 200101106,
  185. serialNumber: '200101106Table1MinStock',
  186. tableId: '200101106Table1',
  187. tableName: '备品备件采购表',
  188. columnProp: 'minStock',
  189. headerAlign: 'center',
  190. align: 'right',
  191. columnLabel: '最低库存数量',
  192. columnHidden: false,
  193. columnImage: false,
  194. columnSortable: false,
  195. sortLv: 0,
  196. status: true,
  197. fixed: '',
  198. columnWidth: 100
  199. },
  200. {
  201. userId: this.$store.state.user.name,
  202. functionId: 200101106,
  203. serialNumber: '200101106Table1QtyOfPo',
  204. tableId: '200101106Table1',
  205. tableName: '备品备件采购表',
  206. columnProp: 'qtyOfPo',
  207. headerAlign: 'center',
  208. align: 'right',
  209. columnLabel: '在途订单数量',
  210. columnHidden: false,
  211. columnImage: false,
  212. columnSortable: false,
  213. sortLv: 0,
  214. status: true,
  215. fixed: '',
  216. columnWidth: 100
  217. },
  218. {
  219. userId: this.$store.state.user.name,
  220. functionId: 200101106,
  221. serialNumber: '200101106Table1PartnerId',
  222. tableId: '200101106Table1',
  223. tableName: '备品备件采购表',
  224. columnProp: 'partnerId',
  225. headerAlign: 'center',
  226. align: 'left',
  227. columnLabel: '操作员',
  228. columnHidden: false,
  229. columnImage: false,
  230. columnSortable: false,
  231. sortLv: 0,
  232. status: true,
  233. fixed: '',
  234. columnWidth: 100
  235. },
  236. {
  237. userId: this.$store.state.user.name,
  238. functionId: 200101106,
  239. serialNumber: '200101106Table1FirstInDate',
  240. tableId: '200101106Table1',
  241. tableName: '备品备件采购表',
  242. columnProp: 'firstInDate',
  243. headerAlign: 'center',
  244. align: 'center',
  245. columnLabel: '录入日期',
  246. columnHidden: false,
  247. columnImage: false,
  248. columnSortable: false,
  249. sortLv: 0,
  250. status: true,
  251. fixed: '',
  252. columnWidth: 150
  253. },
  254. ],
  255. columns2:[
  256. {
  257. userId: this.$store.state.user.name,
  258. functionId: 200101106,
  259. serialNumber: '200101106Table1BuDesc',
  260. tableId: '200101106Table1',
  261. tableName: '备品备件采购表',
  262. columnProp: 'buDesc',
  263. headerAlign: 'center',
  264. align: 'center',
  265. columnLabel: 'BU',
  266. columnHidden: false,
  267. columnImage: false,
  268. columnSortable: false,
  269. sortLv: 0,
  270. status: true,
  271. fixed: '',
  272. columnWidth: 80
  273. },
  274. {
  275. userId: this.$store.state.user.name,
  276. functionId: 200101106,
  277. serialNumber: '200101106Table1PartNo',
  278. tableId: '200101106Table1',
  279. tableName: '备品备件采购表',
  280. columnProp: 'partNo',
  281. headerAlign: 'center',
  282. align: 'left',
  283. columnLabel: '备品备件编码',
  284. columnHidden: false,
  285. columnImage: false,
  286. columnSortable: false,
  287. sortLv: 0,
  288. status: true,
  289. fixed: '',
  290. columnWidth: 120
  291. },
  292. {
  293. userId: this.$store.state.user.name,
  294. functionId: 200101106,
  295. serialNumber: '200101106Table1PartDescription',
  296. tableId: '200101106Table1',
  297. tableName: '备品备件采购表',
  298. columnProp: 'partDescription',
  299. headerAlign: 'center',
  300. align: 'left',
  301. columnLabel: '备品备件名称',
  302. columnHidden: false,
  303. columnImage: false,
  304. columnSortable: false,
  305. sortLv: 0,
  306. status: true,
  307. fixed: '',
  308. columnWidth: 160
  309. },
  310. {
  311. userId: this.$store.state.user.name,
  312. functionId: 200101106,
  313. serialNumber: '200101106Table1QtyOnHand',
  314. tableId: '200101106Table1',
  315. tableName: '备品备件采购表',
  316. columnProp: 'qtyOnHand',
  317. headerAlign: 'center',
  318. align: 'right',
  319. columnLabel: '在库数量',
  320. columnHidden: false,
  321. columnImage: false,
  322. columnSortable: false,
  323. sortLv: 0,
  324. status: true,
  325. fixed: '',
  326. columnWidth: 80
  327. },
  328. {
  329. userId: this.$store.state.user.name,
  330. functionId: 200101106,
  331. serialNumber: '200101106Table1MinStock',
  332. tableId: '200101106Table1',
  333. tableName: '备品备件采购表',
  334. columnProp: 'minStock',
  335. headerAlign: 'center',
  336. align: 'right',
  337. columnLabel: '最低库存数量',
  338. columnHidden: false,
  339. columnImage: false,
  340. columnSortable: false,
  341. sortLv: 0,
  342. status: true,
  343. fixed: '',
  344. columnWidth: 100
  345. },
  346. {
  347. userId: this.$store.state.user.name,
  348. functionId: 200101106,
  349. serialNumber: '200101106Table1QtyOfPo',
  350. tableId: '200101106Table1',
  351. tableName: '备品备件采购表',
  352. columnProp: 'qtyOfPo',
  353. headerAlign: 'center',
  354. align: 'right',
  355. columnLabel: '在途订单数量',
  356. columnHidden: false,
  357. columnImage: false,
  358. columnSortable: false,
  359. sortLv: 0,
  360. status: true,
  361. fixed: '',
  362. columnWidth: 100
  363. },
  364. ],
  365. selectionDataList:[],
  366. purchaseVisible:false,
  367. purchaseLoading:false,
  368. }
  369. },
  370. methods:{
  371. handleQuery(){
  372. this.queryLoading = true
  373. getInventoryStockList(this.queryParams).then(({data}) => {
  374. if (data && data.code === 0) {
  375. this.dataList = data.page.list
  376. this.total = data.page.totalCount
  377. } else {
  378. this.dataList = []
  379. this.total = 0
  380. }
  381. this.queryLoading = false
  382. }).catch((error)=>{
  383. this.$message.error(error)
  384. this.queryLoading = false
  385. })
  386. },
  387. getWareHouseList(){
  388. let wareHouse = {
  389. site: this.$store.state.user.site,
  390. active: 'Y',
  391. warehousetype: "备品备件仓",
  392. }
  393. getWareHouseList(wareHouse).then(({data}) =>{
  394. if (data && data.code === 0){
  395. this.wareHouseList = data.data
  396. }
  397. })
  398. },
  399. getBuList() {
  400. let tempData = {
  401. username: this.$store.state.user.name,
  402. }
  403. getAllBuList(tempData).then(({data}) => {
  404. if (data && data.code === 0) {
  405. this.buList = data.rows
  406. }
  407. })
  408. },
  409. handleQueryBySize(val){
  410. this.queryParams.limit = val
  411. this.handleQuery()
  412. },
  413. handleQueryByPage(val){
  414. this.queryParams.page = val
  415. this.handleQuery()
  416. },
  417. rowStyle({row}){
  418. // 当前行在库数量
  419. let qtyOnHand = row.qtyOnHand
  420. // 当前行最低库存数量
  421. let minStock = row.minStock
  422. // 在途数量
  423. let qtyOfPo = row.qtyOfPo
  424. // 累计数量
  425. if (this.queryParams.securityMethod === '库存和在途'){
  426. qtyOnHand += qtyOfPo
  427. }
  428. // 区分不同的样式对应不同的颜色
  429. if (qtyOnHand <= minStock) {
  430. return { 'background-color': '#D8ECF1', cursor: 'pointer' }
  431. }
  432. },
  433. handleSelectionChange(val) {
  434. let qty = 0;
  435. this.selectionDataList = val.map(item => {
  436. if (new Decimal(item.minStock).toNumber() > new Decimal(item.qtyOnHand).toNumber()){
  437. qty = new Decimal(item.minStock).sub(new Decimal(item.qtyOnHand)).toNumber()
  438. }
  439. return {
  440. ...item,
  441. purchaseQty: qty,
  442. }
  443. });
  444. },
  445. handlePurchase(){
  446. if (this.selectionDataList.length === 0) {
  447. this.$message.warning('请选择需要采购的备件')
  448. return
  449. }
  450. this.purchaseVisible = true
  451. },
  452. handlePurchaseSave(){
  453. let params = this.selectionDataList.map((item)=>{
  454. return {
  455. ...item,
  456. buNo:item.citemCode,
  457. inventoryStockId: item.id,
  458. id:null,
  459. qty: item.purchaseQty,
  460. }
  461. })
  462. this.purchaseLoading = true
  463. saveBatchPurchaseOrder(params).then(({data})=>{
  464. if (data && data.code === 0) {
  465. this.handleQuery();
  466. this.$refs.table.clearSelection();
  467. this.purchaseVisible = false;
  468. this.$message.success(data.msg)
  469. }else {
  470. this.$message.error(data.msg)
  471. }
  472. this.purchaseLoading = false
  473. }).catch((error)=>{
  474. this.$message.error(error)
  475. this.purchaseLoading = false
  476. })
  477. }
  478. },
  479. watch:{
  480. queryLoading(newVal, oldVal){
  481. if (newVal === true){
  482. setTimeout(()=>{
  483. this.queryLoading = false
  484. },3000)
  485. }
  486. },
  487. purchaseLoading(newVal, oldVal){
  488. if (newVal === true){
  489. setTimeout(()=>{
  490. this.purchaseLoading = false
  491. },3000)
  492. }
  493. }
  494. },
  495. created() {
  496. this.getBuList()
  497. this.getWareHouseList()
  498. this.handleQuery()
  499. },
  500. }
  501. </script>
  502. <template>
  503. <div class="box-container">
  504. <el-form label-position="top" :model="queryParams" style="max-width: 1200px">
  505. <el-row :gutter="10">
  506. <el-col :span="span">
  507. <el-form-item label="备品备件编码">
  508. <el-input v-model="queryParams.partNo" clearable></el-input>
  509. </el-form-item>
  510. </el-col>
  511. <el-col :span="span">
  512. <el-form-item label="备品备件名称">
  513. <el-input v-model="queryParams.partDescription" clearable></el-input>
  514. </el-form-item>
  515. </el-col>
  516. <el-col :span="span">
  517. <el-form-item label="规格型号">
  518. <el-input v-model="queryParams.spec" clearable></el-input>
  519. </el-form-item>
  520. </el-col>
  521. <el-col :span="span">
  522. <el-form-item label="序列号">
  523. <el-input v-model="queryParams.batchNo" clearable></el-input>
  524. </el-form-item>
  525. </el-col>
  526. <el-col :span="span">
  527. <el-form-item label="仓库">
  528. <el-select v-model="queryParams.warehouseId" style="width: 100%">
  529. <el-option value="" label="全部"></el-option>
  530. <el-option v-for="(item,index) in wareHouseList "
  531. :key="item.warehouseId" :value="item.warehouseId" :label="item.warehouseName"></el-option>
  532. </el-select>
  533. </el-form-item>
  534. </el-col>
  535. <el-col :span="span">
  536. <el-form-item label="汇总方式">
  537. <el-select v-model="queryParams.groupType" style="width: 100%">
  538. <el-option value="0" label="料号+序号"></el-option>
  539. <el-option value="1" label="料号"></el-option>
  540. </el-select>
  541. </el-form-item>
  542. </el-col>
  543. <el-col :span="span*2">
  544. <el-form-item label=" ">
  545. <el-button type="primary" @click="handleQuery">查询</el-button>
  546. <el-button type="primary" @click="handlePurchase">采购</el-button>
  547. </el-form-item>
  548. </el-col>
  549. <el-col :span="span*2">
  550. <el-form-item label="录入日期">
  551. <el-date-picker
  552. style="width: 47.5%"
  553. v-model="queryParams.startFirstInDate"
  554. type="date"
  555. format="yyyy-MM-dd"
  556. value-format="yyyy-MM-dd"
  557. placeholder="选择日期">
  558. </el-date-picker>
  559. <span style="text-align: center">-</span>
  560. <el-date-picker
  561. style="width: 47.5%"
  562. v-model="queryParams.endFirstInDate"
  563. type="date"
  564. format="yyyy-MM-dd"
  565. value-format="yyyy-MM-dd 23:59:59"
  566. placeholder="选择日期">
  567. </el-date-picker>
  568. </el-form-item>
  569. </el-col>
  570. <el-col :span="span*2">
  571. <el-form-item label="在库数量范围">
  572. <el-input style="width: 47.5%" v-model="queryParams.startQtyOnHand" clearable></el-input>
  573. <span style="text-align: center">-</span>
  574. <el-input style="width: 47.5%" v-model="queryParams.endQtyOnHand" clearable></el-input>
  575. </el-form-item>
  576. </el-col>
  577. <el-col :span="span">
  578. <el-form-item label="货位编码">
  579. <el-input v-model="queryParams.startQtyOnHand" clearable></el-input>
  580. </el-form-item>
  581. </el-col>
  582. <el-col :span="span">
  583. <el-form-item label="BU">
  584. <el-select v-model="queryParams.buNo" placeholder="请选择" style="width: 100%">
  585. <el-option label="全部" value=""> </el-option>
  586. <el-option
  587. v-for = "i in buList"
  588. :key = "i.buNo"
  589. :label = "i.buDesc"
  590. :value = "i.buNo">
  591. </el-option>
  592. </el-select>
  593. </el-form-item>
  594. </el-col>
  595. <el-col :span="span">
  596. <el-form-item label="安全库存汇总方式">
  597. <el-select v-model="queryParams.securityMethod" style="width: 100%">
  598. <el-option label="库存数量" value="库存"></el-option>
  599. <el-option label="(库存+在途)数量" value="库存和在途"></el-option>
  600. </el-select>
  601. </el-form-item>
  602. </el-col>
  603. <el-col :span="span">
  604. <el-form-item label=" ">
  605. <el-checkbox v-model="queryParams.safetyStock" true-label="不安全" false-label="" @change="handleQuery">仅显示低于安全库存的备件</el-checkbox>
  606. </el-form-item>
  607. </el-col>
  608. </el-row>
  609. </el-form>
  610. <div style="height: calc(100% - 120px)">
  611. <el-table :data="dataList" border
  612. height="100%" ref="table"
  613. v-loading="queryLoading"
  614. :row-style="rowStyle"
  615. @selection-change="handleSelectionChange">
  616. <el-table-column
  617. type="selection"
  618. header-align="center"
  619. align="center"
  620. width="50">
  621. </el-table-column>
  622. <el-table-column
  623. v-for="(item,index) in columns" :key="index"
  624. :sortable="item.columnSortable"
  625. :prop="item.columnProp"
  626. :header-align="item.headerAlign"
  627. :show-overflow-tooltip="item.showOverflowTooltip"
  628. :align="item.align"
  629. :fixed="item.fixed===''?false:item.fixed"
  630. :min-width="item.columnWidth"
  631. :label="item.columnLabel">
  632. <template slot-scope="scope">
  633. <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
  634. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  635. </template>
  636. </el-table-column>
  637. </el-table>
  638. </div>
  639. <el-pagination
  640. style="margin-top: 5px"
  641. @size-change="handleQueryBySize"
  642. @current-change="handleQueryByPage"
  643. :current-page="queryParams.page"
  644. :page-sizes="[50, 100, 500, 1000]"
  645. :page-size="queryParams.limit"
  646. :total="total"
  647. layout="total, sizes, prev, pager, next, jumper">
  648. </el-pagination>
  649. <el-dialog :visible.sync="purchaseVisible" title="待创建采购订单备件清单" :close-on-click-modal="false" width="1000px" v-drag>
  650. <div class="rq">
  651. <el-table :data="selectionDataList" border height="400px">
  652. <el-table-column
  653. v-for="(item,index) in columns2" :key="index"
  654. :sortable="item.columnSortable"
  655. :prop="item.columnProp"
  656. :header-align="item.headerAlign"
  657. :show-overflow-tooltip="item.showOverflowTooltip"
  658. :align="item.align"
  659. :fixed="item.fixed===''?false:item.fixed"
  660. :min-width="item.columnWidth"
  661. :label="item.columnLabel">
  662. <template slot-scope="scope">
  663. <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
  664. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  665. </template>
  666. </el-table-column>
  667. <el-table-column label="采购数量" align="center" min-width="100">
  668. <template slot-scope="{row,$index}">
  669. <el-input-number style="width: 100%;" :min="0" :controls="false" :step="0" v-model="selectionDataList[$index].purchaseQty"></el-input-number>
  670. </template>
  671. </el-table-column>
  672. </el-table>
  673. </div>
  674. <el-footer style="text-align: center;line-height: 1;height: 30px;margin-top: 10px">
  675. <el-button type="primary" :loading="purchaseLoading" @click="handlePurchaseSave">保存</el-button>
  676. <el-button type="primary" @click="purchaseVisible = false">关闭</el-button>
  677. </el-footer>
  678. </el-dialog>
  679. </div>
  680. </template>
  681. <style scoped>
  682. </style>