<div style="border: 1px solid black"> <div class="c" > 资产管理信息</div>
<div style="width: 94%;margin-left: 40px;">
<table id="demo" lay-filter="demo" style="margin-top: 20px">
<button type="submit" class="layui-btn layui-btn-primary" id="aaa" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
</table>
</div>
</div>
</div>
</div>
<script th:src="@{/layui-v2.5.5/layui.js}" charset="utf-8"></script>
<script>
layui.use(['form', 'table'], function () {
var $ = layui.jquery,
form = layui.form,
layer=layui.layer,
table = layui.table;//获取当前页面所有的table
var columns = [
{field: 'zdid', title: '工单编号', style:'width:10%',hide:true},
{field:'zd_state',title:'使用归属组', style:'width:10%', templet:function (c) {
return c.zd_state.access_network}, },
];
//渲染表格
table.render({
elem: '#demo',//指定table的id
url: '/zd/ceshicha',
done:function(res, curr ,count){
toolbar:'#toolbarDemo',
$('th').css(({ 'text-align':'center','background-color': '#bdccea', 'color': 'black', 'font-weight': '500' }))
$('layui-table-total.layui-table tbody tr').css({ 'color': 'red' });
$('.layui-table-total.layui-table tbody tr').css({ 'background-color': '#ffffb4' });
var that = this.elem.next(); res.data.forEach(function (item, index) {
//console.log(item.empName);item表示每列显示的数据
if (index % 2 == 0) {
var tr = that.find(".layui-table-box tbody tr[data-index='" + index + "']")
.css(({'border-top':'1px solid black','border-bottom':'dashed','border-left':'1px','text-align':'center'}));
} else {
var tr = that.find(".layui-table-box tbody tr[data-index='" + index + "']")
.css(({'border-top':'1px solid red','border-bottom':'dashed','text-align':'center'}));
}
});
},
defaultToolbar: ['filter', 'exports', 'print', {
title: '提示',
layEvent: 'LAYTABLE_TIPS',
icon: 'layui-icon-tips'
}],
method: "post",
cols: [columns],
limits: [10, 15, 20, 25, 50, 100],
limit: 15,
page: true,
skin: 'line'
});
//点击监听
table.on('row(demo)', function (obj) {
//获取的zdid
alert(JSON.stringify(obj.data.zdid));
//跳转的时候如何拿到获取的值
layer.open({
type:2,
shadeClose: true,
shade: false,
maxmin:true,
area:['100%','100%'],
content: 'http://localhost:8887/zd/xiangxi/'+obj.data.zdid
});
})
// 监听搜索操作
form.on('submit(data-search-btn)', function (data) {
//执行搜索重载
table.reload('demo', {
page: {
curr: 1
},
where: data.field
}, 'data');
return false;
});
table.on('tool(currentTableFilter)', function (obj) {
var data = obj.data;
if (obj.event === 'exit') {
layer.open({
type: 2
,title: false //不显示标题栏
,closeBtn: false
,area: ['900px','600px']
,shade: 0.8
,id: 'LAY_layuipro' //设定一个id,防止重复弹出
,btn: ['取消']
,btnAlign: 'c'
,moveType: 1 //拖拽模式,0或者1
,content: '/letter/toLetterList?lNumber='+data.lNumber
,success: function(layero,index){
}
});
}
});
});
</script>