89 lines
3.2 KiB
XML
89 lines
3.2 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 12px",
|
|
"borderRadius": "6px 6px 0 0",
|
|
"alignItems": "center"
|
|
},
|
|
"subwidgets": [
|
|
{"widgettype": "Text", "options": {"text": "产品分类", "cwidth": 3, "fontSize": "12px", "fontWeight": "600", "color": "#94A3B8"}},
|
|
{"widgettype": "Text", "options": {"text": "产品名称", "cwidth": 5, "fontSize": "12px", "fontWeight": "600", "color": "#94A3B8"}},
|
|
{"widgettype": "Text", "options": {"text": "产品编码", "cwidth": 3, "fontSize": "12px", "fontWeight": "600", "color": "#94A3B8"}},
|
|
{"widgettype": "Text", "options": {"text": "折扣(可编辑)", "cwidth": 3, "fontSize": "12px", "fontWeight": "600", "color": "#94A3B8"}}
|
|
]
|
|
},
|
|
{
|
|
"widgettype": "VBox",
|
|
"id": "discount_rows",
|
|
"options": {
|
|
"width": "100%",
|
|
"css": "childrensize"
|
|
},
|
|
"subwidgets": [
|
|
{% for p in products %}
|
|
{
|
|
"widgettype": "HBox",
|
|
"options": {
|
|
"padding": "6px 12px",
|
|
"border": "0 0 1px 0",
|
|
"borderColor": "#334155",
|
|
"alignItems": "center",
|
|
"width": "100%"
|
|
},
|
|
"subwidgets": [
|
|
{"widgettype": "Text", "options": {"text": "{{p.category_name or ''}}", "cwidth": 3, "fontSize": "12px", "color": "#E2E8F0"}},
|
|
{"widgettype": "Text", "options": {"text": "{{p.product_name or ''}}", "cwidth": 5, "fontSize": "12px", "color": "#F1F5F9"}},
|
|
{"widgettype": "Text", "options": {"text": "{{p.product_code or ''}}", "cwidth": 3, "fontSize": "12px", "color": "#E2E8F0"}},
|
|
{
|
|
"widgettype": "Form",
|
|
"id": "discount_form_{{loop.index}}",
|
|
"options": {
|
|
"cwidth": 3,
|
|
"show_label": false,
|
|
"css": "childrensize",
|
|
"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}
|
|
]
|
|
},
|
|
"binds": [
|
|
{
|
|
"wid": "self",
|
|
"event": "changed",
|
|
"actiontype": "script",
|
|
"target": "self",
|
|
"script": "var form = this.target; var d = form.getValue(); var old = form._last_val; if (d.discount === old) return; form._last_val = d.discount; fetch(form.options.submit_url, {method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify(d)}).then(function(r){ return r.json(); }).then(function(resp){ if (resp.widgettype === 'Error') bricks.show_error(resp.options); else console.log('discount saved'); }).catch(function(e){ console.error(e); });"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}{% if not loop.last %},{% endif %}
|
|
{% endfor %}
|
|
]
|
|
}
|
|
]
|
|
}
|