Переглянути джерело

增加超级管理员端设置项目信息

Minho 7 роки тому
батько
коміт
7aead382ad
2 змінених файлів з 81 додано та 3 видалено
  1. 33 2
      controllers/manager.go
  2. 48 1
      views/manager/edit_book.tpl

+ 33 - 2
controllers/manager.go

@@ -326,6 +326,12 @@ func (c *ManagerController) EditBook() {
 		commentStatus := c.GetString("comment_status")
 		tag := strings.TrimSpace(c.GetString("label"))
 		orderIndex, _ := c.GetInt("order_index", 0)
+		isDownload := strings.TrimSpace(c.GetString("is_download")) == "on"
+		enableShare := strings.TrimSpace(c.GetString("enable_share")) == "on"
+		isUseFirstDocument :=  strings.TrimSpace(c.GetString("is_use_first_document")) == "on"
+		autoRelease := strings.TrimSpace(c.GetString("auto_release")) == "on"
+		publisher := strings.TrimSpace(c.GetString("publisher"))
+		historyCount,_ := c.GetInt("history_count",0)
 
 		if strings.Count(description, "") > 500 {
 			c.JsonResult(6004, "项目描述不能大于500字")
@@ -339,13 +345,35 @@ func (c *ManagerController) EditBook() {
 				c.JsonResult(6005, "最多允许添加10个标签")
 			}
 		}
-
+		book.Publisher = publisher
+		book.HistoryCount = historyCount
 		book.BookName = bookName
 		book.Description = description
 		book.CommentStatus = commentStatus
 		book.Label = tag
 		book.OrderIndex = orderIndex
 
+		if autoRelease {
+			book.AutoRelease = 1
+		} else {
+			book.AutoRelease = 0
+		}
+		if isDownload {
+			book.IsDownload = 0
+		}else{
+			book.IsDownload = 1
+		}
+		if enableShare {
+			book.IsEnableShare = 0
+		}else{
+			book.IsEnableShare = 1
+		}
+		if isUseFirstDocument {
+			book.IsUseFirstDocument = 1
+		}else{
+			book.IsUseFirstDocument = 0
+		}
+
 		if err := book.Update(); err != nil {
 			c.JsonResult(6006, "保存失败")
 		}
@@ -354,7 +382,10 @@ func (c *ManagerController) EditBook() {
 	if book.PrivateToken != "" {
 		book.PrivateToken = conf.URLFor("DocumentController.Index", ":key", book.Identify, "token", book.PrivateToken)
 	}
-	c.Data["Model"] = book
+	bookResult := models.NewBookResult()
+	bookResult.ToBookResult(*book)
+
+	c.Data["Model"] = bookResult
 }
 
 // 删除项目.

+ 48 - 1
views/manager/edit_book.tpl

@@ -9,6 +9,8 @@
 
     <!-- Bootstrap -->
     <link href="{{cdncss "/static/bootstrap/css/bootstrap.min.css"}}" rel="stylesheet">
+    <link href="{{cdncss "/static/bootstrap/plugins/tagsinput/bootstrap-tagsinput.css"}}" rel="stylesheet">
+    <link href="{{cdncss "/static/bootstrap/plugins/bootstrap-switch/css/bootstrap3//bootstrap-switch.min.css"}}" rel="stylesheet">
     <link href="{{cdncss "/static/font-awesome/css/font-awesome.min.css"}}" rel="stylesheet">
     <link href="{{cdncss "/static/webuploader/webuploader.css"}}" rel="stylesheet">
     <link href="{{cdncss "/static/cropper/2.3.4/cropper.min.css"}}" rel="stylesheet">
@@ -51,7 +53,7 @@
                 </div>
                 <div class="box-body" style="padding-right: 200px;">
                     <div class="form-left">
-                        <form method="post" id="bookEditForm" action="{{urlfor "ManagerController.EditBook"}}">
+                        <form method="post" id="bookEditForm" action="{{urlfor "ManagerController.EditBook" ":key" .Model.Identify}}">
                             <input type="hidden" name="identify" value="{{.Model.Identify}}">
                             <div class="form-group">
                                 <label>标题</label>
@@ -61,6 +63,16 @@
                                 <label>标识</label>
                                 <input type="text" class="form-control" value="{{urlfor "DocumentController.Index" ":key" .Model.Identify}}" disabled placeholder="项目标识">
                             </div>
+                            <div class="form-group">
+                                <label>历史记录数量</label>
+                                <input type="text" class="form-control" name="history_count" value="{{.Model.HistoryCount}}" placeholder="历史记录数量">
+                                <p class="text">当开启文档历史时,该值会限制每个文档保存的历史数量</p>
+                            </div>
+                            <div class="form-group">
+                                <label>公司标识</label>
+                                <input type="text" class="form-control" name="publisher" value="{{.Model.Publisher}}" placeholder="公司名称">
+                                <p class="text">导出文档PDF文档时显示的页脚</p>
+                            </div>
                             <div class="form-group">
                                 <label>排序</label>
                                 <input type="number" min="0" class="form-control" value="{{.Model.OrderIndex}}" name="order_index" placeholder="项目排序">
@@ -108,6 +120,38 @@
                                 </div>
                             </div>
                             {{end}}
+                            <div class="form-group">
+                                <label for="autoRelease">自动发布</label>
+                                <div class="controls">
+                                    <div class="switch switch-small" data-on="primary" data-off="info">
+                                        <input type="checkbox" id="autoRelease" name="auto_release"{{if .Model.AutoRelease }} checked{{end}} data-size="small">
+                                    </div>
+                                </div>
+                            </div>
+                            <div class="form-group">
+                                <label for="autoRelease">开启导出</label>
+                                <div class="controls">
+                                    <div class="switch switch-small" data-on="primary" data-off="info">
+                                        <input type="checkbox" id="isDownload" name="is_download"{{if .Model.IsDownload }} checked{{end}} data-size="small" placeholder="开启导出">
+                                    </div>
+                                </div>
+                            </div>
+                            <div class="form-group">
+                                <label for="autoRelease">开启分享</label>
+                                <div class="controls">
+                                    <div class="switch switch-small" data-on="primary" data-off="info">
+                                        <input type="checkbox" id="enableShare" name="enable_share"{{if .Model.IsEnableShare }} checked{{end}} data-size="small" placeholder="开启分享">
+                                    </div>
+                                </div>
+                            </div>
+                            <div class="form-group">
+                                <label for="autoRelease">设置第一篇文档为默认首页</label>
+                                <div class="controls">
+                                    <div class="switch switch-small" data-on="primary" data-off="info">
+                                        <input type="checkbox" id="is_use_first_document" name="is_use_first_document"{{if .Model.IsUseFirstDocument }} checked{{end}} data-size="small" placeholder="设置第一篇文档为默认首页">
+                                    </div>
+                                </div>
+                            </div>
                             <div class="form-group">
                                 <button type="submit" id="btnSaveBookInfo" class="btn btn-success" data-loading-text="保存中...">保存修改</button>
                                 <span id="form-error-message" class="error-message"></span>
@@ -220,9 +264,12 @@
 <script src="{{cdnjs "/static/webuploader/webuploader.min.js"}}" type="text/javascript"></script>
 <script src="{{cdnjs "/static/cropper/2.3.4/cropper.min.js"}}" type="text/javascript"></script>
 <script src="{{cdnjs "/static/js/jquery.form.js"}}" type="text/javascript"></script>
+<script src="{{cdnjs "/static/bootstrap/plugins/tagsinput/bootstrap-tagsinput.min.js"}}" type="text/javascript"></script>
+<script src="{{cdnjs "/static/bootstrap/plugins/bootstrap-switch/js/bootstrap-switch.min.js"}}" type="text/javascript"></script>
 <script src="{{cdnjs "/static/js/main.js"}}" type="text/javascript"></script>
 <script type="text/javascript">
     $(function () {
+        $("#autoRelease,#enableShare,#isDownload,#is_use_first_document").bootstrapSwitch();
         $("#upload-logo-panel").on("hidden.bs.modal",function () {
             $("#upload-logo-panel").find(".modal-body").html(window.modalHtml);
         }).on("show.bs.modal",function () {