chore: 分类去除根目录
This commit is contained in:
parent
e3188acbc4
commit
5ea280b611
@ -3,7 +3,12 @@ import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { $t } from '@vben/locales';
|
||||
import { cloneDeep, getPopupContainer, listToTree } from '@vben/utils';
|
||||
import {
|
||||
addFullName,
|
||||
cloneDeep,
|
||||
getPopupContainer,
|
||||
listToTree,
|
||||
} from '@vben/utils';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
@ -40,17 +45,11 @@ const [BasicForm, formApi] = useVbenForm({
|
||||
|
||||
async function setupCategorySelect() {
|
||||
const listData = await categoryList();
|
||||
let treeData = listToTree(listData, {
|
||||
const treeData = listToTree(listData, {
|
||||
id: 'categoryId',
|
||||
pid: 'parentId',
|
||||
});
|
||||
treeData = [
|
||||
{
|
||||
categoryName: '根目录',
|
||||
categoryId: 0,
|
||||
children: treeData,
|
||||
},
|
||||
];
|
||||
addFullName(treeData, 'categoryName', ' / ');
|
||||
formApi.updateSchema([
|
||||
{
|
||||
fieldName: 'parentId',
|
||||
@ -59,6 +58,7 @@ async function setupCategorySelect() {
|
||||
treeLine: { showLeafIcon: false },
|
||||
fieldNames: { label: 'categoryName', value: 'categoryId' },
|
||||
treeDefaultExpandAll: true,
|
||||
treeNodeLabelProp: 'fullName',
|
||||
getPopupContainer,
|
||||
},
|
||||
},
|
||||
@ -120,7 +120,11 @@ async function handleCancel() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<BasicModal :close-on-click-modal="false" :title="title">
|
||||
<BasicModal
|
||||
:close-on-click-modal="false"
|
||||
:title="title"
|
||||
class="min-h-[500px]"
|
||||
>
|
||||
<BasicForm />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
@ -51,7 +51,7 @@ export const modalSchema: FormSchemaGetter = () => [
|
||||
fieldName: 'parentId',
|
||||
label: '父级分类',
|
||||
rules: 'required',
|
||||
defaultValue: 0,
|
||||
defaultValue: 100,
|
||||
component: 'TreeSelect',
|
||||
},
|
||||
{
|
||||
|
@ -43,17 +43,10 @@ async function loadTree() {
|
||||
selectCode.value = [];
|
||||
|
||||
const ret = await categoryList();
|
||||
let treeData = listToTree(ret, {
|
||||
const treeData = listToTree(ret, {
|
||||
id: 'categoryId',
|
||||
pid: 'parentId',
|
||||
});
|
||||
treeData = [
|
||||
{
|
||||
categoryName: '根目录',
|
||||
categoryId: 0,
|
||||
children: treeData,
|
||||
},
|
||||
];
|
||||
|
||||
categoryTreeArray.value = treeData;
|
||||
showTreeSkeleton.value = false;
|
||||
|
Loading…
Reference in New Issue
Block a user