From d372f72935a5d0a9b7343337c069adaa6967eb98 Mon Sep 17 00:00:00 2001 From: zhuotianyuan Date: Fri, 9 Jan 2026 14:56:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0webhook=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E5=AD=97=E6=AE=B5=E5=92=8C=E5=8C=BA=E5=9F=9F=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在站点列表和编辑表单中添加webhook地址字段 在订单列表中添加付款日期字段 在统计页面添加国家/区域选择功能,支持多选和搜索 引入i18n-iso-countries库实现国家名称本地化 --- src/pages/Order/List/index.tsx | 8 ++- src/pages/Site/List/index.tsx | 2 + src/pages/Site/Shop/EditSiteForm.tsx | 6 ++ src/pages/Statistics/Order/index.tsx | 28 +++++++- src/pages/Statistics/OrderSource/index.tsx | 74 +++++++++++++++++----- 5 files changed, 101 insertions(+), 17 deletions(-) diff --git a/src/pages/Order/List/index.tsx b/src/pages/Order/List/index.tsx index 3ae3da8..d507c14 100644 --- a/src/pages/Order/List/index.tsx +++ b/src/pages/Order/List/index.tsx @@ -215,11 +215,17 @@ const ListPage: React.FC = () => { dataIndex: 'externalOrderId', }, { - title: '订单日期', + title: '订单创建日期', dataIndex: 'date_created', hideInSearch: true, valueType: 'dateTime', }, + { + title: '付款日期', + dataIndex: 'date_paid', + hideInSearch: true, + valueType: 'dateTime', + }, { title: '金额', dataIndex: 'total', diff --git a/src/pages/Site/List/index.tsx b/src/pages/Site/List/index.tsx index 5a04a56..15f2b9b 100644 --- a/src/pages/Site/List/index.tsx +++ b/src/pages/Site/List/index.tsx @@ -188,6 +188,8 @@ const SiteList: React.FC = () => { ), }, + { title: 'webhook地址', dataIndex: 'webhookUrl', width: 280, hideInSearch: true }, + { title: 'SKU 前缀', dataIndex: 'skuPrefix', diff --git a/src/pages/Site/Shop/EditSiteForm.tsx b/src/pages/Site/Shop/EditSiteForm.tsx index a361be4..bd40360 100644 --- a/src/pages/Site/Shop/EditSiteForm.tsx +++ b/src/pages/Site/Shop/EditSiteForm.tsx @@ -100,6 +100,11 @@ const EditSiteForm: React.FC = ({ label="网站地址" placeholder="请输入网站地址" /> + = ({ label="区域" mode="multiple" placeholder="请选择区域" + showSearch filterOption={(input, option) => (option?.label ?? '').toLowerCase().includes(input.toLowerCase()) diff --git a/src/pages/Statistics/Order/index.tsx b/src/pages/Statistics/Order/index.tsx index 7190b67..0b2f8b8 100644 --- a/src/pages/Statistics/Order/index.tsx +++ b/src/pages/Statistics/Order/index.tsx @@ -2,6 +2,7 @@ import { ORDER_STATUS_ENUM } from '@/constants'; import { AddTag } from '@/pages/Customer/List'; import { customercontrollerDeltag } from '@/servers/api/customer'; import { sitecontrollerAll } from '@/servers/api/site'; +import * as countries from 'i18n-iso-countries'; import { statisticscontrollerGetorderbydate, statisticscontrollerGetorderbyemail, @@ -22,7 +23,8 @@ import dayjs from 'dayjs'; import ReactECharts from 'echarts-for-react'; import { useEffect, useMemo, useRef, useState } from 'react'; import weekOfYear from 'dayjs/plugin/weekOfYear'; - +import zhCN from 'i18n-iso-countries/langs/zh'; + countries.registerLocale(zhCN); dayjs.extend(weekOfYear); const highlightText = (text: string, keyword: string) => { if (!keyword) return text; @@ -38,6 +40,17 @@ const highlightText = (text: string, keyword: string) => { ); }; +// 获取所有国家/地区的选项 + const getCountryOptions = () => { + // 获取所有国家的 ISO 代码 + const countryCodes = countries.getAlpha2Codes(); + // 将国家代码转换为选项数组 + return Object.keys(countryCodes).map((code) => ({ + label: countries.getName(code, 'zh') || code, // 使用中文名称, 如果没有则使用代码 + value: code, + })); + }; + const ListPage: React.FC = () => { const [xAxis, setXAxis] = useState([]); const [series, setSeries] = useState([]); @@ -620,6 +633,19 @@ const ListPage: React.FC = () => { })); }} /> + + + (option?.label ?? '').toLowerCase().includes(input.toLowerCase()) + } + options={getCountryOptions()} + /> {/* { const [data, setData] = useState({}); - - useEffect(() => { - statisticscontrollerGetordersorce().then(({ data, success }) => { + const initialValues = { + country: ['CA'], + }; + function handleSubmit(values: typeof initialValues) { + statisticscontrollerGetordersorce({params: values}).then(({ data, success }) => { if (success) setData(data); }); + } + useEffect(() => { + handleSubmit(initialValues) }, []); const option = useMemo(() => { @@ -39,11 +49,11 @@ const ListPage: React.FC = () => { data: data?.inactiveRes?.map((v) => v.new_user_count)?.sort((_) => -1), label: { show: true, - formatter: function (params) { + formatter: function (params) { if (!params.value) return ''; - return Math.abs(params.value) - +'\n' - +Math.abs(data?.inactiveRes?.find((item) => item.order_month === params.name)?.new_user_total || 0); + return Math.abs(params.value) + + '\n' + + Math.abs(data?.inactiveRes?.find((item) => item.order_month === params.name)?.new_user_total || 0); }, color: '#000000', }, @@ -59,11 +69,11 @@ const ListPage: React.FC = () => { data: data?.inactiveRes?.map((v) => v.old_user_count)?.sort((_) => -1), label: { show: true, - formatter: function (params) { + formatter: function (params) { if (!params.value) return ''; - return Math.abs(params.value) - +'\n' - +Math.abs(data?.inactiveRes?.find((item) => item.order_month === params.name)?.old_user_total || 0); + return Math.abs(params.value) + + '\n' + + Math.abs(data?.inactiveRes?.find((item) => item.order_month === params.name)?.old_user_total || 0); }, color: '#000000', }, @@ -83,11 +93,11 @@ const ListPage: React.FC = () => { show: true, formatter: function (params) { if (!params.value) return ''; - return Math.abs(params.value) - +'\n'+ - +Math.abs(data?.res?.find((item) => item.order_month === params.name && + return Math.abs(params.value) + + '\n' + + +Math.abs(data?.res?.find((item) => item.order_month === params.name && item.first_order_month_group === v)?.total || 0); - }, + }, color: '#000000', }, data: xAxisData.map((month) => { @@ -258,9 +268,29 @@ const ListPage: React.FC = () => { ); }, }, + ]; + return ( + + + + (option?.label ?? '').toLowerCase().includes(input.toLowerCase()) + } + options={getCountryOptions()} + /> + { }, }} /> + {tableData?.length ? ( { ); }; + + +// 获取所有国家/地区的选项 +const getCountryOptions = () => { + // 获取所有国家的 ISO 代码 + const countryCodes = countries.getAlpha2Codes(); + // 将国家代码转换为选项数组 + + return Object.keys(countryCodes).map((code) => ({ + label: countries.getName(code, 'zh') || code, // 使用中文名称, 如果没有则使用代码 + value: code, + })); +}; export default ListPage; -- 2.40.1