import {layuiObj } from "../index.js";
import { schoolStarRatingHistoryGetlist } from "../orgApi/starRatingHistoryData.js";
import { getYearOption } from "../centerPage.js";
let starRatingHistoryList=[];
function showStarRatingDataTotal(){
layuiObj.layer.open({
type: 1,
title: '星级评定-数据统计', //不显示标题栏
area: ['960px', '600px'],
shade: 0.6,
id:new Date().getTime(), //设定一个id,防止重复弹出
btnAlign: 'c',
moveType: 1, //拖拽模式,0或者1
content: `
`,
success: function(layero){
$("#historyYearSelect").html(getYearOption());
layuiObj.layuiForm.render()
addStarRatingHistoryDataEvent();
var year=$("#historyYearSelect").find("option:selected").val();
selectYearStarRatingData(year)
}
});
}
function addStarRatingHistoryDataEvent(){
$("#starRatingHistoryBtn").on('click',function(e){
e.preventDefault();
var year=$("#historyYearSelect").find("option:selected").val();
selectYearStarRatingData(year)
})
$("#starRatingHistoryExportBtn").on('click',function(e){
e.preventDefault();
export2TroubleExcel()
})
}
function export2TroubleExcel() {
var tableName=$("#historyYearSelect").find("option:selected").val()+"校园星级评定数据统计表"
// 添加表头信息
let thead = `
校园星级评定数据统计表 |
序号 |
派出所 |
五星学校 |
四星学校 |
三星学校 |
二星学校 |
一星学校 |
`;
var data=getStarRatingBoroughData();
var levelBrigade5Total=0;
var levelBrigade4Total=0;
var levelBrigade3Total=0;
var levelBrigade2Total=0;
var levelBrigade1Total=0;
var tr=``;
for(var i=0;i
${data[i]["index"]} |
${data[i]["borough"]} |
${data[i]["levelBrigade5"].length} |
${data[i]["levelBrigade4"].length} |
${data[i]["levelBrigade3"].length} |
${data[i]["levelBrigade2"].length} |
${data[i]["levelBrigade1"].length} |
`
levelBrigade5Total+=data[i]["levelBrigade5"].length
levelBrigade4Total+=data[i]["levelBrigade4"].length
levelBrigade3Total+=data[i]["levelBrigade3"].length
levelBrigade2Total+=data[i]["levelBrigade2"].length
levelBrigade1Total+=data[i]["levelBrigade1"].length
}
tr+=`
合计 |
${levelBrigade5Total} |
${levelBrigade4Total} |
${levelBrigade3Total} |
${levelBrigade2Total} |
${levelBrigade1Total} |
`
// 添加每一行数据
let tbody = `${tr}`;
let table = thead + tbody;
// 导出表格
exportToExcel(table, tableName);
};
function selectYearStarRatingData(year){
starRatingHistoryList=[];
var obj={
schoolTime:year
}
schoolStarRatingHistoryGetlist(obj).then(res=>{
var code=res["data"]["code"];
if(code==0){
var data=res["data"]["data"];
for(var i=0;i