|
|
@@ -1,321 +1,321 @@
|
|
1
|
|
-<template>
|
|
2
|
|
- <div class="app-container">
|
|
3
|
|
- <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
|
4
|
|
- <el-form-item label="表名称" prop="tableName">
|
|
5
|
|
- <el-input
|
|
6
|
|
- v-model="queryParams.tableName"
|
|
7
|
|
- placeholder="请输入表名称"
|
|
8
|
|
- clearable
|
|
9
|
|
- size="small"
|
|
10
|
|
- @keyup.enter.native="handleQuery"
|
|
11
|
|
- />
|
|
12
|
|
- </el-form-item>
|
|
13
|
|
- <el-form-item label="表描述" prop="tableComment">
|
|
14
|
|
- <el-input
|
|
15
|
|
- v-model="queryParams.tableComment"
|
|
16
|
|
- placeholder="请输入表描述"
|
|
17
|
|
- clearable
|
|
18
|
|
- size="small"
|
|
19
|
|
- @keyup.enter.native="handleQuery"
|
|
20
|
|
- />
|
|
21
|
|
- </el-form-item>
|
|
22
|
|
- <el-form-item label="创建时间">
|
|
23
|
|
- <el-date-picker
|
|
24
|
|
- v-model="dateRange"
|
|
25
|
|
- size="small"
|
|
26
|
|
- style="width: 240px"
|
|
27
|
|
- value-format="yyyy-MM-dd"
|
|
28
|
|
- type="daterange"
|
|
29
|
|
- range-separator="-"
|
|
30
|
|
- start-placeholder="开始日期"
|
|
31
|
|
- end-placeholder="结束日期"
|
|
32
|
|
- ></el-date-picker>
|
|
33
|
|
- </el-form-item>
|
|
34
|
|
- <el-form-item>
|
|
35
|
|
- <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
36
|
|
- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
37
|
|
- </el-form-item>
|
|
38
|
|
- </el-form>
|
|
39
|
|
-
|
|
40
|
|
- <el-row :gutter="10" class="mb8">
|
|
41
|
|
- <el-col :span="1.5">
|
|
42
|
|
- <el-button
|
|
43
|
|
- type="primary"
|
|
44
|
|
- icon="el-icon-download"
|
|
45
|
|
- size="mini"
|
|
46
|
|
- @click="handleGenTable"
|
|
47
|
|
- v-hasPermi="['tool:gen:code']"
|
|
48
|
|
- >生成</el-button>
|
|
49
|
|
- </el-col>
|
|
50
|
|
- <el-col :span="1.5">
|
|
51
|
|
- <el-button
|
|
52
|
|
- type="info"
|
|
53
|
|
- icon="el-icon-upload"
|
|
54
|
|
- size="mini"
|
|
55
|
|
- @click="openImportTable"
|
|
56
|
|
- v-hasPermi="['tool:gen:import']"
|
|
57
|
|
- >导入</el-button>
|
|
58
|
|
- </el-col>
|
|
59
|
|
- <el-col :span="1.5">
|
|
60
|
|
- <el-button
|
|
61
|
|
- type="success"
|
|
62
|
|
- icon="el-icon-edit"
|
|
63
|
|
- size="mini"
|
|
64
|
|
- :disabled="single"
|
|
65
|
|
- @click="handleEditTable"
|
|
66
|
|
- v-hasPermi="['tool:gen:edit']"
|
|
67
|
|
- >修改</el-button>
|
|
68
|
|
- </el-col>
|
|
69
|
|
- <el-col :span="1.5">
|
|
70
|
|
- <el-button
|
|
71
|
|
- type="danger"
|
|
72
|
|
- icon="el-icon-delete"
|
|
73
|
|
- size="mini"
|
|
74
|
|
- :disabled="multiple"
|
|
75
|
|
- @click="handleDelete"
|
|
76
|
|
- v-hasPermi="['tool:gen:remove']"
|
|
77
|
|
- >删除</el-button>
|
|
78
|
|
- </el-col>
|
|
79
|
|
- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
80
|
|
- </el-row>
|
|
81
|
|
-
|
|
82
|
|
- <el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange">
|
|
83
|
|
- <el-table-column type="selection" width="55"></el-table-column>
|
|
84
|
|
- <el-table-column label="序号" type="index" width="50" align="center">
|
|
85
|
|
- <template slot-scope="scope">
|
|
86
|
|
- <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
|
|
87
|
|
- </template>
|
|
88
|
|
- </el-table-column>
|
|
89
|
|
- <el-table-column
|
|
90
|
|
- label="表名称"
|
|
91
|
|
- align="center"
|
|
92
|
|
- prop="tableName"
|
|
93
|
|
- :show-overflow-tooltip="true"
|
|
94
|
|
- width="120"
|
|
95
|
|
- />
|
|
96
|
|
- <el-table-column
|
|
97
|
|
- label="表描述"
|
|
98
|
|
- align="center"
|
|
99
|
|
- prop="tableComment"
|
|
100
|
|
- :show-overflow-tooltip="true"
|
|
101
|
|
- width="120"
|
|
102
|
|
- />
|
|
103
|
|
- <el-table-column
|
|
104
|
|
- label="实体"
|
|
105
|
|
- align="center"
|
|
106
|
|
- prop="className"
|
|
107
|
|
- :show-overflow-tooltip="true"
|
|
108
|
|
- width="120"
|
|
109
|
|
- />
|
|
110
|
|
- <el-table-column label="创建时间" align="center" prop="createTime" width="160" />
|
|
111
|
|
- <el-table-column label="更新时间" align="center" prop="updateTime" width="160" />
|
|
112
|
|
- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
113
|
|
- <template slot-scope="scope">
|
|
114
|
|
- <el-button
|
|
115
|
|
- type="text"
|
|
116
|
|
- size="small"
|
|
117
|
|
- icon="el-icon-view"
|
|
118
|
|
- @click="handlePreview(scope.row)"
|
|
119
|
|
- v-hasPermi="['tool:gen:preview']"
|
|
120
|
|
- >预览</el-button>
|
|
121
|
|
- <el-button
|
|
122
|
|
- type="text"
|
|
123
|
|
- size="small"
|
|
124
|
|
- icon="el-icon-edit"
|
|
125
|
|
- @click="handleEditTable(scope.row)"
|
|
126
|
|
- v-hasPermi="['tool:gen:edit']"
|
|
127
|
|
- >编辑</el-button>
|
|
128
|
|
- <el-button
|
|
129
|
|
- type="text"
|
|
130
|
|
- size="small"
|
|
131
|
|
- icon="el-icon-delete"
|
|
132
|
|
- @click="handleDelete(scope.row)"
|
|
133
|
|
- v-hasPermi="['tool:gen:remove']"
|
|
134
|
|
- >删除</el-button>
|
|
135
|
|
- <el-button
|
|
136
|
|
- type="text"
|
|
137
|
|
- size="small"
|
|
138
|
|
- icon="el-icon-refresh"
|
|
139
|
|
- @click="handleSynchDb(scope.row)"
|
|
140
|
|
- v-hasPermi="['tool:gen:edit']"
|
|
141
|
|
- >同步</el-button>
|
|
142
|
|
- <el-button
|
|
143
|
|
- type="text"
|
|
144
|
|
- size="small"
|
|
145
|
|
- icon="el-icon-download"
|
|
146
|
|
- @click="handleGenTable(scope.row)"
|
|
147
|
|
- v-hasPermi="['tool:gen:code']"
|
|
148
|
|
- >生成代码</el-button>
|
|
149
|
|
- </template>
|
|
150
|
|
- </el-table-column>
|
|
151
|
|
- </el-table>
|
|
152
|
|
- <pagination
|
|
153
|
|
- v-show="total>0"
|
|
154
|
|
- :total="total"
|
|
155
|
|
- :page.sync="queryParams.pageNum"
|
|
156
|
|
- :limit.sync="queryParams.pageSize"
|
|
157
|
|
- @pagination="getList"
|
|
158
|
|
- />
|
|
159
|
|
- <!-- 预览界面 -->
|
|
160
|
|
- <el-dialog :title="preview.title" :visible.sync="preview.open" width="80%" top="5vh" append-to-body>
|
|
161
|
|
- <el-tabs v-model="preview.activeName">
|
|
162
|
|
- <el-tab-pane
|
|
163
|
|
- v-for="(value, key) in preview.data"
|
|
164
|
|
- :label="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))"
|
|
165
|
|
- :name="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))"
|
|
166
|
|
- :key="key"
|
|
167
|
|
- >
|
|
168
|
|
- <highlightjs autodetect :code="value" />
|
|
169
|
|
- </el-tab-pane>
|
|
170
|
|
- </el-tabs>
|
|
171
|
|
- </el-dialog>
|
|
172
|
|
- <import-table ref="import" @ok="handleQuery" />
|
|
173
|
|
- </div>
|
|
174
|
|
-</template>
|
|
175
|
|
-
|
|
176
|
|
-<script>
|
|
177
|
|
-import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen";
|
|
178
|
|
-import importTable from "./importTable";
|
|
179
|
|
-import { downLoadZip } from "@/utils/zipdownload";
|
|
180
|
|
-
|
|
181
|
|
-export default {
|
|
182
|
|
- name: "Gen",
|
|
183
|
|
- components: { importTable },
|
|
184
|
|
- data() {
|
|
185
|
|
- return {
|
|
186
|
|
- // 遮罩层
|
|
187
|
|
- loading: true,
|
|
188
|
|
- // 唯一标识符
|
|
189
|
|
- uniqueId: "",
|
|
190
|
|
- // 选中数组
|
|
191
|
|
- ids: [],
|
|
192
|
|
- // 选中表数组
|
|
193
|
|
- tableNames: [],
|
|
194
|
|
- // 非单个禁用
|
|
195
|
|
- single: true,
|
|
196
|
|
- // 非多个禁用
|
|
197
|
|
- multiple: true,
|
|
198
|
|
- // 显示搜索条件
|
|
199
|
|
- showSearch: true,
|
|
200
|
|
- // 总条数
|
|
201
|
|
- total: 0,
|
|
202
|
|
- // 表数据
|
|
203
|
|
- tableList: [],
|
|
204
|
|
- // 日期范围
|
|
205
|
|
- dateRange: "",
|
|
206
|
|
- // 查询参数
|
|
207
|
|
- queryParams: {
|
|
208
|
|
- pageNum: 1,
|
|
209
|
|
- pageSize: 10,
|
|
210
|
|
- tableName: undefined,
|
|
211
|
|
- tableComment: undefined
|
|
212
|
|
- },
|
|
213
|
|
- // 预览参数
|
|
214
|
|
- preview: {
|
|
215
|
|
- open: false,
|
|
216
|
|
- title: "代码预览",
|
|
217
|
|
- data: {},
|
|
218
|
|
- activeName: "domain.java"
|
|
219
|
|
- }
|
|
220
|
|
- };
|
|
221
|
|
- },
|
|
222
|
|
- created() {
|
|
223
|
|
- this.getList();
|
|
224
|
|
- },
|
|
225
|
|
- activated() {
|
|
226
|
|
- const time = this.$route.query.t;
|
|
227
|
|
- if (time != null && time != this.uniqueId) {
|
|
228
|
|
- this.uniqueId = time;
|
|
229
|
|
- this.resetQuery();
|
|
230
|
|
- }
|
|
231
|
|
- },
|
|
232
|
|
- methods: {
|
|
233
|
|
- /** 查询表集合 */
|
|
234
|
|
- getList() {
|
|
235
|
|
- this.loading = true;
|
|
236
|
|
- listTable(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
|
|
237
|
|
- this.tableList = response.rows;
|
|
238
|
|
- this.total = response.total;
|
|
239
|
|
- this.loading = false;
|
|
240
|
|
- }
|
|
241
|
|
- );
|
|
242
|
|
- },
|
|
243
|
|
- /** 搜索按钮操作 */
|
|
244
|
|
- handleQuery() {
|
|
245
|
|
- this.queryParams.pageNum = 1;
|
|
246
|
|
- this.getList();
|
|
247
|
|
- },
|
|
248
|
|
- /** 生成代码操作 */
|
|
249
|
|
- handleGenTable(row) {
|
|
250
|
|
- const tableNames = row.tableName || this.tableNames;
|
|
251
|
|
- if (tableNames == "") {
|
|
252
|
|
- this.msgError("请选择要生成的数据");
|
|
253
|
|
- return;
|
|
254
|
|
- }
|
|
255
|
|
- if(row.genType === "1") {
|
|
256
|
|
- genCode(row.tableName).then(response => {
|
|
257
|
|
- this.msgSuccess("成功生成到自定义路径:" + row.genPath);
|
|
258
|
|
- });
|
|
259
|
|
- } else {
|
|
260
|
|
- downLoadZip("/tool/gen/batchGenCode?tables=" + tableNames, "ruoyi");
|
|
261
|
|
- }
|
|
262
|
|
- },
|
|
263
|
|
- /** 同步数据库操作 */
|
|
264
|
|
- handleSynchDb(row) {
|
|
265
|
|
- const tableName = row.tableName;
|
|
266
|
|
- this.$confirm('确认要强制同步"' + tableName + '"表结构吗?', "警告", {
|
|
267
|
|
- confirmButtonText: "确定",
|
|
268
|
|
- cancelButtonText: "取消",
|
|
269
|
|
- type: "warning"
|
|
270
|
|
- }).then(function() {
|
|
271
|
|
- return synchDb(tableName);
|
|
272
|
|
- }).then(() => {
|
|
273
|
|
- this.msgSuccess("同步成功");
|
|
274
|
|
- })
|
|
275
|
|
- },
|
|
276
|
|
- /** 打开导入表弹窗 */
|
|
277
|
|
- openImportTable() {
|
|
278
|
|
- this.$refs.import.show();
|
|
279
|
|
- },
|
|
280
|
|
- /** 重置按钮操作 */
|
|
281
|
|
- resetQuery() {
|
|
282
|
|
- this.dateRange = [];
|
|
283
|
|
- this.resetForm("queryForm");
|
|
284
|
|
- this.handleQuery();
|
|
285
|
|
- },
|
|
286
|
|
- /** 预览按钮 */
|
|
287
|
|
- handlePreview(row) {
|
|
288
|
|
- previewTable(row.tableId).then(response => {
|
|
289
|
|
- this.preview.data = response.data;
|
|
290
|
|
- this.preview.open = true;
|
|
291
|
|
- });
|
|
292
|
|
- },
|
|
293
|
|
- // 多选框选中数据
|
|
294
|
|
- handleSelectionChange(selection) {
|
|
295
|
|
- this.ids = selection.map(item => item.tableId);
|
|
296
|
|
- this.tableNames = selection.map(item => item.tableName);
|
|
297
|
|
- this.single = selection.length != 1;
|
|
298
|
|
- this.multiple = !selection.length;
|
|
299
|
|
- },
|
|
300
|
|
- /** 修改按钮操作 */
|
|
301
|
|
- handleEditTable(row) {
|
|
302
|
|
- const tableId = row.tableId || this.ids[0];
|
|
303
|
|
- this.$router.push("/gen/edit/" + tableId);
|
|
304
|
|
- },
|
|
305
|
|
- /** 删除按钮操作 */
|
|
306
|
|
- handleDelete(row) {
|
|
307
|
|
- const tableIds = row.tableId || this.ids;
|
|
308
|
|
- this.$confirm('是否确认删除表编号为"' + tableIds + '"的数据项?', "警告", {
|
|
309
|
|
- confirmButtonText: "确定",
|
|
310
|
|
- cancelButtonText: "取消",
|
|
311
|
|
- type: "warning"
|
|
312
|
|
- }).then(function() {
|
|
313
|
|
- return delTable(tableIds);
|
|
314
|
|
- }).then(() => {
|
|
315
|
|
- this.getList();
|
|
316
|
|
- this.msgSuccess("删除成功");
|
|
317
|
|
- })
|
|
318
|
|
- }
|
|
319
|
|
- }
|
|
320
|
|
-};
|
|
321
|
|
-</script>
|
|
|
1
|
+<template>
|
|
|
2
|
+ <div class="app-container">
|
|
|
3
|
+ <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
|
|
4
|
+ <el-form-item label="表名称" prop="tableName">
|
|
|
5
|
+ <el-input
|
|
|
6
|
+ v-model="queryParams.tableName"
|
|
|
7
|
+ placeholder="请输入表名称"
|
|
|
8
|
+ clearable
|
|
|
9
|
+ size="small"
|
|
|
10
|
+ @keyup.enter.native="handleQuery"
|
|
|
11
|
+ />
|
|
|
12
|
+ </el-form-item>
|
|
|
13
|
+ <el-form-item label="表描述" prop="tableComment">
|
|
|
14
|
+ <el-input
|
|
|
15
|
+ v-model="queryParams.tableComment"
|
|
|
16
|
+ placeholder="请输入表描述"
|
|
|
17
|
+ clearable
|
|
|
18
|
+ size="small"
|
|
|
19
|
+ @keyup.enter.native="handleQuery"
|
|
|
20
|
+ />
|
|
|
21
|
+ </el-form-item>
|
|
|
22
|
+ <el-form-item label="创建时间">
|
|
|
23
|
+ <el-date-picker
|
|
|
24
|
+ v-model="dateRange"
|
|
|
25
|
+ size="small"
|
|
|
26
|
+ style="width: 240px"
|
|
|
27
|
+ value-format="yyyy-MM-dd"
|
|
|
28
|
+ type="daterange"
|
|
|
29
|
+ range-separator="-"
|
|
|
30
|
+ start-placeholder="开始日期"
|
|
|
31
|
+ end-placeholder="结束日期"
|
|
|
32
|
+ ></el-date-picker>
|
|
|
33
|
+ </el-form-item>
|
|
|
34
|
+ <el-form-item>
|
|
|
35
|
+ <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
|
36
|
+ <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
|
37
|
+ </el-form-item>
|
|
|
38
|
+ </el-form>
|
|
|
39
|
+
|
|
|
40
|
+ <el-row :gutter="10" class="mb8">
|
|
|
41
|
+ <el-col :span="1.5">
|
|
|
42
|
+ <el-button
|
|
|
43
|
+ type="primary"
|
|
|
44
|
+ icon="el-icon-download"
|
|
|
45
|
+ size="mini"
|
|
|
46
|
+ @click="handleGenTable"
|
|
|
47
|
+ v-hasPermi="['tool:gen:code']"
|
|
|
48
|
+ >生成</el-button>
|
|
|
49
|
+ </el-col>
|
|
|
50
|
+ <el-col :span="1.5">
|
|
|
51
|
+ <el-button
|
|
|
52
|
+ type="info"
|
|
|
53
|
+ icon="el-icon-upload"
|
|
|
54
|
+ size="mini"
|
|
|
55
|
+ @click="openImportTable"
|
|
|
56
|
+ v-hasPermi="['tool:gen:import']"
|
|
|
57
|
+ >导入</el-button>
|
|
|
58
|
+ </el-col>
|
|
|
59
|
+ <el-col :span="1.5">
|
|
|
60
|
+ <el-button
|
|
|
61
|
+ type="success"
|
|
|
62
|
+ icon="el-icon-edit"
|
|
|
63
|
+ size="mini"
|
|
|
64
|
+ :disabled="single"
|
|
|
65
|
+ @click="handleEditTable"
|
|
|
66
|
+ v-hasPermi="['tool:gen:edit']"
|
|
|
67
|
+ >修改</el-button>
|
|
|
68
|
+ </el-col>
|
|
|
69
|
+ <el-col :span="1.5">
|
|
|
70
|
+ <el-button
|
|
|
71
|
+ type="danger"
|
|
|
72
|
+ icon="el-icon-delete"
|
|
|
73
|
+ size="mini"
|
|
|
74
|
+ :disabled="multiple"
|
|
|
75
|
+ @click="handleDelete"
|
|
|
76
|
+ v-hasPermi="['tool:gen:remove']"
|
|
|
77
|
+ >删除</el-button>
|
|
|
78
|
+ </el-col>
|
|
|
79
|
+ <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
80
|
+ </el-row>
|
|
|
81
|
+
|
|
|
82
|
+ <el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange">
|
|
|
83
|
+ <el-table-column type="selection" width="55"></el-table-column>
|
|
|
84
|
+ <el-table-column label="序号" type="index" width="50" align="center">
|
|
|
85
|
+ <template slot-scope="scope">
|
|
|
86
|
+ <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
|
|
|
87
|
+ </template>
|
|
|
88
|
+ </el-table-column>
|
|
|
89
|
+ <el-table-column
|
|
|
90
|
+ label="表名称"
|
|
|
91
|
+ align="center"
|
|
|
92
|
+ prop="tableName"
|
|
|
93
|
+ :show-overflow-tooltip="true"
|
|
|
94
|
+ width="120"
|
|
|
95
|
+ />
|
|
|
96
|
+ <el-table-column
|
|
|
97
|
+ label="表描述"
|
|
|
98
|
+ align="center"
|
|
|
99
|
+ prop="tableComment"
|
|
|
100
|
+ :show-overflow-tooltip="true"
|
|
|
101
|
+ width="120"
|
|
|
102
|
+ />
|
|
|
103
|
+ <el-table-column
|
|
|
104
|
+ label="实体"
|
|
|
105
|
+ align="center"
|
|
|
106
|
+ prop="className"
|
|
|
107
|
+ :show-overflow-tooltip="true"
|
|
|
108
|
+ width="120"
|
|
|
109
|
+ />
|
|
|
110
|
+ <el-table-column label="创建时间" align="center" prop="createTime" width="160" />
|
|
|
111
|
+ <el-table-column label="更新时间" align="center" prop="updateTime" width="160" />
|
|
|
112
|
+ <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
113
|
+ <template slot-scope="scope">
|
|
|
114
|
+ <el-button
|
|
|
115
|
+ type="text"
|
|
|
116
|
+ size="small"
|
|
|
117
|
+ icon="el-icon-view"
|
|
|
118
|
+ @click="handlePreview(scope.row)"
|
|
|
119
|
+ v-hasPermi="['tool:gen:preview']"
|
|
|
120
|
+ >预览</el-button>
|
|
|
121
|
+ <el-button
|
|
|
122
|
+ type="text"
|
|
|
123
|
+ size="small"
|
|
|
124
|
+ icon="el-icon-edit"
|
|
|
125
|
+ @click="handleEditTable(scope.row)"
|
|
|
126
|
+ v-hasPermi="['tool:gen:edit']"
|
|
|
127
|
+ >编辑</el-button>
|
|
|
128
|
+ <el-button
|
|
|
129
|
+ type="text"
|
|
|
130
|
+ size="small"
|
|
|
131
|
+ icon="el-icon-delete"
|
|
|
132
|
+ @click="handleDelete(scope.row)"
|
|
|
133
|
+ v-hasPermi="['tool:gen:remove']"
|
|
|
134
|
+ >删除</el-button>
|
|
|
135
|
+ <el-button
|
|
|
136
|
+ type="text"
|
|
|
137
|
+ size="small"
|
|
|
138
|
+ icon="el-icon-refresh"
|
|
|
139
|
+ @click="handleSynchDb(scope.row)"
|
|
|
140
|
+ v-hasPermi="['tool:gen:edit']"
|
|
|
141
|
+ >同步</el-button>
|
|
|
142
|
+ <el-button
|
|
|
143
|
+ type="text"
|
|
|
144
|
+ size="small"
|
|
|
145
|
+ icon="el-icon-download"
|
|
|
146
|
+ @click="handleGenTable(scope.row)"
|
|
|
147
|
+ v-hasPermi="['tool:gen:code']"
|
|
|
148
|
+ >生成代码</el-button>
|
|
|
149
|
+ </template>
|
|
|
150
|
+ </el-table-column>
|
|
|
151
|
+ </el-table>
|
|
|
152
|
+ <pagination
|
|
|
153
|
+ v-show="total>0"
|
|
|
154
|
+ :total="total"
|
|
|
155
|
+ :page.sync="queryParams.pageNum"
|
|
|
156
|
+ :limit.sync="queryParams.pageSize"
|
|
|
157
|
+ @pagination="getList"
|
|
|
158
|
+ />
|
|
|
159
|
+ <!-- 预览界面 -->
|
|
|
160
|
+ <el-dialog :title="preview.title" :visible.sync="preview.open" width="80%" top="5vh" append-to-body>
|
|
|
161
|
+ <el-tabs v-model="preview.activeName">
|
|
|
162
|
+ <el-tab-pane
|
|
|
163
|
+ v-for="(value, key) in preview.data"
|
|
|
164
|
+ :label="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))"
|
|
|
165
|
+ :name="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))"
|
|
|
166
|
+ :key="key"
|
|
|
167
|
+ >
|
|
|
168
|
+ <highlightjs autodetect :code="value" />
|
|
|
169
|
+ </el-tab-pane>
|
|
|
170
|
+ </el-tabs>
|
|
|
171
|
+ </el-dialog>
|
|
|
172
|
+ <import-table ref="import" @ok="handleQuery" />
|
|
|
173
|
+ </div>
|
|
|
174
|
+</template>
|
|
|
175
|
+
|
|
|
176
|
+<script>
|
|
|
177
|
+import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen";
|
|
|
178
|
+import importTable from "./importTable";
|
|
|
179
|
+import { downLoadZip } from "@/utils/zipdownload";
|
|
|
180
|
+
|
|
|
181
|
+export default {
|
|
|
182
|
+ name: "Gen",
|
|
|
183
|
+ components: { importTable },
|
|
|
184
|
+ data() {
|
|
|
185
|
+ return {
|
|
|
186
|
+ // 遮罩层
|
|
|
187
|
+ loading: true,
|
|
|
188
|
+ // 唯一标识符
|
|
|
189
|
+ uniqueId: "",
|
|
|
190
|
+ // 选中数组
|
|
|
191
|
+ ids: [],
|
|
|
192
|
+ // 选中表数组
|
|
|
193
|
+ tableNames: [],
|
|
|
194
|
+ // 非单个禁用
|
|
|
195
|
+ single: true,
|
|
|
196
|
+ // 非多个禁用
|
|
|
197
|
+ multiple: true,
|
|
|
198
|
+ // 显示搜索条件
|
|
|
199
|
+ showSearch: true,
|
|
|
200
|
+ // 总条数
|
|
|
201
|
+ total: 0,
|
|
|
202
|
+ // 表数据
|
|
|
203
|
+ tableList: [],
|
|
|
204
|
+ // 日期范围
|
|
|
205
|
+ dateRange: "",
|
|
|
206
|
+ // 查询参数
|
|
|
207
|
+ queryParams: {
|
|
|
208
|
+ pageNum: 1,
|
|
|
209
|
+ pageSize: 10,
|
|
|
210
|
+ tableName: undefined,
|
|
|
211
|
+ tableComment: undefined
|
|
|
212
|
+ },
|
|
|
213
|
+ // 预览参数
|
|
|
214
|
+ preview: {
|
|
|
215
|
+ open: false,
|
|
|
216
|
+ title: "代码预览",
|
|
|
217
|
+ data: {},
|
|
|
218
|
+ activeName: "domain.java"
|
|
|
219
|
+ }
|
|
|
220
|
+ };
|
|
|
221
|
+ },
|
|
|
222
|
+ created() {
|
|
|
223
|
+ this.getList();
|
|
|
224
|
+ },
|
|
|
225
|
+ activated() {
|
|
|
226
|
+ const time = this.$route.query.t;
|
|
|
227
|
+ if (time != null && time != this.uniqueId) {
|
|
|
228
|
+ this.uniqueId = time;
|
|
|
229
|
+ this.resetQuery();
|
|
|
230
|
+ }
|
|
|
231
|
+ },
|
|
|
232
|
+ methods: {
|
|
|
233
|
+ /** 查询表集合 */
|
|
|
234
|
+ getList() {
|
|
|
235
|
+ this.loading = true;
|
|
|
236
|
+ listTable(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
|
|
|
237
|
+ this.tableList = response.rows;
|
|
|
238
|
+ this.total = response.total;
|
|
|
239
|
+ this.loading = false;
|
|
|
240
|
+ }
|
|
|
241
|
+ );
|
|
|
242
|
+ },
|
|
|
243
|
+ /** 搜索按钮操作 */
|
|
|
244
|
+ handleQuery() {
|
|
|
245
|
+ this.queryParams.pageNum = 1;
|
|
|
246
|
+ this.getList();
|
|
|
247
|
+ },
|
|
|
248
|
+ /** 生成代码操作 */
|
|
|
249
|
+ handleGenTable(row) {
|
|
|
250
|
+ const tableNames = row.tableName || this.tableNames;
|
|
|
251
|
+ if (tableNames == "") {
|
|
|
252
|
+ this.msgError("请选择要生成的数据");
|
|
|
253
|
+ return;
|
|
|
254
|
+ }
|
|
|
255
|
+ if(row.genType === "1") {
|
|
|
256
|
+ genCode(row.tableName).then(response => {
|
|
|
257
|
+ this.msgSuccess("成功生成到自定义路径:" + row.genPath);
|
|
|
258
|
+ });
|
|
|
259
|
+ } else {
|
|
|
260
|
+ downLoadZip("/code/gen/batchGenCode?tables=" + tableNames, "ruoyi");
|
|
|
261
|
+ }
|
|
|
262
|
+ },
|
|
|
263
|
+ /** 同步数据库操作 */
|
|
|
264
|
+ handleSynchDb(row) {
|
|
|
265
|
+ const tableName = row.tableName;
|
|
|
266
|
+ this.$confirm('确认要强制同步"' + tableName + '"表结构吗?', "警告", {
|
|
|
267
|
+ confirmButtonText: "确定",
|
|
|
268
|
+ cancelButtonText: "取消",
|
|
|
269
|
+ type: "warning"
|
|
|
270
|
+ }).then(function() {
|
|
|
271
|
+ return synchDb(tableName);
|
|
|
272
|
+ }).then(() => {
|
|
|
273
|
+ this.msgSuccess("同步成功");
|
|
|
274
|
+ })
|
|
|
275
|
+ },
|
|
|
276
|
+ /** 打开导入表弹窗 */
|
|
|
277
|
+ openImportTable() {
|
|
|
278
|
+ this.$refs.import.show();
|
|
|
279
|
+ },
|
|
|
280
|
+ /** 重置按钮操作 */
|
|
|
281
|
+ resetQuery() {
|
|
|
282
|
+ this.dateRange = [];
|
|
|
283
|
+ this.resetForm("queryForm");
|
|
|
284
|
+ this.handleQuery();
|
|
|
285
|
+ },
|
|
|
286
|
+ /** 预览按钮 */
|
|
|
287
|
+ handlePreview(row) {
|
|
|
288
|
+ previewTable(row.tableId).then(response => {
|
|
|
289
|
+ this.preview.data = response.data;
|
|
|
290
|
+ this.preview.open = true;
|
|
|
291
|
+ });
|
|
|
292
|
+ },
|
|
|
293
|
+ // 多选框选中数据
|
|
|
294
|
+ handleSelectionChange(selection) {
|
|
|
295
|
+ this.ids = selection.map(item => item.tableId);
|
|
|
296
|
+ this.tableNames = selection.map(item => item.tableName);
|
|
|
297
|
+ this.single = selection.length != 1;
|
|
|
298
|
+ this.multiple = !selection.length;
|
|
|
299
|
+ },
|
|
|
300
|
+ /** 修改按钮操作 */
|
|
|
301
|
+ handleEditTable(row) {
|
|
|
302
|
+ const tableId = row.tableId || this.ids[0];
|
|
|
303
|
+ this.$router.push("/gen/edit/" + tableId);
|
|
|
304
|
+ },
|
|
|
305
|
+ /** 删除按钮操作 */
|
|
|
306
|
+ handleDelete(row) {
|
|
|
307
|
+ const tableIds = row.tableId || this.ids;
|
|
|
308
|
+ this.$confirm('是否确认删除表编号为"' + tableIds + '"的数据项?', "警告", {
|
|
|
309
|
+ confirmButtonText: "确定",
|
|
|
310
|
+ cancelButtonText: "取消",
|
|
|
311
|
+ type: "warning"
|
|
|
312
|
+ }).then(function() {
|
|
|
313
|
+ return delTable(tableIds);
|
|
|
314
|
+ }).then(() => {
|
|
|
315
|
+ this.getList();
|
|
|
316
|
+ this.msgSuccess("删除成功");
|
|
|
317
|
+ })
|
|
|
318
|
+ }
|
|
|
319
|
+ }
|
|
|
320
|
+};
|
|
|
321
|
+</script>
|