新增导出

This commit is contained in:
gyq
2026-01-31 09:26:25 +08:00
parent 3855ed4b75
commit 058c8dcadc
6 changed files with 69 additions and 44 deletions

View File

@@ -51,6 +51,15 @@ const AuthAPI = {
method: "delete",
});
},
// 导出常用单位
exportUnits(params: any) {
return request<any, Responseres>({
url: `${baseURL}/export`,
method: "get",
params,
responseType: 'blob'
});
}
};

View File

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

View File

@@ -7,17 +7,9 @@
@reset-click="handleResetClick" /> -->
<!-- 列表 -->
<page-content
ref="contentRef"
:content-config="contentConfig"
@add-click="handleAddClick"
@edit-click="handleEditClick"
@export-click="handleExportClick"
@search-click="handleSearchClick"
@toolbar-click="handleToolbarClick"
@operat-click="handleOperatClick"
@filter-change="handleFilterChange"
>
<page-content ref="contentRef" :content-config="contentConfig" @add-click="handleAddClick"
@edit-click="handleEditClick" @export-click="handleExportClick" @search-click="handleSearchClick"
@toolbar-click="handleToolbarClick" @operat-click="handleOperatClick" @filter-change="handleFilterChange">
<template #status="scope">
<el-tag :type="scope.row[scope.prop] == 1 ? 'success' : 'info'">
{{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }}
@@ -25,12 +17,7 @@
</template>
<template #slotNameimage="scope">
<el-image
v-if="scope.row.pic"
:src="scope.row.pic"
lazy
style="width: 40px; height: 40px"
/>
<el-image v-if="scope.row.pic" :src="scope.row.pic" lazy style="width: 40px; height: 40px" />
<div v-else></div>
</template>
<template #gender="scope">
@@ -38,42 +25,26 @@
</template>
<template #mobile="scope">
<el-text>{{ scope.row[scope.prop] }}</el-text>
<copy-button
v-if="scope.row[scope.prop]"
:text="scope.row[scope.prop]"
style="margin-left: 2px"
/>
<copy-button v-if="scope.row[scope.prop]" :text="scope.row[scope.prop]" style="margin-left: 2px" />
</template>
</page-content>
<!-- 新增 -->
<page-modal
ref="addModalRef"
:modal-config="addModalConfig"
@submit-click="handleSubmitClick"
>
<page-modal ref="addModalRef" :modal-config="addModalConfig" @submit-click="handleSubmitClick">
<template #gender="scope">
<Dict v-model="scope.formData[scope.prop]" code="gender" />
</template>
</page-modal>
<!-- 编辑 -->
<page-modal
ref="editModalRef"
:modal-config="editModalConfig"
@submit-click="handleSubmitClick"
>
<page-modal ref="editModalRef" :modal-config="editModalConfig" @submit-click="handleSubmitClick">
<template #gender="scope">
<Dict v-model="scope.formData[scope.prop]" code="gender" v-bind="scope.attrs" />
</template>
</page-modal>
</template>
<template v-else>
<page-content
ref="contentRef"
:content-config="contentConfig2"
@operat-click="handleOperatClick"
>
<page-content ref="contentRef" :content-config="contentConfig2" @operat-click="handleOperatClick">
<template #status="scope">
<el-tag :type="scope.row[scope.prop] == 1 ? 'success' : 'info'">
{{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }}
@@ -95,7 +66,7 @@ import contentConfig from "./categoryconfig/content";
import contentConfig2 from "./categoryconfig/content2";
import editModalConfig from "./categoryconfig/edit";
import searchConfig from "./categoryconfig/search";
import { isSyncStatus } from "@/utils/index";
import { isSyncStatus, downloadFile } from "@/utils/index";
const {
searchRef,
@@ -107,7 +78,7 @@ const {
// handleAddClick,
// handleEditClick,
handleSubmitClick,
handleExportClick,
// handleExportClick,
handleSearchClick,
handleFilterChange,
} = usePage();
@@ -123,6 +94,18 @@ if (isSyncStatus()) {
contentConfig.cols[contentConfig.cols.length - 1].operat[0].hidden = false
contentConfig.cols[contentConfig.cols.length - 1].operat[1].hidden = false
}
// 导出
async function handleExportClick() {
try {
const filterParams = searchRef.value?.getQueryParams();
const file = await UserAPI.exportCategories(filterParams);
downloadFile(file, "商品分类列表", "xlsx");
} catch (error) {
console.log(error);
}
}
// 新增
async function handleAddClick() {
addModalRef.value?.setModalVisible();

View File

@@ -52,6 +52,13 @@ const contentConfig: IContentConfig<UserPageQuery> = {
name: "add",
auth: "import",
},
{
icon: "Download",
text: "导出",
type: "",
name: "export",
auth: "import",
},
],
cols: [
// { type: "selection", width: 50, align: "center" },
@@ -76,7 +83,7 @@ const contentConfig: IContentConfig<UserPageQuery> = {
fixed: "right",
width: 280,
templet: "tool",
operat: [{ text: "编辑", icon: 'edit', name: "edit"}, { text: "删除", icon: 'delete', type: 'danger', name: "delete"}],
operat: [{ text: "编辑", icon: 'edit', name: "edit" }, { text: "删除", icon: 'delete', type: 'danger', name: "delete" }],
},
],
};

View File

@@ -61,7 +61,7 @@ import contentConfig from "./unitconfig/content";
import contentConfig2 from "./unitconfig/content2";
import editModalConfig from "./unitconfig/edit";
import searchConfig from "./unitconfig/search";
import { isSyncStatus } from "@/utils/index";
import { isSyncStatus, downloadFile } from "@/utils/index";
const {
searchRef,
@@ -73,7 +73,7 @@ const {
// handleAddClick,
// handleEditClick,
handleSubmitClick,
handleExportClick,
// handleExportClick,
handleSearchClick,
handleFilterChange,
} = usePage();
@@ -88,6 +88,17 @@ if (isSyncStatus()) {
contentConfig.cols[contentConfig.cols.length - 1].operat[1].hidden = false
}
// 导出商品单位
async function handleExportClick() {
try {
const filterParams = searchRef.value?.getQueryParams();
const file = await UserAPI.exportUnits(filterParams);
downloadFile(file, "商品单位列表", "xlsx");
} catch (error) {
console.log(error);
}
}
// 新增
async function handleAddClick() {
addModalRef.value?.setModalVisible();

View File

@@ -45,6 +45,13 @@ const contentConfig: IContentConfig<UserPageQuery> = {
name: "add",
auth: "import",
},
{
icon: "Download",
text: "导出",
type: "",
name: "export",
auth: "import",
},
],
cols: [
// { type: "selection", width: 50, align: "center" },
@@ -56,7 +63,7 @@ const contentConfig: IContentConfig<UserPageQuery> = {
fixed: "right",
width: 280,
templet: "tool",
operat: [{ text: "编辑", icon: 'edit', name: "edit"}, { text: "删除", icon: 'delete', type: 'danger', name: "delete"}],
operat: [{ text: "编辑", icon: 'edit', name: "edit" }, { text: "删除", icon: 'delete', type: 'danger', name: "delete" }],
},
],
};