diff --git a/wwwroot/discount_setting/index.ui b/wwwroot/discount_setting/index.ui index 4977bee..b8919f0 100644 --- a/wwwroot/discount_setting/index.ui +++ b/wwwroot/discount_setting/index.ui @@ -1,4 +1,6 @@ {% set products = get_discount_setting_products(request) %} +{% set save_url = entire_url('./save_discount.dspy') %} +{% set disc_id = params_kw.discountid %} { "widgettype": "VBox", "options": { @@ -47,46 +49,46 @@ }, "subwidgets": [ {% for p in products %} - { - "widgettype": "HBox", - "options": { - "padding": "6px 0", - "border": "0 0 1px 0", - "borderColor": "#334155", - "alignItems": "center", - "width": "100%" - }, - "subwidgets": [ - {"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": "UiFloat", + "widgettype": "HBox", "options": { - "width": "22%", - "padding": "0 12px", - "name": "discount", - "value": "{{p.discount or ''}}", - "placeholder": "0~1", - "dec_len": 2, - "fontSize": "12px" + "padding": "6px 0", + "border": "0 0 1px 0", + "borderColor": "#334155", + "alignItems": "center", + "width": "100%" }, - "binds": [ + "subwidgets": [ + {"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"}}, { - "wid": "self", - "event": "blur", - "actiontype": "script", - "target": "self", - "script": "var v=this.target.dom_element.querySelector('input');if(!v)return;var nv=v.value;fetch('{{entire_url(\"./save_discount.dspy\")}}',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({discountid:'{{params_kw.discountid}}',productid:'{{p.productid}}',detail_id:'{{p.detail_id or ''}}',discount:nv})}).then(function(r){return r.json()}).then(function(r){if(r.widgettype==='Error')bricks.show_error(r.options)}).catch(function(e){console.error(e)})" + "widgettype": "UiFloat", + "options": { + "width": "22%", + "padding": "0 12px", + "name": "discount", + "value": "{{p.discount or ''}}", + "placeholder": "0~1", + "dec_len": 2, + "fontSize": "12px" + }, + "binds": [ + { + "wid": "self", + "event": "blur", + "actiontype": "script", + "target": "self", + "script": "var inp=this.target.dom_element.querySelector('input');if(!inp)return;var nv=inp.value;fetch('{{save_url}}',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({discountid:'{{disc_id}}',productid:'{{p.productid}}',detail_id:'{{p.detail_id or ""}}',discount:nv})}).then(function(r){return r.json()}).then(function(r){if(r.widgettype==='Error')bricks.show_error(r.options)}).catch(function(e){console.error(e)})" + } + ] } ] - } - ] - }{% if not loop.last %},{% endif %} + }{% if not loop.last %},{% endif %} {% endfor %} + ] + } ] } - ] - } -] + ] }