From c8a3bb0b7cd0f9b5212ec66a77821bc29ec96a48 Mon Sep 17 00:00:00 2001 From: WUSIJIAN <13825895+wsj0228@user.noreply.gitee.com> Date: Tue, 16 Dec 2025 10:42:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=88=86=E7=B1=BB=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E5=8A=9F=E8=83=BD,=E6=94=AF=E6=8C=81=E5=85=B3?= =?UTF-8?q?=E9=94=AE=E8=AF=8D=E6=9F=A5=E8=AF=A2=E5=B9=B6=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=AD=97=E6=AE=B5=E6=98=BE=E7=A4=BA=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/assets/category/index.ts | 9 +++++++ .../category/component/editCategory.vue | 4 +-- src/views/assets/category/index.vue | 27 +++++++++++++++++-- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/api/assets/category/index.ts b/src/api/assets/category/index.ts index a309d87..f9f491b 100644 --- a/src/api/assets/category/index.ts +++ b/src/api/assets/category/index.ts @@ -29,6 +29,15 @@ export function addCategory(data: object) { }); } +// 查询获取列表 +export function listCategories(keyword: string) { + return newService({ + url: '/assets/category/listCategories', + method: 'get', + params: {keyword}, + }); +} + // 修改分类 export function updateCategory(data: object) { return newService({ diff --git a/src/views/assets/category/component/editCategory.vue b/src/views/assets/category/component/editCategory.vue index 81bfbe8..552b395 100644 --- a/src/views/assets/category/component/editCategory.vue +++ b/src/views/assets/category/component/editCategory.vue @@ -19,7 +19,7 @@ - +
diff --git a/src/views/assets/category/index.vue b/src/views/assets/category/index.vue index 73058e5..e0a605e 100644 --- a/src/views/assets/category/index.vue +++ b/src/views/assets/category/index.vue @@ -7,7 +7,7 @@ - + 查询 @@ -67,7 +67,7 @@ export default { import { ref, reactive, onMounted } from 'vue'; import { ElMessageBox, ElMessage } from 'element-plus'; import EditCategory from './component/editCategory.vue'; -import { getCategoryTree, deleteCategory, updateCategoryStatus } from '/@/api/assets/category'; +import { getCategoryTree, deleteCategory, updateCategoryStatus,listCategories } from '/@/api/assets/category'; interface CategoryRow { id: string; @@ -108,6 +108,29 @@ const getCategoryList = () => { }); }; +// 查询功能 +const AlistCategories = () => { + const keyword = tableData.param.name?.trim(); + // 如果没有输入关键词,则获取完整树形结构 + if (!keyword) { + getCategoryList(); + return; + } + // 有关键词时进行搜索 + tableData.loading = true; + listCategories(keyword) + .then((res: any) => { + // 搜索结果直接展示为列表 + tableData.data = res.data?.list ?? res.data ?? []; + }) + .catch(() => { + tableData.data = []; + ElMessage.error('查询失败'); + }) + .finally(() => { + tableData.loading = false; + }); +} // 打开新增弹窗 const onOpenAddCategory = (row?: CategoryRow) => { editCategoryRef.value.openDialog(row?.id);