MrDoc/template/app_doc/manage_project.html

274 lines
12 KiB
HTML
Raw Normal View History

2019-07-23 13:05:27 +08:00
{% extends 'app_doc/manage_base.html' %}
2020-10-18 08:05:41 +08:00
{% load static %}
2019-07-23 14:58:49 +08:00
{% block title %}文集管理{% endblock %}
2019-07-23 13:05:27 +08:00
{% block content %}
2020-08-30 13:51:26 +08:00
<div class="layui-card-header" style="margin-bottom: 10px;background-color: #fff;">
<div class="layui-row">
<span style="font-size:18px;">文集管理
</span>
</div>
</div>
<div class="layui-row" >
2019-07-23 22:03:51 +08:00
<form action="{% url 'manage_project' %}" method="get">
2019-07-23 13:05:27 +08:00
<div class="layui-form-item">
2019-07-23 10:57:42 +08:00
<div class="layui-input-inline">
2019-11-03 20:36:34 +08:00
<input type="text" name="kw" id="kw" placeholder="输入文集内容" autocomplete="off" class="layui-input">
2019-07-23 10:57:42 +08:00
</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>
2020-07-20 21:38:29 +08:00
<a class="layui-btn layui-btn-normal layui-btn-sm" href="{% url 'import_project' %}"><i class="layui-icon layui-icon-upload"></i>导入文集</a>
2019-07-23 10:57:42 +08:00
</div>
2019-07-23 22:03:51 +08:00
</form>
2019-07-23 10:57:42 +08:00
</div>
<div class="layui-row">
2020-08-30 13:51:26 +08:00
<table class="layui-table" id="doctemp-list" lay-skin="nob" lay-size="" lay-even>
2019-11-03 20:36:34 +08:00
<colgroup>
2020-08-30 13:51:26 +08:00
<col width="120">
<col width="200">
<col width="45">
2019-11-03 20:36:34 +08:00
<col width="100">
<col width="50">
<col width="60">
2020-08-30 13:51:26 +08:00
<!-- <col width="40"> -->
<col width="120">
2019-11-03 20:36:34 +08:00
</colgroup>
2019-07-23 13:05:27 +08:00
<thead>
<tr>
2019-07-23 14:58:49 +08:00
<th>文集名称</th>
<th>文集简介</th>
<th>文档数量</th>
2019-07-23 13:05:27 +08:00
<th>创建时间</th>
<th>协作人数</th>
2019-07-23 13:05:27 +08:00
<th>操作</th>
</tr>
</thead>
<tbody>
2020-08-30 13:51:26 +08:00
{% load project_filter %}
2019-11-03 20:36:34 +08:00
{% for pro in pros %}
2019-07-23 13:05:27 +08:00
<tr>
2020-05-04 21:26:07 +08:00
2020-08-30 13:51:26 +08:00
<td>
<img src="{% static 'icon_img/manage-pro-icon.svg' %}" height="20px" width="20px" />
<a href="{% url 'pro_index' pro_id=pro.id %}" target="_blank" title='{{pro.name}}'>{{ pro.name }}</a>
<!-- 文集阅读权限 -->
{% if pro.role == 0 %}
2020-10-18 08:05:41 +08:00
<a href="javascript:void(0);" title="公开文集"><img src="{% static 'icon_img/manage-eye-icon.svg' %}" height="14px" width="14px" /></a>
2020-08-30 13:51:26 +08:00
{% elif pro.role == 1 %}
2020-10-18 08:05:41 +08:00
<a href="javascript:void(0);" title="私密文集"><i class="layui-icon layui-icon-password"></i></a>
2020-08-30 13:51:26 +08:00
{% elif pro.role == 2 %}
2020-10-18 08:05:41 +08:00
<a href="javascript:void(0);" title="指定用户可见"><i class="layui-icon layui-icon-user"></i></a>
2020-08-30 13:51:26 +08:00
{% elif pro.role == 3 %}
2020-10-18 08:05:41 +08:00
<a href="javascript:void(0);" title="访问码可见"><i class="layui-icon layui-icon-key"></i></a>
2020-08-30 13:51:26 +08:00
{% endif %}
<!-- 文集前台下载权限 -->
{% if pro.id|report_status_epub == 1 or pro.id|report_status_pdf == 1 %}
2020-10-18 08:05:41 +08:00
<a href="javascript:void(0);" title="允许前台下载"><img src="{% static 'icon_img/manage-download-yes.svg' %}" height="14px" width="14px" /></a>
2020-08-30 13:51:26 +08:00
{% else %}
2020-10-18 08:05:41 +08:00
<a href="javascript:void(0);" title="禁止前台下载"><img src="{% static 'icon_img/manage-download-no.svg' %}" height="14px" width="14px" /></a>
2020-08-30 13:51:26 +08:00
{% endif %}
</td>
<td>{{ pro.intro }}</td>
<td>{{ pro.id | get_doc_count }}</td>
<td>{{ pro.create_time }}</td>
2020-08-07 21:36:37 +08:00
<td>{{ pro.id | project_collaborator_cnt }} <a href="{% url 'manage_pro_colla' pro.id %}" title="管理文集协作"><i class="layui-icon layui-icon-set"></i></a></td>
2020-10-18 08:05:41 +08:00
<td>
<!-- <a href="javascript:void(0);" title="修改文集" 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>
2020-10-18 08:05:41 +08:00
</a> -->
<a href="{% url 'modify_project' %}?pro_id={{pro.id}}" title="修改文集配置" class="layui-btn layui-btn-xs layui-btn-normal">
<i class="layui-icon layui-icon-set"></i>
</a>
<!-- <a href="javascript:void(0);" title="导出文集" onclick="reportMd('{{pro.id}}')" class="layui-btn layui-btn-xs layui-btn-normal">
<i class="layui-icon layui-icon-export"></i>
</a>
<a href="javascript:void(0);" title="删除文集" onclick="delProject('{{pro.id}}');" class="layui-btn layui-btn-xs layui-btn-warm">
<i class="layui-icon layui-icon-delete"></i>
</a> -->
</td>
2019-07-23 13:05:27 +08:00
</tr>
{% endfor %}
</tbody>
</table>
2019-07-23 10:57:42 +08:00
</div>
2019-11-03 20:36:34 +08:00
<!-- 分页 -->
<div class="layui-row">
<div class="layui-box layui-laypage layui-laypage-default">
<!-- 上一页 -->
2019-11-03 20:36:34 +08:00
{% 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>
2019-11-03 20:36:34 +08:00
{% endif %}
<!-- 当前页 -->
<span class="layui-laypage-curr">
<em class="layui-laypage-em"></em>
<em>{{ pros.number }}/{{ pros.paginator.num_pages }}</em>
2019-11-03 20:36:34 +08:00
</span>
<!-- 下一页 -->
2019-11-03 20:36:34 +08:00
{% 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>
2019-11-03 20:36:34 +08:00
{% endif %}
</div>
</div>
2019-07-23 22:03:51 +08:00
{% endblock %}
{% block custom_script %}
<script>
$.ajaxSetup({
data: {csrfmiddlewaretoken: '{{ csrf_token }}' },
});
2020-01-01 21:24:29 +08:00
//创建文集
2019-07-23 22:03:51 +08:00
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);
2019-07-23 22:03:51 +08:00
data = {
'pname':$("#pname").val(),
'desc':$("#desc").val(),
}
$.post("{% url 'create_project' %}",data,function(r){
layer.closeAll('loading'); //关闭loading
2019-07-23 22:03:51 +08:00
if(r.status){
//创建成功
window.location.reload();
//layer.close(index)
}else{
//创建失败,提示
console.log(r)
}
})
},
});
};
2020-01-01 21:24:29 +08:00
//修改文集
2019-07-23 22:03:51 +08:00
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);
2019-07-23 22:03:51 +08:00
data = {
'pro_id':pro_id,
'name':$("#pname").val(),
'desc':$("#desc").val(),
}
$.post("{% url 'modify_project' %}",data,function(r){
layer.closeAll('loading'); //关闭loading
2019-07-23 22:03:51 +08:00
if(r.status){
//修改成功
window.location.reload();
//layer.close(index)
}else{
//修改失败,提示
// console.log(r)
2019-07-23 22:03:51 +08:00
layer.msg(r.data)
}
})
},
});
};
2020-01-01 21:24:29 +08:00
//删除文集
2019-07-23 22:03:51 +08:00
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);
2019-07-23 22:03:51 +08:00
data = {
'pro_id':pro_id,
}
$.post("{% url 'del_project' %}",data,function(r){
layer.closeAll('loading'); //关闭loading
2019-07-23 22:03:51 +08:00
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 () {
2020-05-04 21:26:07 +08:00
layer.closeAll();
})
}
})
};
2020-01-01 21:24:29 +08:00
//修改文集权限
modifyProjectRole = function(pro_id){
layer.open({
type:1,
title:"修改文集权限",
content:$("#modify-project-role-div"),
});
};
2019-07-23 22:03:51 +08:00
</script>
2019-07-23 13:05:27 +08:00
{% endblock %}