history.tpl 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <!DOCTYPE html>
  2. <html lang="zh-cn">
  3. <head>
  4. <meta charset="utf-8">
  5. <link rel="shortcut icon" href="/favicon.ico">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  7. <meta name="renderer" content="webkit" />
  8. <meta name="viewport" content="width=device-width, initial-scale=1">
  9. <meta name="author" content="SmartWiki" />
  10. <title>历史版本 - Powered by MinDoc</title>
  11. <!-- Bootstrap -->
  12. <link href="{{cdncss "/static/bootstrap/css/bootstrap.min.css"}}" rel="stylesheet">
  13. <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  14. <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  15. <!--[if lt IE 9]>
  16. <script src="/static/html5shiv/3.7.3/html5shiv.min.js"></script>
  17. <script src="/static/respond.js/1.4.2/respond.min.js"></script>
  18. <![endif]-->
  19. <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
  20. <script src="{{cdnjs "/static/jquery/1.12.4/jquery.min.js"}}"></script>
  21. <style type="text/css">
  22. .container{margin: 5px auto;}
  23. </style>
  24. </head>
  25. <body>
  26. <div class="container">
  27. <div class="table-responsive">
  28. <table class="table table-hover">
  29. <thead>
  30. <tr>
  31. <td>#</td>
  32. <td class="col-sm-6">修改时间</td>
  33. <td class="col-sm-2">修改人</td>
  34. <td class="col-sm=2">版本</td>
  35. <td class="col-sm-2">操作</td>
  36. </tr>
  37. </thead>
  38. <tbody>
  39. {{range $index,$item := .List}}
  40. <tr>
  41. <td>{{$item.HistoryId}}</td>
  42. <td>{{date $item.ModifyTime "Y-m-d H:i:s"}}</td>
  43. <td>{{$item.ModifyName}}</td>
  44. <td>{{$item.Version}}</td>
  45. <td>
  46. <button class="btn btn-danger btn-sm delete-btn" data-id="{{$item.HistoryId}}" data-loading-text="删除中...">
  47. 删除
  48. </button>
  49. <button class="btn btn-success btn-sm restore-btn" data-id="{{$item.HistoryId}}" data-loading-text="恢复中...">
  50. 恢复
  51. </button>
  52. </td>
  53. </tr>
  54. {{else}}
  55. <tr>
  56. <td colspan="6" class="text-center">暂无数据</td>
  57. </tr>
  58. {{end}}
  59. </tbody>
  60. </table>
  61. </div>
  62. <nav>
  63. {{.PageHtml}}
  64. </nav>
  65. </div>
  66. <!-- Include all compiled plugins (below), or include individual files as needed -->
  67. <script src="{{cdnjs "/static/bootstrap/js/bootstrap.min.js"}}"></script>
  68. <script src="{{cdnjs "/static/layer/layer.js"}}" type="text/javascript" ></script>
  69. <script type="text/javascript">
  70. $(function () {
  71. $(".delete-btn").on("click",function () {
  72. var id = $(this).attr('data-id');
  73. var $btn = $(this).button('loading');
  74. var $then = $(this);
  75. if(!id){
  76. layer.msg('参数错误');
  77. }else{
  78. $.ajax({
  79. url : "{{urlfor "DocumentController.DeleteHistory"}}",
  80. type : "post",
  81. dataType : "json",
  82. data : { "identify" : "{{.Model.Identify}}","doc_id" : "{{.Document.DocumentId}}" ,"history_id" : id },
  83. success :function (res) {
  84. if(res.errcode === 0){
  85. $then.parents('tr').remove().empty();
  86. }else{
  87. layer.msg(res.message);
  88. }
  89. },
  90. error : function () {
  91. $btn.button('reset');
  92. }
  93. })
  94. }
  95. });
  96. $(".restore-btn").on("click",function () {
  97. var id = $(this).attr('data-id');
  98. var $btn = $(this).button('loading');
  99. var $then = $(this);
  100. var index = parent.layer.getFrameIndex(window.name);
  101. if(!id){
  102. layer.msg('参数错误');
  103. }else{
  104. $.ajax({
  105. url : "{{urlfor "DocumentController.RestoreHistory"}}",
  106. type : "post",
  107. dataType : "json",
  108. data : { "identify" : "{{.Model.Identify}}","doc_id" : "{{.Document.DocumentId}}" ,"history_id" : id },
  109. success :function (res) {
  110. if(res.errcode === 0){
  111. var $node = { "node" : { "id" : res.data.doc_id}};
  112. parent.loadDocument($node);
  113. parent.layer.close(index);
  114. }else{
  115. layer.msg(res.message);
  116. }
  117. },
  118. error : function () {
  119. $btn.button('reset');
  120. }
  121. })
  122. }
  123. });
  124. });
  125. </script>
  126. </body>
  127. </html>