anxiao_web/pages/starrating/js/index.js

168 lines
5.5 KiB
JavaScript

import {getstationcount,stationInfoPageReq} from "./orgApi/getStationInfo.js";
import {getStarRating} from "./orgApi/getStarRating.js";
import { schoolCheckGetPending } from "./orgApi/schoolCheckGetPending.js";
import { starRatingGetbonus } from "./orgApi/starRatingGetbonus.js";
import { showStarRatingHistoryData } from "./pop/starRatingHistoryData.js";
import { showStarRatingDataTotal } from "./pop/starRatingDataTotal.js";
import {
createSchoolInfo,
showSchoolInfo,
showThreeColorInfo,
showStarraingBottomTen
} from "./leftPage.js";
import { initSchoolSelect} from "./centerPage.js";
import { showHistoricalOverview } from "./rightPage.js";
import { getYearTime } from "./orgApi/getYearTime.js";
import { drawSchoolBonusEchart } from "./drawEchart.js";
import { getBoroughInfo } from "./orgApi/getBoroughInfo.js";
var layuiObj={};
let starRatingArr=[];//三色的评分
let schoolCheckPending=[];
let schoolBasicInfo=[];
let starRatingGetbonusList=[];
let yearTimeList=[];
let currenYearNewTime="";
let boroughList=[];//保存所有的派出所
layui.use(['carousel','table','form','laydate','slider','element'],function() {
layuiObj["layer"] = layui.layer;
layuiObj["carousel"] = layui.carousel;
layuiObj["layuitable"] = layui.table;
layuiObj["rate"] = layui.rate;
layuiObj["layuiForm"] = layui.form;
layuiObj["laydate"] =layui.laydate;
layuiObj["slider"] =layui.slider;
layuiObj["element"] =layui.element;
var loginJson=sessionStorage.getItem("unameInfoStr");
var basicloginInfo=JSON.parse(loginJson);
axios.defaults.headers.common['Authorization'] = basicloginInfo["session"];
initApi();
addThreeColorEventSelect();
})
async function initApi(){
var yearTimeReq= await getYearTime();
var yearTimeCode=yearTimeReq["data"]["code"];
if(yearTimeCode==0){
yearTimeList=yearTimeReq["data"]["data"]
currenYearNewTime=yearTimeList[yearTimeList.length-1]["schoolTime"]
//currenYearNewTime="2023年上半年"
}
var boroughReq=await getBoroughInfo();
boroughList=boroughReq["data"]["data"]
//获取学校信息
var stationcountRes=await getstationcount();
var stationcount=stationcountRes.data.data.count;
var stationlistRes= await stationInfoPageReq(stationcount)
stationlistRes.forEach(item=>{
var data=item.data.data;
schoolBasicInfo=data;
//显示学校信息
createSchoolInfo();
showSchoolInfo();
})
//获取所有学校评分最新的数据
getStarRating(currenYearNewTime).then(res=>{
var code=res.data.code;
if(code==0){
starRatingArr=res.data.data
for(var i=0;i<starRatingArr.length;i++){
starRatingArr[i]["scoreBonus"]=parseFloat(starRatingArr[i]["scoreBonus"]/10);
starRatingArr[i]["scoreInsideManage"]=parseFloat(starRatingArr[i]["scoreInsideManage"]/10);
starRatingArr[i]["scoreLawEducation"]=parseFloat(starRatingArr[i]["scoreLawEducation"]/10);
starRatingArr[i]["scoreOutsideManage"]=parseFloat(starRatingArr[i]["scoreOutsideManage"]/10);
starRatingArr[i]["scoreEmcManage"]=parseFloat(starRatingArr[i]["scoreEmcManage"]/10);
starRatingArr[i]["scoreRiskManage"]=parseFloat(starRatingArr[i]["scoreRiskManage"]/10);
starRatingArr[i]["scoreTotal"]=parseFloat(starRatingArr[i]["scoreTotal"]/10);
}
}
showStarraingBottomTen();
showThreeColorInfo();
initSchoolSelect();
showHistoricalOverview(starRatingArr);
})
//获取学校所有的扣分项
schoolCheckGetPending().then(res=>{
var code=res["data"]["code"];
if(code==0){
schoolCheckPending=res.data.data
showSchoolNotCompIndex(schoolCheckPending)
}
})
//获取加分学校的数据
starRatingGetbonus().then(res=>{
var code=res["data"]["code"];
if(code==0){
if(res.data.data!=null){
starRatingGetbonusList=res.data.data
}
}
drawSchoolBonusEchart();
})
}
function addThreeColorEventSelect(){
$(".selectStarRatingHistoryData").on('click',function(){
showStarRatingHistoryData();
})
$(".selectStarRatingDataTotal").on('click',function(){
showStarRatingDataTotal();
})
}
function showSchoolNotCompIndex(data){
var oli=""
for(var i=0;i<data.length;i++){
oli+=`
<li style="margin-top: 0px; ">
<p>
<span title="${data[i]['station']}">[${data[i]['station']}]</span>
</p>
<p>
<span>整改项目:<i>${data[i]["itemValue"]}</i></span>
</p>
</li>`;
}
$(".factoryInfo").html(oli);
autoani();
}
function autoani(){
$(".factoryInfo>li:first-child").animate(
{
"margin-top":'-70px'
},
1000,
function(){
$(this).css("marginTop","0");
$(".factoryInfo").children("li").eq(0).remove();
$(".factoryInfo").append(this);
}
)
}
//自动间隔时间向上滑动
var anifun = setInterval(autoani,2000);
//悬停时停止滑动,离开时继续执行
$(".factoryInfo").hover(function(){
clearInterval(anifun); //清除自动滑动动画
},function(){
anifun = setInterval(autoani,2000); //继续执行动画
})
export {
layuiObj,
starRatingArr,
schoolBasicInfo,
yearTimeList,
starRatingGetbonusList,
boroughList,
currenYearNewTime
}