feat: 顶部显示折扣名称和客户名称

This commit is contained in:
yumoqing 2026-06-29 17:02:57 +08:00
parent 7e3af2d9b8
commit 02f00c6739
2 changed files with 26 additions and 1 deletions

View File

@ -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 {}

View File

@ -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",