add modal fucnc

This commit is contained in:
Your Name
2024-04-04 19:31:07 +03:00
parent 7ccbba06c1
commit 1fce4b41c0
3 changed files with 165 additions and 48 deletions

View File

@@ -78,10 +78,13 @@ nav{
} }
.table{ table{
word-break: break-all; word-break: break-all;
border-collapse: separate!important;
}
td{
padding: 0;
} }
.aud{ .aud{
width: 110px; width: 110px;
} }

View File

@@ -1,10 +1,7 @@
$(document).ready(function() { function getAllData(){
let tableBody = document.getElementById('alldatatable').getElementsByTagName("tbody")[0]; let tableBody = document.getElementById('alldatatable').getElementsByTagName("tbody")[0];
tableBody.innerHTML = '';
i = 0; i = 0;
$.getJSON("/getall", function(data) { $.getJSON("/getall", function(data) {
$.each(data, function(index, item) { $.each(data, function(index, item) {
let newRow = tableBody.insertRow(tableBody.rows.length); let newRow = tableBody.insertRow(tableBody.rows.length);
@@ -15,29 +12,145 @@ $(document).ready(function() {
let cell5 = newRow.insertCell(4); let cell5 = newRow.insertCell(4);
let cell6 = newRow.insertCell(5); let cell6 = newRow.insertCell(5);
let cell7 = newRow.insertCell(6); let cell7 = newRow.insertCell(6);
let cell8 = newRow.insertCell(7);
i++; i++;
cell1.innerText = i; cell1.innerText = i;
cell2.innerText = item.invNumber; cell2.innerText = item.numberved;
cell3.innerText = item.invNumber;
cell4.innerText = item.nazvanie; cell4.innerText = item.nazvanie;
cell3.innerText = item.kolichestvo; cell5.innerText = item.kolichestvo;
cell5.innerText = item.numberved; cell6.innerText = item.balancenumber;
cell6.innerText = item.raspologenie; cell7.innerText= item.aud;
cell7.innerText = item.aud; cell8.innerText = item.raspologenie;
$(newRow).data('itemData', i); $(newRow).data('itemData', i);
$(newRow).on("click", function() { $(newRow).on("click", function() {
let ind = newRow.cells[0].innerText;
let invNumber = newRow.cells[1].innerText;
$('#getmodal').modal('show') let vednumbertxt = newRow.cells[1].innerText;
let invnomertxt = newRow.cells[2].innerText;
let nazvanietxt = newRow.cells[3].innerText;
let kolvotxt = newRow.cells[4].innerText;
let schettxt = newRow.cells[5].innerText;
let raspologtxt = newRow.cells[7].innerText;
$('#getmodal').modal('show');
let vedomost = document.getElementById('modal_vednumber')
let invnom = document.getElementById('modal_invnom')
let matcen = document.getElementById('modal_matcenn')
let kolvo = document.getElementById('modal_kolvo')
let balancenumber = document.getElementById('modal_balance')
let rasp = document.getElementById('modal_rapolog')
invnom.innerText = invnomertxt
matcen.innerText = nazvanietxt.substring(0,15)
if (vednumbertxt.length>0){
vedomost.value = vednumbertxt;
}
if (kolvotxt.length>0){
kolvo.value = kolvotxt;
}
if (schettxt.length>0){
balancenumber.value = kolvotxt;
}
if (raspologtxt.length>0){
rasp.value = raspologtxt;
}
}); });
}); });
}); });
}
$( document ).ready(function() {
getAllData();
}); });
$('#modalclose').click(function(){
let vednumber = document.getElementById('modal_vednumber')
let kolvo = document.getElementById('modal_kolvo')
let balancenumber = document.getElementById('modal_balance')
let matcen = document.getElementById('modal_matcenn')
let rasp = document.getElementById('modal_rapolog')
vednumber = '';
kolvo = '';
balancenumber = '';
matcen = '';
rasp = '';
$('#getmodal').modal('hide')
} )
$('#modalsavetodb').click(function(){
let invnom = document.getElementById('modal_invnom')
let vednumber = document.getElementById('modal_vednumber')
let kolvo = document.getElementById('modal_kolvo')
let balancenumber = document.getElementById('modal_balance')
let matcen = document.getElementById('modal_matcenn')
let rasp = document.getElementById('modal_rapolog')
let changeddata = new Array()
changeddata[0] = invnom.text;
changeddata[1] = vednumber.value;
changeddata[2] = kolvo.value;
changeddata[3] = balancenumber.value;
changeddata[4] = rasp.value;
let sendData = changeddata.join(',')
console.log(sendData)
$.ajax({
url: "/addraspved",
type: "POST",
contentType: "application/json;charset=utf-8",
dataType: "json",
data: sendData,
success: function(){
invnom = '';
vednumber = '';
kolvo = '';
balancenumber = '';
matcen = '';
rasp = '';
changeddata = []
$('#getmodal').modal('hide')
getAllData();
}
})
})

View File

@@ -9,38 +9,37 @@
<div class="modal-content"> <div class="modal-content">
<div class="modal-body" id="textarea"> <div class="modal-body" id="textarea">
<input type="text" class="form-control" id ='vednumber' placeholder="Номер из веломости">
<input type="text" class="form-control" id ='rapolog' placeholder="Введите расположение">
<div class="row"> <div class="row">
<a id="modal_invnom"> </a><a id="modal_matcenn"></a> <a id="modal_invnom"> </a><a id="modal_matcenn"></a>
</div> </div>
<form method="POST" action="/addraspved">
<div class="row"> <div class="row">
№ из ведомости № из ведомости
<input type="text" class="form-control" name="modal_vednumber" id ='modal_vednumber' placeholder="Номер из ведомости"> <input type="text" class="form-control" id ='modal_vednumber' placeholder="Номер из ведомости">
</div>
<div class="row">
Количество
<input type="text" class="form-control" id ='modal_kolvo' placeholder="Количество">
</div>
<div class="row">
Балансовый счёт
<input type="text" class="form-control" id ='modal_balance' placeholder="Балансовый счёт">
</div> </div>
<div class="row"> <div class="row">
Расположение Расположение
<input type="text" class="form-control" name="modal_rapolog" id ='modal_rapolog' placeholder="Введите расположение"> <input type="text" class="form-control" id ='modal_rapolog' placeholder="Введите расположение">
</div> </div>
</form>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" id="modalclose">Закрыть</button> <button type="button" class="btn btn-secondary" data-dismiss="modal" id="modalclose">Закрыть</button>
<button type="button" class="btn btn-primary" id="modalsavetodb" >Сохранить изменения</button> <button type="button" class="btn btn-primary" id="modalsavetodb" >Сохранить изменения</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
@@ -57,17 +56,19 @@
</div> </div>
<div class="row"> <div class="row">
<div class="card col-md-11"> <div class="card col-md-11 table-responsive">
<table id="alldatatable" class="alldatable table pagebreak" > <table id="alldatatable" class="alldatable table pagebreak" >
<thead> <thead>
<tr> <tr>
<th scope="col">п/п</th> <th scope="col"><br>п/п <br>АСУ</th>
<th scope="col">№ п/п вед</th> <th scope="col">№ п/п <br>вед</th>
<th scope="col">Инв. номер</th> <th scope="col">Инв. номер</th>
<th scope="col">Название</th> <th scope="col">Название</th>
<th scope="col">Кол-во</th> <th scope="col">Кол-во</th>
<th scope="col">Счёт</th> <th scope="col">Счёт</th>
<th scope="col">Аудитория</th> <th scope="col">Ауд - я</th>
<th scope="col">Расположение</th>
</tr> </tr>
</thead> </thead>
<tr> <tr>