wip: Form→VBox+uitype:float

This commit is contained in:
yumoqing 2026-06-29 16:20:12 +08:00
parent 3896a8145e
commit c126ca9021

View File

@ -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)})"
}
]
}