From 79b93495988f483649c125e27d09af01f34f373d Mon Sep 17 00:00:00 2001 From: lSun <15893999301@qq.com> Date: Mon, 22 Sep 2025 11:14:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E4=B8=8A=E7=BA=BF=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.js | 6 + src/views/publicService/components/navBar.vue | 590 +++++++++-------- src/views/publicService/index.vue | 363 ++++++----- .../publicService/proMaterials/index.vue | 119 ++-- .../publicService/productCenter/index.vue | 613 ++++++++++-------- 5 files changed, 896 insertions(+), 795 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index b2b9d48..71d64e3 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -110,6 +110,7 @@ export const constantRoutes = [ component: () => import('@/views/publicService/productCenter/index.vue'), name: 'ProductCenter', + meta: { showSearch: true } // 需要搜索框 }, // 产品中心 ---- 查看详情页面 @@ -120,6 +121,7 @@ export const constantRoutes = [ '@/views/publicService/productCenter/product-detail.vue' ), name: 'ProductDetail', + meta: { showSearch: false } // 不需要搜索框 }, // 产品中心 ---- 查看案例页面 { @@ -129,6 +131,7 @@ export const constantRoutes = [ '@/views/publicService/productCenter/product-case-list.vue' ), name: 'ProductCaseList', + meta: { showSearch: false } // 不需要搜索框 }, // 公共组件 { @@ -136,6 +139,7 @@ export const constantRoutes = [ component: () => import('@/views/publicService/commonCom/index.vue'), name: 'CommonCom', + meta: { showSearch: true } // 需要搜索框 }, // 宣传物料 { @@ -143,6 +147,7 @@ export const constantRoutes = [ component: () => import('@/views/publicService/proMaterials/index.vue'), name: 'ProMaterials', + meta: { showSearch: true } // 需要搜索框 }, // 文档中心 { @@ -150,6 +155,7 @@ export const constantRoutes = [ component: () => import('@/views/publicService/docCenter/index.vue'), name: 'DocCenter', + meta: { showSearch: true } // 需要搜索框 }, ], }, diff --git a/src/views/publicService/components/navBar.vue b/src/views/publicService/components/navBar.vue index 57386ad..4bf9b83 100644 --- a/src/views/publicService/components/navBar.vue +++ b/src/views/publicService/components/navBar.vue @@ -1,377 +1,397 @@ diff --git a/src/views/publicService/index.vue b/src/views/publicService/index.vue index 7ce815c..842195c 100644 --- a/src/views/publicService/index.vue +++ b/src/views/publicService/index.vue @@ -1,13 +1,17 @@ diff --git a/src/views/publicService/proMaterials/index.vue b/src/views/publicService/proMaterials/index.vue index 6427cbd..7de4bea 100644 --- a/src/views/publicService/proMaterials/index.vue +++ b/src/views/publicService/proMaterials/index.vue @@ -68,7 +68,6 @@
下 载 @@ -77,6 +76,7 @@
+ - - @@ -124,6 +122,12 @@ export default { DialogModel, }, dicts: ['tb_product_type'], + props: { + searchKeyword: { + type: String, + default: '' + } + }, data() { return { downloading: false, // 添加下载状态标识 @@ -189,37 +193,6 @@ export default { }, 300); }, - // 统一的筛选方法 - // updateFilteredList() { - // let filtered = this.proMaterialsListAll; - // - // // 应用分类筛选 - // if (this.activeTypeValue !== 'all') { - // filtered = filtered.filter(item => item.typeId === Number(this.activeTypeValue)); - // } - // - // // 应用类型筛选 - // if (this.selectedTypes.length > 0) { - // filtered = filtered.filter(item => - // this.selectedTypes.includes(item.fileType.toString()) - // ); - // } - // - // this.showProMaterialsDuctList = filtered; - // }, - // 统一的筛选方法 - updateFilteredList() { - this.currentPage = 1; - // 添加防抖 - if (this.requestTimeout) { - clearTimeout(this.requestTimeout); - } - this.requestTimeout = setTimeout(() => { - this.getProductCenterListInScreenFun(); - }, 300); - }, - - // 获取产品卡片宽度 getItemWidth() { this.itemWidth = (this.$refs.servicesGrid?.clientWidth - 120) / 4 @@ -245,7 +218,6 @@ export default { } }, // 下载 - // 下载 async handleDownload(service) { // 防止重复点击 @@ -319,31 +291,32 @@ export default { } this.executeGetProductList(); - }, // 实际执行获取列表的方法 async executeGetProductList() { try { - let fileType = ""; - if (this.selectedTypes.length > 0 && this.selectedTypes.length < 2) { - fileType = this.selectedTypes.join(','); - } - // 根据图片中的参数格式,调整为 list 参数 - const requestParams = { - pageNum: this.currentPage, - pageSize: this.pageSize, - typeId: this.activeTypeValue !== 'all' ? this.activeTypeValue : undefined, - fileType: fileType - }; + let fileType = ""; + if (this.selectedTypes.length > 0 && this.selectedTypes.length < 2) { + fileType = this.selectedTypes.join(','); + } + // 根据图片中的参数格式,调整为 list 参数 + const requestParams = { + pageNum: this.currentPage, + pageSize: this.pageSize, + typeId: this.activeTypeValue !== 'all' ? this.activeTypeValue : undefined, + fileType: fileType, + // 添加搜索关键词参数 + name: this.searchKeyword || undefined + }; - const res = await getMaterialListAPI(requestParams); - this.proMaterialsListAll = res.rows; - this.total = res.total || 0; - this.showProMaterialsDuctList = this.proMaterialsListAll; - } catch (error) { - console.error('获取物料列表失败:', error); - } + const res = await getMaterialListAPI(requestParams); + this.proMaterialsListAll = res.rows; + this.total = res.total || 0; + this.showProMaterialsDuctList = this.proMaterialsListAll; + } catch (error) { + console.error('获取物料列表失败:', error); + } }, // 关闭弹框 @@ -419,9 +392,22 @@ export default { }, 300); }, + // 根据搜索关键词过滤物料列表(前端过滤备用方法) + filterMaterialsByKeyword(materials, keyword) { + if (!keyword) return materials + + const lowerKeyword = keyword.toLowerCase() + return materials.filter(item => + // 在物料名称、描述等字段中搜索 + (item.name && item.name.toLowerCase().includes(lowerKeyword)) || + (item.description && item.description.toLowerCase().includes(lowerKeyword)) || + (item.version && item.version.toLowerCase().includes(lowerKeyword)) || + (item.typeName && item.typeName.toLowerCase().includes(lowerKeyword)) + ) + } }, - // 监听分类变化 + // 监听分类变化和搜索关键词变化 watch: { activeTypeValue() { this.currentPage = 1; @@ -433,6 +419,29 @@ export default { this.getProductCenterListInScreenFun(); }, 300); }, + + // 监听搜索关键词变化 + searchKeyword(newVal) { + this.currentPage = 1; + // 添加防抖 + if (this.requestTimeout) { + clearTimeout(this.requestTimeout); + } + this.requestTimeout = setTimeout(() => { + this.getProductCenterListInScreenFun(); + }, 300); + }, + + selectedTypes() { + this.currentPage = 1; + // 添加防抖 + if (this.requestTimeout) { + clearTimeout(this.requestTimeout); + } + this.requestTimeout = setTimeout(() => { + this.getProductCenterListInScreenFun(); + }, 300); + } }, beforeDestroy() { if (this.requestTimeout) { diff --git a/src/views/publicService/productCenter/index.vue b/src/views/publicService/productCenter/index.vue index 32964b5..f4a4db5 100644 --- a/src/views/publicService/productCenter/index.vue +++ b/src/views/publicService/productCenter/index.vue @@ -1,296 +1,337 @@