Blame view

src/main/resources/templates/tool/gen/gen.html 6.17 KB
tangying authored
1
2
3
4
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="gray-bg">
mahuandong authored
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<div class="container-div">
	<div class="row">
		<div class="col-sm-12 select-info">
			<form id="gen-form">
				<div class="select-list">
					<ul>
						<li>
							表名称:<input type="text" name="tableName"/>
						</li>
						<li>
							表描述:<input type="text" name="tableComment"/>
						</li>
						<li class="time">
							<label>表时间: </label>
							<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
							<span>-</span>
							<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
						</li>
						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>

		<div class="btn-group-sm" id="toolbar" role="group">
			<a class="btn btn-success multiple disabled" onclick="javascript:batchGenCode()" shiro:hasPermission="tool:gen:code">
				<i class="fa fa-download"></i> 生成
			</a>
			<a class="btn btn-info" onclick="importTable()">
				<i class="fa fa-upload"></i> 导入
			</a>
			<a class="btn btn-primary single disabled" onclick="edit()" shiro:hasPermission="tool:gen:edit">
				<i class="fa fa-edit"></i> 修改
			</a>
			<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="tool:gen:remove">
				<i class="fa fa-remove"></i> 删除
			</a>
		</div>

		<div class="col-sm-12 select-info">
			<table id="bootstrap-table"></table>
tangying authored
49
50
		</div>
	</div>
mahuandong authored
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
	var prefix = ctx + "tool/gen";
	var editFlag = [[${@permission.hasPermi('tool:gen:edit')}]];
	var removeFlag = [[${@permission.hasPermi('tool:gen:remove')}]];
	var previewFlag = [[${@permission.hasPermi('tool:gen:preview')}]];
	var codeFlag = [[${@permission.hasPermi('tool:gen:code')}]];

	$(function() {
		var options = {
			url: prefix + "/list",
			updateUrl: prefix + "/edit/{id}",
			removeUrl: prefix + "/remove",
			sortName: "create_time",
			sortOrder: "desc",
			showExport: true,
			modalName: "生成配置",
			rememberSelected: true,
			uniqueId: "tableId",
			columns: [{
				field: 'state',
				checkbox: true
			},
				{
					field: 'tableId',
					title: '编号',
					visible: false
				},
				{
					title: "序号",
					formatter: function (value, row, index) {
						return $.table.serialNumber(index);
					}
				},
				{
					field: 'tableName',
					title: '表名称',
					sortable: true,
					formatter: function(value, row, index) {
						return $.table.tooltip(value);
					}
				},
				{
					field: 'tableComment',
					title: '表描述',
					sortable: true,
					formatter: function(value, row, index) {
						return $.table.tooltip(value, 15);
					}
				},
				{
					field: 'className',
					title: '实体类名称',
					sortable: true
				},
				{
					field: 'createTime',
					title: '创建时间',
					sortable: true
				},
				{
					field: 'updateTime',
					title: '更新时间',
					sortable: true
				},
				{
					title: '操作',
					align: 'center',
					formatter: function(value, row, index) {
						var actions = [];
						actions.push('<a class="btn btn-info btn-xs ' + previewFlag + '" href="javascript:void(0)" onclick="preview(\'' + row.tableId + '\')"><i class="fa fa-search"></i>预览</a> ');
yihao.liu authored
123
						actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.tableId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
mahuandong authored
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
						actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.tableId + '\')"><i class="fa fa-remove"></i>删除</a> ');
						actions.push('<a class="btn btn-primary btn-xs ' + codeFlag + '" href="javascript:void(0)" onclick="genCode(\'' + row.tableName + '\')"><i class="fa fa-bug"></i>生成代码</a> ');
						return actions.join('');
					}
				}]
		};
		$.table.init(options);
	});

	// 预览代码
	function preview(tableId) {
		var preViewUrl = prefix + "/preview/" + tableId;
		$.modal.loading("正在加载数据,请稍后...");
		$.get(preViewUrl, function(result) {
			if (result.code == web_status.SUCCESS) {
				var items = [];
				$.each(result.data, function(index, value) {
					value = value.replace(/</g, "&lt;");
					value = value.replace(/>/g, "&gt;");
					var templateName = index.substring(index.lastIndexOf("/") + 1, index.length).replace(/\.vm/g, "");
					if(!$.common.equals("sql", templateName) && !$.common.equals("tree.html", templateName) && !$.common.equals("sub-domain.java", templateName)){
						items.push({
							title: templateName , content: "<pre class=\"layui-code\">" + value + "</pre>"
						})
					}
				});
				layer.tab({
					area: ['90%', '90%'],
					shadeClose: true,
					tab: items
				});
			} else {
				$.modal.alertError(result.msg);
			}
			$.modal.closeLoading();
tangying authored
159
		});
mahuandong authored
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
	}

	// 生成代码
	function genCode(tableName) {
		$.modal.confirm("确定要生成" + tableName + "表代码吗?", function() {
			location.href = prefix + "/genCode/" + tableName;
			layer.msg('执行成功,正在生成代码请稍后…', { icon: 1 });
		})
	}

	//批量生成代码
	function batchGenCode() {
		var rows = $.table.selectColumns("tableName");
		if (rows.length == 0) {
			$.modal.alertWarning("请选择要生成的数据");
			return;
tangying authored
176
		}
mahuandong authored
177
178
179
180
181
182
183
184
185
186
187
188
189
190
		$.modal.confirm("确认要生成选中的" + rows.length + "条数据吗?", function() {
			location.href = prefix + "/batchGenCode?tables=" + rows;
			layer.msg('执行成功,正在生成代码请稍后…', { icon: 1 });
		});
	}

	// 导入表结构
	function importTable() {
		var importTableUrl = prefix + "/importTable";
		$.modal.open("导入表结构", importTableUrl);
	}

	function edit() {
		let row = $('#bootstrap-table').bootstrapTable('getSelections');
yihao.liu authored
191
		$.operate.editTab(row[0].tableId);
mahuandong authored
192
193
	}
</script>
tangying authored
194
195
</body>
</html>