main.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <meta name="keywords" content="">
  8. <meta name="description" content="">
  9. <title text="代码生成"></title>
  10. <link rel="stylesheet" href="../../component/pear/css/pear.css">
  11. </head>
  12. <body class="pear-container">
  13. <div class="layui-card">
  14. <div class="layui-card-body">
  15. <form class="layui-form">
  16. <div class="layui-form-item">
  17. <label class="layui-form-label">表名称</label>
  18. <div class="layui-input-inline">
  19. <input type="text" name="tableName" placeholder="" class="layui-input">
  20. </div>
  21. <button type="button" class="pear-btn pear-btn-md-0 pear-btn-primary" lay-submit lay-filter="query">
  22. <i class="layui-icon layui-icon-search"></i> 查询
  23. </button>
  24. <button type="reset" class="pear-btn pear-btn-md-0">
  25. <i class="layui-icon layui-icon-refresh"></i> 重置
  26. </button>
  27. </div>
  28. </form>
  29. </div>
  30. </div>
  31. <div class="layui-card">
  32. <div class="layui-card-body">
  33. <table id="table" lay-filter="table"></table>
  34. </div>
  35. </div>
  36. <script type="text/html" id="toolbar">
  37. <button class="pear-btn pear-btn-primary pear-btn-md" lay-event="import">
  38. <i class="pear-icon pear-icon-import"></i> 导入
  39. </button>
  40. </script>
  41. <script type="text/html" id="bar">
  42. <a class="cool-line-btn cool-bg-blue" lay-event="edit">编辑</a>
  43. <div class="cool-line-divider"></div>
  44. <a class="cool-line-btn cool-bg-blue" lay-event="generate">生成</a>
  45. </script>
  46. <script type="text/html" id="createTime">
  47. {{ layui.util.toDateString(d.createTime, 'yyyy-MM-dd HH:mm:ss') }}
  48. </script>
  49. <script type="text/html" id="updateTime">
  50. {{ layui.util.toDateString(d.updateTime, 'yyyy-MM-dd HH:mm:ss') }}
  51. </script>
  52. <script src="../../component/layui/layui.js"></script>
  53. <script src="../../component/pear/pear.js"></script>
  54. <script>
  55. layui.use(['request', 'form', 'table', 'popup'], function () {
  56. var $ = layui.jquery,
  57. request = layui.request,
  58. form = layui.form,
  59. table = layui.table;
  60. var MODULE_PATH = "/generator/v1/";
  61. request.tableRender({
  62. url: MODULE_PATH,
  63. cols: [
  64. [
  65. {type: 'checkbox'},
  66. {title: '表名称', field: 'tableName'},
  67. {title: '表注释', field: 'tableComment'},
  68. {title: '创建时间', field: 'createTime',templet: '#createTime'},
  69. {title: '更新时间', field: 'updateTime',templet: '#updateTime'},
  70. {title: '操作', toolbar: '#bar', align: 'center'}
  71. ]
  72. ]
  73. });
  74. table.on('toolbar(table)', function (obj) {
  75. if (obj.event === 'refresh') {
  76. window.refresh();
  77. }
  78. else if(obj.event === 'import') {
  79. window.import();
  80. }
  81. });
  82. table.on('tool(table)', function (obj) {
  83. if (obj.event === 'edit') {
  84. window.edit(obj);
  85. }
  86. else if (obj.event === 'generate') {
  87. window.generate(obj);
  88. }
  89. });
  90. form.on('submit(query)', function (data) {
  91. refresh(data.field);
  92. return false;
  93. });
  94. window.import = function () {
  95. layer.open({
  96. type: 2,
  97. title: '导入表结构',
  98. shade: 0.1,
  99. area: ['1000px', '600px'],
  100. content: "import.html",
  101. btn: ["确定", "取消"],
  102. yes: function (index, layero) {
  103. layero.find('iframe')[0].contentWindow.submitHandler();
  104. },
  105. cancel: function (index, layero) {
  106. layui.layer.close(index);
  107. return false;
  108. }
  109. });
  110. };
  111. window.generate = function (obj) {
  112. layer.open({
  113. type: 2,
  114. title: '代码生成',
  115. shade: 0.1,
  116. area: ['460px', '280px'],
  117. content: 'generate.html?id=' + obj.data.id
  118. });
  119. };
  120. window.edit = function (obj) {
  121. parent.layui.tab.addTabOnlyByElem('content', {
  122. id: "gen" + obj.data.id,
  123. title: '生成配置',
  124. url: 'view/generator/edit.html?id=' + obj.data.id,
  125. close: true
  126. })
  127. };
  128. window.refresh = function (param) {
  129. table.reload('table', {where: param});
  130. }
  131. });
  132. </script>
  133. </body>
  134. </html>