//Объезды
class TGeofences //Current user with role name and access
{
constructor(map){
this.groups = [];
this.geofences = [];
//Глобальный Vue шаблон для отображения группы списке
Vue.component('c_geofence', {
props: ["geofence","index"],
template: `
{{geofence.name}}
{{geofence.count}}
`+trt('Geofence_type')+` : {{geofence.geofence_type_name}}
`,
computed:{
color: function(){
let result="";
if (this.index%2==0) result='var(--row-color-1)'; else result='var(--row-color-2)';
return result;
}
},
methods: {
edit() {
this.geofence.parent.editDetour({id: this.geofence.id});
},
del() {
this.geofence.del();
}
},
mounted() {
}
});
}
//Получаем список объектов
//Фильтруем объекты для заполнения в таблицу
filtering()
{
showProgressBar(document.getElementById('id5_geofences'));
let data = {
geofence_type_id: document.getElementById("geofence_type_id_id0").value,
name: document.getElementById("filter_name_geofences").value
};
$.ajax({
url: '/monitoring/pscripts/geofences.php?fn=1',
data: JSON.stringify(data),
//contentType: 'application/json; charset=utf-8',
type: "POST",
//dataType: "json",
dataType: "text",
success: (data,status) => {
if(status=='success')
{
try{
data=JSON.parse(data);
}catch(e)
{
alert2(trt('Error'),'Parsing error: ' + e.name + ":" + e.message,e.stack);
hideProgressBar('id5_geofences');
return;
}
if(data!=null)
{
if(data.errorCode==0)
{
let count=0;
this.groups.splice(0,this.groups.length); //Чистим
//let features = [];
//g_vectorSource.clear(false);
//g_vectorSource.addFeatures(features);
for(let i=0;i
`+trt('View')+`. `+trt('Geofence_name')+` `+trt('Points')+`
`;
let app = new Vue({
data: {
message: 'Hello Vue!',
color: false,
groups: this.groups
},
methods: {
setMessage: function(event){
/*this.message = event.target.value;
if(this.message=='123')
this.color = true;
else
this.color = false;*/
}
}
});
div.innerHTML=html;
app.$mount('#id5_geofences');
let hideObjectsBtn = document.getElementById("hideGeofencesBtn");
if(hideObjectsBtn!=null) hideObjectsBtn.onclick = ()=>{this.hide();};
return;
/*
var div=document.getElementById("id5_geofences");
delChild(div);
div.innerHTML=''+trt('View')+'. '+trt('Geofence_name')+' '+trt('Points')+'
';
var theTable = document.getElementById('thetable_geofences');
let type_name='';
for(i=0;i';
tr.appendChild(td);
td = document.createElement('td');
td.style.cssText="text-align: center;";
td.innerHTML=' ';
tr.appendChild(td);
td = document.createElement('td');
td.style.cursor='pointer';
td.innerHTML=this.geofences[i].name;
td.onclick=function(detour){
return function(){
detour.goToCenter();
}
}(this.geofences[i]);
tr.appendChild(td);
td = document.createElement('td');
td.style.cssText='cursor:pointer;text-align:right;';
td.innerHTML=this.geofences[i].count;
td.onclick=function(detour){
return function(){
detour.goToCenter();
}
}(this.geofences[i]);
tr.appendChild(td);
theTable.tBodies[0].appendChild(tr);
//Формирую раскрывающийся список
var tr = document.createElement('tr');
tr.id=this.geofences[i].id;
tr.style.cssText="background-color:var(--back-color-3);display:none";
td = document.createElement('td');
td.colSpan=4;
let html='';
if(this.geofences[i].geofence_type_name!=null)
html+='Тип геозоны'+trt('')+' : '+this.geofences[i].geofence_type_name+' ';
html+='
';
td.innerHTML=html;
tr.appendChild(td);
theTable.tBodies[0].appendChild(tr);
var cell=document.getElementById("geofences_ch_"+this.geofences[i].id);
cell.onclick=function(route){
return function(){
var chb=document.getElementById("geofences_ch_"+route.id);
route.visible = chb.checked;
}
}(this.geofences[i]);
//Кнопка разсрыть список
var btn=document.getElementById('geofences_down_btn_'+this.geofences[i].id);
btn.onclick=function(tr,thiz,id){ return function(){
var btn=document.getElementById('geofences_down_btn_'+id);
if(btn.src.indexOf("right.png")!=-1)
{
btn.src = '/resources/images/down.png';
tr.style.display = 'table-row';
}else if(btn.src.indexOf("down.png")!=-1)
{
btn.src = '/resources/images/right.png';
tr.style.display = 'none';
}
}; }(tr,this,this.geofences[i].id);
//Кнопка удалить
btn=document.getElementById('detour_del_'+this.geofences[i].id)
btn.onclick=function(thiz,id){ return function(){ thiz.deleteDetour({id:id}); }; }(this,this.geofences[i].id);
//Кнопка редактировать
btn=document.getElementById('detour_edit_'+this.geofences[i].id)
btn.onclick=function(thiz,id){ return function(){ thiz.editDetour({id:id}); }; }(this,this.geofences[i].id);
}
//Количество элементов в дереве
var divCnt = document.getElementById("count_geofences");
delChild(divCnt);
divCnt.appendChild(document.createTextNode(this.geofences.length));
//По нажатию на заголовок инвертируем чекбуксы
divCnt = document.getElementById("cell_ch_D");
divCnt.onclick=function(thiz){
return function(){
thiz.hide();
}
}(this);
*/
}
createDetour()
{
//В настройках передаю центр карты
let center=ol.proj.transform(g_map.getView().getCenter(), 'EPSG:3857','EPSG:4326');
let eRec = new EdtRec("");
eRec.eRecNa("Geofences",-1,' ');
eRec.win.onClose=function(thiz){ return function(){ thiz.filtering();};}(this);
}
editDetour(settings)
{
if (typeof settings === 'string' || settings instanceof String)
{
try {
settings = JSON.parse(settings);
} catch (e) {
alert(e.message);
return;
}
}
let detour=this.getDetourByID(settings.id);
let eRec = new EdtRec("");
eRec.eRecNa("Geofences",settings.id);
eRec.win.setCenter();
eRec.win.onClose=function(thiz,detour){ return function(){
detour.showPoints(false);
};}(this,detour);
if(detour!=null)
{
detour.showPoints(true);
detour.visible=true;
}
}
//Вернуть объект TDetour по идентификатору
getDetourByID(id)
{
for(let i=0;i{
let data = {
id: this.id
};
$.ajax({
url: '/monitoring/pscripts/geofences.php?fn=3',
data: JSON.stringify(data),
contentType: 'application/json; charset=utf-8',
type: "POST",
dataType: "json",
success: (data,status)=>{
if(status=='success')
{
if(data.errorCode==0)
{
this.parent.filtering();
}else
{
alert2(trt('Error'),data.errorMessage);
}
}else
{
alert2(trt('Error'),trt('Failed_to_complete_the_request'));
}
},
error: ()=>{
alert2(trt('Error'),trt('Failed_to_complete_the_request'));
}
});
return true;
},
null);
}
}