This commit is contained in:
parent
25de7d3510
commit
de41f8a4cf
|
|
@ -255,7 +255,7 @@ export default {
|
||||||
|
|
||||||
// 下载
|
// 下载
|
||||||
onHandleDownload() {
|
onHandleDownload() {
|
||||||
this.download('material-mall/decChange/exportDetails', { id: this.recordId }, `出库记录单.xlsx`)
|
this.download('material-mall/decChange/exportDetailsRepair', { id: this.recordId }, `维修记录单.xlsx`)
|
||||||
},
|
},
|
||||||
|
|
||||||
// 打印
|
// 打印
|
||||||
|
|
@ -313,7 +313,7 @@ export default {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
::v-deep .el-card__body {
|
::v-deep .el-card__body {
|
||||||
display: flex !important;
|
display: flex !important;
|
||||||
flex-direction: column !important;
|
flex-direction: column !important;
|
||||||
|
|
|
||||||
|
|
@ -262,42 +262,9 @@ export default {
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
// 下载PDF方法
|
// 下载
|
||||||
onHandleDownload() {
|
onHandleDownload() {
|
||||||
this.downloadPDF('material-mall/decChange/exportDetails', { id: this.recordId }, '出库记录单.pdf');
|
this.download('material-mall/decChange/exportDetails', { id: this.recordId }, `出库记录单.xlsx`)
|
||||||
},
|
|
||||||
|
|
||||||
// 封装PDF下载逻辑
|
|
||||||
async downloadPDF(url, params, fileName) {
|
|
||||||
try {
|
|
||||||
// 关键:设置responseType为blob(二进制流)
|
|
||||||
const response = await this.$axios({
|
|
||||||
method: 'post',
|
|
||||||
url: url,
|
|
||||||
data: params, // POST请求参数
|
|
||||||
responseType: 'blob', // 必须指定为blob
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json;charset=UTF-8' // 匹配后端接收格式
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 创建下载链接
|
|
||||||
const blob = new Blob([response.data], { type: 'application/pdf' });
|
|
||||||
const downloadUrl = window.URL.createObjectURL(blob);
|
|
||||||
const link = document.createElement('a');
|
|
||||||
link.href = downloadUrl;
|
|
||||||
link.download = fileName; // 文件名
|
|
||||||
document.body.appendChild(link);
|
|
||||||
link.click(); // 触发下载
|
|
||||||
|
|
||||||
// 释放资源
|
|
||||||
document.body.removeChild(link);
|
|
||||||
window.URL.revokeObjectURL(downloadUrl);
|
|
||||||
|
|
||||||
this.$message.success('PDF导出成功!');
|
|
||||||
} catch (error) {
|
|
||||||
this.$message.error('PDF导出失败:' + (error.message || '未知错误'));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// 打印
|
// 打印
|
||||||
|
|
|
||||||
|
|
@ -265,7 +265,7 @@ export default {
|
||||||
|
|
||||||
// 下载
|
// 下载
|
||||||
onHandleDownload() {
|
onHandleDownload() {
|
||||||
this.download('material-mall/decChange/exportDetails', { id: this.recordId }, `出库记录单.xlsx`)
|
this.download('material-mall/decChange/exportDetailsRetire', { id: this.recordId }, `退役记录单.xlsx`)
|
||||||
},
|
},
|
||||||
|
|
||||||
// 打印
|
// 打印
|
||||||
|
|
|
||||||
|
|
@ -255,7 +255,7 @@ export default {
|
||||||
|
|
||||||
// 下载
|
// 下载
|
||||||
onHandleDownload() {
|
onHandleDownload() {
|
||||||
this.download('material-mall/decChange/exportDetails', { id: this.recordId }, `出库记录单.xlsx`)
|
this.download('material-mall/decChange/exportDetails', { id: this.recordId }, `退库记录单.xlsx`)
|
||||||
},
|
},
|
||||||
|
|
||||||
// 打印
|
// 打印
|
||||||
|
|
@ -311,7 +311,7 @@ export default {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
::v-deep .el-card__body {
|
::v-deep .el-card__body {
|
||||||
display: flex !important;
|
display: flex !important;
|
||||||
flex-direction: column !important;
|
flex-direction: column !important;
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-button
|
<el-button
|
||||||
icon="el-icon-download"
|
icon="el-icon-download"
|
||||||
style="margin-left: 1250px"
|
style="margin-left: 1320px"
|
||||||
type="primary"
|
type="primary"
|
||||||
size="mini"
|
size="mini"
|
||||||
@click="handleExport"
|
@click="handleExport"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue