新增商品导出

This commit is contained in:
gyq
2026-01-30 16:01:44 +08:00
parent 60ea128a10
commit 3855ed4b75
3 changed files with 29 additions and 2 deletions

View File

@@ -181,6 +181,15 @@ const AuthAPI = {
method: "get", method: "get",
params, params,
}); });
},
// 导出商品
exportProducts(params: any) {
return request<any, Responseres>({
url: `${baseURL}/export`,
method: "get",
params,
responseType: 'blob'
});
} }
}; };

View File

@@ -174,7 +174,7 @@ import UserAPI from "@/api/product/index";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import type { IObject, IOperatData } from "@/components/CURD/types"; import type { IObject, IOperatData } from "@/components/CURD/types";
import usePage from "@/components/CURD/usePage"; import usePage from "@/components/CURD/usePage";
import { isSyncStatus } from "@/utils/index"; import { isSyncStatus, downloadFile } from "@/utils/index";
import addModalConfig from "./indexconfig/add"; import addModalConfig from "./indexconfig/add";
import contentConfig from "./indexconfig/content"; import contentConfig from "./indexconfig/content";
import MultiImageUpload from "@/components/Upload/MultiImageUpload.vue"; import MultiImageUpload from "@/components/Upload/MultiImageUpload.vue";
@@ -193,7 +193,7 @@ const {
handleResetClick, handleResetClick,
// handleEditClick, // handleEditClick,
handleSubmitClick, handleSubmitClick,
handleExportClick, // handleExportClick,
handleSearchClick, handleSearchClick,
handleFilterChange, handleFilterChange,
} = usePage(); } = 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() { async function handleAddClick() {
router.push({ name: "addgoods" }); router.push({ name: "addgoods" });

View File

@@ -79,6 +79,13 @@ const contentConfig: IContentConfig<UserPageQuery> = {
name: "custom1", name: "custom1",
auth: "import", auth: "import",
}, },
{
icon: "Download",
text: "导出",
type: "",
name: "export",
auth: "import",
},
], ],
cols: [ cols: [
// { type: "selection", width: 50, align: "center" }, // { type: "selection", width: 50, align: "center" },