显示分类

This commit is contained in:
Cain 2025-03-11 20:31:38 +08:00
parent 811a6a3ad2
commit 864aa95d24
8 changed files with 27 additions and 63 deletions

View File

@ -19,6 +19,7 @@ const local: App.I18n.Schema = {
check: 'Check',
expandColumn: 'Expand Column',
columnSetting: 'Column Setting',
loadFail: 'Load Fail',
config: 'Config',
confirm: 'Confirm',
save: 'Save',

View File

@ -14,6 +14,7 @@ const local: App.I18n.Schema = {
addSuccess: '添加成功',
backToHome: '返回首页',
batchDelete: '批量删除',
loadFail: '加载失败',
cancel: '取消',
close: '关闭',
check: '勾选',

View File

@ -26,15 +26,6 @@ export function fetchAddCategory(data: Api.Category.Model) {
}
// /** edit category */
// export function fetchEditCategory(data: Api.Namespace.Namespace) {
// return request<boolean>({
// url: '/namespace',
// method: 'put',
// data
// });
// }
// /** add category */
export function fetchEditCategory(data: Api.Category.Model) {
return request({
url: '/category',

View File

@ -1372,7 +1372,6 @@ declare namespace Api {
*/
namespace Category {
type CategoryType = '网站' | '文献';
type RowData = Category & {
@ -1394,11 +1393,5 @@ declare namespace Api {
type: string;
parent: string;
}
interface Result {
status: 1,
    message: string,
    data: RowData[]
}
}
}

View File

@ -300,6 +300,7 @@ declare namespace App {
check: string;
expandColumn: string;
columnSetting: string;
loadFail: string;
config: string;
confirm: string;
save: string;

View File

@ -104,7 +104,7 @@ const {
//
const headAdd = () => {
handleAdd(-1);
handleAdd(0);
}
const refresh = () => {
console.log("你点击了刷新按钮")

View File

@ -58,6 +58,7 @@ function updateModel(categoryName: string, categoryType: string, parentId: numbe
}
function createDefaultModel(): Api.Category.Model {
return {
id: 0,
name: '',
type: '',
parent: ''

View File

@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, reactive, ref, watch } from 'vue';
import { computed, reactive, ref, watch, onMounted } from 'vue';
import { useClipboard } from '@vueuse/core';
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
import { $t } from '@/locales';
@ -11,6 +11,7 @@ import {
groupConfigYesOrNoOptions
} from '@/constants/business';
import { fetchAddGroupConfig, fetchEditGroupConfig, fetchGetPartitionTableList } from '@/service/api/group';
import { fetchGetCategoryList } from '@/service/api';
defineOptions({
name: 'GroupOperateDrawer'
@ -194,52 +195,27 @@ async function handleCopy(source: string) {
import { ElCascader } from 'element-plus';
import type { CascaderOption } from 'element-plus';
const options: CascaderOption[] = [
{
value: '1',
label: 'Group 1',
children: [
{
value: '1-1',
label: 'Subgroup 1-1',
children: [
{ value: '1-1-1', label: 'Item 1-1-1' },
{ value: '1-1-2', label: 'Item 1-1-2' }
]
},
{
value: '1-2',
label: 'Subgroup 1-2',
children: [
{ value: '1-2-1', label: 'Item 1-2-1' },
{ value: '1-2-2', label: 'Item 1-2-2' }
]
let options: CascaderOption[] = [];
//
function transformData(data: any[]): CascaderOption[] {
return data.map(item => {
const transformedItem: CascaderOption = {
label: item.categoryName,
value: item.categoryName,
children: item.children ? transformData(item.children) : undefined
};
return transformedItem;
});
}
]
},
{
value: '2',
label: 'Group 2',
children: [
{
value: '2-1',
label: 'Subgroup 2-1',
children: [
{ value: '2-1-1', label: 'Item 2-1-1' },
{ value: '2-1-2', label: 'Item 2-1-2' }
]
},
{
value: '2-2',
label: 'Subgroup 2-2',
children: [
{ value: '2-2-1', label: 'Item 2-2-1' },
{ value: '2-2-2', label: 'Item 2-2-2' }
]
onMounted(async () => {
try {
const { data } = await fetchGetCategoryList();
options = transformData(data);
} catch (error) {
window.$message?.error($t('common.loadFail'));
}
]
}
];
});
</script>
<template>