fix: vue2代码生成模板

This commit is contained in:
xingyu
2022-07-25 16:53:36 +08:00
parent 9983590fdf
commit a57f79cf90
10 changed files with 42 additions and 46 deletions

View File

@ -72,7 +72,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
children: [
{
path: 'edit',
component: () => import('@/views/infra/codegen/EditTable.vue'),
component: () => import('@/views/infra/codegen/components/EditTable.vue'),
name: 'EditTable',
meta: {
noCache: true,

View File

@ -1,9 +1,9 @@
<script setup lang="ts">
import { ref, unref, onMounted } from 'vue'
import { ContentDetailWrap } from '@/components/ContentDetailWrap'
import BasicInfoForm from './components/BasicInfoForm.vue'
import CloumInfoFormVue from './components/CloumInfoForm.vue'
import GenInfoFormVue from './components/GenInfoForm.vue'
import BasicInfoForm from './BasicInfoForm.vue'
import CloumInfoFormVue from './CloumInfoForm.vue'
import GenInfoFormVue from './GenInfoForm.vue'
import { ElTabs, ElTabPane, ElButton } from 'element-plus'
import { getCodegenTableApi } from '@/api/infra/codegen'
import { useRouter, useRoute } from 'vue-router'
@ -38,7 +38,6 @@ const submitForm = async () => {
console.info(basicInfoData)
console.info(genInfoData)
}
console.info(1)
}
onMounted(() => {
getList()

View File

@ -47,6 +47,7 @@ const schema = reactive<FormSchema[]>([
label: '模块名',
field: 'moduleName',
component: 'Input',
labelMessage: '模块名,即一级目录,例如 system、infra、tool 等等',
colProps: {
span: 12
}
@ -55,6 +56,7 @@ const schema = reactive<FormSchema[]>([
label: '业务名',
field: 'businessName',
component: 'Input',
labelMessage: '业务名,即二级目录,例如 user、permission、dict 等等',
colProps: {
span: 12
}
@ -63,6 +65,7 @@ const schema = reactive<FormSchema[]>([
label: '类名称',
field: 'className',
component: 'Input',
labelMessage: '类名称首字母大写例如SysUser、SysMenu、SysDictData 等等',
colProps: {
span: 12
}
@ -71,6 +74,7 @@ const schema = reactive<FormSchema[]>([
label: '类描述',
field: 'classComment',
component: 'Input',
labelMessage: '用作类描述,例如 用户',
colProps: {
span: 12
}
@ -79,6 +83,7 @@ const schema = reactive<FormSchema[]>([
label: '上级菜单',
field: 'parentMenuId',
component: 'Input',
labelMessage: '分配到指定菜单下,例如 系统管理',
colProps: {
span: 12
}

View File

@ -8,17 +8,18 @@ import {
ElForm,
ElFormItem,
ElInput,
ElEmpty
ElSelect,
ElOption
} from 'element-plus'
import { useI18n } from '@/hooks/web/useI18n'
import { useEmitt } from '@/hooks/web/useEmitt'
import { getDataSourceConfigListApi } from '@/api/infra/dataSourceConfig'
import type { DataSourceConfigVO } from '@/api/infra/dataSourceConfig/types'
import type { DatabaseTableVO } from '@/api/infra/codegen/types'
const { t } = useI18n() // 国际化
const { emitter } = useEmitt()
const emit = defineEmits(['ok'])
// ======== 显示页面 ========
const visible = ref(false)
const dbLoading = ref(true)
const queryParams = reactive({
tableName: undefined,
tableComment: undefined,
@ -37,8 +38,10 @@ const dbTableList = ref<DatabaseTableVO[]>([])
/** 查询表数据 */
const getList = async () => {
dbLoading.value = true
const res = await getSchemaTableListApi(queryParams)
dbTableList.value = res
dbLoading.value = false
}
// 查询操作
const handleQuery = async () => {
@ -56,19 +59,18 @@ const handleSelectionChange = (val: DatabaseTableVO[]) => {
tables.value = val.map((item) => item.name)
}
/** 导入按钮操作 */
const handleImportTable = () => {
const handleImportTable = async () => {
if (tables.value.length === 0) {
ElMessage.error('请选择要导入的表')
return
}
createCodegenListApi({
await createCodegenListApi({
dataSourceConfigId: queryParams.dataSourceConfigId,
tableNames: tables.value
}).then((res) => {
ElMessage.success(res.msg)
visible.value = false
emitter.emit('ok')
})
ElMessage.success('导入成功')
visible.value = false
emit('ok')
}
defineExpose({
show
@ -78,7 +80,7 @@ defineExpose({
<!-- 导入表 -->
<Dialog title="导入表" v-model="visible" maxHeight="500px" width="50%">
<el-form :model="queryParams" ref="queryRef" :inline="true">
<!-- <el-form-item label="数据源" prop="dataSourceConfigId">
<el-form-item label="数据源" prop="dataSourceConfigId">
<el-select v-model="queryParams.dataSourceConfigId" placeholder="请选择数据源" clearable>
<el-option
v-for="config in dataSourceConfigs"
@ -87,7 +89,7 @@ defineExpose({
:value="config.id"
/>
</el-select>
</el-form-item> -->
</el-form-item>
<el-form-item label="表名称" prop="tableName">
<el-input v-model="queryParams.tableName" placeholder="请输入表名称" clearable />
</el-form-item>
@ -109,11 +111,9 @@ defineExpose({
ref="table"
:data="dbTableList"
@selection-change="handleSelectionChange"
v-loading="dbLoading"
height="400px"
>
<template #empty>
<el-empty description="加载中" />
</template>
<el-table-column type="selection" width="55" />
<el-table-column prop="name" label="表名称" :show-overflow-tooltip="true" />
<el-table-column prop="comment" label="表描述" :show-overflow-tooltip="true" />

View File

@ -0,0 +1,7 @@
import BasicInfoForm from './BasicInfoForm.vue'
import CloumInfoForm from './CloumInfoForm.vue'
import EditTable from './EditTable.vue'
import GenInfoForm from './GenInfoForm.vue'
import ImportTable from './ImportTable.vue'
import Preview from './Preview.vue'
export { BasicInfoForm, CloumInfoForm, EditTable, GenInfoForm, ImportTable, Preview }

View File

@ -6,8 +6,7 @@ import { useTable } from '@/hooks/web/useTable'
import { CodegenTableVO } from '@/api/infra/codegen/types'
import { allSchemas } from './codegen.data'
import { useI18n } from '@/hooks/web/useI18n'
import ImportTable from './components/ImportTable.vue'
import Preview from './components/Preview.vue'
import { ImportTable, Preview } from './components'
import download from '@/utils/download'
import { useRouter } from 'vue-router'
import { useMessage } from '@/hooks/web/useMessage'