From 6a76d36c46b98db85fe873d8bb32baf7442e109e Mon Sep 17 00:00:00 2001 From: Alex Danamir Date: Wed, 20 Mar 2024 22:17:21 +0300 Subject: [PATCH] add modal func --- app.py | 32 ++++++++++- static/js/searchonaud.js | 115 ++++++++++++++++++++++++------------- templates/searchonaud.html | 9 ++- 3 files changed, 112 insertions(+), 44 deletions(-) diff --git a/app.py b/app.py index 2f96d60..1aa53ca 100644 --- a/app.py +++ b/app.py @@ -132,8 +132,6 @@ def updateduplicate(): aud = request.form.get('auditory_dubl') - - @app.route('/vneaud', methods=['GET', 'POST']) def vneaud(): res = [] @@ -180,6 +178,36 @@ def zamsearch(): for item in searchedZam: zam.append([item.txtzam, item.created_date]) return render_template('zametki.html', zam=zam) + + +@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") + + # 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 + query_dict = {} + for pair in key_value_pairs: + 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}") + + + + return jsonify({'success': True}, 200, {'ContentType': 'application/json'}) + + # ================================================================================== diff --git a/static/js/searchonaud.js b/static/js/searchonaud.js index bdd8b2b..1e1b6e4 100644 --- a/static/js/searchonaud.js +++ b/static/js/searchonaud.js @@ -1,43 +1,44 @@ - $("#searchbutton").click(function(){ - - const audid = document.getElementById('auditory') +function getData(){ + const audid = document.getElementById('auditory') + $.ajax({ - $.ajax({ + url: "/searchonaud", + type: "get", + contentType: 'application/json', + dataType: 'json', + data: { + auditory: audid.value + }, - url: "/searchonaud", - type: "get", - contentType: 'application/json', - dataType: 'json', - data: { - auditory: audid.value - }, + success: function(response){ + var data = response; + const table = document.getElementById('datatable') + table.innerHTML = '' + var headTable = ' Номер в Инв. вед Инв. номерНазваниеАудитория Расположение Проверено ' + table.innerHTML += headTable + var tr ="" - success: function(response){ - - var data = response; - const table = document.getElementById('datatable') - table.innerHTML = '' - var headTable = ' Инв. номерНазваниеАудитория Проверено ' - table.innerHTML += headTable - var tr ="" - - data.forEach(element => { - tr += '' - tr += '' + element.inv_number + '' - tr += '' + element.oboruds_id + '' - tr += '' + element.auditory_name + '' - tr += '' + '\n' + '' - - tr += '' - }); - table.innerHTML += tr - } - }) + data.forEach(element => { + tr += '' + tr += ' ' + tr += '' + element.inv_number + '' + tr += '' + element.oboruds_id + '' + tr += '' + element.auditory_name + '' + tr += ' ' + tr += '' + '\n' + '' + tr += '' + }); + table.innerHTML += tr + } }) +} +$("#searchbutton").click(function(){ + getData(); + }) function tableclick(x){ let roww = x.rowIndex @@ -45,16 +46,52 @@ let datas = x.innerText.split('\t') - console.log(datas[0]) - + console.log(datas) + $('#getmodal').modal('show') + + let rasp = document.getElementById('rapolog') + let vedomost = document.getElementById('vednumber') + + if (datas[0].length>0){ + rasp.value=datas[0]; + } + + if (datas[4].length>0){ + vedomost.value=datas[4] + } - - - $('#getmodal').modal('show') $('#modalclose').click(function(){ $('#getmodal').modal('hide'); - } ) - } + } ) + + $('#modalsavetodb').click(function(){ + + console.log(datas) + + $.ajax({ + + url: "/addraspved", + type: "post", + contentType: 'application/json', + dataType: 'json', + data: { + rasp: rasp.value, + ved: vedomost.value + }, + + }) + + rasp.value=''; + + vedomost.value=''; + + + + $('#getmodal').modal('hide'); + + // getData(); + }) +} diff --git a/templates/searchonaud.html b/templates/searchonaud.html index c20dbab..3d811af 100644 --- a/templates/searchonaud.html +++ b/templates/searchonaud.html @@ -9,13 +9,13 @@ @@ -47,9 +47,12 @@ + + + {% for item in res: %}
Номер в Инв. вед Инв. номер Название АудиторияРасположение