backuplist.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. {extend name="common/base" /}
  2. <!-- 主体 -->
  3. {block name="body"}
  4. <div class="p-3">
  5. <div class="gg-form-bar border-t border-x" style="background-color:#FAFAFA">
  6. <h3>数据还原</h3>
  7. </div>
  8. <table cellspacing="0" cellpadding="0" border="0" class="layui-table layui-table-form">
  9. <tr>
  10. <th style=" text-align: center; font-weight: 800;"><span>文件名称</span></th>
  11. <th style=" text-align: center; font-weight: 800;"><span>文件格式</span></th>
  12. <th style=" text-align: center; font-weight: 800;"><span>分隔符</span></th>
  13. <th style=" text-align: center; font-weight: 800;"><span>文件总大小</span></th>
  14. <th style=" text-align: center; font-weight: 800;"><span>分卷总数</span></th>
  15. <th style=" text-align: center; font-weight: 800; width:222px"><span>操作</span></th>
  16. </tr>
  17. {empty name="list"}
  18. <tr>
  19. <td colspan="6" align="center">暂无备份数据</td>
  20. </tr>
  21. {/empty}
  22. {volist name="list" id="vo" key="k"}
  23. <tr style="background-color: #fafafa;">
  24. <td><strong>备份时间:{$vo.time}</strong>{if $vo.timespan == $lock_time}<span
  25. style="color:red; margin-left:20px;">该备份不是完整备份,请删除重新备份</span>{/if}</td>
  26. <td align="center"><span>.sql</span></td>
  27. <td align="center"><span>{$vo.data.compress}</span></td>
  28. <td align="center"><span>{:format_bytes($vo.data.size)}</span></td>
  29. <td align="center"><span>{$vo.data.part}</span></td>
  30. <td align="center">
  31. <div class="layui-btn-group" data-time='{$vo.timespan}'>
  32. {if $vo.timespan == $lock_time}
  33. <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="reset">清除不完整的备份</a>
  34. {else/}
  35. <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="import">数据还原</a>
  36. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">备份删除</a>
  37. {/if}
  38. </div>
  39. </td>
  40. </tr>
  41. {for start="0" end="$vo.data.part" step="1"}
  42. <tr>
  43. <td colspan="5">
  44. {:date("Ymd",$vo.timespan)}{$vo.data.compress}{:date("His",$vo.timespan)}{$vo.data.compress}{$i+1}.sql
  45. </td>
  46. <td align="center">
  47. <a class="layui-btn layui-btn-xs"
  48. href='/admin/database/downfile?time={$vo.data.time}&part={$i+1}'>下载备份(分卷{$i+1})</a>
  49. </td>
  50. </tr>
  51. {/for}
  52. {/volist}
  53. </table>
  54. </div>
  55. {/block}
  56. <!-- /主体 -->
  57. <!-- 脚本 -->
  58. {block name="script"}
  59. <script>
  60. function gouguInit() {
  61. function importData(data) {
  62. if (data.code == 0) {
  63. console.log(data.msg);
  64. layer.closeAll();
  65. layer.msg(data.msg, { time: 200000 });
  66. if ($.isPlainObject(data.data)) {
  67. $.ajax({
  68. url: "/admin/database/import",
  69. type: 'get',
  70. data: { "part": data.data.part, "start": data.data.start, time: data.data.time },
  71. success: function (res) {
  72. importData(res);
  73. }
  74. })
  75. } else {
  76. layer.msg(data.msg);
  77. window.onbeforeunload = function () { return null; }
  78. }
  79. } else {
  80. layer.msg(data.msg);
  81. }
  82. }
  83. //监听行工具事件
  84. $('[lay-event="import"]').on('click', function () {
  85. var time = $(this).parent().data('time');
  86. layer.confirm('确认要还原该备份吗?', {
  87. icon: 3,
  88. title: '提示'
  89. }, function (index) {
  90. layer.msg("数据还原中...", { time: 200000 });
  91. $.ajax({
  92. url: "/admin/database/import?time=" + time,
  93. type: 'post',
  94. success: function (res) {
  95. importData(res);
  96. }
  97. })
  98. window.onbeforeunload = function () { return "正在还原数据库,请不要关闭!" }
  99. layer.close(index);
  100. });
  101. return false;
  102. })
  103. $('[lay-event="del"]').on('click', function () {
  104. var time = $(this).parent().data('time');
  105. layer.confirm('确认要删除该备份吗?', {
  106. icon: 3,
  107. title: '提示'
  108. }, function (index) {
  109. $.ajax({
  110. url: "/admin/database/del",
  111. data: { 'time': time },
  112. success: function (res) {
  113. layer.msg(res.msg);
  114. if (res.code == 0) {
  115. setTimeout(function () {
  116. location.reload();
  117. }, 2000)
  118. }
  119. }
  120. })
  121. layer.close(index);
  122. });
  123. return false;
  124. })
  125. $('[lay-event="reset"]').on('click', function () {
  126. var time = $(this).parent().data('time');
  127. layer.confirm('确认要清除该备份吗?', {
  128. icon: 3,
  129. title: '提示'
  130. }, function (index) {
  131. $.ajax({
  132. url: "/admin/database/del",
  133. data: { 'time': time, 'lock': 1 },
  134. success: function (res) {
  135. layer.msg(res.msg);
  136. if (res.code == 0) {
  137. setTimeout(function () {
  138. location.reload();
  139. }, 2000)
  140. }
  141. }
  142. })
  143. layer.close(index);
  144. });
  145. return false;
  146. })
  147. }
  148. </script>
  149. {/block}
  150. <!-- /脚本 -->