chore: 更新分类逻辑
This commit is contained in:
parent
0c7a8f1eb0
commit
b9edb5d493
@ -3,7 +3,7 @@ import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { $t } from '@vben/locales';
|
||||
import { cloneDeep, listToTree } from '@vben/utils';
|
||||
import { cloneDeep, getPopupContainer, listToTree } from '@vben/utils';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
@ -59,6 +59,7 @@ async function setupCategorySelect() {
|
||||
treeLine: { showLeafIcon: false },
|
||||
fieldNames: { label: 'categoryName', value: 'id' },
|
||||
treeDefaultExpandAll: true,
|
||||
getPopupContainer,
|
||||
},
|
||||
},
|
||||
]);
|
||||
@ -74,13 +75,19 @@ const [BasicModal, modalApi] = useVbenModal({
|
||||
}
|
||||
modalApi.modalLoading(true);
|
||||
|
||||
const { id } = modalApi.getData() as { id?: number | string };
|
||||
const { id, parentId } = modalApi.getData() as {
|
||||
id?: number | string;
|
||||
parentId?: number | string;
|
||||
};
|
||||
isUpdate.value = !!id;
|
||||
|
||||
if (isUpdate.value && id) {
|
||||
const record = await categoryInfo(id);
|
||||
await formApi.setValues(record);
|
||||
}
|
||||
if (parentId) {
|
||||
await formApi.setValues({ parentId });
|
||||
}
|
||||
await setupCategorySelect();
|
||||
|
||||
modalApi.modalLoading(false);
|
||||
|
@ -33,7 +33,7 @@ export const columns: VxeGridProps['columns'] = [
|
||||
fixed: 'right',
|
||||
slots: { default: 'action' },
|
||||
title: '操作',
|
||||
width: 180,
|
||||
width: 200,
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -70,8 +70,8 @@ const [CategoryModal, modalApi] = useVbenModal({
|
||||
connectedComponent: categoryModal,
|
||||
});
|
||||
|
||||
function handleAdd() {
|
||||
modalApi.setData({});
|
||||
function handleAdd(row?: Recordable<any>) {
|
||||
modalApi.setData({ parentId: row?.id });
|
||||
modalApi.open();
|
||||
}
|
||||
|
||||
@ -122,6 +122,12 @@ function collapseAll() {
|
||||
>
|
||||
{{ $t('pages.common.edit') }}
|
||||
</ghost-button>
|
||||
<ghost-button
|
||||
v-access:code="['workflow:category:edit']"
|
||||
@click.stop="handleAdd(row)"
|
||||
>
|
||||
{{ $t('pages.common.add') }}
|
||||
</ghost-button>
|
||||
<Popconfirm
|
||||
:get-popup-container="getPopupContainer"
|
||||
placement="left"
|
||||
|
Loading…
Reference in New Issue
Block a user