新增文档可配置显示下级文档列表

This commit is contained in:
yangjian 2020-12-15 20:48:47 +08:00
parent 958d4c39b6
commit 7964e66d43
6 changed files with 70 additions and 2 deletions

View File

@ -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

View File

@ -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 []

View File

@ -46,6 +46,18 @@
{% else %}
<textarea style="display: none;">{{ doc.pre_content }}</textarea>
{% endif %}
{% endblock %}
{% block children_content %}
{% if doc.show_children %}
{% load doc_filter %}
{% for children in doc.id|get_next_doc %}
<li style="list-style: disc;font-size: 15px;"><a href="{% url 'doc' pro_id=pro_id doc_id=children.id %}" title="{{children.name}}">{{ children.name }}</a></li>
{% endfor %}
{% endif %}
{% endblock %}
{% block doc_bottom_block %}

View File

@ -195,6 +195,10 @@
{% endblock %}
</div>
<!-- 正文结束 -->
<div class="markdown-body" style="padding-left: 20px;">
{% block children_content %}
{% endblock %}
</div>
</div>
<hr>
<!-- 分享栏 -->

View File

@ -116,6 +116,25 @@
</div>
</div>
<!-- 显示下级文档 -->
<div class="layui-collapse" style="margin-top: 10px;margin-bottom: 10px;">
<div class="layui-colla-item">
<h2 class="layui-colla-title">文档内显示下级文档</h2>
<div class="layui-colla-content layui-show">
<div class="layui-row layui-col-space5" style="padding: 5px;background-color: #fff;">
{%if doc.show_children %}
<input type="radio" name="show-children" value="true" title="显示" checked>
<input type="radio" name="show-children" value="false" title="隐藏">
{% else %}
<input type="radio" name="show-children" value="true" title="显示">
<input type="radio" name="show-children" value="false" title="隐藏" checked>
{% endif %}
</div>
</div>
</div>
</div>
<!-- 发布按钮 -->
<div class="layui-collapse" style="margin-top: 10px;margin-bottom: 10px;">
<div class="layui-colla-item">
@ -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 == ""){

View File

@ -125,6 +125,24 @@
</div>
</div>
</div>
<!-- 显示下级文档 -->
<div class="layui-collapse" style="margin-top: 10px;margin-bottom: 10px;">
<div class="layui-colla-item">
<h2 class="layui-colla-title">文档内显示下级文档</h2>
<div class="layui-colla-content layui-show">
<div class="layui-row layui-col-space5" style="padding: 5px;background-color: #fff;">
{%if doc.show_children %}
<input type="radio" name="show-children" value="true" title="显示" checked>
<input type="radio" name="show-children" value="false" title="隐藏">
{% else %}
<input type="radio" name="show-children" value="true" title="显示">
<input type="radio" name="show-children" value="false" title="隐藏" checked>
{% endif %}
</div>
</div>
</div>
</div>
<!-- 发布按钮 -->
<div class="layui-collapse" style="margin-top: 10px;margin-bottom: 10px;">
@ -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");