From 34ea9725603396b04a9bef572b26e7d369a27a07 Mon Sep 17 00:00:00 2001 From: Alex Danamir Date: Tue, 2 Apr 2024 22:50:36 +0300 Subject: [PATCH] add new fictures --- .gitignore | 2 ++ app.py | 26 +++++++++++++-------- static/css/index.css | 9 ++++++++ static/js/allmatc.js | 35 ++++++++++++++++++++++++++++ templates/all.html | 55 ++++++++++++++++++++------------------------ templates/js.html | 3 ++- 6 files changed, 89 insertions(+), 41 deletions(-) create mode 100644 static/js/allmatc.js diff --git a/.gitignore b/.gitignore index cd420b7..d42868d 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ project.db c*.txt +__pycache__/app.cpython-312.pyc +__pycache__/models.cpython-312.pyc diff --git a/app.py b/app.py index 75793c3..4571ff5 100644 --- a/app.py +++ b/app.py @@ -114,20 +114,26 @@ def addoborudtodb(): @app.route('/all') def alloborud(): + return render_template('all.html') - result = db.session.query(Oboruds).order_by(Oboruds.invNumber).all() - res = [] +@app.route('/getall') +def getall(): + oboruds = Oboruds.query.all() + oboruds_json = [{ + 'id': oborud.id, + 'invNumber': oborud.invNumber, + 'nazvanie': oborud.nazvanie, + 'raspologenie': oborud.raspologenie, + 'numberved': oborud.numberved, + 'buhnumberpp': oborud.buhnumberpp, + 'kolichestvo': oborud.kolichestvo, + 'balancenumber': oborud.balancenumber, + 'aud_id': oborud.aud_id + } for oborud in oboruds] - for ob in result: - if ob.aud_id is not None: - aud = db.session.query(Auditory).filter_by(id=ob.aud_id).first() - res.append([ob.invNumber, ob.nazvanie, aud.audnazvanie]) - else: - res.append([ob.invNumber, ob.nazvanie]) - - return render_template('all.html', res=res) + return jsonify(oboruds_json) @app.route('/updateduplicate', methods=['GET', 'POST']) def updateduplicate(): diff --git a/static/css/index.css b/static/css/index.css index 6bc3fb1..72385ec 100644 --- a/static/css/index.css +++ b/static/css/index.css @@ -100,6 +100,15 @@ nav{ margin-left: 20px; } +.datatable{ + background-color: whitesmoke; +} + + + + + + @media print { *{ diff --git a/static/js/allmatc.js b/static/js/allmatc.js new file mode 100644 index 0000000..c9e2668 --- /dev/null +++ b/static/js/allmatc.js @@ -0,0 +1,35 @@ +function getAllData(){ + $.ajax({ + + url: "/getall", + type: "get", + contentType: 'application/json', + dataType: 'json', + + success: function(response){ + console.log(response) + let data = response; + $('#datatable tbody').empty(); + $.each(response, function(index, item) { + $('#datatable tbody').append( + '' + + '' + item.invNumber + '' + + '' + item.nazvanie + '' + + '' + item.raspologenie + '' + + '' + item.numberved + '' + + '' + item.buhnumberpp + '' + + '' + item.kolichestvo + '' + + '' + item.balancenumber + '' + + '' + ); + }) + }, + + + }) +} + +$(document).ready(function(){ + + getAllData() +}) \ No newline at end of file diff --git a/templates/all.html b/templates/all.html index 97281a9..05ac334 100644 --- a/templates/all.html +++ b/templates/all.html @@ -3,37 +3,32 @@ {% block content %} +
+
+

Все мат. ценности

+ +
+
+ +
+ +
-
-
- -
-

Все мат. ценности

- - - - - - - - - - - {% for item in res: %} - - - - - - - - {% endfor %} - -
Инв. номерНазваниеАудитория
{{ item[0] }} {{ item[1] }} - {{ item[2] }} -
-
-
+
+ + + + + + + + + + + + +
№ п/п№ п/п ведИнв. номерНазваниеКол-воСчётАудитория
+
diff --git a/templates/js.html b/templates/js.html index a9092d2..672e2f6 100644 --- a/templates/js.html +++ b/templates/js.html @@ -9,4 +9,5 @@ - \ No newline at end of file + + \ No newline at end of file