index.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. {include file='common/header' /}
  2. <style>#repair{ margin-left: 10px;}</style>
  3. <div class="LM-container">
  4. <div class="LM-main">
  5. <fieldset class="layui-elem-field LM-search layui-field-title">
  6. <legend>数据库{:lang('list')}</legend>
  7. </fieldset>
  8. <blockquote class="layui-elem-quote">
  9. 数据库中共有<i class="count"></i> 张表,共计<i class="size"></i>
  10. <a href="javascript:void(0)" id="repair" class="layui-btn layui-btn-sm layui-btn-warm">修复</a>
  11. <a href="javascript:void(0)" id="optimize" class="layui-btn layui-btn-sm layui-btn-normal">优化</a>
  12. <a href="javascript:void(0)" id="backUp" class="layui-btn layui-btn-sm">备份</a>
  13. </blockquote>
  14. <table class="layui-hide" id="list" lay-filter="list"></table>
  15. </div>
  16. </div>
  17. {include file='common/footer' /}
  18. <script type="text/html" id="size">
  19. {{d.size}}
  20. </script>
  21. <script>
  22. layui.use(['form', 'table'], function () {
  23. var $ = layui.jquery,
  24. form = layui.form,
  25. table = layui.table;
  26. table.render({
  27. elem: '#list',
  28. url: '{:url("index")}',
  29. method: 'post',
  30. cols: [[
  31. {checkbox: true, fixed: true},
  32. {field: 'name', title: '数据库表', width: 150, fixed: true, sort: true},
  33. {field: 'rows', title: '记录条数', width: 150, sort: true},
  34. {field: 'size', title: '大小', width: 150, templet: '#size', sort: true},
  35. {field: 'engine', title: '类型', width: 110, sort: true},
  36. {field: 'collation', title: '编码', width: 150, sort: true},
  37. {field: 'create_time', title: '创建时间', width: 180, sort: true},
  38. {field: 'comment', title: '说明', width: 180},
  39. ]],
  40. done: function(res, curr, count){
  41. $('.count').html(res.tableNum);
  42. $('.size').html(res.total);
  43. },
  44. //
  45. limits: [10, 15, 20, 25, 50, 100],
  46. limit: 50,
  47. page: true
  48. });
  49. $('#backUp').click(function(){
  50. var obj = $(this);
  51. var checkStatus = table.checkStatus('list'); //test即为参数id设定的值
  52. var a = [];
  53. $(checkStatus.data).each(function(i,o){
  54. a.push(o.name);
  55. });
  56. obj.addClass('layui-btn-disabled');
  57. obj.html('备份进行中...');
  58. $.post("{:url('database/backup')}",{tables:a},function(data){
  59. if(data.code==1){
  60. layer.msg(data.msg,{time:1000,icon:1},function(){
  61. tableIn.reload();
  62. });
  63. }else{
  64. layer.msg(data.msg,{time:1000,icon:2});
  65. }
  66. obj.removeClass('layui-btn-disabled');
  67. obj.html('备份');
  68. });
  69. });
  70. $('#optimize').click(function(){
  71. var obj = $(this);
  72. var checkStatus = table.checkStatus('list'); //test即为参数id设定的值
  73. var a = [];
  74. $(checkStatus.data).each(function(i,o){
  75. a.push(o.name);
  76. });
  77. obj.addClass('layui-btn-disabled');
  78. obj.html('优化进行中...');
  79. $.post("{:url('database/optimize')}",{tables:a},function(data){
  80. if(data.code==1){
  81. layer.msg(data.msg,{time:1000,icon:1},function(){
  82. tableIn.reload();
  83. });
  84. }else{
  85. layer.msg(data.msg,{time:1000,icon:2});
  86. }
  87. obj.removeClass('layui-btn-disabled');
  88. obj.html('优化');
  89. });
  90. });
  91. $('#repair').click(function(){
  92. var obj = $(this);
  93. var checkStatus = table.checkStatus('list'); //test即为参数id设定的值
  94. var a = [];
  95. $(checkStatus.data).each(function(i,o){
  96. a.push(o.name);
  97. });
  98. obj.addClass('layui-btn-disabled');
  99. obj.html('修复进行中...');
  100. $.post("{:url('database/repair')}",{tables:a},function(data){
  101. if(data.code==1){
  102. layer.msg(data.msg,{time:1000,icon:1},function(){
  103. tableIn.reload();
  104. });
  105. }else{
  106. layer.msg(data.msg,{time:1000,icon:2});
  107. }
  108. obj.removeClass('layui-btn-disabled');
  109. obj.html('修复');
  110. });
  111. })
  112. })
  113. </script>