diff --git a/__pycache__/app.cpython-312.pyc b/__pycache__/app.cpython-312.pyc index 6618bef..18d2bc2 100644 Binary files a/__pycache__/app.cpython-312.pyc and b/__pycache__/app.cpython-312.pyc differ diff --git a/__pycache__/models.cpython-312.pyc b/__pycache__/models.cpython-312.pyc index 84cd74b..3d4cca7 100644 Binary files a/__pycache__/models.cpython-312.pyc and b/__pycache__/models.cpython-312.pyc differ diff --git a/app.py b/app.py index 1aa53ca..8b652cc 100644 --- a/app.py +++ b/app.py @@ -6,6 +6,7 @@ from flask_migrate import Migrate from datetime import * import csv import random +from urllib.parse import unquote app = Flask(__name__) @@ -77,11 +78,14 @@ def searchonaud(): results = [] for auditory, oboruds in q: results.append({ + 'num_ved': oboruds.numberved, 'auditory_id': auditory.id, 'auditory_name': auditory.audnazvanie, 'inv_number': oboruds.invNumber, 'oboruds_id': oboruds.nazvanie, + 'raspolog': oboruds.raspologenie, }) + print(results) return jsonify(results) else: @@ -183,25 +187,21 @@ def zamsearch(): @app.route('/addraspved', methods=['GET', 'POST']) def addraspved(): if request.method == 'POST': - query_string = request.data - # Convert the bytes object to a string - query_string_str = query_string.decode("utf-8") + #b'rasp=asndhaslkj&ved=1111111&inv=18124' + query_string = request.get_data().decode() + un_query_string = unquote(unquote(query_string)) - # Split the query string by '&' to get individual key-value pairs - key_value_pairs = query_string_str.split("&") - - # Create a dictionary to store the key-value pairs + print(un_query_string.split('&')) query_dict = {} - for pair in key_value_pairs: + for pair in un_query_string.split('&'): key, value = pair.split("=") query_dict[key] = value - # Retrieve the values for specific keys - rasp_value = query_dict.get("rasp") - ved_value = query_dict.get("ved") - - print(f"Value for 'rasp': {rasp_value}") - print(f"Value for 'ved': {ved_value}") + ob = db.session.query(Oboruds).filter_by(invNumber=query_dict['inv']).first() + print(ob) + ob.raspologenie=query_dict['rasp'] + ob.numberved = query_dict['ved'] + db.session.commit() @@ -262,16 +262,6 @@ def createdb(): db.session.commit() - """ - with open('zabalans.csv', encoding='utf-8') as csv_file: - csv_reader = csv.reader(csv_file, delimiter=';') - for row in csv_reader: - print(row) - db.session.add( - Oboruds(invNumber=row[0], nazvanie=row[1], typeBalanse="забаланс")) - - db.session.commit() - """ if __name__ == '__main__': diff --git a/migrations/__pycache__/env.cpython-312.pyc b/migrations/__pycache__/env.cpython-312.pyc index d40e79f..26bd5f4 100644 Binary files a/migrations/__pycache__/env.cpython-312.pyc and b/migrations/__pycache__/env.cpython-312.pyc differ diff --git a/migrations/versions/__pycache__/256c3a3e91a2_.cpython-312.pyc b/migrations/versions/__pycache__/256c3a3e91a2_.cpython-312.pyc index 77081c0..280709a 100644 Binary files a/migrations/versions/__pycache__/256c3a3e91a2_.cpython-312.pyc and b/migrations/versions/__pycache__/256c3a3e91a2_.cpython-312.pyc differ diff --git a/migrations/versions/__pycache__/4f95d12a8352_.cpython-312.pyc b/migrations/versions/__pycache__/4f95d12a8352_.cpython-312.pyc index 2889172..a22fbdb 100644 Binary files a/migrations/versions/__pycache__/4f95d12a8352_.cpython-312.pyc and b/migrations/versions/__pycache__/4f95d12a8352_.cpython-312.pyc differ diff --git a/migrations/versions/__pycache__/50f85881169e_.cpython-312.pyc b/migrations/versions/__pycache__/50f85881169e_.cpython-312.pyc index aee53e0..09660f0 100644 Binary files a/migrations/versions/__pycache__/50f85881169e_.cpython-312.pyc and b/migrations/versions/__pycache__/50f85881169e_.cpython-312.pyc differ diff --git a/migrations/versions/__pycache__/873defe09f22_.cpython-312.pyc b/migrations/versions/__pycache__/873defe09f22_.cpython-312.pyc index fd851b5..6f099d5 100644 Binary files a/migrations/versions/__pycache__/873defe09f22_.cpython-312.pyc and b/migrations/versions/__pycache__/873defe09f22_.cpython-312.pyc differ diff --git a/migrations/versions/__pycache__/8e838956713f_.cpython-312.pyc b/migrations/versions/__pycache__/8e838956713f_.cpython-312.pyc index 386f4de..0e15d3a 100644 Binary files a/migrations/versions/__pycache__/8e838956713f_.cpython-312.pyc and b/migrations/versions/__pycache__/8e838956713f_.cpython-312.pyc differ diff --git a/migrations/versions/__pycache__/b24baa0d98e6_.cpython-312.pyc b/migrations/versions/__pycache__/b24baa0d98e6_.cpython-312.pyc index 69a74a0..43d1576 100644 Binary files a/migrations/versions/__pycache__/b24baa0d98e6_.cpython-312.pyc and b/migrations/versions/__pycache__/b24baa0d98e6_.cpython-312.pyc differ diff --git a/migrations/versions/__pycache__/b2a61aef79e9_.cpython-312.pyc b/migrations/versions/__pycache__/b2a61aef79e9_.cpython-312.pyc index 6f573f0..a7e9152 100644 Binary files a/migrations/versions/__pycache__/b2a61aef79e9_.cpython-312.pyc and b/migrations/versions/__pycache__/b2a61aef79e9_.cpython-312.pyc differ diff --git a/migrations/versions/__pycache__/ec6bbcd361bd_.cpython-312.pyc b/migrations/versions/__pycache__/ec6bbcd361bd_.cpython-312.pyc index 1d027b0..e5f76bc 100644 Binary files a/migrations/versions/__pycache__/ec6bbcd361bd_.cpython-312.pyc and b/migrations/versions/__pycache__/ec6bbcd361bd_.cpython-312.pyc differ diff --git a/static/css/index.css b/static/css/index.css index c47c1a0..6bc3fb1 100644 --- a/static/css/index.css +++ b/static/css/index.css @@ -18,6 +18,7 @@ body { border: 1px; + } header { @@ -77,6 +78,28 @@ nav{ } +.table{ + word-break: break-all; +} + +.aud{ + width: 110px; +} + +.inv{ + width: 400px; +} + +.rasp{ + max-width: 200px; + word-break: break-word; +} + +#modal_matcenn{ + + margin-left: 20px; +} + @media print { *{ diff --git a/static/js/searchonaud.js b/static/js/searchonaud.js index 1e1b6e4..abfe949 100644 --- a/static/js/searchonaud.js +++ b/static/js/searchonaud.js @@ -13,20 +13,22 @@ function getData(){ }, success: function(response){ + console.log(response) var data = response; const table = document.getElementById('datatable') table.innerHTML = '' - var headTable = ' Номер в Инв. вед Инв. номерНазваниеАудитория Расположение Проверено ' + var headTable = ' Номер в Инв. вед Инв. номерНазваниеАудитория Расположение Проверено ' table.innerHTML += headTable var tr ="" + data.forEach(element => { tr += '' - tr += ' ' - tr += '' + element.inv_number + '' + tr += '' + element.num_ved + '' + tr += '' + element.inv_number + '' tr += '' + element.oboruds_id + '' tr += '' + element.auditory_name + '' - tr += ' ' + tr += '' +element.raspolog + '' tr += '' + '\n' + '' tr += '' @@ -40,58 +42,64 @@ $("#searchbutton").click(function(){ getData(); }) - function tableclick(x){ - let roww = x.rowIndex - let data = document.getElementById(x.rowIndex) +function tableclick(x){ + let data = document.getElementById(x.rowIndex) - let datas = x.innerText.split('\t') + let datas = x.innerText.split('\t') - console.log(datas) + - $('#getmodal').modal('show') - let rasp = document.getElementById('rapolog') - let vedomost = document.getElementById('vednumber') + $('#getmodal').modal('show') - if (datas[0].length>0){ - rasp.value=datas[0]; - } + let rasp = document.getElementById('rapolog') + let vedomost = document.getElementById('vednumber') + let invnom = document.getElementById('modal_invnom') + let matcen = document.getElementById('modal_matcenn') + + invnom.innerText=datas[1]+"\t" + matcen.innerText=datas[2].substring(0,15) - if (datas[4].length>0){ - vedomost.value=datas[4] - } - $('#modalclose').click(function(){ + if (datas[4].length>0){ + rasp.value=datas[4]; + } + + if (datas[0].length>0){ + vedomost.value=datas[0] + } + + $('#modalclose').click(function(){ + + $('#getmodal').modal('hide'); + + } ) + + $('#modalsavetodb').click(function(){ - $('#getmodal').modal('hide'); - } ) - $('#modalsavetodb').click(function(){ + $.ajax({ - console.log(datas) + url: "/addraspved", + type: "POST", + contentType: "application/json;charset=utf-8", + dataType: "json", + data: { + rasp: rasp.value, + ved: vedomost.value, + inv: datas[1] + }, - $.ajax({ + }) + rasp.value = ''; + vedomost.value= ''; + + datas = []; + + $('#getmodal').modal('hide'); - url: "/addraspved", - type: "post", - contentType: 'application/json', - dataType: 'json', - data: { - rasp: rasp.value, - ved: vedomost.value - }, - - }) - - rasp.value=''; - - vedomost.value=''; - - - - $('#getmodal').modal('hide'); - - // getData(); - }) + getData(); +}) + } diff --git a/templates/searchonaud.html b/templates/searchonaud.html index 3d811af..67bf3ff 100644 --- a/templates/searchonaud.html +++ b/templates/searchonaud.html @@ -8,9 +8,21 @@