| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 | 
							- <!DOCTYPE html>
 
- <html>
 
- <head>
 
-     <meta charset="utf-8">
 
-     <title>layui</title>
 
-     <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
 
-     <script src="__PUBLIC__/layui/layui.js" charset="utf-8"></script>
 
- </head>
 
- <body style="padding:10px;">
 
- <div style="margin:20px 0px;">
 
-     <div class="layui-tab">
 
-         <ul class="layui-tab-title">
 
-             <li class="layui-this">备份</li>
 
-             <li><a href="{:url('admin/databackup/importlist')}" class="a_menu">还原</a></li>
 
-         </ul>
 
-     </div>
 
-     <a id="export" class="layui-btn layui-btn-sm" href="javascript:;" autocomplete="off">立即备份</a>
 
-     <a id="optimize" href="{:url('admin/databackup/optimize')}" class="layui-btn layui-btn-sm ">优化数据表</a>
 
-     <a id="repair" href="{:url('admin/databackup/repair')}" class="layui-btn layui-btn-sm">修复数据表</a>
 
-     <form id="export-form" method="post" action="{:url('admin/databackup/export')}">
 
-         <table class="layui-table" lay-even="" lay-skin="row" lay-size="sm">
 
-             <colgroup>
 
-                 <col width="50">
 
-                 <col width="150">
 
-                 <col width="150">
 
-                 <col width="150">
 
-                 <col width="200">
 
-                 <col width="200">
 
-                 <col width="150">
 
-             </colgroup>
 
-             <thead>
 
-             <tr>
 
-                 <th width="48"><input lay-skin="primary" checked="chedked" type="checkbox" value=""
 
-                                       id="checkOrCancelAll"></th>
 
-                 <th>表名</th>
 
-                 <th>数据量</th>
 
-                 <th>数据大小</th>
 
-                 <th>创建时间</th>
 
-                 <th>状态</th>
 
-                 <th>操作</th>
 
-             </tr>
 
-             </thead>
 
-             <tbody>
 
-             {volist name='list' id='table'}
 
-             <tr>
 
-                 <td>
 
-                     <input class="ids" checked="chedked" type="checkbox" name="tables[]" value="{$table.name}">
 
-                 </td>
 
-                 <td class="tablename">{$table.name}</td>
 
-                 <td>{$table.rows}</td>
 
-                 <td>{$table.data_length|format_bytes}</td>
 
-                 <td>{$table.create_time}</td>
 
-                 <td class="info">-</td>
 
-                 <td>
 
-                     <a href="javascript:;" class="layui-btn layui-btn-xs optimiz" tables="{$table.name}">优化表</a> 
 
-                     <a href="javascript:;" class="layui-btn layui-btn-xs repair" tables="{$table.name}">修复表</a>
 
-                 </td>
 
-             </tr>
 
-             {/volist}
 
-             </tbody>
 
-         </table>
 
-     </form>
 
-     <span style="color:red;">注意 :此功能虽然便捷,但是效率差,数据多时请使用其它备份工具</span>
 
- </div>
 
- <script src="__PUBLIC__/jquery/jquery.min.js"></script>
 
- <script>
 
-     layui.use(['jquery', 'layer'], function () {
 
-         window.$ = layui.$;
 
-         var layer = layui.layer;
 
-         //备份表方法
 
-         $("#export").click(function () {
 
-             $(this).html("正在发送备份请求...");
 
-             clearmsg();
 
-             $.post(
 
-                 $("#export-form").attr("action"),
 
-                 $("#export-form").serialize(),
 
-                 function (data) {
 
-                     if (data.code == 1) {
 
-                         $("#export").html("开始备份,请不要关闭本页面!");
 
-                         myload = layer.load(1, {
 
-                             shade: [0.5, '#fff'] //0.1透明度的白色背景
 
-                         });
 
-                         backup(data.data.tab);
 
-                         window.onbeforeunload = function () {
 
-                             return "正在备份数据库,请不要关闭!"
 
-                         }
 
-                     } else {
 
-                         layer.tips(data.msg, "#export", {
 
-                             tips: [1, '#3595CC'],
 
-                             time: 4000
 
-                         });
 
-                         $("#export").html("立即备份");
 
-                     }
 
-                 }, "json");
 
-             return false;
 
-         });
 
-         //递归备份表
 
-         function backup(tab, status) {
 
-             status && showmsg(tab.id, "开始备份...(0%)");
 
-             $.get($("#export-form").attr("action"), tab, function (data) {
 
-                 // console.log(data)
 
-                 if (data.code == 1) {
 
-                     showmsg(tab, data.msg);
 
-                     if (!$.isPlainObject(data.data.tab)) {
 
-                         $("#export").html("备份完成");
 
-                         layer.close(myload);
 
-                         window.onbeforeunload = function () {
 
-                             return null
 
-                         }
 
-                         return;
 
-                     }
 
-                     backup(data.data.tab, tab.id != data.data.tab.id);
 
-                 } else {
 
-                     $("#export").html("立即备份");
 
-                 }
 
-             }, "json");
 
-         }
 
-         //修改备份状态
 
-         function showmsg(tab, msg) {
 
-             $(".tablename").each(function (index) {
 
-                 if ($(this).text() == tab.tablename) {
 
-                     $("table tbody tr").eq(index).find(".info").html(msg)
 
-                 }
 
-             })
 
-         }
 
-         function clearmsg() {
 
-             $("table tbody tr").each(function (index) {
 
-                 $(this).find(".info").html('-');
 
-             })
 
-         }
 
-         //优化表
 
-         $("#optimize").click(function () {
 
-             $.post(this.href, $("#export-form").serialize(), function (data) {
 
-                 layer.tips(data.msg, "#optimize", {
 
-                     tips: [1, '#3595CC'],
 
-                     time: 4000
 
-                 });
 
-             }, "json");
 
-             return false;
 
-         });
 
-         //修复表
 
-         $("#repair").on("click", function (e) {
 
-             $.post(this.href, $("#export-form").serialize(), function (data) {
 
-                 layer.tips(data.msg, "#repair", {
 
-                     tips: [1, '#3595CC'],
 
-                     time: 4000
 
-                 });
 
-             }, "json");
 
-             return false;
 
-         });
 
-     });
 
- </script>
 
- <script type="text/javascript">
 
-     //全选
 
-     $(function () {
 
-         $('#checkOrCancelAll').on('click', function () {
 
-             if (this.checked) {
 
-                 $(".ids").prop('checked', true);
 
-             } else {
 
-                 $(".ids").prop('checked', false);
 
-             }
 
-         });
 
-     });
 
-     $('.optimiz').click(function () {
 
-         var tables = $(this).attr('tables');
 
-         $.ajax({
 
-             url: "{:url('admin/databackup/optimize')}"
 
-             , dataType: 'json', data: {tables: tables}
 
-             , success: function (res) {
 
-                 layer.msg(res.msg);
 
-             }
 
-         })
 
-     })
 
-     $('.repair').on('click', function () {
 
-         var tables = $(this).attr('tables');
 
-         $.ajax({
 
-             url: "{:url('admin/databackup/repair')}"
 
-             , dataType: 'json', data: {tables: tables}
 
-             , success: function (res) {
 
-                 layer.msg(res.msg);
 
-             }
 
-         })
 
-     })
 
- </script>
 
- </body>
 
- </html>
 
 
  |