68 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			68 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <div class="table-content">
 | |
| 	<div class="layui-form-bar border-t border-x">
 | |
| 		<button class="layui-btn layui-btn-sm add-new">+ 新建文档</button>
 | |
| 	</div>
 | |
| 	<table class="layui-hide" id="test" lay-filter="test"></table>
 | |
| </div>
 | |
| 
 | |
| <script type="text/html" id="barDemo">
 | |
| <div class="layui-btn-group"><span class="layui-btn layui-btn-normal layui-btn-xs" lay-event="view">查看</span><span class="layui-btn layui-btn-xs" lay-event="edit">编辑</span><span class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</span></div>
 | |
| </script>
 | |
| 
 | |
| <script>
 | |
| function pageInit(){
 | |
| 	var project_id = {$id};
 | |
| 	var table = layui.table,tool = layui.tool;	
 | |
| 	
 | |
| 	layui.documentTable = table.render({
 | |
| 		elem: '#test',
 | |
| 		title: '文档列表',
 | |
| 		cellMinWidth:200,
 | |
| 		url: "/api/document/get_list", //数据接口
 | |
| 		where:{'m':'project','tid':project_id},
 | |
| 		page: true, //开启分页
 | |
| 		limit: 20,
 | |
| 		cols:  [[
 | |
| 			{field:'id', title: 'ID编号',width: 80, align:'center'}
 | |
| 			,{field:'title',title: '标题'}
 | |
| 			,{field:'name',title: '创建人', align:'center',width: 100}
 | |
| 			,{field:'create_time',title: '创建时间',align:'center',width: 150}	
 | |
| 			,{field:'update_time',title: '最后更新时间', align:'center',width: 150}
 | |
| 			,{title: '操作',align: 'center',width: 136,toolbar: '#barDemo',}
 | |
| 		]]
 | |
| 	});
 | |
| 	
 | |
| 	//新增
 | |
| 	$('.add-new').on('click',function(){
 | |
| 		tool.open('/api/document/add?project_id='+project_id);
 | |
| 	});
 | |
| 	
 | |
| 	//监听行工具事件
 | |
| 	table.on('tool(test)', function(obj) {
 | |
| 		var data = obj.data;
 | |
| 		if (obj.event === 'view') {
 | |
| 			tool.open('/api/document/view?id='+data.id);
 | |
| 			return;
 | |
| 		}
 | |
| 		if (obj.event === 'edit') {
 | |
| 			tool.open('/api/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("/api/document/delete",{ id: obj.data.id,'module':'project'},callback);
 | |
| 				layer.close(index);
 | |
| 			});
 | |
| 		}
 | |
| 	});
 | |
| }		
 | |
| </script> |