feat: codegen
parent
26dd8eefc9
commit
a7d04683b2
|
@ -2,6 +2,7 @@ export default {
|
|||
more: 'more',
|
||||
create: 'Create',
|
||||
edit: 'Edit',
|
||||
view: 'View',
|
||||
test: 'Test',
|
||||
delete: 'Delete',
|
||||
detail: 'Detail',
|
||||
|
|
|
@ -2,6 +2,7 @@ export default {
|
|||
more: '更多',
|
||||
create: '新增',
|
||||
edit: '修改',
|
||||
view: '查看',
|
||||
test: '测试',
|
||||
delete: '删除',
|
||||
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" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
<script lang="ts" setup name="CodegenModal">
|
||||
<script lang="ts" setup name="ImportTable">
|
||||
import { ref, computed, unref } from 'vue'
|
||||
import { BasicModal, useModalInner } from '@/components/Modal'
|
||||
import { BasicForm, useForm } from '@/components/Form'
|
|
@ -112,3 +112,43 @@ export const formSchema: FormSchema[] = [
|
|||
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>
|
||||
<BasicTable @register="registerTable">
|
||||
<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 #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'action'">
|
||||
<TableAction
|
||||
: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: '同步', onClick: handleEdit.bind(null, record) },
|
||||
{ icon: IconEnum.EDIT, label: '生成代码', onClick: handleEdit.bind(null, record) },
|
||||
{
|
||||
icon: IconEnum.DELETE,
|
||||
color: 'error',
|
||||
|
@ -24,14 +27,14 @@
|
|||
</template>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<CodegenModal @register="registerModal" @success="reload()" />
|
||||
<ImportTableModal @register="registerModal" @success="reload()" />
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup name="Codegen">
|
||||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
import { useMessage } from '@/hooks/web/useMessage'
|
||||
import { useModal } from '@/components/Modal'
|
||||
import CodegenModal from './CodegenModal.vue'
|
||||
import ImportTableModal from './ImportTableModal.vue'
|
||||
import { IconEnum } from '@/enums/appEnum'
|
||||
import { BasicTable, useTable, TableAction } from '@/components/Table'
|
||||
import { deleteCodegenTable, getCodegenTablePage } from '@/api/infra/codegen'
|
||||
|
@ -53,17 +56,15 @@ const [registerTable, { reload }] = useTable({
|
|||
showTableSetting: true,
|
||||
showIndexColumn: false,
|
||||
actionColumn: {
|
||||
width: 140,
|
||||
width: 360,
|
||||
title: t('common.action'),
|
||||
dataIndex: 'action',
|
||||
fixed: 'right'
|
||||
}
|
||||
})
|
||||
|
||||
function handleCreate() {
|
||||
openModal(true, {
|
||||
isUpdate: false
|
||||
})
|
||||
function openImportTable() {
|
||||
openModal(true)
|
||||
}
|
||||
|
||||
function handleEdit(record: Recordable) {
|
||||
|
|
Loading…
Reference in New Issue