diff --git a/discount/init.py b/discount/init.py index 65bf13d..7b819e6 100644 --- a/discount/init.py +++ b/discount/init.py @@ -739,7 +739,14 @@ async def get_discount_setting_products(request): Used in Jinja2 template: {% set products = get_discount_setting_products(request) %} """ 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() if not discountid or not user_orgid: diff --git a/wwwroot/discount_setting/index.ui b/wwwroot/discount_setting/index.ui index b785584..ee4c5a6 100644 --- a/wwwroot/discount_setting/index.ui +++ b/wwwroot/discount_setting/index.ui @@ -21,44 +21,44 @@ "widgettype": "HBox", "options": { "bgcolor": "#0F172A", - "padding": "8px 12px", + "padding": "8px 0", "borderRadius": "6px 6px 0 0", - "alignItems": "center" + "alignItems": "center", + "width": "100%" }, "subwidgets": [ - {"widgettype": "Text", "options": {"text": "产品分类", "cwidth": 3, "fontSize": "12px", "fontWeight": "600", "color": "#94A3B8"}}, - {"widgettype": "Text", "options": {"text": "产品名称", "cwidth": 5, "fontSize": "12px", "fontWeight": "600", "color": "#94A3B8"}}, - {"widgettype": "Text", "options": {"text": "产品编码", "cwidth": 3, "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": "产品名称", "width": "34%", "padding": "0 12px", "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": "折扣(可编辑)", "width": "22%", "padding": "0 12px", "fontSize": "12px", "fontWeight": "600", "color": "#94A3B8"}} ] }, { "widgettype": "VBox", "id": "discount_rows", "options": { - "width": "100%", - "css": "childrensize" + "width": "100%" }, "subwidgets": [ {% for p in products %} { "widgettype": "HBox", "options": { - "padding": "6px 12px", + "padding": "6px 0", "border": "0 0 1px 0", "borderColor": "#334155", "alignItems": "center", "width": "100%" }, "subwidgets": [ - {"widgettype": "Text", "options": {"text": "{{p.category_name or ''}}", "cwidth": 3, "fontSize": "12px", "color": "#E2E8F0"}}, - {"widgettype": "Text", "options": {"text": "{{p.product_name or ''}}", "cwidth": 5, "fontSize": "12px", "color": "#F1F5F9"}}, - {"widgettype": "Text", "options": {"text": "{{p.product_code 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 ''}}", "width": "34%", "padding": "0 12px", "fontSize": "12px", "color": "#F1F5F9"}}, + {"widgettype": "Text", "options": {"text": "{{p.product_code or ''}}", "width": "22%", "padding": "0 12px", "fontSize": "12px", "color": "#E2E8F0"}}, { "widgettype": "Form", "id": "discount_form_{{loop.index}}", "options": { - "cwidth": 3, + "width": "22%", "show_label": false, "css": "childrensize", "submit_url": "{{entire_url('./save_discount.dspy')}}",