anxiao_web/pages/information/dailyInspection/js/exportTable.js

110 lines
3.8 KiB
JavaScript
Raw Permalink Normal View History

2024-07-24 09:22:32 +08:00
function exportSchoolExcel(data) {
var start=$("#clockHistoryStart").val();
var end=$("#clockHistoryEnd").val();
var tableName="芙蓉智慧防控平台试用期“重点护学岗”数据统计"+start+"---"+end
// 添加表头信息
let thead = `
<thead>
<tr style="font-size:22px;">
<td colspan="7" style="text-align:center;">芙蓉智慧防控平台试用期重点护学岗数据统计${start}---${end}</td>
</tr>
<tr style="font-size:18px;">
<th>序号</th>
<th>/园名称</th>
<th>属地派出所</th>
<th>注册人数<br/>校园老师保安家长志愿者</th>
<th>注册人数<br/>派出所民辅警</th>
<th>校园打卡人数<br/>校园老师保安家长志愿者</th>
<th>派出所民辅警打卡人数</th>
</tr>
</thead>`;
var tr=``;
var index=1;
for(var i=0;i<data.length;i++){
var borough=data[i]["borough"]
var schoolSummaryList=data[i]["schoolSummaryList"];
for(var j=0;j<schoolSummaryList.length;j++){
var guardCount=schoolSummaryList[j]["guardCount"]
var guardSignCount=schoolSummaryList[j]["guardSignCount"]
var policeCount=schoolSummaryList[j]["policeCount"]
var policeSignCount=schoolSummaryList[j]["policeSignCount"]
var station=schoolSummaryList[j]["station"]
if(j==0){
var policeTd=`<td rowspan=${schoolSummaryList.length}>${borough}</td>`
}else{
var policeTd=``
}
tr+=`<tr style="font-size:16px;">
<td>${index}</td>
<td>${station}</td>
${policeTd}
<td>${guardCount}</td>
<td>${policeCount}</td>
<td>${guardSignCount}</td>
<td>${policeSignCount}</td>
</tr>`
index++;
}
}
// 添加每一行数据
let tbody = `<tbody>${tr}</tbody>`;
let table = thead + tbody;
// 导出表格
exportToExcel(table, tableName);
};
function exportPoliceExcel(data) {
var start=$("#clockHistoryStart").val();
var end=$("#clockHistoryEnd").val();
var tableName="芙蓉智慧防控平台试用期“重点护学岗”数据统计"+start+"---"+end
// 添加表头信息
let thead = `
<thead>
<tr style="font-size:22px;">
<td colspan="7" style="text-align:center;">芙蓉智慧防控平台试用期重点护学岗数据统计${start}---${end}</td>
</tr>
<tr style="font-size:18px;">
<th>序号</th>
<th>属地派出所</th>
<th>注册人数<br/>校园老师保安家长志愿者</th>
<th>注册人数<br/>派出所民辅警</th>
<th>校园打卡人数<br/>校园老师保安家长志愿者</th>
<th>派出所民辅警打卡人数</th>
</tr>
</thead>`;
var tr=``;
var index=1;
for(var i=0;i<data.length;i++){
var borough=data[i]["borough"]
var guardCount=data[i]["guardCount"]
var policeCount=data[i]["policeCount"]
var guardSignCount=data[i]["guardSignCount"]
var policeSignCount=data[i]["policeSignCount"]
tr+=`<tr style="font-size:16px;">
<td>${index}</td>
<td>${borough}</td>
<td>${guardCount}</td>
<td>${policeCount}</td>
<td>${guardSignCount}</td>
<td>${policeSignCount}</td>
</tr>`
index++;
}
// 添加每一行数据
let tbody = `<tbody>${tr}</tbody>`;
let table = thead + tbody;
// 导出表格
exportToExcel(table, tableName);
};
export {
exportSchoolExcel,
exportPoliceExcel,
}