feat:【antd】【crm】产品分类的代码优化

This commit is contained in:
YunaiV
2025-09-28 09:51:07 +08:00
parent 968552ec4b
commit 43c3169c54
68 changed files with 91 additions and 91 deletions

View File

@@ -57,6 +57,10 @@ export function useGridFormSchema(): VbenFormSchema[] {
fieldName: 'name',
label: '分类名称',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入分类名称',
},
},
];
}

View File

@@ -23,8 +23,15 @@ const [FormModal, formModalApi] = useVbenModal({
destroyOnClose: true,
});
/** 切换树形展开/收缩状态 */
const isExpanded = ref(false);
function handleExpand() {
isExpanded.value = !isExpanded.value;
gridApi.grid.setAllTreeExpand(isExpanded.value);
}
/** 刷新表格 */
function onRefresh() {
function handleRefresh() {
gridApi.query();
}
@@ -51,22 +58,13 @@ async function handleDelete(row: CrmProductCategoryApi.ProductCategory) {
});
try {
await deleteProductCategory(row.id as number);
message.success({
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
});
onRefresh();
message.success($t('ui.actionMessage.deleteSuccess', [row.name]));
handleRefresh();
} finally {
hideLoading();
}
}
/** 切换树形展开/收缩状态 */
const isExpanded = ref(false);
function toggleExpand() {
isExpanded.value = !isExpanded.value;
gridApi.grid.setAllTreeExpand(isExpanded.value);
}
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
@@ -87,14 +85,17 @@ const [Grid, gridApi] = useVbenVxeGrid({
},
rowConfig: {
keyField: 'id',
isHover: true,
},
toolbarConfig: {
refresh: true,
search: true,
},
treeConfig: {
parentField: 'parentId',
rowField: 'id',
transform: true,
expandAll: true,
reserve: true,
},
} as VxeTableGridOptions<CrmProductCategoryApi.ProductCategory>,
@@ -110,7 +111,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
/>
</template>
<FormModal @success="onRefresh" />
<FormModal @success="handleRefresh" />
<Grid>
<template #toolbar-tools>
<TableAction
@@ -125,16 +126,11 @@ const [Grid, gridApi] = useVbenVxeGrid({
{
label: isExpanded ? '收缩' : '展开',
type: 'primary',
onClick: toggleExpand,
onClick: handleExpand,
},
]"
/>
</template>
<template #name="{ row }">
<div class="flex w-full items-center gap-1">
<span class="flex-auto">{{ row.name }}</span>
</div>
</template>
<template #actions="{ row }">
<TableAction
:actions="[