125 lines
3.2 KiB
JavaScript
125 lines
3.2 KiB
JavaScript
|
|
function getData(){
|
|
|
|
const audid = document.getElementById('auditory')
|
|
$.ajax({
|
|
|
|
url: "/searchonaud",
|
|
type: "get",
|
|
contentType: 'application/json',
|
|
dataType: 'json',
|
|
data: {
|
|
auditory: audid.value
|
|
},
|
|
|
|
success: function(response){
|
|
|
|
var data = response;
|
|
const table = document.getElementById('datatable')
|
|
|
|
var headTable = '<tr> <td >Номер в Инв. вед</td> <td id="invnomer">Инв. номер</td><td>Название</td><td class="no-print aud">Аудитория</td> <td >Расположение</td> <td id="proverka"class="hidden-column"> Проверено</td> </tr>'
|
|
|
|
var tr =""
|
|
|
|
|
|
data.forEach(element => {
|
|
tr += '<tr onclick="tableclick(this)">'
|
|
tr += '<td>' + element.num_ved + '</td>'
|
|
tr += '<td clas="inv">' + element.inv_number + '</td>'
|
|
tr += '<td>' + element.oboruds_id + '</td>'
|
|
tr += '<td class="no-print">' + element.auditory_name + '</td>'
|
|
tr += '<td class="rasp">' +element.raspolog + '</td>'
|
|
tr += '<td>' + '\n' + '</td>'
|
|
|
|
tr += '</tr>'
|
|
});
|
|
table.innerHTML = headTable + tr
|
|
}
|
|
})
|
|
}
|
|
|
|
$("#searchbutton").click(function(){
|
|
getData();
|
|
})
|
|
|
|
$('#modalsavetodb').click(function(){
|
|
|
|
let rasp = document.getElementById('modal_rapolog')
|
|
let vedomost = document.getElementById('modal_vednumber')
|
|
let invnom = document.getElementById('modal_invnom')
|
|
let matcen = document.getElementById('modal_matcenn')
|
|
|
|
let changeddata = new Array()
|
|
|
|
changeddata[0] = invnom.text
|
|
changeddata[1] = vedomost.value
|
|
changeddata[2] = rasp.value
|
|
|
|
let sendData = changeddata.join(',')
|
|
|
|
changeddata = []
|
|
$.ajax({
|
|
|
|
url: "/addraspved",
|
|
type: "POST",
|
|
contentType: "application/json;charset=utf-8",
|
|
dataType: "json",
|
|
data: sendData,
|
|
|
|
success: function(){
|
|
/*
|
|
rasp='',
|
|
vedomost = '',
|
|
invnom = '',
|
|
matcen = '',
|
|
|
|
changeddata = []
|
|
*/
|
|
$('#getmodal').modal('hide').data( 'bs.modal', null );
|
|
getData();
|
|
}
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
function tableclick(tableRow){
|
|
|
|
let nomved = tableRow.childNodes[0].innerHTML;
|
|
let invnomer = tableRow.childNodes[1].innerHTML;
|
|
let nazvanie = tableRow.childNodes[2].innerHTML;
|
|
let raspolog = tableRow.childNodes[4].innerHTML;
|
|
|
|
$('#getmodal').modal('show')
|
|
|
|
let rasp = document.getElementById('modal_rapolog')
|
|
let vedomost = document.getElementById('modal_vednumber')
|
|
let invnom = document.getElementById('modal_invnom')
|
|
let matcen = document.getElementById('modal_matcenn')
|
|
|
|
invnom.innerText = invnomer
|
|
matcen.innerText = nazvanie.substring(0,15)
|
|
|
|
if (nomved.length >0){
|
|
|
|
vedomost.value = nomved
|
|
}
|
|
|
|
if(raspolog.length>0){
|
|
rasp.value = raspolog
|
|
}
|
|
|
|
$("#mimodal").on('hidden.bs.modal', function () {
|
|
$(this).data('bs.modal', null);
|
|
});
|
|
|
|
|
|
$('#modalclose').click(function(){
|
|
|
|
$('#getmodal').modal('hide').data( 'bs.modal', null );
|
|
|
|
} )
|
|
|
|
|
|
} |