From 868e08bf0513b2e6ad0360bc2000119a7e376548 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期五, 24 四月 2026 15:25:53 +0800
Subject: [PATCH] 产品管理: 增加导出产品数据功能,支持按大类选择导出
---
src/views/basicData/product/index.vue | 86 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 86 insertions(+), 0 deletions(-)
diff --git a/src/views/basicData/product/index.vue b/src/views/basicData/product/index.vue
index 7b2a819..d8ced28 100644
--- a/src/views/basicData/product/index.vue
+++ b/src/views/basicData/product/index.vue
@@ -17,6 +17,9 @@
style="margin-left: 10px"
>鏂板浜у搧澶х被</el-button
>
+ <el-button type="success" style="margin-left: 10px" @click="openExportDia">
+ 瀵煎嚭
+ </el-button>
</div>
<div ref="containerRef">
<el-tree
@@ -170,6 +173,42 @@
</div>
</template>
</el-dialog>
+ <el-dialog
+ v-model="exportDia"
+ title="瀵煎嚭浜у搧鏁版嵁"
+ width="420px"
+ @keydown.enter.prevent
+ >
+ <el-form label-position="top">
+ <el-form-item label="閫夋嫨浜у搧澶х被锛堝彲涓嶉�夛級">
+ <el-select
+ v-model="exportProductId"
+ clearable
+ filterable
+ placeholder="涓嶉�夊垯瀵煎嚭鍏ㄩ儴浜у搧"
+ style="width: 100%"
+ >
+ <el-option
+ v-for="item in rootProductOptions"
+ :key="item.id"
+ :label="item.label"
+ :value="item.id"
+ />
+ </el-select>
+ <div class="export-tip">
+ 宸查�夛細瀵煎嚭璇ュぇ绫诲強鍏跺瓙绫伙紱鏈�夛細瀵煎嚭鍏ㄩ儴
+ </div>
+ </el-form-item>
+ </el-form>
+ <template #footer>
+ <div class="dialog-footer">
+ <el-button type="primary" :loading="exportLoading" :disabled="exportLoading" @click="handleExport">
+ 纭瀵煎嚭
+ </el-button>
+ <el-button @click="closeExportDia">鍙栨秷</el-button>
+ </div>
+ </template>
+ </el-dialog>
</div>
</template>
@@ -181,6 +220,7 @@
addOrEditProductModel,
delProduct,
delProductModel,
+ exportProductData,
modelListPage,
productTreeList,
} from "@/api/basicData/product.js";
@@ -192,14 +232,18 @@
const productDia = ref(false);
const modelDia = ref(false);
+const exportDia = ref(false);
+const exportLoading = ref(false);
const modelOperationType = ref("");
const search = ref("");
const currentId = ref("");
const currentParentId = ref("");
+const exportProductId = ref("");
const operationType = ref("");
const treeLoad = ref(false);
const list = ref([]);
const expandedKeys = ref([]);
+const rootProductOptions = ref([]);
const tableColumn = ref([
{
label: "瑙勬牸鍨嬪彿",
@@ -259,6 +303,7 @@
productTreeList()
.then((res) => {
list.value = res;
+ rootProductOptions.value = Array.isArray(res) ? res : [];
list.value.forEach((a) => {
expandedKeys.value.push(a.label);
});
@@ -425,6 +470,42 @@
proxy.$modal.msg("宸插彇娑�");
});
};
+const openExportDia = () => {
+ exportDia.value = true;
+};
+const closeExportDia = () => {
+ exportDia.value = false;
+};
+// 瀵煎嚭浜у搧锛堝彲鎸夊ぇ绫伙紝鍚瓙绫伙級
+const handleExport = () => {
+ if (exportLoading.value) return;
+ exportLoading.value = true;
+ const params = exportProductId.value ? { productId: exportProductId.value } : {};
+ exportProductData(params)
+ .then((blobData) => {
+ const blob =
+ blobData instanceof Blob
+ ? blobData
+ : new Blob([blobData], {
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ });
+ const url = window.URL.createObjectURL(blob);
+ const link = document.createElement("a");
+ link.href = url;
+ link.download = "浜у搧鏁版嵁.xlsx";
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
+ window.URL.revokeObjectURL(url);
+ closeExportDia();
+ })
+ .catch(() => {
+ proxy.$modal.msgError("瀵煎嚭澶辫触锛岃绋嶅悗閲嶈瘯");
+ })
+ .finally(() => {
+ exportLoading.value = false;
+ });
+};
// 璋冪敤tree杩囨护鏂规硶 涓枃鑻辫繃婊�
const filterNode = (value, data, node) => {
if (!value) {
@@ -529,4 +610,9 @@
.product-tree-scroll::-webkit-scrollbar-thumb:hover {
background: #909399;
}
+.export-tip {
+ margin-top: 8px;
+ font-size: 12px;
+ color: #909399;
+}
</style>
--
Gitblit v1.9.3