2020-11-16 21:50:13 +08:00
|
|
|
{% extends 'app_doc/user/user_base.html' %}
|
2020-10-18 08:05:41 +08:00
|
|
|
{% load static %}
|
2020-12-02 21:25:59 +08:00
|
|
|
{% load i18n %}
|
2020-12-06 01:33:59 +08:00
|
|
|
{% block title %}{% trans "文集管理" %}{% endblock %}
|
2019-07-23 13:05:27 +08:00
|
|
|
{% block content %}
|
2020-11-16 21:32:08 +08:00
|
|
|
<div class="layui-card">
|
|
|
|
<div class="layui-card-body">
|
|
|
|
<table id="project-table" lay-filter="project-table"></table>
|
2020-08-30 13:51:26 +08:00
|
|
|
</div>
|
2020-11-16 21:32:08 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- 表格工具栏 -->
|
|
|
|
<script type="text/html" id="project-toolbar">
|
|
|
|
<div class="layui-input-inline">
|
2020-11-30 21:46:15 +08:00
|
|
|
<input type="text" name="project-search-kw" placeholder="" class="layui-input" >
|
2019-07-23 10:57:42 +08:00
|
|
|
</div>
|
2021-02-15 17:22:14 +08:00
|
|
|
<button class="pear-btn pear-btn-sm" lay-event="search">
|
2020-12-06 01:33:59 +08:00
|
|
|
<i class="layui-icon layui-icon-search"></i>{% trans "搜索" %}
|
2020-11-16 21:32:08 +08:00
|
|
|
</button>
|
2021-02-15 17:22:14 +08:00
|
|
|
<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="add">
|
2020-12-06 01:33:59 +08:00
|
|
|
<i class="layui-icon layui-icon-add-1"></i>{% trans "新增" %}
|
2020-11-25 21:24:46 +08:00
|
|
|
</button>
|
2021-02-15 17:22:14 +08:00
|
|
|
<button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="batchRemove">
|
2020-12-06 01:33:59 +08:00
|
|
|
<i class="layui-icon layui-icon-delete"></i>{% trans "删除" %}
|
2020-11-25 21:24:46 +08:00
|
|
|
</button>
|
2021-04-11 19:13:00 +08:00
|
|
|
<button class="pear-btn pear-btn-normal pear-btn-sm" lay-event="batchReport">
|
2021-05-30 16:04:44 +08:00
|
|
|
<i class="layui-icon layui-icon-util"></i>{% trans "批量导出" %}
|
2021-04-11 19:13:00 +08:00
|
|
|
</button>
|
2020-11-25 21:24:46 +08:00
|
|
|
|
2020-11-16 21:32:08 +08:00
|
|
|
</script>
|
2020-05-04 21:26:07 +08:00
|
|
|
|
2020-11-16 21:32:08 +08:00
|
|
|
<!-- 文集名称 -->
|
|
|
|
<script type="text/html" id="project-name">
|
|
|
|
{% verbatim %}
|
2020-11-25 21:24:46 +08:00
|
|
|
<a href="/project-{{d.id}}/" target="_blank">
|
|
|
|
{{d.name}}
|
|
|
|
{{#if (d.role == 0) { }}
|
|
|
|
{{# }else if(d.role == 1){ }}
|
2020-12-13 15:43:59 +08:00
|
|
|
<span tooltip="私密" placement="right"><i class="layui-icon layui-icon-password"></i></span>
|
2020-11-25 21:24:46 +08:00
|
|
|
{{# }else if(d.role == 2){ }}
|
2020-12-13 15:43:59 +08:00
|
|
|
<span tooltip="指定用户" placement="right"><i class="layui-icon layui-icon-user"></i></span>
|
2020-11-25 21:24:46 +08:00
|
|
|
{{# }else if(d.role == 3){ }}
|
2020-12-13 15:43:59 +08:00
|
|
|
<span tooltip="访问码" placement="right"><i class="layui-icon layui-icon-key"></i></span>
|
2020-11-25 21:24:46 +08:00
|
|
|
{{# } }}
|
|
|
|
</a>
|
2020-11-16 21:32:08 +08:00
|
|
|
{% endverbatim %}
|
|
|
|
</script>
|
2020-08-30 13:51:26 +08:00
|
|
|
|
2020-11-16 21:32:08 +08:00
|
|
|
<!-- 单个文集操作 -->
|
|
|
|
<script type="text/html" id="project-bar">
|
|
|
|
{% verbatim %}
|
2021-02-15 17:22:14 +08:00
|
|
|
<a href="/manage_pro_doc_sort/{{d.id}}/" title="排序文档" class="pear-btn pear-btn-sm" lay-event="sort"><i class="layui-icon layui-icon-cols"></i></a>
|
|
|
|
<a href="/modify_pro/?pro_id={{d.id}}" title="修改文集配置" class="pear-btn pear-btn-sm"><i class="layui-icon layui-icon-set"></i></a>
|
|
|
|
<button class="pear-btn pear-btn-danger pear-btn-sm" title="删除文集" lay-event="remove"><i class="layui-icon layui-icon-delete"></i></button>
|
2020-11-16 21:32:08 +08:00
|
|
|
{% endverbatim %}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<!-- 文集权限 -->
|
|
|
|
<script type="text/html" id="project-role">
|
|
|
|
{% verbatim %}
|
|
|
|
{{#if (d.role == 0) { }}
|
|
|
|
<span>公开</span>
|
|
|
|
{{# }else if(d.role == 1){ }}
|
|
|
|
<span>私密</span>
|
|
|
|
{{# }else if(d.role == 2){ }}
|
|
|
|
<span>指定用户</span>
|
|
|
|
{{# }else if(d.role == 3){ }}
|
|
|
|
<span>访问码</span>
|
|
|
|
{{# } }}
|
|
|
|
{% endverbatim %}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<!-- 协作人数 -->
|
|
|
|
<script type="text/html" id="colla-cnt">
|
|
|
|
{% verbatim %}
|
|
|
|
<span>{{d.colla_total}}</span> <a href="/manage_project_colla/{{d.id}}/" title="管理文集协作"><i class="layui-icon layui-icon-set"></i></a>
|
|
|
|
{% endverbatim %}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<!-- 创建时间 -->
|
|
|
|
<script type="text/html" id="project-create-time">
|
|
|
|
{% verbatim %}
|
|
|
|
{{layui.util.toDateString(d.create_time, "yyyy-MM-dd HH:mm:ss")}}
|
|
|
|
{% endverbatim %}
|
|
|
|
</script>
|
2019-07-23 22:03:51 +08:00
|
|
|
{% endblock %}
|
|
|
|
{% block custom_script %}
|
|
|
|
<script>
|
2020-11-16 21:32:08 +08:00
|
|
|
layui.use(['table', 'form', 'jquery', 'layer'], function() {
|
|
|
|
let table = layui.table;
|
|
|
|
let form = layui.form;
|
|
|
|
let $ = layui.jquery;
|
|
|
|
let layer = layui.layer;
|
|
|
|
$.ajaxSetup({
|
|
|
|
data: {csrfmiddlewaretoken: '{{ csrf_token }}' },
|
|
|
|
});
|
|
|
|
let cols = [
|
|
|
|
[
|
|
|
|
{type: 'checkbox',width:20},
|
2020-12-06 01:33:59 +08:00
|
|
|
{title: '{% trans "文集名称" %}',field: 'name',align: 'left',templet:"#project-name",minWidth:200},
|
2020-11-25 21:24:46 +08:00
|
|
|
// {title: '简介',field: 'intro',align: 'left',templet:"#share-type"},
|
|
|
|
// {title: '权限',field: 'role',align: 'left',templet:"#project-role"},
|
2020-12-06 01:33:59 +08:00
|
|
|
{title: '{% trans "文档数" %}',field: 'doc_total',align: 'left',width:90},
|
2021-01-31 20:48:24 +08:00
|
|
|
{title: '{% trans "文集成员" %}',field: 'colla_total',align: 'left',templet:"#colla-cnt",width:90},
|
2020-12-06 01:33:59 +08:00
|
|
|
{title: '{% trans "创建时间" %}',field: 'create_time',align: 'left',templet:"#project-create-time"},
|
|
|
|
{title: '{% trans "操作" %}',toolbar: '#project-bar',align: 'left',}
|
2020-11-16 21:32:08 +08:00
|
|
|
]
|
|
|
|
]
|
|
|
|
// 渲染表格
|
|
|
|
table.render({
|
|
|
|
elem: '#project-table',
|
|
|
|
method:'post',
|
2020-11-30 21:46:15 +08:00
|
|
|
where:{
|
|
|
|
'type':1
|
|
|
|
},
|
2020-11-16 21:32:08 +08:00
|
|
|
url: "{% url 'manage_project' %}",
|
|
|
|
page: true,
|
|
|
|
cols: cols,
|
|
|
|
skin: 'line',
|
|
|
|
toolbar: '#project-toolbar',
|
|
|
|
defaultToolbar: ['filter']
|
2019-07-23 22:03:51 +08:00
|
|
|
});
|
2020-11-16 21:32:08 +08:00
|
|
|
// 侦听文集删除按钮
|
|
|
|
table.on("tool(project-table)",function(obj){
|
|
|
|
if (obj.event === 'remove') {
|
|
|
|
// console.log(obj)
|
2021-01-21 21:25:28 +08:00
|
|
|
delProject(obj.data.id,obj.data.name)
|
2020-11-16 21:32:08 +08:00
|
|
|
}
|
2020-11-30 21:46:15 +08:00
|
|
|
});
|
2020-11-16 21:32:08 +08:00
|
|
|
// 侦听表格工具栏
|
|
|
|
table.on("toolbar(project-table)",function(obj){
|
|
|
|
if (obj.event === 'add') { // 新增文集
|
|
|
|
createProject();
|
|
|
|
}else if(obj.event === 'batchRemove'){ // 批量删除文集
|
|
|
|
batchRemove(obj)
|
2020-11-30 21:46:15 +08:00
|
|
|
}else if(obj.event === 'search'){ // 搜索文集
|
2021-01-31 20:48:24 +08:00
|
|
|
// console.log('搜索文集')
|
2020-11-30 21:46:15 +08:00
|
|
|
table.reload('project-table',{
|
|
|
|
where:{
|
2021-01-31 20:48:24 +08:00
|
|
|
'type':1,'kw':$('input[name="project-search-kw"]').val()
|
|
|
|
},
|
2020-11-30 21:46:15 +08:00
|
|
|
})
|
2021-03-21 17:36:20 +08:00
|
|
|
}else if(obj.event === 'batchReport'){ // 批量导出文集
|
|
|
|
batchReport(obj)
|
2021-01-31 20:48:24 +08:00
|
|
|
}
|
2020-11-30 21:46:15 +08:00
|
|
|
});
|
2020-11-16 21:32:08 +08:00
|
|
|
//创建文集
|
|
|
|
createProject = function(){
|
|
|
|
layer.open({
|
|
|
|
type:1,
|
2020-12-06 01:33:59 +08:00
|
|
|
title:'{% trans "新建文集" %}',
|
2020-11-16 21:32:08 +08:00
|
|
|
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>',
|
2020-12-06 01:33:59 +08:00
|
|
|
btn:['{% trans "确定" %}','{% trans "取消" %}'], //添加按钮
|
2020-11-16 21:32:08 +08:00
|
|
|
btnAlign:'c', //按钮居中
|
|
|
|
yes:function (index,layero) {
|
|
|
|
layer.load(1);
|
|
|
|
data = {
|
|
|
|
'pname':$("#pname").val(),
|
|
|
|
'desc':$("#desc").val(),
|
2019-07-23 22:03:51 +08:00
|
|
|
}
|
2020-11-16 21:32:08 +08:00
|
|
|
$.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,
|
2020-12-06 01:33:59 +08:00
|
|
|
title:'{% trans "修改文集" %}',
|
2020-11-16 21:32:08 +08:00
|
|
|
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>',
|
2020-12-06 01:33:59 +08:00
|
|
|
btn:['{% trans "确定" %}','{% trans "取消" %}'], //添加按钮
|
2020-11-16 21:32:08 +08:00
|
|
|
btnAlign:'c', //按钮居中
|
|
|
|
yes:function (index,layero) {
|
|
|
|
layer.load(1);
|
|
|
|
data = {
|
|
|
|
'pro_id':pro_id,
|
|
|
|
'name':$("#pname").val(),
|
|
|
|
'desc':$("#desc").val(),
|
2019-07-23 22:03:51 +08:00
|
|
|
}
|
2020-11-16 21:32:08 +08:00
|
|
|
$.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)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
//删除文集
|
2021-01-21 21:25:28 +08:00
|
|
|
delProject = function(pro_id,pro_name){
|
2020-11-16 21:32:08 +08:00
|
|
|
layer.open({
|
|
|
|
type:1,
|
2020-12-06 01:33:59 +08:00
|
|
|
title:'{% trans "删除文集" %}',
|
2020-11-16 21:32:08 +08:00
|
|
|
area:'300px;',
|
|
|
|
id:'delPro',//配置ID
|
2021-01-21 21:25:28 +08:00
|
|
|
content:'<div style="margin-left:10px;">你正在删除:<span style="font-weight:700;color:red;">【'+pro_name+'】</span><br><br>警告!此操作将<span style="font-weight:700;color:red;">删除此文集及文集下所有文档!</span>并且<span style="font-weight:700;color:red;">不可恢复!</span><br><br>请输入“DELETE”以再次确认删除。<br><input class="layui-input" style="width:95%;" id="confirm_delete_project" placeholder="DELETE"></div>',
|
|
|
|
btn:['{% trans "删除" %}','{% trans "取消" %}'], //添加按钮
|
2020-11-16 21:32:08 +08:00
|
|
|
btnAlign:'c', //按钮居中
|
|
|
|
yes:function (index,layero) {
|
2021-01-21 21:25:28 +08:00
|
|
|
var confirm_delete = $("#confirm_delete_project").val()
|
|
|
|
if(confirm_delete === 'DELETE'){
|
|
|
|
layer.load(1);
|
|
|
|
data = {
|
|
|
|
'pro_id':pro_id,
|
2020-11-16 21:32:08 +08:00
|
|
|
}
|
2021-01-21 21:25:28 +08:00
|
|
|
$.post("{% url 'del_project' %}",data,function(r){
|
|
|
|
layer.closeAll(); //关闭loading
|
|
|
|
if(r.status){
|
|
|
|
layer.msg("{% trans '删除成功' %}", {
|
|
|
|
icon: 1,
|
|
|
|
time: 1000
|
|
|
|
}, function() {
|
|
|
|
table.reload('project-table');
|
|
|
|
});
|
|
|
|
}else{
|
|
|
|
//修改失败,提示
|
|
|
|
console.log(r)
|
|
|
|
layer.msg(r.data)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}else{
|
|
|
|
layer.msg("输入错误!")
|
|
|
|
}
|
2020-11-16 21:32:08 +08:00
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
// 批量删除文集
|
|
|
|
batchRemove = function(obj) {
|
|
|
|
let data = table.checkStatus(obj.config.id).data;
|
|
|
|
if (data.length === 0) {
|
2020-12-06 01:33:59 +08:00
|
|
|
layer.msg("{% trans '未选中任何文集' %}", {
|
2020-11-16 21:32:08 +08:00
|
|
|
icon: 3,
|
|
|
|
time: 1000
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
let pro_id = "";
|
|
|
|
for (let i = 0; i < data.length; i++) {
|
|
|
|
pro_id += data[i].id + ",";
|
|
|
|
}
|
|
|
|
pro_id = pro_id.substr(0, pro_id.length - 1);
|
|
|
|
// console.log(pro_id)
|
2021-01-21 21:25:28 +08:00
|
|
|
layer.open({
|
|
|
|
type:1,
|
|
|
|
title:'{% trans "删除文集" %}',
|
|
|
|
area:'300px;',
|
|
|
|
id:'delPro',//配置ID
|
|
|
|
content:'<div style="margin-left:10px;">你正在批量删除文集!<br><br>警告!此操作将<span style="font-weight:700;color:red;">删除所选文集及文集下所有文档!</span>并且<span style="font-weight:700;color:red;">不可恢复!</span><br><br>请输入“DELETE”以再次确认删除。<br><input class="layui-input" style="width:95%;" id="confirm_batch_delete_project" placeholder="DELETE"></div>',
|
|
|
|
btn:['{% trans "批量删除" %}','{% trans "取消" %}'], //添加按钮
|
|
|
|
btnAlign:'c', //按钮居中
|
|
|
|
yes:function (index,layero) {
|
|
|
|
var confirm_delete = $("#confirm_batch_delete_project").val()
|
|
|
|
if(confirm_delete === 'DELETE'){
|
|
|
|
let loading = layer.load();
|
|
|
|
$.ajax({
|
|
|
|
url: "{% url 'del_project' %}",
|
|
|
|
dataType: 'json',
|
|
|
|
type: 'post',
|
|
|
|
data:{'pro_id':pro_id,'range':'multi'},
|
|
|
|
success: function(r) {
|
|
|
|
layer.closeAll();
|
|
|
|
if (r.status) {
|
|
|
|
layer.msg("{% trans '删除成功' %}", {
|
|
|
|
icon: 1,
|
|
|
|
time: 1000
|
|
|
|
}, function() {
|
|
|
|
table.reload('project-table');
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
layer.msg(r.data, {
|
|
|
|
icon: 2,
|
|
|
|
time: 1000
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}else{
|
|
|
|
layer.msg("输入错误!")
|
2019-12-08 18:59:49 +08:00
|
|
|
}
|
2021-01-21 21:25:28 +08:00
|
|
|
}
|
2020-11-16 21:32:08 +08:00
|
|
|
});
|
2021-01-31 20:48:24 +08:00
|
|
|
};
|
2021-03-21 17:36:20 +08:00
|
|
|
//批量导出文集
|
|
|
|
batchReport = function(obj){
|
|
|
|
let data = table.checkStatus(obj.config.id).data;
|
|
|
|
if (data.length === 0) {
|
|
|
|
layer.msg("{% trans '未选中任何文集' %}", {
|
|
|
|
icon: 3,
|
|
|
|
time: 1000
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
let pro_id = "";
|
|
|
|
for (let i = 0; i < data.length; i++) {
|
|
|
|
pro_id += data[i].id + ",";
|
|
|
|
}
|
|
|
|
pro_id = pro_id.substr(0, pro_id.length - 1);
|
2021-04-11 19:13:00 +08:00
|
|
|
console.log(pro_id);
|
|
|
|
layer.open({
|
|
|
|
type:1,
|
|
|
|
title:"{% trans '打包文集' %}",
|
|
|
|
area:"300px",
|
|
|
|
id:"reportMd",
|
|
|
|
content:'<div style="margin-left:10px;">确定打包导出所选的文集?</div>',
|
|
|
|
btn:['确定','取消'], //添加按钮
|
|
|
|
btnAlign:'c', //按钮居中
|
|
|
|
yes:function (index,layero) {
|
|
|
|
var load = layer.load()
|
|
|
|
data = {
|
|
|
|
'project_id':pro_id,'type':'multi'
|
|
|
|
}
|
|
|
|
$.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:"{% trans '下载导出文档' %}",
|
|
|
|
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();
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
};
|
|
|
|
|
2020-11-16 21:32:08 +08:00
|
|
|
})
|
2019-07-23 22:03:51 +08:00
|
|
|
</script>
|
2019-07-23 13:05:27 +08:00
|
|
|
{% endblock %}
|