Динамическое получение списка заготовок и поставщиков
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
from flask import request, Blueprint, render_template, url_for
|
from flask import request, Blueprint, render_template, url_for
|
||||||
from os import path
|
from os import path
|
||||||
from checker import check_auth
|
from checker import check_auth
|
||||||
from .requests_model import sklad, materials_per_seller
|
from .requests_model import sklad, materials_per_seller, sellers_names, materials_names
|
||||||
import json
|
import json
|
||||||
|
|
||||||
with open(path.join(path.dirname(__file__), 'zapros_menu.json')) as f:
|
with open(path.join(path.dirname(__file__), 'zapros_menu.json')) as f:
|
||||||
@@ -19,8 +19,8 @@ def requests():
|
|||||||
@check_auth
|
@check_auth
|
||||||
def sklad_zapros():
|
def sklad_zapros():
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
# materials = ['Сталь', 'Алюминий', 'Медь', 'Пластик', 'Дерево']
|
materials = materials_names()
|
||||||
return render_template('zagotovki.html', header='Количество заготовок на складе')
|
return render_template('zagotovki.html', materials=materials.result)
|
||||||
else:
|
else:
|
||||||
material = dict(request.form)
|
material = dict(request.form)
|
||||||
zagotovki = sklad(material)
|
zagotovki = sklad(material)
|
||||||
@@ -34,8 +34,8 @@ def sklad_zapros():
|
|||||||
@check_auth
|
@check_auth
|
||||||
def sellers_ship():
|
def sellers_ship():
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
# sellers = ['Alpha Supplies', 'Beta Materials', 'Gamma Parts', 'Delta Components', 'Epsilon Goods']
|
sellers = sellers_names()
|
||||||
return render_template('sellers_ship.html')
|
return render_template('sellers_ship.html', sellers=sellers.result)
|
||||||
else:
|
else:
|
||||||
seller = dict(request.form)
|
seller = dict(request.form)
|
||||||
zagotovki = materials_per_seller(seller)
|
zagotovki = materials_per_seller(seller)
|
||||||
|
|||||||
@@ -11,6 +11,24 @@ class InfoRespronse:
|
|||||||
error_message: str
|
error_message: str
|
||||||
status: bool
|
status: bool
|
||||||
|
|
||||||
|
def sellers_names() -> InfoRespronse:
|
||||||
|
_sql = sql_provider.get('sellers_names.sql', {})
|
||||||
|
result = select_list(current_app.config['db_config'], _sql)
|
||||||
|
if result is None:
|
||||||
|
return InfoRespronse((),
|
||||||
|
error_message = 'Ошибка в подключении к базе данных. Свяжитесь с администратором',
|
||||||
|
status=False)
|
||||||
|
return InfoRespronse(result, error_message='', status=True)
|
||||||
|
|
||||||
|
def materials_names() -> InfoRespronse:
|
||||||
|
_sql = sql_provider.get('materials_names.sql', {})
|
||||||
|
result = select_list(current_app.config['db_config'], _sql)
|
||||||
|
if result is None:
|
||||||
|
return InfoRespronse((),
|
||||||
|
error_message = 'Ошибка в подключении к базе данных. Свяжитесь с администратором',
|
||||||
|
status=False)
|
||||||
|
return InfoRespronse(result, error_message='', status=True)
|
||||||
|
|
||||||
def sklad(input_data) -> InfoRespronse:
|
def sklad(input_data) -> InfoRespronse:
|
||||||
_sql = sql_provider.get('sklad_material.sql', input_data)
|
_sql = sql_provider.get('sklad_material.sql', input_data)
|
||||||
print("sql = ", _sql)
|
print("sql = ", _sql)
|
||||||
@@ -21,6 +39,7 @@ def sklad(input_data) -> InfoRespronse:
|
|||||||
status=False)
|
status=False)
|
||||||
return InfoRespronse(result, error_message='', status=True)
|
return InfoRespronse(result, error_message='', status=True)
|
||||||
|
|
||||||
|
|
||||||
def materials_per_seller(input_data) -> InfoRespronse:
|
def materials_per_seller(input_data) -> InfoRespronse:
|
||||||
_sql = sql_provider.get('ship_seller.sql', input_data)
|
_sql = sql_provider.get('ship_seller.sql', input_data)
|
||||||
result = select_list(current_app.config['db_config'], _sql)
|
result = select_list(current_app.config['db_config'], _sql)
|
||||||
|
|||||||
1
App/Requests/sql/materials_names.sql
Normal file
1
App/Requests/sql/materials_names.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
SELECT DISTINCT material FROM workpiece;
|
||||||
1
App/Requests/sql/sellers_names.sql
Normal file
1
App/Requests/sql/sellers_names.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
SELECT name FROM sellers;
|
||||||
@@ -15,11 +15,9 @@
|
|||||||
<p>Выберите поставщика</p>
|
<p>Выберите поставщика</p>
|
||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
<select name="seller">
|
<select name="seller">
|
||||||
<option value="Alpha Supplies">Alpha Supplies</option>
|
{% for seller in sellers %}
|
||||||
<option value="Beta Materials">Beta Materials</option>
|
<option value="{{ seller['name'] }}">{{ seller['name'] }}</option>
|
||||||
<option value="Gamma Parts">Gamma Parts</option>
|
{% endfor %}
|
||||||
<option value="Delta Components">Delta Components</option>
|
|
||||||
<option value="Epsilon Goods">Epsilon Goods</option>
|
|
||||||
</select>
|
</select>
|
||||||
<input type="submit" value="Отправить">
|
<input type="submit" value="Отправить">
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<html lang="ru">
|
<html lang="ru">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>{{ header }}</title>
|
<title>Количество заготовок на складе</title>
|
||||||
<link href="/static/css/main.css" type="text/css" rel="stylesheet">
|
<link href="/static/css/main.css" type="text/css" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
<a href="{{ url_for('logout') }}"><button>Выход</button></a>
|
<a href="{{ url_for('logout') }}"><button>Выход</button></a>
|
||||||
</div>
|
</div>
|
||||||
<!-- Input -->
|
<!-- Input -->
|
||||||
<h1>{{ header }}</h1>
|
<h1>Количество заготовок на складе</h1>
|
||||||
<div class="form">
|
<div class="form">
|
||||||
<form action="" method="post" style="display: inline-block;">
|
<form action="" method="post" style="display: inline-block;">
|
||||||
<p>Выберите материал<p></p>
|
<p>Выберите материал<p></p>
|
||||||
|
|||||||
Reference in New Issue
Block a user