Compare commits
2 Commits
d3d4ad7f3f
...
2c52b486ed
| Author | SHA1 | Date |
|---|---|---|
|
|
2c52b486ed | |
|
|
aa221ded75 |
|
|
@ -8,6 +8,7 @@
|
||||||
<body>
|
<body>
|
||||||
<div style="padding: 10px;">
|
<div style="padding: 10px;">
|
||||||
<div class="layui-btn-container" id="auditBtnGroup">
|
<div class="layui-btn-container" id="auditBtnGroup">
|
||||||
|
<button id="exportBtn" class="layui-btn">导出</button>
|
||||||
</div>
|
</div>
|
||||||
<table class="layui-table" id="baseTable" lay-filter="test"></table>
|
<table class="layui-table" id="baseTable" lay-filter="test"></table>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -17,6 +18,8 @@
|
||||||
<script src="../../../layui/layui.js"></script>
|
<script src="../../../layui/layui.js"></script>
|
||||||
<script type="text/javascript" src="../../../js/jq.js"></script>
|
<script type="text/javascript" src="../../../js/jq.js"></script>
|
||||||
<script type="text/javascript" src="../../../js/my/permission.js"></script>
|
<script type="text/javascript" src="../../../js/my/permission.js"></script>
|
||||||
|
<!-- SheetJS xlsx 用于导出 Excel -->
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
let headerRows;
|
let headerRows;
|
||||||
let layer, laydate, table;
|
let layer, laydate, table;
|
||||||
|
|
@ -144,6 +147,43 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 导出按钮点击事件
|
||||||
|
$('#exportBtn').on('click', function () {
|
||||||
|
var data = table.cache.baseTable; // 获取表格缓存数据
|
||||||
|
|
||||||
|
if (!data || data.length === 0) {
|
||||||
|
alert("没有可导出的数据!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构造二维数组用于导出
|
||||||
|
let exportData = [];
|
||||||
|
|
||||||
|
// 定义字段名映射关系
|
||||||
|
const fieldMap = {
|
||||||
|
'avgScore': '月度对标平均得分',
|
||||||
|
'subName': '分包商名称'
|
||||||
|
// 可以继续添加其他字段映射
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取表头(排除 LAY_* 字段,并做字段名替换)
|
||||||
|
const originalHeaders = Object.keys(data[0]).filter(key => !key.startsWith('LAY_'));
|
||||||
|
const headers = originalHeaders.map(key => fieldMap[key] || key); // 替换为中文字段名
|
||||||
|
exportData.push(headers);
|
||||||
|
|
||||||
|
// 遍历每一行数据,只保留非 LAY_* 字段并映射值
|
||||||
|
data.forEach(row => {
|
||||||
|
const rowData = originalHeaders.map(header => row[header]);
|
||||||
|
exportData.push(rowData);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 使用 xlsx 导出
|
||||||
|
var ws = XLSX.utils.aoa_to_sheet(exportData);
|
||||||
|
var wb = XLSX.utils.book_new();
|
||||||
|
XLSX.utils.book_append_sheet(wb, ws, '导出数据');
|
||||||
|
XLSX.writeFile(wb, '月度排名统计.xlsx');
|
||||||
|
});
|
||||||
|
|
||||||
function getTitle() {
|
function getTitle() {
|
||||||
let evaluateDate = new Set();
|
let evaluateDate = new Set();
|
||||||
let data = JSON.parse(localStorage.getItem("evaluateData"));
|
let data = JSON.parse(localStorage.getItem("evaluateData"));
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,7 @@
|
||||||
if (index > 2 && index != cols.length - 1) {
|
if (index > 2 && index != cols.length - 1) {
|
||||||
$(this).data('edit', 'false');
|
$(this).data('edit', 'false');
|
||||||
$(this).removeAttr('data-edit');
|
$(this).removeAttr('data-edit');
|
||||||
$(this).addClass('layui-disabled');
|
// $(this).addClass('layui-disabled');
|
||||||
//将td元素的contentEditable属性设置为false,禁止编辑
|
//将td元素的contentEditable属性设置为false,禁止编辑
|
||||||
$(this).attr('contentEditable', 'false');
|
$(this).attr('contentEditable', 'false');
|
||||||
//将td元素的style属性设置为pointer-events: none,禁止点击
|
//将td元素的style属性设置为pointer-events: none,禁止点击
|
||||||
|
|
@ -219,7 +219,7 @@
|
||||||
|
|
||||||
let dataId = $(this).data('field')
|
let dataId = $(this).data('field')
|
||||||
if (item1[`${dataId}-file`] && item1[`${dataId}-file`]['fileName'] != '') {
|
if (item1[`${dataId}-file`] && item1[`${dataId}-file`]['fileName'] != '') {
|
||||||
$(this).find('.layui-table-cell').append(`<i class="layui-icon layui-icon-file-b" style="margin-left:6px"></i> `)
|
$(this).find('.layui-table-cell').append(`<i class="layui-icon layui-icon-file-b" style="margin-left:6px;cursor:pointer"></i> `)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -341,7 +341,7 @@
|
||||||
|
|
||||||
console.log('inputValueinputValueinputValue', inputValue)
|
console.log('inputValueinputValueinputValue', inputValue)
|
||||||
|
|
||||||
const regex = /^\d+$/
|
const regex = /^(0|[1-9]\d*)?$/
|
||||||
|
|
||||||
if (!regex.test(inputValue)) {
|
if (!regex.test(inputValue)) {
|
||||||
layer.msg('请输入大于等于0的正整数')
|
layer.msg('请输入大于等于0的正整数')
|
||||||
|
|
@ -357,7 +357,10 @@
|
||||||
|
|
||||||
let dataId = $(this).data('id') // 获取 data-id
|
let dataId = $(this).data('id') // 获取 data-id
|
||||||
if (dataId && inputValue) {
|
if (dataId && inputValue) {
|
||||||
|
console.log('inputValue=====', inputValue)
|
||||||
formData[dataId] = inputValue * 1 // 将 data-id 作为键,输入框的值作为值
|
formData[dataId] = inputValue * 1 // 将 data-id 作为键,输入框的值作为值
|
||||||
|
} else {
|
||||||
|
formData[dataId] = ''
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue