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.

691 lines
22 KiB

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