@chenchaolong/plugin-trade-compliance-workbench 1.0.41 → 1.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../../../src/lib/remote-ui/pages/analytics.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAmD,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAC1G,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAsB,sBAAsB,EAAmC,oBAAoB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAErM,OAAO,2BAA2B,CAAA;AAElC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,aAAa,CAAA;IACnB,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,OAAO,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACxD,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACzE,CAAA;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,kBAAkB,GAAG,cAAc,CAI1G;AAeD,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,kBAAkB,2CAqE7G;AAgcD,wBAAgB,uBAAuB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,2CAiB3E;AAiID,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,SAAS,oBAAoB,EAAE,GAAG,kBAAkB,EAAE,CAYtG"}
1
+ {"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../../../src/lib/remote-ui/pages/analytics.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAiC,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACxF,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAsB,sBAAsB,EAAmC,oBAAoB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAErM,OAAO,2BAA2B,CAAA;AAElC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,aAAa,CAAA;IACnB,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,OAAO,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACxD,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACzE,CAAA;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,kBAAkB,GAAG,cAAc,CAI1G;AAED,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,kBAAkB,2CAgE7G;AA6WD,wBAAgB,uBAAuB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,2CAiB3E;AA8ID,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,SAAS,oBAAoB,EAAE,GAAG,kBAAkB,EAAE,CAYtG"}
@@ -1,25 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { Decimal } from 'decimal.js';
3
3
  import React from 'react';
4
- import { DataGrid, FilterPanel, RiskNotice } from '../components/data-grid.js';
4
+ import { DataGrid, RiskNotice } from '../components/data-grid.js';
5
5
  import './analytics-prototype.css';
6
6
  export function analyticsPageSizeQuery(query, pageSize) {
7
7
  return query.mode === 'PURCHASE'
8
8
  ? { ...query, page: 1, pageSize }
9
9
  : { ...query, page: 1, pageSize };
10
10
  }
11
- const purchaseFilters = [
12
- { type: 'date-range', key: 'orderDate', label: '下单日期' },
13
- { type: 'text', key: 'supplier', label: '供应商' },
14
- { type: 'text', key: 'productName', label: '商品名称' },
15
- { type: 'text', key: 'hsCode', label: '海关编码' }
16
- ];
17
- const salesFilters = [
18
- { type: 'date-range', key: 'orderDate', label: '下单日期' },
19
- { type: 'text', key: 'customer', label: '客户' },
20
- { type: 'text', key: 'productName', label: '商品名称' },
21
- { type: 'text', key: 'hsCode', label: '海关编码' }
22
- ];
23
11
  export function AnalyticsPage({ data, committedQuery, busy, error, onQuery, onExportXlsx }) {
24
12
  const fallbackQuery = React.useMemo(() => queryFromData(data), [data.mode, data.dimension, data.details.page, data.details.pageSize]);
25
13
  const committed = committedQuery ?? fallbackQuery;
@@ -28,23 +16,18 @@ export function AnalyticsPage({ data, committedQuery, busy, error, onQuery, onEx
28
16
  const [filters, setFilters] = React.useState(() => filterStateFromQuery(committed));
29
17
  const [activeDialog, setActiveDialog] = React.useState(null);
30
18
  const [drilldown, setDrilldown] = React.useState(null);
19
+ const [infoModal, setInfoModal] = React.useState(null);
31
20
  const [detailsOpen, setDetailsOpen] = React.useState(false);
32
21
  React.useEffect(() => {
33
22
  setMode(committed.mode);
34
23
  setDimension(committed.dimension);
35
24
  setFilters(filterStateFromQuery(committed));
36
25
  }, [committed]);
37
- const dimensions = mode === 'PURCHASE' ? [['SUPPLIER', '供应商'], ['PRODUCT', '商品名称']] : [['CUSTOMER', '客户'], ['PRODUCT', '商品名称']];
38
26
  const typedFilters = toAnalyticsFilters(filters);
39
27
  const queryFor = (nextMode, nextDimension, page, nextFilters) => nextMode === 'PURCHASE'
40
28
  ? { mode: nextMode, dimension: nextDimension === 'SUPPLIER' ? 'SUPPLIER' : 'PRODUCT', filters: purchaseAnalyticsFilters(nextFilters), page, pageSize: data.details.pageSize || 20 }
41
29
  : { mode: nextMode, dimension: nextDimension === 'CUSTOMER' ? 'CUSTOMER' : 'PRODUCT', filters: salesAnalyticsFilters(nextFilters), page, pageSize: data.details.pageSize || 20 };
42
30
  const runQuery = (page = 1, nextMode = mode, nextDimension = dimension) => onQuery(queryFor(nextMode, nextDimension, page, typedFilters));
43
- const switchMode = (nextMode) => {
44
- const nextDimension = nextMode === 'PURCHASE' ? 'SUPPLIER' : 'CUSTOMER';
45
- void onQuery(queryFor(nextMode, nextDimension, 1, {}));
46
- };
47
- const switchDimension = (nextDimension) => { void runQuery(1, mode, nextDimension); };
48
31
  const exportCurrent = (scope) => {
49
32
  if (!onExportXlsx)
50
33
  return;
@@ -52,7 +35,7 @@ export function AnalyticsPage({ data, committedQuery, busy, error, onQuery, onEx
52
35
  void onExportXlsx(request.mode === 'PURCHASE' ? { mode: request.mode, dimension: request.dimension, filters: request.filters, format: 'XLSX' } : { mode: request.mode, dimension: request.dimension, filters: request.filters, format: 'XLSX' });
53
36
  setActiveDialog(null);
54
37
  };
55
- return _jsxs("section", { className: "tcw-analytics-page", "aria-label": "\u6570\u636E\u5206\u6790", children: [_jsxs("div", { className: "tcw-analytics-cockpit-hero", children: [_jsxs("div", { children: [_jsx("h1", { children: "\u5916\u8D38\u5408\u89C4\u7ECF\u8425\u9A7E\u9A76\u8231" }), _jsx("p", { children: "\u7ECF\u8425\u8D44\u91D1\u3001\u5408\u540C\u5BA1\u6838\u3001\u5546\u54C1\u7BA1\u63A7\u3001\u5236\u88C1\u547D\u4E2D\u3001\u5229\u6DA6\u5F02\u5E38\u7EDF\u4E00\u76D1\u63A7" })] }), _jsxs("div", { className: "tcw-analytics-refresh-card", children: [_jsx("span", { children: "\u6700\u8FD1\u5237\u65B0" }), _jsxs("strong", { children: [data.currentYear, "-08-05 10:32"] })] })] }), _jsxs("div", { className: "tcw-analytics-query", children: [_jsx(FilterPanel, { definitions: mode === 'PURCHASE' ? purchaseFilters : salesFilters, values: filters, onChange: (key, value) => setFilters(current => ({ ...current, [key]: value })), onQuery: () => void runQuery(), onReset: () => { setFilters({}); void onQuery(queryFor(mode, dimension, 1, {})); } }), _jsxs("div", { className: "tcw-analytics-toolbar", children: [_jsxs("span", { className: "tcw-analytics-chip", children: [_jsx("i", { className: "ri-building-2-line", "aria-hidden": "true" }), "\u5F53\u524D\u7EC4\u7EC7"] }), _jsxs("span", { className: "tcw-analytics-chip", children: [_jsx("i", { className: "ri-calendar-event-line", "aria-hidden": "true" }), "\u7EDF\u8BA1\u5468\u671F\uFF1A", data.currentYear, " \u5E74\u5EA6"] }), _jsxs("span", { className: "tcw-analytics-chip", children: [_jsx("i", { className: "ri-money-cny-circle-line", "aria-hidden": "true" }), "\u5E01\u79CD\uFF1ACNY"] }), _jsxs("div", { className: "tcw-segmented-control", role: "group", "aria-label": "\u6570\u636E\u53E3\u5F84", children: [_jsxs("button", { type: "button", "aria-pressed": mode === 'PURCHASE', onClick: () => switchMode('PURCHASE'), children: [_jsx("i", { className: "ri-shopping-cart-2-line", "aria-hidden": "true" }), "\u91C7\u8D2D\u53E3\u5F84"] }), _jsxs("button", { type: "button", "aria-pressed": mode === 'SALES', onClick: () => switchMode('SALES'), children: [_jsx("i", { className: "ri-line-chart-line", "aria-hidden": "true" }), "\u9500\u552E\u53E3\u5F84"] })] }), _jsx("div", { className: "tcw-segmented-control", role: "group", "aria-label": "\u7EDF\u8BA1\u7EF4\u5EA6", children: dimensions.map(([value, label]) => _jsxs("button", { type: "button", "aria-pressed": dimension === value, onClick: () => switchDimension(value), children: [_jsx("i", { className: value === 'PRODUCT' ? 'ri-box-3-line' : value === 'SUPPLIER' ? 'ri-truck-line' : 'ri-user-3-line', "aria-hidden": "true" }), label] }, value)) }), _jsxs("div", { className: "tcw-analytics-switches", "aria-label": "\u98CE\u9669\u8FC7\u6EE4", children: [mode === 'PURCHASE' && _jsxs(_Fragment, { children: [_jsx(Toggle, { label: "\u672A\u4ED8\u6B3E", checked: 'unpaidOnly' in typedFilters && typedFilters.unpaidOnly === true, onChange: checked => setFilters(current => ({ ...current, unpaidOnly: checked ? 'true' : '' })) }), _jsx(Toggle, { label: "\u672A\u9000\u7A0E", checked: 'unrefundedOnly' in typedFilters && typedFilters.unrefundedOnly === true, onChange: checked => setFilters(current => ({ ...current, unrefundedOnly: checked ? 'true' : '' })) })] }), mode === 'SALES' && _jsx(Toggle, { label: "\u672A\u6536\u6B3E", checked: 'unreceivedOnly' in typedFilters && typedFilters.unreceivedOnly === true, onChange: checked => setFilters(current => ({ ...current, unreceivedOnly: checked ? 'true' : '' })) })] }), _jsxs("button", { type: "button", className: "tcw-button tcw-button--secondary", "aria-label": "\u7B5B\u9009\u6761\u4EF6\u5165\u53E3", onClick: () => setActiveDialog('filter'), children: [_jsx("i", { className: "ri-filter-3-line", "aria-hidden": "true" }), "\u7B5B\u9009\u6761\u4EF6"] }), _jsxs("button", { type: "button", className: "tcw-button tcw-button--secondary", onClick: () => setDetailsOpen(true), children: [_jsx("i", { className: "ri-table-line", "aria-hidden": "true" }), "\u5B8C\u6574\u660E\u7EC6"] }), onExportXlsx && _jsxs("button", { type: "button", className: "tcw-button tcw-button--secondary", "aria-label": "\u5BFC\u51FA\u6570\u636E", onClick: () => setActiveDialog('export'), children: [_jsx("i", { className: "ri-file-excel-2-line", "aria-hidden": "true" }), "\u5BFC\u51FA\u62A5\u8868"] }), _jsxs("button", { type: "button", className: "tcw-button tcw-button--primary", onClick: () => void runQuery(), children: [_jsx("i", { className: "ri-refresh-line", "aria-hidden": "true" }), "\u5237\u65B0"] })] })] }), _jsx(AnalyticsCockpit, { data: data, onDrilldown: setDrilldown }), error && _jsx(RiskNotice, { children: error }), busy && _jsxs("div", { className: "tcw-inline-loading", role: "status", children: [_jsx("span", { className: "tcw-spinner", "aria-hidden": "true" }), "\u6570\u636E\u52A0\u8F7D\u4E2D"] }), drilldown && _jsx(AnalyticsDrilldownPanel, { data: data, drilldown: drilldown, onClose: () => setDrilldown(null) }), detailsOpen && _jsx(AnalyticsDetailsModal, { mode: mode, dimension: dimension, data: data, onClose: () => setDetailsOpen(false), onPageChange: page => void runQuery(page), onPageSizeChange: pageSize => void onQuery(analyticsPageSizeQuery(queryFor(mode, dimension, 1, typedFilters), pageSize)) }), _jsx(AdvancedFilterModal, { active: activeDialog === 'filter', mode: mode, filters: filters, onFilterChange: (key, value) => setFilters(current => ({ ...current, [key]: value })), onApply: () => { void runQuery(); setActiveDialog(null); }, onReset: () => { setFilters({}); void onQuery(queryFor(mode, dimension, 1, {})); setActiveDialog(null); }, onClose: () => setActiveDialog(null) }), onExportXlsx && _jsx(BusinessExportModal, { active: activeDialog === 'export', total: data.details.total, onClose: () => setActiveDialog(null), onExport: exportCurrent })] });
38
+ return _jsxs("section", { className: "tcw-analytics-page", "aria-label": "\u6570\u636E\u5206\u6790", children: [_jsxs("div", { className: "tcw-analytics-cockpit-hero", children: [_jsxs("div", { children: [_jsxs("nav", { className: "tcw-analytics-cockpit-crumbs", "aria-label": "\u6570\u636E\u5206\u6790\u9762\u5305\u5C51", children: [_jsx("span", { children: "\u9996\u9875" }), _jsx("i", { className: "ri-arrow-right-s-line", "aria-hidden": "true" }), _jsx("strong", { children: "\u6570\u636E\u5206\u6790" })] }), _jsx("h1", { children: "\u5916\u8D38\u5408\u89C4\u7ECF\u8425\u9A7E\u9A76\u8231" }), _jsx("p", { children: "\u7ECF\u8425\u8D44\u91D1\u3001\u5408\u540C\u5BA1\u6838\u3001\u5546\u54C1\u7BA1\u63A7\u3001\u5236\u88C1\u547D\u4E2D\u3001\u5229\u6DA6\u5F02\u5E38\u7EDF\u4E00\u76D1\u63A7" })] }), _jsxs("div", { className: "tcw-analytics-page-actions", children: [onExportXlsx && _jsxs("button", { type: "button", className: "tcw-button tcw-button--secondary", "aria-label": "\u5BFC\u51FA\u6570\u636E", onClick: () => setActiveDialog('export'), children: [_jsx("i", { className: "ri-download-2-line", "aria-hidden": "true" }), "\u5BFC\u51FA\u62A5\u8868"] }), _jsxs("button", { type: "button", className: "tcw-button tcw-button--secondary", onClick: () => void runQuery(), children: [_jsx("i", { className: "ri-refresh-line", "aria-hidden": "true" }), "\u5237\u65B0"] })] })] }), _jsx("div", { className: "tcw-analytics-query", children: _jsxs("div", { className: "tcw-analytics-toolbar", children: [_jsxs("span", { className: "tcw-analytics-chip tcw-analytics-chip--org", children: [_jsx("i", { className: "ri-building-2-line", "aria-hidden": "true" }), "\u5F53\u524D\u7EC4\u7EC7\uFF1A\u534E\u5357\u5916\u8D38\u4E8B\u4E1A\u90E8"] }), _jsx("span", { className: "tcw-analytics-label", children: "\u7EDF\u8BA1\u5468\u671F\uFF1A" }), _jsxs("button", { type: "button", className: "tcw-analytics-chip", onClick: () => setFilters(current => ({ ...current, orderDate: quickRange(3) })), children: [_jsx("i", { className: "ri-calendar-event-line", "aria-hidden": "true" }), data.currentYear, " \u5E74\u5EA6"] }), _jsxs("div", { className: "tcw-segmented-control tcw-analytics-period", role: "group", "aria-label": "\u7EDF\u8BA1\u65F6\u95F4", children: [_jsxs("button", { type: "button", "aria-pressed": false, onClick: () => setFilters(current => ({ ...current, orderDate: quickRange(3) })), children: [_jsx("i", { className: "ri-calendar-check-line", "aria-hidden": "true" }), "\u672C\u6708"] }), _jsxs("button", { type: "button", "aria-pressed": false, onClick: () => setActiveDialog('filter'), children: [_jsx("i", { className: "ri-calendar-2-line", "aria-hidden": "true" }), "\u81EA\u5B9A\u4E49\u533A\u95F4"] })] }), _jsx("span", { className: "tcw-analytics-label", children: "\u5E01\u79CD\uFF1A" }), _jsxs("button", { type: "button", className: "tcw-analytics-chip", children: [_jsx("i", { className: "ri-money-cny-circle-line", "aria-hidden": "true" }), "CNY"] }), _jsxs("span", { className: "tcw-analytics-chip tcw-analytics-chip--refresh", children: [_jsx("i", { className: "ri-time-line", "aria-hidden": "true" }), "\u6700\u8FD1\u5237\u65B0\uFF1A", data.currentYear, "-08-05 10:32"] }), _jsxs("button", { type: "button", className: "tcw-button tcw-button--secondary", "aria-label": "\u7B5B\u9009\u6761\u4EF6\u5165\u53E3", onClick: () => setActiveDialog('filter'), children: [_jsx("i", { className: "ri-filter-3-line", "aria-hidden": "true" }), "\u7B5B\u9009\u6761\u4EF6"] }), _jsxs("button", { type: "button", className: "tcw-button tcw-button--secondary", onClick: () => setDetailsOpen(true), children: [_jsx("i", { className: "ri-table-line", "aria-hidden": "true" }), "\u5B8C\u6574\u660E\u7EC6"] })] }) }), _jsx(AnalyticsCockpit, { data: data, onDrilldown: setDrilldown, onInfo: setInfoModal }), error && _jsx(RiskNotice, { children: error }), busy && _jsxs("div", { className: "tcw-inline-loading", role: "status", children: [_jsx("span", { className: "tcw-spinner", "aria-hidden": "true" }), "\u6570\u636E\u52A0\u8F7D\u4E2D"] }), drilldown && _jsx(AnalyticsDrilldownPanel, { data: data, drilldown: drilldown, onClose: () => setDrilldown(null) }), detailsOpen && _jsx(AnalyticsDetailsModal, { mode: mode, dimension: dimension, data: data, onClose: () => setDetailsOpen(false), onPageChange: page => void runQuery(page), onPageSizeChange: pageSize => void onQuery(analyticsPageSizeQuery(queryFor(mode, dimension, 1, typedFilters), pageSize)) }), infoModal && _jsx(AnalyticsInfoModal, { info: infoModal, onClose: () => setInfoModal(null) }), _jsx(AdvancedFilterModal, { active: activeDialog === 'filter', filters: filters, onFilterChange: (key, value) => setFilters(current => ({ ...current, [key]: value })), onApply: () => { void runQuery(); setActiveDialog(null); }, onReset: () => { setFilters({}); void onQuery(queryFor(mode, dimension, 1, {})); setActiveDialog(null); }, onClose: () => setActiveDialog(null) }), onExportXlsx && _jsx(BusinessExportModal, { active: activeDialog === 'export', total: data.details.total, onClose: () => setActiveDialog(null), onExport: exportCurrent })] });
56
39
  }
57
40
  const analyticsExportFields = [
58
41
  { key: 'label', label: '客户/供应商名称' },
@@ -62,32 +45,33 @@ const analyticsExportFields = [
62
45
  { key: 'status', label: '审核状态' },
63
46
  { key: 'createdAt', label: '创建时间' }
64
47
  ];
65
- function AnalyticsCockpit({ data, onDrilldown }) {
48
+ function AnalyticsCockpit({ data, onDrilldown, onInfo }) {
66
49
  const dashboard = data.dashboard;
67
- const customerValueRows = customerValueRowsFromData(data);
68
- const receivableRiskRows = receivableRiskRowsFromData(data);
69
- const supplierRiskRows = supplierRiskRowsFromData(data);
70
- const salesFileRows = salesFileRowsFromData(data);
71
- const riskOrderRows = riskOrderRowsFromData(data);
50
+ const customerValueRows = dashboard.customerValueTop5.map(item => ({ key: item.customerId, name: item.customerName, salesAmountCny: item.salesAmountCny, grossProfitRate: item.estimatedGrossProfitRate, unreceivedCny: item.unreceivedCny, riskStatus: item.riskStatus }));
51
+ const receivableRiskRows = dashboard.receivableRiskTop5.map(item => ({ key: item.customerId, name: item.customerName, unreceivedCny: item.unreceivedCny, orderCount: item.orderCount, latestOrderDate: item.latestOrderDate }));
52
+ const supplierRiskRows = dashboard.supplierRiskTop5.map(item => ({ key: item.supplierId, name: item.supplierName, unpaidCny: item.unpaidCny, sanctionHitCount: item.sanctionHitCount, productRiskHitCount: item.productRiskHitCount, purchaseOrderCount: item.purchaseOrderCount }));
53
+ const salesFileRows = dashboard.salesFileReviews.map(item => ({ key: item.fileId, fileName: item.fileName, fileType: item.fileType, orderNo: item.salesOrderNo, reason: item.reason, status: '待复核' }));
54
+ const riskOrderRows = dashboard.riskOrders.map(item => ({ key: item.orderKey, orderNo: item.orderNo, partyName: item.partyName, riskType: item.riskType, riskAmountCny: item.riskAmountCny, status: item.status }));
55
+ const monthlyDeltas = monthlyDeltaLabels(dashboard.monthlyTrend);
72
56
  const kpis = [
73
- { label: '采购总额', value: compactMoney(dashboard.kpis.purchaseTotalCny), subtext: `${data.currentYear} 年采购订单`, fullValue: `${money(dashboard.kpis.purchaseTotalCny)} CNY`, icon: 'ri-shopping-bag-3-line', tone: 'money' },
74
- { label: '销售总额', value: compactMoney(dashboard.kpis.salesTotalCny), subtext: `${data.currentYear} 年销售订单`, fullValue: `${money(dashboard.kpis.salesTotalCny)} CNY`, icon: 'ri-line-chart-line', tone: 'money' },
75
- { label: '已收款金额', value: compactMoney(dashboard.kpis.receivedCny), subtext: `回款率 ${amountRatio(dashboard.kpis.receivedCny, dashboard.kpis.salesTotalCny)}`, fullValue: `${money(dashboard.kpis.receivedCny)} CNY`, icon: 'ri-bank-card-line', tone: 'money' },
76
- { label: '未收款金额', value: compactMoney(dashboard.kpis.unreceivedCny), subtext: `销售占比 ${amountRatio(dashboard.kpis.unreceivedCny, dashboard.kpis.salesTotalCny)}`, fullValue: `${money(dashboard.kpis.unreceivedCny)} CNY`, icon: 'ri-alarm-warning-line', tone: 'risk' },
77
- { label: '已付款金额', value: compactMoney(dashboard.kpis.paidCny), subtext: `付款率 ${amountRatio(dashboard.kpis.paidCny, dashboard.kpis.purchaseTotalCny)}`, fullValue: `${money(dashboard.kpis.paidCny)} CNY`, icon: 'ri-secure-payment-line', tone: 'money' },
78
- { label: '未付款金额', value: compactMoney(dashboard.kpis.unpaidCny), subtext: `采购占比 ${amountRatio(dashboard.kpis.unpaidCny, dashboard.kpis.purchaseTotalCny)}`, fullValue: `${money(dashboard.kpis.unpaidCny)} CNY`, icon: 'ri-error-warning-line', tone: 'risk' },
79
- { label: '未退税金额', value: compactMoney(dashboard.kpis.unrefundedCny), subtext: `退税缺口 ${amountRatio(dashboard.kpis.unrefundedCny, addMoney(dashboard.kpis.refundedCny, dashboard.kpis.unrefundedCny))}`, fullValue: `${money(dashboard.kpis.unrefundedCny)} CNY`, icon: 'ri-refund-2-line', tone: 'audit' },
80
- { label: '预计毛利率', value: percent(dashboard.kpis.estimatedGrossProfitRate), subtext: `预计毛利 ${compactMoney(dashboard.kpis.estimatedGrossProfitCny)}`, icon: 'ri-funds-box-line', tone: 'money' },
81
- { label: '合规待办数', value: `${dashboard.kpis.complianceTodoCount} 项`, subtext: `队列 ${dashboard.todos.length} 类`, icon: 'ri-shield-check-line', tone: 'audit' },
82
- { label: '风险敞口金额', value: compactMoney(dashboard.kpis.riskExposureCny), subtext: `资金风险占比 ${amountRatio(dashboard.kpis.riskExposureCny, addMoney(dashboard.kpis.salesTotalCny, dashboard.kpis.purchaseTotalCny))}`, fullValue: `${money(dashboard.kpis.riskExposureCny)} CNY`, icon: 'ri-radar-line', tone: 'risk' }
57
+ { label: '采购总额', value: compactMoney(dashboard.kpis.purchaseTotalCny), subtext: monthlyDeltas.purchase, fullValue: `${money(dashboard.kpis.purchaseTotalCny)} CNY`, icon: 'ri-shopping-cart-line', tone: 'money' },
58
+ { label: '销售总额', value: compactMoney(dashboard.kpis.salesTotalCny), subtext: monthlyDeltas.sales, fullValue: `${money(dashboard.kpis.salesTotalCny)} CNY`, icon: 'ri-bar-chart-line', tone: 'money' },
59
+ { label: '已收款金额', value: compactMoney(dashboard.kpis.receivedCny), subtext: `回款率 ${amountRatio(dashboard.kpis.receivedCny, dashboard.kpis.salesTotalCny)}`, fullValue: `${money(dashboard.kpis.receivedCny)} CNY`, icon: 'ri-time-line', tone: 'success' },
60
+ { label: '未收款金额', value: compactMoney(dashboard.kpis.unreceivedCny), subtext: `销售占比 ${amountRatio(dashboard.kpis.unreceivedCny, dashboard.kpis.salesTotalCny)}`, fullValue: `${money(dashboard.kpis.unreceivedCny)} CNY`, icon: 'ri-alarm-warning-line', tone: 'warn' },
61
+ { label: '已付款金额', value: compactMoney(dashboard.kpis.paidCny), subtext: `付款率 ${amountRatio(dashboard.kpis.paidCny, dashboard.kpis.purchaseTotalCny)}`, fullValue: `${money(dashboard.kpis.paidCny)} CNY`, icon: 'ri-secure-payment-line', tone: 'success' },
62
+ { label: '未付款金额', value: compactMoney(dashboard.kpis.unpaidCny), subtext: `采购占比 ${amountRatio(dashboard.kpis.unpaidCny, dashboard.kpis.purchaseTotalCny)}`, fullValue: `${money(dashboard.kpis.unpaidCny)} CNY`, icon: 'ri-error-warning-line', tone: 'warn' },
63
+ { label: '未退税金额', value: compactMoney(dashboard.kpis.unrefundedCny), subtext: `退税缺口 ${amountRatio(dashboard.kpis.unrefundedCny, addMoney(dashboard.kpis.refundedCny, dashboard.kpis.unrefundedCny))}`, fullValue: `${money(dashboard.kpis.unrefundedCny)} CNY`, icon: 'ri-refund-2-line', tone: 'warn' },
64
+ { label: '预计毛利率', value: percent(dashboard.kpis.estimatedGrossProfitRate), subtext: `毛利 ${compactMoney(dashboard.kpis.estimatedGrossProfitCny)}`, icon: 'ri-funds-box-line', tone: 'success' },
65
+ { label: '合规待办数', value: `${dashboard.kpis.complianceTodoCount} 项`, subtext: `队列 ${dashboard.todos.length} 类`, icon: 'ri-shield-check-line', tone: 'warn' },
66
+ { label: '风险敞口金额', value: compactMoney(dashboard.kpis.riskExposureCny), subtext: `资金风险占比 ${amountRatio(dashboard.kpis.riskExposureCny, addMoney(dashboard.kpis.salesTotalCny, dashboard.kpis.purchaseTotalCny))}`, fullValue: `${money(dashboard.kpis.riskExposureCny)} CNY`, icon: 'ri-shield-flash-line', tone: 'risk' }
83
67
  ];
84
- return _jsxs("section", { className: "tcw-analytics-cockpit", "aria-label": "\u5916\u8D38\u5408\u89C4\u7ECF\u8425\u9A7E\u9A76\u8231", children: [_jsx("div", { className: "tcw-analytics-kpi-grid", children: kpis.map(item => _jsxs("button", { type: "button", className: `is-${item.tone}`, title: 'fullValue' in item ? item.fullValue : item.value, onClick: () => onDrilldown({ title: `${item.label}下钻明细`, tone: item.tone }), children: [_jsx("i", { className: item.icon, "aria-hidden": "true" }), _jsx("span", { children: item.label }), _jsx("strong", { children: item.value }), _jsx("small", { children: item.subtext })] }, item.label)) }), _jsxs("div", { className: "tcw-analytics-cockpit-layout", children: [_jsx(Panel, { title: "\u5408\u89C4\u5F85\u529E\u961F\u5217", icon: "ri-list-check-3", action: _jsx(PanelLink, { href: "#analytics-todos", label: "\u67E5\u770B\u5168\u90E8" }), children: _jsx("div", { className: "tcw-analytics-todo-list", children: dashboard.todos.length ? dashboard.todos.map(todo => _jsxs("article", { className: `is-${todo.priority}`, children: [_jsx("strong", { children: todo.label }), _jsx("span", { children: todo.description }), _jsxs("b", { children: [todo.count, " \u9879", todo.amountCny ? ` · ${money(todo.amountCny)} CNY` : ''] })] }, todo.key)) : _jsx(EmptyText, { text: "\u6682\u65E0\u5408\u89C4\u5F85\u529E" }) }) }), _jsxs(Panel, { title: "\u6708\u5EA6\u7ECF\u8425\u8D8B\u52BF", icon: "ri-bar-chart-box-line", className: "tcw-analytics-panel--wide", children: [_jsx(TrendLineChart, { points: dashboard.monthlyTrend }), _jsxs("div", { className: "tcw-analytics-chart-legend", children: [_jsxs("span", { children: [_jsx("i", { className: "is-purchase" }), "\u91C7\u8D2D\u989D"] }), _jsxs("span", { children: [_jsx("i", { className: "is-sales" }), "\u9500\u552E\u989D"] }), _jsxs("span", { children: [_jsx("i", { className: "is-profit" }), "\u9884\u8BA1\u6BDB\u5229 ", money(dashboard.kpis.estimatedGrossProfitCny), " CNY"] })] }), _jsxs("div", { className: "tcw-analytics-trend-summary", children: [_jsxs("span", { children: ["\u9500\u552E ", compactMoney(dashboard.kpis.salesTotalCny)] }), _jsxs("span", { children: ["\u91C7\u8D2D ", compactMoney(dashboard.kpis.purchaseTotalCny)] }), _jsxs("span", { children: ["\u6BDB\u5229\u7387 ", percent(dashboard.kpis.estimatedGrossProfitRate)] })] })] }), _jsx(Panel, { title: "\u8D44\u91D1\u98CE\u9669\u7ED3\u6784", icon: "ri-stack-line", children: _jsx(MoneyStructure, { kpis: dashboard.kpis }) }), _jsx(Panel, { title: "\u5408\u89C4\u98CE\u9669\u5206\u5E03", icon: "ri-donut-chart-line", children: _jsx(RiskDistribution, { items: dashboard.riskDistribution }) }), _jsx(Panel, { title: "\u5BA2\u6237\u4EF7\u503C TOP5", icon: "ri-vip-crown-line", children: _jsx(CustomerValue, { rows: customerValueRows }) }), _jsx(Panel, { title: "\u5E94\u6536\u98CE\u9669 TOP5", icon: "ri-bank-line", children: _jsx(ReceivableRisk, { rows: receivableRiskRows }) }), _jsx(Panel, { title: "\u4F9B\u5E94\u5546\u98CE\u9669 TOP5", icon: "ri-truck-line", children: _jsx(SupplierRisk, { rows: supplierRiskRows }) }), _jsx(Panel, { title: "\u9500\u552E\u6587\u4EF6\u590D\u6838", icon: "ri-file-search-line", action: _jsx(PanelLink, { href: "#analytics-review-files", label: "\u67E5\u770B\u5168\u90E8" }), children: _jsx(SalesFileReviews, { rows: salesFileRows }) }), _jsx(Panel, { title: "\u98CE\u9669\u8BA2\u5355\u660E\u7EC6", icon: "ri-file-warning-line", className: "tcw-analytics-panel--wide", action: _jsx(PanelLink, { href: "#analytics-risk-orders", label: "\u67E5\u770B\u5168\u90E8" }), children: _jsx(RiskOrders, { rows: riskOrderRows }) }), _jsx(Panel, { title: "\u6307\u6807\u6570\u636E\u6765\u6E90", icon: "ri-database-2-line", action: _jsx(PanelLink, { href: "#analytics-sources", label: "\u67E5\u770B\u8BE6\u60C5" }), children: _jsx("div", { className: "tcw-analytics-source-list", children: dashboard.dataSources.map(source => _jsxs("a", { href: "#analytics-sources", children: [_jsx("strong", { children: source.label }), _jsx("span", { children: source.description })] }, source.label)) }) })] })] });
68
+ return _jsxs("section", { className: "tcw-analytics-cockpit", "aria-label": "\u5916\u8D38\u5408\u89C4\u7ECF\u8425\u9A7E\u9A76\u8231", children: [_jsx("div", { className: "tcw-analytics-kpi-grid", children: kpis.map(item => _jsxs("button", { type: "button", className: `is-${item.tone}`, title: 'fullValue' in item ? item.fullValue : item.value, onClick: () => onDrilldown({ title: `${item.label}下钻明细`, tone: item.tone === 'success' || item.tone === 'warn' ? 'money' : item.tone }), children: [_jsx("span", { children: item.label }), _jsx("i", { className: item.icon, "aria-hidden": "true" }), _jsx("strong", { children: item.value }), _jsx("small", { children: item.subtext.startsWith('较上月') ? _jsxs(_Fragment, { children: [_jsx("em", { children: "\u8F83\u4E0A\u6708" }), _jsx("b", { children: item.subtext.replace('较上月 ', '') })] }) : item.subtext })] }, item.label)) }), _jsxs("div", { className: "tcw-analytics-cockpit-layout", children: [_jsx(Panel, { title: "\u5408\u89C4\u5F85\u529E\u961F\u5217", icon: "ri-list-check-3", className: "tcw-analytics-panel--queue", action: _jsx(PanelLink, { label: "\u67E5\u770B\u5168\u90E8", onClick: () => onInfo({ title: '合规待办明细', rows: dashboard.todos.map(todo => [todo.label, `${todo.count} · ${todo.description}`]) }) }), children: _jsx(TodoQueue, { rows: dashboard.todos }) }), _jsxs(Panel, { title: "\u6708\u5EA6\u7ECF\u8425\u8D8B\u52BF", icon: "ri-bar-chart-box-line", className: "tcw-analytics-panel--trend", children: [_jsx(TrendLineChart, { points: dashboard.monthlyTrend }), _jsxs("div", { className: "tcw-analytics-chart-legend", children: [_jsx("b", { children: "\u91D1\u989D\uFF08\u4E07\u5143\uFF09" }), _jsxs("span", { children: [_jsx("i", { className: "is-sales" }), "\u9500\u552E\u989D"] }), _jsxs("span", { children: [_jsx("i", { className: "is-purchase" }), "\u91C7\u8D2D\u989D"] }), _jsxs("span", { children: [_jsx("i", { className: "is-profit" }), "\u9884\u8BA1\u6BDB\u5229"] }), _jsxs("span", { children: [_jsx("i", { className: "is-received" }), "\u56DE\u6B3E\u91D1\u989D"] })] }), _jsxs("div", { className: "tcw-analytics-trend-summary", children: [_jsxs("span", { children: ["\u9500\u552E ", compactMoney(dashboard.kpis.salesTotalCny)] }), _jsxs("span", { children: ["\u91C7\u8D2D ", compactMoney(dashboard.kpis.purchaseTotalCny)] }), _jsxs("span", { children: ["\u6BDB\u5229\u7387 ", percent(dashboard.kpis.estimatedGrossProfitRate)] })] })] }), _jsx(Panel, { title: "\u8D44\u91D1\u98CE\u9669\u7ED3\u6784", icon: "ri-stack-line", className: "tcw-analytics-panel--capital", children: _jsx(MoneyStructure, { kpis: dashboard.kpis }) }), _jsx(Panel, { title: "\u5408\u89C4\u98CE\u9669\u5206\u5E03", icon: "ri-donut-chart-line", className: "tcw-analytics-panel--risk", children: _jsx(RiskDistribution, { items: dashboard.riskDistribution, onOpen: item => onInfo({ title: `${item.label}明细`, rows: [[item.label, `${item.count} 项${item.amountCny ? ` · ${money(item.amountCny)} CNY` : ''}`]] }) }) }), _jsx(Panel, { title: "\u5BA2\u6237\u4EF7\u503C TOP5", icon: "ri-vip-crown-line", children: _jsx(CustomerValue, { rows: customerValueRows }) }), _jsx(Panel, { title: "\u672A\u6536\u98CE\u9669 TOP5", icon: "ri-bank-line", children: _jsx(ReceivableRisk, { rows: receivableRiskRows }) }), _jsx(Panel, { title: "\u4F9B\u5E94\u5546\u98CE\u9669 TOP5", icon: "ri-truck-line", children: _jsx(SupplierRisk, { rows: supplierRiskRows }) }), _jsx(Panel, { title: "\u9500\u552E\u6587\u4EF6\u590D\u6838", icon: "ri-file-search-line", action: _jsx(PanelLink, { label: "\u67E5\u770B\u5168\u90E8", onClick: () => onInfo({ title: '销售文件复核明细', rows: salesFileRows.map(row => [row.fileName, `${row.fileType} · ${row.orderNo} · ${row.status}`]) }) }), children: _jsx(SalesFileReviews, { rows: salesFileRows }) }), _jsx(Panel, { title: "\u98CE\u9669\u8BA2\u5355\u660E\u7EC6", icon: "ri-file-warning-line", className: "tcw-analytics-panel--wide", action: _jsx(PanelLink, { label: "\u67E5\u770B\u5168\u90E8", onClick: () => onInfo({ title: '风险订单明细', rows: riskOrderRows.map(row => [row.orderNo, `${row.partyName} · ${row.riskType} · ${money(row.riskAmountCny)} CNY`]) }) }), children: _jsx(RiskOrders, { rows: riskOrderRows }) }), _jsx(Panel, { title: "\u6307\u6807\u6570\u636E\u6765\u6E90", icon: "ri-database-2-line", action: _jsx(PanelLink, { label: "\u67E5\u770B\u8BE6\u60C5", onClick: () => onInfo({ title: '指标数据来源', rows: dashboard.dataSources.map(source => [source.label, source.description]) }) }), children: _jsx("div", { className: "tcw-analytics-source-list", children: dashboard.dataSources.map(source => _jsxs("button", { type: "button", onClick: () => onInfo({ title: source.label, rows: [[source.label, source.description]] }), children: [_jsx("i", { className: "ri-links-line", "aria-hidden": "true" }), _jsx("strong", { children: source.label }), _jsx("span", { children: source.description })] }, source.label)) }) })] })] });
85
69
  }
86
70
  function Panel({ title, icon, className = '', action, children }) {
87
71
  return _jsxs("section", { className: `tcw-analytics-panel ${className}`.trim(), children: [_jsxs("header", { children: [_jsxs("strong", { children: [_jsx("i", { className: icon, "aria-hidden": "true" }), title] }), action] }), children] });
88
72
  }
89
- function PanelLink({ href, label }) {
90
- return _jsxs("a", { className: "tcw-analytics-panel-link", href: href, children: [label, _jsx("i", { className: "ri-arrow-right-s-line", "aria-hidden": "true" })] });
73
+ function PanelLink({ label, onClick }) {
74
+ return _jsxs("button", { type: "button", className: "tcw-analytics-panel-link", onClick: onClick, children: [label, _jsx("i", { className: "ri-arrow-right-s-line", "aria-hidden": "true" })] });
91
75
  }
92
76
  function MoneyStructure({ kpis }) {
93
77
  const items = [
@@ -99,15 +83,24 @@ function MoneyStructure({ kpis }) {
99
83
  const total = Math.max(...items.map(item => Number(item.value) || 0), 1);
100
84
  return _jsx("div", { className: "tcw-analytics-money-structure", children: items.map(item => _jsxs("div", { children: [_jsxs("span", { children: [_jsx("i", { style: { background: item.color } }), item.label] }), _jsxs("b", { children: [money(item.value), " CNY"] }), _jsx("em", { children: _jsx("i", { style: { width: `${Math.max(6, (Number(item.value) || 0) / total * 100)}%`, background: item.color } }) })] }, item.label)) });
101
85
  }
102
- function RiskDistribution({ items }) {
86
+ function RiskDistribution({ items, onOpen }) {
103
87
  const total = items.reduce((sum, item) => sum + item.count, 0);
104
- return _jsxs("div", { className: "tcw-analytics-risk-distribution", children: [_jsxs("div", { className: "tcw-analytics-donut", children: [_jsx("strong", { children: total }), _jsx("span", { children: "\u98CE\u9669\u9879" })] }), _jsx("dl", { children: items.map(item => _jsxs("div", { children: [_jsx("dt", { children: item.label }), _jsxs("dd", { children: [item.count, " \u9879", item.amountCny ? ` · ${money(item.amountCny)} CNY` : ''] })] }, item.key)) })] });
88
+ const colors = ['#1769ff', '#26b6c8', '#ff9f1c', '#8b5cf6', '#5ac85a', '#ff4d55'];
89
+ const segments = items.length ? items.map((item, index) => ({ item, color: colors[index % colors.length] })) : [{ item: { key: 'empty', label: '暂无风险', count: 1, amountCny: '0' }, color: '#e7edf5' }];
90
+ let cursor = 0;
91
+ const conic = segments.map(({ item, color }) => {
92
+ const start = cursor;
93
+ cursor += ((total > 0 ? item.count / total : 1) * 100);
94
+ return `${color} ${start.toFixed(2)}% ${cursor.toFixed(2)}%`;
95
+ }).join(', ');
96
+ const style = { '--risk-donut': `conic-gradient(${conic})` };
97
+ return _jsxs("div", { className: "tcw-analytics-risk-distribution", children: [_jsxs("div", { className: "tcw-analytics-donut", style: style, children: [_jsx("strong", { children: "\u5408\u8BA1" }), _jsx("span", { children: total })] }), _jsx("dl", { children: items.map((item, index) => _jsxs("button", { type: "button", onClick: () => onOpen(item), children: [_jsxs("dt", { children: [_jsx("i", { className: "ri-checkbox-blank-circle-fill", style: { color: colors[index % colors.length] }, "aria-hidden": "true" }), item.label] }), _jsxs("dd", { children: [item.count, " (", percentRatio(item.count, total), ")"] })] }, item.key)) })] });
105
98
  }
106
99
  function CustomerValue({ rows }) {
107
100
  return rows.length ? _jsxs("table", { className: "tcw-analytics-dashboard-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "\u5BA2\u6237/\u4F9B\u5E94\u5546" }), _jsx("th", { children: "\u9500\u552E\u989D\uFF08\u4EBA\u6C11\u5E01\uFF09" }), _jsx("th", { children: "\u6BDB\u5229\u7387" }), _jsx("th", { children: "\u98CE\u9669" })] }) }), _jsx("tbody", { children: rows.map(row => _jsxs("tr", { children: [_jsx("td", { title: row.name, children: row.name }), _jsx("td", { children: money(row.salesAmountCny) }), _jsx("td", { children: percent(row.grossProfitRate) }), _jsx("td", { children: _jsx(RiskBadge, { status: row.riskStatus }) })] }, row.key)) })] }) : _jsx(EmptyText, { text: "\u6682\u65E0\u5BA2\u6237\u4EF7\u503C\u6392\u540D" });
108
101
  }
109
102
  function ReceivableRisk({ rows }) {
110
- return rows.length ? _jsxs("table", { className: "tcw-analytics-dashboard-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "\u5BA2\u6237/\u4F9B\u5E94\u5546" }), _jsx("th", { children: "\u672A\u6536\u6B3E\u91D1\u989D\uFF08\u4EBA\u6C11\u5E01\uFF09" }), _jsx("th", { children: "\u8BA2\u5355\u6570" }), _jsx("th", { children: "\u6700\u8FD1\u8BA2\u5355" })] }) }), _jsx("tbody", { children: rows.map(row => _jsxs("tr", { children: [_jsx("td", { title: row.name, children: row.name }), _jsx("td", { children: money(row.unreceivedCny) }), _jsx("td", { children: row.orderCount }), _jsx("td", { children: shortDate(row.latestOrderDate) })] }, row.key)) })] }) : _jsx(EmptyText, { text: "\u6682\u65E0\u5E94\u6536\u98CE\u9669" });
103
+ return rows.length ? _jsxs("table", { className: "tcw-analytics-dashboard-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "\u5BA2\u6237" }), _jsx("th", { children: "\u672A\u6536\u6B3E\u91D1\u989D\uFF08\u4EBA\u6C11\u5E01\uFF09" }), _jsx("th", { children: "\u8BA2\u5355\u6570" }), _jsx("th", { children: "\u6700\u8FD1\u8BA2\u5355" })] }) }), _jsx("tbody", { children: rows.map(row => _jsxs("tr", { children: [_jsx("td", { title: row.name, children: row.name }), _jsx("td", { children: money(row.unreceivedCny) }), _jsx("td", { children: row.orderCount }), _jsx("td", { children: shortDate(row.latestOrderDate) })] }, row.key)) })] }) : _jsx(EmptyText, { text: "\u6682\u65E0\u672A\u6536\u98CE\u9669" });
111
104
  }
112
105
  function SupplierRisk({ rows }) {
113
106
  return rows.length ? _jsxs("table", { className: "tcw-analytics-dashboard-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "\u4F9B\u5E94\u5546" }), _jsx("th", { children: "\u672A\u4ED8\u6B3E\u91D1\u989D\uFF08\u4EBA\u6C11\u5E01\uFF09" }), _jsx("th", { children: "\u5546\u54C1\u547D\u4E2D" }), _jsx("th", { children: "\u5236\u88C1\u547D\u4E2D" })] }) }), _jsx("tbody", { children: rows.map(row => _jsxs("tr", { children: [_jsx("td", { title: row.name, children: row.name }), _jsx("td", { children: money(row.unpaidCny) }), _jsx("td", { children: row.productRiskHitCount }), _jsx("td", { children: row.sanctionHitCount })] }, row.key)) })] }) : _jsx(EmptyText, { text: "\u6682\u65E0\u4F9B\u5E94\u5546\u98CE\u9669" });
@@ -118,6 +111,9 @@ function SalesFileReviews({ rows }) {
118
111
  function RiskOrders({ rows }) {
119
112
  return rows.length ? _jsxs("table", { className: "tcw-analytics-dashboard-table tcw-analytics-risk-orders", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "\u8BA2\u5355\u53F7" }), _jsx("th", { children: "\u5BA2\u6237/\u4F9B\u5E94\u5546" }), _jsx("th", { children: "\u98CE\u9669\u7C7B\u578B" }), _jsx("th", { children: "\u8BA2\u5355\u91D1\u989D\uFF08\u4EBA\u6C11\u5E01\uFF09" }), _jsx("th", { children: "\u72B6\u6001" })] }) }), _jsx("tbody", { children: rows.map(row => _jsxs("tr", { children: [_jsx("td", { children: row.orderNo }), _jsx("td", { title: row.partyName, children: row.partyName }), _jsx("td", { children: _jsx("em", { children: row.riskType }) }), _jsx("td", { children: money(row.riskAmountCny) }), _jsx("td", { children: _jsx("span", { children: row.status }) })] }, row.key)) })] }) : _jsx(EmptyText, { text: "\u6682\u65E0\u98CE\u9669\u8BA2\u5355" });
120
113
  }
114
+ function TodoQueue({ rows }) {
115
+ return rows.length ? _jsxs("table", { className: "tcw-analytics-todo-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "\u5F85\u529E\u4E8B\u9879" }), _jsx("th", { children: "\u6570\u91CF" }), _jsx("th", { children: "\u4F18\u5148\u7EA7" })] }) }), _jsx("tbody", { children: rows.map(row => _jsxs("tr", { children: [_jsx("td", { title: row.description, children: row.label }), _jsx("td", { children: row.count }), _jsx("td", { children: _jsx(RiskBadge, { status: row.priority === 'high' ? 'HIGH' : row.priority === 'medium' ? 'MEDIUM' : 'LOW' }) })] }, row.key)) })] }) : _jsx(EmptyText, { text: "\u6682\u65E0\u5408\u89C4\u5F85\u529E" });
116
+ }
121
117
  function RiskBadge({ status }) {
122
118
  const label = status === 'HIGH' ? '高' : status === 'MEDIUM' ? '中' : status === 'LOW' ? '低' : status;
123
119
  return _jsx("span", { className: `tcw-analytics-risk-badge is-${status.toLocaleLowerCase()}`, children: label });
@@ -130,133 +126,35 @@ function TrendLineChart({ points }) {
130
126
  const y = 132 - ((Number(point[key]) || 0) / max) * 104;
131
127
  return `${x.toFixed(1)},${y.toFixed(1)}`;
132
128
  }).join(' ');
133
- return _jsx("div", { className: "tcw-analytics-line-chart", children: _jsxs("svg", { viewBox: "0 0 600 160", role: "img", "aria-label": "\u6708\u5EA6\u7ECF\u8425\u8D8B\u52BF\u6298\u7EBF\u56FE", children: [_jsx("g", { className: "tcw-analytics-line-grid", children: [28, 54, 80, 106, 132].map(y => _jsx("line", { x1: "24", x2: "576", y1: y, y2: y }, y)) }), _jsx("polyline", { className: "is-purchase", points: line('purchaseAmountCny') }), _jsx("polyline", { className: "is-sales", points: line('salesAmountCny') }), _jsx("polyline", { className: "is-profit", points: line('estimatedGrossProfitCny') }), months.map((point, index) => _jsx("text", { x: 24 + index * (552 / 11), y: "153", children: point.month }, point.month))] }) });
134
- }
135
- function customerValueRowsFromData(data) {
136
- if (data.dashboard.customerValueTop5.length)
137
- return data.dashboard.customerValueTop5.map(item => ({
138
- key: item.customerId,
139
- name: item.customerName,
140
- salesAmountCny: item.salesAmountCny,
141
- grossProfitRate: item.estimatedGrossProfitRate,
142
- unreceivedCny: item.unreceivedCny,
143
- riskStatus: item.riskStatus
144
- }));
145
- const source = data.top5.length ? data.top5.map(item => {
146
- const detail = findDetail(data, item.key, item.label);
147
- return detail ?? { key: item.key, label: item.label, orderCount: 0, amountCny: item.amountCny };
148
- }) : data.details.items;
149
- return source.slice(0, 5).map(row => ({
150
- key: row.key,
151
- name: row.label,
152
- salesAmountCny: row.amountCny,
153
- grossProfitRate: amountRatio(estimatedGrossProfit(row), row.amountCny, false),
154
- unreceivedCny: row.unreceivedCny ?? row.unpaidCny ?? '0',
155
- riskStatus: riskStatusForAmount(row.unreceivedCny ?? row.unpaidCny ?? row.unrefundedCny)
156
- }));
157
- }
158
- function receivableRiskRowsFromData(data) {
159
- if (data.dashboard.receivableRiskTop5.length)
160
- return data.dashboard.receivableRiskTop5.map(item => ({
161
- key: item.customerId,
162
- name: item.customerName,
163
- unreceivedCny: item.unreceivedCny,
164
- orderCount: item.orderCount,
165
- latestOrderDate: item.latestOrderDate
166
- }));
167
- return data.details.items
168
- .map(row => ({ key: row.key, name: row.label, unreceivedCny: row.unreceivedCny ?? row.unpaidCny ?? '0', orderCount: row.orderCount, latestOrderDate: null }))
169
- .filter(row => Number(row.unreceivedCny) > 0)
170
- .sort((a, b) => Number(b.unreceivedCny) - Number(a.unreceivedCny))
171
- .slice(0, 5);
172
- }
173
- function supplierRiskRowsFromData(data) {
174
- if (data.dashboard.supplierRiskTop5.length)
175
- return data.dashboard.supplierRiskTop5.map(item => ({
176
- key: item.supplierId,
177
- name: item.supplierName,
178
- unpaidCny: item.unpaidCny,
179
- sanctionHitCount: item.sanctionHitCount,
180
- productRiskHitCount: item.productRiskHitCount,
181
- purchaseOrderCount: item.purchaseOrderCount
182
- }));
183
- return data.details.items
184
- .map(row => ({
185
- key: row.key,
186
- name: row.label,
187
- unpaidCny: row.unpaidCny ?? row.unreceivedCny ?? '0',
188
- sanctionHitCount: 0,
189
- productRiskHitCount: Number(row.productQuantity) > 0 ? 1 : 0,
190
- purchaseOrderCount: row.orderCount
191
- }))
192
- .filter(row => Number(row.unpaidCny) > 0)
193
- .sort((a, b) => Number(b.unpaidCny) - Number(a.unpaidCny))
194
- .slice(0, 5);
195
- }
196
- function salesFileRowsFromData(data) {
197
- if (data.dashboard.salesFileReviews.length)
198
- return data.dashboard.salesFileReviews.map(item => ({
199
- key: item.fileId,
200
- fileName: item.fileName,
201
- fileType: item.fileType,
202
- orderNo: item.salesOrderNo,
203
- reason: item.reason,
204
- status: '待复核'
205
- }));
206
- return data.details.items
207
- .filter(row => hasRiskAmount(row))
208
- .slice(0, 5)
209
- .map(row => ({ key: `review-${row.key}`, fileName: `${row.label}合规资料`, fileType: '业务单据', orderNo: row.key, reason: riskLabelForRow(row), status: '待复核' }));
210
- }
211
- function riskOrderRowsFromData(data) {
212
- if (data.dashboard.riskOrders.length)
213
- return data.dashboard.riskOrders.map(item => ({
214
- key: item.orderKey,
215
- orderNo: item.orderNo,
216
- partyName: item.partyName,
217
- riskType: item.riskType,
218
- riskAmountCny: item.riskAmountCny,
219
- status: item.status
220
- }));
221
- return data.details.items
222
- .map(row => ({ key: `risk-${row.key}`, orderNo: row.key, partyName: row.label, riskType: riskLabelForRow(row), riskAmountCny: largestRiskAmount(row), status: '待复核' }))
223
- .filter(row => Number(row.riskAmountCny) > 0)
224
- .sort((a, b) => Number(b.riskAmountCny) - Number(a.riskAmountCny))
225
- .slice(0, 5);
226
- }
227
- function findDetail(data, key, label) {
228
- return data.details.items.find(row => row.key === key || row.label === label);
229
- }
230
- function estimatedGrossProfit(row) {
231
- if (row.receivedCny || row.paidCny)
232
- return new Decimal(row.receivedCny ?? row.amountCny).minus(row.paidCny ?? 0).toString();
233
- return '0';
234
- }
235
- function riskStatusForAmount(value) {
236
- const number = Number(value) || 0;
237
- if (number <= 0)
238
- return 'LOW';
239
- return number >= 100_000 ? 'HIGH' : 'MEDIUM';
240
- }
241
- function hasRiskAmount(row) {
242
- return Number(row.unreceivedCny ?? 0) > 0 || Number(row.unpaidCny ?? 0) > 0 || Number(row.unrefundedCny ?? 0) > 0;
243
- }
244
- function riskLabelForRow(row) {
245
- const risks = [
246
- Number(row.unreceivedCny ?? 0) > 0 ? '未收款' : '',
247
- Number(row.unpaidCny ?? 0) > 0 ? '未付款' : '',
248
- Number(row.unrefundedCny ?? 0) > 0 ? '未退税' : ''
249
- ].filter(Boolean);
250
- return risks.length ? risks.join('/') : '合规待复核';
251
- }
252
- function largestRiskAmount(row) {
253
- return String(Math.max(Number(row.unreceivedCny ?? 0), Number(row.unpaidCny ?? 0), Number(row.unrefundedCny ?? 0)));
129
+ return _jsx("div", { className: "tcw-analytics-line-chart", children: _jsxs("svg", { viewBox: "0 0 600 160", role: "img", "aria-label": "\u6708\u5EA6\u7ECF\u8425\u8D8B\u52BF\u6298\u7EBF\u56FE", children: [_jsx("g", { className: "tcw-analytics-line-grid", children: [28, 54, 80, 106, 132].map(y => _jsx("line", { x1: "24", x2: "576", y1: y, y2: y }, y)) }), _jsx("polyline", { className: "is-purchase", points: line('purchaseAmountCny') }), _jsx("polyline", { className: "is-sales", points: line('salesAmountCny') }), _jsx("polyline", { className: "is-profit", points: line('estimatedGrossProfitCny') }), _jsx("polyline", { className: "is-received", points: line('receivedCny') }), months.map((point, index) => _jsx("text", { x: 24 + index * (552 / 11), y: "153", children: point.month }, point.month))] }) });
130
+ }
131
+ function monthlyDeltaLabels(points) {
132
+ const sorted = [...points].sort((a, b) => a.month - b.month);
133
+ let latestIndex = -1;
134
+ for (let index = sorted.length - 1; index >= 0; index -= 1) {
135
+ const point = sorted[index];
136
+ if (Number(point.purchaseAmountCny) > 0 || Number(point.salesAmountCny) > 0 || Number(point.receivedCny) > 0) {
137
+ latestIndex = index;
138
+ break;
139
+ }
140
+ }
141
+ const latest = latestIndex >= 0 ? sorted[latestIndex] : undefined;
142
+ const previous = latestIndex > 0 ? sorted[latestIndex - 1] : undefined;
143
+ return {
144
+ purchase: `较上月 ${deltaLabel(latest?.purchaseAmountCny, previous?.purchaseAmountCny)}`,
145
+ sales: `较上月 ${deltaLabel(latest?.salesAmountCny, previous?.salesAmountCny)}`,
146
+ received: `较上月 ${deltaLabel(latest?.receivedCny, previous?.receivedCny)}`,
147
+ profit: `较上月 ${deltaLabel(latest?.estimatedGrossProfitCny, previous?.estimatedGrossProfitCny)}`
148
+ };
254
149
  }
255
150
  function EmptyText({ text }) {
256
151
  return _jsx("small", { className: "tcw-analytics-empty", children: text });
257
152
  }
258
- function AdvancedFilterModal({ active, mode, filters, onFilterChange, onApply, onReset, onClose }) {
259
- return _jsx("div", { className: "tcw-analytics-modal-deck", hidden: !active, "aria-hidden": !active, children: _jsx(AnalyticsModal, { title: "\u9AD8\u7EA7\u7B5B\u9009", active: active, onClose: onClose, footer: _jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "tcw-button tcw-button--secondary", onClick: onReset, children: [_jsx("i", { className: "ri-restart-line", "aria-hidden": "true" }), "\u91CD\u7F6E"] }), _jsxs("button", { type: "button", className: "tcw-button tcw-button--primary", onClick: onApply, children: [_jsx("i", { className: "ri-check-line", "aria-hidden": "true" }), "\u786E\u5B9A"] })] }), children: _jsxs("div", { className: "tcw-analytics-modal-grid", children: [_jsx("div", { className: "tcw-analytics-quick-range", "aria-label": "\u7EDF\u8BA1\u65F6\u95F4", children: ['今日', '近7天', '近30天', '本月'].map((label, index) => _jsxs("button", { type: "button", className: index === 2 ? 'is-active' : undefined, onClick: () => onFilterChange('orderDate', quickRange(index)), children: [_jsx("i", { className: "ri-calendar-line", "aria-hidden": "true" }), label] }, label)) }), _jsx(ModalRange, { label: "\u4E0B\u5355\u65E5\u671F", value: filters.orderDate, onChange: value => onFilterChange('orderDate', value) }), _jsx(ModalText, { label: mode === 'PURCHASE' ? '供应商' : '客户', value: String(filters[mode === 'PURCHASE' ? 'supplier' : 'customer'] ?? ''), onChange: value => onFilterChange(mode === 'PURCHASE' ? 'supplier' : 'customer', value) }), _jsx(ModalText, { label: "\u5546\u54C1\u540D\u79F0", value: String(filters.productName ?? ''), onChange: value => onFilterChange('productName', value) }), _jsx(ModalText, { label: "\u6D77\u5173\u7F16\u7801", value: String(filters.hsCode ?? ''), onChange: value => onFilterChange('hsCode', value) }), ['国家/地区', '产品类别', '风险等级', '审核状态', '金额范围'].map(label => _jsxs("label", { className: "tcw-form-field", children: [_jsx("span", { children: label }), _jsx("input", { disabled: true, placeholder: "\u540E\u7AEF\u7B5B\u9009\u5B57\u6BB5\u5F85\u63A5\u5165" })] }, label))] }) }) });
153
+ function AdvancedFilterModal({ active, filters, onFilterChange, onApply, onReset, onClose }) {
154
+ return _jsx("div", { className: "tcw-analytics-modal-deck", hidden: !active, "aria-hidden": !active, children: _jsx(AnalyticsModal, { title: "\u9AD8\u7EA7\u7B5B\u9009", active: active, onClose: onClose, footer: _jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "tcw-button tcw-button--secondary", onClick: onReset, children: [_jsx("i", { className: "ri-restart-line", "aria-hidden": "true" }), "\u91CD\u7F6E"] }), _jsxs("button", { type: "button", className: "tcw-button tcw-button--primary", onClick: onApply, children: [_jsx("i", { className: "ri-check-line", "aria-hidden": "true" }), "\u786E\u5B9A"] })] }), children: _jsxs("div", { className: "tcw-analytics-modal-grid", children: [_jsx("div", { className: "tcw-analytics-quick-range", "aria-label": "\u7EDF\u8BA1\u65F6\u95F4", children: ['今日', '近7天', '近30天', '本月'].map((label, index) => _jsxs("button", { type: "button", className: index === 2 ? 'is-active' : undefined, onClick: () => onFilterChange('orderDate', quickRange(index)), children: [_jsx("i", { className: "ri-calendar-line", "aria-hidden": "true" }), label] }, label)) }), _jsx(ModalRange, { label: "\u4E0B\u5355\u65E5\u671F", value: filters.orderDate, onChange: value => onFilterChange('orderDate', value) }), _jsx(ModalText, { label: "\u5546\u54C1\u540D\u79F0", value: String(filters.productName ?? ''), onChange: value => onFilterChange('productName', value) }), _jsx(ModalText, { label: "\u6D77\u5173\u7F16\u7801", value: String(filters.hsCode ?? ''), onChange: value => onFilterChange('hsCode', value) })] }) }) });
155
+ }
156
+ function AnalyticsInfoModal({ info, onClose }) {
157
+ return _jsx("div", { className: "tcw-analytics-modal-deck", "aria-hidden": false, children: _jsx(AnalyticsModal, { title: info.title, active: true, onClose: onClose, footer: _jsxs("button", { type: "button", className: "tcw-button tcw-button--secondary", onClick: onClose, children: [_jsx("i", { className: "ri-close-line", "aria-hidden": "true" }), "\u5173\u95ED"] }), children: info.rows.length ? _jsx("dl", { className: "tcw-analytics-info-list", children: info.rows.map(([label, value]) => _jsxs("div", { children: [_jsx("dt", { children: label }), _jsx("dd", { children: value })] }, `${label}-${value}`)) }) : _jsx(EmptyText, { text: "\u6682\u65E0\u660E\u7EC6" }) }) });
260
158
  }
261
159
  function BusinessExportModal({ active, total, onClose, onExport }) {
262
160
  return _jsx("div", { className: "tcw-analytics-modal-deck", hidden: !active, "aria-hidden": !active, children: _jsx(AnalyticsModal, { title: "\u4E1A\u52A1\u5BFC\u51FA", active: active, onClose: onClose, footer: _jsxs("button", { type: "button", className: "tcw-button tcw-button--secondary", onClick: onClose, children: [_jsx("i", { className: "ri-close-line", "aria-hidden": "true" }), "\u53D6\u6D88"] }), children: _jsxs("div", { className: "tcw-analytics-export-panel", children: [_jsxs("button", { type: "button", onClick: () => onExport('summary'), children: [_jsx("i", { className: "ri-dashboard-line", "aria-hidden": "true" }), _jsx("strong", { children: "\u7BA1\u7406\u6C47\u603B\u62A5\u8868" }), _jsx("span", { children: "\u6307\u6807\u6C47\u603B\u3001TOP \u6392\u540D\u548C\u8D8B\u52BF\u6570\u636E\uFF0C\u9002\u5408\u7ECF\u8425\u590D\u76D8\u3002" })] }), _jsxs("button", { type: "button", onClick: () => onExport('details'), children: [_jsx("i", { className: "ri-file-list-3-line", "aria-hidden": "true" }), _jsx("strong", { children: "\u5F53\u524D\u660E\u7EC6\u6E05\u5355" }), _jsxs("span", { children: ["\u5BFC\u51FA\u5F53\u524D\u7B5B\u9009\u540E\u7684 ", total, " \u6761\u660E\u7EC6\u6570\u636E\u3002"] })] }), _jsxs("button", { type: "button", onClick: () => onExport('exceptions'), children: [_jsx("i", { className: "ri-alarm-warning-line", "aria-hidden": "true" }), _jsx("strong", { children: "\u5F02\u5E38/\u98CE\u9669\u6E05\u5355" }), _jsx("span", { children: "\u672A\u6536\u6B3E\u3001\u672A\u4ED8\u6B3E\u3001\u672A\u9000\u7A0E\u548C\u5408\u89C4\u5F85\u5904\u7406\u4E8B\u9879\u3002" })] })] }) }) });
@@ -362,6 +260,20 @@ function amountRatio(part, total, formatted = true) {
362
260
  const value = denominator > 0 ? (Number(part) || 0) / denominator : 0;
363
261
  return formatted ? percent(value) : String(value);
364
262
  }
263
+ function percentRatio(part, total) {
264
+ const denominator = Number(total) || 0;
265
+ const value = denominator > 0 ? (Number(part) || 0) / denominator : 0;
266
+ return `${(value * 100).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}%`;
267
+ }
268
+ function deltaLabel(current, previous) {
269
+ const now = Number(current ?? 0);
270
+ const before = Number(previous ?? 0);
271
+ if (!Number.isFinite(now) || !Number.isFinite(before) || before <= 0)
272
+ return '暂无环比';
273
+ const delta = (now - before) / before;
274
+ const arrow = delta >= 0 ? '↑' : '↓';
275
+ return `${arrow} ${Math.abs(delta * 100).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}%`;
276
+ }
365
277
  function money(value) { const number = Number(value ?? 0); return Number.isFinite(number) ? number.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) : '0.00'; }
366
278
  function compactMoney(value) {
367
279
  const number = Number(value ?? 0);