Появление сущности накладной + перенос waybill.css в отдельную папку

This commit is contained in:
2024-12-01 20:16:56 +03:00
parent 988d8fe006
commit b3f856b401
6 changed files with 36 additions and 38 deletions

View File

@@ -1,16 +1,24 @@
from flask import request, Blueprint, render_template, session, current_app, redirect, url_for
from checker import check_auth
from .model import waybill_model
waybill_bp = Blueprint('waybill_bp', __name__, template_folder='templates')
from .model import workpiece_list, clear
waybill_bp = Blueprint('waybill_bp', __name__, template_folder='templates', static_folder='static')
@waybill_bp.route('/', methods=['GET', 'POST'])
@waybill_bp.route('/', methods=['GET'])
@check_auth
def index():
lst = workpiece_list()
if lst.status:
return render_template('waybill.html', items=lst.result)
else:
return render_template('error.html', error_message=lst.error_message)
@waybill_bp.route('/clear', methods=['GET'])
@check_auth
def clear_basket():
clear()
return redirect(url_for('waybill_bp.index'))
@waybill_bp.route('/', methods=['POST'])
def waybill():
if request.method == 'GET':
pack = waybill_model()
if pack.status:
return render_template('waybill.html', items=pack.result)
else:
return render_template('error.html', error_message=pack.error_message)
print(request.form)
return 'OK'

View File

@@ -1,6 +1,6 @@
from .db.sql_provider import SQLProvider
from .db.work import select_list
from flask import current_app
from flask import current_app, session
from dataclasses import dataclass
import os
@@ -12,8 +12,11 @@ class InfoRespronse:
sql_provider = SQLProvider(os.path.join(os.path.dirname(__file__), 'sql'))
def clear():
if session.get('basket',{}):
session.pop('basket')
def waybill_model() -> InfoRespronse:
def workpiece_list() -> InfoRespronse:
_sql = sql_provider.get('goods.sql', {})
result = select_list(current_app.config['db_config'], _sql)
if result is None:

View File

@@ -9,7 +9,7 @@
<form method="POST" action="">
<input type="hidden" name="product_display" value="{{item['work_id']}}" />
<button class="btn btn-primary">
Добавить в корзину
Добавить в накладную
</button>
<button type="submit" name="product_display_minus" value="minus" class="btn btn-danger">-</button>
<button type="submit" name="product_display_plus" value="plus" class="btn btn-success">+</button>

View File

@@ -5,17 +5,16 @@
<meta charset="UTF-8">
<title>Оформление накладной</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="/static/css/waybill.css" type="text/css" rel="stylesheet">
<link href="static/css/waybill.css" type="text/css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<link href="/static/css/main.css" type="text/css" rel="stylesheet">
</head>
<body>
<div class="container mt-4">
<div class="row">
<!-- Секция товаров -->
<!-- Секция заготовок -->
<div class="col-md-8">
<h4>Список товаров</h4>
<h4>Список заготовок</h4>
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-3">
{% for item in items %}
<div class="col">
@@ -25,15 +24,17 @@
</div>
</div>
<!-- Секция корзины -->
<!-- Секция кнакладной -->
<div class="col-md-4">
<h4>Корзина</h4>
<ul class="list-group" id="cart-items">
<li class="list-group-item">Корзина пуста</li>
</ul>
<div class="mt-3">
<h5>Итог: <span id="total-price">0</span></h5>
</div>
<h4>Накладная</h4>
{% if basket %}
{% for item in basket %}
{{ components.render_item(item, show_form = False, show_amount = True) }}
{% endfor %}
<a href="{{url_for('basket_bp.save_order')}}"><button class="btn btn-primary">Оформить накладную</button></a>
{% else %}
<span>Ваша накладная пуста</span>
{% endif %}
</div>
</div>
</div>

View File

@@ -1,14 +0,0 @@
table {
border: 1px solid black;
border-collapse: collapse;
background: white;
margin: 0 auto;
}
th {
background-color: #d3d3d3;
}
th, td {
border: 1px solid black;
padding: 5px;
text-align: center;
}