From 7964e66d43d66208bd8bc293760e3be3d50a363c Mon Sep 17 00:00:00 2001 From: yangjian Date: Tue, 15 Dec 2020 20:48:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=96=87=E6=A1=A3=E5=8F=AF?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=98=BE=E7=A4=BA=E4=B8=8B=E7=BA=A7=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app_doc/models.py | 1 + app_doc/views.py | 16 ++++++++++++++-- template/app_doc/doc.html | 12 ++++++++++++ template/app_doc/docs_base.html | 4 ++++ template/app_doc/editor/create_doc.html | 20 ++++++++++++++++++++ template/app_doc/editor/modify_doc.html | 19 +++++++++++++++++++ 6 files changed, 70 insertions(+), 2 deletions(-) diff --git a/app_doc/models.py b/app_doc/models.py index 2e520e1..1262f94 100644 --- a/app_doc/models.py +++ b/app_doc/models.py @@ -74,6 +74,7 @@ class Doc(models.Model): # 编辑器模式:1表示Editormd编辑器,2表示Vditor编辑器,3表示iceEditor编辑器 editor_mode = models.IntegerField(default=1,verbose_name='编辑器模式') open_children = models.BooleanField(default=False,verbose_name="展开下级目录") + show_children = models.BooleanField(verbose_name="显示下级文档",default=False) def __str__(self): return self.name diff --git a/app_doc/views.py b/app_doc/views.py index 584fb1c..e298bd6 100644 --- a/app_doc/views.py +++ b/app_doc/views.py @@ -911,10 +911,15 @@ def create_doc(request): sort = request.POST.get('sort','') # 文档排序 status = request.POST.get('status',1) # 文档状态 open_children = request.POST.get('open_children', False) # 展示下级目录 + show_children = request.POST.get('show_children', False) # 展示下级目录 if open_children == 'true': open_children = True else: open_children = False + if show_children == 'true': + show_children = True + else: + show_children = False if project != '' and doc_name != '' and project != '-1': # 验证请求者是否有文集的权限 check_project = Project.objects.filter(id=project,create_user=request.user) @@ -935,7 +940,8 @@ def create_doc(request): create_user=request.user, status = status, editor_mode = editor_mode, - open_children = open_children + open_children = open_children, + show_children = show_children ) # 设置文档标签 for t in doc_tags.split(","): @@ -1012,10 +1018,15 @@ def modify_doc(request,doc_id): sort = request.POST.get('sort', '') # 文档排序 status = request.POST.get('status',1) # 文档状态 open_children = request.POST.get('open_children',False) # 展示下级目录 + show_children = request.POST.get('show_children', False) # 展示下级目录 if open_children == 'true': open_children = True else: open_children = False + if show_children == 'true': + show_children = True + else: + show_children = False if doc_id != '' and project_id != '' and doc_name != '' and project_id != '-1': doc = Doc.objects.get(id=doc_id) @@ -1049,7 +1060,8 @@ def modify_doc(request,doc_id): modify_time = datetime.datetime.now(), status = status, editor_mode = editor_mode, - open_children = open_children + open_children = open_children, + show_children = show_children ) # 更新文档标签 doc_tag_list = doc_tags.split(",") if doc_tags != "" else [] diff --git a/template/app_doc/doc.html b/template/app_doc/doc.html index 1fe089e..a3e3651 100644 --- a/template/app_doc/doc.html +++ b/template/app_doc/doc.html @@ -46,6 +46,18 @@ {% else %} {% endif %} + + +{% endblock %} + +{% block children_content %} + {% if doc.show_children %} + {% load doc_filter %} + {% for children in doc.id|get_next_doc %} +
  • {{ children.name }}
  • + {% endfor %} + {% endif %} + {% endblock %} {% block doc_bottom_block %} diff --git a/template/app_doc/docs_base.html b/template/app_doc/docs_base.html index f37d4aa..b66ba09 100644 --- a/template/app_doc/docs_base.html +++ b/template/app_doc/docs_base.html @@ -195,6 +195,10 @@ {% endblock %} +
    + {% block children_content %} + {% endblock %} +

    diff --git a/template/app_doc/editor/create_doc.html b/template/app_doc/editor/create_doc.html index 79c771f..93125b5 100644 --- a/template/app_doc/editor/create_doc.html +++ b/template/app_doc/editor/create_doc.html @@ -116,6 +116,25 @@ + +
    +
    +

    文档内显示下级文档

    +
    +
    + {%if doc.show_children %} + + + {% else %} + + + {% endif %} +
    +
    +
    +
    + +
    @@ -270,6 +289,7 @@ 'sort':$("#sort").val(), 'status':status, 'open_children':$('input:radio[name="open-children"]:checked').val(), + 'show_children':$('input:radio[name="show-children"]:checked').val(), } // console.log(data) if(data.doc_name == ""){ diff --git a/template/app_doc/editor/modify_doc.html b/template/app_doc/editor/modify_doc.html index eb1b034..a550e13 100644 --- a/template/app_doc/editor/modify_doc.html +++ b/template/app_doc/editor/modify_doc.html @@ -125,6 +125,24 @@
    + + +
    +
    +

    文档内显示下级文档

    +
    +
    + {%if doc.show_children %} + + + {% else %} + + + {% endif %} +
    +
    +
    +
    @@ -265,6 +283,7 @@ 'sort':$("#sort").val(), 'status':status, 'open_children':$('input:radio[name="open-children"]:checked').val(), + 'show_children':$('input:radio[name="show-children"]:checked').val(), } $.post("{% url 'modify_doc' doc_id=doc.id %}",data,function(r){ layer.closeAll("loading");