anxiao_web/pages/starrating/js/centerPage.js

316 lines
12 KiB
JavaScript

import { layuiObj,
yearTimeList,
boroughList,
schoolBasicInfo,
currenYearNewTime
} from "./index.js";
import { getStationStarRatingHistory } from "./orgApi/getStationStarRatingHistory.js";
import { drawSchoolYearScopeChart } from "./drawEchart.js";
import { getStartLevelText } from "./leftPage.js";
import { getStationStarDetail } from "./orgApi/getStationStarDetail.js";
import {
showSchoolInScopePopPage,
showSchoolOutScopePopPage,
showHiddenRectifPopPage,
showLegalEducationPopPage,
showEmergencyResponsePopPage
} from "./pop/starRatingDetail.js";
import { showSchoolSignature } from "./pop/schoolSignature.js";
let currentStation="";
let currentTime="";
let currentBorough="";
let schoolScopeList=[];
function initSchoolSelect(){
$("#mainContentC_boroughSelect").html(createBoroughOptions());
$("#mainContentC_schoolSelect").html(starRatingSelectOptions());
$("#mainContentC_school_time").html(getYearOption());
layuiObj.layuiForm.render("select","mainContentC_schoolForm");
boroughOptionsChange();
$("#mainContentC_schoolSelect").siblings("div.layui-form-select").find("div.layui-select-title").find("input").attr("onfocus","this.select()");
$("#mainContentC_school_time").siblings("div.layui-form-select").find("div.layui-select-title").find("input").attr("onfocus","this.select()");
$("#schoolLevelHistory_time").html(getYearOption());
layuiObj.layuiForm.render("select","schoolLevelHistoryForm");
$("#schoolLevelHistory_time").siblings("div.layui-form-select").find("div.layui-select-title").find("input").attr("onfocus","this.select()");
addThreeColorSelectBtn();
getStationStarRatingData();
}
function createBoroughOptions(){
var options=``;
for(var i=0;i<boroughList.length;i++){
var remark=boroughList[i]["remark"];
var borough=boroughList[i]["borough"];
if(i==0){
currentBorough=borough;
options+=`<option value="${borough}" selected>${remark}</option>`;
}else{
options+=`<option value="${borough}">${remark}</option>`;
}
}
return options;
}
function addThreeColorSelectBtn(){
$(".selectThreeColorBtn").on('click',function(){
currentStation=$("#mainContentC_schoolSelect").find("option:selected").val();
currentTime=$("#mainContentC_school_time").find("option:selected").val();
getStationStarRatingData();
})
}
function boroughOptionsChange(){
layuiObj.layuiForm.on('select(mainContentC_boroughSelect)', function(data){
currentBorough=data["value"];
$("#mainContentC_schoolSelect").html(starRatingSelectOptions());
layuiObj.layuiForm.render("select","mainContentC_schoolForm");
})
}
function getStationStarRatingData(){
getStationStarRatingHistory(currentStation).then(res=>{
var code=res["data"]["code"];
if(code==0){
var data=res["data"]["data"];
for(var i=0;i<data.length;i++){
data[i]["scoreBonus"]=parseFloat(data[i]["scoreBonus"]/10);
data[i]["scoreInsideManage"]=parseFloat(data[i]["scoreInsideManage"]/10);
data[i]["scoreLawEducation"]=parseFloat(data[i]["scoreLawEducation"]/10);//法制
data[i]["scoreOutsideManage"]=parseFloat(data[i]["scoreOutsideManage"]/10);
data[i]["scoreEmcManage"]=parseFloat(data[i]["scoreEmcManage"]/10);
data[i]["scoreRiskManage"]=parseFloat(data[i]["scoreRiskManage"]/10);//隐患整改
data[i]["scoreTotal"]=parseFloat(data[i]["scoreTotal"]/10);
}
schoolScopeList=data;
}
showSchoolColorRating();
drawSchoolYearScope();
})
}
function showSchoolColorRating(){
for(var i=0;i<schoolScopeList.length;i++){
if(currentTime==schoolScopeList[i]["schoolTime"]){
var timestamp=schoolScopeList[i]["timestamp"];
var scoreTotal=schoolScopeList[i]["scoreTotal"];
var scoreInsideManage=schoolScopeList[i]["scoreInsideManage"];
var scoreLawEducation=schoolScopeList[i]["scoreLawEducation"];
var scoreOutsideManage=schoolScopeList[i]["scoreOutsideManage"];
var scoreEmcManage=schoolScopeList[i]["scoreEmcManage"];
var scoreRiskManage=schoolScopeList[i]["scoreRiskManage"];
var school_Info_div=`
<div>
<img src="./image/img.png" alt="">
</div>
<div class="schoolInfoAndScope">
<div>
<p>${currentStation}</p>
</div>
<div>
<p>评分</p>
<p>得分:<span>${scoreTotal}分</span></p>
</div>
<div>
<p>星级</p>
<p>${getStartLevelText(scoreTotal)}</p>
</div>
<div>
<p>评估时间</p>
<p>${timestamp}</p>
</div>
</div>`;
var school_level_div=`
<div class="mainContentC_school_center_title">
<p>评分指标</p>
<p>
<span>当前学校:</span>
<span>${currentStation}</span>
<button type="button" class="layui-btn schoolSignature">签名</button>
</p>
</div>
<div class="mainContentC_school_center_target">
<ul class="colorDetailContent">
<li name="scoreInsideManage">
<div>
<p>校园安全</p>
<p><span>${scoreInsideManage}</span>/20</p>
</div>
</li>
<li name="scoreOutsideManage">
<div>
<p>周边安全</p>
<p><span>${scoreOutsideManage}</span>/20</p>
</div>
</li>
<li name="scoreRiskManage">
<div>
<p>隐患整改</p>
<p><span>${scoreRiskManage}</span>/25</p>
</div>
</li>
<li name="scoreLawEducation">
<div>
<p>法制宣传</p>
<p><span>${scoreLawEducation}</span>/15</p>
</div>
</li>
<li name="scoreEmcManage">
<div>
<p>应急处置</p>
<p><span>${scoreEmcManage}</span>/20</p>
</div>
</li>
</ul>
</div>`;
$(".mainContentC_school_logo").html(school_Info_div)
$(".mainContentC_school_center").html(school_level_div)
}
}
addSchoolColorRatingEvent();
}
function addSchoolColorRatingEvent(){
$(".colorDetailContent>li").on('click',function(){
var name=$(this).attr("name");
getStationStarDetail(currentStation,currentTime).then(res=>{
var code=res["data"]["code"];
if(code==0){
var obj=res["data"]["data"];
obj["inResponsibility"]=obj["inResponsibility"]/10;
obj["inTeamBuild"]=obj["inTeamBuild"]/10;
obj["inDevicesSetup"]=obj["inDevicesSetup"]/10;
obj["inFireManage"]=obj["inFireManage"]/10;
obj["inDangerousManage"]=obj["inDangerousManage"]/10;
obj["inSmartSecurity"]=obj["inSmartSecurity"]/10;
obj["inSecurityScheme"]=obj["inSecurityScheme"]/10;
obj["outPeakGuard"]=obj["outPeakGuard"]/10;
obj["outRiskPrevent"]=obj["outRiskPrevent"]/10;
obj["outTraffic"]=obj["outTraffic"]/10;
obj["outCaseManage"]=obj["outCaseManage"]/10;
obj["riskDangerManage"]=obj["riskDangerManage"]/10;
obj["riskConflictManage"]=obj["riskConflictManage"]/10;
obj["riskProcess"]=obj["riskProcess"]/10;
obj["lawEducation"]=obj["lawEducation"]/10;
obj["lawFirstClass"]=obj["lawFirstClass"]/10;
obj["emcPlan"]=obj["emcPlan"]/10;
obj["emcDrill"]=obj["emcDrill"]/10;
obj["bonus1"]=obj["bonus1"]/10;
obj["bonus2"]=obj["bonus2"]/10;
obj["bonus3"]=obj["bonus3"]/10;
obj["bonus4"]=obj["bonus4"]/10;
obj["bonus5"]=obj["bonus5"]/10;
switch(name){
case "scoreInsideManage"://校园安全
showSchoolInScopePopPage(obj);
break;
case "scoreOutsideManage"://周边安全
showSchoolOutScopePopPage(obj)
break;
case "scoreRiskManage"://隐患整改
showHiddenRectifPopPage(obj)
break;
case "scoreLawEducation"://法制宣传
showLegalEducationPopPage(obj)
break;
case "scoreEmcManage"://应急处置
showEmergencyResponsePopPage(obj)
break;
default:
break;
}
}else{
layer.msg("接口异常");
}
})
})
//显示签名
$(".schoolSignature").on('click',function(){
getStationStarDetail(currentStation,currentTime).then(res=>{
var code=res["data"]["code"];
if(code==0){
var obj=res["data"]["data"];
//学校
var signatureImage=obj["signatureImage"];
//派出所
var signatureImageSchool=obj["signatureImageSchool"];
var flag=0;
if(signatureImage!=null){
flag++;
}
if(signatureImageSchool!=null){
flag++
}
if(flag!=0){
showSchoolSignature(currentStation,currentTime,signatureImage,signatureImageSchool)
}else{
layer.msg("未提供签名");
}
}
})
})
}
function drawSchoolYearScope(){
var valueData=[];
var timeData=getYearTime();
for(var i=0;i<timeData.length;i++){
for(var j=0;j<schoolScopeList.length;j++){
if(timeData[i]==schoolScopeList[j]["schoolTime"]){
valueData.push(schoolScopeList[j]["scoreTotal"]);
break;
}
}
}
drawSchoolYearScopeChart(timeData,valueData);
}
function starRatingSelectOptions(){
var options=``;
for(var i=0;i<schoolBasicInfo.length;i++){
var name=schoolBasicInfo[i]["name"]
var borough=schoolBasicInfo[i]["borough"]
if(currentBorough==borough){
currentStation=name;
options+=`<option value="${name}" selected>${name}</option>`;
}
}
return options;
}
function getYearTime(){
var arr=[];
for(var i=0;i<yearTimeList.length;i++){
arr.push(yearTimeList[i]["schoolTime"])
}
return arr;
}
//获取年
function getYearOption(){
var yearList=getYearTime();
var options="请选择年份";
for(var i=0;i<yearList.length;i++){
if(yearList[i]==currenYearNewTime){
currentTime=currenYearNewTime
options+=`<option value=${yearList[i]} selected>${yearList[i]}</option>`
}else{
options+=`<option value=${yearList[i]}>${yearList[i]}</option>`
}
}
return options;
}
export {
initSchoolSelect,
schoolScopeList,
getYearOption
}