修改模板 动表头前备份

This commit is contained in:
dell
2023-03-23 14:14:23 +08:00
parent 25d007bba0
commit e8ebf4850d
25 changed files with 40 additions and 23 deletions

View File

@ -106,8 +106,8 @@
</div>
</form>
<form class="layui-form" style="height:100%;width:100%" id="tablepanel">
<div class="layui-panel" id="gridpanel" >
<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>
@ -124,9 +124,10 @@
</script>
<script>
layui.use(["layer", "laytpl", "element", "form", "slider", "laydate", "rate", "colorpicker", "carousel", "upload", "formField", "numberInput", "iconPicker", "cron", "labelGeneration"],
layui.use(["table", "layer", "laytpl", "element", "form", "slider", "laydate", "rate", "colorpicker", "carousel", "upload", "formField", "numberInput", "iconPicker", "cron", "labelGeneration"],
function () {
var $ = layui.jquery,
table = layui.table,
layer = layui.layer,
laytpl = layui.laytpl,
setter = layui.cache,
@ -355,37 +356,41 @@
// 合并单元格
handler.mergeTable(workbook, true);
staticToLayTable();
completeLoading();
},
// csv 数据转换为 table
csv2table(csv, showTab = false) {
var html = "<table class=\"layui-table\" lay-even=\"\" lay-skin=\"row\">";
var html = "<table lay-filter = \"tdemo\" class=\"layui-table\" lay-even=\"\" lay-skin=\"row\">";
var rows = csv.split("\n");
debugger;
rows.pop(); // 最后一行没用的
html += "<tbody>";
rows.forEach(function (row, idx) {
var columns = row.split(",");
if (showTab) {
columns.unshift(idx + 1); // 添加行索引
if (idx == 0) {
// 添加列索引
html += "<tr>";
for (var i = 0; i < columns.length; i++) {
html +=
"<th>" +
//(i == 0 ? "" : String.fromCharCode(65 + i - 1)) +
(i == 0 ? "" : i.toString()) +
"</th>";
}
html += "</tr>";
}
}
//if (showTab) {
// columns.unshift(idx + 1); // 添加行索引
// if (idx == 0) {
// // 添加列索引
// html += "<tr>";
// for (var i = 1; i < columns.length; i++) {
// html +=
// "<th>" +
// //(i == 0 ? "" : String.fromCharCode(65 + i - 1)) +
// (i == 0 ? "" : i.toString()) +
// "</th>";
// }
// html += "</tr>";
// }
//}
html += "<tr>";
columns.forEach(function (column) {
html += "<td align=center>" + column + "</td>";
});
html += "</tr>";
});
html += "</tbody>";
html += "</table>";
return html;
},
@ -402,11 +407,11 @@
let baiseAdd = hasTab ? 1 : 0;
mergeInfo.forEach((item) => {
let start_r = item.s.r + baiseAdd;
let end_r = item.e.r + baiseAdd;
let start_r = item.s.r + baiseAdd-1;
let end_r = item.e.r + baiseAdd-1;
let start_c = item.s.c + baiseAdd;
let end_c = item.e.c + baiseAdd;
let start_c = item.s.c + baiseAdd-1;
let end_c = item.e.c + baiseAdd-1;
for (let i = start_r; i <= end_r; i++) {
let row = document.querySelectorAll("#result tr")[i];
@ -438,6 +443,18 @@
}
};
function staticToLayTable()
{
var table = layui.table;
//转换静态表格
table.init('tdemo', {
//height: 315 //设置高度
//, limit: 10 //注意:请务必确保 limit 参数默认10是与你服务端限定的数据条数一致
//支持所有基础参数
});
}
function dataURLToFile(dataUrl, fileName) {
const dataArr = dataUrl.split(',');

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.