更新
This commit is contained in:
@ -14,6 +14,10 @@
|
||||
<title>
|
||||
表单设计器代码
|
||||
</title>
|
||||
<style type="text/css">
|
||||
|
||||
|
||||
</style>
|
||||
<link rel="stylesheet" href="~/lib/layui/css/layui.css" />
|
||||
<link rel="stylesheet" href="~/js/lay-module/formDesigner/formDesigner.css" />
|
||||
<link rel="stylesheet" href="~/js/lay-module/cron/cron.css" />
|
||||
@ -22,10 +26,10 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="workerdiv" style="margin: 10px 20px;">
|
||||
<form class="layui-form" style="height:100%;" id="formPreviewForm">
|
||||
<div id="workerdiv" style="margin: 10px 5px;">
|
||||
<form class="layui-form" style="height:30px;" id="formPreviewForm">
|
||||
<div id="grid_2" class="layui-form-item layui-row grid active" data-id="grid_2"
|
||||
data-tag="grid" data-index="0">
|
||||
data-tag="grid" data-index="0" style="height:100%">
|
||||
<div class="layui-col-md3 widget-col-list column0" data-index="0" data-parentindex="0">
|
||||
<div id="ReStartTime" class="layui-form-item active" data-id="ReStartTime"
|
||||
data-tag="date" data-index="0">
|
||||
@ -106,11 +110,13 @@
|
||||
</div>
|
||||
|
||||
</form>
|
||||
<form class="layui-form" style="height:100%;width:100%;" id="tablepanel">
|
||||
<div class="layui-panel" id="gridpanel" style="height:100%;width:100%;overflow:scroll;">
|
||||
<div id="result"></div>
|
||||
</div>
|
||||
</form>
|
||||
@*<form class="layui-form" style="height:100%;width:100%;" id="tablepanel">*@
|
||||
@*<div class="layui-panel" id="gridpanel" style="height:100%;width:100%;overflow:scroll;">
|
||||
<div id="result" style="height:100%;width:100%;"></div>
|
||||
</div>*@
|
||||
<div id="result" style="height:100%;width:100%;overflow:scroll;">
|
||||
</div>
|
||||
@*</form>*@
|
||||
</div>
|
||||
<script type="text/javascript" src="~/lib/layui/layui.js">
|
||||
</script>
|
||||
@ -355,17 +361,70 @@
|
||||
);
|
||||
|
||||
// 合并单元格
|
||||
handler.mergeTable(workbook, true);
|
||||
//handler.mergeTable(workbook, true);
|
||||
staticToLayTable();
|
||||
completeLoading();
|
||||
},
|
||||
|
||||
// csv 数据转换为 table
|
||||
csv2table(csv, showTab = false) {
|
||||
var html = "<table lay-filter = \"tdemo\" class=\"layui-table\" lay-even=\"\" lay-skin=\"row\">";
|
||||
var html = "<table lay-filter=\"tdemo\" border=\"1\">";// class=\"layui-table\" lay-data=\"{报表数据}\"
|
||||
var rows = csv.split("\n");
|
||||
debugger;
|
||||
rows.pop(); // 最后一行没用的
|
||||
|
||||
var oneheadarray = rows[0].split(",");
|
||||
var onehead = new Array();
|
||||
var oneheadlength = new Array();
|
||||
var marge = 0;
|
||||
oneheadarray.forEach(function (onestring,oneid){
|
||||
if(onestring!=""){
|
||||
if(oneid == 0){
|
||||
onehead.push(onestring);
|
||||
}else{
|
||||
oneheadlength.push(marge+1);
|
||||
marge = 0;
|
||||
onehead.push(onestring);
|
||||
}
|
||||
|
||||
}else{
|
||||
marge++;
|
||||
if(oneid == (oneheadarray.length-1)){
|
||||
oneheadlength.push(marge + 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var twoheadarray = rows[1].split(",");
|
||||
|
||||
html +="<thead>";
|
||||
html+="<tr>";
|
||||
onehead.forEach(function(head,hid){
|
||||
let colspan = oneheadlength[hid];
|
||||
if(colspan == 1){
|
||||
html += "<th lay-data=\"{ align:'center'} \" colspan=" + colspan + ",colGroup:true>" + head + "</th>";
|
||||
}else{
|
||||
html += "<th lay-data=\"{ align:'center' } \" colspan="+colspan+">"+head+"</th>";
|
||||
}
|
||||
|
||||
});
|
||||
html+="</tr>";
|
||||
|
||||
html += "<tr>";//
|
||||
twoheadarray.forEach(function (dhead, did) {
|
||||
if(did == 0){
|
||||
html += "<th lay-data=\"{ field: 'a" + did + "', width:200 ,fixed:\'left\'} \">" + dhead + "</th>";//
|
||||
}else{
|
||||
html += "<th lay-data=\"{ field: 'a" + did + "', width:150} \">" + dhead + "</th>";//
|
||||
}
|
||||
|
||||
});
|
||||
html += "</tr>";
|
||||
html+="</thead>";
|
||||
|
||||
rows.shift();
|
||||
rows.shift();
|
||||
|
||||
html += "<tbody>";
|
||||
rows.forEach(function (row, idx) {
|
||||
var columns = row.split(",");
|
||||
@ -449,9 +508,41 @@
|
||||
|
||||
//转换静态表格
|
||||
table.init('tdemo', {
|
||||
page:true,
|
||||
limit:17,
|
||||
//height: 315 //设置高度
|
||||
//, limit: 10 //注意:请务必确保 limit 参数(默认:10)是与你服务端限定的数据条数一致
|
||||
//limit: 10 //注意:请务必确保 limit 参数(默认:10)是与你服务端限定的数据条数一致
|
||||
//支持所有基础参数
|
||||
|
||||
done:function(res,curr,count){
|
||||
// console.log(res)
|
||||
//解决操作栏因为内容过多换行问题
|
||||
$(".layui-table-main tr").each(function (index, val) {
|
||||
$($(".layui-table-fixed-l .layui-table-body tbody tr")[index]).height($(val).height());
|
||||
$($(".layui-table-fixed-r .layui-table-body tbody tr")[index]).height($(val).height());
|
||||
});
|
||||
//解决fixed固定,而导致的th高度不一致
|
||||
$(".layui-table-header tr").each(function (index, val) {
|
||||
$(".layui-table-fixed").each(function () {
|
||||
$($(this).find(".layui-table-header thead th")[index]).height($(val).height());
|
||||
});
|
||||
});
|
||||
$(".layui-table-header tr").each(function (index, val) {
|
||||
$(".layui-table-fixed").each(function () {
|
||||
$($(this).find(".layui-table-header thead tr")[index]).height($(val).height());
|
||||
});
|
||||
});
|
||||
$(".layui-table-main tr").each(function (index, val) {
|
||||
$(".layui-table-fixed").each(function () {
|
||||
$($(this).find(".layui-table-body tbody tr")[index]).height($(val).height());
|
||||
});
|
||||
});
|
||||
$(".layui-table-main tr").each(function (index, val) {
|
||||
$(".layui-table-fixed").each(function () {
|
||||
$($(this).find(".layui-table-body tbody th")[index]).height($(val).height());
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user