index.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. {extend name="public/container"}
  2. {block name="content"}
  3. <div class="row">
  4. <div class="col-sm-12">
  5. <div class="ibox float-e-margins">
  6. <div class="ibox-title">
  7. <h5>数据库备份记录</h5>
  8. </div>
  9. <div class="ibox-content" style="display: block;">
  10. <div class="table-responsive">
  11. <table class="layui-hide" id="fileList" lay-filter="fileList"></table>
  12. <script type="text/html" id="fileListtool">
  13. <button type="button" class="layui-btn layui-btn-xs" lay-event="import"><i class="layui-icon layui-icon-edit"></i>倒入</button>
  14. <button type="button" class="layui-btn layui-btn-xs" lay-event="delFile"><i class="layui-icon layui-icon-edit"></i>删除</button>
  15. <button type="button" class="layui-btn layui-btn-xs" lay-event="downloadFile"><i class="layui-icon layui-icon-edit"></i>下载</button>
  16. </script>
  17. </div>
  18. </div>
  19. </div>
  20. </div>
  21. </div>
  22. <div class="row">
  23. <div class="col-sm-12">
  24. <div class="ibox">
  25. <div class="ibox-title">
  26. <h5>数据库表列表</h5>
  27. </div>
  28. <div class="ibox-content">
  29. <div class="table-responsive">
  30. <script type="text/html" id="toolbarDemo">
  31. <div class="layui-btn-container">
  32. <button class="layui-btn layui-btn-sm" lay-event="backup">备份</button>
  33. <button class="layui-btn layui-btn-sm" lay-event="optimize">优化表</button>
  34. <button class="layui-btn layui-btn-sm" lay-event="repair">修复表</button>
  35. </div>
  36. </script>
  37. <table class="layui-hide" id="tableListID" lay-filter="tableListID"></table>
  38. <script type="text/html" id="barDemo">
  39. <button type="button" class="layui-btn layui-btn-xs" lay-event="see"><i class="layui-icon layui-icon-edit"></i>详情</button>
  40. </script>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. <script src="{__ADMIN_PATH}js/layuiList.js"></script>
  47. <script>
  48. layui.use('table', function(){
  49. var fileList = layui.table;
  50. var tableList = layui.table;
  51. //加载sql备份列表
  52. fileList.render({
  53. elem: '#fileList'
  54. ,url:"{:Url('fileList')}"
  55. ,cols: [[
  56. {field: 'backtime', title: '备份名称', sort: true},
  57. {field: 'part', title: '备注'},
  58. {field: 'size', title: '大小'},
  59. {field: 'compress', title: '类型'},
  60. {field: 'time', title: '时间'},
  61. {fixed: 'right', title: '操作', width: '20%', align: 'center', toolbar: '#fileListtool'}
  62. ]]
  63. ,page: false
  64. });
  65. //监听工具条
  66. fileList.on('tool(fileList)', function(obj){
  67. var data = obj.data;
  68. if(obj.event === 'import'){
  69. layer.msg('ID:'+ data.id + ' 的查看操作');
  70. } else if(obj.event === 'delFile'){
  71. layer.confirm('真的删除行么', function(index){
  72. layList.basePost(layList.Url({a:'delFile'}),{feilname:data.time},function (res) {
  73. layList.msg(res.msg);
  74. // layList.reload();
  75. });
  76. obj.del();
  77. layer.close(index);
  78. });
  79. } else if(obj.event === 'downloadFile'){
  80. layer.alert('编辑行:<br>'+ JSON.stringify(data))
  81. }
  82. });
  83. //加载table
  84. tableList.render({
  85. elem: '#tableListID'
  86. ,url:"{:Url('tablelist')}"
  87. ,toolbar: '#toolbarDemo'
  88. ,cols: [[
  89. {type:'checkbox'},
  90. {field: 'name', title: '表名称', sort: true},
  91. {field: 'comment', title: '备注' },
  92. {field: 'engine', title: '类型', sort: true},
  93. {field: 'data_length', title: '大小', sort: true,totalRow: true},
  94. {field: 'update_time', title: '更新时间', sort: true},
  95. {field: 'rows', title: '行数'},
  96. {fixed: 'right', title: '操作', width: '10%', align: 'center', toolbar: '#barDemo'}
  97. ]]
  98. ,page: false
  99. });
  100. //头工具栏事件
  101. tableList.on('toolbar(tableListID)', function(obj){
  102. var checkStatus = tableList.checkStatus(obj.config.id);
  103. var data = checkStatus.data;
  104. var tables = [];
  105. $.each(data, function (name, value) {
  106. if (value['name'] != undefined) tables.push(value['name']);
  107. });
  108. switch(obj.event){
  109. case 'backup':
  110. if(tables.length){
  111. layList.basePost(layList.Url({a:'backup'}),{tables:tables},function (res) {
  112. layList.msg(res.msg);
  113. fileList.reload();
  114. });
  115. }else{
  116. layList.msg('请选择表');
  117. }
  118. break;
  119. case 'optimize':
  120. if(tables.length){
  121. layList.basePost(layList.Url({a:'optimize'}),{tables:tables},function (res) {
  122. layList.msg(res.msg);
  123. });
  124. }else{
  125. layList.msg('请选择表');
  126. }
  127. break;
  128. case 'repair':
  129. if(tables.length){
  130. layList.basePost(layList.Url({a:'repair'}),{tables:tables},function (res) {
  131. layList.msg(res.msg);
  132. });
  133. }else{
  134. layList.msg('请选择表');
  135. }
  136. break;
  137. };
  138. });
  139. //监听并执行操作
  140. tableList.on('tool(tableListID)', function(obj){
  141. var data = obj.data;
  142. if(obj.event === 'see'){
  143. $eb.createModalFrame('详情',layList.Url({a:'edit',p:{tablename:data.name}}));
  144. }
  145. });
  146. });
  147. </script>
  148. {/block}