From 54c61b9756c6d49d0075019d0fa5179ab15c91f9 Mon Sep 17 00:00:00 2001 From: Alex Danamir Date: Mon, 1 Apr 2024 13:05:06 +0300 Subject: [PATCH] some func --- __pycache__/app.cpython-312.pyc | Bin 15045 -> 16039 bytes __pycache__/models.cpython-311.pyc | Bin 0 -> 2602 bytes __pycache__/models.cpython-312.pyc | Bin 2363 -> 2363 bytes addoborudtodb | 0 app.py | 45 +++--- migrations/__pycache__/env.cpython-312.pyc | Bin 4531 -> 4531 bytes .../__pycache__/256c3a3e91a2_.cpython-312.pyc | Bin 1319 -> 1319 bytes .../__pycache__/4f95d12a8352_.cpython-312.pyc | Bin 1317 -> 1317 bytes .../__pycache__/50f85881169e_.cpython-312.pyc | Bin 687 -> 687 bytes .../__pycache__/873defe09f22_.cpython-312.pyc | Bin 1324 -> 1324 bytes .../__pycache__/8e838956713f_.cpython-312.pyc | Bin 1321 -> 1321 bytes .../__pycache__/b24baa0d98e6_.cpython-312.pyc | Bin 717 -> 717 bytes .../__pycache__/b2a61aef79e9_.cpython-312.pyc | Bin 687 -> 687 bytes .../__pycache__/ec6bbcd361bd_.cpython-312.pyc | Bin 2058 -> 2058 bytes static/css/index.css | 23 +++ static/js/searchonaud.js | 133 +++++++++++------- static/js/tmp.js | 47 +++++++ templates/searchonaud.html | 44 ++++-- 18 files changed, 197 insertions(+), 95 deletions(-) create mode 100644 __pycache__/models.cpython-311.pyc create mode 100644 addoborudtodb create mode 100644 static/js/tmp.js diff --git a/__pycache__/app.cpython-312.pyc b/__pycache__/app.cpython-312.pyc index 6618befc868f0a68928363ce10fae0b859e708e3..18d2bc281950e860c1d94224d7808b208d6fba18 100644 GIT binary patch delta 1057 zcmZ8fO>7%Q7@gT4d%dxpHnAQ5G_Dgv?5z_g1zAZ3y zzW2?({dRwvyHj%i>~hI~o=kMRgQT8K(Q;J z+N9ugABtZAr(;N=7+3eBLl@!zV6WP7evOablgm#}O%(NaXY*7!U%M(F?}96}?ViUxT&r!p{1*qmsC^&*j)PUQkhtNR zZyU@agtJ=VvWmz_rw``IB_&E0!ghF_eC`eNC18+<-$!UL&KYrzhMKR#QosV zR&eO6&U!FaZl{XRUzT?~(T9L@yi`866X?Db{4{8e-8}fgiSpR0cPAVzpIFsCJlPPb zp&AQu&Q9WNKTz}cM+Na?n*G<>>q9Qlwn{0kkjd1txIyXfwck>2LU@P_4!`aFlJ%}r zu%t{TpPf-N8N5nv4Zq)Zjdj>9c!MNHdgXhRvj1JXT6=5cHiR;XjQU7NdP!;c04J^l lmILLZW@@9)99#<2;Vb`eemDXD^Mr*s-z#BA4hlOkE6c@-tUPDxS7! zh#Q`=@DN8SR_UGmmI8H_aVZE{#3_-hI3@MusPh-Qw7+1jhuR(=zqG$lt%uqk&tBSJxYk2$ zk8e2J-*L)U!1lbI;qWzkcDg_PDJ*PNLUM^xA`@m7^p9)+BT#$qufZR&i9S%{I|4B~r z#t&AFPbg4dNHD&j_^e-tNoSTY$(J|5I!c~L{Hm{7Qu7HZ1T+qN5grPHIVT@cId#)7 zmJta}iI!rHa>)zOxXj(K`OI7tRWCXqnrK{Bkr$OfGl>?q%t=lE!E1o31Y?pwX1pL) zC9|HYZ4e_S@Hsq&32+grvWb=M)X|CCq3+@hk<~VmFtfk_L|FHvj<2kvx*#pi+ZUkMKtCFNJ#XVf^qvCjBe= E7vLHM$^ZZW literal 0 HcmV?d00001 diff --git a/__pycache__/models.cpython-312.pyc b/__pycache__/models.cpython-312.pyc index 84cd74ba589dca8257aa975630f7edb50500d3ab..3d4cca7df5775e8cc87b28c16291eda4aa899dd7 100644 GIT binary patch delta 51 zcmdljv|EV#G%qg~0}woY|7Rn&4U?p^RZKupetJ=2Zf<5?dQ3oNNk)DiP$X+}0@H0a E0K9k-LjV8( delta 51 zcmdljv|EV#G%qg~0}!0x_`Q+ahDp-JDkh*PKfNe1H#ajcJtm;CBqKi$B(gby={6ex Dmah>! diff --git a/addoborudtodb b/addoborudtodb new file mode 100644 index 0000000..e69de29 diff --git a/app.py b/app.py index 1aa53ca..75793c3 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,10 +78,12 @@ 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, }) return jsonify(results) @@ -183,30 +186,24 @@ 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") - # Split the query string by '&' to get individual key-value pairs - key_value_pairs = query_string_str.split("&") + query_string = request.data.decode() - # 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 + print(query_string) + un_query_string = unquote(unquote(query_string)).split(',') - # 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}") + print(un_query_string) - - return jsonify({'success': True}, 200, {'ContentType': 'application/json'}) - + + 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] + db.session.commit() + db.session.close() + + return jsonify({'success': True}, 200, {'ContentType': 'application/json'}) + # ================================================================================== @@ -262,16 +259,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 d40e79f400bb16ed92d574bacba9859fc929731d..26bd5f43025677793ecc3a3f32f9f3c9b03e87ad 100644 GIT binary patch delta 33 ocmdn2yjhw1G%qg~0}woY|7RojM delta 33 ncmdn2yjhw1G%qg~0}wb?|J=y^k%`e|@?R!##`Mji%=7pFrmYFs diff --git a/migrations/versions/__pycache__/256c3a3e91a2_.cpython-312.pyc b/migrations/versions/__pycache__/256c3a3e91a2_.cpython-312.pyc index 77081c020d0561fcf0bae39f174e7f1634cd7da5..280709a1ee6a6bff249d19d258745785f406cb45 100644 GIT binary patch delta 50 zcmZ3^wVaFlG%qg~0}woY|7Roj9Y#rKtC)bI{Pd#4+}zB(^q7Fkl8pR3ph(sxCUs^2 DvBD9O delta 50 zcmZ3^wVaFlG%qg~0}wb?|J=xZhf&hSDkh*PKfNe1H#ajcJtm;CBqKi$B(jM~of!a$ CV-R%! diff --git a/migrations/versions/__pycache__/4f95d12a8352_.cpython-312.pyc b/migrations/versions/__pycache__/4f95d12a8352_.cpython-312.pyc index 2889172c48bcc637f0802a4cc60643c47ee508aa..a22fbdba7d14976b081fd4de951dc714d7f8fb34 100644 GIT binary patch delta 51 zcmZ3=wUmqdG%qg~0}woY|7Rn2Jd>oeRZKupetJ=2Zf<5?dQ3oNNk)DiP$X+}Gt(j_ E0JUin5C8xG delta 51 zcmZ3=wUmqdG%qg~0}wb?|J=wO&m`$$6%$aDpI(%ho12-J9urVml98VW64~6$w1^1+ Di|r8e diff --git a/migrations/versions/__pycache__/50f85881169e_.cpython-312.pyc b/migrations/versions/__pycache__/50f85881169e_.cpython-312.pyc index aee53e012d4bd8c8629af841795a6c4383eced9d..09660f0669e349e2275b93619a0d0111d9f51a66 100644 GIT binary patch delta 51 zcmZ3_x}KH$G%qg~0}woY|7Rn&6r-fGRZKupetJ=2Zf<5?dQ3oNNk)DiP$X-!9b+LQ E0IcW{TmS$7 delta 51 zcmZ3_x}KH$G%qg~0}wb?|J=we#VF}w6%$aDpI(%ho12-J9urVml98VW64`9WSjY$f DgKQ8# diff --git a/migrations/versions/__pycache__/873defe09f22_.cpython-312.pyc b/migrations/versions/__pycache__/873defe09f22_.cpython-312.pyc index fd851b545b20ef076a3b75ffd03cc99fa5620d02..6f099d51484d56605be5ccf068b24509e6ecdd5b 100644 GIT binary patch delta 33 ncmZ3(wT6rPG%qg~0}woY|7Rn2DifpgFKkvD;f(PeTTlQ?7g<~F9qOaQ9&3A6wJ diff --git a/migrations/versions/__pycache__/b24baa0d98e6_.cpython-312.pyc b/migrations/versions/__pycache__/b24baa0d98e6_.cpython-312.pyc index 69a74a07e7bccc54efa3b14042dc9461a8150d5f..43d15762a7818a8c00bc305dac1f09aca20e1b12 100644 GIT binary patch delta 51 zcmX@hdX|;@G%qg~0}woY|7Rn&1*4?1RZKupetJ=2Zf<5?dQ3oNNk)DiP$X+}3}Yc9 E0KE1Q)Bpeg delta 51 zcmX@hdX|;@G%qg~0}wb?|J=xJ!6@ls6%$aDpI(%ho12-J9urVml98VW64@NXSjY$f DlX?)h diff --git a/migrations/versions/__pycache__/b2a61aef79e9_.cpython-312.pyc b/migrations/versions/__pycache__/b2a61aef79e9_.cpython-312.pyc index 6f573f09a6017ca70e230698ea78f77387fc7300..a7e9152bb66bea3a82a0e44bde5e09775d76a7e2 100644 GIT binary patch delta 51 zcmZ3_x}KH$G%qg~0}woY|7Rn&6r-fGRZKupetJ=2Zf<5?dQ3oNNk)DiP$X-!9b+LQ E0IcW{TmS$7 delta 51 zcmZ3_x}KH$G%qg~0}wb?|J=we#VF}w6%$aDpI(%ho12-J9urVml98VW64`9WSjY$f DgKQ8# diff --git a/migrations/versions/__pycache__/ec6bbcd361bd_.cpython-312.pyc b/migrations/versions/__pycache__/ec6bbcd361bd_.cpython-312.pyc index 1d027b0c3daaddba27d7e21b2e3b7083749d8fec..e5f76bc43be7407a1fc729ddd056775d7ae128ae 100644 GIT binary patch delta 33 ncmeAY=n~*Q&CAQh00d9p|JlgR%*^OKnV(slF>A9r^J5kOmmCQ2 delta 33 ncmeAY=n~*Q&CAQh00fTJKR0qSGc&qO=4TdXOy8`|{Fns*fpiDc 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 ce603b8..ac233b4 100644 --- a/static/js/searchonaud.js +++ b/static/js/searchonaud.js @@ -13,21 +13,23 @@ function getData(){ }, success: function(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 += '' + '\n' + '' + tr += '' +element.raspolog + '' + tr += '' + '\n' + '' tr += '' }); @@ -40,59 +42,84 @@ $("#searchbutton").click(function(){ getData(); }) - function tableclick(x){ - let roww = x.rowIndex - let data = document.getElementById(x.rowIndex) +$('#modalsavetodb').click(function(){ - let datas = x.innerText.split('\t') + let rasp = document.getElementById('modal_rapolog') + let vedomost = document.getElementById('modal_vednumber') + let invnom = document.getElementById('modal_invnom') + let matcen = document.getElementById('modal_matcenn') - console.log(datas) + let changeddata = new Array() - $('#getmodal').modal('show') + changeddata[0] = invnom.text + changeddata[1] = vedomost.value + changeddata[2] = rasp.value - let rasp = document.getElementById('rapolog') - let vedomost = document.getElementById('vednumber') + let sendData = changeddata.join(',') - if (datas[0].length>0){ - rasp.value=datas[0]; + changeddata = [] + $.ajax({ + + url: "/addraspved", + type: "POST", + contentType: "application/json;charset=utf-8", + dataType: "json", + data: sendData, + + success: function(){ + /* + rasp='', + vedomost = '', + invnom = '', + matcen = '', + + changeddata = [] + */ + $('#getmodal').modal('hide').data( 'bs.modal', null ); + getData(); } - - if (datas[4].length>0){ - vedomost.value=datas[4] - } - - $('#modalclose').click(function(){ - - $('#getmodal').modal('hide'); - } ) - - $('#modalsavetodb').click(function(){ - - console.log(datas) - - $.ajax({ - - url: "/addraspved", - type: "post", - contentType: 'application/json', - dataType: 'json', - data: { - ved: vedomost.value, - rasp: rasp.value - - }, - - }) - - rasp.value=''; - - vedomost.value=''; - - - - $('#getmodal').modal('hide'); - - // getData(); }) -} + +}) + + +function tableclick(tableRow){ + + let nomved = tableRow.childNodes[0].innerHTML; + let invnomer = tableRow.childNodes[1].innerHTML; + let nazvanie = tableRow.childNodes[2].innerHTML; + let raspolog = tableRow.childNodes[4].innerHTML; + + $('#getmodal').modal('show') + + let rasp = document.getElementById('modal_rapolog') + let vedomost = document.getElementById('modal_vednumber') + let invnom = document.getElementById('modal_invnom') + let matcen = document.getElementById('modal_matcenn') + + invnom.innerText = invnomer + matcen.innerText = nazvanie.substring(0,15) + + if (nomved.length >0){ + + vedomost.value = nomved + } + + if(raspolog.length>0){ + rasp.value = raspolog + } + + $("#mimodal").on('hidden.bs.modal', function () { + $(this).data('bs.modal', null); + }); + + + $('#modalclose').click(function(){ + + $('#getmodal').modal('hide').data( 'bs.modal', null ); + + } ) + + +} \ No newline at end of file diff --git a/static/js/tmp.js b/static/js/tmp.js new file mode 100644 index 0000000..da3063e --- /dev/null +++ b/static/js/tmp.js @@ -0,0 +1,47 @@ +function tableclick(x){ + // let data = document.getElementById(x.rowIndex) + + let datas = x.innerText.split('\t') + + + + invnom.innerText=datas[1]+"\t" + matcen.innerText=datas[2] + + + 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(){ + $.ajax({ + + url: "/addraspved", + type: "POST", + contentType: "application/json;charset=utf-8", + dataType: "json", + data: { + rasp: rasp.value, + ved: vedomost.value, + inv: invnomer + }, + success:function() { + rasp.value = ''; + vedomost.value= ''; + data=[]; + rasp + $('#getmodal').modal('hide'); + getData(); + } + }) + })} \ No newline at end of file diff --git a/templates/searchonaud.html b/templates/searchonaud.html index 3d811af..5214d5d 100644 --- a/templates/searchonaud.html +++ b/templates/searchonaud.html @@ -8,15 +8,33 @@ @@ -45,13 +63,13 @@

Поаудиторно

- +
- - - - - + + + + + {% for item in res: %}
Номер в Инв. ведИнв. номерНазваниеАудиторияРасположениеНомер в Инв. ведИнв. номерНазваниеАудиторияРасположение