26
26
<el-row :gutter =" 10" class =" mb8" >
27
27
<el-col :span =" 1.5" >
28
28
<el-button type =" info" plain icon =" el-icon-upload" size =" mini" @click =" openImportTable"
29
- v-hasPermi =" ['infra:codegen:create']" >基于 DB 导入</el-button >
30
- <el-button type =" info" plain icon =" el-icon-upload" size =" mini" @click =" openImportSQL"
31
- v-hasPermi =" ['infra:codegen:create']" >基于 SQL 导入</el-button >
29
+ v-hasPermi =" ['infra:codegen:create']" >导入</el-button >
32
30
</el-col >
33
31
<right-toolbar :showSearch.sync =" showSearch" @queryTable =" getList" ></right-toolbar >
34
32
</el-row >
35
33
36
34
<!-- 列表 -->
37
35
<el-table v-loading =" loading" :data =" tableList" >
38
- <el-table-column label =" 表名称" align =" center" prop =" tableName" :show-overflow-tooltip =" true" width =" 200" />
36
+ <el-table-column label =" 数据源" align =" center" :formatter =" dataSourceConfigNameFormat" />
37
+ <el-table-column label =" 表名称" align =" center" prop =" tableName" width =" 200" />
39
38
<el-table-column label =" 表描述" align =" center" prop =" tableComment" :show-overflow-tooltip =" true" width =" 120" />
40
- <el-table-column label =" 实体" align =" center" prop =" className" :show-overflow-tooltip = " true " width =" 200" />
41
- <el-table-column label =" 创建时间" align =" center" prop =" createTime" width =" 160 " >
39
+ <el-table-column label =" 实体" align =" center" prop =" className" width =" 200" />
40
+ <el-table-column label =" 创建时间" align =" center" prop =" createTime" width =" 180 " >
42
41
<template slot-scope="scope">
43
42
<span >{{ parseTime(scope.row.createTime) }}</span >
44
43
</template >
45
44
</el-table-column >
46
- <el-table-column label =" 更新时间" align =" center" prop =" createTime" width =" 160 " >
45
+ <el-table-column label =" 更新时间" align =" center" prop =" createTime" width =" 180 " >
47
46
<template slot-scope="scope">
48
47
<span >{{ parseTime(scope.row.updateTime) }}</span >
49
48
</template >
50
49
</el-table-column >
51
- <el-table-column label =" 操作" align =" center" class-name =" small-padding fixed-width" >
50
+ <el-table-column label =" 操作" align =" center" width = " 300px " class-name =" small-padding fixed-width" >
52
51
<template slot-scope="scope">
53
52
<el-button type =" text" size =" small" icon =" el-icon-view" @click =" handlePreview(scope.row)" v-hasPermi =" ['infra:codegen:preview']" >预览</el-button >
54
53
<el-button type =" text" size =" small" icon =" el-icon-edit" @click =" handleEditTable(scope.row)" v-hasPermi =" ['infra:codegen:update']" >编辑</el-button >
81
80
82
81
<!-- 基于 DB 导入 -->
83
82
<import-table ref =" import" @ok =" handleQuery" />
84
-
85
- <!-- 基于 SQL 导入 -->
86
- <el-dialog :title =" importSQL.title" :visible.sync =" importSQL.open" width =" 800px" append-to-body >
87
- <el-form ref =" importSQLForm" :model =" importSQL.form" :rules =" importSQL.rules" label-width =" 120px" >
88
- <el-row >
89
- <el-col :span =" 12" >
90
- <el-form-item label =" 建表 SQL 语句" prop =" sql" >
91
- <el-input v-model =" importSQL.form.sql" type =" textarea" rows =" 30" style =" width : 650px ;" placeholder =" 请输入建 SQL 语句" />
92
- </el-form-item >
93
- </el-col >
94
- </el-row >
95
- </el-form >
96
- <div slot =" footer" class =" dialog-footer" >
97
- <el-button type =" primary" @click =" submitImportSQLForm" >确 定</el-button >
98
- <el-button @click =" cancel" >取 消</el-button >
99
- </div >
100
- </el-dialog >
101
83
</div >
102
84
</template >
103
85
@@ -109,6 +91,7 @@ import importTable from "./importTable";
109
91
// 代码高亮插件
110
92
import hljs from " highlight.js/lib/highlight" ;
111
93
import " highlight.js/styles/github-gist.css" ;
94
+ import {getDataSourceConfigList } from " @/api/infra/dataSourceConfig" ;
112
95
hljs .registerLanguage (" java" , require (" highlight.js/lib/languages/java" ));
113
96
hljs .registerLanguage (" xml" , require (" highlight.js/lib/languages/xml" ));
114
97
hljs .registerLanguage (" html" , require (" highlight.js/lib/languages/xml" ));
@@ -150,21 +133,16 @@ export default {
150
133
data: {},
151
134
activeName: " " ,
152
135
},
153
- // 基于 SQL 导入
154
- importSQL: {
155
- open: false ,
156
- title: " " ,
157
- form: {
158
-
159
- },
160
- rules: {
161
- sql: [{ required: true , message: " SQL 不能为空" , trigger: " blur" }]
162
- }
163
- }
136
+ // 数据源列表
137
+ dataSourceConfigs: [],
164
138
};
165
139
},
166
140
created () {
167
141
this .getList ();
142
+ // 加载数据源
143
+ getDataSourceConfigList ().then (response => {
144
+ this .dataSourceConfigs = response .data ;
145
+ });
168
146
},
169
147
activated () {
170
148
const time = this .$route .query .t ;
@@ -200,12 +178,6 @@ export default {
200
178
},
201
179
/** 同步数据库操作 */
202
180
handleSynchDb (row ) {
203
- // 基于 SQL 同步
204
- if (row .importType === 2 ) {
205
- this .importSQL .open = true ;
206
- this .importSQL .form .tableId = row .id ;
207
- return ;
208
- }
209
181
// 基于 DB 同步
210
182
const tableName = row .tableName ;
211
183
this .$modal .confirm (' 确认要强制同步"' + tableName + ' "表结构吗?' ).then (function () {
@@ -218,10 +190,6 @@ export default {
218
190
openImportTable () {
219
191
this .$refs .import .show ();
220
192
},
221
- /** 打开 SQL 导入的弹窗 **/
222
- openImportSQL () {
223
- this .importSQL .open = true ;
224
- },
225
193
/** 重置按钮操作 */
226
194
resetQuery () {
227
195
this .dateRange = [];
@@ -336,43 +304,15 @@ export default {
336
304
this .$modal .msgSuccess (" 删除成功" );
337
305
}).catch (() => {});
338
306
},
339
- // 取消按钮
340
- cancel () {
341
- this .importSQL .open = false ;
342
- this .reset ();
343
- },
344
- // 表单重置
345
- reset () {
346
- this .importSQL .form = {
347
- tableId: undefined ,
348
- sql: undefined ,
349
- };
350
- this .resetForm (" importSQLForm" );
351
- },
352
- // 提交 import SQL 表单
353
- submitImportSQLForm () {
354
- this .$refs [" importSQLForm" ].validate (valid => {
355
- if (! valid) {
356
- return ;
357
- }
358
- // 修改的提交
359
- let form = this .importSQL .form ;
360
- if (form .tableId != null ) {
361
- syncCodegenFromSQL (form .tableId , form .sql ).then (response => {
362
- this .$modal .msgSuccess (" 同步成功" );
363
- this .importSQL .open = false ;
364
- this .getList ();
365
- });
366
- return ;
307
+ // 数据源配置的名字
308
+ dataSourceConfigNameFormat (row , column ) {
309
+ for (const config of this .dataSourceConfigs ) {
310
+ if (row .dataSourceConfigId === config .id ) {
311
+ return config .name ;
367
312
}
368
- // 添加的提交
369
- createCodegenListFromSQL (form).then (response => {
370
- this .$modal .msgSuccess (" 导入成功" );
371
- this .importSQL .open = false ;
372
- this .getList ();
373
- });
374
- });
375
- }
313
+ }
314
+ return ' 未知【' + row .leaderUserId + ' 】' ;
315
+ },
376
316
}
377
317
};
378
318
</script >
0 commit comments