From 57f792fbe55d612fce39dba53422d7aedb874265 Mon Sep 17 00:00:00 2001 From: fish Date: Fri, 24 Jul 2026 22:52:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E7=BA=A6=E7=AE=A1=E7=90=86=E7=AE=80?= =?UTF-8?q?=E5=8C=96=E4=B8=BA=E9=80=89=E5=93=81=E7=A7=8D+=E5=A1=AB?= =?UTF-8?q?=E6=9C=88=E4=BB=BD=EF=BC=8C=E7=B3=BB=E7=BB=9F=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=8B=BC=E6=8E=A5=E5=90=88=E7=BA=A6=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ft-app/app/routers/admin.py | 14 ++++++++++---- ft-app/app/templates/admin.html | 21 +++------------------ 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/ft-app/app/routers/admin.py b/ft-app/app/routers/admin.py index 38ca7ff..ab15095 100644 --- a/ft-app/app/routers/admin.py +++ b/ft-app/app/routers/admin.py @@ -76,15 +76,21 @@ def create_product( def create_contract( request: Request, product_id: int = Form(...), - code: str = Form(...), - name: str = Form(...), + month: str = Form(...), db: Session = Depends(get_db), ): - existing = db.query(Contract).filter(Contract.code == code.upper()).first() + product = db.query(Product).filter(Product.id == product_id).first() + if not product: + return RedirectResponse("/admin/?tab=contract", status_code=303) + + code = (product.code + month).upper() + name = month.upper() + + existing = db.query(Contract).filter(Contract.code == code).first() if not existing: c = Contract( product_id=product_id, - code=code.upper(), + code=code, name=name, is_active=True, ) diff --git a/ft-app/app/templates/admin.html b/ft-app/app/templates/admin.html index ffe40f3..8068cac 100644 --- a/ft-app/app/templates/admin.html +++ b/ft-app/app/templates/admin.html @@ -139,20 +139,16 @@
- {% for p in products %} - + {% endfor %}
- - -
-
- +
@@ -216,16 +212,5 @@ function toggleProduct(header) { } } -function onProductChange() { - var sel = document.getElementById('contract-product'); - var opt = sel.options[sel.selectedIndex]; - var code = opt.dataset.code || ''; - var input = document.getElementById('contract-code'); - if (code) { - input.placeholder = code + '2609'; - } else { - input.placeholder = '先选品种'; - } -} {% endblock %}