From 02f00c6739deebb981c13516d50da94179d2c54f Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 29 Jun 2026 17:02:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=A1=B6=E9=83=A8=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=8A=98=E6=89=A3=E5=90=8D=E7=A7=B0=E5=92=8C=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- discount/init.py | 24 ++++++++++++++++++++++++ wwwroot/discount_setting/index.ui | 3 ++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/discount/init.py b/discount/init.py index f8df9e5..4904d67 100644 --- a/discount/init.py +++ b/discount/init.py @@ -732,6 +732,7 @@ def load_discount(): env.assign_customer_to_sale = assign_customer_to_sale # Discount setting products list env.get_discount_setting_products = get_discount_setting_products + env.get_discount_info = get_discount_info async def get_discount_setting_products(request): @@ -771,3 +772,26 @@ async def get_discount_setting_products(request): async with db.sqlorContext(dbname) as sor: recs = await sor.sqlExe(sql, ns) return recs if recs else [] + + +async def get_discount_info(request): + """Get discount name and customer name for display header.""" + env = request._run_ns + discountid = (request._run_ns.params_kw or {}).get('discountid', '') + if not discountid: + return {} + dbname = env.get_module_dbname('discount') + db = DBPools() + config = getConfig() + db.databases = config.databases + sql = """ + SELECT d.name, o.orgname + FROM discount d + LEFT JOIN organization o ON d.customerid = o.id + WHERE d.id = ${discountid}$ + """ + async with db.sqlorContext(dbname) as sor: + recs = await sor.sqlExe(sql, {'discountid': discountid}) + if recs: + return {'name': recs[0].name or '', 'customer': recs[0].orgname or ''} + return {} diff --git a/wwwroot/discount_setting/index.ui b/wwwroot/discount_setting/index.ui index 531e75e..a604a08 100644 --- a/wwwroot/discount_setting/index.ui +++ b/wwwroot/discount_setting/index.ui @@ -1,4 +1,5 @@ {% set products = get_discount_setting_products(request) %} +{% set info = get_discount_info(request) %} { "widgettype": "VBox", "options": { @@ -10,7 +11,7 @@ { "widgettype": "Text", "options": { - "text": "产品折扣设置", + "text": "产品折扣设置 - {{info.name or ''}}{% if info.customer %} ({{info.customer}}){% endif %}", "fontSize": "16px", "fontWeight": "600", "color": "#F1F5F9",