diff --git a/wwwroot/agreement_discount_setting.ui b/wwwroot/agreement_discount_setting.ui index 3d36d6f..b951367 100644 --- a/wwwroot/agreement_discount_setting.ui +++ b/wwwroot/agreement_discount_setting.ui @@ -26,6 +26,7 @@ {% for p in items %} { "widgettype": "HBox", + "id": "da_row_{{p.productid}}", "options": {"padding": "6px 0", "border": "0 0 1px 0", "borderColor": "#334155", "alignItems": "center", "width": "100%"}, "subwidgets": [ {"widgettype": "Text", "options": {"text": {{json.dumps(p.category_name or '')}}, "width": "22%", "padding": "0 8px", "fontSize": "12px", "color": "#E2E8F0"}}, @@ -45,7 +46,7 @@ ] }, {"widgettype": "Text", "options": {"text": {{json.dumps(p.sale_price or '')}}, "width": "14%", "padding": "0 8px", "fontSize": "12px", "color": "#E2E8F0"}}, - {"widgettype": "Text", "options": {"text": {% if p.item_id %}"✓已设置"{% else %}"-未设置"{% endif %}, "width": "20%", "padding": "0 8px", "fontSize": "11px", "color": {% if p.item_id %}"#34D399"{% else %}"#64748B"{% endif %}}} + {"widgettype": "Text", "id": "da_status_{{p.productid}}", "options": {"text": {% if p.item_id %}"✓已设置"{% else %}"-未设置"{% endif %}, "width": "20%", "padding": "0 8px", "fontSize": "11px", "color": {% if p.item_id %}"#34D399"{% else %}"#64748B"{% endif %}}} ] }{% if not loop.last %},{% endif %} {% endfor %} diff --git a/wwwroot/api/save_agreement_discount.dspy b/wwwroot/api/save_agreement_discount.dspy index 10e6e18..76928f0 100644 --- a/wwwroot/api/save_agreement_discount.dspy +++ b/wwwroot/api/save_agreement_discount.dspy @@ -27,10 +27,10 @@ async with DBPools().sqlorContext(dbname) as sor: }) elif float(new_discount) > 0 and new_discount != old_discount: # New item — create - new_id = getID() + item_id = getID() now = timestampstr() await sor.C('distribution_agreement_items', { - 'id': new_id, 'agreement_id': agreement_id, 'resellerid': userorgid, + 'id': item_id, 'agreement_id': agreement_id, 'resellerid': userorgid, 'productid': productid, 'prodtypeid': prodtypeid, 'discount': new_discount, 'created_at': now, }) @@ -50,7 +50,7 @@ async with DBPools().sqlorContext(dbname) as sor: await s3.C('product_org_auth', { 'id': getID(), 'product_id': productid, 'org_id': ag[0].sub_reseller_id, - 'auth_source': 'distribution_agreement', 'auth_source_id': new_id, + 'auth_source': 'distribution_agreement', 'auth_source_id': item_id, }) -return {'status': 'ok'} +return {'status': 'ok', 'item_id': item_id or '', 'discount': new_discount, 'productid': productid} diff --git a/wwwroot/api/save_contract_discount.dspy b/wwwroot/api/save_contract_discount.dspy index e9260b1..f42adf3 100644 --- a/wwwroot/api/save_contract_discount.dspy +++ b/wwwroot/api/save_contract_discount.dspy @@ -27,4 +27,4 @@ async with DBPools().sqlorContext(dbname) as sor: 'discount': new_discount, 'created_at': now, }) -return {'status': 'ok'} +return {'status': 'ok', 'item_id': item_id or '', 'discount': new_discount, 'productid': productid} diff --git a/wwwroot/contract_discount_setting.ui b/wwwroot/contract_discount_setting.ui index 904832b..01737b3 100644 --- a/wwwroot/contract_discount_setting.ui +++ b/wwwroot/contract_discount_setting.ui @@ -26,6 +26,7 @@ {% for p in items %} { "widgettype": "HBox", + "id": "sc_row_{{p.productid}}", "options": {"padding": "6px 0", "border": "0 0 1px 0", "borderColor": "#334155", "alignItems": "center", "width": "100%"}, "subwidgets": [ {"widgettype": "Text", "options": {"text": {{json.dumps(p.category_name or '')}}, "width": "22%", "padding": "0 8px", "fontSize": "12px", "color": "#E2E8F0"}}, @@ -45,7 +46,7 @@ ] }, {"widgettype": "Text", "options": {"text": {{json.dumps(p.sale_price or '')}}, "width": "14%", "padding": "0 8px", "fontSize": "12px", "color": "#E2E8F0"}}, - {"widgettype": "Text", "options": {"text": {% if p.item_id %}"✓已设置"{% else %}"-未设置"{% endif %}, "width": "20%", "padding": "0 8px", "fontSize": "11px", "color": {% if p.item_id %}"#34D399"{% else %}"#64748B"{% endif %}}} + {"widgettype": "Text", "id": "sc_status_{{p.productid}}", "options": {"text": {% if p.item_id %}"✓已设置"{% else %}"-未设置"{% endif %}, "width": "20%", "padding": "0 8px", "fontSize": "11px", "color": {% if p.item_id %}"#34D399"{% else %}"#64748B"{% endif %}}} ] }{% if not loop.last %},{% endif %} {% endfor %}