commit
03c6e0758d
|
@ -125,7 +125,7 @@ const handleMenuClick = (e: any) => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="m-table-action">
|
<div class="m-table-action w-fit">
|
||||||
<Space :size="2">
|
<Space :size="2">
|
||||||
<template v-for="(action, index) in getActions" :key="index">
|
<template v-for="(action, index) in getActions" :key="index">
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
|
|
|
@ -4,6 +4,7 @@ import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||||
import type { CodegenApi } from '#/api/infra/codegen';
|
import type { CodegenApi } from '#/api/infra/codegen';
|
||||||
|
|
||||||
import { getDataSourceConfigList } from '#/api/infra/data-source-config';
|
import { getDataSourceConfigList } from '#/api/infra/data-source-config';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
export namespace CodegenDefaultData {
|
export namespace CodegenDefaultData {
|
||||||
/**
|
/**
|
||||||
|
@ -26,10 +27,11 @@ export namespace CodegenDefaultData {
|
||||||
{ field: 'createTime', title: '创建时间', formatter: 'formatDateTime' },
|
{ field: 'createTime', title: '创建时间', formatter: 'formatDateTime' },
|
||||||
{ field: 'updateTime', title: '更新时间', formatter: 'formatDateTime' },
|
{ field: 'updateTime', title: '更新时间', formatter: 'formatDateTime' },
|
||||||
{
|
{
|
||||||
title: '操作',
|
field: 'action',
|
||||||
width: 'auto',
|
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
|
width: 'auto',
|
||||||
slots: { default: 'action' },
|
slots: { default: 'action' },
|
||||||
|
title: $t('page.action.action'),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -8,13 +8,19 @@ import {
|
||||||
type VxeGridProps,
|
type VxeGridProps,
|
||||||
} from '@vben/plugins/vxe-table';
|
} from '@vben/plugins/vxe-table';
|
||||||
|
|
||||||
import { getSchemaTableList } from '#/api/infra/codegen';
|
import {
|
||||||
|
type CodegenApi,
|
||||||
|
createCodegenList,
|
||||||
|
getSchemaTableList,
|
||||||
|
} from '#/api/infra/codegen';
|
||||||
|
|
||||||
import { CodegenImportTableModalData } from '../codegen.data';
|
import { CodegenImportTableModalData } from '../codegen.data';
|
||||||
|
|
||||||
|
const confirmLoading = ref<boolean>(false);
|
||||||
|
|
||||||
// checked
|
// checked
|
||||||
const checkedStatus = ref<boolean>(false);
|
const checkedStatus = ref<boolean>(false);
|
||||||
|
const checkedRecords = ref<any[]>([]);
|
||||||
/**
|
/**
|
||||||
* 表格查询表单配置
|
* 表格查询表单配置
|
||||||
*/
|
*/
|
||||||
|
@ -55,8 +61,9 @@ const gridOptions = reactive<any>({
|
||||||
|
|
||||||
const gridEvents = reactive<any>({
|
const gridEvents = reactive<any>({
|
||||||
checkboxChange: (params) => {
|
checkboxChange: (params) => {
|
||||||
const { checked } = params;
|
const { checked, $grid } = params;
|
||||||
checkedStatus.value = checked;
|
checkedStatus.value = checked;
|
||||||
|
checkedRecords.value = $grid.getCheckboxRecords();
|
||||||
},
|
},
|
||||||
checkboxAll: (params) => {
|
checkboxAll: (params) => {
|
||||||
const { checked } = params;
|
const { checked } = params;
|
||||||
|
@ -73,11 +80,30 @@ const [Grid, gridApi] = useVbenVxeGrid(
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
const [Modal] = useVbenModal({
|
const [Modal, modalApi] = useVbenModal({
|
||||||
class: 'w-[800px] h-[800px]',
|
class: 'w-[800px] h-[800px]',
|
||||||
|
confirmLoading: confirmLoading.value,
|
||||||
|
closeOnClickModal: false,
|
||||||
|
closeOnPressEscape: false,
|
||||||
onOpened: async () => {
|
onOpened: async () => {
|
||||||
gridApi.reload(await gridApi.formApi.getValues());
|
gridApi.reload(await gridApi.formApi.getValues());
|
||||||
},
|
},
|
||||||
|
onConfirm: async () => {
|
||||||
|
modalApi.setState({ confirmLoading: true });
|
||||||
|
const formValues = await gridApi.formApi.getValues();
|
||||||
|
// 获取选中的数据
|
||||||
|
const checkedRecords =
|
||||||
|
gridApi.grid.getCheckboxRecords() as CodegenApi.DatabaseTableRespVO[];
|
||||||
|
try {
|
||||||
|
await createCodegenList({
|
||||||
|
dataSourceConfigId: formValues.dataSourceConfigId,
|
||||||
|
tableNames: checkedRecords.map((item) => item.name),
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
modalApi.setState({ confirmLoading: false });
|
||||||
|
}
|
||||||
|
modalApi.close();
|
||||||
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -3,24 +3,16 @@ import { defineAsyncComponent, reactive, ref } from 'vue';
|
||||||
|
|
||||||
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui';
|
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui';
|
||||||
|
|
||||||
import { Button } from 'ant-design-vue';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
useVbenVxeGrid,
|
useVbenVxeGrid,
|
||||||
type VxeGridListeners,
|
type VxeGridListeners,
|
||||||
type VxeGridProps,
|
type VxeGridProps,
|
||||||
} from '#/adapter/vxe-table';
|
} from '#/adapter/vxe-table';
|
||||||
import { type CodegenApi, getCodegenTablePage } from '#/api/infra/codegen';
|
import { type CodegenApi, getCodegenTablePage } from '#/api/infra/codegen';
|
||||||
|
import { ActionButtons, IconEnum } from '#/components/action-buttons';
|
||||||
|
|
||||||
import { CodegenDefaultData } from './codegen.data';
|
import { CodegenDefaultData } from './codegen.data';
|
||||||
|
|
||||||
// 使用导入表弹窗组件
|
|
||||||
const [ImportTableModal, importTableModalApi] = useVbenModal({
|
|
||||||
connectedComponent: defineAsyncComponent(
|
|
||||||
() => import('./components/import-table-modal.vue'),
|
|
||||||
),
|
|
||||||
});
|
|
||||||
|
|
||||||
// checked
|
// checked
|
||||||
const checkedStatus = ref<boolean>(false);
|
const checkedStatus = ref<boolean>(false);
|
||||||
|
|
||||||
|
@ -52,14 +44,6 @@ const handleBatchDelete = (_rows: CodegenApi.CodegenTableRespVO[]) => {
|
||||||
// console.log('批量删除', rows);
|
// console.log('批量删除', rows);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* 导入表
|
|
||||||
*/
|
|
||||||
const handleImportTable = () => {
|
|
||||||
// console.log('导入表', importTableModalApi);
|
|
||||||
importTableModalApi.open();
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 同步
|
* 同步
|
||||||
*/
|
*/
|
||||||
|
@ -109,10 +93,9 @@ const formOptions = reactive<any>({
|
||||||
*/
|
*/
|
||||||
const gridOptions = reactive<any>({
|
const gridOptions = reactive<any>({
|
||||||
columns: CodegenDefaultData.tableColumns,
|
columns: CodegenDefaultData.tableColumns,
|
||||||
toolbarConfig: {
|
height: 'auto',
|
||||||
slots: {
|
checkboxConfig: {
|
||||||
buttons: 'toolbar_buttons',
|
reserve: true,
|
||||||
},
|
|
||||||
},
|
},
|
||||||
proxyConfig: {
|
proxyConfig: {
|
||||||
ajax: {
|
ajax: {
|
||||||
|
@ -140,53 +123,99 @@ const gridEvents = reactive<any>({
|
||||||
} as VxeGridListeners);
|
} as VxeGridListeners);
|
||||||
|
|
||||||
// 使用表格组件
|
// 使用表格组件
|
||||||
const [Grid] = useVbenVxeGrid({
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
formOptions,
|
formOptions,
|
||||||
gridOptions,
|
gridOptions,
|
||||||
gridEvents,
|
gridEvents,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 使用导入表弹窗组件
|
||||||
|
const [ImportTableModal, importTableModalApi] = useVbenModal({
|
||||||
|
connectedComponent: defineAsyncComponent(
|
||||||
|
() => import('./components/import-table-modal.vue'),
|
||||||
|
),
|
||||||
|
onClosed: () => {
|
||||||
|
gridApi.reload(formOptions.values);
|
||||||
|
},
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<Grid>
|
<Grid>
|
||||||
<template #toolbar_buttons="{ $grid }">
|
<template #toolbar-actions>
|
||||||
<div class="flex items-center gap-2">
|
<ActionButtons
|
||||||
<Button type="primary" @click="handleImportTable">导入表</Button>
|
:actions="[
|
||||||
<Button
|
{
|
||||||
:disabled="!checkedStatus"
|
type: 'primary',
|
||||||
type="primary"
|
label: '导入表',
|
||||||
@click="handleBatchSync($grid.getCheckboxRecords())"
|
icon: IconEnum.ADD,
|
||||||
>
|
onClick: () => importTableModalApi.open(),
|
||||||
批量同步
|
},
|
||||||
</Button>
|
{
|
||||||
<Button
|
label: '批量同步',
|
||||||
:disabled="!checkedStatus"
|
disabled: !checkedStatus,
|
||||||
type="primary"
|
class: checkedStatus
|
||||||
@click="handleBatchGenerateCode($grid.getCheckboxRecords())"
|
? 'bg-emerald-500 text-white border-emerald-400 hover:bg-emerald-400 hover:!text-white hover:!border-emerald-400 active:!bg-emerald-600 active:!text-white active:!border-emerald-600'
|
||||||
>
|
: '',
|
||||||
批量生成
|
icon: 'ant-design:sync-outlined',
|
||||||
</Button>
|
onClick: handleBatchSync,
|
||||||
<Button
|
},
|
||||||
:disabled="!checkedStatus"
|
{
|
||||||
danger
|
label: '批量生成',
|
||||||
type="primary"
|
disabled: !checkedStatus,
|
||||||
@click="handleBatchDelete($grid.getCheckboxRecords())"
|
class: checkedStatus
|
||||||
>
|
? 'bg-emerald-500 text-white border-emerald-400 hover:bg-emerald-400 hover:!text-white hover:!border-emerald-400 active:!bg-emerald-600 active:!text-white active:!border-emerald-600'
|
||||||
批量删除
|
: '',
|
||||||
</Button>
|
icon: 'ant-design:code-outlined',
|
||||||
</div>
|
onClick: handleBatchGenerateCode,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '批量删除',
|
||||||
|
disabled: !checkedStatus,
|
||||||
|
danger: true,
|
||||||
|
icon: 'ant-design:delete-outlined',
|
||||||
|
onClick: handleBatchDelete,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #action="{ row }">
|
<template #action="{ row }">
|
||||||
<div class="flex w-fit items-center justify-around">
|
<ActionButtons
|
||||||
<Button type="link" @click="handleView(row)">查看</Button>
|
:actions="[
|
||||||
<Button type="link" @click="handleEdit(row)">编辑</Button>
|
{
|
||||||
<Button type="link" @click="handleSync(row)">同步</Button>
|
type: 'link',
|
||||||
<Button type="link" @click="handleGenerateCode(row)">
|
label: '查看',
|
||||||
生成代码
|
icon: 'ant-design:eye-outlined',
|
||||||
</Button>
|
onClick: handleView.bind(null, row),
|
||||||
<Button danger type="link" @click="handleDelete(row)">删除</Button>
|
},
|
||||||
</div>
|
{
|
||||||
|
type: 'link',
|
||||||
|
label: '编辑',
|
||||||
|
icon: 'ant-design:edit-outlined',
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'link',
|
||||||
|
label: '删除',
|
||||||
|
danger: true,
|
||||||
|
icon: 'ant-design:delete-outlined',
|
||||||
|
onClick: handleDelete.bind(null, row),
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
:drop-down-actions="[
|
||||||
|
{
|
||||||
|
label: '同步',
|
||||||
|
icon: 'ant-design:sync-outlined',
|
||||||
|
onClick: handleSync.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '生成代码',
|
||||||
|
icon: 'ant-design:code-outlined',
|
||||||
|
onClick: handleGenerateCode.bind(null, row),
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
</Grid>
|
</Grid>
|
||||||
<ImportTableModal />
|
<ImportTableModal />
|
||||||
|
|
Loading…
Reference in New Issue