chore: categoryId

This commit is contained in:
dap 2024-12-16 15:59:27 +08:00
parent ac8e1b672f
commit d7d3186ef0
4 changed files with 17 additions and 14 deletions

View File

@ -41,13 +41,13 @@ const [BasicForm, formApi] = useVbenForm({
async function setupCategorySelect() { async function setupCategorySelect() {
const listData = await categoryList(); const listData = await categoryList();
let treeData = listToTree(listData, { let treeData = listToTree(listData, {
id: 'id', id: 'categoryId',
pid: 'parentId', pid: 'parentId',
}); });
treeData = [ treeData = [
{ {
categoryName: '根目录', categoryName: '根目录',
id: 0, categoryId: 0,
children: treeData, children: treeData,
}, },
]; ];
@ -57,7 +57,7 @@ async function setupCategorySelect() {
componentProps: { componentProps: {
treeData, treeData,
treeLine: { showLeafIcon: false }, treeLine: { showLeafIcon: false },
fieldNames: { label: 'categoryName', value: 'id' }, fieldNames: { label: 'categoryName', value: 'categoryId' },
treeDefaultExpandAll: true, treeDefaultExpandAll: true,
getPopupContainer, getPopupContainer,
}, },

View File

@ -56,11 +56,11 @@ const gridOptions: VxeGridProps = {
gt: 0, gt: 0,
}, },
rowConfig: { rowConfig: {
keyField: 'id', keyField: 'categoryId',
}, },
treeConfig: { treeConfig: {
parentField: 'parentId', parentField: 'parentId',
rowField: 'id', rowField: 'categoryId',
transform: true, transform: true,
}, },
// //
@ -73,17 +73,17 @@ const [CategoryModal, modalApi] = useVbenModal({
}); });
function handleAdd(row?: Recordable<any>) { function handleAdd(row?: Recordable<any>) {
modalApi.setData({ parentId: row?.id }); modalApi.setData({ parentId: row?.categoryId });
modalApi.open(); modalApi.open();
} }
async function handleEdit(row: Recordable<any>) { async function handleEdit(row: Recordable<any>) {
modalApi.setData({ id: row.id }); modalApi.setData({ id: row.categoryId });
modalApi.open(); modalApi.open();
} }
async function handleDelete(row: Recordable<any>) { async function handleDelete(row: Recordable<any>) {
await categoryRemove(row.id); await categoryRemove(row.categoryId);
await tableApi.query(); await tableApi.query();
} }

View File

@ -44,13 +44,13 @@ async function loadTree() {
const ret = await categoryList(); const ret = await categoryList();
let treeData = listToTree(ret, { let treeData = listToTree(ret, {
id: 'id', id: 'categoryId',
pid: 'parentId', pid: 'parentId',
}); });
treeData = [ treeData = [
{ {
categoryName: '根目录', categoryName: '根目录',
id: 0, categoryId: 0,
children: treeData, children: treeData,
}, },
]; ];
@ -98,7 +98,7 @@ onMounted(loadTree);
v-if="categoryTreeArray.length > 0" v-if="categoryTreeArray.length > 0"
v-model:selected-keys="selectCode" v-model:selected-keys="selectCode"
:class="$attrs.class" :class="$attrs.class"
:field-names="{ title: 'categoryName', key: 'id' }" :field-names="{ title: 'categoryName', key: 'categoryId' }"
:show-line="{ showLeafIcon: false }" :show-line="{ showLeafIcon: false }"
:tree-data="categoryTreeArray" :tree-data="categoryTreeArray"
:virtual="false" :virtual="false"

View File

@ -43,10 +43,13 @@ const [BasicForm, formApi] = useVbenForm({
async function setupCategorySelect() { async function setupCategorySelect() {
// menu // menu
const resp = await categoryList(); const resp = await categoryList();
const tree = listToTree(resp); const tree = listToTree(resp, {
id: 'categoryId',
pid: 'parentId',
});
const fullMenuTree = [ const fullMenuTree = [
{ {
id: 0, categoryId: 0,
categoryName: $t('menu.root'), categoryName: $t('menu.root'),
children: tree, children: tree,
}, },
@ -58,7 +61,7 @@ async function setupCategorySelect() {
componentProps: { componentProps: {
fieldNames: { fieldNames: {
label: 'categoryName', label: 'categoryName',
value: 'id', value: 'categoryId',
}, },
getPopupContainer, getPopupContainer,
// 256 // 256