This commit is contained in:
parent
7cf190dff9
commit
e7d80dc36e
25
src/api/tools.js
Normal file
25
src/api/tools.js
Normal file
@ -0,0 +1,25 @@
|
||||
import {mande} from "mande";
|
||||
|
||||
const tools = mande('/api/v2/tools')
|
||||
|
||||
// 下载Coach Outlet Excel文件
|
||||
export const DownloadCoachOutletExcel = (providerId) => {
|
||||
// return tools.get(`/excel/coach-outlet/${providerId}`, {
|
||||
// responseType: 'blob' // 指定响应类型为blob,用于文件下载
|
||||
// })
|
||||
return fetch(`/api/v2/tools/excel/coach-outlet/${providerId}`, {
|
||||
method: "get",
|
||||
mode: "no-cors",
|
||||
referrerPolicy: "no-referrer",
|
||||
})
|
||||
.then((res) => res.blob())
|
||||
.then((res) => {
|
||||
const aElement = document.createElement("a");
|
||||
aElement.setAttribute("download", providerId + ".xlsx");
|
||||
const href = URL.createObjectURL(res);
|
||||
aElement.href = href;
|
||||
aElement.setAttribute("target", "_blank");
|
||||
aElement.click();
|
||||
URL.revokeObjectURL(href);
|
||||
});
|
||||
}
|
56
src/componse/tools/ExportCheaper.vue
Normal file
56
src/componse/tools/ExportCheaper.vue
Normal file
@ -0,0 +1,56 @@
|
||||
<template>
|
||||
<a-card bordered hoverable class="w-150px" @click="downloadExcel">
|
||||
<template #title>
|
||||
<div class="text-xxl">
|
||||
导出{{ providerName }}优惠商品
|
||||
</div>
|
||||
</template>
|
||||
<div class="flex space-x-2 items-center">
|
||||
<FileExcelOutlined class="text-lg" />
|
||||
<span>Excel导出</span>
|
||||
</div>
|
||||
</a-card>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { FileExcelOutlined } from "@ant-design/icons-vue";
|
||||
import { computed } from "vue";
|
||||
import { DownloadCoachOutletExcel } from "@/api/tools.js";
|
||||
import { message } from "ant-design-vue";
|
||||
|
||||
const props = defineProps({
|
||||
providerId: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
});
|
||||
|
||||
const loading = defineModel('loading')
|
||||
|
||||
|
||||
// 根据providerId显示不同的名称
|
||||
const providerName = computed(() => {
|
||||
if (props.providerId === 'us-coach-outlet') {
|
||||
return '美国Coach Outlet';
|
||||
} else if (props.providerId === 'ca-coach-outlet') {
|
||||
return '加拿大Coach Outlet';
|
||||
}
|
||||
return 'Coach Outlet';
|
||||
});
|
||||
|
||||
// 下载Excel文件
|
||||
const downloadExcel = () => {
|
||||
loading.value = true;
|
||||
DownloadCoachOutletExcel(props.providerId)
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
message.error('导出失败');
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
@ -1,15 +1,23 @@
|
||||
<template>
|
||||
<div class="h-full m-4 bg-gray-50 rounded-2 shadow-lg p-8 flex flex-col justify-between space-y-4">
|
||||
<a-flex wrap="wrap" >
|
||||
<call-ats-tool></call-ats-tool>
|
||||
</a-flex>
|
||||
<div class="h-full m-4 bg-white rounded-2 shadow-lg p-8 flex flex-col space-y-4 overscroll-auto">
|
||||
<div class="text-2xl font-bold mb-4">工具箱</div>
|
||||
<a-spin tip="Loading..." :spinning="loading">
|
||||
<div class="flex space-x-4">
|
||||
<call-ats-tool></call-ats-tool>
|
||||
<ExportCheaper providerId="us-coach-outlet" v-model:loading="loading"></ExportCheaper>
|
||||
<ExportCheaper providerId="ca-coach-outlet" v-model:loading="loading"></ExportCheaper>
|
||||
</div>
|
||||
</a-spin>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
|
||||
<script setup>
|
||||
import CallAtsTool from "@/componse/tools/call-ats-tool.vue";
|
||||
import ExportCheaper from "@/componse/tools/ExportCheaper.vue";
|
||||
import {ref} from "vue";
|
||||
|
||||
const loading = ref(false)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
@ -82,7 +82,14 @@ export default defineConfig({
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
ws: true,
|
||||
}
|
||||
},
|
||||
'/api/v2/tools': {
|
||||
// target: 'https://ht.timerzz.com:20443/',
|
||||
target: 'http://localhost:8085/',
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
ws: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
resolve: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user