db.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. {extend name="layout:home" /}
  2. {block name="container"}
  3. <div class="layui-tab layui-tab-card">
  4. {include file="layout/admin_items" /}
  5. <div class="layui-tab-content page-tab-content">
  6. <div class="explanation" id="explanation">
  7. <div class="title" id="checkZoom">
  8. <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
  9. <span id="explanationZoom" title="收起提示" class="arrow"></span>
  10. </div>
  11. <ul>
  12. <li>1.会员相关信息。</li>
  13. </ul>
  14. </div>
  15. <div class="mDiv">
  16. <div class="ftitle">
  17. <div style="width: 100px;float: left;line-height: 56px;"><h3>数据库表列表</h3></div>
  18. <div style="width: 300px;float: left;line-height: 56px;"><h5>(共{$tableNum}张记录,共计{$total})</h5></div>
  19. </div>
  20. <a id="export" class="layui-btn layui-btn-primary " style="background-color: #009688;color: #fff;margin-top: 10px;">数据备份</a>
  21. </div>
  22. <form method="post" id="export-form" action="{:url('Admin/Db/export')}">
  23. <div class="layui-tab-content page-tab-content">
  24. <table class="layui-table lay-even">
  25. <colgroup>
  26. <col width="80">
  27. <col width="200">
  28. <col width="100">
  29. <col width="200">
  30. <col width="200">
  31. <col width="150">
  32. <col>
  33. </colgroup>
  34. <thead>
  35. <tr>
  36. <th><input type="checkbox" onclick="javascript:$('input[name*=tables]').prop('checked', this.checked);">全选</th>
  37. <th>数据库表</th>
  38. <th>记录条数</th>
  39. <th>占用空间</th>
  40. <th>编码</th>
  41. <th>冗余</th>
  42. <th>创建时间</th>
  43. <th>备注</th>
  44. <th>操作</th>
  45. </tr>
  46. </thead>
  47. <tbody>
  48. {notempty name="list"}
  49. {volist name="list" id="db"}
  50. <tr data-id="{$db.Name}">
  51. <td>
  52. <input type="checkbox" name="tables[]" value="{$db.Name}">
  53. </td>
  54. <td class="align-center">
  55. {$db.Name}
  56. </td>
  57. <td class="align-center">
  58. {$db.Rows}
  59. </td>
  60. <td class="align-center">
  61. {$db.Data_length|format_bytes}
  62. </td>
  63. <td class="align-center">
  64. {$db.Collation}
  65. </td>
  66. <td>{$db['Data_free']/1024} kb
  67. </td>
  68. <td class="align-center">
  69. {$db.Create_time}
  70. </td>
  71. <td>{$db['Comment']}
  72. </td>
  73. <td class="align-center">
  74. <div style="text-align: center;">
  75. <a href="{:url('Admin/Db/optimize',array('tablename'=>$db['Name']))}" class="layui-btn layui-btn-xs">优化</a>
  76. <a href="{:url('Admin/Db/repair',array('tablename'=>$db['Name']))}" class="layui-btn layui-btn-xs layui-btn-danger">修复</a>
  77. </div>
  78. </td>
  79. </tr>
  80. {/volist}
  81. {else}
  82. <tr class="no_data">
  83. <td colspan="11">{$Think.lang.ds_no_record}</td>
  84. </tr>
  85. {/notempty}
  86. </tbody>
  87. </table>
  88. </div>
  89. </form>
  90. </div>
  91. </div>
  92. <script>
  93. (function ($) {
  94. var $form = $("#export-form"), $export = $("#export"), tables;
  95. $export.click(function () {
  96. if ($("input[name^='tables']:checked").length == 0) {
  97. alert('请选中要备份的数据表');
  98. return false;
  99. }
  100. $export.addClass("disabled");
  101. $export.html("正在发送备份请求...");
  102. $.post(
  103. $form.attr("action"),
  104. $form.serialize(),
  105. function (data) {
  106. if (data.status) {
  107. tables = data.tables;
  108. $export.html(data.info + "开始备份,请不要关闭本页面!");
  109. backup(data.tab);
  110. window.onbeforeunload = function () {
  111. return "正在备份数据库,请不要关闭!"
  112. }
  113. } else {
  114. alert(data.info);
  115. $export.removeClass("disabled");
  116. $export.html("立即备份");
  117. }
  118. },
  119. "json"
  120. );
  121. return false;
  122. });
  123. function backup(tab, status) {
  124. status && showmsg(tab.id, "开始备份...(0%)");
  125. $.get($form.attr("action"), tab, function (data) {
  126. if (data.status) {
  127. showmsg(tab.id, data.info);
  128. if (!$.isPlainObject(data.tab)) {
  129. $export.removeClass("disabled");
  130. $export.html("备份完成,点击重新备份");
  131. window.onbeforeunload = function () {
  132. return null
  133. }
  134. return;
  135. }
  136. backup(data.tab, tab.id != data.tab.id);
  137. } else {
  138. $export.removeClass("disabled");
  139. $export.html("立即备份");
  140. }
  141. }, "json");
  142. }
  143. function showmsg(id, msg) {
  144. $("input[value=" + tables[id] + "]").closest("tr").find(".info").html(msg);
  145. // $("input[value=" + tables[id] + "]").closest("tr").hide(3000);
  146. }
  147. })(jQuery);
  148. </script>
  149. {/block}