feat: codegen
parent
26dd8eefc9
commit
a7d04683b2
|
@ -2,6 +2,7 @@ export default {
|
||||||
more: 'more',
|
more: 'more',
|
||||||
create: 'Create',
|
create: 'Create',
|
||||||
edit: 'Edit',
|
edit: 'Edit',
|
||||||
|
view: 'View',
|
||||||
test: 'Test',
|
test: 'Test',
|
||||||
delete: 'Delete',
|
delete: 'Delete',
|
||||||
detail: 'Detail',
|
detail: 'Detail',
|
||||||
|
|
|
@ -2,6 +2,7 @@ export default {
|
||||||
more: '更多',
|
more: '更多',
|
||||||
create: '新增',
|
create: '新增',
|
||||||
edit: '修改',
|
edit: '修改',
|
||||||
|
view: '查看',
|
||||||
test: '测试',
|
test: '测试',
|
||||||
delete: '删除',
|
delete: '删除',
|
||||||
detail: '详情',
|
detail: '详情',
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
<template>
|
||||||
|
<BasicModal v-bind="$attrs" :width="800" @register="registerModal" title="导入" @ok="handleSubmit">
|
||||||
|
<BasicTable @register="registerTable" />
|
||||||
|
</BasicModal>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup name="ImportTableModal">
|
||||||
|
import { BasicModal, useModalInner } from '@/components/Modal'
|
||||||
|
import { BasicTable, useTable } from '@/components/Table'
|
||||||
|
import { importTableColumns, importTableSearchFormSchema } from './codegen.data'
|
||||||
|
import { createCodegenList, getSchemaTableList } from '@/api/infra/codegen'
|
||||||
|
|
||||||
|
const emit = defineEmits(['success', 'register'])
|
||||||
|
|
||||||
|
const [registerTable, { getSelectRowKeys }] = useTable({
|
||||||
|
api: getSchemaTableList,
|
||||||
|
columns: importTableColumns,
|
||||||
|
formConfig: {
|
||||||
|
labelWidth: 80,
|
||||||
|
schemas: importTableSearchFormSchema
|
||||||
|
},
|
||||||
|
rowSelection: { type: 'checkbox' },
|
||||||
|
rowKey: 'name',
|
||||||
|
useSearchForm: true,
|
||||||
|
pagination: false,
|
||||||
|
showTableSetting: false,
|
||||||
|
showIndexColumn: false
|
||||||
|
})
|
||||||
|
|
||||||
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async () => {
|
||||||
|
setModalProps({ confirmLoading: false })
|
||||||
|
})
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
const datas = await getSelectRowKeys()
|
||||||
|
console.info(datas)
|
||||||
|
await createCodegenList({ dataSourceConfigId: 0, tableNames: datas })
|
||||||
|
closeModal()
|
||||||
|
emit('success')
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -3,7 +3,7 @@
|
||||||
<BasicForm @register="registerForm" />
|
<BasicForm @register="registerForm" />
|
||||||
</BasicModal>
|
</BasicModal>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup name="CodegenModal">
|
<script lang="ts" setup name="ImportTable">
|
||||||
import { ref, computed, unref } from 'vue'
|
import { ref, computed, unref } from 'vue'
|
||||||
import { BasicModal, useModalInner } from '@/components/Modal'
|
import { BasicModal, useModalInner } from '@/components/Modal'
|
||||||
import { BasicForm, useForm } from '@/components/Form'
|
import { BasicForm, useForm } from '@/components/Form'
|
|
@ -112,3 +112,43 @@ export const formSchema: FormSchema[] = [
|
||||||
component: 'InputTextArea'
|
component: 'InputTextArea'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
export const importTableColumns: BasicColumn[] = [
|
||||||
|
{
|
||||||
|
title: '表名称',
|
||||||
|
dataIndex: 'name',
|
||||||
|
width: 200
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '表描述',
|
||||||
|
dataIndex: 'comment',
|
||||||
|
width: 120
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
export const importTableSearchFormSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '数据源',
|
||||||
|
field: 'dataSourceConfigId',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
defaultValue: 0,
|
||||||
|
componentProps: {
|
||||||
|
api: () => getDataSourceConfigList(),
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id'
|
||||||
|
},
|
||||||
|
colProps: { span: 8 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '表名称',
|
||||||
|
field: 'name',
|
||||||
|
component: 'Input',
|
||||||
|
colProps: { span: 8 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '表描述',
|
||||||
|
field: 'comment',
|
||||||
|
component: 'Input',
|
||||||
|
colProps: { span: 8 }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
|
@ -2,13 +2,16 @@
|
||||||
<div>
|
<div>
|
||||||
<BasicTable @register="registerTable">
|
<BasicTable @register="registerTable">
|
||||||
<template #toolbar>
|
<template #toolbar>
|
||||||
<a-button type="primary" :preIcon="IconEnum.IMPORT" @click="handleCreate"> {{ t('action.import') }} </a-button>
|
<a-button type="primary" :preIcon="IconEnum.IMPORT" @click="openImportTable"> {{ t('action.import') }} </a-button>
|
||||||
</template>
|
</template>
|
||||||
<template #bodyCell="{ column, record }">
|
<template #bodyCell="{ column, record }">
|
||||||
<template v-if="column.key === 'action'">
|
<template v-if="column.key === 'action'">
|
||||||
<TableAction
|
<TableAction
|
||||||
:actions="[
|
:actions="[
|
||||||
|
{ icon: IconEnum.EDIT, label: t('action.view'), onClick: handleEdit.bind(null, record) },
|
||||||
{ icon: IconEnum.EDIT, label: t('action.edit'), onClick: handleEdit.bind(null, record) },
|
{ icon: IconEnum.EDIT, label: t('action.edit'), onClick: handleEdit.bind(null, record) },
|
||||||
|
{ icon: IconEnum.EDIT, label: '同步', onClick: handleEdit.bind(null, record) },
|
||||||
|
{ icon: IconEnum.EDIT, label: '生成代码', onClick: handleEdit.bind(null, record) },
|
||||||
{
|
{
|
||||||
icon: IconEnum.DELETE,
|
icon: IconEnum.DELETE,
|
||||||
color: 'error',
|
color: 'error',
|
||||||
|
@ -24,14 +27,14 @@
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</BasicTable>
|
</BasicTable>
|
||||||
<CodegenModal @register="registerModal" @success="reload()" />
|
<ImportTableModal @register="registerModal" @success="reload()" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup name="Codegen">
|
<script lang="ts" setup name="Codegen">
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
import { useMessage } from '@/hooks/web/useMessage'
|
import { useMessage } from '@/hooks/web/useMessage'
|
||||||
import { useModal } from '@/components/Modal'
|
import { useModal } from '@/components/Modal'
|
||||||
import CodegenModal from './CodegenModal.vue'
|
import ImportTableModal from './ImportTableModal.vue'
|
||||||
import { IconEnum } from '@/enums/appEnum'
|
import { IconEnum } from '@/enums/appEnum'
|
||||||
import { BasicTable, useTable, TableAction } from '@/components/Table'
|
import { BasicTable, useTable, TableAction } from '@/components/Table'
|
||||||
import { deleteCodegenTable, getCodegenTablePage } from '@/api/infra/codegen'
|
import { deleteCodegenTable, getCodegenTablePage } from '@/api/infra/codegen'
|
||||||
|
@ -53,17 +56,15 @@ const [registerTable, { reload }] = useTable({
|
||||||
showTableSetting: true,
|
showTableSetting: true,
|
||||||
showIndexColumn: false,
|
showIndexColumn: false,
|
||||||
actionColumn: {
|
actionColumn: {
|
||||||
width: 140,
|
width: 360,
|
||||||
title: t('common.action'),
|
title: t('common.action'),
|
||||||
dataIndex: 'action',
|
dataIndex: 'action',
|
||||||
fixed: 'right'
|
fixed: 'right'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleCreate() {
|
function openImportTable() {
|
||||||
openModal(true, {
|
openModal(true)
|
||||||
isUpdate: false
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleEdit(record: Recordable) {
|
function handleEdit(record: Recordable) {
|
||||||
|
|
Loading…
Reference in New Issue