db.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. {include file="public/header" /}
  2. <div class="page">
  3. <div class="fixed-bar">
  4. <div class="item-title">
  5. <div class="subject">
  6. <h3>{$Think.lang.ds_db}</h3>
  7. <h5></h5>
  8. </div>
  9. {include file="public/admin_items" /}
  10. </div>
  11. </div>
  12. <!-- 操作说明 -->
  13. <div class="explanation" id="explanation">
  14. <div class="title" id="checkZoom">
  15. <h4 title="{$Think.lang.ds_explanation_tip}">{$Think.lang.ds_explanation}</h4>
  16. <span id="explanationZoom" title="{$Think.lang.ds_explanation_close}" class="arrow"></span>
  17. </div>
  18. <ul>
  19. <li>{$Think.lang.db_data_backup_help1}</li>
  20. <li>{$Think.lang.db_data_backup_help2}</li>
  21. </ul>
  22. </div>
  23. <div class="ds-search-form">
  24. <dl>
  25. <dt style="font-size:14px;color: #09C;">{$Think.lang.db_database_table_list}({$Think.lang.db_total_num}{$tableNum}{$Think.lang.db_tablenum_record},{$Think.lang.db_total_size}{$total})</dt>
  26. </dl>
  27. <div class="btn_group">
  28. <a id="export" class="btn">{$Think.lang.ds_db}</a>
  29. </div>
  30. </div>
  31. <table class="ds-default-table">
  32. <thead>
  33. <tr>
  34. <th><input type="checkbox" onclick="javascript:$('input[name*=tables]').prop('checked', this.checked);"></th>
  35. <th>{$Think.lang.db_database_table}</th>
  36. <th>{$Think.lang.db_data_length}</th>
  37. <th>{$Think.lang.db_occupy_space}</th>
  38. <th>{$Think.lang.db_code}</th>
  39. <th>{$Think.lang.db_createtime}</th>
  40. <th>{$Think.lang.db_backup_state}</th>
  41. <th>{$Think.lang.db_handle}</th>
  42. </tr>
  43. </thead>
  44. <form method="post" id="export-form" action="{:url('Database/export')}">
  45. <tbody>
  46. {foreach name="dbtable_list" item="db" key="k" }
  47. <tr data-id="{$db.Name}">
  48. <td class="sign">
  49. <div style="width: 24px;"><input type="checkbox" name="tables[]" value="{$db.Name}"></div>
  50. </td>
  51. <td>{$db.Name}</td>
  52. <td>{$db.Rows}</td>
  53. <td>{$db.Data_length|format_bytes}</td>
  54. <td>{$db.Collation}</td>
  55. <td>{$db.Create_time}</td>
  56. <td class="info">{$Think.lang.db_unbackup}</td>
  57. <td class="handle">
  58. <div style="text-align: center; width: 170px; max-width:170px;">
  59. <a href="{:url('Database/optimize',array('tablename'=>$db['Name']))}"><i class="iconfont">&#xe6e0;</i>{$Think.lang.db_magic}</a> |
  60. <a href="{:url('Database/repair',array('tablename'=>$db['Name']))}"><i class="iconfont">&#xe6e0;</i>{$Think.lang.db_repair}</a>
  61. </div>
  62. </td>
  63. </tr>
  64. {/foreach}
  65. </tbody>
  66. </form>
  67. </table>
  68. </div>
  69. <script>
  70. (function($) {
  71. var $form = $("#export-form"), $export = $("#export"), tables;
  72. $export.click(function() {
  73. if ($("input[name^='tables']:checked").length == 0) {
  74. layer.alert('{$Think.lang.db_backup_error}');
  75. return false;
  76. }
  77. $export.addClass("disabled");
  78. $export.html("{$Think.lang.db_backup_requer}");
  79. $.post(
  80. $form.attr("action"),
  81. $form.serialize(),
  82. function(data) {
  83. if (data.status) {
  84. tables = data.tables;
  85. $export.html(data.info + "{$Think.lang.db_backup_strat}");
  86. backup(data.tab);
  87. window.onbeforeunload = function() {
  88. return "{$Think.lang.db_backup_conduct}"
  89. }
  90. } else {
  91. layer.alert(data.info);
  92. $export.removeClass("disabled");
  93. $export.html("{$Think.lang.db_backup}");
  94. }
  95. },
  96. "json"
  97. );
  98. return false;
  99. });
  100. function backup(tab, status) {
  101. status && showmsg(tab.id, "{$Think.lang.db_backup_state_strat}");
  102. $.get($form.attr("action"), tab, function(data) {
  103. if (data.status) {
  104. showmsg(tab.id, data.info);
  105. if (!$.isPlainObject(data.tab)) {
  106. $export.removeClass("disabled");
  107. $export.html("{$Think.lang.db_backup_restart}");
  108. window.onbeforeunload = function() {
  109. return null
  110. }
  111. return;
  112. }
  113. backup(data.tab, tab.id != data.tab.id);
  114. } else {
  115. $export.removeClass("disabled");
  116. $export.html("{$Think.lang.db_backup}");
  117. }
  118. }, "json");
  119. }
  120. function showmsg(id, msg) {
  121. $("input[value=" + tables[id] + "]").closest("tr").find(".info").html(msg);
  122. // $("input[value=" + tables[id] + "]").closest("tr").hide(3000);
  123. }
  124. })(jQuery);
  125. </script>
  126. </body>
  127. </html>