238 lines
6.6 KiB
JavaScript
238 lines
6.6 KiB
JavaScript
$('[data-mask]').inputmask();
|
|
|
|
$('.select2typeProject').select2();
|
|
$('.select2Reason').select2();
|
|
|
|
$('.pdate-select1').persianDatepicker({
|
|
format: 'YYYY/MM/DD',
|
|
autoClose: true
|
|
});
|
|
|
|
$('.pdate-select2').persianDatepicker({
|
|
format: 'YYYY/MM/DD',
|
|
autoClose: true
|
|
});
|
|
|
|
$('.pdate-select3').persianDatepicker({
|
|
format: 'YYYY/MM/DD HH:MM',
|
|
autoClose: true,
|
|
timePicker: {
|
|
enabled: true
|
|
}
|
|
});
|
|
|
|
$("#status-slider").slider({
|
|
min: 0,
|
|
max: 100,
|
|
value: 0,
|
|
ticks: [0, 100],
|
|
ticks_snap_bounds: 1,
|
|
formatter: function (value) {
|
|
return value + '٪';
|
|
},
|
|
tooltip: 'always',
|
|
tooltip_position:'bottom'
|
|
});
|
|
|
|
var map = L.map('map-layout', {
|
|
center: [35.7130052, 51.3982543],
|
|
zoom: 6,
|
|
minZoom: 5,
|
|
maxZoom: 18,
|
|
layers: [
|
|
L.tileLayer('https://testmap.141.ir/141map/{z}/{x}/{y}.png', {
|
|
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
|
})
|
|
],
|
|
maxBounds: [
|
|
[42.3193359375, 65.1269531256],
|
|
[23.5639871284, 40.5092252948]
|
|
]
|
|
});
|
|
|
|
$('.leaflet-bottom.leaflet-right').hide();
|
|
|
|
$('#prj-form-step-2').hide(0);
|
|
|
|
$('.prj-step .card-main > .card-body > a.btn').click(function () {
|
|
if ($(this).hasClass('btn-next')) {
|
|
let prjStep = $(this).parents('.prj-step');
|
|
|
|
if (prjStep[0].id == 'prj-form-step-1') {
|
|
if ($('input[name=projectName]').val()
|
|
&& $('input[name=sourceCord]').val()
|
|
&& $('input[name=destCord]').val()
|
|
&& $('input[name=calcDistance]').val()
|
|
&& $('select[name=selectOstan]').val()
|
|
&& $('input[name=selectCity]').val()
|
|
&& $('input[name=routeName]').val()
|
|
&& $('input[name=r1]:checked').length > 0
|
|
&& $('.select2typeProject').val().length > 0) {
|
|
if (statusLinePer < 50) {
|
|
changeStatusLine(10);
|
|
}
|
|
prjStep.fadeOut(400);
|
|
prjStep.next().fadeIn(400);
|
|
} else {
|
|
alert('لطفا اطلاعات پروژه را به صورت کامل وارد کنید!');
|
|
}
|
|
}
|
|
} else if (($(this).hasClass('btn-prev'))) {
|
|
let prjStep = $(this).parents('.prj-step');
|
|
prjStep.fadeOut(400);
|
|
prjStep.prev().fadeIn(400);
|
|
//changeStatusLine(-10);
|
|
} else if (($(this).hasClass('btn-finish'))) {
|
|
console.log('finish-form');
|
|
}
|
|
});
|
|
|
|
$('select[name=project-type]').change(function () {
|
|
if ($(this).val() === '1') {
|
|
$('#prj-form-step-3').show();
|
|
if ($('#radioPrimary5').is(':checked')) {
|
|
$('#project-type-sign').show();
|
|
}
|
|
} else {
|
|
$('#prj-form-step-3').hide();
|
|
$('#project-type-sign').hide();
|
|
}
|
|
});
|
|
|
|
$('#radioPrimary4').click(function () {
|
|
if ($(this).is(':checked')) {
|
|
$('#radioPrimary5-box').hide();
|
|
$('#radioPrimary6-box').hide();
|
|
$('#project-type-sign').hide();
|
|
}
|
|
});
|
|
|
|
$('#radioPrimary5').click(function () {
|
|
if ($(this).is(':checked')) {
|
|
$('#radioPrimary5-box').show();
|
|
$('#radioPrimary6-box').hide();
|
|
$('#project-type-sign').hide();
|
|
}
|
|
});
|
|
|
|
$('#radioPrimary6').click(function () {
|
|
if ($(this).is(':checked')) {
|
|
$('#radioPrimary5-box').hide();
|
|
$('#radioPrimary6-box').show();
|
|
if ($('select[name=project-type]').val() === '1') {
|
|
$('#project-type-sign').show();
|
|
}
|
|
}
|
|
});
|
|
|
|
var statusLinePer = 0;
|
|
|
|
var sourceLat = '';
|
|
var sourceLng = '';
|
|
var destLat = '';
|
|
var destLng = '';
|
|
var count = 0;
|
|
|
|
map.on('click', function (e) {
|
|
count++;
|
|
|
|
if (count == 1) {
|
|
$('input[name=sourceCord]').val('(' + e.latlng.lat.toFixed(7) + ')' + ' - ' + '(' + e.latlng.lng.toFixed(7) + ')');
|
|
|
|
sourceLat = e.latlng.lat;
|
|
sourceLng = e.latlng.lng;
|
|
|
|
let sourceMarker = new L.marker(L.latLng(sourceLat, sourceLng), {
|
|
icon: L.icon({
|
|
iconUrl: '../dist/images/source-ico.png',
|
|
iconSize: [32, 32],
|
|
iconAnchor: [16, 30]
|
|
}),
|
|
draggable: true
|
|
}).addTo(map);
|
|
} else if (count == 2) {
|
|
$('input[name=destCord]').val('(' + e.latlng.lat.toFixed(7) + ')' + ' - ' + '(' + e.latlng.lng.toFixed(7) + ')');
|
|
|
|
destLat = e.latlng.lat;
|
|
destLng = e.latlng.lng;
|
|
|
|
let destMarker = new L.marker(L.latLng(destLat, destLng), {
|
|
icon: L.icon({
|
|
iconUrl: '../dist/images/dest-ico.png',
|
|
iconSize: [32, 32],
|
|
iconAnchor: [16, 30]
|
|
}),
|
|
draggable: true
|
|
}).addTo(map);
|
|
|
|
drawPath();
|
|
}
|
|
});
|
|
|
|
function drawPath() {
|
|
$.get(`https://testmap.141.ir/route/v1/driving/${sourceLng},${sourceLat};${destLng},${destLat}?overview=false&alternatives=true&steps=true`,
|
|
function (data) {
|
|
var routeControl = L.Routing.control({
|
|
waypoints: [
|
|
L.latLng(parseFloat(sourceLat), parseFloat(sourceLng)),
|
|
L.latLng(parseFloat(destLat), parseFloat(destLng))
|
|
],
|
|
fitSelectedRoutes: false,
|
|
draggableWaypoints: true,
|
|
createMarker: function () { return null; },
|
|
lineOptions: {
|
|
addWaypoints: false,
|
|
styles: [{
|
|
color: '#28a745',
|
|
opacity: .8,
|
|
weight: 5
|
|
}]
|
|
},
|
|
}).addTo(map);
|
|
|
|
$('input[name=calcDistance]').val((data.routes[0].distance / 1000).toFixed(2) + ' کیلومتر');
|
|
$('input[name=routeName]').val(data.routes[0].legs[0].summary);
|
|
$('select[name=selectOstan]').val(1);
|
|
$('input[name=selectCity]').val('تهران');
|
|
if (statusLinePer == 0) {
|
|
changeStatusLine(25);
|
|
}
|
|
});
|
|
|
|
$('.leaflet-control-container').css('display', 'none');
|
|
$('.leaflet-routing-container-hide').css('display', 'none');
|
|
}
|
|
|
|
$('input[name=r1]').on('change', function () {
|
|
if (statusLinePer == 25 || ($('.select2typeProject').val().length > 0 && statusLinePer == 32.5)) {
|
|
changeStatusLine(7.5);
|
|
}
|
|
});
|
|
|
|
$('.select2typeProject').on('change', function () {
|
|
if ((statusLinePer == 32.5 || statusLinePer == 25) && $(this).val().length > 0) {
|
|
changeStatusLine(7.5);
|
|
} else if ((statusLinePer == 32.5 || statusLinePer == 40) && $(this).val().length == 0) {
|
|
changeStatusLine(-7.5);
|
|
}
|
|
});
|
|
|
|
function changeStatusLine(num) {
|
|
statusLinePer += num;
|
|
$('.step-status-line').width(statusLinePer + '%');
|
|
|
|
if (num > 0 && statusLinePer >= 100) {
|
|
$('.step-status-3').addClass('step-active');
|
|
$('.step-status-2').addClass('step-ok').removeClass('step-active');
|
|
} else if (num > 0 && statusLinePer >= 50) {
|
|
$('.step-status-2').addClass('step-active');
|
|
$('.step-status-1').addClass('step-ok').removeClass('step-active');
|
|
} else if (num < 0 && statusLinePer <= 50) {
|
|
$('.step-status-1').addClass('step-active').removeClass('step-ok');
|
|
$('.step-status-2').removeClass('step-active');
|
|
} else if (num < 0 && statusLinePer <= 100) {
|
|
$('.step-status-2').addClass('step-active').removeClass('step-ok');
|
|
$('.step-status-3').removeClass('step-active');
|
|
}
|
|
}
|