mirror of
https://github.com/hpd840321/craftlabs-authorization-sdk.git
synced 2026-06-09 10:00:30 +08:00
feat(m9): add CSV export for contract-sn report
This commit is contained in:
@@ -373,6 +373,9 @@ export function updateNotificationConfig(body) {
|
||||
export function getContractSnReport(params) {
|
||||
return axios.get('/api/v1/reports/contract-sn', { params });
|
||||
}
|
||||
export function exportReport(params) {
|
||||
return axios.get('/api/v1/reports/export', { params, responseType: 'blob' });
|
||||
}
|
||||
export function getCallbackStats(params) {
|
||||
return axios.get('/api/v1/reports/callback-stats', { params });
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<div class="toolbar">
|
||||
<span class="title">合同 SN 报表</span>
|
||||
<div class="actions">
|
||||
<el-button @click="handleExport" :loading="exporting">导出 CSV</el-button>
|
||||
<el-button type="primary" :loading="loading" @click="load">刷新</el-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -49,11 +50,12 @@
|
||||
import { ref, reactive, onMounted } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { useAuthStore } from "../stores/auth";
|
||||
import { getContractSnReport } from "../api/platform";
|
||||
import { getContractSnReport, exportReport } from "../api/platform";
|
||||
import { apiErrorMessage } from "../utils/apiErrorMessage";
|
||||
|
||||
const auth = useAuthStore();
|
||||
const loading = ref(false);
|
||||
const exporting = ref(false);
|
||||
const rows = ref([]);
|
||||
const kpi = reactive({ totalLineItems: 0, totalIssued: 0, totalActivated: 0, totalGap: 0 });
|
||||
|
||||
@@ -83,6 +85,25 @@ async function load() {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleExport() {
|
||||
exporting.value = true
|
||||
try {
|
||||
const response = await exportReport({ type: 'contract-sn' })
|
||||
const url = window.URL.createObjectURL(new Blob([response.data]))
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.setAttribute('download', `contract-sn-report-${new Date().toISOString().slice(0, 10)}.csv`)
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
window.URL.revokeObjectURL(url)
|
||||
} catch (e) {
|
||||
ElMessage.error('导出失败')
|
||||
} finally {
|
||||
exporting.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user