ASCU_ALL/Site/js/Pasport.js
2024-09-22 04:27:05 +05:00

122 lines
3.1 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var pasport_lable = $('#pasport_label');
var pasport_date = $('#pasport_date');
var pasport_info = $('#pasport_info');
var pasport_data = null;
async function pasport_load(date, name) {
try {
var res = await $.ajax({
type: "POST",
url: 'https://vsmpo.mbucb.ru/api/pasport/getpasport',
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify({
"date": date,
"name": name
})
})
pasport_data = res;
pasport_data.search_date = date;
pasport_data.search_name = name;
return true;
}
catch (err) {
pasport_data = null;
alert("Ошибка загрузки паспорта:\n" +
"\tДата: " + date + "\n" +
"\tПаспорт: " + name);
return false;
}
};
function pasport_custom_set(vdp, dStart, dEnd) {
pasport_data = {};
pasport_data.numVDP = vdp;
pasport_data.dStart = dStart;
pasport_data.dEnd = dEnd;
}
function pasport_fill_label() {
try {
if (pasport_data == undefined ||
pasport_data == null ||
(
!pasport_data.hasOwnProperty('nplav') &&
!pasport_data.hasOwnProperty('numVDP')
)
)
throw 'Ошибка';
if (pasport_data.hasOwnProperty('nplav'))
pasport_lable.find('h5').html('Паспорт №' + pasport_data.nplav);
else
pasport_lable.find('h5').html('Печь №' + pasport_data.numVDP);
return true;
}
catch (err) {
pasport_lable.find('h5').html('Ошибка получения паспорта');
return false;
}
}
function pasport_fill_date() {
try {
if (pasport_data == undefined ||
pasport_data == null)
throw "Ошибка";
pasport_date.find('span').eq(0).html(pasport_data.numVDP);
pasport_date.find('span').eq(1).html(pasport_data.dStart);
pasport_date.find('span').eq(2).html(pasport_data.dEnd);
return true;
}
catch {
return false;
}
}
function pasport_fill_info() {
try {
var temp = pasport_info.find('span');
if (pasport_data.is != '-')
temp.eq(0).html(pasport_data.splav + ' ' + pasport_data.is);
else
temp.eq(0).html(pasport_data.splav);
temp.eq(1).html(pasport_data.prpl);
temp.eq(2).html(pasport_data.nazn);
temp.eq(3).html(pasport_data.kat);
temp.eq(4).html(pasport_data.zakaz);
temp.eq(5).html(pasport_data.vessl);
temp.eq(6).html(pasport_data.kompl);
temp.eq(7).html(pasport_data.dkr);
temp.eq(8).html(pasport_data.diam);
temp.eq(9).html(pasport_data.nkon);
temp.eq(10).html(pasport_data.ukaz);
return true;
}
catch {
return false;
}
}
function pasport_show_lable() {
try {
pasport_lable.removeAttr('hidden');
} catch { }
}
function pasport_show_date() {
try {
pasport_date.removeAttr('hidden');
} catch { }
}
function pasport_show_info() {
try {
pasport_info.removeAttr('hidden');
} catch { }
}
function pasport_hide_all() {
try {
pasport_lable.attr('hidden', true);
} catch { }
try {
pasport_date.attr('hidden', true);
} catch { }
try {
pasport_info.attr('hidden', true);
} catch { }
}