anxiao_web/pages/cmddispatch/js/schoolBaseInfo.js

286 lines
8.1 KiB
JavaScript

import { boroughInfoArr,layuiObj,skynetIpcInfo ,schoolStarRatinglistArr} from "./index.js";
import { getEntranceStaffSign,showEntranceStaffSign } from "./orgApi/getEntranceStaffSign.js";
import {showSchoolMarkerInfo} from "./marker/schoolMarker.js";
import { iframeVideoUrl } from "../../../public/js/url.js";
function showSchoolBaseInfo(obj){
var div=getSchoolInfoDiv(obj);
$(".schoolBaseInfo").html(div);
$(".schoolName").html(obj["name"]);
for(var i=0;i<schoolStarRatinglistArr.length;i++){
if(obj["name"]==schoolStarRatinglistArr[i]["station"]){
var total=schoolStarRatinglistArr[i]["scoreTotal"]
var value= getGradeValue(total)
//显示文字
layuiObj["rate"].render({
elem: '.schoolInfoGrade',
value: value ,//初始值
readonly:true
});
break;
}
}
$(".policeName").html(obj["borough"])
showBoroughInfo(obj);
//显示marker的info
showSchoolMarkerInfo(obj)
//在右下角显示学校的三个摄像图
showStationIpcRightVideo(obj);
}
function showStationIpcRightVideo(obj){
var tempArr=[];
if("station" in obj){
var station=obj["station"];
}else{
var station=obj["name"];
}
for(var i=0;i<skynetIpcInfo.length;i++){
if(station==skynetIpcInfo[i]["station"]){
tempArr.push(skynetIpcInfo[i]);
}
}
var div="";
for(var j=0;j<tempArr.length;j++){
if(j>3){
break;
}else{
var token=tempArr[j]["pointCode"]
div+=`<div state="free" deviceid='${token}'>
<div class="videoPlay" >
${getIframeUrl(token)}
</div>
</div>`;
}
}
$(".videoMonitor").html(div);
setVideoSize(tempArr.length)
}
window.addEventListener('message', function(e) {
var data=e.data
var cmd=data["cmd"];
var deviceid=data["deviceid"]
if(cmd=="closePage"){
closeIpcVideoPage(deviceid);
}
})
function closeIpcVideoPage(token){
var vdiv=$(".videoMonitor>div");
for(var i=0;i<vdiv.length;i++){
var thisDiv=vdiv[i];
var deviceid=$(thisDiv).attr("deviceid");
if(token==deviceid){
$(thisDiv).empty();
}
}
}
function getIframeUrl(token){
var url=`${iframeVideoUrl}?token=${token}&autoplay=true`
return `
<iframe src='${url}' allowfullscreen="true"></iframe>
`
}
function setVideoSize(value){
switch(value){
case 1:
$(".videoMonitor>div").css("width","100%").css("height","100%");
break;
case 2:
// $(".videoMonitor>div").css("width","220px").css("height","100%");
// break;
case 3:
// $(".videoMonitor>div").css("width","220px").css("height","50%");
// $(".videoMonitor>div:last-child").css("width","100%")
//break;
case 4:
$(".videoMonitor>div").css("width","220px").css("height","50%");
break;
default:
$(".videoMonitor>div").css("width","220px").css("height","50%");
break;
}
}
function getSchoolInfoDiv(obj){
var station=obj["name"];
var scoreInsideManage=0;
var scoreOutsideManage=0;
var scoreRiskManage=0;
var scoreLawEducation=0;
var scoreEmcManage=0;
var scoreBonus=0;
for(var i=0;i<schoolStarRatinglistArr.length;i++){
if(station==schoolStarRatinglistArr[i]["station"]){
scoreInsideManage=schoolStarRatinglistArr[i]["scoreInsideManage"]
scoreOutsideManage=schoolStarRatinglistArr[i]["scoreOutsideManage"]
scoreRiskManage=schoolStarRatinglistArr[i]["scoreRiskManage"]
scoreLawEducation=schoolStarRatinglistArr[i]["scoreLawEducation"]
scoreEmcManage=schoolStarRatinglistArr[i]["scoreEmcManage"]
scoreBonus=schoolStarRatinglistArr[i]["scoreBonus"]
break;
}
}
return `
<div class="sb_bInfo">
<div>
<p>
<span>校园名称:</span>
<span title=${obj["name"]}>${obj["name"]}</span>
</p>
<p>
<span>校园地址:</span>
<span title=${obj["address"]}>${obj["address"]}</span>
</p>
</div>
<div>
<p>
<span>派出所:</span>
<span>${obj["borough"]}</span>
</p>
<p>
<span>警务区:</span>
<span>${obj["detachment"]}</span>
</p>
</div>
<div>
<p>
<span>校长:</span>
<span>${obj["legal_person"]}(${obj["legal_person_phone"]})</span>
</p>
<p>
<span>综治专干:</span>
<span></span>
</p>
</div>
</div>
<div class="sb_Device">
<div>
<p>
<span>职工数量:</span>
<span>0</span>
</p>
<p>
<span>学生数量:</span>
<span>0</span>
</p>
<p>
<span>安保人员:</span>
<span>0</span>
</p>
<p>
<span>校车数量:</span>
<span>0</span>
</p>
</div>
<div>
<p>
<span>登记车辆:</span>
<span>0</span>
</p>
<p>
<span>校外监控:</span>
<span>0</span>
</p>
<p>
<span>校内监控:</span>
<span>0</span>
</p>
<p>
<span>安装率:</span>
<span>80%</span>
</p>
</div>
</div>
<div class="sb_grade">
<div>
<div>
<p>校内安全</p>
<p>${scoreInsideManage}</p>
</div>
<div>
<p>周边安全</p>
<p>${scoreOutsideManage}</p>
</div>
<div>
<p>隐患整改</p>
<p>${scoreRiskManage}</p>
</div>
<div>
<p>法治宣传</p>
<p>${scoreInsideManage}</p>
</div>
<div>
<p>应急处置</p>
<p>${scoreEmcManage}</p>
</div>
<div>
<p>加分项</p>
<p>${scoreBonus}</p>
</div>
</div>
</div>
`
}
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 showBoroughInfo(obj){
var borough=obj["borough"];
var div=``;
for(var i=0;i<boroughInfoArr.length;i++){
if(boroughInfoArr[i]["borough"]==borough){
div+=`
<div class="sb_bInfo">
<div>
<p>
<span>派出所:</span>
<span>${boroughInfoArr[i]["legal_person"]}(${boroughInfoArr[i]["phone"]})</span>
</p>
<p>
<span>派出所地址:</span>
<span>${boroughInfoArr[i]["address"]}</span>
</p>
</div>
</div>
<div class="policeInfoTableBox">
<table class="layui-hide" id="policeInfoTable" lay-filter="policeInfoTable"></table>
</div>
`;
}
}
$(".policeBaseInfo").html(div);
getEntranceStaffSign(obj).then(res=>{
var code=res["data"]["code"];
if(code==0){
var data=res["data"]["data"];
showEntranceStaffSign(data)
}
})
}
export {
showSchoolBaseInfo,
getSchoolInfoDiv,
getGradeValue,
getIframeUrl,
showStationIpcRightVideo,
}