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( ...@@ -73,7 +73,6 @@ service.interceptors.request.use(
service.interceptors.response.use( service.interceptors.response.use(
(response: AxiosResponse) => { (response: AxiosResponse) => {
console.log('response', response)
if (response.status === 200) { if (response.status === 200) {
return response.data return response.data
} }
...@@ -101,7 +100,6 @@ function http<T>( ...@@ -101,7 +100,6 @@ function http<T>(
) { ) {
/* 请求成功处理函数 */ /* 请求成功处理函数 */
const successHandler = (res: Response<T>): Promise<Response<T>> | Response<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 === 0 || options?.ignoreErrorCheck) return res
if (res.code === -10) { if (res.code === -10) {
......
...@@ -23,6 +23,7 @@ const isShow = defineModel<boolean>('isShow', { required: true }) ...@@ -23,6 +23,7 @@ const isShow = defineModel<boolean>('isShow', { required: true })
const apiProfileLoading = ref(false) const apiProfileLoading = ref(false)
const apiCallDetailLoading = ref(false) const apiCallDetailLoading = ref(false)
const reportAPIUsageDataLoading = ref(false)
const apiProfileInfo = ref<ApiProfileInfo>({ const apiProfileInfo = ref<ApiProfileInfo>({
apiKey: '', apiKey: '',
apiSecret: '', apiSecret: '',
...@@ -120,6 +121,8 @@ async function handleUpdateDateRange(_value: [number, number], formattedValue: [ ...@@ -120,6 +121,8 @@ async function handleUpdateDateRange(_value: [number, number], formattedValue: [
} }
async function handleExportAPIChannelPointUsageData() { async function handleExportAPIChannelPointUsageData() {
reportAPIUsageDataLoading.value = true
fetchReportAPIChannelPointUsage({ fetchReportAPIChannelPointUsage({
reportRequestType: 'API_CHANNEL_POINT_USAGE', reportRequestType: 'API_CHANNEL_POINT_USAGE',
agentId: personalAppConfigStore.baseInfo.agentId, agentId: personalAppConfigStore.baseInfo.agentId,
...@@ -129,15 +132,21 @@ async function handleExportAPIChannelPointUsageData() { ...@@ -129,15 +132,21 @@ async function handleExportAPIChannelPointUsageData() {
endTime: selectDateRange.value[1], endTime: selectDateRange.value[1],
}, },
}) })
.then((res) => { .then((data: any) => {
console.log(res) const blob = new Blob([data], { type: 'application/vnd.ms-excel' })
const excelUrl = window.URL.createObjectURL(new Blob([res as any], { type: 'application/vnd.ms-excel' })) const link = document.createElement('a')
window.open(excelUrl) 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')) window.$message.success(t('common_module.export_successfully'))
}) })
.catch(() => { .catch(() => {
window.$message.error(t('common_module.export_failed')) window.$message.error(t('common_module.export_failed'))
}) })
.finally(() => {
reportAPIUsageDataLoading.value = false
})
} }
</script> </script>
...@@ -268,6 +277,7 @@ async function handleExportAPIChannelPointUsageData() { ...@@ -268,6 +277,7 @@ async function handleExportAPIChannelPointUsageData() {
type="primary" type="primary"
:bordered="false" :bordered="false"
:disabled="!apiCallDetailData.length" :disabled="!apiCallDetailData.length"
:loading="reportAPIUsageDataLoading"
@click="handleExportAPIChannelPointUsageData" @click="handleExportAPIChannelPointUsageData"
> >
{{ t('common_module.export_data') }} {{ 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