feat: 顶部显示折扣名称和客户名称
This commit is contained in:
parent
7e3af2d9b8
commit
02f00c6739
@ -732,6 +732,7 @@ def load_discount():
|
|||||||
env.assign_customer_to_sale = assign_customer_to_sale
|
env.assign_customer_to_sale = assign_customer_to_sale
|
||||||
# Discount setting products list
|
# Discount setting products list
|
||||||
env.get_discount_setting_products = get_discount_setting_products
|
env.get_discount_setting_products = get_discount_setting_products
|
||||||
|
env.get_discount_info = get_discount_info
|
||||||
|
|
||||||
|
|
||||||
async def get_discount_setting_products(request):
|
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:
|
async with db.sqlorContext(dbname) as sor:
|
||||||
recs = await sor.sqlExe(sql, ns)
|
recs = await sor.sqlExe(sql, ns)
|
||||||
return recs if recs else []
|
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 {}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
{% set products = get_discount_setting_products(request) %}
|
{% set products = get_discount_setting_products(request) %}
|
||||||
|
{% set info = get_discount_info(request) %}
|
||||||
{
|
{
|
||||||
"widgettype": "VBox",
|
"widgettype": "VBox",
|
||||||
"options": {
|
"options": {
|
||||||
@ -10,7 +11,7 @@
|
|||||||
{
|
{
|
||||||
"widgettype": "Text",
|
"widgettype": "Text",
|
||||||
"options": {
|
"options": {
|
||||||
"text": "产品折扣设置",
|
"text": "产品折扣设置 - {{info.name or ''}}{% if info.customer %} ({{info.customer}}){% endif %}",
|
||||||
"fontSize": "16px",
|
"fontSize": "16px",
|
||||||
"fontWeight": "600",
|
"fontWeight": "600",
|
||||||
"color": "#F1F5F9",
|
"color": "#F1F5F9",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user