feat(wms): 新增报表导出文件管理功能
新增报表导出文件管理模块,包含后端接口和前端页面 在各类报表页面添加保存报表功能 优化CoilSelector和CoilCard组件显示 调整分页大小和表格高度 统一各产线报表配置 修复文件预览组件高度问题
This commit is contained in:
@@ -13,6 +13,7 @@ export const dugeConfig = {
|
||||
{ label: '废品库', value: '2019583429955104769' },
|
||||
{ label: '退货库', value: '2019583137616310273' },
|
||||
],
|
||||
productionLine: '镀铬线',
|
||||
}
|
||||
|
||||
export const lajiaoConfig = {
|
||||
@@ -30,6 +31,7 @@ export const lajiaoConfig = {
|
||||
{ label: '废品库', value: '2019583429955104769' },
|
||||
{ label: '退货库', value: '2019583137616310273' },
|
||||
],
|
||||
productionLine: '拉矫线',
|
||||
}
|
||||
|
||||
export const shuangConfig = {
|
||||
@@ -47,6 +49,7 @@ export const shuangConfig = {
|
||||
{ label: '废品库', value: '2019583429955104769' },
|
||||
{ label: '退货库', value: '2019583137616310273' },
|
||||
],
|
||||
productionLine: '双机架线',
|
||||
}
|
||||
|
||||
export const tuozhiConfig = {
|
||||
@@ -64,6 +67,7 @@ export const tuozhiConfig = {
|
||||
{ label: '废品库', value: '2019583429955104769' },
|
||||
{ label: '退货库', value: '2019583137616310273' },
|
||||
],
|
||||
productionLine: '脱脂线',
|
||||
}
|
||||
|
||||
export const suanzhaConfig = {
|
||||
@@ -84,6 +88,7 @@ export const suanzhaConfig = {
|
||||
{ label: '废品库', value: '2019583429955104769' },
|
||||
{ label: '退货库', value: '2019583137616310273' },
|
||||
],
|
||||
productionLine: '酸轧线',
|
||||
}
|
||||
|
||||
export const zincConfig = {
|
||||
@@ -102,6 +107,7 @@ export const zincConfig = {
|
||||
{ value: '2019583429955104769', label: '废品库' },
|
||||
{ value: '2019583137616310273', label: '退货库' },
|
||||
],
|
||||
productionLine: '镀锌线',
|
||||
}
|
||||
|
||||
export const splitConfig = {
|
||||
@@ -117,6 +123,7 @@ export const splitConfig = {
|
||||
{ value: '1988150800092950529', label: '退火分条成品' },
|
||||
{ value: '1988150380649967617', label: '镀锌分条成品' },
|
||||
{ value: '1988151027466170370', label: '拉矫分条成品' },
|
||||
]
|
||||
],
|
||||
productionLine: '分条线',
|
||||
}
|
||||
|
||||
|
||||
54
klp-ui/src/views/wms/report/js/reportFile.js
Normal file
54
klp-ui/src/views/wms/report/js/reportFile.js
Normal file
@@ -0,0 +1,54 @@
|
||||
import { uploadFile } from "@/api/system/oss";
|
||||
import { exportCoilWithAll } from "@/api/wms/coil";
|
||||
import { addExportFile } from "@/api/wms/exportFile";
|
||||
|
||||
export async function saveReportFile(coilIds, { reportParams, productionLine, reportType }) {
|
||||
// 使用exportCoilWithAll接口传入coilIds获取二进制文件数据
|
||||
if (!coilIds) {
|
||||
throw new Error('无数据,无法保存')
|
||||
}
|
||||
const response = await exportCoilWithAll({ coilIds })
|
||||
// 构建报告标题
|
||||
function addZero(num) {
|
||||
return num < 10 ? '0' + num : num
|
||||
}
|
||||
|
||||
const now = new Date()
|
||||
const year = now.getFullYear()
|
||||
const month = addZero(now.getMonth() + 1)
|
||||
const day = addZero(now.getDate())
|
||||
console.log(productionLine)
|
||||
const reportTitle = `${year}-${month}-${day}_${reportType}_${productionLine || '全厂'}`
|
||||
// reportName 后再增加时间戳,避免重复
|
||||
const reportName = `${reportTitle}_${new Date().getTime()}`
|
||||
|
||||
const file = new Blob([response], { type: 'application/vnd.ms-excel' })
|
||||
const fileName = reportTitle + '.xlsx'
|
||||
// 通过new File构建出excel文件
|
||||
const excelFile = new File([file], fileName, { type: 'application/vnd.ms-excel' })
|
||||
// 上传文件到minio
|
||||
const uploadResponse = await uploadFile(excelFile)
|
||||
// 构建请求体创建文件保存记录
|
||||
const reportExportFile = {
|
||||
reportName,
|
||||
reportTitle,
|
||||
reportParams: JSON.stringify(reportParams, null, 2),
|
||||
productionLine,
|
||||
reportType,
|
||||
attachment: uploadResponse.data.url,
|
||||
ossId: uploadResponse.data.ossId,
|
||||
}
|
||||
// 调用addExportFile接口创建文件保存记录
|
||||
const res = await addExportFile(reportExportFile)
|
||||
return true;
|
||||
}
|
||||
|
||||
function createReportTitle(reportType, productionLine) {
|
||||
// 获取一个yyyy-MM-dd格式的北京时间字符串
|
||||
const now = new Date()
|
||||
const year = now.getFullYear()
|
||||
const month = addZero(now.getMonth() + 1)
|
||||
const day = addZero(now.getDate())
|
||||
console.log(year, month, day)
|
||||
return `${year}-${month}-${day}_${reportType}_${productionLine || '全场'}`
|
||||
}
|
||||
Reference in New Issue
Block a user