<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/common/meta.jsp"%>
<link href="${ctx}/static/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
<link href="${ctx}/static/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
<link
href="${ctx}/static/css/plugins/dataTables/dataTables.bootstrap.css"
rel="stylesheet">
<link href="${ctx}/static/jqueyViewer/fileupload/css/iconfont.css" rel="stylesheet" type="text/css"/>
<link href="${ctx}/static/jqueyViewer/fileupload/css/fileUpload.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="${ctx}/static/treeTable/layui/css/layui.css"/>
<link rel="stylesheet" type="text/css" href="${ctx}/static/treeTable/layui/css/common.css"/>
<style>
/** 箭头未展开 */
#table1 + .treeTable .treeTable-icon .layui-icon-triangle-d:before {
content: "\e602";
}
/** 箭头展开 */
#table1 + .treeTable .treeTable-icon.open .layui-icon-triangle-d:before {
content: "\e61a";
}
/** 文件图标 */
#table1 + .treeTable .treeTable-icon .layui-icon-file:before {
content: "";
}
/** 文件夹未展开(默认有图标我改为空了) */
#table1 + .treeTable .treeTable-icon .layui-icon-layer:before {
content: "";
}
/** 文件夹展开(默认有图标我改为空了) */
#table1 + .treeTable .treeTable-icon.open .layui-icon-layer:before {
content: "";
}
/** 箭头未展开 */
#table3 + .treeTable .treeTable-icon .layui-icon-triangle-d:before {
content: "\e602";
}
/** 箭头展开 */
#table3 + .treeTable .treeTable-icon.open .layui-icon-triangle-d:before {
content: "\e61a";
}
/** 文件图标 */
#table3 + .treeTable .treeTable-icon .layui-icon-file:before {
content: "";
}
/** 文件夹未展开(默认有图标我改为空了) */
#table3 + .treeTable .treeTable-icon .layui-icon-layer:before {
content: "";
}
/** 文件夹展开(默认有图标我改为空了) */
#table3 + .treeTable .treeTable-icon.open .layui-icon-layer:before {
content: "";
}
.layui-table-cell {
padding:0 4px;
height:auto;
overflow:visible;
text-overflow:inherit;
white-space:normal;
word-break: break-all;
text-align: center;
}
</style>
</head>
<body class="gray-bg" style="background-color: white;">
<div class="wrapper wrapper-content animated fadeIn padd0">
<div class="row">
<div class="col-xs-12">
<div class="ibox float-e-margins">
<div class="ibox-content padding0">
<form action="#" method="post" id="queryForm">
<div class="dataTables_top">
<span class="Search_reset_box">
<button type="button" class="btn btn-primary btn-sm" onclick="searchProjectinfo()">搜索</button>
<button type="button" class="btn btn-danger btn-sm" onclick="conditionReset()">重置</button>
</span>
</div>
</form>
<div class="Table_title_box" style="background-color: white;">
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief" >
<ul class="layui-tab-title" style="margin-top: 80px;margin-right: 150px;">
<li class="layui-this">*****展示</li>
<li>*****展示</li>
</ul>
<div class="layui-tab-content" >
<div class="layui-tab-item layui-show">
<div class="col-xs-12">
<table id="table1" class="layui-table" style="margin-top: -10px;" lay-filter="table1"></table>
<input id="btn-refresh" style="display: none" >
</div>
</div>
<div class="layui-tab-item">
<div class="col-xs-12">
<table id="table3" class="layui-table" style="margin-top: -10px;" lay-filter="table3"></table>
<input id="btn-refresh3" style="display: none" >
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br/>
<br/>
<br/>
<script src="${ctx}/static/js/bootstrap.min.js?v=3.3.6"></script>
<script src="${ctx}/static/js/plugins/dataTables/jquery.d.js"></script>
<script src="${ctx}/static/js/plugins/dataTables/dataTables.b.js"></script>
<script src="${ctx}/static/js/plugins/datapicker/bootstrap-datepicker.js"></script>
<script src="${ctx}/static/treeTable/layui/layui.js"></script>
<script type="text/javascript">
layui.use('element', function(){
var element = layui.element; //Tab的切换功能,切换事件监听等,需要依赖element模块
});
var treetable ="";
var table
//初始化table
layui.config({
base: '${ctx}/static/treeTable/module/', /* 修改为你module文件夹地址*/
}).extend({
treetable: 'treetable-lay/treetable'
}).use(['table', 'treetable'], function () {
//var $ = layui.jquery;
table = layui.table;
treetable = layui.treetable;
// 渲染表格
var renderTable = function () {
//layer.load(2);
treetable.render({
//size: 'lg', //尺寸-----标题过长去掉此属性
treeColIndex: 0, //设置下拉箭头在第几列
treeSpid: "0", //最上级的父级id
treeIdName: 'deptId', //id字段的名称(自己的id)
treePidName: 'parentId', //pid字段的名称(父亲的id)
treeDefaultClose: true, //是否默认折叠
//treeLinkage: false, //父级展开时是否自动展开所有子级
//smartReloadModel:true,
elem: '#table1', //表格的id
url: '接口地址?year='+encodeURIComponent($("#year").val())+'&importbatch='+encodeURIComponent($("#importbatch").val()), //数据请求地址,返回json格式数据(映射路径)
page: false,
cols: [ //列数和列名可根据需要更改
[
{field: 'bttype',align: 'center',rowspan:2,title: ''},
{align: 'center',colspan:3 ,title: ''},
{align: 'center',colspan:4 ,title: '总计'},
{align: 'center',colspan:4 ,title: '居住用地'},
{align: 'center',colspan:4 ,title: '商业用地'},
{align: 'center',colspan:3 ,title: '非房地产开发用地'},
{templet: complain, align:'center',rowspan:2, title: '操作'}
],
[
{field: 'importbatchzwn', align:'center' , title: '导入批次/县区'},
{field: 'year', align:'center' , title: '年度'},
{field: 'expdata', align:'center' , title: '导入时间'},
{field: 'con1', align:'center' , title: '地块数'},
{field: 'con5', align:'center' , title: '开工数'},
{field: 'con4', align:'center' , title: '开工率'},
{field: 'con2', align:'center' , title: '开发计划填报进度'},
{field: 'zcon1', align:'center' , title: '地块数'},
{field: 'zcon5', align:'center' , title: '开工数'},
{field: 'zcon4', align:'center' , title: '开工率'},
{field: 'zcon2', align:'center' , title: '开发计划填报进度'},
{field: 'scon1', align:'center' , title: '地块数'},
{field: 'scon5', align:'center' , title: '开工数'},
{field: 'scon4', align:'center' , title: '开工率'},
{field: 'scon2', align:'center' , title: '开发计划填报进度'},
{field: 'qcon1', align:'center' , title: '地块数'},
{field: 'qcon5', align:'center' , title: '开工数'},
{field: 'qcon4', align:'center' , title: '开工率'}
]
],
done: function () {
$('table').width('100%');
layer.closeAll('loading');
}
});
};
renderTable();
function complain(d){//操作中显示的内容
if('${isqx}'!=01 ){
return [
'<button type="button" class="layui-btn layui-btn-xs layui-bg-blue" style="margin-top:10px;" onclick="LOOK(\''+d.expdata+'\',\''+d.year+'\',\''+d.importbatch+'\')">查看</button>',
].join('');
} else if(d.importbatch !=null && d.importbatch !='' && d.expdata !=null && d.expdata !=''){
return [
'<button type="button" class="layui-btn layui-btn-xs layui-bg-blue" style="margin-top:10px;" onclick="LOOK(\''+d.expdata+'\',\''+d.year+'\',\''+d.importbatch+'\')">查看</button>',
'<button type="button" class="layui-btn layui-btn-xs layui-bg-blue" style="margin-top:10px;" onclick="importExcel(\''+d.expdata+'\',\''+d.importbatch+'\')">重新导入</button>',
'<button type="button" class="layui-btn layui-btn-xs layui-bg-blue" style="margin-top:10px;" onclick="del(\''+d.expdata+'\',\''+d.importbatch+'\')">删除</button>'
].join('');
}else if(d.importbatchtt !=null && d.importbatchtt !='' ){
return [
'<button type="button" class="layui-btn layui-btn-xs layui-bg-blue" style="margin-top:10px;" onclick="LOOK(\''+d.expdata+'\',\''+d.year1+'\',\''+d.importbatchtt+'\',\''+d.importbatch+'\')">查看</button>',
].join('');
} else{
return [
'<button type="button" class="layui-btn layui-btn-xs layui-bg-blue" style="margin-top:10px;" onclick="LOOK(\''+d.expdata+'\',\''+d.year+'\',\''+d.importbatch+'\')">查看</button>',
].join('');
}
}
$('#btn-refresh').click(function () {
renderTable();
});
//监听工具条
table.on('tool(table1)', function(obj){ //注:tool是工具条事件名,table1是table表格的属性 lay-filter="对应的值"
var data = obj.data; //获得当前行数据
var layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值)
var tr = obj.tr; //获得当前行 tr 的DOM对象
if(layEvent === 'del'){ //删除
layer.confirm('真的删除行么', function(index){
obj.del(); //删除对应行(tr)的DOM结构,并更新缓存
layer.close(index);
//向服务端发送删除指令
});
} else if(layEvent === 'edit'){ //编辑
//do something
}
});
});
var treetable3 ="";
var table3
//初始化table
layui.config({
base: '${ctx}/static/treeTable/module/', /* 修改为你module文件夹地址*/
}).extend({
treetable3: 'treetable-lay/treetable'
}).use(['table', 'treetable'], function () {
//var $ = layui.jquery;
table3 = layui.table;
treetable3 = layui.treetable;
// 渲染表格
var renderTable1 = function () {
//layer.load(2);
treetable3.render({
//size: 'lg', //尺寸
treeColIndex: 0, //设置下拉箭头在第几列
treeSpid: "0", //最上级的父级id
treeIdName: 'deptId3', //id字段的名称(自己的id)
treePidName: 'parentId3', //pid字段的名称(父亲的id)
treeDefaultClose: true, //是否默认折叠
//treeLinkage: false, //父级展开时是否自动展开所有子级
//smartReloadModel:true,
elem: '#table3', //表格的id
url: '后台接口?year='+encodeURIComponent($("#year").val())+'&importbatch='+encodeURIComponent($("#importbatch").val()), //数据请求地址,返回json格式数据(映射路径)
page: false,
cols: [ //列数和列名可根据需要更改
[
{field: 'bttype3',align: 'center',rowspan:2,title: ''},
{field: 'importbatch3',align: 'center',rowspan:2,title: '县区'},
{align: 'center',colspan:4 ,title: '总计'},
{align: 'center',colspan:4 ,title: '居住用地'},
{align: 'center',colspan:4 ,title: '商业用地'},
{align: 'center',colspan:3 ,title: '非房地产开发用地'},
{templet: complain, align:'center',rowspan:2, title: '操作'}
],
[
{field: 'con13', align:'center' , title: '地块数'},
{field: 'con53', align:'center' , title: '开工数'},
{field: 'con43', align:'center' , title: '开工率'},
{field: 'con23', align:'center' , title: '开发计划填报进度'},
{field: 'zcon13', align:'center' , title: '地块数'},
{field: 'zcon53', align:'center' , title: '开工数'},
{field: 'zcon43', align:'center' , title: '开工率'},
{field: 'zcon23', align:'center' , title: '开发计划填报进度'},
{field: 'scon13', align:'center' , title: '地块数'},
{field: 'scon53', align:'center' , title: '开工数'},
{field: 'scon43', align:'center' , title: '开工率'},
{field: 'scon23', align:'center' , title: '开发计划填报进度'},
{field: 'qcon13', align:'center' , title: '地块数'},
{field: 'qcon53', align:'center' , title: '开工数'},
{field: 'qcon43', align:'center' , title: '开工率'}
]
],
done: function () {
$('table').width('100%');
layer.closeAll('loading');
}
});
};
renderTable1();
function complain(d){//操作中显示的内容
if('${isqx}'!=01 ){
return [
'<button type="button" class="layui-btn layui-btn-xs layui-bg-blue" style="margin-top:10px;" onclick="LOOK(\''+d.expdata3+'\',\''+d.year3+'\',\''+d.importbatch3+'\')">查看</button>',
].join('');
} else if(d.importbatch !=null && d.importbatch !='' && d.expdata3 !=null && d.expdata3 !=''){
return [
'<button type="button" class="layui-btn layui-btn-xs layui-bg-blue" style="margin-top:10px;" onclick="LOOK(\''+d.expdata3+'\',\''+d.year3+'\',\''+d.importbatch3+'\')">查看</button>',
'<button type="button" class="layui-btn layui-btn-xs layui-bg-blue" style="margin-top:10px;" onclick="importExcel(\''+d.expdata3+'\',\''+d.importbatch3+'\')">重新导入</button>',
'<button type="button" class="layui-btn layui-btn-xs layui-bg-blue" style="margin-top:10px;" onclick="del(\''+d.expdata3+'\',\''+d.importbatch3+'\')">删除</button>'
].join('');
} else{
return [
'<button type="button" class="layui-btn layui-btn-xs layui-bg-blue" style="margin-top:10px;" onclick="LOOK(\''+d.expdata3+'\',\''+d.year3+'\',\''+d.importbatchtt3+'\',\''+d.importbatch3+'\')">查看</button>',
].join('');
}
}
$('#btn-refresh3').click(function () {
renderTable1();
});
//监听工具条
table3.on('tool(table3)', function(obj){ //注:tool是工具条事件名,table1是table表格的属性 lay-filter="对应的值"
var data = obj.data; //获得当前行数据
var layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值)
var tr = obj.tr; //获得当前行 tr 的DOM对象
if(layEvent === 'del'){ //删除
layer.confirm('真的删除行么', function(index){
obj.del(); //删除对应行(tr)的DOM结构,并更新缓存
layer.close(index);
//向服务端发送删除指令
});
} else if(layEvent === 'edit'){ //编辑
//do something
}
});
});
function searchProjectinfo() {
$("#btn-refresh").click();
$("#btn-refresh3").click();
}
function refresh(){
$("#btn-refresh").click();
$("#btn-refresh3").click();
}
</script>
</body>
</html>
Layui使用treetable复杂表头以及样式错乱、标题过长
项目数据展示与操作:多表格联动查询与管理
于 2022-05-13 19:55:31 首次发布
本文档展示了如何使用layui插件实现两张表格的动态数据管理和搜索功能,包括数据导入、查看、编辑及删除操作。通过树状表格结构,清晰展示房地产开发用地的数据详情和统计。
2995

被折叠的 条评论
为什么被折叠?



