diff --git a/apps/web-antd/src/views/infra/codegen/data.ts b/apps/web-antd/src/views/infra/codegen/data.ts
index 6b76521b4..cc91a1488 100644
--- a/apps/web-antd/src/views/infra/codegen/data.ts
+++ b/apps/web-antd/src/views/infra/codegen/data.ts
@@ -366,8 +366,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '表名称',
component: 'Input',
componentProps: {
- allowClear: true,
placeholder: '请输入表名称',
+ allowClear: true,
},
},
{
@@ -375,8 +375,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '表描述',
component: 'Input',
componentProps: {
- allowClear: true,
placeholder: '请输入表描述',
+ allowClear: true,
},
},
{
@@ -400,28 +400,34 @@ export function useGridColumns(
{
field: 'dataSourceConfigId',
title: '数据源',
+ minWidth: 120,
formatter: ({ cellValue }) => getDataSourceConfigName?.(cellValue) || '-',
},
{
field: 'tableName',
title: '表名称',
+ minWidth: 200,
},
{
field: 'tableComment',
title: '表描述',
+ minWidth: 200,
},
{
field: 'className',
title: '实体',
+ minWidth: 200,
},
{
field: 'createTime',
title: '创建时间',
+ minWidth: 180,
formatter: 'formatDateTime',
},
{
field: 'updateTime',
title: '更新时间',
+ minWidth: 180,
formatter: 'formatDateTime',
},
{
diff --git a/apps/web-antd/src/views/infra/codegen/index.vue b/apps/web-antd/src/views/infra/codegen/index.vue
index 214957bce..e7e3f4f27 100644
--- a/apps/web-antd/src/views/infra/codegen/index.vue
+++ b/apps/web-antd/src/views/infra/codegen/index.vue
@@ -6,7 +6,7 @@ import type { InfraDataSourceConfigApi } from '#/api/infra/data-source-config';
import { ref } from 'vue';
import { useRouter } from 'vue-router';
-import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
+import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
import { isEmpty } from '@vben/utils';
import { message } from 'ant-design-vue';
@@ -49,7 +49,7 @@ const [PreviewModal, previewModalApi] = useVbenModal({
});
/** 刷新表格 */
-function onRefresh() {
+function handleRefresh() {
gridApi.query();
}
@@ -77,7 +77,24 @@ async function handleDelete(row: InfraCodegenApi.CodegenTable) {
try {
await deleteCodegenTable(row.id);
message.success($t('ui.actionMessage.deleteSuccess', [row.tableName]));
- onRefresh();
+ handleRefresh();
+ } finally {
+ hideLoading();
+ }
+}
+
+/** 批量删除代码生成配置 */
+async function handleDeleteBatch() {
+ await confirm($t('ui.actionMessage.deleteBatchConfirm'));
+ const hideLoading = message.loading({
+ content: $t('ui.actionMessage.deletingBatch'),
+ duration: 0,
+ });
+ try {
+ await deleteCodegenTableList(checkedIds.value);
+ checkedIds.value = [];
+ message.success($t('ui.actionMessage.deleteSuccess'));
+ handleRefresh();
} finally {
hideLoading();
}
@@ -92,22 +109,6 @@ function handleRowCheckboxChange({
checkedIds.value = records.map((item) => item.id!);
}
-/** 批量删除代码生成配置 */
-async function handleDeleteBatch() {
- const hideLoading = message.loading({
- content: $t('ui.actionMessage.deleting'),
- duration: 0,
- });
- try {
- await deleteCodegenTableList(checkedIds.value);
- checkedIds.value = [];
- message.success($t('ui.actionMessage.deleteSuccess'));
- onRefresh();
- } finally {
- hideLoading();
- }
-}
-
/** 同步数据库 */
async function handleSync(row: InfraCodegenApi.CodegenTable) {
const hideLoading = message.loading({
@@ -117,7 +118,7 @@ async function handleSync(row: InfraCodegenApi.CodegenTable) {
try {
await syncCodegenFromDB(row.id);
message.success($t('ui.actionMessage.updateSuccess', [row.tableName]));
- onRefresh();
+ handleRefresh();
} finally {
hideLoading();
}
@@ -209,7 +210,7 @@ initDataSourceConfig();
-
+
@@ -223,11 +224,11 @@ initDataSourceConfig();
onClick: handleImport,
},
{
- label: '批量删除',
+ label: $t('ui.actionTitle.deleteBatch'),
type: 'primary',
danger: true,
- disabled: isEmpty(checkedIds),
icon: ACTION_ICON.DELETE,
+ disabled: isEmpty(checkedIds),
auth: ['infra:codegen:delete'],
onClick: handleDeleteBatch,
},
diff --git a/apps/web-ele/src/views/infra/codegen/data.ts b/apps/web-ele/src/views/infra/codegen/data.ts
index 0d63656ca..9039c9db7 100644
--- a/apps/web-ele/src/views/infra/codegen/data.ts
+++ b/apps/web-ele/src/views/infra/codegen/data.ts
@@ -1,13 +1,12 @@
import type { Recordable } from '@vben/types';
import type { VbenFormSchema } from '#/adapter/form';
-import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { InfraCodegenApi } from '#/api/infra/codegen';
import type { SystemMenuApi } from '#/api/system/menu';
import { h } from 'vue';
-import { useAccess } from '@vben/access';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { IconifyIcon } from '@vben/icons';
@@ -18,8 +17,6 @@ import { getMenuList } from '#/api/system/menu';
import { $t } from '#/locales';
import { getRangePickerDefaultProps } from '#/utils';
-const { hasAccessByCodes } = useAccess();
-
/** 导入数据库表的表单 */
export function useImportTableFormSchema(): VbenFormSchema[] {
return [
@@ -45,8 +42,8 @@ export function useImportTableFormSchema(): VbenFormSchema[] {
label: '表名称',
component: 'Input',
componentProps: {
- clearable: true,
placeholder: '请输入表名称',
+ clearable: true,
},
},
{
@@ -54,8 +51,8 @@ export function useImportTableFormSchema(): VbenFormSchema[] {
label: '表描述',
component: 'Input',
componentProps: {
- clearable: true,
placeholder: '请输入表描述',
+ clearable: true,
},
},
];
@@ -369,8 +366,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '表名称',
component: 'Input',
componentProps: {
- clearable: true,
placeholder: '请输入表名称',
+ clearable: true,
},
},
{
@@ -378,8 +375,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '表描述',
component: 'Input',
componentProps: {
- clearable: true,
placeholder: '请输入表描述',
+ clearable: true,
},
},
{
@@ -395,8 +392,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
}
/** 列表的字段 */
-export function useGridColumns(
- onActionClick: OnActionClickFn,
+export function useGridColumns(
getDataSourceConfigName?: (dataSourceConfigId: number) => string | undefined,
): VxeTableGridOptions['columns'] {
return [
@@ -405,7 +401,7 @@ export function useGridColumns(
field: 'dataSourceConfigId',
title: '数据源',
minWidth: 120,
- formatter: (row) => getDataSourceConfigName?.(row.cellValue) || '-',
+ formatter: ({ cellValue }) => getDataSourceConfigName?.(cellValue) || '-',
},
{
field: 'tableName',
@@ -435,44 +431,10 @@ export function useGridColumns(
formatter: 'formatDateTime',
},
{
- field: 'operation',
title: '操作',
- width: 300,
+ width: 280,
fixed: 'right',
- align: 'center',
- cellRender: {
- attrs: {
- nameField: 'tableName',
- nameTitle: '代码生成',
- onClick: onActionClick,
- },
- name: 'CellOperation',
- options: [
- {
- code: 'preview',
- text: '预览',
- show: hasAccessByCodes(['infra:codegen:preview']),
- },
- {
- code: 'edit',
- show: hasAccessByCodes(['infra:codegen:update']),
- },
- {
- code: 'delete',
- show: hasAccessByCodes(['infra:codegen:delete']),
- },
- {
- code: 'sync',
- text: '同步',
- show: hasAccessByCodes(['infra:codegen:update']),
- },
- {
- code: 'generate',
- text: '生成代码',
- show: hasAccessByCodes(['infra:codegen:download']),
- },
- ],
- },
+ slots: { default: 'actions' },
},
];
}
diff --git a/apps/web-ele/src/views/infra/codegen/index.vue b/apps/web-ele/src/views/infra/codegen/index.vue
index d786d5c9c..659cd5d97 100644
--- a/apps/web-ele/src/views/infra/codegen/index.vue
+++ b/apps/web-ele/src/views/infra/codegen/index.vue
@@ -1,8 +1,5 @@