lihai-oa/app/project/view/index/view_document.html

92 lines
2.6 KiB
HTML
Raw Normal View History

2023-10-24 15:17:16 +08:00
<div class="p-3 bg-white">
<table class="layui-hide" id="document" lay-filter="document"></table>
</div>
<script type="text/html" id="toolbardocument">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-sm" lay-event="add">+ 新建文档</button>
</div>
</script>
<script>
function project_document(){
if($('#projectTab').find('li').eq(3).data('load') =='true'){
return false;
}
$('#projectTab').find('li').eq(3).data('load','true');
let tool = layui.tool, table = layui.table;
//项目任务
parent.layui.documentTable = table.render({
elem: '#document',
title: '文档列表',
toolbar: '#toolbardocument',
cellMinWidth:80,
url: "/project/document/index",
where:{'project_id':project_id},
page: true, //开启分页
limit: 20,
cols: [[
{field: 'id', title: '文档编号', width: 80, align: 'center', templet: function (d) {
return 'D' + d.id;
}
}
, {
field: 'title', title: '文档主题', templet: function (d) {
var html = '<a class="side-a" lay-event="detail">' + d.title + '</a>';
return html;
}
}
,{field:'admin_name',title: '创建人', align:'center',width: 80}
,{field:'create_time',title: '创建时间', align:'center', width: 150}
,{
field: 'right',
fixed:'right',
title: '操作',
width: 100,
align: 'center',
templet: function (d) {
var html = '<div class="layui-btn-group">';
var btn1='<span class="layui-btn layui-btn-xs" lay-event="edit">编辑</span>';
var btn2='<span class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</span>';
return html+btn1+btn2+'</div>';
}
}
]]
});
//触发事件
table.on('toolbar(document)', function(obj){
var checkStatus = table.checkStatus(obj.config.id);
switch(obj.event){
case 'add':
parent.layui.tool.side('/project/document/add?project_id='+project_id);
break;
};
});
table.on('tool(document)', function(obj){
var data = obj.data; //获得当前行数据
if(obj.event === 'detail'){ //查看
let url = '/project/document/view/id/'+data.id;
parent.layui.tool.side(url);
}
if(obj.event === 'edit'){
parent.layui.tool.side('/project/document/add?id='+data.id);
return;
}
if (obj.event === 'del') {
layer.confirm('确定要删除吗?', {
icon: 3,
title: '提示'
}, function(index) {
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
obj.del();
}
}
tool.delete("/project/document/delete", {id: data.id}, callback);
layer.close(index);
});
}
})
}
</script>