新增商品导出
This commit is contained in:
@@ -181,6 +181,15 @@ const AuthAPI = {
|
||||
method: "get",
|
||||
params,
|
||||
});
|
||||
},
|
||||
// 导出商品
|
||||
exportProducts(params: any) {
|
||||
return request<any, Responseres>({
|
||||
url: `${baseURL}/export`,
|
||||
method: "get",
|
||||
params,
|
||||
responseType: 'blob'
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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" });
|
||||
|
||||
@@ -79,6 +79,13 @@ const contentConfig: IContentConfig<UserPageQuery> = {
|
||||
name: "custom1",
|
||||
auth: "import",
|
||||
},
|
||||
{
|
||||
icon: "Download",
|
||||
text: "导出",
|
||||
type: "",
|
||||
name: "export",
|
||||
auth: "import",
|
||||
},
|
||||
],
|
||||
cols: [
|
||||
// { type: "selection", width: 50, align: "center" },
|
||||
|
||||
Reference in New Issue
Block a user