import {signedSchoolArr,clockMap} from "../index.js"; import {stationurl,brigade} from "../../../../public/js/url.js"; import {getCurrData} from "../../../../public/js/timestamp.js"; import { showSchoolClockInfo } from "../event.js"; var schoolInSignMarkers_cus=null; var schoolNoSignMarkers_cus=null; var clockMarkerHash={}; var stationClockEventlist={}; var currentSchoolName=""; function addClockMarkerHash(name,marker){ clockMarkerHash[name]=marker; } function initSchoolClockCus(){ schoolInSignMarkers_cus = L.markerClusterGroup({iconCreateFunction: function(cluster) { return L.divIcon({ html: `
${cluster.getChildCount()}
` }); }}); schoolNoSignMarkers_cus= L.markerClusterGroup({iconCreateFunction: function(cluster) { return L.divIcon({ html: `
${cluster.getChildCount()}
` }); }}); } function emptySignMarkers_cus(){ signedSchoolArr.forEach(item=>{ var name=item["name"]; if(name in clockMarkerHash){ clockMarkerHash[name].unbindPopup(); schoolInSignMarkers_cus=null; schoolNoSignMarkers_cus=null; } }) initSchoolClockCus(); } function drawSchoolClockMarker(){ emptySignMarkers_cus(); signedSchoolArr.forEach(item=>{ let longitude=item["longitude"]; let latitude=item["latitude"]; let name=item["name"]; let totalsign=item["totalsign"]; if(totalsign>0){ var iconObj=L.icon({ iconUrl:"./image/clockMarker.png",//图片路径 iconSize: [24, 24]//图片大小设置 }); }else{ var iconObj=L.icon({ iconUrl:"./image/noClockMarker.png",//图片路径 iconSize: [24, 24]//图片大小设置 }); } let marker=L.marker([latitude,longitude],{ icon: iconObj,//将marker设置为上面引用的图形 }); marker.bindTooltip(name).openTooltip(); marker.on('click',function(e){ showSchoolBaseInfo(item) }) addClockMarkerHash(name,marker); if(totalsign>0){ schoolInSignMarkers_cus.addLayer(marker); }else{ schoolNoSignMarkers_cus.addLayer(marker); } }) clockMap.addLayer(schoolNoSignMarkers_cus); clockMap.addLayer(schoolInSignMarkers_cus); } function showSchoolBaseInfo(obj){ currentSchoolName=obj["name"]; var data={ "brigade":brigade, "station":currentSchoolName, "start":getCurrData()+" 00:00:00", "end":getCurrData()+" 23:59:59", "year":-1, "month":-1, "day":-1 } if(currentSchoolName in stationClockEventlist){ stationClockEventlist[currentSchoolName]=[]; } signEventlist(data).then(res=>{ var code=res["data"]["code"]; if(code==0){ var data=res["data"]["data"]; if(data.length==0){ stationClockEventlist[currentSchoolName]=[]; }else{ for(var i=0;i

${currentSchoolName}

${getSignEventDiv()} `, {className:"schoolWindowInfo"}).openPopup(); var lnglat=clockMarkerHash[currentSchoolName].getLatLng() clockMap.setView(lnglat, 18); signRecordEvent(); } function getPersonClockType(type){ switch(type){ case "policeman": return "护校警力"; case "guarder": return "专职保安"; case "volunteer": return "志愿者"; case "school.manager": return "教育部门"; case "police.manager": return "公安部门"; default: return "未知"; } } function getSignEventDiv(){ var p="" if((currentSchoolName in stationClockEventlist)){ var eventList=stationClockEventlist[currentSchoolName]; if(eventList.length!=0){ p+=`

打卡记录:(${eventList.length})

`; }else{ p+=`

无打卡记录

` } for(var i=0;i ${personName} [${personType}] ${signTimestamp}

` } } p+=`
` return p; } //查看打卡详情 function signRecordEvent(){ $(".schoolClockRecords>p>button").on('click',function(){ var station=$(this).parent().attr("station"); var personId=$(this).parent().attr("personId"); if((station in stationClockEventlist)){ var eventList=stationClockEventlist[currentSchoolName]; for(var i=0;i