wip: Form→VBox+uitype:float
This commit is contained in:
parent
3896a8145e
commit
c126ca9021
@ -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_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": "Text", "options": {"text": "{{p.product_code or ''}}", "width": "22%", "padding": "0 12px", "fontSize": "12px", "color": "#E2E8F0"}},
|
||||||
{
|
{
|
||||||
"widgettype": "Form",
|
"widgettype": "VBox",
|
||||||
"options": {
|
"options": {
|
||||||
"width": "22%",
|
"width": "22%",
|
||||||
"padding": "0",
|
"padding": "0 12px",
|
||||||
"margin": "0",
|
"uitype": "float",
|
||||||
"show_label": false,
|
"value": "{{p.discount or ''}}",
|
||||||
"submit_url": "{{entire_url('./save_discount.dspy')}}",
|
"placeholder": "0~1",
|
||||||
"fields": [
|
"dec_len": 2,
|
||||||
{"name": "discountid", "uitype": "hide", "value": "{{params_kw.discountid}}"},
|
"data-productid": "{{p.productid}}",
|
||||||
{"name": "productid", "uitype": "hide", "value": "{{p.productid}}"},
|
"data-detail_id": "{{p.detail_id or ''}}"
|
||||||
{"name": "detail_id", "uitype": "hide", "value": "{{p.detail_id or ''}}"},
|
|
||||||
{"name": "discount", "uitype": "float", "value": "{{p.discount or ''}}", "placeholder": "0~1", "dec_len": 2}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"binds": [
|
"binds": [
|
||||||
{
|
{
|
||||||
@ -75,7 +72,7 @@
|
|||||||
"event": "blur",
|
"event": "blur",
|
||||||
"actiontype": "script",
|
"actiontype": "script",
|
||||||
"target": "self",
|
"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)})"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user