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);