This commit is contained in:
2024-05-06 15:15:23 +03:00
8 changed files with 535 additions and 73 deletions

7
.gitignore vendored
View File

@@ -9,4 +9,9 @@ project.db
c*.txt c*.txt
migrations/__pycache__/* migrations/__pycache__/*
migrations/versions/__pycache__/* migrations/versions/__pycache__/*
__pycache__ __pycache__
migrations/versions/__pycache__
migrations/__pycache__
migrations/versions/__pycache__/6fc3d1adb061_.cpython-312.pyc
migrations/versions/__pycache__/6fc3d1adb061_.cpython-312.pyc
migrations/versions/__pycache__/885bdd7b5161_.cpython-312.pyc

86
app.py
View File

@@ -129,25 +129,35 @@ def alloborud():
@app.route('/getall') @app.route('/getall')
def getall(): def getall():
oboruds = Oboruds.query.all() oborud = db.session.query(Oboruds).order_by(Oboruds.invNumber).all()
oboruds_json = [{
'invNumber': oborud.invNumber,
'nazvanie': oborud.nazvanie,
'raspologenie': oborud.raspologenie,
'balancenumber': oborud.balancenumber,
'kolichestvo': oborud.kolichestvo,
'balancenumber': oborud.balancenumber,
'aud_id': oborud.aud_id
} for oborud in oboruds]
results = []
for oboruds in oborud :
if oboruds.aud_id is None:
results.append({
'invNumber': oboruds.invNumber,
'nazvanie': oboruds.nazvanie,
'raspologenie': oboruds.raspologenie,
'balancenumber': oboruds.balancenumber,
'kolichestvo': oboruds.kolichestvo,
'numberppasu': oboruds.numberppasu,
'numberved': oboruds.numberved,
'aud': "" })
else:
aud = db.session.query(Auditory).filter_by(id=oboruds.aud_id).first()
results.append({
'invNumber': oboruds.invNumber,
'nazvanie': oboruds.nazvanie,
'raspologenie': oboruds.raspologenie,
'balancenumber': oboruds.balancenumber,
'kolichestvo': oboruds.kolichestvo,
'numberppasu': oboruds.numberppasu,
'numberved': oboruds.numberved,
'aud': aud.audnazvanie })
return jsonify(oboruds_json) return jsonify(results)
@app.route('/updateduplicate', methods=['GET', 'POST'])
def updateduplicate():
if request.method == 'POST':
aud = request.form.get('auditory_dubl')
@app.route('/vneaud', methods=['GET', 'POST']) @app.route('/vneaud', methods=['GET', 'POST'])
@@ -204,21 +214,45 @@ def addraspved():
query_string = request.data.decode() query_string = request.data.decode()
print(query_string)
un_query_string = unquote(unquote(query_string)).split(',') un_query_string = unquote(unquote(query_string)).split(',')
print(un_query_string)
ob = db.session.query(Oboruds).filter_by(invNumber=un_query_string[0]).first() ob = db.session.query(Oboruds).filter_by(invNumber=un_query_string[0]).first()
ob.raspologenie=un_query_string[2]
ob.numberved = un_query_string[1] ob.numberved=un_query_string[1]
ob.kolichestvo = un_query_string[2]
ob.balancenumber = un_query_string[3]
ob.raspologenie=un_query_string[4]
db.session.commit() db.session.commit()
db.session.close() db.session.close()
return jsonify({'success': True}, 200, {'ContentType': 'application/json'})
@app.route('/addoborudasu', methods=['GET', 'POST'])
def addoborud():
if request.method == 'POST':
query_string = request.data.decode()
un_query_string = unquote(unquote(query_string)).split(',')
db.session.add(
Oboruds(invNumber=un_query_string[0],
nazvanie=un_query_string[5],
raspologenie= un_query_string[4],
numberved=un_query_string[1],
kolichestvo=un_query_string[2],
balancenumber=un_query_string[3]
)
)
db.session.commit()
return jsonify({'success': True}, 200, {'ContentType': 'application/json'}) return jsonify({'success': True}, 200, {'ContentType': 'application/json'})
# ================================================================================== # ==================================================================================

View File

@@ -0,0 +1,32 @@
"""empty message
Revision ID: 10da3140ab2e
Revises: 4eacd6dcd461
Create Date: 2024-04-05 01:25:48.931573
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '10da3140ab2e'
down_revision = '4eacd6dcd461'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('oboruds', schema=None) as batch_op:
batch_op.add_column(sa.Column('kolichestvo', sa.Integer(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('oboruds', schema=None) as batch_op:
batch_op.drop_column('kolichestvo')
# ### end Alembic commands ###

View File

@@ -0,0 +1,54 @@
"""empty message
Revision ID: 4eacd6dcd461
Revises: c208cbc25232
Create Date: 2024-04-03 23:25:42.271936
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '4eacd6dcd461'
down_revision = 'c208cbc25232'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('oboruds', schema=None) as batch_op:
batch_op.add_column(sa.Column('numberved', sa.String(length=100), nullable=True))
batch_op.add_column(sa.Column('numberppasu', sa.String(length=100), nullable=True))
batch_op.add_column(sa.Column('balancenumber', sa.Integer(), nullable=True))
batch_op.alter_column('nazvanie',
existing_type=sa.TEXT(length=500),
type_=sa.String(length=500),
existing_nullable=True)
batch_op.alter_column('raspologenie',
existing_type=sa.TEXT(length=200),
type_=sa.String(length=200),
existing_nullable=True)
batch_op.drop_column('buhnumberpp')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('oboruds', schema=None) as batch_op:
batch_op.add_column(sa.Column('buhnumberpp', sa.VARCHAR(length=100), nullable=True))
batch_op.alter_column('raspologenie',
existing_type=sa.String(length=200),
type_=sa.TEXT(length=200),
existing_nullable=True)
batch_op.alter_column('nazvanie',
existing_type=sa.String(length=500),
type_=sa.TEXT(length=500),
existing_nullable=True)
batch_op.drop_column('balancenumber')
batch_op.drop_column('numberppasu')
batch_op.drop_column('numberved')
# ### end Alembic commands ###

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,36 +1,260 @@
function getAllData(){ function clearTable() {
$.ajax({ var table = document.getElementById("alldatatable");
var rowCount = table.rows.length;
url: "/getall", // Iterate through each row and remove it
type: "get", for (var i = rowCount - 1; i > 0; i--) {
contentType: 'application/json', table.deleteRow(i);
dataType: 'json', }
success: function(response){
console.log("1111")
let data = response;
var table = document.getElementById('alldatable');
var tbody = table.getElementsByTagName('tbody')[0];
// Clear existing data
tbody.innerHTML = '';
// Loop through the data and create table rows
data.forEach(function(item) {
var row = document.createElement('tr');
Object.values(item).forEach(function(value) {
var cell = document.createElement('td');
cell.textContent = value;
row.appendChild(cell);
});
tbody.appendChild(row);
});
},
})
} }
getAllData() function getAllData(){
console.log('12321321')
clearTable();
let tableBody = document.getElementById('alldatatable').getElementsByTagName("tbody")[0];
i = 0;
$.getJSON("/getall", function(data) {
$.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);
let cell8 = newRow.insertCell(7);
i++;
cell1.innerText = i;
cell2.innerText = item.numberved;
cell3.innerText = item.invNumber;
cell4.innerText = item.nazvanie;
cell5.innerText = item.kolichestvo;
cell6.innerText = item.balancenumber;
cell7.innerText= item.aud;
cell8.innerText = item.raspologenie;
$(newRow).data('itemData', i);
$(newRow).on("click", function() {
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,20)
if (vednumbertxt.length>0){
vedomost.value = vednumbertxt;
}
if (kolvotxt.length>0){
kolvo.value = kolvotxt;
}
if (schettxt.length>0){
balancenumber.value = schettxt;
}
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.value = '';
kolvo.value = '';
balancenumber.value = '';
matcen.value = '';
rasp.value = '';
$('#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 nazv = document.getElementById('modal_nazvanie')
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(){
$('#getmodal').modal('hide')
vednumber.value = '';
kolvo.value = '';
balancenumber.value = '';
matcen.value = '';
rasp.value = '';
changeddata = [];
window.location.reload();
},
})
})
$('#addoborud').click(function(){
$('#addmodal').modal('show');
})
$('#modal2savetodb').click(function(){
let invnomer = document.getElementById('modal2_invnom')
let vednumber = document.getElementById('modal2_vednumber')
let kolvo = document.getElementById('modal2_kolvo')
let balancenumber = document.getElementById('modal2_balance')
let matcen = document.getElementById('modal2_matcenn')
let rasp = document.getElementById('modal2_rapolog')
let nazv = document.getElementById('modal2_nazvanie')
let changeddata = new Array()
changeddata[0] = invnomer.value;
changeddata[1] = vednumber.value;
changeddata[2] = kolvo.value;
changeddata[3] = balancenumber.value;
changeddata[4] = rasp.value;
changeddata[5] = nazv.value;
let sendData = changeddata.join(',')
console.log(sendData)
$.ajax({
url: "/addoborudasu",
type: "POST",
contentType: "application/json;charset=utf-8",
dataType: "json",
data: sendData,
success: function(){
vednumber.value = '';
invnomer.value= '';
nazvanie.value='';
kolvo.value = '';
balancenumber.value = '';
matcen.value = '';
rasp.value = '';
$('#addmodal').modal('hide')
window.location.reload()
},
})
})
$('#modal2close').click(function(){
let vednumber = document.getElementById('modal2_vednumber')
let invnomer = document.getElementById('modal2_invnom')
let nazvanie = document.getElementById('modal2_nazvanie')
let kolvo = document.getElementById('modal2_kolvo')
let balancenumber = document.getElementById('modal2_balance')
let matcen = document.getElementById('modal2_matcenn')
let rasp = document.getElementById('modal2_rapolog')
vednumber.value = '';
invnomer.value= '';
nazvanie.value='';
kolvo.value = '';
balancenumber.value = '';
matcen.value = '';
rasp.value = '';
$('#addmodal').modal('hide')
} )
$('#modal2').on('hidden.bs.modal', function () {
location.reload();
})

View File

@@ -2,31 +2,142 @@
{% 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">
<div class="row">
<a id="modal_invnom"> </a><a id="modal_matcenn"></a>
</div>
<div class="row">
№ из ведомости
<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 class="row">
Расположение
<input type="text" class="form-control" id ='modal_rapolog' placeholder="Введите расположение">
</div>
<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>
<!-- Modal2 -->
<div class="modal fade" id="addmodal" 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">
<div class="row">
<a id="modal_invnom"> </a><a id="modal2_matcenn"></a>
</div>
<div class="row">
№ из ведомости
<input type="text" class="form-control" id ='modal2_vednumber' placeholder="Номер из ведомости">
<div class="row">
Инвентарный номер
<input type="text" class="form-control" id ='modal2_invnom' placeholder="Инвентарный номер">
</div>
</div>
<div class="row">
Название
<input type="text" class="form-control" id ='modal2_nazvanie' placeholder="Название">
</div>
<div class="row">
Количество
<input type="text" class="form-control" id ='modal2_kolvo' placeholder="Количество">
</div>
<div class="row">
Балансовый счёт
<input type="text" class="form-control" id ='modal2_balance' placeholder="Балансовый счёт">
</div>
<div class="row">
Расположение
<input type="text" class="form-control" id ='modal2_rapolog' placeholder="Введите расположение">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" id="modal2close">Закрыть</button>
<button type="button" class="btn btn-primary" id="modal2savetodb" >Сохранить изменения</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>
<button class="button" id="printallbutton"> Печать </button>
</div> <div class="row col-12">
<button class="button" id="printallbutton"> Печать </button>
</div>
<div class="row col-12">
<button class="button" id="addoborud"> Добавить </button>
</div>
</div> </div>
<div class="row"> <div class="row">
<div class="card col-md-11" > <div class="card col-md-11 table-responsive">
<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"><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>
</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>