fix: cwidth改为width百分比(22/34/22/22); discountid改用rel_url.query多种方式获取

This commit is contained in:
yumoqing 2026-06-29 12:05:41 +08:00
parent 2259b68789
commit 2d869c1fbc
2 changed files with 21 additions and 14 deletions

View File

@ -739,7 +739,14 @@ async def get_discount_setting_products(request):
Used in Jinja2 template: {% set products = get_discount_setting_products(request) %} Used in Jinja2 template: {% set products = get_discount_setting_products(request) %}
""" """
env = request._run_ns env = request._run_ns
discountid = (getattr(request, '_params_kw', {}) or {}).get('discountid', '') # Try multiple ways to get discountid from URL query params
discountid = ''
if hasattr(request, 'rel_url') and request.rel_url:
discountid = request.rel_url.query.get('discountid', '')
if not discountid and hasattr(request, 'query'):
discountid = request.query.get('discountid', '')
if not discountid:
discountid = (getattr(request, '_params_kw', {}) or {}).get('discountid', '')
user_orgid = await env.get_userorgid() user_orgid = await env.get_userorgid()
if not discountid or not user_orgid: if not discountid or not user_orgid:

View File

@ -21,44 +21,44 @@
"widgettype": "HBox", "widgettype": "HBox",
"options": { "options": {
"bgcolor": "#0F172A", "bgcolor": "#0F172A",
"padding": "8px 12px", "padding": "8px 0",
"borderRadius": "6px 6px 0 0", "borderRadius": "6px 6px 0 0",
"alignItems": "center" "alignItems": "center",
"width": "100%"
}, },
"subwidgets": [ "subwidgets": [
{"widgettype": "Text", "options": {"text": "产品分类", "cwidth": 3, "fontSize": "12px", "fontWeight": "600", "color": "#94A3B8"}}, {"widgettype": "Text", "options": {"text": "产品分类", "width": "22%", "padding": "0 12px", "fontSize": "12px", "fontWeight": "600", "color": "#94A3B8"}},
{"widgettype": "Text", "options": {"text": "产品名称", "cwidth": 5, "fontSize": "12px", "fontWeight": "600", "color": "#94A3B8"}}, {"widgettype": "Text", "options": {"text": "产品名称", "width": "34%", "padding": "0 12px", "fontSize": "12px", "fontWeight": "600", "color": "#94A3B8"}},
{"widgettype": "Text", "options": {"text": "产品编码", "cwidth": 3, "fontSize": "12px", "fontWeight": "600", "color": "#94A3B8"}}, {"widgettype": "Text", "options": {"text": "产品编码", "width": "22%", "padding": "0 12px", "fontSize": "12px", "fontWeight": "600", "color": "#94A3B8"}},
{"widgettype": "Text", "options": {"text": "折扣(可编辑)", "cwidth": 3, "fontSize": "12px", "fontWeight": "600", "color": "#94A3B8"}} {"widgettype": "Text", "options": {"text": "折扣(可编辑)", "width": "22%", "padding": "0 12px", "fontSize": "12px", "fontWeight": "600", "color": "#94A3B8"}}
] ]
}, },
{ {
"widgettype": "VBox", "widgettype": "VBox",
"id": "discount_rows", "id": "discount_rows",
"options": { "options": {
"width": "100%", "width": "100%"
"css": "childrensize"
}, },
"subwidgets": [ "subwidgets": [
{% for p in products %} {% for p in products %}
{ {
"widgettype": "HBox", "widgettype": "HBox",
"options": { "options": {
"padding": "6px 12px", "padding": "6px 0",
"border": "0 0 1px 0", "border": "0 0 1px 0",
"borderColor": "#334155", "borderColor": "#334155",
"alignItems": "center", "alignItems": "center",
"width": "100%" "width": "100%"
}, },
"subwidgets": [ "subwidgets": [
{"widgettype": "Text", "options": {"text": "{{p.category_name or ''}}", "cwidth": 3, "fontSize": "12px", "color": "#E2E8F0"}}, {"widgettype": "Text", "options": {"text": "{{p.category_name or ''}}", "width": "22%", "padding": "0 12px", "fontSize": "12px", "color": "#E2E8F0"}},
{"widgettype": "Text", "options": {"text": "{{p.product_name or ''}}", "cwidth": 5, "fontSize": "12px", "color": "#F1F5F9"}}, {"widgettype": "Text", "options": {"text": "{{p.product_name or ''}}", "width": "34%", "padding": "0 12px", "fontSize": "12px", "color": "#F1F5F9"}},
{"widgettype": "Text", "options": {"text": "{{p.product_code or ''}}", "cwidth": 3, "fontSize": "12px", "color": "#E2E8F0"}}, {"widgettype": "Text", "options": {"text": "{{p.product_code or ''}}", "width": "22%", "padding": "0 12px", "fontSize": "12px", "color": "#E2E8F0"}},
{ {
"widgettype": "Form", "widgettype": "Form",
"id": "discount_form_{{loop.index}}", "id": "discount_form_{{loop.index}}",
"options": { "options": {
"cwidth": 3, "width": "22%",
"show_label": false, "show_label": false,
"css": "childrensize", "css": "childrensize",
"submit_url": "{{entire_url('./save_discount.dspy')}}", "submit_url": "{{entire_url('./save_discount.dspy')}}",