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