100 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			HTML
		
	
	
		
		
			
		
	
	
			100 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			HTML
		
	
	
| 
								 | 
							
								{layout name="layout" /}
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								<div style="padding: 16px;">
							 | 
						|||
| 
								 | 
							
								    <table class="layui-hide" id="test" lay-filter="test"></table>
							 | 
						|||
| 
								 | 
							
								</div>
							 | 
						|||
| 
								 | 
							
								<script type="text/html" id="toolbarDemo">
							 | 
						|||
| 
								 | 
							
								    <div class="layui-row">
							 | 
						|||
| 
								 | 
							
								        <form class="layui-form layui-col-space16" action="/task">
							 | 
						|||
| 
								 | 
							
								            <div class="layui-col-md3">
							 | 
						|||
| 
								 | 
							
								                <div class="layui-input-wrap">
							 | 
						|||
| 
								 | 
							
								                    <input type="text" name="name" placeholder="任务名" value="{$name??''}" lay-affix="clear" class="layui-input">
							 | 
						|||
| 
								 | 
							
								              </div>
							 | 
						|||
| 
								 | 
							
								            </div>
							 | 
						|||
| 
								 | 
							
								            <div class="layui-btn-container layui-col-md3 layui-col-xs12">
							 | 
						|||
| 
								 | 
							
								                <button class="layui-btn" lay-submit lay-filter="demo-table-search">搜索</button>
							 | 
						|||
| 
								 | 
							
								                <button type="reset" class="layui-btn layui-btn-primary">Clear</button>
							 | 
						|||
| 
								 | 
							
								            </div>
							 | 
						|||
| 
								 | 
							
								        </form>
							 | 
						|||
| 
								 | 
							
								    </div>
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								</script>
							 | 
						|||
| 
								 | 
							
								<script type="text/html" id="toolDemo">
							 | 
						|||
| 
								 | 
							
								    <div class="layui-clear-space">
							 | 
						|||
| 
								 | 
							
								        <a class="layui-btn layui-btn-xs" lay-event="detail">详情</a>
							 | 
						|||
| 
								 | 
							
								    </div>
							 | 
						|||
| 
								 | 
							
								</script>
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								<script>
							 | 
						|||
| 
								 | 
							
								layui.use(['table', 'dropdown'], function(){
							 | 
						|||
| 
								 | 
							
								    var table = layui.table;
							 | 
						|||
| 
								 | 
							
								    var dropdown = layui.dropdown;
							 | 
						|||
| 
								 | 
							
								    var name = "{$name ?? ''}";
							 | 
						|||
| 
								 | 
							
								    // 创建渲染实例
							 | 
						|||
| 
								 | 
							
								    table.render({
							 | 
						|||
| 
								 | 
							
								        elem: '#test',
							 | 
						|||
| 
								 | 
							
								        url: '/task/apiGetList?name=' + name, // 此处为静态模拟数据,实际使用时需换成真实接口
							 | 
						|||
| 
								 | 
							
								        toolbar: '#toolbarDemo',
							 | 
						|||
| 
								 | 
							
								        defaultToolbar: ['filter', 'exports', 'print', { // 右上角工具图标
							 | 
						|||
| 
								 | 
							
								            title: '提示',
							 | 
						|||
| 
								 | 
							
								            layEvent: 'LAYTABLE_TIPS',
							 | 
						|||
| 
								 | 
							
								            icon: 'layui-icon-tips',
							 | 
						|||
| 
								 | 
							
								            onClick: function(obj) { // 2.9.12+
							 | 
						|||
| 
								 | 
							
								                layer.alert('自定义工具栏图标按钮');
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }],
							 | 
						|||
| 
								 | 
							
								        height: 'full-135', // 最大高度减去其他容器已占有的高度差
							 | 
						|||
| 
								 | 
							
								        css: [ // 重设当前表格样式
							 | 
						|||
| 
								 | 
							
								            '.layui-table-tool-temp{padding-right: 145px;}'
							 | 
						|||
| 
								 | 
							
								        ].join(''),
							 | 
						|||
| 
								 | 
							
								        cellMinWidth: 80,
							 | 
						|||
| 
								 | 
							
								        //totalRow: true, // 开启合计行
							 | 
						|||
| 
								 | 
							
								        //page: true,
							 | 
						|||
| 
								 | 
							
								        page: { // 支持传入 laypage 组件的所有参数(某些参数除外,如:jump/elem) - 详见文档
							 | 
						|||
| 
								 | 
							
								            layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'], //自定义分页布局
							 | 
						|||
| 
								 | 
							
								            //curr: 5, //设定初始在第 5 页
							 | 
						|||
| 
								 | 
							
								            limit: 20,
							 | 
						|||
| 
								 | 
							
								            //groups: 1, //只显示 1 个连续页码
							 | 
						|||
| 
								 | 
							
								            //first: false, //不显示首页
							 | 
						|||
| 
								 | 
							
								            //last: false //不显示尾页
							 | 
						|||
| 
								 | 
							
								        },
							 | 
						|||
| 
								 | 
							
								        // 将原始数据解析成 table 组件所规定的数据格式
							 | 
						|||
| 
								 | 
							
								        parseData: function(res){
							 | 
						|||
| 
								 | 
							
								            return {
							 | 
						|||
| 
								 | 
							
								                "code": res.code, //解析接口状态
							 | 
						|||
| 
								 | 
							
								                "msg": res.msg, //解析提示文本
							 | 
						|||
| 
								 | 
							
								                "count": res.taskList.total, //解析数据长度
							 | 
						|||
| 
								 | 
							
								                "data": res.taskList.data //解析数据列表
							 | 
						|||
| 
								 | 
							
								            };
							 | 
						|||
| 
								 | 
							
								        },
							 | 
						|||
| 
								 | 
							
								        cols: [[
							 | 
						|||
| 
								 | 
							
								            {type: 'checkbox', fixed: 'left'},
							 | 
						|||
| 
								 | 
							
								            {field: 'id', fixed: 'left', width:80, title: 'ID'},
							 | 
						|||
| 
								 | 
							
								            {field: 'name', width:300, title: '任务'},
							 | 
						|||
| 
								 | 
							
								            {field: 'projectName', width:150, title: '项目'},
							 | 
						|||
| 
								 | 
							
								            {field: 'executionName', width:150, title: '执行'},
							 | 
						|||
| 
								 | 
							
								            {field: 'statusName', width:80, title: '状态'},
							 | 
						|||
| 
								 | 
							
								            {field: 'assignedToName', width:80, title: '指派给'},
							 | 
						|||
| 
								 | 
							
								            {field: 'finishedByName', width:80, title: '完成者'},
							 | 
						|||
| 
								 | 
							
								            {field: 'finishedDate', title:'完成时间', width: 180},
							 | 
						|||
| 
								 | 
							
								            {fixed: 'right', title:'操作', minWidth: 125, templet: '#toolDemo'}
							 | 
						|||
| 
								 | 
							
								        ]],
							 | 
						|||
| 
								 | 
							
								        done: function(){
							 | 
						|||
| 
								 | 
							
								        },
							 | 
						|||
| 
								 | 
							
								        error: function(res, msg){
							 | 
						|||
| 
								 | 
							
								            console.log(res, msg)
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								    });
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    // 触发单元格工具事件
							 | 
						|||
| 
								 | 
							
								    table.on('tool(test)', function(obj){ // 双击 toolDouble
							 | 
						|||
| 
								 | 
							
								        var data = obj.data; // 获得当前行数据
							 | 
						|||
| 
								 | 
							
								        // console.log(obj)
							 | 
						|||
| 
								 | 
							
								        if(obj.event === 'detail'){
							 | 
						|||
| 
								 | 
							
								            //http://pms.scdxtc.cn/index.php?m=task&f=edit&taskID=57
							 | 
						|||
| 
								 | 
							
								            window.open('http://pms.scdxtc.cn/index.php?m=task&f=edit&taskID=57', '_blank');
							 | 
						|||
| 
								 | 
							
								            //window.open('http://pms.scdxtc.cn/index.php?m=task&f=edit&taskID=' + data.id, '_blank');
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								    });
							 | 
						|||
| 
								 | 
							
								});
							 | 
						|||
| 
								 | 
							
								</script>
							 |