mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-09-19 10:08:03 +08:00
实现文档历史功能
This commit is contained in:
134
views/document/history.tpl
Normal file
134
views/document/history.tpl
Normal file
@@ -0,0 +1,134 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-cn">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="shortcut icon" href="/favicon.ico">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||
<meta name="renderer" content="webkit" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="author" content="SmartWiki" />
|
||||
<title>历史版本 - Powered by MinDoc</title>
|
||||
|
||||
<!-- Bootstrap -->
|
||||
<link href="{{cdncss "/static/bootstrap/css/bootstrap.min.css"}}" rel="stylesheet">
|
||||
|
||||
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
||||
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="/static/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="/static/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
|
||||
<script src="{{cdnjs "/static/jquery/1.12.4/jquery.min.js"}}"></script>
|
||||
<style type="text/css">
|
||||
.container{margin: 5px auto;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>#</td>
|
||||
<td class="col-sm-6">修改时间</td>
|
||||
<td class="col-sm-2">修改人</td>
|
||||
<td class="col-sm=2">版本</td>
|
||||
<td class="col-sm-2">操作</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range $index,$item := .List}}
|
||||
<tr>
|
||||
<td>{{$item.HistoryId}}</td>
|
||||
<td>{{date $item.ModifyTime "Y-m-d H:i:s"}}</td>
|
||||
<td>{{$item.ModifyName}}</td>
|
||||
<td>{{$item.Version}}</td>
|
||||
<td>
|
||||
<button class="btn btn-danger btn-sm delete-btn" data-id="{{$item.HistoryId}}" data-loading-text="删除中...">
|
||||
删除
|
||||
</button>
|
||||
<button class="btn btn-success btn-sm restore-btn" data-id="{{$item.HistoryId}}" data-loading-text="恢复中...">
|
||||
恢复
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{{else}}
|
||||
<tr>
|
||||
<td colspan="6" class="text-center">暂无数据</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<nav>
|
||||
{{.PageHtml}}
|
||||
</nav>
|
||||
</div>
|
||||
<!-- Include all compiled plugins (below), or include individual files as needed -->
|
||||
<script src="{{cdnjs "/static/bootstrap/js/bootstrap.min.js"}}"></script>
|
||||
<script src="{{cdnjs "/static/layer/layer.js"}}" type="text/javascript" ></script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
$(".delete-btn").on("click",function () {
|
||||
var id = $(this).attr('data-id');
|
||||
var $btn = $(this).button('loading');
|
||||
var $then = $(this);
|
||||
|
||||
if(!id){
|
||||
layer.msg('参数错误');
|
||||
}else{
|
||||
$.ajax({
|
||||
url : "{{urlfor "DocumentController.DeleteHistory"}}",
|
||||
type : "post",
|
||||
dataType : "json",
|
||||
data : { "identify" : "{{.Model.Identify}}","doc_id" : "{{.Document.DocumentId}}" ,"history_id" : id },
|
||||
success :function (res) {
|
||||
if(res.errcode === 0){
|
||||
$then.parents('tr').remove().empty();
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
},
|
||||
error : function () {
|
||||
$btn.button('reset');
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
$(".restore-btn").on("click",function () {
|
||||
var id = $(this).attr('data-id');
|
||||
var $btn = $(this).button('loading');
|
||||
var $then = $(this);
|
||||
var index = parent.layer.getFrameIndex(window.name);
|
||||
|
||||
if(!id){
|
||||
layer.msg('参数错误');
|
||||
}else{
|
||||
$.ajax({
|
||||
url : "{{urlfor "DocumentController.RestoreHistory"}}",
|
||||
type : "post",
|
||||
dataType : "json",
|
||||
data : { "identify" : "{{.Model.Identify}}","doc_id" : "{{.Document.DocumentId}}" ,"history_id" : id },
|
||||
success :function (res) {
|
||||
if(res.errcode === 0){
|
||||
var $node = { "node" : { "id" : res.data.doc_id}};
|
||||
|
||||
parent.loadDocument($node);
|
||||
parent.layer.close(index);
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
},
|
||||
error : function () {
|
||||
$btn.button('reset');
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -19,7 +19,8 @@
|
||||
window.releaseURL = "{{urlfor "BookController.Release" ":key" .Model.Identify}}";
|
||||
window.sortURL = "{{urlfor "BookController.SaveSort" ":key" .Model.Identify}}";
|
||||
window.baiduMapKey = "{{.BaiDuMapKey}}";
|
||||
|
||||
window.historyURL = "{{urlfor "DocumentController.History"}}";
|
||||
window.removeAttachURL = "{{urlfor "DocumentController.RemoveAttachment"}}";
|
||||
window.vueApp = null;
|
||||
</script>
|
||||
<!-- Bootstrap -->
|
||||
@@ -190,54 +191,10 @@
|
||||
<script src="{{cdnjs "/static/wangEditor/plugins/save-menu.js"}}" type="text/javascript"></script>
|
||||
<script src="{{cdnjs "/static/wangEditor/plugins/release-menu.js"}}" type="text/javascript"></script>
|
||||
<script src="{{cdnjs "/static/wangEditor/plugins/attach-menu.js"}}" type="text/javascript"></script>
|
||||
<script src="{{cdnjs "/static/wangEditor/plugins/history-menu.js"}}" type="text/javascript"></script>
|
||||
<script src="{{cdnjs "/static/layer/layer.js"}}" type="text/javascript" ></script>
|
||||
<script src="{{cdnjs "/static/to-markdown/dist/to-markdown.js"}}" type="text/javascript"></script>
|
||||
<script src="{{cdnjs "/static/js/jquery.form.js"}}" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
window.vueApp = new Vue({
|
||||
el : "#attachList",
|
||||
data : {
|
||||
lists : []
|
||||
},
|
||||
delimiters : ['${','}'],
|
||||
methods : {
|
||||
removeAttach : function ($attach_id) {
|
||||
var $this = this;
|
||||
var item = $this.lists.filter(function ($item) {
|
||||
return $item.attachment_id == $attach_id;
|
||||
});
|
||||
|
||||
if(item && item[0].hasOwnProperty("state")){
|
||||
$this.lists = $this.lists.filter(function ($item) {
|
||||
return $item.attachment_id != $attach_id;
|
||||
});
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
url : "{{urlfor "DocumentController.RemoveAttachment"}}",
|
||||
type : "post",
|
||||
data : { "attach_id" : $attach_id},
|
||||
success : function (res) {
|
||||
console.log(res);
|
||||
if(res.errcode === 0){
|
||||
$this.lists = $this.lists.filter(function ($item) {
|
||||
return $item.attachment_id != $attach_id;
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
watch : {
|
||||
lists : function ($lists) {
|
||||
$("#attachInfo").text(" " + $lists.length + " 个附件")
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
<script src="/static/js/editor.js" type="text/javascript"></script>
|
||||
<script src="/static/js/html-editor.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
|
@@ -18,6 +18,7 @@
|
||||
window.releaseURL = "{{urlfor "BookController.Release" ":key" .Model.Identify}}";
|
||||
window.sortURL = "{{urlfor "BookController.SaveSort" ":key" .Model.Identify}}";
|
||||
window.historyURL = "{{urlfor "DocumentController.History"}}";
|
||||
window.removeAttachURL = "{{urlfor "DocumentController.RemoveAttachment"}}";
|
||||
</script>
|
||||
<!-- Bootstrap -->
|
||||
<link href="{{cdncss "/static/bootstrap/css/bootstrap.min.css"}}" rel="stylesheet">
|
||||
@@ -214,31 +215,8 @@
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title">文档历史记录</h4>
|
||||
</div>
|
||||
<div class="modal-body text-center">
|
||||
<template v-if="lists.length <= 0">
|
||||
暂无数据
|
||||
</template>
|
||||
<template v-else>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th><th>名称</th><th>修改时间</th><th>修改人</th><th>版本</th><th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template v-for="item in lists">
|
||||
<tr>
|
||||
<td>${item.history_id}</td>
|
||||
<td>${item.action_name}</td>
|
||||
<td>${item.modify_time}</td>
|
||||
<td>${item.modify_name}</td>
|
||||
<td>${item.version}</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</template>
|
||||
</tbody>
|
||||
</table>
|
||||
</template>
|
||||
<div class="modal-body text-center" id="historyList">
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
|
||||
@@ -256,48 +234,7 @@
|
||||
<script src="{{cdnjs "/static/layer/layer.js"}}" type="text/javascript" ></script>
|
||||
<script src="{{cdnjs "/static/js/jquery.form.js"}}" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
window.vueApp = new Vue({
|
||||
el : "#attachList",
|
||||
data : {
|
||||
lists : []
|
||||
},
|
||||
delimiters : ['${','}'],
|
||||
methods : {
|
||||
removeAttach : function ($attach_id) {
|
||||
var $this = this;
|
||||
var item = $this.lists.filter(function ($item) {
|
||||
return $item.attachment_id == $attach_id;
|
||||
});
|
||||
|
||||
if(item && item[0].hasOwnProperty("state")){
|
||||
$this.lists = $this.lists.filter(function ($item) {
|
||||
return $item.attachment_id != $attach_id;
|
||||
});
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
url : "{{urlfor "DocumentController.RemoveAttachment"}}",
|
||||
type : "post",
|
||||
data : { "attach_id" : $attach_id},
|
||||
success : function (res) {
|
||||
console.log(res);
|
||||
if(res.errcode === 0){
|
||||
$this.lists = $this.lists.filter(function ($item) {
|
||||
return $item.attachment_id != $attach_id;
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
watch : {
|
||||
lists : function ($lists) {
|
||||
$("#attachInfo").text(" " + $lists.length + " 个附件")
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
<script src="/static/js/editor.js" type="text/javascript"></script>
|
||||
|
Reference in New Issue
Block a user