import.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. {include file="public/header" /}
  2. <body>
  3. <div class="layui-fluid">
  4. <div class="layui-card">
  5. <div class="layui-form layui-card-header layuiadmin-card-header-auto">
  6. <button class="layui-btn layui-btn-danger layuiBtn" data-type="getCheckData" >
  7. <i class="fa fa-trash-o"></i> 批量删除
  8. </button>
  9. </div>
  10. <div class="layui-card-body">
  11. <table id="LAY-table-manage" lay-filter="LAY-table-manage"></table>
  12. <!--操作模板-->
  13. <script type="text/html" id="opeBar">
  14. <a class="layui-btn layui-btn-xs" onclick="restore('{:url('revert')}','{{d.time}}')" title="还原" ><i class="fa fa-magic"></i></a>
  15. <a class="layui-btn layui-btn-danger layui-btn-xs" title="删除" onclick="dataDel(this,'{{d.time}}')"><i class="fa fa-trash-o"></i></a>
  16. </script>
  17. </div>
  18. </div>
  19. </div>
  20. {include file="public/footer" /}
  21. <script>
  22. layui.use(['index', 'table'], function () {
  23. var $ = layui.$
  24. , form = layui.form
  25. , table = layui.table
  26. table.render({
  27. elem: '#LAY-table-manage'
  28. , url: '{:url("Data/import")}'
  29. ,response: {
  30. statusCode: 220 //成功的状态码,默认:0
  31. }
  32. , page: false
  33. , even: false //开启隔行背景
  34. , size: 'lg' //sm小尺寸的表格 lg大尺寸
  35. // ,width:100
  36. , cellMinWidth: 150
  37. , limits: [5, 10, 15, 20, 25, 30]
  38. , limit: "{:config('pages')}"
  39. , loading: true
  40. , id: 'LAY-table'
  41. , cols: [[
  42. {type: 'checkbox', fixed: 'left'}
  43. , {field: 'time', width: '', title: '备份名称', align: 'center'}
  44. , {field: 'part', width: '', title: '卷数', align: 'center'}
  45. , {field: 'compress', width: 90, title: '压缩', align: 'center'}
  46. , {field: 'size', width: '', title: '数据大小', align: 'center',}
  47. , {field: 'date', width: '', title: '备份时间', align: 'center',templet:"<div>{{d.date?layui.util.toDateString(d.date,'yyyy-MM-dd HH:MM'):''}}</div>"}
  48. , {width: '', title: '状态', align: 'center',templet:"<div><span id='restore_{{d.time}}'>-</span></div>"}
  49. , {fixed: 'right', width: 90, title: '操作', align: 'center', toolbar: '#opeBar'}
  50. ]]
  51. });
  52. var active = {
  53. getCheckData: function(){
  54. layer.confirm('确认批量删除备份文件吗?', {icon: 3, title:'提示'}, function(index){
  55. $.ajax({
  56. url: "{:url('batchDelData')}",
  57. type: "post",
  58. dataType: "json",
  59. data: "ids=" + getIds(),
  60. success: function (res) {
  61. if(res.code == 200){
  62. layer.msg(res.msg,{icon:1,time:1500,shade:0.1},function(){
  63. if (res.data != "") {
  64. $.each(res.data, function (index, item) {
  65. $('#restore_' + item).parents("tr").remove();
  66. })
  67. }
  68. })
  69. } else if (res.code == 100){
  70. wk.error(res.msg,2,'');
  71. }
  72. }
  73. });
  74. })
  75. }
  76. };
  77. $('.layuiBtn').on('click', function () {
  78. var type = $(this).data('type');
  79. active[type] ? active[type].call(this) : '';
  80. });
  81. //获取选中目标
  82. var getIds = function () {
  83. var ids = [];
  84. var checkStatus = table.checkStatus('LAY-table')
  85. ,data = checkStatus.data;
  86. $.each(data,function(index,item){
  87. ids.push(item['time'])
  88. });
  89. return ids;
  90. }
  91. });
  92. //还原数据
  93. var restore = function(url,time){
  94. $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
  95. $.get(url,{time:time} , success, "json");
  96. window.onbeforeunload = function () { return "正在还原数据库,请不要关闭!";};
  97. return false;
  98. function success(data) {
  99. if (data.code) {
  100. if (data.data.gz) {
  101. // data.msg += status;
  102. data.msg += '<i class="fa fa-refresh fa-spin"></i>';
  103. // if (status.length === 5) {
  104. // status = ".";
  105. // } else {
  106. // status += ".";
  107. // }
  108. }
  109. var w = $('#restore_'+time)
  110. w.removeClass('layui-badge layui-bg-green').addClass('layui-badge layui-bg-blue');
  111. w.html(data.msg);
  112. if(data.data == 'success'){
  113. // w.css('color','#1BB394');
  114. w.removeClass('layui-bg-blue').addClass('layui-bg-green');
  115. $('.layui-btn').removeClass('layui-disabled').removeAttr('disabled');
  116. }
  117. if (data.data.part) {
  118. $.get(url, {"part": data.data.part, "start": data.data.start}, success, "json");
  119. } else {
  120. window.onbeforeunload = function () {return null;};
  121. }
  122. }else{
  123. $('.layui-btn').removeClass('layui-disabled').removeAttr('disabled');
  124. }
  125. }
  126. }
  127. //删除备份
  128. function dataDel(obj,id){
  129. layer.confirm('确认删除此备份?', {icon: 3, title:'提示'}, function(index){
  130. $.getJSON("{:url('delData')}", {'id' : id}, function(res){
  131. if(res.code == 200){
  132. layer.msg(res.msg,{icon:1,time:1500,shade: 0.1},function(index){
  133. layer.close(index);
  134. $(obj).parents("tr").remove();
  135. });
  136. }else if(res.code == 100){
  137. wk.error(res.msg,2,'');
  138. }
  139. });
  140. })
  141. }
  142. </script>
  143. </body>
  144. </html>