gen.html 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <!DOCTYPE html>
  2. <html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
  3. <head>
  4. <th:block th:include="include :: header('代码生成列表')" />
  5. </head>
  6. <body class="gray-bg">
  7. <div class="container-div">
  8. <div class="row">
  9. <div class="col-sm-12 search-collapse">
  10. <form id="gen-form">
  11. <div class="select-list">
  12. <ul>
  13. <li>
  14. 表名称:<input type="text" name="tableName"/>
  15. </li>
  16. <li>
  17. 表描述:<input type="text" name="tableComment"/>
  18. </li>
  19. <li class="select-time">
  20. <label>表时间: </label>
  21. <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
  22. <span>-</span>
  23. <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
  24. </li>
  25. <li>
  26. <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
  27. <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
  28. </li>
  29. </ul>
  30. </div>
  31. </form>
  32. </div>
  33. <div class="btn-group-sm" id="toolbar" role="group">
  34. <a class="btn btn-success multiple disabled" onclick="javascript:batchGenCode()" shiro:hasPermission="tool:gen:code">
  35. <i class="fa fa-download"></i> 生成
  36. </a>
  37. <a class="btn btn-info" onclick="importTable()">
  38. <i class="fa fa-upload"></i> 导入
  39. </a>
  40. <a class="btn btn-primary single disabled" onclick="$.operate.editTab()" shiro:hasPermission="tool:gen:edit">
  41. <i class="fa fa-edit"></i> 修改
  42. </a>
  43. <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="tool:gen:remove">
  44. <i class="fa fa-remove"></i> 删除
  45. </a>
  46. </div>
  47. <div class="col-sm-12 select-table table-striped">
  48. <table id="bootstrap-table"></table>
  49. </div>
  50. </div>
  51. </div>
  52. <th:block th:include="include :: footer" />
  53. <script th:inline="javascript">
  54. var prefix = ctx + "tool/gen";
  55. var editFlag = [[${@permission.hasPermi('tool:gen:edit')}]];
  56. var removeFlag = [[${@permission.hasPermi('tool:gen:remove')}]];
  57. var previewFlag = [[${@permission.hasPermi('tool:gen:preview')}]];
  58. var codeFlag = [[${@permission.hasPermi('tool:gen:code')}]];
  59. $(function() {
  60. var options = {
  61. url: prefix + "/list",
  62. updateUrl: prefix + "/edit/{id}",
  63. removeUrl: prefix + "/remove",
  64. sortName: "createTime",
  65. sortOrder: "desc",
  66. showExport: true,
  67. modalName: "生成配置",
  68. rememberSelected: true,
  69. uniqueId: "tableId",
  70. columns: [{
  71. field: 'state',
  72. checkbox: true
  73. },
  74. {
  75. field: 'tableId',
  76. title: '编号',
  77. visible: false
  78. },
  79. {
  80. title: "序号",
  81. formatter: function (value, row, index) {
  82. return $.table.serialNumber(index);
  83. }
  84. },
  85. {
  86. field: 'tableName',
  87. title: '表名称',
  88. sortable: true,
  89. formatter: function(value, row, index) {
  90. return $.table.tooltip(value);
  91. }
  92. },
  93. {
  94. field: 'tableComment',
  95. title: '表描述',
  96. sortable: true,
  97. formatter: function(value, row, index) {
  98. return $.table.tooltip(value, 15);
  99. }
  100. },
  101. {
  102. field: 'className',
  103. title: '实体类名称',
  104. sortable: true
  105. },
  106. {
  107. field: 'createTime',
  108. title: '创建时间',
  109. sortable: true
  110. },
  111. {
  112. field: 'updateTime',
  113. title: '更新时间',
  114. sortable: true
  115. },
  116. {
  117. title: '操作',
  118. align: 'center',
  119. formatter: function(value, row, index) {
  120. var actions = [];
  121. 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> ');
  122. 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> ');
  123. 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> ');
  124. 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> ');
  125. return actions.join('');
  126. }
  127. }]
  128. };
  129. $.table.init(options);
  130. });
  131. // 预览代码
  132. function preview(tableId) {
  133. var preViewUrl = prefix + "/preview/" + tableId;
  134. $.modal.loading("正在加载数据,请稍后...");
  135. $.get(preViewUrl, function(result) {
  136. if (result.code == web_status.SUCCESS) {
  137. var items = [];
  138. $.each(result.data, function(index, value) {
  139. value = value.replace(/</g, "&lt;");
  140. value = value.replace(/>/g, "&gt;");
  141. var templateName = index.substring(index.lastIndexOf("/") + 1, index.length).replace(/\.vm/g, "");
  142. if(!$.common.equals("sql", templateName) && !$.common.equals("tree.html", templateName) && !$.common.equals("sub-domain.java", templateName)){
  143. items.push({
  144. title: templateName , content: "<pre class=\"layui-code\">" + value + "</pre>"
  145. })
  146. }
  147. });
  148. top.layer.tab({
  149. area: ['90%', '90%'],
  150. shadeClose: true,
  151. tab: items
  152. });
  153. } else {
  154. $.modal.alertError(result.msg);
  155. }
  156. $.modal.closeLoading();
  157. });
  158. }
  159. // 生成代码
  160. function genCode(tableName) {
  161. $.modal.confirm("确定要生成" + tableName + "表代码吗?", function() {
  162. location.href = prefix + "/genCode/" + tableName;
  163. layer.msg('执行成功,正在生成代码请稍后…', { icon: 1 });
  164. })
  165. }
  166. //批量生成代码
  167. function batchGenCode() {
  168. var rows = $.table.selectColumns("tableName");
  169. if (rows.length == 0) {
  170. $.modal.alertWarning("请选择要生成的数据");
  171. return;
  172. }
  173. $.modal.confirm("确认要生成选中的" + rows.length + "条数据吗?", function() {
  174. location.href = prefix + "/batchGenCode?tables=" + rows;
  175. layer.msg('执行成功,正在生成代码请稍后…', { icon: 1 });
  176. });
  177. }
  178. // 导入表结构
  179. function importTable() {
  180. var importTableUrl = prefix + "/importTable";
  181. $.modal.open("导入表结构", importTableUrl);
  182. }
  183. </script>
  184. </body>
  185. </html>