diff --git a/src/api/customerService/product/index.ts b/src/api/customerService/product/index.ts
index 77a55d6..cdfa43d 100644
--- a/src/api/customerService/product/index.ts
+++ b/src/api/customerService/product/index.ts
@@ -36,10 +36,22 @@ export function updateProduct(data: object) {
});
}
+// 导出产品
export function exportProduct(data: object) {
return newService({
url: '/customerService/product/export',
+ responseType: 'blob',
method: 'get',
params: data,
});
}
+
+//导入产品
+export function importProduct(data: object) {
+ return newService({
+ url: '/customerService/product/import',
+ responseType: 'blob',
+ method: 'post',
+ data: data,
+ });
+}
diff --git a/src/utils/request.ts b/src/utils/request.ts
index 3f7e8b1..03e7d49 100644
--- a/src/utils/request.ts
+++ b/src/utils/request.ts
@@ -51,6 +51,14 @@ const responseInterceptor = (response: any) => {
const res = response.data;
const code = response.data.code;
const message = response.data.message;
+ // 第65行附近添加:如果是文件流响应,直接返回整个response
+ if (
+ response.config.responseType === 'blob' ||
+ response.headers['content-type']?.includes('application/zip') ||
+ response.headers['content-type']?.includes('application/octet-stream')
+ ) {
+ return response; // 直接返回原始响应,不进行JSON解析
+ }
if (code === 401 || message === 'token is invalid') {
// 401未授权:token过期,跳转登录页
ElMessageBox.alert('登录状态已过期,请重新登录', '提示', { confirmButtonText: '确定' })
diff --git a/src/views/customerService/product/component/exportDialog.vue b/src/views/customerService/product/component/exportDialog.vue
index 0f9a398..7a70815 100644
--- a/src/views/customerService/product/component/exportDialog.vue
+++ b/src/views/customerService/product/component/exportDialog.vue
@@ -1,55 +1,99 @@
- 确定要导出产品数据吗?