anxiao_web/pages/information/nursingSchoolExamSituation/js/exportTable.js

238 lines
8.8 KiB
JavaScript

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="17" style="text-align:center;">芙蓉智慧防控平台试用期“重点护学岗”数据统计${start}---${end}</td>
</tr>
<tr style="font-size:18px;">
<th rowspan="2">序号</th>
<th rowspan="2">派出所</th>
<th rowspan="2">学校</th>
<th colspan="4">注册人数</th>
<th colspan="4">打卡人数</th>
<th colspan="4">风采上传</th>
<th colspan="2">安全检查</th>
</tr>
<tr style="font-size:18px;">
<th>民辅警</th>
<th>老师</th>
<th>保安</th>
<th>志愿者</th>
<th>民辅警</th>
<th>老师</th>
<th>保安</th>
<th>志愿者</th>
<th>护学岗</th>
<th>法制宣传</th>
<th>应急演练</th>
<th>其他</th>
<th>检查</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 teacherCount=schoolSummaryList[j]["teacherCount"]
var teacherSignCount=schoolSummaryList[j]["teacherSignCount"]
var volunteerCount=schoolSummaryList[j]["volunteerCount"]
var volunteerSignCount=schoolSummaryList[j]["volunteerSignCount"]
var newsPeakGuard=schoolSummaryList[j]["newsPeakGuard"]//护学岗
var newsLaw=schoolSummaryList[j]["newsLaw"]//法制宣传
var newsExercise=schoolSummaryList[j]["newsExercise"]//应急演练
var newsOther=schoolSummaryList[j]["newsOther"]//其他
var securityCheckCount=schoolSummaryList[j]["securityCheckCount"]
var pendingProcessCount=schoolSummaryList[j]["pendingProcessCount"]
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>
${policeTd}
<td>${station}</td>
<td>${policeCount}</td>
<td>${teacherCount}</td>
<td>${guardCount}</td>
<td>${volunteerCount}</td>
<td>${policeSignCount}</td>
<td>${teacherSignCount}</td>
<td>${guardSignCount}</td>
<td>${volunteerSignCount}</td>
<td>${newsPeakGuard}</td>
<td>${newsLaw}</td>
<td>${newsExercise}</td>
<td>${newsOther}</td>
<td>${securityCheckCount}</td>
<td>${pendingProcessCount}</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);
};
function exportStationClockExcel(list){
var data=getNoClockData(JSON.parse(JSON.stringify(list)));
var start=$("#clockHistoryStart").val();
var end=$("#clockHistoryEnd").val();
var tableName="芙蓉智慧防控平台试用期“学校未打卡”数据统计"
//添加表头信息
let thead = `
<thead>
<tr style="font-size:22px;">
<td colspan="5" style="text-align:center;">${tableName}${start}---${end}</td>
</tr>
<tr style="font-size:18px;">
<th>序号</th>
<th>派出所</th>
<th>学校</th>
<th>注册人数</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 teacherCount=schoolSummaryList[j]["teacherCount"]
var teacherSignCount=schoolSummaryList[j]["teacherSignCount"]
var volunteerCount=schoolSummaryList[j]["volunteerCount"]
var teacherSignCount=schoolSummaryList[j]["teacherSignCount"]
var station=schoolSummaryList[j]["station"]
var count=guardCount+policeCount+teacherCount+volunteerCount;
var signCount=guardSignCount+policeSignCount+teacherSignCount+teacherSignCount;
if(j==0){
var policeTd=`<td rowspan=${schoolSummaryList.length}>${borough}(${schoolSummaryList.length})</td>`
}else{
var policeTd=``
}
if(count==0){
var registerTd=`<td style="font-weight:bold;color:#ED7D31;">${count}</td>`;
}else{
var registerTd=`<td>${count}</td>`;
}
tr+=`<tr style="font-size:16px;">
<td>${index}</td>
${policeTd}
<td>${station}</td>
${registerTd}
<td>${signCount}</td>
</tr>`
index++;
}
}
// 添加每一行数据
let tbody = `<tbody>${tr}</tbody>`;
let table = thead + tbody;
// 导出表格
exportToExcel(table, tableName);
}
//获取学校的打卡数量
function getNoClockData(data){
var list=[];
for(var i=0;i<data.length;i++){
let schoolSummaryList=data[i]["schoolSummaryList"];
var obj={
"borough":data[i]["borough"],
"schoolSummaryList":[]
};
list.push(obj);
for(var j=0;j<schoolSummaryList.length;j++){
var guardSignCount=schoolSummaryList[j]["guardSignCount"];
var policeSignCount=schoolSummaryList[j]["policeSignCount"];
var teacherSignCount=schoolSummaryList[j]["teacherSignCount"];
var volunteerSignCount=schoolSummaryList[j]["volunteerSignCount"];
if(
(guardSignCount==0)
&&
(policeSignCount==0)
&&
(teacherSignCount==0)
&&
(volunteerSignCount==0)
){
obj["schoolSummaryList"].push(schoolSummaryList[j]);
}
}
}
return list;
}
export {
exportSchoolExcel,
exportPoliceExcel,
exportStationClockExcel
}