更新库存查询和仓储汇总页面

This commit is contained in:
Developer
2026-06-04 08:36:53 +08:00
parent 197603483d
commit 833cd016ff
2 changed files with 131 additions and 17 deletions

View File

@@ -72,7 +72,9 @@
style="width:1622px"
height="740px"
@cell-click="handleEdit"
@sort-change="sortChange">
@sort-change="sortChange"
@selection-change="handleSelectionChange">
<el-table-column type="selection" width="40" :reserve-selection="true" />
<el-table-column type="expand" width="1">
<template slot-scope="scope">
<el-table
@@ -343,6 +345,8 @@
<script>
import { mapGetters } from 'vuex'
import XLSX from 'xlsx'
import FileSaver from 'file-saver'
export default {
data() {
@@ -379,7 +383,8 @@ export default {
pageCurrent1: 1, // 分页当前页
pageSize1: 30, // 分页每页显示条数
orderName: '', // 排序列名
order: '' // 排序方式
order: '', // 排序方式
multipleSelection: [] // 选中的行
}
},
computed: {
@@ -474,8 +479,21 @@ export default {
this.total = response.data.total
})
},
handleSelectionChange(val) {
this.multipleSelection = val
},
exportExcel() {
if (this.tableData1.length !== 0) {
if (this.tableData1.length === 0) {
this.$message.warning('暂无数据')
return
}
if (this.multipleSelection.length > 0) {
this.exportSelected()
} else {
this.exportAll()
}
},
exportAll() {
let materialNameTypeValue_check, locationWarehouseValue_check
this.materialNameTypeValue ? materialNameTypeValue_check = 1 : materialNameTypeValue_check = 0
this.locationWarehouseValue ? locationWarehouseValue_check = 1 : locationWarehouseValue_check = 0
@@ -488,9 +506,60 @@ export default {
param[5] = ['排序方式', this.order]
var Data = this.CreateData('2001', '报表_仓储管理_通用库存_查询', param)
this.exportExcel_NPOI(Data)
},
exportSelected() {
var loadingInstance = this.$loading({ text: '正在导出,请稍候...' })
var promises = this.multipleSelection.map(function(row) {
var param = []
param[0] = ['物料流水号', row.物料流水号]
var Data = this.CreateData('11', '库存查询_物料出入库记录_查询', param, 10000, 1)
return this.ExecDatabase(Data).then(function(response) {
return { row: row, expandData: response.data.rows || [] }
})
}.bind(this))
Promise.all(promises).then(function(results) {
var data = []
// 表头
data.push(['物料编号', '物料名称', '图号型号', '库位', '库存', '需求数', '可用库存', '加工中', '采购中', '毛坯数', '单位', '类型', '库存批次', '待入库', '最低库存', '安全库存', '最高库存', '', '物料编号', '物料名称', '图号/型号', '类型', '出/入库数', '出/入库日期', '批次编码'])
results.forEach(function(item) {
var row = item.row
var mainRow = [
row.物料编码, row.物料名称, row.图号或型号, row.货位名称, row.库存,
row.需求量, row.库存 - row.需求量, row.加工中 < 0 ? 0 : row.加工中,
row.采购中, row.毛坯库存, row.单位, row.类型, row.批次, row.预库存,
row.最低库存, row.安全库存, row.最高库存, ''
]
if (item.expandData.length > 0) {
item.expandData.forEach(function(expand, idx) {
if (idx === 0) {
data.push(mainRow.concat([expand.物料编码, expand.物料名称, expand.图号或型号, expand.类型, expand.数量, expand.日期, expand.批次编号 || expand.批次编码]))
} else {
this.$message.warning('暂无数据')
data.push(['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', expand.物料编码, expand.物料名称, expand.图号或型号, expand.类型, expand.数量, expand.日期, expand.批次编号 || expand.批次编码])
}
})
} else {
data.push(mainRow)
}
})
var ws = XLSX.utils.aoa_to_sheet(data)
ws['!cols'] = [
{ wch: 15 }, { wch: 20 }, { wch: 15 }, { wch: 10 }, { wch: 8 },
{ wch: 8 }, { wch: 10 }, { wch: 8 }, { wch: 8 }, { wch: 8 },
{ wch: 6 }, { wch: 8 }, { wch: 12 }, { wch: 8 }, { wch: 10 },
{ wch: 10 }, { wch: 10 }, { wch: 2 },
{ wch: 15 }, { wch: 20 }, { wch: 15 }, { wch: 8 }, { wch: 10 },
{ wch: 15 }, { wch: 15 }
]
var wb = XLSX.utils.book_new()
XLSX.utils.book_append_sheet(wb, ws, '库存查询')
var wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: false, type: 'array' })
FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), '库存查询.xlsx')
loadingInstance.close()
this.$message.success('导出成功')
}.bind(this)).catch(function() {
loadingInstance.close()
this.$message.error('导出失败')
}.bind(this))
},
sortChange(column) {
if (column.prop === '物料编码') {

View File

@@ -63,7 +63,10 @@
</el-row>
</div>
<div style="margin-top: 20px">
<h3 style="margin-bottom: 10px">{{ currentDetail }}详情</h3>
<div style="display: flex; align-items: center; margin-bottom: 10px">
<h3 style="margin: 0">{{ currentDetail }}详情</h3>
<el-button v-if="currentDetail === '生产中'" type="primary" size="mini" style="margin-left: 15px" @click="exportProductionDetail">导出</el-button>
</div>
<el-table
v-loading="loading"
:data="detailData"
@@ -99,6 +102,8 @@
<script>
import { mapGetters } from 'vuex'
import XLSX from 'xlsx'
import FileSaver from 'file-saver'
export default {
data() {
@@ -576,6 +581,46 @@ export default {
]
this.loading = false
})
},
// 导出生产中详情
exportProductionDetail() {
if (!this.生产中全部数据 || this.生产中全部数据.length === 0) {
this.$message.warning('暂无数据可导出')
return
}
var header = ['补货单号', '物料名称', '补货数量', '入库数', '状态', '补货日期', '补货期限', '期限状态', '超期时间(天)']
var data = this.生产中全部数据.map(item => {
return [
item.补货单号 || '',
item.名称 || '',
item.补货数 || '',
item.入库数 || '',
item.状态 || '',
item.补货日期 || '',
item.补货期限 || '',
item.期限状态 || '',
item.超期时间 || ''
]
})
// 添加空行和统计汇总
data.push([])
data.push(['统计汇总', '', '', '', '', '', '', '', ''])
data.push(['正常', this.生产中统计.正常, '', '', '', '', '', '', ''])
data.push(['临期', this.生产中统计.临期, '', '', '', '', '', '', ''])
data.push(['超期', this.生产中统计.超期, '', '', '', '', '', '', ''])
data.push(['总计', this.statistics.生产中, '', '', '', '', '', '', ''])
data.unshift(header)
var ws = XLSX.utils.aoa_to_sheet(data)
// 设置列宽
ws['!cols'] = [
{ wch: 15 }, { wch: 20 }, { wch: 10 }, { wch: 10 },
{ wch: 10 }, { wch: 15 }, { wch: 15 }, { wch: 10 }, { wch: 12 }
]
var wb = XLSX.utils.book_new()
XLSX.utils.book_append_sheet(wb, ws, '生产中详情')
var wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: false, type: 'array' })
FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), '生产中详情.xlsx')
}
}
}