add click on row

This commit is contained in:
Your Name
2024-04-04 12:48:43 +03:00
parent 63115f0328
commit 7ccbba06c1
4 changed files with 114 additions and 49 deletions

28
app.py
View File

@@ -119,20 +119,26 @@ def alloborud():
@app.route('/getall') @app.route('/getall')
def getall(): def getall():
oboruds = Oboruds.query.all() oborud = db.session.query(Auditory, Oboruds).filter(
oboruds_json = [{ Oboruds.aud_id==Auditory.id
).order_by(Oboruds.invNumber).all()
'invNumber': oborud.invNumber, results = []
'nazvanie': oborud.nazvanie, for auditory, oboruds in oborud :
'raspologenie': oborud.raspologenie, results.append({
'balancenumber': oborud.balancenumber, 'invNumber': oboruds.invNumber,
'kolichestvo': oborud.kolichestvo, 'nazvanie': oboruds.nazvanie,
'balancenumber': oborud.balancenumber, 'raspologenie': oboruds.raspologenie,
'aud_id': oborud.aud_id 'balancenumber': oboruds.balancenumber,
} for oborud in oboruds] 'kolichestvo': oboruds.kolichestvo,
'numberppasu': oboruds.numberppasu,
'numberved': oboruds.numberved,
'aud': auditory.audnazvanie
})
return jsonify(oboruds_json) return jsonify(results)
@app.route('/updateduplicate', methods=['GET', 'POST']) @app.route('/updateduplicate', methods=['GET', 'POST'])
def updateduplicate(): def updateduplicate():

View File

@@ -1,36 +1,43 @@
function getAllData(){
$.ajax({
url: "/getall", $(document).ready(function() {
type: "get",
contentType: 'application/json',
dataType: 'json',
success: function(response){ let tableBody = document.getElementById('alldatatable').getElementsByTagName("tbody")[0];
console.log("1111") tableBody.innerHTML = '';
let data = response; i = 0;
var table = document.getElementById('alldatable');
var tbody = table.getElementsByTagName('tbody')[0];
// Clear existing data $.getJSON("/getall", function(data) {
tbody.innerHTML = ''; $.each(data, function(index, item) {
let newRow = tableBody.insertRow(tableBody.rows.length);
let cell1 = newRow.insertCell(0);
let cell2 = newRow.insertCell(1);
let cell3 = newRow.insertCell(2);
let cell4 = newRow.insertCell(3);
let cell5 = newRow.insertCell(4);
let cell6 = newRow.insertCell(5);
let cell7 = newRow.insertCell(6);
i++;
// Loop through the data and create table rows cell1.innerText = i;
data.forEach(function(item) { cell2.innerText = item.invNumber;
var row = document.createElement('tr'); cell4.innerText = item.nazvanie;
Object.values(item).forEach(function(value) { cell3.innerText = item.kolichestvo;
var cell = document.createElement('td'); cell5.innerText = item.numberved;
cell.textContent = value; cell6.innerText = item.raspologenie;
row.appendChild(cell); cell7.innerText = item.aud;
});
tbody.appendChild(row); $(newRow).data('itemData', i);
});
}, $(newRow).on("click", function() {
let ind = newRow.cells[0].innerText;
let invNumber = newRow.cells[1].innerText;
}) $('#getmodal').modal('show')
} });
});
});
});
getAllData()

View File

@@ -3,9 +3,52 @@
{% block content %} {% block content %}
<!-- Modal -->
<div class="modal fade" id="getmodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<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">
<a id="modal_invnom"> </a><a id="modal_matcenn"></a>
</div>
<form method="POST" action="/addraspved">
<div class="row">
№ из ведомости
<input type="text" class="form-control" name="modal_vednumber" id ='modal_vednumber' placeholder="Номер из ведомости">
</div>
<div class="row">
Расположение
<input type="text" class="form-control" name="modal_rapolog" id ='modal_rapolog' placeholder="Введите расположение">
</div>
</form>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" id="modalclose">Закрыть</button>
<button type="button" class="btn btn-primary" id="modalsavetodb" >Сохранить изменения</button>
</div>
</div>
</div>
</div>
</div>
<div class="row col-12"> <div class="row col-12">
<div class=" card col-11"> <div class=" card col-11">
<h3 class=" no-print"> Все мат. ценности </h3> <h3 id ='123' class=" no-print"> Все мат. ценности </h3>
</div> </div>
<div class="row col-12"> <div class="row col-12">
@@ -14,8 +57,8 @@
</div> </div>
<div class="row"> <div class="row">
<div class="card col-md-11" > <div class="card col-md-11">
<table id="datable" class="alldatable table pagebreak" > <table id="alldatatable" class="alldatable table pagebreak" >
<thead> <thead>
<tr> <tr>
<th scope="col">№ п/п</th> <th scope="col">№ п/п</th>
@@ -27,6 +70,16 @@
<th scope="col">Аудитория</th> <th scope="col">Аудитория</th>
</tr> </tr>
</thead> </thead>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
</tr>
</table> </table>
</div> </div>

View File

@@ -8,12 +8,12 @@
<div class="modal-dialog modal-dialog-centered" role="document"> <div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-body" id="textarea"> <div class="modal-body" id="textarea">
<<<<<<< HEAD
<input type="text" class="form-control" id ='vednumber' placeholder="Номер из веломости"> <input type="text" class="form-control" id ='vednumber' placeholder="Номер из веломости">
<input type="text" class="form-control" id ='rapolog' 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>
@@ -38,7 +38,6 @@
<button type="button" class="btn btn-primary" id="modalsavetodb" >Сохранить изменения</button> <button type="button" class="btn btn-primary" id="modalsavetodb" >Сохранить изменения</button>
</div> </div>
>>>>>>> 965695a6936eaf44348f73ca898f98c76b663157
</div> </div>