From 4c7a47d71fef3905c942f723116155c08b6ba9f1 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 29 Jun 2026 11:09:28 +0800 Subject: [PATCH] bugfix --- wwwroot/discount_setting/index.ui | 142 ++++++++++++++---------------- 1 file changed, 65 insertions(+), 77 deletions(-) diff --git a/wwwroot/discount_setting/index.ui b/wwwroot/discount_setting/index.ui index 3429b31..5ed59d2 100644 --- a/wwwroot/discount_setting/index.ui +++ b/wwwroot/discount_setting/index.ui @@ -1,79 +1,67 @@ { - "widgettype": "VBox", - "options": {"height": "100%", "width": "100%"}, - "subwidgets": [ - { - "id": "product_discount_tbl", - "widgettype": "Tabular", - "options": { - "width": "100%", - "height": "100%", - "title": "产品折扣设置", - "description": "选中产品后点击工具栏按钮设置折扣", - "css": "card", - "toolbar": { - "tools": [ - { - "name": "set_discount", - "label": "设置折扣", - "selected_row": true, - "icon": "{{entire_url('/bricks/imgs/edit.svg')}}" - } - ] - }, - "data_url": "{{entire_url('./get_products_with_discount.dspy')}}", - "data_method": "GET", - "row_options": { - "idField": "productid", - "checkField": "checked", - "fields": [ - { - "name": "category_name", - "title": "产品分类", - "type": "str", - "cwidth": 2 - }, - { - "name": "product_name", - "title": "产品名称", - "type": "str", - "cwidth": 4 - }, - { - "name": "product_code", - "title": "产品编码", - "type": "str", - "cwidth": 3 - }, - { - "name": "discount", - "title": "当前折扣", - "type": "float", - "cwidth": 2 - } - ] - }, - "page_rows": 100, - "cache_limit": 5 - }, - "binds": [ - { - "wid": "set_discount", - "event": "click", - "actiontype": "script", - "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({}); });" - } - ] - } - ], - "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}); }" - } - ] + "id": "product_discount_tbl", + "widgettype": "Tabular", + "options": { + "width": "100%", + "height": "100%", + "title": "产品折扣设置", + "description": "选中产品后点击工具栏按钮设置折扣", + "css": "card", + "toolbar": { + "tools": [ + { + "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_method": "GET", + "row_options": { + "idField": "productid", + "checkField": "checked", + "fields": [ + { + "name": "category_name", + "title": "产品分类", + "type": "str", + "cwidth": 2 + }, + { + "name": "product_name", + "title": "产品名称", + "type": "str", + "cwidth": 4 + }, + { + "name": "product_code", + "title": "产品编码", + "type": "str", + "cwidth": 3 + }, + { + "name": "discount", + "title": "当前折扣", + "type": "float", + "cwidth": 2 + } + ] + }, + "page_rows": 100, + "cache_limit": 5 + }, + "binds": [ + { + "wid": "set_discount", + "event": "click", + "actiontype": "script", + "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({}); });" + } + ] }