anxiao_web/pages/poplayui/levelJudge.js

399 lines
15 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { stationurl } from "../../public/js/url.js";
import { layuiObj,schoolStarRatinglistArr} from "../../pages/cmddispatch/js/index.js"
import {getSchoolOptions} from "../cmddispatch/js/tree.js"
import {getGradeValue} from "../cmddispatch/js/schoolBaseInfo.js";
import {
getSchoolLevelTitle,
getSchoolInSafeDiv,
getSchoolOutSafeDiv,
getHiddenRectifDiv,
getLegalEducationDiv,
getEmergencyResponseDiv,
getPlusesDiv
} from "../cmddispatch/getText/starRating.js";
function showLevelJudge(){
layuiObj.layer.open({
type: 1,
title: '星级评定', //不显示标题栏
area: ['1360px', '600px'],
shade: 0.6,
id:new Date().getTime(), //设定一个id防止重复弹出
btnAlign: 'c',
moveType: 1, //拖拽模式0或者1
content: `<div style="padding:10px;color:#fff;background:#032357;height:calc(100% - 20px);overflow-y:auto;">
<div class="legalitySchoolInfo">
<form class="layui-form" action="" id="legalitySchoolForm" lay-filter="legalitySchoolForm" >
<div class="layui-input-inline">
<select name="interest" lay-filter="legalityBoroughSelect" id="legalityBoroughSelect" lay-search></select>
</div>
<div class="layui-input-inline">
<button class="layui-btn" id="legalitySchoolBtn" style="height:38px !important;line-height:38px !important;">查询</button>
</div>
</form>
</div>
<div class="staffSignSelectContent">
<table class="layui-hide" id="legalitySchoolTable" lay-filter="legalitySchoolTable"></table>
</div>
</div>`,
success: function(layero){
legalitySchoolFromRender();
showlegalitySchoolContent(schoolStarRatinglistArr)
initBoroughSelect();
}
});
}
function initBoroughSelect(){
var boroughArr=[];
for(var i=0;i<schoolStarRatinglistArr.length;i++){
var borough=schoolStarRatinglistArr[i]["borough"];
if(boroughArr.indexOf(borough)==-1){
boroughArr.push(borough);
}
}
var options=`<option value="000">请选择派出所</option>`;
boroughArr.forEach(item=>{
options+=`<option value="${item}">${item}</option>`
})
$("#legalityBoroughSelect").html(options);
layuiObj.layuiForm.render("select","legalitySchoolForm");
$("#legalityBoroughSelect").siblings("div.layui-form-select").find("div.layui-select-title").find("input").attr("onfocus","this.select()");
}
function legalitySchoolFromRender(){
$("#legalitySchoolSelect").html(getSchoolOptions());
layuiObj.layuiForm.render("select","legalitySchoolForm");
$("#legalitySchoolBtn").on('click',function(e){
e.preventDefault();
var borough=$("#legalityBoroughSelect").find("option:selected").val();
if(borough=="000"){
showlegalitySchoolContent(schoolStarRatinglistArr);
}else{
var arr=[];
for(var i=0;i<schoolStarRatinglistArr.length;i++){
if(schoolStarRatinglistArr[i]["borough"]==borough){
arr.push(schoolStarRatinglistArr[i]);
}
}
showlegalitySchoolContent(arr)
}
})
}
function getSchoolBtnLevel(type,value){
var className="";
switch(type){
case "scoreTotal"://总分
if(value>80){
className="layui-btn-normal";
}else{
className="layui-btn-danger";
}
break;
case "scoreInsideManage"://校内安全(20)
if((value/20)*100>80){
className="layui-btn-normal";
}else{
className="layui-btn-danger";
}
break;
case "scoreInsideManage"://周边安全(20)
if((value/20)*100>80){
className="layui-btn-normal";
}else{
className="layui-btn-danger";
}
break;
case "scoreRiskManage"://隐患整改(25)
if((value/25)*100>80){
className="layui-btn-normal";
}else{
className="layui-btn-danger";
}
break;
case "scoreLawEducation"://法治宣传(15)
if((value/15)*100>80){
className="layui-btn-normal";
}else{
className="layui-btn-danger";
}
break;
case "scoreEmcManage"://应急处置(20)
if((value/20)*100>80){
className="layui-btn-normal";
}else{
className="layui-btn-danger";
}
break;
default:
break;
}
return `<button type="button" class="layui-btn ${className}">${value}</button>`;
}
function showlegalitySchoolContent(data){
layuiObj.layuitable.render({
elem:'#legalitySchoolTable',
data:data,
cols: [[
{field:'station', width:"9%", title: '学校名称'},
{field:'scoreTotal', width:"13%", title: '安全等级',templet : function(data) {// 替换数据
return `<div id="avgScore${data['station']}"></div>`;
}
},
{field:'scoreTotal', width:"7%", title: '总分',event:"7",templet : function(data) {// 替换数据
return getSchoolBtnLevel('scoreTotal',data["scoreTotal"]);
}},
{field:'scoreInsideManage', width:"11%", title: '校内安全(20)分',event:"1",templet : function(data) {// 替换数据
return getSchoolBtnLevel('scoreInsideManage',data["scoreInsideManage"]);
}},
{field:'scoreOutsideManage', width:"11%", title: '周边安全(20)分',event:"2",templet : function(data) {// 替换数据
return getSchoolBtnLevel('scoreOutsideManage',data["scoreOutsideManage"]);
}},
{field:'scoreRiskManage', width:"11%", title: '隐患整改(25)分',event:"3",templet : function(data) {// 替换数据
return getSchoolBtnLevel('scoreRiskManage',data["scoreRiskManage"]);
}},
{field:'scoreLawEducation', width:"11%", title: '法治宣传(15)分',event:"4",templet : function(data) {// 替换数据
return getSchoolBtnLevel('scoreLawEducation',data["scoreLawEducation"]);
}},
{field:'scoreEmcManage', width:"11%", title: '应急处置(20)分',event:"5",templet : function(data) {// 替换数据
return getSchoolBtnLevel('scoreEmcManage',data["scoreEmcManage"]);
}},
{field:'scoreBonus', width:"8%", title: '加分项',event:"6",templet : function(data) {// 替换数据
return `<button type="button" class="layui-btn layui-btn-normal">${data["scoreBonus"]}</button>`;
}},
]],
limit:Number.MAX_VALUE, // 数据表格默认全部显示
done:function(res, curr, count){
var data = res.data;//返回的json中data数据
data.forEach(item => {
var value= getGradeValue(item["scoreTotal"]);
layuiObj["rate"].render({
elem:`#avgScore${item['station']}`,
value:value,
readonly:true
});
});
}
});
layuiObj.layuitable.on('tool(legalitySchoolTable)', function(obj){
var event=obj["event"];
var data=obj["data"]
legalitySchoolScorePage(event,data);
})
}
function updateStarRatingDetailValue(){
currentSchoolRatingDetailArr["inResponsibility"]=currentSchoolRatingDetailArr["inResponsibility"]/10;
currentSchoolRatingDetailArr["inTeamBuild"]=currentSchoolRatingDetailArr["inTeamBuild"]/10;
currentSchoolRatingDetailArr["inDevicesSetup"]=currentSchoolRatingDetailArr["inDevicesSetup"]/10;
currentSchoolRatingDetailArr["inFireManage"]=currentSchoolRatingDetailArr["inFireManage"]/10;
currentSchoolRatingDetailArr["inDangerousManage"]=currentSchoolRatingDetailArr["inDangerousManage"]/10;
currentSchoolRatingDetailArr["inSmartSecurity"]=currentSchoolRatingDetailArr["inSmartSecurity"]/10;
currentSchoolRatingDetailArr["inSecurityScheme"]=currentSchoolRatingDetailArr["inSecurityScheme"]/10;
currentSchoolRatingDetailArr["outPeakGuard"]=currentSchoolRatingDetailArr["outPeakGuard"]/10;
currentSchoolRatingDetailArr["outRiskPrevent"]=currentSchoolRatingDetailArr["outRiskPrevent"]/10;
currentSchoolRatingDetailArr["outTraffic"]=currentSchoolRatingDetailArr["outTraffic"]/10;
currentSchoolRatingDetailArr["outCaseManage"]=currentSchoolRatingDetailArr["outCaseManage"]/10;
currentSchoolRatingDetailArr["riskDangerManage"]=currentSchoolRatingDetailArr["riskDangerManage"]/10;
currentSchoolRatingDetailArr["riskConflictManage"]=currentSchoolRatingDetailArr["riskConflictManage"]/10;
currentSchoolRatingDetailArr["riskProcess"]=currentSchoolRatingDetailArr["riskProcess"]/10;
currentSchoolRatingDetailArr["lawEducation"]=currentSchoolRatingDetailArr["lawEducation"]/10;
currentSchoolRatingDetailArr["lawFirstClass"]=currentSchoolRatingDetailArr["lawFirstClass"]/10;
currentSchoolRatingDetailArr["emcPlan"]=currentSchoolRatingDetailArr["emcPlan"]/10;
currentSchoolRatingDetailArr["emcDrill"]=currentSchoolRatingDetailArr["emcDrill"]/10;
currentSchoolRatingDetailArr["bonus1"]=currentSchoolRatingDetailArr["bonus1"]/10;
currentSchoolRatingDetailArr["bonus2"]=currentSchoolRatingDetailArr["bonus2"]/10;
currentSchoolRatingDetailArr["bonus3"]=currentSchoolRatingDetailArr["bonus3"]/10;
currentSchoolRatingDetailArr["bonus4"]=currentSchoolRatingDetailArr["bonus4"]/10;
currentSchoolRatingDetailArr["bonus5"]=currentSchoolRatingDetailArr["bonus5"]/10;
}
var currentSchoolRatingDetailArr=null;
async function legalitySchoolScorePage(event,data){
var starRatingRes=await getStarRatingDetail(data);
var starRatingDetail=starRatingRes.data.data;
currentSchoolRatingDetailArr=starRatingDetail;
updateStarRatingDetailValue();//把回来的数据除以10
switch(event){
case "1":
showSchoolInScopePopPage(data,currentSchoolRatingDetailArr);
break;
case "2":
showSchoolOutScopePopPage(data,currentSchoolRatingDetailArr);
break;
case "3":
showHiddenRectifPopPage(data,currentSchoolRatingDetailArr);
break;
case "4":
showLegalEducationPopPage(data,currentSchoolRatingDetailArr);
break;
case "5":
showEmergencyResponsePopPage(data,currentSchoolRatingDetailArr);
break;
case "6":
showPlusesPopPage(data,currentSchoolRatingDetailArr);
break;
default:
break;
}
}
function getStarRatingDetail(data){
var data={
"station":data["station"]
}
var loginurl=stationurl+"/iotserver/school/star_detail/getdetail";
return axios({
method: 'post',
url:loginurl,
data: data
})
}
function showSchoolInScopePopPage(data,starRatingDetail){
layuiObj.layer.open({
type: 1,
title:`${data["station"]}-校内安全`, //不显示标题栏
area: ['900px', '600px'],
shade: 0.6,
id:new Date().getTime(), //设定一个id防止重复弹出
btnAlign: 'c',
moveType: 1, //拖拽模式0或者1
content: `<div style="padding:10px;color:#fff;background:#032357;height:calc(100% - 20px);overflow-y:auto;">
<div>
${getSchoolLevelTitle()}
${getSchoolInSafeDiv(starRatingDetail)}
</div>
</div>`,
success: function(layero){
}
});
}
function showSchoolOutScopePopPage(data,starRatingDetail){
layuiObj.layer.open({
type: 1,
title: `${data["station"]}-周边安全`, //不显示标题栏
area: ['900px', '630px'],
shade: 0.6,
id:new Date().getTime(), //设定一个id防止重复弹出
btnAlign: 'c',
moveType: 1, //拖拽模式0或者1
content: `<div style="padding:10px;color:#fff;background:#032357;height:calc(100% - 20px);overflow-y:auto;">
<div>
${getSchoolLevelTitle()}
${getSchoolOutSafeDiv(starRatingDetail)}
</div>
</div>`,
success: function(layero){
}
});
}
function showHiddenRectifPopPage(data,starRatingDetail){
layuiObj.layer.open({
type: 1,
title:`${data["station"]}-隐患整改`, //不显示标题栏
area: ['900px', 'auto'],
shade: 0.6,
id:new Date().getTime(), //设定一个id防止重复弹出
btnAlign: 'c',
moveType: 1, //拖拽模式0或者1
content: `<div style="padding:10px;color:#fff;background:#032357;height:calc(100% - 20px);overflow-y:auto;">
<div>
${getSchoolLevelTitle()}
${getHiddenRectifDiv(starRatingDetail)}
</div>
</div>`,
success: function(layero){
}
});
}
function showLegalEducationPopPage(data,starRatingDetail){
layuiObj.layer.open({
type: 1,
title: `${data["station"]}-法治宣传`, //不显示标题栏
area: ['900px', 'auto'],
shade: 0.6,
id:new Date().getTime(), //设定一个id防止重复弹出
btnAlign: 'c',
moveType: 1, //拖拽模式0或者1
content: `<div style="padding:10px;color:#fff;background:#032357;height:calc(100% - 20px);overflow-y:auto;">
<div>
${getSchoolLevelTitle()}
${getLegalEducationDiv(starRatingDetail)}
</div>
</div>`,
success: function(layero){
}
});
}
function showEmergencyResponsePopPage(data,starRatingDetail){
layuiObj.layer.open({
type: 1,
title: `${data["station"]}-应急处置`, //不显示标题栏
area: ['900px', 'auto'],
shade: 0.6,
id:new Date().getTime(), //设定一个id防止重复弹出
btnAlign: 'c',
moveType: 1, //拖拽模式0或者1
content: `<div style="padding:10px;color:#fff;background:#032357;height:calc(100% - 20px);overflow-y:auto;">
<div>
${getSchoolLevelTitle()}
${getEmergencyResponseDiv(starRatingDetail)}
</div>
</div>`,
success: function(layero){
}
});
}
function showPlusesPopPage(data,starRatingDetail){
layuiObj.layer.open({
type: 1,
title: `${data["station"]}-应急处置`, //不显示标题栏
area: ['900px', '500px'],
shade: 0.6,
id:new Date().getTime(), //设定一个id防止重复弹出
btnAlign: 'c',
moveType: 1, //拖拽模式0或者1
content: `<div style="padding:10px;color:#fff;background:#032357;height:calc(100% - 20px);overflow-y:auto;">
<div>
${getSchoolLevelTitle()}
${getPlusesDiv(starRatingDetail)}
</div>
</div>`,
success: function(layero){
}
});
}
//
export {showLevelJudge}