84 lines
3.4 KiB
XML
84 lines
3.4 KiB
XML
{% set products = get_discount_setting_products(request) %}
|
|
{
|
|
"widgettype": "VBox",
|
|
"options": {
|
|
"width": "100%",
|
|
"height": "100%",
|
|
"css": "filler"
|
|
},
|
|
"subwidgets": [
|
|
{
|
|
"widgettype": "Text",
|
|
"options": {
|
|
"text": "产品折扣设置",
|
|
"fontSize": "16px",
|
|
"fontWeight": "600",
|
|
"color": "#F1F5F9",
|
|
"padding": "8px 12px"
|
|
}
|
|
},
|
|
{
|
|
"widgettype": "HBox",
|
|
"options": {
|
|
"bgcolor": "#0F172A",
|
|
"padding": "8px 0",
|
|
"borderRadius": "6px 6px 0 0",
|
|
"alignItems": "center",
|
|
"width": "100%"
|
|
},
|
|
"subwidgets": [
|
|
{"widgettype": "Text", "options": {"text": "产品分类", "width": "22%", "padding": "0 12px", "fontSize": "12px", "fontWeight": "600", "color": "#94A3B8"}},
|
|
{"widgettype": "Text", "options": {"text": "产品名称", "width": "34%", "padding": "0 12px", "fontSize": "12px", "fontWeight": "600", "color": "#94A3B8"}},
|
|
{"widgettype": "Text", "options": {"text": "产品编码", "width": "22%", "padding": "0 12px", "fontSize": "12px", "fontWeight": "600", "color": "#94A3B8"}},
|
|
{"widgettype": "Text", "options": {"text": "折扣", "width": "22%", "padding": "0 12px", "fontSize": "12px", "fontWeight": "600", "color": "#94A3B8"}}
|
|
]
|
|
},
|
|
{
|
|
"widgettype": "VBox",
|
|
"id": "discount_rows",
|
|
"options": {
|
|
"width": "100%"
|
|
},
|
|
"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": "VBox",
|
|
"id": "disc_cell_{{loop.index}}",
|
|
"options": {
|
|
"width": "22%",
|
|
"padding": "0 12px",
|
|
"data-pid": "{{p.productid}}",
|
|
"data-did": "{{p.detail_id or ''}}",
|
|
"data-discount": "{{p.discount or ''}}"
|
|
}
|
|
}
|
|
]
|
|
}{% if not loop.last %},{% endif %}
|
|
{% endfor %}
|
|
]
|
|
}
|
|
],
|
|
"binds": [
|
|
{
|
|
"wid": "self",
|
|
"event": "show",
|
|
"actiontype": "script",
|
|
"target": "self",
|
|
"script": "setTimeout(function(){for(var i=1;;i++){var cell=bricks.getWidgetById('disc_cell_'+i,bricks.app.root);if(!cell)break;(function(c,idx){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)})(cell,i)}},300)"
|
|
}
|
|
]
|
|
}
|