From 014a8de964c9310903319c7038a53da886e59055 Mon Sep 17 00:00:00 2001 From: fish Date: Tue, 28 Jul 2026 10:06:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=81=E4=BB=93=E9=A1=B5=E9=9D=A2=E5=93=81?= =?UTF-8?q?=E7=A7=8Dtab=E5=A2=9E=E5=8A=A0=E5=85=A8=E5=B9=B3=E6=8C=89?= =?UTF-8?q?=E9=92=AE=EF=BC=8C=E6=94=AF=E6=8C=81=E6=8C=89=E5=93=81=E7=A7=8D?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=B9=B3=E4=BB=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 --- ft-app/app/routers/trades.py | 23 +++++++++++++++++ ft-app/app/templates/trades.html | 43 ++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/ft-app/app/routers/trades.py b/ft-app/app/routers/trades.py index b075faa..ff7e199 100644 --- a/ft-app/app/routers/trades.py +++ b/ft-app/app/routers/trades.py @@ -152,6 +152,29 @@ def edit_trade( return RedirectResponse("/trades/", status_code=303) +@router.post("/bulk-close") +def bulk_close( + request: Request, + product_code: str = Form(...), + close_date: str = Form(...), + close_price: float = Form(...), + close_fee: float = Form(0.0), + db: Session = Depends(get_db), +): + trades = ( + db.query(Trade) + .filter(Trade.product_code == product_code.upper(), Trade.status == "open") + .all() + ) + for t in trades: + t.close_date = date.fromisoformat(close_date) + t.close_price = close_price + t.close_fee = close_fee + t.status = "closed" + db.commit() + return RedirectResponse("/trades/", status_code=303) + + @router.post("/{trade_id}/delete") def delete_trade(trade_id: int, db: Session = Depends(get_db)): t = db.query(Trade).filter(Trade.id == trade_id).first() diff --git a/ft-app/app/templates/trades.html b/ft-app/app/templates/trades.html index f05f52a..f77a53f 100644 --- a/ft-app/app/templates/trades.html +++ b/ft-app/app/templates/trades.html @@ -138,6 +138,14 @@ {% endif %} {% endif %} {% endfor %} + + {% if product_tab != '全部' and open_trades %} +
+ +
+ {% endif %} {% else %}
暂无持仓
{% endif %} @@ -166,6 +174,31 @@ +{# ── 全平弹窗 ── #} + + + {% else %}
@@ -302,6 +335,16 @@ function hideCloseForm() { document.getElementById('closeFormOverlay').style.display = 'none'; document.getElementById('closeFormBox').style.display = 'none'; } +function showBulkClose(productCode) { + document.getElementById('bulkCloseLabel').textContent = productCode; + document.getElementById('bulkCloseProduct').value = productCode; + document.getElementById('bulkCloseOverlay').style.display = 'block'; + document.getElementById('bulkCloseBox').style.display = 'block'; +} +function hideBulkClose() { + document.getElementById('bulkCloseOverlay').style.display = 'none'; + document.getElementById('bulkCloseBox').style.display = 'none'; +} {% endif %}