anxiao_web/pages/starrating/js/pop/starRatingDetail.js

393 lines
15 KiB
JavaScript
Raw Permalink Normal View History

2024-07-24 09:22:32 +08:00
import {
getSchoolLevelTitle,
getSchoolInSafeDiv,
getSchoolOutSafeDiv,
getHiddenRectifDiv,
getLegalEducationDiv,
getEmergencyResponseDiv,
getPlusesDiv
} from "./getStarRatingText.js";
import { stationurl } from "../../../../public/js/url.js";
import {layuiObj,starRatingArr } from "../index.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(starRatingArr)
initBoroughSelect();
}
});
}
function initBoroughSelect(){
var boroughArr=[];
for(var i=0;i<starRatingArr.length;i++){
var borough=starRatingArr[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 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(currentSchoolRatingDetailArr);
break;
case "2":
showSchoolOutScopePopPage(currentSchoolRatingDetailArr);
break;
case "3":
showHiddenRectifPopPage(currentSchoolRatingDetailArr);
break;
case "4":
showLegalEducationPopPage(currentSchoolRatingDetailArr);
break;
case "5":
showEmergencyResponsePopPage(currentSchoolRatingDetailArr);
break;
case "6":
showPlusesPopPage(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(starRatingDetail){
layuiObj.layer.open({
type: 1,
title:`${starRatingDetail["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(starRatingDetail){
layuiObj.layer.open({
type: 1,
title: `${starRatingDetail["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(starRatingDetail){
layuiObj.layer.open({
type: 1,
title:`${starRatingDetail["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(starRatingDetail){
layuiObj.layer.open({
type: 1,
title: `${starRatingDetail["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(starRatingDetail){
layuiObj.layer.open({
type: 1,
title: `${starRatingDetail["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 getGradeValue(score_total){
var value=0;
if(score_total<=20){
value=1;
}else if(score_total<=40){
value=2;
}else if(score_total<=60){
value=3;
}else if(score_total<=80){
value=4;
}else if(score_total<=100){
value=5;
}
return value;
}
function showPlusesPopPage(starRatingDetail){
layuiObj.layer.open({
type: 1,
title: `${starRatingDetail["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,
showSchoolInScopePopPage,
showSchoolOutScopePopPage,
showHiddenRectifPopPage,
showLegalEducationPopPage,
showEmergencyResponsePopPage
}