history.tpl 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <!DOCTYPE html>
  2. <html lang="zh-cn">
  3. <head>
  4. <meta charset="utf-8">
  5. <link rel="shortcut icon" href="{{cdnimg "/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>{{i18n .Lang "doc.his_ver"}} - 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">{{i18n .Lang "doc.update_time"}}</td>
  33. <td class="col-sm-2">{{i18n .Lang "doc.updater"}}</td>
  34. <td class="col-sm=2">{{i18n .Lang "doc.version"}}</td>
  35. <td class="col-sm-2">{{i18n .Lang "doc.operation"}}</td>
  36. </tr>
  37. </thead>
  38. <tbody>
  39. {{range $index,$item := .List}}
  40. <tr>
  41. <td>{{$item.HistoryId}}</td>
  42. <td>{{date_format $item.ModifyTime "2006-01-02 15:04:05"}}</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="{{i18n $.Lang "message.processing"}}">
  47. {{i18n $.Lang "doc.delete"}}
  48. </button>
  49. <button class="btn btn-success btn-sm restore-btn" data-id="{{$item.HistoryId}}" data-loading-text="{{i18n $.Lang "message.processing"}}">
  50. {{i18n $.Lang "doc.recover"}}
  51. </button>
  52. {{if eq $.Model.Editor "markdown"}}
  53. <button class="btn btn-success btn-sm compare-btn" data-id="{{$item.HistoryId}}">
  54. {{i18n $.Lang "doc.merge"}}
  55. </button>
  56. {{end}}
  57. </td>
  58. </tr>
  59. {{else}}
  60. <tr>
  61. <td colspan="6" class="text-center">暂无数据</td>
  62. </tr>
  63. {{end}}
  64. </tbody>
  65. </table>
  66. </div>
  67. <nav>
  68. {{.PageHtml}}
  69. </nav>
  70. </div>
  71. <!-- Include all compiled plugins (below), or include individual files as needed -->
  72. <script src="{{cdnjs "/static/bootstrap/js/bootstrap.min.js"}}"></script>
  73. <script src="{{cdnjs "/static/layer/layer.js"}}" type="text/javascript" ></script>
  74. <script type="text/javascript">
  75. $(function () {
  76. $(".delete-btn").on("click",function () {
  77. var id = $(this).attr('data-id');
  78. var $btn = $(this).button('loading');
  79. var $then = $(this);
  80. if(!id){
  81. layer.msg('{{i18n .Lang "message.param_error"}}');
  82. }else{
  83. $.ajax({
  84. url : "{{urlfor "DocumentController.DeleteHistory"}}",
  85. type : "post",
  86. dataType : "json",
  87. data : { "identify" : "{{.Model.Identify}}","doc_id" : "{{.Document.DocumentId}}" ,"history_id" : id },
  88. success :function (res) {
  89. if(res.errcode === 0){
  90. $then.parents('tr').remove().empty();
  91. }else{
  92. layer.msg(res.message);
  93. }
  94. },
  95. error : function () {
  96. $btn.button('reset');
  97. }
  98. })
  99. }
  100. });
  101. $(".restore-btn").on("click",function () {
  102. var id = $(this).attr('data-id');
  103. var $btn = $(this).button('loading');
  104. var $then = $(this);
  105. var index = parent.layer.getFrameIndex(window.name);
  106. if(!id){
  107. layer.msg('{{i18n .Lang "message.param_error"}}');
  108. }else{
  109. $.ajax({
  110. url : "{{urlfor "DocumentController.RestoreHistory"}}",
  111. type : "post",
  112. dataType : "json",
  113. data : { "identify" : "{{.Model.Identify}}","doc_id" : "{{.Document.DocumentId}}" ,"history_id" : id },
  114. success :function (res) {
  115. if(res.errcode === 0){
  116. var $node = { "node" : { "id" : res.data.doc_id}};
  117. parent.loadDocument($node);
  118. parent.layer.close(index);
  119. }else{
  120. layer.msg(res.message);
  121. }
  122. },
  123. error : function () {
  124. $btn.button('reset');
  125. }
  126. })
  127. }
  128. });
  129. $(".compare-btn").on("click",function () {
  130. var historyId = $(this).attr("data-id");
  131. window.compareIndex = window.top.layer.open({
  132. type: 2,
  133. title: '{{i18n .Lang "doc.comparison_title"}}',
  134. shade: 0.8,
  135. area: ['380px', '90%'],
  136. content: "{{urlfor "DocumentController.Compare" ":key" .Model.Identify ":id" ""}}" + historyId
  137. });
  138. window.top.layer.full(window.compareIndex);
  139. });
  140. });
  141. </script>
  142. </body>
  143. </html>