Browse Source

feat(inspection): 添加验货申请单导出功能

- 在API中新增exportInspectionRequest方法用于导出Excel文件
- 扩展操作列宽度以适应新增的导出按钮
- 在表格操作列中添加导出功能按钮
- 实现exportRowExcel方法处理单条记录的Excel导出逻辑
- 集成Blob下载方式实现前端文件保存
- 添加导出成功和失败的消息提示
master
qiankanghui 6 days ago
parent
commit
06c13206d2
  1. 3
      src/api/inspection/inspectionRequestHeader.js
  2. 33
      src/views/modules/inspection/inspectionRequestList.vue

3
src/api/inspection/inspectionRequestHeader.js

@ -81,3 +81,6 @@ export const createIqc = (data) => createAPI(`/qms/qc/createIqc`, 'post', data)
// 开始验货
export const startInspection = (data) => createAPI(`/inspection/startInspection`, 'post', data)
// 导出验货申请单(后端生成带边框样式的Excel)
export const exportInspectionRequest = (requestNo, site) => createAPI(`/inspection/export/${requestNo}`, 'get', { site: site }, 'download')

33
src/views/modules/inspection/inspectionRequestList.vue

@ -101,7 +101,7 @@
style="width: 100px; height: 100px"/></span>
</template>
</el-table-column>
<el-table-column fixed="right" header-align="center" align="center" width="120" label="操作">
<el-table-column fixed="right" header-align="center" align="center" width="160" label="操作">
<template slot-scope="scope">
<a v-if="isRowStatus(scope.row, ['Draft'])"
class="customer-a" @click="confirmInspection(scope.row)">确认</a>
@ -117,6 +117,7 @@
class="customer-a"
:style="(isRowStatus(scope.row, ['Draft']) || isRowStatus(scope.row, ['Confirmed'])) ? 'margin-left: 3px;' : ''"
@click="applyChangeRequest(scope.row)">申请变更</a>
<a class="customer-a" style="margin-left: 3px;" @click="exportRowExcel(scope.row)">导出</a>
<span v-if="!isRowStatus(scope.row, ['Draft', 'Confirmed', 'Audited', 'Scheduled'])"
class="customer-a"
style="color: #909399; cursor: default;">{{ scope.row.status }}</span>
@ -3051,6 +3052,36 @@ export default {
})
},
// - Excel
exportRowExcel (row) {
if (!row || !row.requestNo) {
this.$message.warning('数据异常,无法导出')
return
}
this.$http({
url: this.$http.adornUrl(`/inspection/export/${row.requestNo}`),
method: 'get',
params: { site: row.site },
responseType: 'blob'
}).then(response => {
const blob = new Blob([response.data], {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
})
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = '验货申请单_' + row.requestNo + '.xlsx'
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
window.URL.revokeObjectURL(url)
this.$message.success('导出成功')
}).catch(error => {
console.error('导出失败:', error)
this.$message.error('导出失败,请稍后重试')
})
},
executeApplyChangeRequest (requestNo, changeRemark) {
this.applyChangeLoading = true
applyChangeInspectionRequest(requestNo, { changeRemark }).then(({ data }) => {

Loading…
Cancel
Save