{% set env = request._run_ns %} {% set scope, orgid = _resolve_view(request) %} {% set today_data = j2_distributor_financial(request, 'today') %} {% set month_data = j2_distributor_financial(request, 'month') %} {% set year_data = j2_distributor_financial(request, 'year') %} {% set all_data = j2_distributor_financial(request, 'all') %} {% macro fmt(val) %}{{'¥' + ('%.2f' % val)}}{% endmacro %} { "widgettype": "VBox", "options": {"width": "100%"}, "subwidgets": [ {"widgettype": "HBox", "options": {"width": "100%", "gap": "12px", "marginBottom": "12px"}, "subwidgets": [ {"widgettype": "VBox", "options": {"css": "card", "padding": "12px", "borderRadius": "6px", "width": "25%"}, "subwidgets": [ {"widgettype": "Text", "options": {"text": "今天", "fontWeight": "600", "fontSize": "12px", "color": "var(--sage-text-primary)"}}, {"widgettype": "Text", "options": {"text": "收入: " + {{json.dumps(fmt(today_data.total_revenue_cny))}}, "fontSize": "11px", "marginTop": "4px"}}, {"widgettype": "Text", "options": {"text": "成本: " + {{json.dumps(fmt(today_data.total_cost_cny))}}, "fontSize": "11px"}}, {"widgettype": "Text", "options": {"text": "毛利: " + {{json.dumps(fmt(today_data.gross_profit_cny))}}, "fontSize": "11px", "color": {{json.dumps('#10b981' if today_data.gross_profit_cny >= 0 else '#ef4444')}}}} ] }, {"widgettype": "VBox", "options": {"css": "card", "padding": "12px", "borderRadius": "6px", "width": "25%"}, "subwidgets": [ {"widgettype": "Text", "options": {"text": "本月", "fontWeight": "600", "fontSize": "12px", "color": "var(--sage-text-primary)"}}, {"widgettype": "Text", "options": {"text": "收入: " + {{json.dumps(fmt(month_data.total_revenue_cny))}}, "fontSize": "11px", "marginTop": "4px"}}, {"widgettype": "Text", "options": {"text": "成本: " + {{json.dumps(fmt(month_data.total_cost_cny))}}, "fontSize": "11px"}}, {"widgettype": "Text", "options": {"text": "毛利: " + {{json.dumps(fmt(month_data.gross_profit_cny))}}, "fontSize": "11px", "color": {{json.dumps('#10b981' if month_data.gross_profit_cny >= 0 else '#ef4444')}}}} ] }, {"widgettype": "VBox", "options": {"css": "card", "padding": "12px", "borderRadius": "6px", "width": "25%"}, "subwidgets": [ {"widgettype": "Text", "options": {"text": "本年", "fontWeight": "600", "fontSize": "12px", "color": "var(--sage-text-primary)"}}, {"widgettype": "Text", "options": {"text": "收入: " + {{json.dumps(fmt(year_data.total_revenue_cny))}}, "fontSize": "11px", "marginTop": "4px"}}, {"widgettype": "Text", "options": {"text": "成本: " + {{json.dumps(fmt(year_data.total_cost_cny))}}, "fontSize": "11px"}}, {"widgettype": "Text", "options": {"text": "毛利: " + {{json.dumps(fmt(year_data.gross_profit_cny))}}, "fontSize": "11px", "color": {{json.dumps('#10b981' if year_data.gross_profit_cny >= 0 else '#ef4444')}}}} ] }, {"widgettype": "VBox", "options": {"css": "card", "padding": "12px", "borderRadius": "6px", "width": "25%"}, "subwidgets": [ {"widgettype": "Text", "options": {"text": "累计", "fontWeight": "600", "fontSize": "12px", "color": "var(--sage-text-primary)"}}, {"widgettype": "Text", "options": {"text": "收入: " + {{json.dumps(fmt(all_data.total_revenue_cny))}}, "fontSize": "11px", "marginTop": "4px"}}, {"widgettype": "Text", "options": {"text": "成本: " + {{json.dumps(fmt(all_data.total_cost_cny))}}, "fontSize": "11px"}}, {"widgettype": "Text", "options": {"text": "毛利: " + {{json.dumps(fmt(all_data.gross_profit_cny))}}, "fontSize": "11px", "color": {{json.dumps('#10b981' if all_data.gross_profit_cny >= 0 else '#ef4444')}}}} ] } ] }, {"widgettype": "RefreshWidget", "options": { "period_seconds": 60, "url": "/sage_datamart/sect_distributor_currency.ui", "width": "100%" }} ] }