Commit acb3430b authored by nick zheng's avatar nick zheng

Merge branch 'beta' into 'master'

chore: 应用API调用导出调用明细excel

See merge request !131
parents 2ca7b535 9217d063
......@@ -73,7 +73,6 @@ service.interceptors.request.use(
service.interceptors.response.use(
(response: AxiosResponse) => {
console.log('response', response)
if (response.status === 200) {
return response.data
}
......@@ -101,7 +100,6 @@ function http<T>(
) {
/* 请求成功处理函数 */
const successHandler = (res: Response<T>): Promise<Response<T>> | Response<T> => {
console.log('successHandler', res)
if (res.code === 0 || options?.ignoreErrorCheck) return res
if (res.code === -10) {
......
......@@ -23,6 +23,7 @@ const isShow = defineModel<boolean>('isShow', { required: true })
const apiProfileLoading = ref(false)
const apiCallDetailLoading = ref(false)
const reportAPIUsageDataLoading = ref(false)
const apiProfileInfo = ref<ApiProfileInfo>({
apiKey: '',
apiSecret: '',
......@@ -120,6 +121,8 @@ async function handleUpdateDateRange(_value: [number, number], formattedValue: [
}
async function handleExportAPIChannelPointUsageData() {
reportAPIUsageDataLoading.value = true
fetchReportAPIChannelPointUsage({
reportRequestType: 'API_CHANNEL_POINT_USAGE',
agentId: personalAppConfigStore.baseInfo.agentId,
......@@ -129,15 +132,21 @@ async function handleExportAPIChannelPointUsageData() {
endTime: selectDateRange.value[1],
},
})
.then((res) => {
console.log(res)
const excelUrl = window.URL.createObjectURL(new Blob([res as any], { type: 'application/vnd.ms-excel' }))
window.open(excelUrl)
.then((data: any) => {
const blob = new Blob([data], { type: 'application/vnd.ms-excel' })
const link = document.createElement('a')
link.href = window.URL.createObjectURL(blob)
link.download = `${personalAppConfigStore.baseInfo.agentId}.xlsx`
link.click()
window.URL.revokeObjectURL(link.href)
window.$message.success(t('common_module.export_successfully'))
})
.catch(() => {
window.$message.error(t('common_module.export_failed'))
})
.finally(() => {
reportAPIUsageDataLoading.value = false
})
}
</script>
......@@ -268,6 +277,7 @@ async function handleExportAPIChannelPointUsageData() {
type="primary"
:bordered="false"
:disabled="!apiCallDetailData.length"
:loading="reportAPIUsageDataLoading"
@click="handleExportAPIChannelPointUsageData"
>
{{ t('common_module.export_data') }}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment