fix: 用widgettype:UiFloat+urlwidget替代Form+JS
This commit is contained in:
parent
d536490599
commit
b3dabcf0f6
@ -35,7 +35,6 @@
|
||||
},
|
||||
{
|
||||
"widgettype": "VBox",
|
||||
"id": "discount_rows",
|
||||
"options": {
|
||||
"width": "100%"
|
||||
},
|
||||
@ -55,29 +54,38 @@
|
||||
{"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": "VBox",
|
||||
"id": "disc_cell_{{loop.index}}",
|
||||
"widgettype": "UiFloat",
|
||||
"options": {
|
||||
"width": "22%",
|
||||
"padding": "0 12px",
|
||||
"data-pid": "{{p.productid}}",
|
||||
"data-did": "{{p.detail_id or ''}}",
|
||||
"data-discount": "{{p.discount or ''}}"
|
||||
}
|
||||
"name": "discount",
|
||||
"value": "{{p.discount or ''}}",
|
||||
"placeholder": "0~1",
|
||||
"dec_len": 2,
|
||||
"fontSize": "12px"
|
||||
},
|
||||
"binds": [
|
||||
{
|
||||
"wid": "self",
|
||||
"event": "blur",
|
||||
"actiontype": "urlwidget",
|
||||
"target": "discount_rows",
|
||||
"options": {
|
||||
"url": "{{entire_url('./save_discount.dspy')}}",
|
||||
"params": {
|
||||
"discountid": "{{params_kw.discountid}}",
|
||||
"productid": "{{p.productid}}",
|
||||
"detail_id": "{{p.detail_id or ''}}",
|
||||
"discount": "{{p.discount or ''}}"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}{% if not loop.last %},{% endif %}
|
||||
{% endfor %}
|
||||
]
|
||||
}
|
||||
],
|
||||
"binds": [
|
||||
{
|
||||
"wid": "self",
|
||||
"event": "show",
|
||||
"actiontype": "script",
|
||||
"target": "self",
|
||||
"script": "var tid=setInterval(function(){var cell=bricks.getWidgetById('disc_cell_1',bricks.app.root);if(!cell)return;clearInterval(tid);for(var i=1;;i++){var c=bricks.getWidgetById('disc_cell_'+i,bricks.app.root);if(!c)break;(function(c){var el=c.dom_element;var pid=el.getAttribute('data-pid');var did=el.getAttribute('data-did')||'';var val=el.getAttribute('data-discount')||'';var uf=new bricks.UiFloat({value:val,dec_len:2,placeholder:'0~1',fontSize:'12px',width:'100%'});uf._lv=val;uf.dom_element.addEventListener('blur',function(){var nv=String(uf.getValue()||'');if(nv===uf._lv)return;uf._lv=nv;fetch('{{entire_url(\"./save_discount.dspy\")}}',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({discountid:'{{params_kw.discountid}}',productid:pid,detail_id:did,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)})});c.add_widget(uf)})(c)}},300);"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user