From c126ca9021b2d9c40a33ba3e8b5077efeac595a8 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 29 Jun 2026 16:20:12 +0800 Subject: [PATCH] =?UTF-8?q?wip:=20Form=E2=86=92VBox+uitype:float?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/discount_setting/index.ui | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/wwwroot/discount_setting/index.ui b/wwwroot/discount_setting/index.ui index d6f8933..06665df 100644 --- a/wwwroot/discount_setting/index.ui +++ b/wwwroot/discount_setting/index.ui @@ -55,19 +55,16 @@ {"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", + "widgettype": "VBox", "options": { "width": "22%", - "padding": "0", - "margin": "0", - "show_label": false, - "submit_url": "{{entire_url('./save_discount.dspy')}}", - "fields": [ - {"name": "discountid", "uitype": "hide", "value": "{{params_kw.discountid}}"}, - {"name": "productid", "uitype": "hide", "value": "{{p.productid}}"}, - {"name": "detail_id", "uitype": "hide", "value": "{{p.detail_id or ''}}"}, - {"name": "discount", "uitype": "float", "value": "{{p.discount or ''}}", "placeholder": "0~1", "dec_len": 2} - ] + "padding": "0 12px", + "uitype": "float", + "value": "{{p.discount or ''}}", + "placeholder": "0~1", + "dec_len": 2, + "data-productid": "{{p.productid}}", + "data-detail_id": "{{p.detail_id or ''}}" }, "binds": [ { @@ -75,7 +72,7 @@ "event": "blur", "actiontype": "script", "target": "self", - "script": "var f=this.target;var d=f.getValue();var o=f._lv;if(d.discount===o)return;f._lv=d.discount;fetch(f.options.submit_url,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(d)}).then(function(r){return r.json()}).then(function(r){if(r.widgettype==='Error')bricks.show_error(r.options)}).catch(function(e){console.error(e)})" + "script": "var el=this.target.dom_element;var v=el.querySelector('input');if(!v)return;var nv=v.value;var ov=el._lv;if(nv===ov)return;el._lv=nv;fetch('{{entire_url(\"./save_discount.dspy\")}}',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({discountid:'{{params_kw.discountid}}',productid:el.getAttribute('data-productid'),detail_id:el.getAttribute('data-detail_id'),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)})" } ] }