维护系统->检查方法、部位导出表格功能OK
This commit is contained in:
@@ -87,6 +87,26 @@ export function delCheckMethod(checkMethodId) {
|
||||
})
|
||||
}
|
||||
|
||||
// 导出检查方法
|
||||
export function exportCheckMethod(query) {
|
||||
return request({
|
||||
url: '/check/method/export',
|
||||
method: 'get',
|
||||
params: query,
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
|
||||
// 导出检查部位
|
||||
export function exportCheckPart(query) {
|
||||
return request({
|
||||
url: '/check/part/export',
|
||||
method: 'get',
|
||||
params: query,
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
|
||||
// 查询检查部位列表
|
||||
export function listCheckPart(query) {
|
||||
return request({
|
||||
|
||||
@@ -506,7 +506,7 @@
|
||||
import { ref, reactive, onMounted, computed } from 'vue';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { getDicts } from '@/api/system/dict/data';
|
||||
import { listCheckType, listCheckMethod, listCheckPart, listCheckPackage, searchCheckMethod, searchCheckPart, addCheckType, updateCheckType, delCheckType, addCheckMethod, updateCheckMethod, delCheckMethod, addCheckPart, updateCheckPart, delCheckPart } from '@/api/system/checkType';
|
||||
import { listCheckType, listCheckMethod, listCheckPart, listCheckPackage, searchCheckMethod, searchCheckPart, addCheckType, updateCheckType, delCheckType, addCheckMethod, updateCheckMethod, delCheckMethod, addCheckPart, updateCheckPart, delCheckPart, exportCheckMethod, exportCheckPart } from '@/api/system/checkType';
|
||||
import PackageSettings from './components/PackageSettings.vue';
|
||||
import PackageManagement from './components/PackageManagement.vue';
|
||||
|
||||
@@ -1269,10 +1269,51 @@ function handleReset() {
|
||||
// 处理导出表格功能
|
||||
function handleExport() {
|
||||
console.log('导出表格:', activeMenu.value);
|
||||
ElMessage.success(`正在导出${activeMenu.value}数据,请稍候...`);
|
||||
|
||||
// 这里可以实现实际的导出逻辑
|
||||
// 例如调用API或使用前端库生成Excel文件
|
||||
if (activeMenu.value === '检查方法') {
|
||||
// 调用检查方法导出API
|
||||
exportCheckMethod(searchParamsMethod).then(blobData => {
|
||||
// 直接使用blobData创建下载链接,因为response拦截器已经返回了res.data
|
||||
const blob = new Blob([blobData], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
// 设置文件名
|
||||
link.setAttribute('download', `检查方法数据_${new Date().toISOString().slice(0, 10)}.xlsx`);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
// 清理
|
||||
document.body.removeChild(link);
|
||||
window.URL.revokeObjectURL(url);
|
||||
ElMessage.success('检查方法数据导出成功');
|
||||
}).catch(error => {
|
||||
console.error('导出检查方法数据失败:', error);
|
||||
ElMessage.error('导出检查方法数据失败');
|
||||
});
|
||||
} else if (activeMenu.value === '检查部位') {
|
||||
// 调用检查部位导出API
|
||||
exportCheckPart(searchParamsPart).then(blobData => {
|
||||
// 直接使用blobData创建下载链接,因为response拦截器已经返回了res.data
|
||||
const blob = new Blob([blobData], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
// 设置文件名
|
||||
link.setAttribute('download', `检查部位数据_${new Date().toISOString().slice(0, 10)}.xlsx`);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
// 清理
|
||||
document.body.removeChild(link);
|
||||
window.URL.revokeObjectURL(url);
|
||||
ElMessage.success('检查部位数据导出成功');
|
||||
}).catch(error => {
|
||||
console.error('导出检查部位数据失败:', error);
|
||||
ElMessage.error('导出检查部位数据失败');
|
||||
});
|
||||
} else {
|
||||
// 其他菜单的导出逻辑可以在这里扩展
|
||||
ElMessage.warning('该功能尚未实现');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user