Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b1e74a1d
authored
Mar 29, 2023
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
REVIEW 代码生成(ImportTable)
parent
d5f3f0ad
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
65 deletions
+73
-65
src/views/infra/codegen/ImportTable.vue
+67
-58
src/views/infra/codegen/PreviewCode.vue
+0
-0
src/views/infra/codegen/components/index.ts
+1
-3
src/views/infra/codegen/index.vue
+5
-4
No files found.
src/views/infra/codegen/
components/
ImportTable.vue
→
src/views/infra/codegen/ImportTable.vue
View file @
b1e74a1d
<
template
>
<
template
>
<Dialog
:title=
"modelTitle"
v-model=
"modelVisible"
>
<Dialog
title=
"导入表"
v-model=
"modelVisible"
width=
"800px"
>
<el-form
:model=
"queryParams"
ref=
"queryFormRef"
:inline=
"true"
>
<!-- 搜索栏 -->
<el-form
:model=
"queryParams"
ref=
"queryFormRef"
:inline=
"true"
label-width=
"68px"
>
<el-form-item
label=
"数据源"
prop=
"dataSourceConfigId"
>
<el-form-item
label=
"数据源"
prop=
"dataSourceConfigId"
>
<el-select
v-model=
"queryParams.dataSourceConfigId"
placeholder=
"请选择数据源"
>
<el-select
v-model=
"queryParams.dataSourceConfigId"
placeholder=
"请选择数据源"
class=
"!w-240px"
>
<el-option
<el-option
v-for=
"config in dataSourceConfig
s
"
v-for=
"config in dataSourceConfig
List
"
:key=
"config.id"
:key=
"config.id"
:label=
"config.name"
:label=
"config.name"
:value=
"config.id"
:value=
"config.id"
...
@@ -16,7 +21,8 @@
...
@@ -16,7 +21,8 @@
v-model=
"queryParams.name"
v-model=
"queryParams.name"
placeholder=
"请输入表名称"
placeholder=
"请输入表名称"
clearable
clearable
@
keyup
.
enter=
"handleQuery"
@
keyup
.
enter=
"getList"
class=
"!w-240px"
/>
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"表描述"
prop=
"comment"
>
<el-form-item
label=
"表描述"
prop=
"comment"
>
...
@@ -24,19 +30,20 @@
...
@@ -24,19 +30,20 @@
v-model=
"queryParams.comment"
v-model=
"queryParams.comment"
placeholder=
"请输入表描述"
placeholder=
"请输入表描述"
clearable
clearable
@
keyup
.
enter=
"handleQuery"
@
keyup
.
enter=
"getList"
class=
"!w-240px"
/>
/>
</el-form-item>
</el-form-item>
<el-form-item>
<el-form-item>
<el-button
@
click=
"
handleQuery
"
><Icon
icon=
"ep:search"
class=
"mr-5px"
/>
搜索
</el-button>
<el-button
@
click=
"
getList
"
><Icon
icon=
"ep:search"
class=
"mr-5px"
/>
搜索
</el-button>
<el-button
@
click=
"resetQuery"
><Icon
icon=
"ep:refresh"
class=
"mr-5px"
/>
重置
</el-button>
<el-button
@
click=
"resetQuery"
><Icon
icon=
"ep:refresh"
class=
"mr-5px"
/>
重置
</el-button>
</el-form-item>
</el-form-item>
</el-form>
</el-form>
<!-- 列表 -->
<el-row>
<el-row>
<el-table
<el-table
v-loading=
"dbLoading"
v-loading=
"db
Table
Loading"
@
row-click=
"
clickRow
"
@
row-click=
"
handleRowClick
"
ref=
"tableRef"
ref=
"tableRef"
:data=
"dbTableList"
:data=
"dbTableList"
@
selection-change=
"handleSelectionChange"
@
selection-change=
"handleSelectionChange"
...
@@ -47,87 +54,89 @@
...
@@ -47,87 +54,89 @@
<el-table-column
prop=
"comment"
label=
"表描述"
:show-overflow-tooltip=
"true"
/>
<el-table-column
prop=
"comment"
label=
"表描述"
:show-overflow-tooltip=
"true"
/>
</el-table>
</el-table>
</el-row>
</el-row>
<!-- 操作 -->
<template
#
footer
>
<template
#
footer
>
<div
class=
"dialog-footer"
>
<el-button
@
click=
"handleImportTable"
type=
"primary"
:disabled=
"tableList.length === 0"
>
<el-button
@
click=
"handleImportTable"
type=
"primary"
:disabled=
"tables.length === 0"
>
{{
导入
t
(
'action.import'
)
</el-button>
}}
</el-button>
<el-button
@
click=
"close"
>
关闭
</el-button>
<el-button
@
click=
"handleClose"
>
{{
t
(
'dialog.close'
)
}}
</el-button>
</div>
</
template
>
</
template
>
</Dialog>
</Dialog>
</template>
</template>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
type
{
DatabaseTableVO
}
from
'@/api/infra/codegen/types'
import
*
as
CodegenApi
from
'@/api/infra/codegen'
import
*
as
CodegenApi
from
'@/api/infra/codegen'
import
{
getDataSourceConfigList
,
DataSourceConfigVO
}
from
'@/api/infra/dataSourceConfig'
import
*
as
DataSourceConfigApi
from
'@/api/infra/dataSourceConfig'
import
{
ElTable
}
from
'element-plus'
import
{
ElTable
}
from
'element-plus'
const
{
t
}
=
useI18n
()
// 国际化
const
message
=
useMessage
()
// 消息弹窗
const
message
=
useMessage
()
// 消息弹窗
const
emit
=
defineEmits
([
'ok'
])
const
modelVisible
=
ref
(
false
)
// 弹窗的是否展示
const
modelVisible
=
ref
(
false
)
// 弹窗的是否展示
const
modelTitle
=
ref
(
'导入表'
)
// 弹窗的标题
const
dbTableLoading
=
ref
(
true
)
// 数据源的加载中
const
db
Loading
=
ref
(
true
)
const
db
TableList
=
ref
<
CodegenApi
.
DatabaseTableVO
[]
>
([])
// 表的列表
const
queryParams
=
reactive
({
const
queryParams
=
reactive
({
name
:
undefined
,
name
:
undefined
,
comment
:
undefined
,
comment
:
undefined
,
dataSourceConfigId
:
0
dataSourceConfigId
:
0
})
})
const
dataSourceConfigs
=
ref
<
DataSourceConfigVO
[]
>
([])
const
queryFormRef
=
ref
()
// 搜索的表单
const
show
=
async
()
=>
{
const
dataSourceConfigList
=
ref
<
DataSourceConfigApi
.
DataSourceConfigVO
[]
>
([])
// 数据源列表
dataSourceConfigs
.
value
=
await
getDataSourceConfigList
()
queryParams
.
dataSourceConfigId
=
dataSourceConfigs
.
value
[
0
].
id
as
number
modelVisible
.
value
=
true
await
getList
()
}
/** 查询表数据 */
const
dbTableList
=
ref
<
DatabaseTableVO
[]
>
([])
/** 查询表数据 */
/** 查询表数据 */
const
getList
=
async
()
=>
{
const
getList
=
async
()
=>
{
dbLoading
.
value
=
true
dbTableLoading
.
value
=
true
dbTableList
.
value
=
await
CodegenApi
.
getSchemaTableList
(
queryParams
)
try
{
dbLoading
.
value
=
false
dbTableList
.
value
=
await
CodegenApi
.
getSchemaTableList
(
queryParams
)
}
finally
{
dbTableLoading
.
value
=
false
}
}
}
// 查询操作
const
handleQuery
=
async
()
=>
{
/** 重置操作 */
await
getList
()
}
// 重置操作
const
resetQuery
=
async
()
=>
{
const
resetQuery
=
async
()
=>
{
queryParams
.
name
=
undefined
queryParams
.
name
=
undefined
queryParams
.
comment
=
undefined
queryParams
.
comment
=
undefined
queryParams
.
dataSourceConfigId
=
dataSourceConfig
s
.
value
[
0
].
id
as
number
queryParams
.
dataSourceConfigId
=
dataSourceConfig
List
.
value
[
0
].
id
as
number
await
getList
()
await
getList
()
}
}
const
tableRef
=
ref
<
typeof
ElTable
>
()
/** 多选框选中数据 */
/** 打开弹窗 */
const
tables
=
ref
<
string
[]
>
([])
const
open
=
async
()
=>
{
const
clickRow
=
(
row
)
=>
{
// 加载数据源的列表
dataSourceConfigList
.
value
=
await
DataSourceConfigApi
.
getDataSourceConfigList
()
queryParams
.
dataSourceConfigId
=
dataSourceConfigList
.
value
[
0
].
id
as
number
modelVisible
.
value
=
true
// 加载表的列表
await
getList
()
}
defineExpose
({
open
})
// 提供 open 方法,用于打开弹窗
/** 关闭弹窗 */
const
close
=
()
=>
{
modelVisible
.
value
=
false
tableList
.
value
=
[]
}
const
tableRef
=
ref
<
typeof
ElTable
>
()
// 表格的 Ref
const
tableList
=
ref
<
string
[]
>
([])
// 选中的表名
/** 处理某一行的点击 */
const
handleRowClick
=
(
row
)
=>
{
unref
(
tableRef
)?.
toggleRowSelection
(
row
)
unref
(
tableRef
)?.
toggleRowSelection
(
row
)
}
}
// 多选框选中数据
/** 多选框选中数据 */
const
handleSelectionChange
=
(
selection
)
=>
{
const
handleSelectionChange
=
(
selection
)
=>
{
table
s
.
value
=
selection
.
map
((
item
)
=>
item
.
name
)
table
List
.
value
=
selection
.
map
((
item
)
=>
item
.
name
)
}
}
/** 导入按钮操作 */
/** 导入按钮操作 */
const
handleImportTable
=
async
()
=>
{
const
handleImportTable
=
async
()
=>
{
await
CodegenApi
.
createCodegenList
({
await
CodegenApi
.
createCodegenList
({
dataSourceConfigId
:
queryParams
.
dataSourceConfigId
,
dataSourceConfigId
:
queryParams
.
dataSourceConfigId
,
tableNames
:
table
s
.
value
tableNames
:
table
List
.
value
})
})
message
.
success
(
'导入成功'
)
message
.
success
(
'导入成功'
)
emit
(
'
ok
'
)
emit
(
'
success
'
)
handleC
lose
()
c
lose
()
}
}
const
handleClose
=
()
=>
{
const
emit
=
defineEmits
([
'success'
])
modelVisible
.
value
=
false
tables
.
value
=
[]
}
defineExpose
({
show
})
</
script
>
</
script
>
src/views/infra/codegen/
components/Preview
.vue
→
src/views/infra/codegen/
PreviewCode
.vue
View file @
b1e74a1d
File moved
src/views/infra/codegen/components/index.ts
View file @
b1e74a1d
import
BasicInfoForm
from
'./BasicInfoForm.vue'
import
BasicInfoForm
from
'./BasicInfoForm.vue'
import
ColumInfoForm
from
'./ColumInfoForm.vue'
import
ColumInfoForm
from
'./ColumInfoForm.vue'
import
GenerateInfoForm
from
'./GenerateInfoForm.vue'
import
GenerateInfoForm
from
'./GenerateInfoForm.vue'
import
ImportTable
from
'./ImportTable.vue'
export
{
BasicInfoForm
,
ColumInfoForm
,
GenerateInfoForm
}
import
Preview
from
'./Preview.vue'
export
{
BasicInfoForm
,
ColumInfoForm
,
GenerateInfoForm
,
ImportTable
,
Preview
}
src/views/infra/codegen/index.vue
View file @
b1e74a1d
...
@@ -135,16 +135,17 @@
...
@@ -135,16 +135,17 @@
</content-wrap>
</content-wrap>
<!-- 弹窗:导入表 -->
<!-- 弹窗:导入表 -->
<ImportTable
ref=
"importRef"
@
ok
=
"getList"
/>
<ImportTable
ref=
"importRef"
success
=
"getList"
/>
<!-- 弹窗:预览代码 -->
<!-- 弹窗:预览代码 -->
<Preview
ref=
"previewRef"
/>
<Preview
Code
ref=
"previewRef"
/>
</template>
</template>
<
script
setup
lang=
"ts"
name=
"Codegen"
>
<
script
setup
lang=
"ts"
name=
"Codegen"
>
import
{
dateFormatter
}
from
'@/utils/formatTime'
import
{
dateFormatter
}
from
'@/utils/formatTime'
import
download
from
'@/utils/download'
import
download
from
'@/utils/download'
import
*
as
CodegenApi
from
'@/api/infra/codegen'
import
*
as
CodegenApi
from
'@/api/infra/codegen'
import
*
as
DataSourceConfigApi
from
'@/api/infra/dataSourceConfig'
import
*
as
DataSourceConfigApi
from
'@/api/infra/dataSourceConfig'
import
{
ImportTable
,
Preview
}
from
'./components'
import
ImportTable
from
'./ImportTable.vue'
import
PreviewCode
from
'./PreviewCode.vue'
const
message
=
useMessage
()
// 消息弹窗
const
message
=
useMessage
()
// 消息弹窗
const
{
t
}
=
useI18n
()
// 国际化
const
{
t
}
=
useI18n
()
// 国际化
const
{
push
}
=
useRouter
()
// 路由跳转
const
{
push
}
=
useRouter
()
// 路由跳转
...
@@ -189,7 +190,7 @@ const resetQuery = () => {
...
@@ -189,7 +190,7 @@ const resetQuery = () => {
// 导入操作
// 导入操作
const
importRef
=
ref
()
const
importRef
=
ref
()
const
openImportTable
=
()
=>
{
const
openImportTable
=
()
=>
{
importRef
.
value
.
show
()
importRef
.
value
.
open
()
}
}
/** 编辑操作 */
/** 编辑操作 */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment