133 lines
3.8 KiB
JavaScript
133 lines
3.8 KiB
JavaScript
|
import {mapUrl,stationurl,brigade} from "../../../public/js/url.js";
|
||
|
import {getstationcount,stationInfoPageReq} from "./orgApi/getStationInfo.js";
|
||
|
import {connectClockStationWebsocket} from "../api/stationDeviceWebsocket.js"
|
||
|
import {drawSchoolClockMarker} from "./marker/schoolMarker.js";
|
||
|
import {initClockSchoolSearchSelect} from "./schoolSearch.js"
|
||
|
import {} from "./event.js"
|
||
|
var clockMap=null;
|
||
|
var layuiObj={};
|
||
|
var clockStationsInfoArr=[];
|
||
|
var signedSchoolArr=[];
|
||
|
var clockloginInfo=null;
|
||
|
|
||
|
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");
|
||
|
clockloginInfo=JSON.parse(loginJson);
|
||
|
axios.defaults.headers.common['Authorization'] = clockloginInfo["session"];
|
||
|
clockMapInit();
|
||
|
})
|
||
|
|
||
|
async function clockMapInit(){
|
||
|
clockMap = L.map('clockMap',{
|
||
|
center: [28.19,113.03],
|
||
|
zoom: 15,
|
||
|
attributionControl:false,
|
||
|
zoomControl:false,
|
||
|
minZoom :1,
|
||
|
maxZoom :18
|
||
|
});
|
||
|
L.tileLayer(`${mapUrl}/roadmap/{z}/{x}/{y}.png`, {
|
||
|
attribution: ''
|
||
|
}).addTo(clockMap);
|
||
|
|
||
|
//获取学校的信息
|
||
|
var stationcountRes=await getstationcount();
|
||
|
var stationcount=stationcountRes.data.data.count;
|
||
|
var stationlistRes= await stationInfoPageReq(stationcount)
|
||
|
stationlistRes.forEach(item=>{
|
||
|
var data=item.data.data;
|
||
|
for(let i=0;i<data.length;i++){
|
||
|
clockStationsInfoArr.push(data[i]);
|
||
|
}
|
||
|
})
|
||
|
//获取今天已经打卡的学校
|
||
|
var signedSchoolsReq = await getSignedSchools();
|
||
|
signedSchoolArr=signedSchoolsReq.data.data;
|
||
|
|
||
|
//合并数据
|
||
|
bindClockAndSchoolData();
|
||
|
//显示打卡的信息
|
||
|
initSchoolSignedData();
|
||
|
//初始化下拉框
|
||
|
initClockSchoolSearchSelect();
|
||
|
//连接websocket
|
||
|
connectClockStationWebsocket();
|
||
|
}
|
||
|
|
||
|
async function initSchoolSignedData(){
|
||
|
//显示打卡信息
|
||
|
showSignedSchools();
|
||
|
//画打卡点位
|
||
|
drawSchoolClockMarker();
|
||
|
}
|
||
|
|
||
|
function bindClockAndSchoolData(){
|
||
|
for(var i=0;i<clockStationsInfoArr.length;i++){
|
||
|
var station=clockStationsInfoArr[i]["name"];
|
||
|
for(var j=0;j<signedSchoolArr.length;j++){
|
||
|
if(station==signedSchoolArr[j]["station"]){
|
||
|
signedSchoolArr[j]={...clockStationsInfoArr[i],...signedSchoolArr[j]}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
function getSignedSchools(){
|
||
|
// var signUrl=stationurl+"/firectrl/client/sign/get_signed_schools";
|
||
|
var signUrl=stationurl+"/firectrl/client/statistics/stations_last_list";
|
||
|
var data={brigade}
|
||
|
return axios({
|
||
|
method: 'post',
|
||
|
url:signUrl,
|
||
|
data:data
|
||
|
})
|
||
|
}
|
||
|
|
||
|
function showSignedSchools(){
|
||
|
$(".pointTotalCount").html(signedSchoolArr.length);
|
||
|
var pointCount=0;
|
||
|
var totalsign=0;
|
||
|
var volunteer_sign=0;
|
||
|
var police_sign=0;
|
||
|
var guarder_sign=0;
|
||
|
|
||
|
signedSchoolArr.forEach(item=>{
|
||
|
if(item["totalsign"]>0){
|
||
|
totalsign+=item["totalsign"];//总的
|
||
|
volunteer_sign+=item["volunteer_sign"];//志愿者
|
||
|
police_sign+=item["police_sign"];//警察
|
||
|
guarder_sign+=item["guarder_sign"];//保安
|
||
|
pointCount++;
|
||
|
|
||
|
}
|
||
|
})
|
||
|
|
||
|
|
||
|
$(".totalsign").html(totalsign);
|
||
|
$(".volunteer_sign").html(volunteer_sign);
|
||
|
$(".police_sign").html(police_sign);
|
||
|
$(".guarder_sign").html(guarder_sign);
|
||
|
$(".fininshPointCount").html(pointCount);
|
||
|
$(".no_sign").html(signedSchoolArr.length-pointCount);
|
||
|
}
|
||
|
|
||
|
export {
|
||
|
clockStationsInfoArr,
|
||
|
signedSchoolArr,
|
||
|
clockloginInfo,
|
||
|
clockMap,
|
||
|
layuiObj,
|
||
|
initSchoolSignedData
|
||
|
}
|