2020-11-16 21:32:08 +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 %}
|
2020-04-06 17:36:04 +08:00
|
|
|
|
{% block content %}
|
2020-11-16 21:32:08 +08:00
|
|
|
|
<div class="layui-card">
|
|
|
|
|
<div class="layui-card-body">
|
|
|
|
|
<div class="layui-row">
|
|
|
|
|
<form action="{% url 'manage_attachment' %}" 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>
|
2021-02-15 17:22:14 +08:00
|
|
|
|
<button class="pear-btn pear-btn-sm" type="submit"><i class="layui-icon layui-icon-search"></i>{% trans "搜索" %}</button>
|
|
|
|
|
<button class="pear-btn pear-btn-primary pear-btn-sm" type="button" id="upload_attachment" title="支持Zip格式压缩文件">
|
2020-12-06 01:33:59 +08:00
|
|
|
|
<i class="layui-icon layui-icon-upload"></i>{% trans "上传附件" %}</button>
|
2020-04-06 17:36:04 +08:00
|
|
|
|
</div>
|
2020-11-16 21:32:08 +08:00
|
|
|
|
</form>
|
2020-04-06 17:36:04 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2020-11-16 21:32:08 +08:00
|
|
|
|
</div>
|
|
|
|
|
<div class="layui-card">
|
|
|
|
|
<div class="layui-card-body">
|
|
|
|
|
<div class="layui-row" >
|
|
|
|
|
<table class="layui-table" id="doctemp-list" lay-skin="nob" lay-even>
|
|
|
|
|
<colgroup>
|
|
|
|
|
<col width="400">
|
|
|
|
|
<col width="200">
|
|
|
|
|
<col width="200">
|
|
|
|
|
<col>
|
|
|
|
|
</colgroup>
|
|
|
|
|
<thead>
|
|
|
|
|
<tr>
|
2020-12-06 01:33:59 +08:00
|
|
|
|
<th>{% trans "附件名称" %}</th>
|
|
|
|
|
<th>{% trans "文件大小" %}</th>
|
|
|
|
|
<th>{% trans "上传时间" %}</th>
|
|
|
|
|
<th>{% trans "操作" %}</th>
|
2020-11-16 21:32:08 +08:00
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody>
|
|
|
|
|
{% for attachment in attachments %}
|
|
|
|
|
<tr>
|
|
|
|
|
<td><a href="/media/{{attachment.file_path}}" target="_blank">{{ attachment.file_name }}</a></td>
|
|
|
|
|
<td>{{ attachment.file_size }}</td>
|
|
|
|
|
<td>{{ attachment.create_time }}</td>
|
|
|
|
|
<td>
|
2021-02-21 13:09:32 +08:00
|
|
|
|
<a href="javascript:void(0);" onclick="delAttach('{{attachment.id}}');" class="pear-btn pear-btn-xs pear-btn-danger">
|
2020-12-06 01:33:59 +08:00
|
|
|
|
<i class="layui-icon layui-icon-delete"></i>{% trans "删除" %}
|
2020-11-16 21:32:08 +08:00
|
|
|
|
</a>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
{% endfor %}
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
<!-- 分页 -->
|
|
|
|
|
<div class="layui-row">
|
|
|
|
|
<div class="layui-box layui-laypage layui-laypage-default">
|
|
|
|
|
<!-- 上一页 -->
|
|
|
|
|
{% if attachments.has_previous %}
|
2020-12-06 01:33:59 +08:00
|
|
|
|
<a href="?page={{ attachments.previous_page_number }}&kw={{attachments.kw}}" class="layui-btn layui-btn-xs layui-btn-normal">{% trans "上一页" %}</a>
|
2020-11-16 21:32:08 +08:00
|
|
|
|
{% else %}
|
2020-12-06 01:33:59 +08:00
|
|
|
|
<a href="javascript:;" class="layui-btn layui-btn-xs layui-btn-disabled">{% trans "上一页" %}</a>
|
2020-11-16 21:32:08 +08:00
|
|
|
|
{% endif %}
|
|
|
|
|
<!-- 当前页 -->
|
|
|
|
|
<span class="layui-laypage-curr">
|
|
|
|
|
<em class="layui-laypage-em"></em>
|
|
|
|
|
<em>{{ attachments.number }}/{{ attachments.paginator.num_pages }}</em>
|
|
|
|
|
</span>
|
|
|
|
|
<!-- 下一页 -->
|
|
|
|
|
{% if attachments.has_next %}
|
2020-12-06 01:33:59 +08:00
|
|
|
|
<a href="?page={{ attachments.next_page_number }}&kw={{attachments.kw}}" class="layui-btn layui-btn-xs layui-btn-normal">{% trans "下一页" %}</a>
|
2020-11-16 21:32:08 +08:00
|
|
|
|
{% else %}
|
2020-12-06 01:33:59 +08:00
|
|
|
|
<a class="layui-btn layui-btn-xs layui-btn-disabled">{% trans "下一页" %}</a>
|
2020-11-16 21:32:08 +08:00
|
|
|
|
{% endif %}
|
|
|
|
|
</div>
|
2020-04-06 17:36:04 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2020-11-16 21:32:08 +08:00
|
|
|
|
</div>
|
2020-04-06 17:36:04 +08:00
|
|
|
|
{% endblock %}
|
|
|
|
|
{% block custom_script %}
|
|
|
|
|
<script>
|
2020-11-16 21:32:08 +08:00
|
|
|
|
layui.use(['table', 'form', 'jquery', 'dtree','upload'], function() {
|
|
|
|
|
let table = layui.table;
|
|
|
|
|
let form = layui.form;
|
|
|
|
|
let $ = layui.jquery;
|
|
|
|
|
let dtree = layui.dtree;
|
|
|
|
|
$.ajaxSetup({
|
|
|
|
|
data: {csrfmiddlewaretoken: '{{ csrf_token }}' },
|
|
|
|
|
});
|
|
|
|
|
//上传附件
|
|
|
|
|
var upload = layui.upload;
|
|
|
|
|
upload.render({
|
|
|
|
|
elem: '#upload_attachment',
|
|
|
|
|
url: '{% url "manage_attachment" %}',
|
|
|
|
|
data:{types:0,csrfmiddlewaretoken: '{{ csrf_token }}'},
|
|
|
|
|
before: function(obj){ //obj参数包含的信息,跟 choose回调完全一致,可参见上文。
|
|
|
|
|
layer.load(1); //上传loading
|
|
|
|
|
},
|
|
|
|
|
done: function(res, index, upload){ //上传后的回调
|
|
|
|
|
layer.closeAll('loading'); //关闭loading
|
|
|
|
|
//上传成功,刷新页面
|
|
|
|
|
if(res.status == 1){
|
|
|
|
|
window.location.reload();
|
|
|
|
|
}else{
|
|
|
|
|
layer.msg(res.data)
|
2020-04-06 17:36:04 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2020-11-16 21:32:08 +08:00
|
|
|
|
accept: 'file', //允许上传的文件类型
|
|
|
|
|
//exts:'zip', //允许上传zip压缩文件
|
|
|
|
|
field:'attachment_upload',
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
// 删除附件
|
|
|
|
|
delAttach = function(attach_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 = {
|
|
|
|
|
'attach_id':attach_id,
|
|
|
|
|
'types':1
|
|
|
|
|
}
|
|
|
|
|
$.post("{% url 'manage_attachment' %}",data,function(r){
|
|
|
|
|
layer.closeAll('loading');
|
|
|
|
|
if(r.status){
|
|
|
|
|
//修改成功
|
|
|
|
|
window.location.reload();
|
|
|
|
|
//layer.close(index)
|
|
|
|
|
}else{
|
|
|
|
|
//修改失败,提示
|
|
|
|
|
// console.log(r)
|
|
|
|
|
layer.msg(r.data)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
})
|
2020-04-06 17:36:04 +08:00
|
|
|
|
</script>
|
|
|
|
|
{% endblock %}
|