From 3855ed4b7514f85be45b81c58f3fbaa5ac683a79 Mon Sep 17 00:00:00 2001 From: gyq <875626088@qq.com> Date: Fri, 30 Jan 2026 16:01:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=95=86=E5=93=81=E5=AF=BC?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/product/index.ts | 9 +++++++++ src/views/product/index.vue | 15 +++++++++++++-- src/views/product/indexconfig/content.ts | 7 +++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/api/product/index.ts b/src/api/product/index.ts index 2facf1e..ae3d34c 100644 --- a/src/api/product/index.ts +++ b/src/api/product/index.ts @@ -181,6 +181,15 @@ const AuthAPI = { method: "get", params, }); + }, + // 导出商品 + exportProducts(params: any) { + return request({ + url: `${baseURL}/export`, + method: "get", + params, + responseType: 'blob' + }); } }; diff --git a/src/views/product/index.vue b/src/views/product/index.vue index c49889e..a06a6e8 100644 --- a/src/views/product/index.vue +++ b/src/views/product/index.vue @@ -174,7 +174,7 @@ import UserAPI from "@/api/product/index"; import { useRouter } from "vue-router"; import type { IObject, IOperatData } from "@/components/CURD/types"; import usePage from "@/components/CURD/usePage"; -import { isSyncStatus } from "@/utils/index"; +import { isSyncStatus, downloadFile } from "@/utils/index"; import addModalConfig from "./indexconfig/add"; import contentConfig from "./indexconfig/content"; import MultiImageUpload from "@/components/Upload/MultiImageUpload.vue"; @@ -193,7 +193,7 @@ const { handleResetClick, // handleEditClick, handleSubmitClick, - handleExportClick, + // handleExportClick, handleSearchClick, handleFilterChange, } = usePage(); @@ -302,6 +302,17 @@ function getTongji(params: IObject | undefined) { }); } +// 导出商品 +async function handleExportClick() { + try { + const filterParams = searchRef.value?.getQueryParams(); + const file = await UserAPI.exportProducts(filterParams); + downloadFile(file, "商品列表", "xlsx"); + } catch (error) { + console.log(error); + } +} + // 新增 async function handleAddClick() { router.push({ name: "addgoods" }); diff --git a/src/views/product/indexconfig/content.ts b/src/views/product/indexconfig/content.ts index 2ac8516..a177bd2 100644 --- a/src/views/product/indexconfig/content.ts +++ b/src/views/product/indexconfig/content.ts @@ -79,6 +79,13 @@ const contentConfig: IContentConfig = { name: "custom1", auth: "import", }, + { + icon: "Download", + text: "导出", + type: "", + name: "export", + auth: "import", + }, ], cols: [ // { type: "selection", width: 50, align: "center" },