MrDoc/template/app_doc/manage_project.html
2020-05-04 21:26:07 +08:00

271 lines
12 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{% extends 'app_doc/manage_base.html' %}
{% load staticfiles %}
{% block title %}文集管理{% endblock %}
{% block content %}
<div class="layui-card-header" style="margin-bottom: 10px;">
<div class="layui-row">
<span style="font-size:18px;">文集管理
</span>
</div>
</div>
<div class="layui-row">
<form action="{% url 'manage_project' %}" method="get">
<div class="layui-form-item">
<div class="layui-input-inline">
<input type="text" name="kw" id="kw" placeholder="输入文集内容" autocomplete="off" class="layui-input">
</div>
<button class="layui-btn layui-btn-normal layui-btn-sm" type="submit"><i class="layui-icon layui-icon-search" ></i>搜索</button>
<button class="layui-btn layui-btn-normal layui-btn-sm" onclick="createProject()" type="button"><i class="layui-icon layui-icon-addition"></i>新建文集</button>
<a class="layui-btn layui-btn-normal layui-btn-sm" href="{% url 'manage_pro_colla_self' %}"><i class="layui-icon layui-icon-group"></i>我协作的文集</a>
</div>
</form>
</div>
<div class="layui-row">
<table class="layui-table" id="doctemp-list" lay-skin="" lay-size="" lay-even>
<colgroup>
<col width="100">
<col width="200">
<col width="45">
<col width="100">
<col width="50">
<col width="100">
<col width="60">
<col width="150">
</colgroup>
<thead>
<tr>
<th>文集名称</th>
<th>文集简介</th>
<th>文档数量</th>
<th>创建时间</th>
<th>前台下载</th>
<th>阅读权限</th>
<th>协作人数</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{% for pro in pros %}
<tr>
<td><a href="{% url 'pro_index' pro_id=pro.id %}" target="_blank">{{ pro.name }}</a></td>
<td>{{ pro.intro }}</td>
{% load project_filter %}
<td>{{ pro.id | get_doc_count }}</td>
<td>{{ pro.create_time }}</td>
<td>
{% if pro.id|report_status_epub == 1 or pro.id|report_status_pdf == 1 %}
<span style="color: #01AAED;">允许</span> <a href="{% url 'modify_pro_download' pro.id %}" title="修改前台下载"><i class="layui-icon layui-icon-edit"></i></a>
{% else %}
<span style="color: hotpink;">禁止</span> <a href="{% url 'modify_pro_download' pro.id %}" title="修改前台下载"><i class="layui-icon layui-icon-edit"></i></a>
{% endif %}
</td>
<td>
<div class="layui-input-inline">
{% if pro.role == 0 %}
<i class="layui-icon layui-icon-circle-dot" style="color: #01AAED;"></i> 公开 <a href="{% url 'modify_pro_role' pro.id %}" title="修改文集权限"><i class="layui-icon layui-icon-edit"></i></a>
{% elif pro.role == 1 %}
<i class="layui-icon layui-icon-password"></i> 私密 <a href="{% url 'modify_pro_role' pro.id %}" title="修改文集权限"><i class="layui-icon layui-icon-edit"></i></a>
{% elif pro.role == 2 %}
<i class="layui-icon layui-icon-group"></i> 指定用户 <a href="{% url 'modify_pro_role' pro.id %}" title="修改文集权限"><i class="layui-icon layui-icon-edit"></i></a>
{% elif pro.role == 3 %}
<i class="layui-icon layui-icon-key"></i> 访问码 <a href="{% url 'modify_pro_role' pro.id %}" title="修改文集权限"><i class="layui-icon layui-icon-edit"></i></a>
{% endif %}
</div>
</td>
<td>{{ pro.id | project_collaborator_cnt }} <a href="{% url 'manage_pro_colla' pro.id %}" title="管理文集协作"><i class="layui-icon layui-icon-edit"></i></a></td>
<td>
<a href="javascript:void(0);" onclick="modifyProject('{{pro.id}}','{{pro.name}}','{{pro.intro}}')" class="layui-btn layui-btn-xs layui-btn-normal">
<i class="layui-icon layui-icon-edit"></i>修改
</a>
<a href="javascript:void(0);" onclick="delProject('{{pro.id}}');" class="layui-btn layui-btn-xs layui-btn-normal">
<i class="layui-icon layui-icon-delete"></i>删除
</a>
<a href="javascript:void(0);" onclick="reportMd('{{pro.id}}')" class="layui-btn layui-btn-xs layui-btn-normal">
<i class="layui-icon layui-icon-export"></i>导出
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- 分页 -->
<div class="layui-row">
<div class="layui-box layui-laypage layui-laypage-default">
<!-- 上一页 -->
{% if pros.has_previous %}
<a href="?page={{ pros.previous_page_number }}&kw={{pros.kw}}" class="layui-btn layui-btn-xs layui-btn-normal">上一页</a>
{% else %}
<a href="javascript:;" class="layui-btn layui-btn-xs layui-btn-disabled">上一页</a>
{% endif %}
<!-- 当前页 -->
<span class="layui-laypage-curr">
<em class="layui-laypage-em"></em>
<em>{{ pros.number }}/{{ pros.paginator.num_pages }}</em>
</span>
<!-- 下一页 -->
{% if pros.has_next %}
<a href="?page={{ pros.next_page_number }}&kw={{pros.kw}}" class="layui-btn layui-btn-xs layui-btn-normal">下一页</a>
{% else %}
<a class="layui-btn layui-btn-xs layui-btn-disabled">下一页</a>
{% endif %}
</div>
</div>
{% endblock %}
{% block custom_script %}
<script>
$.ajaxSetup({
data: {csrfmiddlewaretoken: '{{ csrf_token }}' },
});
//创建文集
createProject = function(){
layer.open({
type:1,
title:'新建文集',
area:'300px;',
id:'createPro',//配置ID
content:'<div style="padding: 20px;"><input class="layui-input" type="text" id="pname" style="margin-bottom:10px;" placeholder="输入文集名" required lay-verify="required"><textarea name="desc" id="desc" placeholder="输入文集简介" class="layui-textarea"></textarea></div>',
btn:['确定','取消'], //添加按钮
btnAlign:'c', //按钮居中
yes:function (index,layero) {
layer.load(1);
data = {
'pname':$("#pname").val(),
'desc':$("#desc").val(),
}
$.post("{% url 'create_project' %}",data,function(r){
layer.closeAll('loading'); //关闭loading
if(r.status){
//创建成功
window.location.reload();
//layer.close(index)
}else{
//创建失败,提示
console.log(r)
}
})
},
});
};
//修改文集
modifyProject = function(pro_id,pro_name,pro_intro){
layer.open({
type:1,
title:'修改文集',
area:'300px;',
id:'modifyPro',//配置ID
content:'<div style="padding: 20px;"><input class="layui-input" type="text" id="pname" style="margin-bottom:10px;" placeholder="输入文集名" required lay-verify="required" value="'+pro_name+'"><textarea name="desc" id="desc" placeholder="输入文集简介" class="layui-textarea">'+pro_intro+'</textarea></div>',
btn:['确定','取消'], //添加按钮
btnAlign:'c', //按钮居中
yes:function (index,layero) {
layer.load(1);
data = {
'pro_id':pro_id,
'name':$("#pname").val(),
'desc':$("#desc").val(),
}
$.post("{% url 'modify_project' %}",data,function(r){
layer.closeAll('loading'); //关闭loading
if(r.status){
//修改成功
window.location.reload();
//layer.close(index)
}else{
//修改失败,提示
// console.log(r)
layer.msg(r.data)
}
})
},
});
};
//删除文集
delProject = function(pro_id){
layer.open({
type:1,
title:'删除文集',
area:'300px;',
id:'delPro',//配置ID
content:'<div style="margin-left:10px;">警告:此操作将删除文集及文集下所有文档!</div>',
btn:['确定','取消'], //添加按钮
btnAlign:'c', //按钮居中
yes:function (index,layero) {
layer.load(1);
data = {
'pro_id':pro_id,
}
$.post("{% url 'del_project' %}",data,function(r){
layer.closeAll('loading'); //关闭loading
if(r.status){
//修改成功
window.location.reload();
//layer.close(index)
}else{
//修改失败,提示
console.log(r)
layer.msg(r.data)
}
})
},
});
}
//导出MD
reportMd = function(pro_id){
layer.open({
type:1,
title:"导出文集",
area:"300px",
id:"reportMd",
content:'<div style="margin-left:10px;">将此文集下所有文档导出为MD文件并打包</div>',
btn:['确定','取消'], //添加按钮
btnAlign:'c', //按钮居中
yes:function (index,layero) {
var load = layer.load()
data = {
'project_id':pro_id,
}
$.post("{% url 'report_md' %}",data,function(r){
layer.closeAll('loading'); //关闭loading
if(r.status){
//导出成功
//文件下载提示
downloadMd(r.data)
}else{
//导出失败,提示
// console.log(r)
layer.msg(r.data)
}
layer.close(load)
})
},
})
}
//下载文件弹出框
downloadMd = function(download_link){
layer.open({
type:1,
title:"下载导出文档",
area:"300px",
id:"downloadMd",
content:'<p style="text-align:center;color:red;">请尽快下载,避免失效!</p><br><a class="layui-btn layui-btn-fluid download-md-link" href="'+ download_link + '" download="mrdoc_report_md.zip" >点击下载文件(zip)</a>',
//btn:['确定','取消'], //添加按钮
//btnAlign:'c', //按钮居中
success: function (layero, index) {
$(layero).find('.download-md-link').click(function () {
layer.closeAll();
})
}
})
};
//修改文集权限
modifyProjectRole = function(pro_id){
layer.open({
type:1,
title:"修改文集权限",
content:$("#modify-project-role-div"),
});
};
</script>
{% endblock %}