This commit is contained in:
yumoqing 2026-06-29 11:09:28 +08:00
parent e9a0cf6650
commit 4c7a47d71f

View File

@ -1,79 +1,67 @@
{ {
"widgettype": "VBox", "id": "product_discount_tbl",
"options": {"height": "100%", "width": "100%"}, "widgettype": "Tabular",
"subwidgets": [ "options": {
{ "width": "100%",
"id": "product_discount_tbl", "height": "100%",
"widgettype": "Tabular", "title": "产品折扣设置",
"options": { "description": "选中产品后点击工具栏按钮设置折扣",
"width": "100%", "css": "card",
"height": "100%", "toolbar": {
"title": "产品折扣设置", "tools": [
"description": "选中产品后点击工具栏按钮设置折扣", {
"css": "card", "name": "set_discount",
"toolbar": { "label": "设置折扣",
"tools": [ "selected_row": true,
{ "icon": "{{entire_url('/bricks/imgs/edit.svg')}}"
"name": "set_discount", }
"label": "设置折扣", ]
"selected_row": true, },
"icon": "{{entire_url('/bricks/imgs/edit.svg')}}" "data_url": "{{entire_url('./get_products_with_discount.dspy')}}",
} "params": {
] "discountid": "{{params_kw.discountid}}"
}, },
"data_url": "{{entire_url('./get_products_with_discount.dspy')}}", "data_method": "GET",
"data_method": "GET", "row_options": {
"row_options": { "idField": "productid",
"idField": "productid", "checkField": "checked",
"checkField": "checked", "fields": [
"fields": [ {
{ "name": "category_name",
"name": "category_name", "title": "产品分类",
"title": "产品分类", "type": "str",
"type": "str", "cwidth": 2
"cwidth": 2 },
}, {
{ "name": "product_name",
"name": "product_name", "title": "产品名称",
"title": "产品名称", "type": "str",
"type": "str", "cwidth": 4
"cwidth": 4 },
}, {
{ "name": "product_code",
"name": "product_code", "title": "产品编码",
"title": "产品编码", "type": "str",
"type": "str", "cwidth": 3
"cwidth": 3 },
}, {
{ "name": "discount",
"name": "discount", "title": "当前折扣",
"title": "当前折扣", "type": "float",
"type": "float", "cwidth": 2
"cwidth": 2 }
} ]
] },
}, "page_rows": 100,
"page_rows": 100, "cache_limit": 5
"cache_limit": 5 },
}, "binds": [
"binds": [ {
{ "wid": "set_discount",
"wid": "set_discount", "event": "click",
"event": "click", "actiontype": "script",
"actiontype": "script", "target": "self",
"target": "self", "script": "var dv = bricks.getWidgetById('product_discount_tbl', bricks.app.root); if (!dv || !dv.select_row || !dv.select_row.user_data) { alert('请先选中一个产品'); return; } var row = dv.select_row.user_data; var discountid = new URLSearchParams(window.location.search).get('discountid') || ''; var mf = new bricks.ModalForm({title: '设置折扣 - ' + row.product_name, width: '400px', auto_open: true, fields: [{name: 'discountid', uitype: 'hide', value: discountid}, {name: 'productid', uitype: 'hide', value: row.productid}, {name: 'category_id', uitype: 'hide', value: row.category_id}, {name: 'detail_id', uitype: 'hide', value: row.detail_id || ''}, {name: 'product_name', label: '产品', uitype: 'text', value: row.product_name}, {name: 'category_name', label: '分类', uitype: 'text', value: row.category_name}, {name: 'discount', label: '折扣(0-1)', uitype: 'float', value: row.discount || '', tip: '0到1之间如0.8表示8折留空或0表示清除折扣'}], submit_url: '{{entire_url('./save_discount.dspy')}}'}); mf.bind('submited', async function(params) { await bricks.show_resp_message_or_error(params); await dv.render({}); });"
"script": "var dv = bricks.getWidgetById('product_discount_tbl', bricks.app.root); if (!dv || !dv.select_row || !dv.select_row.user_data) { alert('请先选中一个产品'); return; } var row = dv.select_row.user_data; var discountid = new URLSearchParams(window.location.search).get('discountid') || ''; var mf = new bricks.ModalForm({title: '设置折扣 - ' + row.product_name, width: '400px', auto_open: true, fields: [{name: 'discountid', uitype: 'hide', value: discountid}, {name: 'productid', uitype: 'hide', value: row.productid}, {name: 'category_id', uitype: 'hide', value: row.category_id}, {name: 'detail_id', uitype: 'hide', value: row.detail_id || ''}, {name: 'product_name', label: '产品', uitype: 'text', value: row.product_name}, {name: 'category_name', label: '分类', uitype: 'text', value: row.category_name}, {name: 'discount', label: '折扣(0-1)', uitype: 'float', value: row.discount || '', tip: '0到1之间如0.8表示8折留空或0表示清除折扣'}], submit_url: '{{entire_url('./save_discount.dspy')}}'}); mf.bind('submited', async function(params) { await bricks.show_resp_message_or_error(params); await dv.render({}); });" }
} ]
]
}
],
"binds": [
{
"wid": "self",
"event": "init",
"actiontype": "script",
"target": "product_discount_tbl",
"script": "var discountid = new URLSearchParams(window.location.search).get('discountid') || ''; if (discountid) { await this.render({discountid: discountid}); }"
}
]
} }