提交 | 用户 | 时间
|
759b1c
|
1 |
<template> |
H |
2 |
<!-- 导入表 --> |
|
3 |
<el-dialog title="导入表" :visible.sync="visible" width="800px" top="5vh" append-to-body> |
|
4 |
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true"> |
|
5 |
<el-form-item label="数据源" prop="dataSourceConfigId"> |
|
6 |
<el-select v-model="queryParams.dataSourceConfigId" placeholder="请选择数据源" clearable> |
|
7 |
<el-option v-for="config in dataSourceConfigs" |
|
8 |
:key="config.id" :label="config.name" :value="config.id"/> |
|
9 |
</el-select> |
|
10 |
</el-form-item> |
|
11 |
<el-form-item label="表名称" prop="name"> |
|
12 |
<el-input v-model="queryParams.name" placeholder="请输入表名称" clearable @keyup.enter.native="handleQuery" /> |
|
13 |
</el-form-item> |
|
14 |
<el-form-item label="表描述" prop="comment"> |
|
15 |
<el-input v-model="queryParams.comment" placeholder="请输入表描述" clearable @keyup.enter.native="handleQuery"/> |
|
16 |
</el-form-item> |
|
17 |
<el-form-item> |
|
18 |
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> |
|
19 |
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> |
|
20 |
</el-form-item> |
|
21 |
</el-form> |
|
22 |
<el-row> |
|
23 |
<el-table v-loading="loading" @row-click="clickRow" ref="table" :data="dbTableList" |
|
24 |
@selection-change="handleSelectionChange" height="260px"> |
|
25 |
<el-table-column type="selection" width="55" /> |
|
26 |
<el-table-column prop="name" label="表名称" :show-overflow-tooltip="true" /> |
|
27 |
<el-table-column prop="comment" label="表描述" :show-overflow-tooltip="true" /> |
|
28 |
</el-table> |
|
29 |
</el-row> |
|
30 |
<div slot="footer" class="dialog-footer"> |
|
31 |
<el-button type="primary" @click="handleImportTable">确 定</el-button> |
|
32 |
<el-button @click="visible = false">取 消</el-button> |
|
33 |
</div> |
|
34 |
</el-dialog> |
|
35 |
</template> |
|
36 |
|
|
37 |
<script> |
|
38 |
import { getSchemaTableList, createCodegenList } from "@/api/infra/codegen"; |
|
39 |
import {getDataSourceConfigList} from "@/api/infra/dataSourceConfig"; |
|
40 |
export default { |
|
41 |
data() { |
|
42 |
return { |
|
43 |
// 遮罩层 |
|
44 |
loading: false, |
|
45 |
// 遮罩层 |
|
46 |
visible: false, |
|
47 |
// 选中数组值 |
|
48 |
tables: [], |
|
49 |
// 总条数 |
|
50 |
total: 0, |
|
51 |
// 表数据 |
|
52 |
dbTableList: [], |
|
53 |
// 查询参数 |
|
54 |
queryParams: { |
|
55 |
dataSourceConfigId: undefined, |
|
56 |
name: undefined, |
|
57 |
comment: undefined, |
|
58 |
}, |
|
59 |
// 数据源列表 |
|
60 |
dataSourceConfigs: [], |
|
61 |
}; |
|
62 |
}, |
|
63 |
methods: { |
|
64 |
// 显示弹框 |
|
65 |
show() { |
|
66 |
this.visible = true; |
|
67 |
// 加载数据源 |
|
68 |
getDataSourceConfigList().then(response => { |
|
69 |
this.dataSourceConfigs = response.data; |
|
70 |
this.queryParams.dataSourceConfigId = this.dataSourceConfigs[0].id; |
|
71 |
// 加载表列表 |
|
72 |
this.getList(); |
|
73 |
}); |
|
74 |
}, |
|
75 |
clickRow(row) { |
|
76 |
this.$refs.table.toggleRowSelection(row); |
|
77 |
}, |
|
78 |
// 多选框选中数据 |
|
79 |
handleSelectionChange(selection) { |
|
80 |
this.tables = selection.map(item => item.name); |
|
81 |
}, |
|
82 |
// 查询表数据 |
|
83 |
getList() { |
|
84 |
this.loading = true; |
|
85 |
getSchemaTableList(this.queryParams).then(res => { |
|
86 |
this.dbTableList = res.data; |
|
87 |
}).finally(() => { |
|
88 |
this.loading = false; |
|
89 |
}); |
|
90 |
}, |
|
91 |
/** 搜索按钮操作 */ |
|
92 |
handleQuery() { |
|
93 |
this.getList(); |
|
94 |
}, |
|
95 |
/** 重置按钮操作 */ |
|
96 |
resetQuery() { |
|
97 |
this.resetForm("queryForm"); |
|
98 |
this.queryParams.dataSourceConfigId = this.dataSourceConfigs[0].id; |
|
99 |
this.handleQuery(); |
|
100 |
}, |
|
101 |
/** 导入按钮操作 */ |
|
102 |
handleImportTable() { |
|
103 |
createCodegenList({ |
|
104 |
dataSourceConfigId: this.queryParams.dataSourceConfigId, |
|
105 |
tableNames: this.tables |
|
106 |
}).then(res => { |
|
107 |
this.$modal.msgSuccess("导入成功"); |
|
108 |
this.visible = false; |
|
109 |
this.$emit("ok"); |
|
110 |
}); |
|
111 |
} |
|
112 |
} |
|
113 |
}; |
|
114 |
</script> |