|
|
|
|
@ -1,4 +1,6 @@
|
|
|
|
|
import request from "@/api/request"; |
|
|
|
|
import feedback from "../../utils/feedback"; |
|
|
|
|
import {getToken} from "../../utils/token"; |
|
|
|
|
|
|
|
|
|
export function getComplaintCollectionPage(body) { |
|
|
|
|
return request.post({ |
|
|
|
|
@ -64,3 +66,43 @@ export function handlerData(body) {
|
|
|
|
|
body |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 导出 |
|
|
|
|
*/ |
|
|
|
|
export async function exportData(body) { |
|
|
|
|
const response = await fetch('/api/v2/data/complaintCollection/exportData', { |
|
|
|
|
method: 'POST', |
|
|
|
|
headers: { |
|
|
|
|
'Authorization': getToken(), |
|
|
|
|
'Content-Type': 'application/json' |
|
|
|
|
}, |
|
|
|
|
body: JSON.stringify(body) |
|
|
|
|
}) |
|
|
|
|
if (!response.ok) { |
|
|
|
|
feedback.msgError('导出失败') |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
// 👉 关键:直接拿 blob
|
|
|
|
|
const blob = await response.blob() |
|
|
|
|
let filename = '涉访涉诉数据.xlsx' |
|
|
|
|
const disposition = response.headers.get('content-disposition') |
|
|
|
|
if (disposition) { |
|
|
|
|
const match = disposition.match(/filename\*=UTF-8''(.+)/) |
|
|
|
|
if (match) { |
|
|
|
|
filename = decodeURIComponent(match[1]) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 👉 触发下载
|
|
|
|
|
const url = window.URL.createObjectURL(blob) |
|
|
|
|
const a = document.createElement('a') |
|
|
|
|
a.href = url |
|
|
|
|
a.download = filename |
|
|
|
|
|
|
|
|
|
document.body.appendChild(a) |
|
|
|
|
a.click() |
|
|
|
|
|
|
|
|
|
document.body.removeChild(a) |
|
|
|
|
window.URL.revokeObjectURL(url) |
|
|
|
|
} |