201 lines
6.4 KiB
JavaScript
201 lines
6.4 KiB
JavaScript
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: `<div class="polyMarker-cusmarker">
|
|
<img src="./image/clockMarker.png">
|
|
<span> ${cluster.getChildCount()}</span>
|
|
</div>` });
|
|
}});
|
|
schoolNoSignMarkers_cus= L.markerClusterGroup({iconCreateFunction: function(cluster) {
|
|
return L.divIcon({ html: `<div class="polyMarker-cusmarker polyMarker-cusmarke_no">
|
|
<img src="./image/noClockMarker.png">
|
|
<span> ${cluster.getChildCount()}</span>
|
|
</div>` });
|
|
}});
|
|
}
|
|
|
|
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<data.length;i++){
|
|
if(!(currentSchoolName in stationClockEventlist)){
|
|
stationClockEventlist[currentSchoolName]=[];
|
|
}
|
|
stationClockEventlist[currentSchoolName].push(data[i]);
|
|
}
|
|
}
|
|
getschoolClockRecordsContent();
|
|
}
|
|
})
|
|
}
|
|
|
|
function getschoolClockRecordsContent(){
|
|
clockMarkerHash[currentSchoolName].unbindPopup();
|
|
clockMarkerHash[currentSchoolName].bindPopup(
|
|
`<div>
|
|
<p>${currentSchoolName}</p>
|
|
${getSignEventDiv()}
|
|
</div>`,
|
|
{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+=`<p>打卡记录:(${eventList.length})</p> <div class="schoolClockRecords">`;
|
|
}else{
|
|
p+=`<p>无打卡记录</p>`
|
|
}
|
|
for(var i=0;i<eventList.length;i++){
|
|
console.log(eventList)
|
|
var station=eventList[i]['station'];
|
|
var personId=eventList[i]['personId'];
|
|
var personName=eventList[i]['personName'];
|
|
var personType=getPersonClockType(eventList[i]['personType']);
|
|
var signTimestamp=eventList[i]['signTimestamp'];
|
|
p+=`<p station="${station}" personId="${personId}">
|
|
<span>${personName}</span>
|
|
<span style="margin:0 10px;">[${personType}]</span>
|
|
<span>${signTimestamp}</span>
|
|
<button type="button" class="layui-btn layui-btn-normal">详情</button>
|
|
</p>`
|
|
}
|
|
}
|
|
p+=`</div>`
|
|
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<eventList.length;i++){
|
|
if(personId==eventList[i]['personId']){
|
|
showSchoolClockInfo(eventList[i]);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
function signEventlist(data){
|
|
var signEventUrl=stationurl+"/firectrl/school/sign_event/getlist";
|
|
return axios({
|
|
method: 'post',
|
|
url:signEventUrl,
|
|
data:data
|
|
})
|
|
}
|
|
|
|
export {
|
|
drawSchoolClockMarker,
|
|
showSchoolBaseInfo,
|
|
signEventlist,
|
|
getPersonClockType
|
|
} |