sync: 同步 monkey-ai@weiyuan(ddc5b9443) 的 web/ 到 ui-optimization
- 合入 weiyuan 新功能前端:分佣 V2 / 伙伴工作台、智能路由、企业资金与分析、官网设置与预约演示等, semi-ui 已全部迁移到 antd 6 / @/components/ui,不重新引入 Semi - 分佣二级菜单与页头去重、伙伴入口探测(企业伙伴走企业中心「企业分佣」)、超管侧栏入口恢复 - 适配层 DatePicker / TimePicker 统一 onChange(Date|Date[]|null, 文本) 契约;生产构建剔除调试日志 - 图片链接刷新:同任务请求复用、后台刷新不弹全局错误、离页停止批量请求 - 恢复 bun.lock(与 package-lock.json 共存);docs 规范与 CHANGELOG 更新 - 停止跟踪 .env.playwright.local(本地登录凭据,已加入 .gitignore)
This commit is contained in:
@@ -0,0 +1,551 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { API } from '../../helpers';
|
||||
import { shouldLoadHistoricalTrend } from './dashboardHistory';
|
||||
import './dashboard.css';
|
||||
|
||||
const EMPTY = [];
|
||||
const DAY = 86400;
|
||||
const amount = (value) => (Number.isFinite(Number(value)) ? Number(value) : 0);
|
||||
const protectionUntil = (row) =>
|
||||
amount(row.extended_until || row.protected_until);
|
||||
const salesAmount = (row) =>
|
||||
row.base_amount_uyuan ?? row.sales_amount_uyuan ?? row.sales_uyuan;
|
||||
const inMonth = (row, month) =>
|
||||
!row.statement_month || row.statement_month === month;
|
||||
|
||||
function sixMonths(month) {
|
||||
if (!/^\d{4}-(0[1-9]|1[0-2])$/.test(month || '')) return [];
|
||||
const [year, number] = month.split('-').map(Number);
|
||||
return Array.from({ length: 6 }, (_, index) => {
|
||||
const date = new Date(Date.UTC(year, number - 6 + index, 1));
|
||||
return `${date.getUTCFullYear()}-${String(date.getUTCMonth() + 1).padStart(2, '0')}`;
|
||||
});
|
||||
}
|
||||
|
||||
export default function Dashboard({
|
||||
bills = EMPTY,
|
||||
partners = EMPTY,
|
||||
assignments = EMPTY,
|
||||
exceptions = EMPTY,
|
||||
realtime = EMPTY,
|
||||
options = {},
|
||||
tiers = EMPTY,
|
||||
month,
|
||||
onNavigate,
|
||||
trend = EMPTY,
|
||||
ready = false,
|
||||
}) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const [retry, setRetry] = useState(0);
|
||||
const [history, setHistory] = useState({
|
||||
month: '',
|
||||
rows: [],
|
||||
failed: [],
|
||||
loading: true,
|
||||
});
|
||||
const months = useMemo(() => sixMonths(month), [month]);
|
||||
const suppliedTrend = trend.length > 0;
|
||||
const historicalMonths = months.slice(0, -1).join(',');
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
!shouldLoadHistoricalTrend({
|
||||
ready,
|
||||
suppliedTrend,
|
||||
historicalMonths,
|
||||
})
|
||||
)
|
||||
return;
|
||||
let cancelled = false;
|
||||
const controller = new AbortController();
|
||||
setHistory({ month, rows: [], failed: [], loading: true });
|
||||
const keys = historicalMonths.split(',');
|
||||
Promise.allSettled(
|
||||
keys.map(async (key) => {
|
||||
const response = await API.get(
|
||||
`/api/commission/v2/statements?month=${encodeURIComponent(key)}`,
|
||||
{
|
||||
skipErrorHandler: true,
|
||||
disableDuplicate: true,
|
||||
signal: controller.signal,
|
||||
},
|
||||
);
|
||||
if (!response.data?.success || (response.data.data != null && !Array.isArray(response.data.data))) {
|
||||
throw new Error('Invalid statement response');
|
||||
}
|
||||
return response.data.data || [];
|
||||
}),
|
||||
).then((results) => {
|
||||
if (cancelled) return;
|
||||
const rows = [];
|
||||
const failed = [];
|
||||
results.forEach((result, index) => {
|
||||
if (result.status === 'fulfilled') rows.push(...result.value);
|
||||
else failed.push(keys[index]);
|
||||
});
|
||||
setHistory({ month, rows, failed, loading: false });
|
||||
});
|
||||
return () => {
|
||||
cancelled = true;
|
||||
controller.abort();
|
||||
};
|
||||
}, [month, historicalMonths, ready, suppliedTrend, retry]);
|
||||
|
||||
const numberFormat = useMemo(
|
||||
() =>
|
||||
new Intl.NumberFormat(i18n.language, {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
}),
|
||||
[i18n.language],
|
||||
);
|
||||
const money = (value) => `¥ ${numberFormat.format(amount(value) / 1e6)}`;
|
||||
const now = Date.now() / 1000;
|
||||
const currentBills = bills.filter((row) => inMonth(row, month));
|
||||
const currentRealtime = realtime.filter((row) => inMonth(row, month));
|
||||
const estimated = currentRealtime.reduce(
|
||||
(total, row) => total + amount(row.estimated_uyuan),
|
||||
0,
|
||||
);
|
||||
const hasSales =
|
||||
currentRealtime.length === 0 ||
|
||||
currentRealtime.every((row) => salesAmount(row) != null);
|
||||
const sales = currentRealtime.reduce(
|
||||
(total, row) => total + amount(salesAmount(row)),
|
||||
0,
|
||||
);
|
||||
const partnerById = new Map(partners.map((row) => [String(row.id), row]));
|
||||
const protectedAssignments = assignments.filter(
|
||||
(row) =>
|
||||
['protected', 'protected_extended', 'pending_conversion'].includes(
|
||||
row.status,
|
||||
) && !row.ended_at,
|
||||
);
|
||||
const expiring = protectedAssignments.filter(
|
||||
(row) =>
|
||||
['protected', 'protected_extended'].includes(row.status) &&
|
||||
protectionUntil(row) > now &&
|
||||
protectionUntil(row) <= now + 7 * DAY,
|
||||
);
|
||||
const conversions = assignments.filter(
|
||||
(row) => row.status === 'pending_conversion',
|
||||
);
|
||||
const agreements = partners.filter(
|
||||
(row) =>
|
||||
amount(row.agreement_expires_at) > now &&
|
||||
amount(row.agreement_expires_at) <= now + 30 * DAY,
|
||||
);
|
||||
const openExceptions = exceptions.filter((row) => row.status === 'open');
|
||||
const checking = currentBills.filter((row) => row.status === 'checking');
|
||||
const fees = currentBills.filter(
|
||||
(row) =>
|
||||
['estimated', 'checking'].includes(row.status) &&
|
||||
!row.fee_recorded &&
|
||||
partnerById.get(String(row.partner_id))?.type === 'individual',
|
||||
);
|
||||
const payments = currentBills.filter(
|
||||
(row) => row.status === 'confirmed' && amount(row.payable_uyuan) > 0,
|
||||
);
|
||||
const overdue = currentBills.filter(
|
||||
(row) =>
|
||||
row.status === 'pending_confirmation' &&
|
||||
amount(row.confirmation_deadline) > 0 &&
|
||||
amount(row.confirmation_deadline) <= now,
|
||||
);
|
||||
const activeTiers = tiers.filter(
|
||||
(tier) =>
|
||||
amount(tier.effective_from) <= now &&
|
||||
(!amount(tier.effective_to) || amount(tier.effective_to) > now),
|
||||
);
|
||||
const boundChannels = new Set();
|
||||
const boundLevels = new Set();
|
||||
activeTiers.forEach((tier) => {
|
||||
if (tier.source_type === 'channel') {
|
||||
const ids = tier.channel_ids?.length
|
||||
? tier.channel_ids
|
||||
: [tier.source_id];
|
||||
ids.forEach((id) => boundChannels.add(String(id)));
|
||||
} else if (tier.source_type === 'level') {
|
||||
boundLevels.add(`${tier.level_type}:${tier.tier_key}`);
|
||||
}
|
||||
});
|
||||
const unboundChannels = (options.channels || []).filter(
|
||||
(row) =>
|
||||
(row.status == null || Number(row.status) === 1) &&
|
||||
!boundChannels.has(String(row.id)),
|
||||
);
|
||||
const unboundLevels = (options.levels || []).filter(
|
||||
(row) =>
|
||||
!row.is_default &&
|
||||
row.key !== 'default' &&
|
||||
!boundLevels.has(`${row.type}:${row.key}`),
|
||||
);
|
||||
const summaryTodos = [
|
||||
{
|
||||
label: '保护期 7 日内到期',
|
||||
rows: expiring,
|
||||
target: 'assignments',
|
||||
filter: 'expiring_protection',
|
||||
tone: 'warning',
|
||||
},
|
||||
{
|
||||
label: '待确认转化',
|
||||
rows: conversions,
|
||||
target: 'assignments',
|
||||
filter: 'pending_conversion',
|
||||
tone: 'primary',
|
||||
},
|
||||
{
|
||||
label: '待修复计提异常',
|
||||
rows: openExceptions,
|
||||
target: 'exceptions',
|
||||
filter: 'open',
|
||||
tone: 'danger',
|
||||
},
|
||||
{
|
||||
label: '协议 30 日内到期',
|
||||
rows: agreements,
|
||||
target: 'partners',
|
||||
filter: 'expiring_agreement',
|
||||
tone: 'warning',
|
||||
},
|
||||
];
|
||||
const detailedTodos = [
|
||||
{
|
||||
label: '账单待核对',
|
||||
description: '核对销售额、提成与调整后发出确认',
|
||||
rows: checking,
|
||||
filter: 'checking',
|
||||
action: '去核对',
|
||||
tone: 'primary',
|
||||
},
|
||||
{
|
||||
label: '个人手续费待录入',
|
||||
description: '个人伙伴账单需录入手续费后出账',
|
||||
rows: fees,
|
||||
filter: 'fee_missing',
|
||||
action: '录入手续费',
|
||||
tone: 'warning',
|
||||
},
|
||||
{
|
||||
label: '已确认待打款',
|
||||
description: '账单已确认,可登记付款结果',
|
||||
rows: payments,
|
||||
filter: 'pending_payment',
|
||||
action: '去打款',
|
||||
tone: 'primary',
|
||||
},
|
||||
{
|
||||
label: '已超过确认截止日',
|
||||
description: '检查确认状态并处理逾期账单',
|
||||
rows: overdue,
|
||||
filter: 'overdue_confirmation',
|
||||
action: '去处理',
|
||||
tone: 'danger',
|
||||
},
|
||||
];
|
||||
const navigateTodo = (todo, target = 'bills') =>
|
||||
onNavigate?.(todo.target || target, {
|
||||
todo: todo.filter,
|
||||
ids: todo.rows.map((row) => row.id),
|
||||
});
|
||||
|
||||
const historyMatches = history.month === month;
|
||||
const trendLoading =
|
||||
!suppliedTrend && (!historyMatches || history.loading) && months.length > 0;
|
||||
const failedMonths =
|
||||
!suppliedTrend && historyMatches ? history.failed : EMPTY;
|
||||
const chartRows = suppliedTrend
|
||||
? trend
|
||||
: historyMatches
|
||||
? history.rows
|
||||
: EMPTY;
|
||||
const totals = new Map();
|
||||
chartRows.forEach((row) => {
|
||||
const key = row.statement_month;
|
||||
totals.set(key, (totals.get(key) || 0) + amount(row.payable_uyuan));
|
||||
});
|
||||
const chart = months.map((key, index) => ({
|
||||
month: key,
|
||||
value: index === 5 ? estimated : (totals.get(key) ?? 0),
|
||||
hasData: index === 5 ? currentRealtime.length > 0 : totals.has(key),
|
||||
failed: failedMonths.includes(key),
|
||||
estimated: index === 5,
|
||||
}));
|
||||
const chartMax = Math.max(1, ...chart.map((row) => Math.abs(row.value)));
|
||||
|
||||
return (
|
||||
<div className='commission-dashboard'>
|
||||
<section aria-labelledby='commission-month-overview'>
|
||||
<h3 id='commission-month-overview'>{t('本月概览')}</h3>
|
||||
<div className='commission-dashboard-core'>
|
||||
<div className='commission-dashboard-stat'>
|
||||
<span>{t('预估有效销售额')}</span>
|
||||
<strong>{hasSales ? money(sales) : '—'}</strong>
|
||||
{!hasSales && <small>{t('暂无销售额数据')}</small>}
|
||||
</div>
|
||||
<div className='commission-dashboard-stat commission-dashboard-stat--featured'>
|
||||
<span>{t('预估应付提成')}</span>
|
||||
<strong>{money(estimated)}</strong>
|
||||
</div>
|
||||
<div className='commission-dashboard-stat'>
|
||||
<span>{t('占销售额比例')}</span>
|
||||
<strong>
|
||||
{hasSales && sales > 0
|
||||
? `${numberFormat.format((estimated / sales) * 100)}%`
|
||||
: '—'}
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div className='commission-dashboard-support'>
|
||||
{[
|
||||
[
|
||||
'生效合作伙伴',
|
||||
partners.filter((row) => row.status === 'active').length,
|
||||
],
|
||||
[
|
||||
'正式归属客户',
|
||||
assignments.filter(
|
||||
(row) => row.status === 'formal' && !row.ended_at,
|
||||
).length,
|
||||
],
|
||||
['保护期客户', protectedAssignments.length],
|
||||
].map(([label, count]) => (
|
||||
<div className='commission-dashboard-stat' key={label}>
|
||||
<span>{t(label)}</span>
|
||||
<strong>{count}</strong>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<p className='commission-dashboard-note'>
|
||||
{t('预估数据会因人工调整发生变化,以正式账单为准。')}
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<div className='commission-dashboard-main'>
|
||||
<section
|
||||
className='commission-dashboard-card'
|
||||
aria-labelledby='commission-dashboard-todos'
|
||||
>
|
||||
<h3 id='commission-dashboard-todos'>{t('待办事项')}</h3>
|
||||
<div className='commission-dashboard-todo-summary'>
|
||||
{summaryTodos.map((todo) => (
|
||||
<button
|
||||
type='button'
|
||||
className='commission-dashboard-summary-item'
|
||||
key={todo.filter}
|
||||
onClick={() => navigateTodo(todo)}
|
||||
>
|
||||
<span>{t(todo.label)}</span>
|
||||
<strong className={`commission-dashboard-${todo.tone}`}>
|
||||
{todo.rows.length}
|
||||
</strong>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<div className='commission-dashboard-todo-list'>
|
||||
{detailedTodos.map((todo) => (
|
||||
<div className='commission-dashboard-todo' key={todo.filter}>
|
||||
<div>
|
||||
<span
|
||||
className={`commission-dashboard-tag commission-dashboard-tag--${todo.tone}`}
|
||||
>
|
||||
{t(todo.label)}
|
||||
</span>
|
||||
<h4>
|
||||
{t('待处理 {{count}} 项', { count: todo.rows.length })}
|
||||
</h4>
|
||||
<p>{t(todo.description)}</p>
|
||||
{todo.rows.length > 0 && (
|
||||
<small>
|
||||
{todo.rows
|
||||
.slice(0, 2)
|
||||
.map((row) =>
|
||||
t('{{partner}} · {{month}}', {
|
||||
partner:
|
||||
partnerById.get(String(row.partner_id))?.name ||
|
||||
t('伙伴 #{{id}}', { id: row.partner_id }),
|
||||
month: row.statement_month,
|
||||
}),
|
||||
)
|
||||
.join(' / ')}
|
||||
</small>
|
||||
)}
|
||||
</div>
|
||||
<button
|
||||
type='button'
|
||||
className={`commission-dashboard-button${todo.rows.length ? ' commission-dashboard-button--primary' : ''}`}
|
||||
onClick={() => navigateTodo(todo)}
|
||||
aria-label={t('{{action}}:{{label}},{{count}} 项', {
|
||||
action: t(todo.action),
|
||||
label: t(todo.label),
|
||||
count: todo.rows.length,
|
||||
})}
|
||||
>
|
||||
{t(todo.action)}
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section
|
||||
className='commission-dashboard-card commission-dashboard-health'
|
||||
aria-labelledby='commission-dashboard-health'
|
||||
>
|
||||
<h3 id='commission-dashboard-health'>{t('数据健康')}</h3>
|
||||
<p>{t('关注分佣档位配置完整性')}</p>
|
||||
<div className='commission-dashboard-health-metrics'>
|
||||
<button
|
||||
type='button'
|
||||
className='commission-dashboard-health-item'
|
||||
onClick={() =>
|
||||
onNavigate?.('tiers', {
|
||||
source_type: 'channel',
|
||||
unbound: true,
|
||||
ids: unboundChannels.map((row) => row.id),
|
||||
})
|
||||
}
|
||||
>
|
||||
<span>{t('未绑定档位渠道')}</span>
|
||||
<strong
|
||||
className={
|
||||
unboundChannels.length
|
||||
? 'commission-dashboard-danger'
|
||||
: 'commission-dashboard-success'
|
||||
}
|
||||
>
|
||||
{unboundChannels.length}
|
||||
</strong>
|
||||
<small>{t('查看渠道档位')} →</small>
|
||||
</button>
|
||||
<button
|
||||
type='button'
|
||||
className='commission-dashboard-health-item'
|
||||
onClick={() =>
|
||||
onNavigate?.('tiers', {
|
||||
source_type: 'level',
|
||||
unbound: true,
|
||||
levels: unboundLevels.map((row) => `${row.type}:${row.key}`),
|
||||
})
|
||||
}
|
||||
>
|
||||
<span>{t('未绑定档位等级')}</span>
|
||||
<strong
|
||||
className={
|
||||
unboundLevels.length
|
||||
? 'commission-dashboard-danger'
|
||||
: 'commission-dashboard-success'
|
||||
}
|
||||
>
|
||||
{unboundLevels.length}
|
||||
</strong>
|
||||
<p>{t('不含跟随模型或渠道档位的默认等级')}</p>
|
||||
<small>{t('查看等级档位')} →</small>
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<section
|
||||
className='commission-dashboard-card commission-dashboard-trend'
|
||||
aria-labelledby='commission-dashboard-trend'
|
||||
>
|
||||
<div className='commission-dashboard-trend-heading'>
|
||||
<h3 id='commission-dashboard-trend'>{t('近 6 个月提成应付趋势')}</h3>
|
||||
<span>{t('单位:万元 · 本月为预估')}</span>
|
||||
</div>
|
||||
{trendLoading && <p role='status'>{t('正在加载历史账单')}</p>}
|
||||
{failedMonths.length > 0 && (
|
||||
<div className='commission-dashboard-trend-error' role='alert'>
|
||||
<span>
|
||||
{t('部分月份加载失败:{{months}}', {
|
||||
months: failedMonths.join('、'),
|
||||
})}
|
||||
</span>
|
||||
<button
|
||||
type='button'
|
||||
className='commission-dashboard-button'
|
||||
onClick={() => setRetry((value) => value + 1)}
|
||||
>
|
||||
{t('重试')}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
<div className='commission-dashboard-chart' aria-busy={trendLoading}>
|
||||
{chart.map((row) => (
|
||||
<button
|
||||
type='button'
|
||||
key={row.month}
|
||||
className={`commission-dashboard-chart-column${row.estimated ? ' commission-dashboard-chart-column--current' : ''}`}
|
||||
onClick={() => onNavigate?.('bills', { month: row.month })}
|
||||
aria-label={t('{{month}}:{{amount}},{{status}}', {
|
||||
month: row.month,
|
||||
amount: money(row.value),
|
||||
status: t(
|
||||
row.failed
|
||||
? '加载失败'
|
||||
: row.estimated
|
||||
? '实时预估'
|
||||
: row.hasData
|
||||
? '账单应付'
|
||||
: '暂无数据',
|
||||
),
|
||||
})}
|
||||
>
|
||||
<span className='commission-dashboard-chart-plot'>
|
||||
<span
|
||||
className='commission-dashboard-chart-bar'
|
||||
style={{
|
||||
height: `${Math.max(row.value ? 2 : 0, (Math.abs(row.value) / chartMax) * 100)}%`,
|
||||
}}
|
||||
>
|
||||
<span className='commission-dashboard-chart-value'>
|
||||
{row.failed || (trendLoading && !row.estimated)
|
||||
? '—'
|
||||
: numberFormat.format(row.value / 1e10)}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
<span className='commission-dashboard-chart-month'>
|
||||
{row.month.slice(5)}
|
||||
{t('月')}
|
||||
</span>
|
||||
<span className='commission-dashboard-chart-status'>
|
||||
{row.failed
|
||||
? t('加载失败')
|
||||
: row.estimated
|
||||
? t('预估')
|
||||
: trendLoading
|
||||
? t('加载中')
|
||||
: !row.hasData
|
||||
? t('暂无数据')
|
||||
: '\u00a0'}
|
||||
</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
import { Alert, Button } from 'antd';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import ListPanel from './ListPanel';
|
||||
import { latestTierURL, fetchAllLatestTiers } from './latestTiers';
|
||||
|
||||
export default function LatestTierPanel({
|
||||
fetchJSON,
|
||||
columns,
|
||||
onExport,
|
||||
refreshToken,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const generation = useRef(0);
|
||||
// 依赖变化时生成新的上下文对象,用于丢弃旧请求结果(原有逻辑,依赖为有意设置)。
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
const context = useMemo(() => ({}), [fetchJSON, refreshToken]);
|
||||
const activeContext = useRef(context);
|
||||
activeContext.current = context;
|
||||
const exportRequest = useRef(null);
|
||||
const [query, setQuery] = useState({ status: 'all', page: 1 });
|
||||
const [state, setState] = useState({
|
||||
items: [],
|
||||
total: 0,
|
||||
counts: {},
|
||||
busy: true,
|
||||
error: '',
|
||||
});
|
||||
const [exporting, setExporting] = useState(false);
|
||||
const load = useCallback(async () => {
|
||||
const current = ++generation.current;
|
||||
setExporting(false);
|
||||
setState((old) => ({ ...old, context, items: [], busy: true, error: '' }));
|
||||
try {
|
||||
const result = await fetchJSON(latestTierURL(query, query.page));
|
||||
if (current !== generation.current || activeContext.current !== context)
|
||||
return;
|
||||
setState({
|
||||
...result,
|
||||
context,
|
||||
items: result.items.map((item) => ({ ...item, __asOf: result.as_of })),
|
||||
busy: false,
|
||||
error: '',
|
||||
});
|
||||
} catch (error) {
|
||||
if (current === generation.current && activeContext.current === context)
|
||||
setState((old) => ({
|
||||
...old,
|
||||
items: [],
|
||||
busy: false,
|
||||
error: error.message,
|
||||
}));
|
||||
}
|
||||
}, [fetchJSON, query, context]);
|
||||
useEffect(() => {
|
||||
load();
|
||||
return () => {
|
||||
// 卸载或重新加载时作废进行中的请求(原有逻辑)。
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
generation.current++;
|
||||
};
|
||||
}, [load]);
|
||||
const exportAll = async () => {
|
||||
if (
|
||||
exportRequest.current?.context === context ||
|
||||
state.busy ||
|
||||
state.context !== context
|
||||
)
|
||||
return;
|
||||
const request = { context };
|
||||
exportRequest.current = request;
|
||||
const current = generation.current;
|
||||
setExporting(true);
|
||||
try {
|
||||
const rows = await fetchAllLatestTiers(fetchJSON, query);
|
||||
if (current === generation.current && activeContext.current === context)
|
||||
onExport(rows);
|
||||
} catch (error) {
|
||||
if (current === generation.current && activeContext.current === context)
|
||||
setState((old) => ({ ...old, error: error.message }));
|
||||
} finally {
|
||||
if (exportRequest.current === request) exportRequest.current = null;
|
||||
if (current === generation.current && activeContext.current === context)
|
||||
setExporting(false);
|
||||
}
|
||||
};
|
||||
const visible =
|
||||
state.context === context
|
||||
? state
|
||||
: {
|
||||
...state,
|
||||
items: [],
|
||||
total: 0,
|
||||
counts: {},
|
||||
busy: true,
|
||||
error: '',
|
||||
revision: undefined,
|
||||
};
|
||||
return (
|
||||
<div data-testid='commission-latest-tiers' data-revision={visible.revision}>
|
||||
{visible.error && (
|
||||
<Alert
|
||||
type='error'
|
||||
showIcon
|
||||
className='commission-inline-alert'
|
||||
title={visible.error}
|
||||
action={
|
||||
<Button size='small' onClick={load}>
|
||||
{t('重试')}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<ListPanel
|
||||
section='tiers'
|
||||
rows={visible.items}
|
||||
columns={columns}
|
||||
partners={[]}
|
||||
searchableText={() => ''}
|
||||
onExport={exportAll}
|
||||
server={{
|
||||
...visible,
|
||||
page: query.page,
|
||||
exporting,
|
||||
onChange: (next) => {
|
||||
generation.current++;
|
||||
exportRequest.current = null;
|
||||
setExporting(false);
|
||||
setState((old) => ({ ...old, items: [], busy: true, error: '' }));
|
||||
setQuery(next);
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,289 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button, Card, Empty, Input, Select, Table } from 'antd';
|
||||
import { Search } from 'lucide-react';
|
||||
import { filterCommissionRows, matchesStatus } from './listFilters';
|
||||
|
||||
export default function ListPanel({
|
||||
section,
|
||||
rows,
|
||||
columns,
|
||||
partners,
|
||||
searchableText,
|
||||
onExport,
|
||||
context,
|
||||
server,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [draft, setDraft] = useState({ query: '', type: '', partner: '' });
|
||||
const [filters, setFilters] = useState({});
|
||||
const [scopedIds, setScopedIds] = useState(context?.ids || null);
|
||||
const [status, setStatus] = useState('all');
|
||||
const [page, setPage] = useState(1);
|
||||
const set = (key, value) =>
|
||||
setDraft((current) => ({ ...current, [key]: value }));
|
||||
const tabSets = {
|
||||
assignments: [
|
||||
['all', '全部'],
|
||||
['protect', '保护中'],
|
||||
['pending_conversion', '待确认转化'],
|
||||
['formal', '正式归属'],
|
||||
['history', '历史归属'],
|
||||
],
|
||||
bills: [
|
||||
['all', '全部'],
|
||||
['estimated', '本月预估'],
|
||||
['checking', '待核对'],
|
||||
['pending_confirmation', '待确认'],
|
||||
['confirmed', '已确认'],
|
||||
['completed', '已完成'],
|
||||
],
|
||||
adjustments: [
|
||||
['all', '全部'],
|
||||
['applied', '已生效'],
|
||||
['voided', '已作废'],
|
||||
],
|
||||
tiers: [
|
||||
['all', '全部档位'],
|
||||
['enabled', '启用中'],
|
||||
['scheduled', '待生效'],
|
||||
['disabled', '已停用'],
|
||||
],
|
||||
};
|
||||
const typeOptions =
|
||||
section === 'partners'
|
||||
? [
|
||||
['company', '企业'],
|
||||
['individual', '个人'],
|
||||
]
|
||||
: section === 'assignments'
|
||||
? [
|
||||
['organization', '企业'],
|
||||
['user', 'C 端'],
|
||||
]
|
||||
: section === 'tiers'
|
||||
? [
|
||||
['level', '等级档位'],
|
||||
['model', '模型档位'],
|
||||
['channel', '渠道档位'],
|
||||
]
|
||||
: null;
|
||||
const placeholders = {
|
||||
partners: '搜索伙伴名称 / 编号 / 协议编号',
|
||||
assignments: '搜索客户名称 / ID',
|
||||
tiers: '搜索档位 / 模型 / 渠道',
|
||||
bills: '搜索伙伴 / 账单号',
|
||||
adjustments: '搜索调整单 / 客户 / 原因',
|
||||
audit: '搜索操作 / 实体 / 操作人',
|
||||
exceptions: '搜索异常码 / 计费事实 / 说明',
|
||||
};
|
||||
const scopedRows = scopedIds
|
||||
? rows.filter((row) => scopedIds.includes(row.id))
|
||||
: rows;
|
||||
const filtered = server
|
||||
? rows
|
||||
: filterCommissionRows(
|
||||
scopedRows,
|
||||
{
|
||||
...filters,
|
||||
status: section === 'partners' ? filters.status : status,
|
||||
},
|
||||
section,
|
||||
searchableText,
|
||||
);
|
||||
const query = () => {
|
||||
setFilters(draft);
|
||||
setPage(1);
|
||||
server?.onChange({ ...draft, status, page: 1 });
|
||||
};
|
||||
return (
|
||||
<Card
|
||||
className={`commission-card commission-list commission-list--${section}`}
|
||||
>
|
||||
{tabSets[section] && (
|
||||
<div
|
||||
className='commission-list-tabs'
|
||||
role='tablist'
|
||||
aria-label={t('状态筛选')}
|
||||
>
|
||||
{tabSets[section].map(([key, label]) => (
|
||||
<button
|
||||
key={key}
|
||||
type='button'
|
||||
role='tab'
|
||||
aria-selected={status === key}
|
||||
className={status === key ? 'is-active' : ''}
|
||||
onClick={() => {
|
||||
setStatus(key);
|
||||
setPage(1);
|
||||
server?.onChange({ ...filters, status: key, page: 1 });
|
||||
}}
|
||||
>
|
||||
{t(label)}
|
||||
<span>
|
||||
{server
|
||||
? server.counts[
|
||||
{ enabled: 'active', scheduled: 'pending' }[key] || key
|
||||
] || 0
|
||||
: rows.filter((row) => matchesStatus(row, key, section))
|
||||
.length}
|
||||
</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{scopedIds && (
|
||||
<div className='commission-context-filter'>
|
||||
{t('正在查看工作台待办筛选结果')}
|
||||
<Button
|
||||
type='link'
|
||||
size='small'
|
||||
onClick={() => {
|
||||
setScopedIds(null);
|
||||
setPage(1);
|
||||
}}
|
||||
>
|
||||
{t('查看全部')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
<div className='commission-filter-bar'>
|
||||
<Input
|
||||
prefix={<Search size={16} aria-hidden />}
|
||||
value={draft.query}
|
||||
onChange={(event) => set('query', event.target.value)}
|
||||
onPressEnter={query}
|
||||
allowClear
|
||||
placeholder={t(placeholders[section])}
|
||||
aria-label={t(placeholders[section])}
|
||||
/>
|
||||
{typeOptions && (
|
||||
<Select
|
||||
aria-label={t('类型筛选')}
|
||||
value={draft.type}
|
||||
onChange={(value) => set('type', value)}
|
||||
options={[
|
||||
{
|
||||
value: '',
|
||||
label: t(
|
||||
section === 'assignments'
|
||||
? '全部客户类型'
|
||||
: section === 'tiers'
|
||||
? '全部来源'
|
||||
: '全部类型',
|
||||
),
|
||||
},
|
||||
...typeOptions.map(([value, label]) => ({
|
||||
value,
|
||||
label: t(label),
|
||||
})),
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
{section === 'partners' && (
|
||||
<Select
|
||||
aria-label={t('状态筛选')}
|
||||
value={draft.status || ''}
|
||||
onChange={(value) => set('status', value)}
|
||||
options={['', 'draft', 'active', 'suspended', 'terminated'].map(
|
||||
(value, i) => ({
|
||||
value,
|
||||
label: t(['全部状态', '草稿', '生效中', '已暂停', '已终止'][i]),
|
||||
}),
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
{['assignments', 'bills', 'adjustments'].includes(section) && (
|
||||
<Select
|
||||
aria-label={t('合作伙伴筛选')}
|
||||
showSearch={{ optionFilterProp: 'label' }}
|
||||
value={draft.partner}
|
||||
onChange={(value) => set('partner', value)}
|
||||
options={[
|
||||
{ value: '', label: t('全部合作伙伴') },
|
||||
...partners.map((row) => ({ value: row.id, label: row.name })),
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
<Button type='primary' onClick={query}>
|
||||
{t('查询')}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setDraft({ query: '', type: '', partner: '' });
|
||||
setFilters({});
|
||||
setStatus('all');
|
||||
server?.onChange({ status: 'all', page: 1 });
|
||||
setScopedIds(null);
|
||||
setPage(1);
|
||||
}}
|
||||
>
|
||||
{t('重置')}
|
||||
</Button>
|
||||
<div className='commission-filter-end'>
|
||||
<span>
|
||||
{t('共 {{count}} 条', {
|
||||
count: server ? server.total : filtered.length,
|
||||
})}
|
||||
</span>
|
||||
{onExport && (
|
||||
<Button
|
||||
loading={server?.exporting}
|
||||
disabled={!!server?.busy}
|
||||
onClick={() => onExport(filtered)}
|
||||
>
|
||||
{t('导出')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<Table
|
||||
rowKey='id'
|
||||
loading={server?.busy}
|
||||
columns={columns}
|
||||
dataSource={filtered}
|
||||
size='middle'
|
||||
scroll={{ x: 'max-content' }}
|
||||
pagination={{
|
||||
size: 'small',
|
||||
pageSize: server ? 100 : 10,
|
||||
total: server ? server.total : filtered.length,
|
||||
current: server ? server.page : page,
|
||||
onChange: (next) => {
|
||||
setPage(next);
|
||||
server?.onChange({ ...filters, status, page: next });
|
||||
},
|
||||
showSizeChanger: false,
|
||||
showTotal: (total) => t('共 {{total}} 条', { total }),
|
||||
}}
|
||||
locale={{
|
||||
emptyText: (
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description={t('暂无数据')}
|
||||
/>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Alert, Button, Descriptions, Drawer, Spin, Table, Tag } from 'antd';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { commissionActorName, commissionLabel, statusTagColor } from './labels';
|
||||
import { EvidenceLink } from './operations';
|
||||
|
||||
export default function PartnerDetail({
|
||||
partner,
|
||||
assignments,
|
||||
audit,
|
||||
fetchJSON,
|
||||
onClose,
|
||||
onEdit,
|
||||
}) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const [record, setRecord] = useState(null);
|
||||
const [error, setError] = useState('');
|
||||
useEffect(() => {
|
||||
let current = true;
|
||||
setRecord(null);
|
||||
setError('');
|
||||
if (partner)
|
||||
fetchJSON(`/api/commission/v2/partners/${partner.id}`)
|
||||
.then((value) => current && setRecord(value))
|
||||
.catch((err) => current && setError(err.message));
|
||||
return () => {
|
||||
current = false;
|
||||
};
|
||||
}, [partner, fetchJSON]);
|
||||
const row = record || partner || {};
|
||||
const date = (value) =>
|
||||
value ? new Date(value * 1000).toLocaleDateString(i18n.language) : '—';
|
||||
const section = (title, fields) => (
|
||||
<section className='commission-profile-section'>
|
||||
<h3>{t(title)}</h3>
|
||||
<Descriptions
|
||||
size='small'
|
||||
column={{ xs: 1, md: 2 }}
|
||||
items={fields.map(([key, value]) => ({
|
||||
key,
|
||||
label: t(key),
|
||||
children: value || '—',
|
||||
}))}
|
||||
/>
|
||||
</section>
|
||||
);
|
||||
return (
|
||||
<Drawer
|
||||
rootClassName='commission-profile-drawer commission-detail-drawer'
|
||||
title={
|
||||
<span>
|
||||
{row.name}{' '}
|
||||
<Tag color={statusTagColor(row.status)}>
|
||||
{commissionLabel(t, 'status', row.status)}
|
||||
</Tag>
|
||||
</span>
|
||||
}
|
||||
open={!!partner}
|
||||
placement='right'
|
||||
size={820}
|
||||
onClose={onClose}
|
||||
footer={
|
||||
<div className='commission-drawer-actions'>
|
||||
<Button onClick={onClose}>{t('关闭')}</Button>
|
||||
<Button type='primary' onClick={() => onEdit(partner)}>
|
||||
{t('编辑伙伴档案')}
|
||||
</Button>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
{error && (
|
||||
<Alert
|
||||
type='error'
|
||||
showIcon
|
||||
className='commission-inline-alert'
|
||||
title={error}
|
||||
/>
|
||||
)}
|
||||
{!record && !error ? (
|
||||
<Spin className='commission-drawer-spin' />
|
||||
) : (
|
||||
<>
|
||||
{section('基本信息', [
|
||||
['伙伴编号', row.partner_code],
|
||||
['主体类型', commissionLabel(t, 'partnerType', row.type)],
|
||||
['状态', commissionLabel(t, 'status', row.status)],
|
||||
['伙伴名称', row.name],
|
||||
['登录主体', `#${row.user_id}`],
|
||||
['证件号码', row.identity_no],
|
||||
['联系人', row.contact_name],
|
||||
['联系电话', row.contact_phone],
|
||||
['通知邮箱', row.contact_email],
|
||||
])}
|
||||
{section('协议信息', [
|
||||
['协议编号', row.agreement_no],
|
||||
[
|
||||
'协议有效期',
|
||||
`${date(row.agreement_effective_at)} ~ ${date(row.agreement_expires_at)}`,
|
||||
],
|
||||
[
|
||||
'协议附件',
|
||||
row.agreement_evidence ? (
|
||||
<EvidenceLink value={row.agreement_evidence} />
|
||||
) : null,
|
||||
],
|
||||
])}
|
||||
{section('结算资料', [
|
||||
['收款账户名', row.receiving_name],
|
||||
['收款账号', row.receiving_account],
|
||||
['开户行', row.receiving_bank],
|
||||
])}
|
||||
<section className='commission-profile-section'>
|
||||
<h3>{t('名下客户')}</h3>
|
||||
<Table
|
||||
rowKey='id'
|
||||
size='middle'
|
||||
scroll={{ x: 'max-content' }}
|
||||
dataSource={assignments.filter(
|
||||
(item) => item.partner_id === row.id,
|
||||
)}
|
||||
pagination={{ pageSize: 5, size: 'small' }}
|
||||
columns={[
|
||||
{
|
||||
title: t('客户'),
|
||||
render: (_, item) =>
|
||||
item.customer_name || `#${item.subject_id}`,
|
||||
},
|
||||
{
|
||||
title: t('类型'),
|
||||
render: (_, item) =>
|
||||
commissionLabel(t, 'subjectType', item.subject_type),
|
||||
},
|
||||
{
|
||||
title: t('状态'),
|
||||
render: (_, item) =>
|
||||
commissionLabel(t, 'status', item.status),
|
||||
},
|
||||
{
|
||||
title: t('起止时间'),
|
||||
render: (_, item) =>
|
||||
`${date(item.started_at)} ~ ${date(item.ended_at)}`,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</section>
|
||||
<section className='commission-profile-section'>
|
||||
<h3>{t('变更记录')}</h3>
|
||||
<div className='commission-timeline'>
|
||||
{audit
|
||||
.filter(
|
||||
(item) =>
|
||||
item.entity_type === 'partner' && item.entity_id === row.id,
|
||||
)
|
||||
.map((item) => (
|
||||
<div key={item.id}>
|
||||
<strong>
|
||||
{commissionLabel(t, 'operation', item.action)}
|
||||
</strong>
|
||||
<p>
|
||||
{date(item.created_at)} · {t('操作人')}{' '}
|
||||
{commissionActorName(t, item)}
|
||||
</p>
|
||||
</div>
|
||||
))}
|
||||
{!audit.some(
|
||||
(item) =>
|
||||
item.entity_type === 'partner' && item.entity_id === row.id,
|
||||
) && <p className='commission-muted'>{t('暂无操作记录')}</p>}
|
||||
</div>
|
||||
</section>
|
||||
</>
|
||||
)}
|
||||
</Drawer>
|
||||
);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,183 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, {
|
||||
forwardRef,
|
||||
useEffect,
|
||||
useImperativeHandle,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
import { Alert, Button, Select } from 'antd';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
createRequestGeneration,
|
||||
mergeIdentityOptions,
|
||||
identityOptionLabel,
|
||||
} from './latestTiers';
|
||||
|
||||
const RemoteIdentitySelect = forwardRef(function RemoteIdentitySelect(
|
||||
{ type, value, onChange, fetchJSON },
|
||||
ref,
|
||||
) {
|
||||
const { t } = useTranslation();
|
||||
const gate = useRef(createRequestGeneration());
|
||||
const timer = useRef();
|
||||
const [query, setQuery] = useState('');
|
||||
const [state, setState] = useState({
|
||||
items: [],
|
||||
total: 0,
|
||||
page: 0,
|
||||
busy: false,
|
||||
error: '',
|
||||
});
|
||||
const selected = useRef(null);
|
||||
const active = useRef(true);
|
||||
useImperativeHandle(
|
||||
ref,
|
||||
() => ({
|
||||
invalidate() {
|
||||
active.current = false;
|
||||
gate.current.next();
|
||||
clearTimeout(timer.current);
|
||||
},
|
||||
}),
|
||||
[],
|
||||
);
|
||||
const load = async (q, page, generation) => {
|
||||
setState((old) => ({ ...old, busy: true, error: '' }));
|
||||
try {
|
||||
const result = await fetchJSON(
|
||||
`/api/commission/v2/options/${type === 'company' ? 'organizations' : 'users'}?${new URLSearchParams({ q, p: String(page), page_size: '20' })}`,
|
||||
);
|
||||
if (!gate.current.current(generation)) return;
|
||||
setState((old) => ({
|
||||
items: mergeIdentityOptions(
|
||||
page === 1 ? [] : old.items,
|
||||
result.items || [],
|
||||
selected.current,
|
||||
),
|
||||
total: result.total,
|
||||
page,
|
||||
busy: false,
|
||||
error: '',
|
||||
}));
|
||||
} catch (error) {
|
||||
if (gate.current.current(generation))
|
||||
setState((old) => ({ ...old, busy: false, error: error.message }));
|
||||
}
|
||||
};
|
||||
const search = (q) => {
|
||||
clearTimeout(timer.current);
|
||||
const generation = gate.current.next();
|
||||
setQuery(q);
|
||||
setState({
|
||||
items: selected.current ? [selected.current] : [],
|
||||
total: 0,
|
||||
page: 0,
|
||||
busy: true,
|
||||
error: '',
|
||||
});
|
||||
timer.current = setTimeout(() => load(q, 1, generation), 300);
|
||||
};
|
||||
useEffect(() => {
|
||||
active.current = true;
|
||||
search('');
|
||||
return () => {
|
||||
active.current = false;
|
||||
// 卸载时作废进行中的请求(原有逻辑)。
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
gate.current.next();
|
||||
clearTimeout(timer.current);
|
||||
};
|
||||
// 仅在类型或数据源变化时重新搜索(原有逻辑,依赖为有意设置)。
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [type, fetchJSON]);
|
||||
const selectIdentity = (id) => {
|
||||
if (!active.current) return;
|
||||
selected.current = state.items.find((item) => item.id === id) || null;
|
||||
onChange(id);
|
||||
};
|
||||
return (
|
||||
<div>
|
||||
<Select
|
||||
aria-label={t(type === 'company' ? '关联企业' : '关联个人用户')}
|
||||
placeholder={t(
|
||||
type === 'company'
|
||||
? '输入企业 ID、名称或编码'
|
||||
: '输入用户 ID、用户名或显示名',
|
||||
)}
|
||||
showSearch={{ filterOption: false, onSearch: search }}
|
||||
allowClear
|
||||
style={{ width: '100%' }}
|
||||
value={value}
|
||||
loading={state.busy}
|
||||
// 选中即提交,保证快速保存时读取到的就是界面显示的 ID。
|
||||
onSelect={selectIdentity}
|
||||
onChange={(id) => {
|
||||
if (id == null) selectIdentity(id);
|
||||
}}
|
||||
options={state.items.map((item) => ({
|
||||
value: item.id,
|
||||
label: identityOptionLabel(item),
|
||||
disabled: item.disabled,
|
||||
}))}
|
||||
notFoundContent={
|
||||
state.error
|
||||
? t('加载失败')
|
||||
: state.busy
|
||||
? t('加载中')
|
||||
: t(
|
||||
type === 'company'
|
||||
? '未找到可关联企业,请核对 ID 或企业状态'
|
||||
: '未找到可关联用户,请核对 ID 或账号状态',
|
||||
)
|
||||
}
|
||||
onOpenChange={(visible) => {
|
||||
if (visible && !state.page && !state.busy) search(query);
|
||||
}}
|
||||
/>
|
||||
{state.error && (
|
||||
<Alert
|
||||
type='error'
|
||||
showIcon
|
||||
className='commission-inline-alert'
|
||||
title={state.error}
|
||||
/>
|
||||
)}
|
||||
{state.error && (
|
||||
<Button
|
||||
aria-label={t('重试加载身份')}
|
||||
onClick={() => load(query, state.page + 1, gate.current.next())}
|
||||
>
|
||||
{t('重试')}
|
||||
</Button>
|
||||
)}
|
||||
{!state.error && state.page * 20 < state.total && (
|
||||
<Button
|
||||
aria-label={t('加载更多身份')}
|
||||
loading={state.busy}
|
||||
onClick={() => load(query, state.page + 1, gate.current.next())}
|
||||
>
|
||||
{t('加载更多')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
export default RemoteIdentitySelect;
|
||||
@@ -0,0 +1,492 @@
|
||||
.commission-dashboard {
|
||||
--dash-line: var(--border-subtle, rgba(15, 23, 42, 0.12));
|
||||
--dash-muted: var(--text-tertiary, var(--text-secondary, #7b8798));
|
||||
--dash-primary: var(
|
||||
--commission-primary-solid,
|
||||
var(--commission-primary, var(--brand-primary, #165dff))
|
||||
);
|
||||
--dash-text: var(--text-primary, #1d2129);
|
||||
--dash-card: var(--surface-card, #fff);
|
||||
--dash-soft: color-mix(in srgb, var(--surface-bg-base) 52%, var(--dash-card));
|
||||
--dash-featured-bg: color-mix(
|
||||
in srgb,
|
||||
var(--commission-primary-soft, #e8f0ff) 62%,
|
||||
var(--dash-card)
|
||||
);
|
||||
--dash-featured-line: color-mix(
|
||||
in srgb,
|
||||
var(--dash-primary) 24%,
|
||||
var(--dash-line)
|
||||
);
|
||||
--dash-warning: color-mix(in srgb, #f59e0b 78%, var(--dash-text));
|
||||
--dash-danger: color-mix(in srgb, #f56c7a 82%, var(--dash-text));
|
||||
--dash-success: color-mix(in srgb, #22c55e 78%, var(--dash-text));
|
||||
--dash-warning-bg: color-mix(in srgb, #f59e0b 12%, var(--dash-card));
|
||||
--dash-danger-bg: color-mix(in srgb, #f56c7a 12%, var(--dash-card));
|
||||
--dash-grid: color-mix(in srgb, var(--dash-text) 11%, transparent);
|
||||
--dash-muted-bar: color-mix(
|
||||
in srgb,
|
||||
var(--dash-primary) 28%,
|
||||
var(--dash-card)
|
||||
);
|
||||
color: var(--dash-text);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.commission-dashboard-heading,
|
||||
.commission-dashboard-trend-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.commission-dashboard-heading {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.commission-dashboard h2 {
|
||||
margin: 0 0 6px;
|
||||
font-size: 22px;
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.commission-dashboard h3 {
|
||||
margin: 0 0 18px;
|
||||
color: var(--dash-text);
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.commission-dashboard p {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
color: var(--dash-muted);
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.commission-dashboard-period {
|
||||
flex-shrink: 0;
|
||||
border: 1px solid var(--dash-line);
|
||||
border-radius: 4px;
|
||||
background: var(--dash-card);
|
||||
padding: 6px 12px;
|
||||
font-size: 12px;
|
||||
color: var(--dash-muted);
|
||||
}
|
||||
|
||||
.commission-dashboard-core,
|
||||
.commission-dashboard-support {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.commission-dashboard-stat,
|
||||
.commission-dashboard-card {
|
||||
border: 1px solid var(--dash-line);
|
||||
border-radius: 6px;
|
||||
background: var(--dash-card);
|
||||
box-shadow: none;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.commission-dashboard-stat {
|
||||
padding: 16px 20px;
|
||||
}
|
||||
|
||||
.commission-dashboard-stat > span,
|
||||
.commission-dashboard-summary-item > span,
|
||||
.commission-dashboard-health-item > span {
|
||||
display: block;
|
||||
font-size: 13px;
|
||||
font-weight: 400;
|
||||
color: var(--dash-muted);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.commission-dashboard strong {
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.commission-dashboard-stat > strong {
|
||||
display: block;
|
||||
margin-top: 8px;
|
||||
font-size: 28px;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.7px;
|
||||
line-height: 1.3;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.commission-dashboard-stat > small {
|
||||
display: block;
|
||||
margin-top: 6px;
|
||||
color: var(--dash-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.commission-dashboard-stat--featured {
|
||||
background: var(--dash-featured-bg);
|
||||
border-color: var(--dash-featured-line);
|
||||
}
|
||||
|
||||
.commission-dashboard-stat--featured > strong {
|
||||
color: var(--dash-primary);
|
||||
}
|
||||
|
||||
.commission-dashboard-support {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.commission-dashboard-support .commission-dashboard-stat {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
padding: 14px 20px;
|
||||
}
|
||||
|
||||
.commission-dashboard-support .commission-dashboard-stat > strong {
|
||||
margin: 0;
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.commission-dashboard p.commission-dashboard-note {
|
||||
margin-top: 12px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.commission-dashboard-main {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 2.2fr) minmax(260px, 1fr);
|
||||
gap: 16px;
|
||||
margin: 16px 0;
|
||||
}
|
||||
|
||||
.commission-dashboard-card {
|
||||
padding: 18px 20px;
|
||||
}
|
||||
|
||||
.commission-dashboard-todo-summary {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.commission-dashboard button {
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.commission-dashboard button:focus-visible {
|
||||
outline: 2px solid var(--dash-primary);
|
||||
outline-offset: 3px;
|
||||
}
|
||||
|
||||
.commission-dashboard-summary-item {
|
||||
padding: 10px 12px;
|
||||
text-align: left;
|
||||
border: 1px solid var(--dash-line);
|
||||
border-radius: 4px;
|
||||
background: var(--dash-soft);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.commission-dashboard-summary-item > span {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.commission-dashboard-summary-item > strong {
|
||||
display: block;
|
||||
margin-top: 6px;
|
||||
font-size: 22px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.commission-dashboard-primary {
|
||||
color: var(--dash-primary);
|
||||
}
|
||||
|
||||
.commission-dashboard-warning {
|
||||
color: var(--dash-warning);
|
||||
}
|
||||
|
||||
.commission-dashboard-danger {
|
||||
color: var(--dash-danger);
|
||||
}
|
||||
|
||||
.commission-dashboard-success {
|
||||
color: var(--dash-success);
|
||||
}
|
||||
|
||||
.commission-dashboard-todo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 14px;
|
||||
border-bottom: 1px solid var(--dash-line);
|
||||
padding: 15px 0;
|
||||
}
|
||||
|
||||
.commission-dashboard-todo:last-child {
|
||||
border: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.commission-dashboard-todo > div {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.commission-dashboard-tag {
|
||||
display: inline-block;
|
||||
border-radius: 4px;
|
||||
padding: 1px 7px;
|
||||
font-size: 11px;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.commission-dashboard-tag--primary {
|
||||
background: var(--dash-featured-bg);
|
||||
color: var(--dash-primary);
|
||||
}
|
||||
|
||||
.commission-dashboard-tag--warning {
|
||||
background: var(--dash-warning-bg);
|
||||
color: var(--dash-warning);
|
||||
}
|
||||
|
||||
.commission-dashboard-tag--danger {
|
||||
background: var(--dash-danger-bg);
|
||||
color: var(--dash-danger);
|
||||
}
|
||||
|
||||
.commission-dashboard-todo h4 {
|
||||
margin: 5px 0 2px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.commission-dashboard-todo small {
|
||||
display: block;
|
||||
color: var(--dash-muted);
|
||||
font-size: 12px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.commission-dashboard-button {
|
||||
flex-shrink: 0;
|
||||
border: 1px solid var(--dash-line);
|
||||
border-radius: 4px;
|
||||
padding: 6px 12px;
|
||||
color: var(--text-secondary);
|
||||
background: var(--dash-card);
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.commission-dashboard-button--primary {
|
||||
border-color: var(--dash-primary);
|
||||
color: #fff;
|
||||
background: var(--dash-primary);
|
||||
}
|
||||
|
||||
.commission-dashboard-button:hover,
|
||||
.commission-dashboard-summary-item:hover,
|
||||
.commission-dashboard-health-item:hover {
|
||||
filter: brightness(0.97);
|
||||
}
|
||||
|
||||
.commission-dashboard-health h3 {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.commission-dashboard-health-item {
|
||||
width: 100%;
|
||||
margin-top: 12px;
|
||||
border: 0;
|
||||
border: 1px solid var(--dash-line);
|
||||
border-radius: 4px;
|
||||
padding: 16px;
|
||||
text-align: left;
|
||||
background: var(--dash-soft);
|
||||
}
|
||||
|
||||
.commission-dashboard-health-item > strong {
|
||||
display: block;
|
||||
margin-top: 8px;
|
||||
font-size: 28px;
|
||||
line-height: 1.3;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.commission-dashboard-health-item > p {
|
||||
margin-top: 12px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.commission-dashboard-health-item > small {
|
||||
display: block;
|
||||
margin-top: 12px;
|
||||
color: var(--dash-primary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.commission-dashboard-trend-heading {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.commission-dashboard-trend-heading h3 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.commission-dashboard-trend-heading > span {
|
||||
color: var(--dash-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.commission-dashboard-trend-error {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin: 0 0 20px;
|
||||
border: 1px solid
|
||||
color-mix(in srgb, var(--dash-warning) 24%, var(--dash-line));
|
||||
border-radius: 4px;
|
||||
padding: 10px 12px;
|
||||
background: var(--dash-warning-bg);
|
||||
color: var(--dash-warning);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.commission-dashboard-chart {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||||
padding-top: 16px;
|
||||
}
|
||||
|
||||
.commission-dashboard-chart-column {
|
||||
min-width: 0;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
text-align: center;
|
||||
color: var(--dash-muted);
|
||||
}
|
||||
|
||||
.commission-dashboard-chart-plot {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
height: 145px;
|
||||
border-bottom: 1px solid var(--dash-line);
|
||||
background: repeating-linear-gradient(
|
||||
to top,
|
||||
transparent 0,
|
||||
transparent 47px,
|
||||
var(--dash-grid) 47px,
|
||||
var(--dash-grid) 48px
|
||||
);
|
||||
}
|
||||
|
||||
.commission-dashboard-chart-bar {
|
||||
position: relative;
|
||||
display: block;
|
||||
width: 42%;
|
||||
max-width: 72px;
|
||||
min-height: 1px;
|
||||
border-radius: 2px 2px 0 0;
|
||||
background: var(--dash-muted-bar);
|
||||
}
|
||||
|
||||
.commission-dashboard-chart-column--current .commission-dashboard-chart-bar {
|
||||
background: var(--dash-primary);
|
||||
}
|
||||
|
||||
.commission-dashboard-chart-value {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
bottom: calc(100% + 8px);
|
||||
transform: translateX(-50%);
|
||||
font-size: 12px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.commission-dashboard-chart-month {
|
||||
display: block;
|
||||
margin-top: 10px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.commission-dashboard-chart-status {
|
||||
display: block;
|
||||
margin-top: 3px;
|
||||
color: var(--dash-muted);
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
@media (max-width: 1150px) {
|
||||
.commission-dashboard-todo-summary {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.commission-dashboard-stat {
|
||||
padding: 18px;
|
||||
}
|
||||
|
||||
.commission-dashboard-stat > strong {
|
||||
font-size: 26px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.commission-dashboard-main {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.commission-dashboard-core,
|
||||
.commission-dashboard-support {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.commission-dashboard-health-metrics {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 520px) {
|
||||
.commission-dashboard-heading,
|
||||
.commission-dashboard-trend-heading {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.commission-dashboard-card {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.commission-dashboard-health-metrics {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.commission-dashboard-todo {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.commission-dashboard-button {
|
||||
padding: 6px 9px;
|
||||
}
|
||||
|
||||
.commission-dashboard-chart-value {
|
||||
font-size: 10px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
export function shouldLoadHistoricalTrend({
|
||||
ready,
|
||||
suppliedTrend,
|
||||
historicalMonths,
|
||||
}) {
|
||||
return Boolean(ready && !suppliedTrend && historicalMonths);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { shouldLoadHistoricalTrend } from './dashboardHistory.js';
|
||||
|
||||
test('historical trend waits for authenticated dashboard data', () => {
|
||||
assert.equal(
|
||||
shouldLoadHistoricalTrend({
|
||||
ready: false,
|
||||
suppliedTrend: false,
|
||||
historicalMonths: '2026-06,2026-07',
|
||||
}),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
shouldLoadHistoricalTrend({
|
||||
ready: true,
|
||||
suppliedTrend: false,
|
||||
historicalMonths: '2026-06,2026-07',
|
||||
}),
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
test('historical trend does not load when trend data is supplied or months are empty', () => {
|
||||
assert.equal(
|
||||
shouldLoadHistoricalTrend({
|
||||
ready: true,
|
||||
suppliedTrend: true,
|
||||
historicalMonths: '2026-06',
|
||||
}),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
shouldLoadHistoricalTrend({
|
||||
ready: true,
|
||||
suppliedTrend: false,
|
||||
historicalMonths: '',
|
||||
}),
|
||||
false,
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
export function pickerEpoch(firstValue, secondValue) {
|
||||
// Semi DatePicker defaults to onChangeWithDateFirst=true, but callers can
|
||||
// opt into the legacy text-first order. Prefer the actual Date object in
|
||||
// either position so localized display text is never parsed as the value.
|
||||
const dateValue = [firstValue, secondValue].find(
|
||||
(value) => value instanceof Date && !Number.isNaN(value.getTime()),
|
||||
);
|
||||
const selected = dateValue ?? firstValue ?? secondValue;
|
||||
if (!selected) return 0;
|
||||
const timestamp = new Date(selected).getTime();
|
||||
return Number.isFinite(timestamp) ? Math.floor(timestamp / 1000) : 0;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { pickerEpoch } from './datePicker.js';
|
||||
|
||||
test('pickerEpoch handles Semi DatePicker date-first callback order', () => {
|
||||
const selected = new Date('2026-12-24T08:30:00.000Z');
|
||||
assert.equal(
|
||||
pickerEpoch(selected, '2026-12-25 00:00:00'),
|
||||
Math.floor(selected.getTime() / 1000),
|
||||
);
|
||||
});
|
||||
|
||||
test('pickerEpoch also handles text-first callbacks', () => {
|
||||
const selected = new Date('2026-12-24T08:30:00.000Z');
|
||||
assert.equal(
|
||||
pickerEpoch('2026-12-25 00:00:00', selected),
|
||||
Math.floor(selected.getTime() / 1000),
|
||||
);
|
||||
});
|
||||
|
||||
test('pickerEpoch returns zero for an empty or invalid selection', () => {
|
||||
assert.equal(pickerEpoch('', undefined), 0);
|
||||
assert.equal(pickerEpoch('invalid localized date', undefined), 0);
|
||||
});
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
export const COMMISSION_EVIDENCE_MAX_BYTES = 10 * 1024 * 1024;
|
||||
export const COMMISSION_EVIDENCE_ACCEPT =
|
||||
'.pdf,.jpg,.jpeg,.png,.webp,.doc,.docx,.xls,.xlsx';
|
||||
|
||||
const supportedExtensions = new Set([
|
||||
'pdf',
|
||||
'jpg',
|
||||
'jpeg',
|
||||
'png',
|
||||
'webp',
|
||||
'doc',
|
||||
'docx',
|
||||
'xls',
|
||||
'xlsx',
|
||||
]);
|
||||
|
||||
export function validateCommissionEvidenceFile(file) {
|
||||
if (!file) return '请选择要上传的凭证文件';
|
||||
const extension = String(file.name || '')
|
||||
.split('.')
|
||||
.pop()
|
||||
.toLowerCase();
|
||||
if (!supportedExtensions.has(extension)) {
|
||||
return '凭证支持 PDF、JPG、PNG、WEBP、Word 或 Excel 文件';
|
||||
}
|
||||
if (Number(file.size || 0) > COMMISSION_EVIDENCE_MAX_BYTES) {
|
||||
return '凭证文件不能超过 10MB';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
export function commissionEvidenceErrorMessage(error) {
|
||||
const serverMessage = error?.response?.data?.message;
|
||||
if (typeof serverMessage === 'string' && serverMessage.trim()) {
|
||||
return serverMessage.trim();
|
||||
}
|
||||
if (error?.code === 'ERR_NETWORK' || error?.message === 'Network Error') {
|
||||
return '上传服务不可用,请检查后端服务和平台私有文件存储配置';
|
||||
}
|
||||
if (typeof error?.message === 'string' && error.message.trim()) {
|
||||
return error.message.trim();
|
||||
}
|
||||
return '凭证上传失败,请稍后重试';
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
commissionEvidenceErrorMessage,
|
||||
validateCommissionEvidenceFile,
|
||||
} from './evidenceUpload.js';
|
||||
|
||||
test('accepts supported evidence files within the size limit', () => {
|
||||
assert.equal(
|
||||
validateCommissionEvidenceFile({ name: 'agreement.pdf', size: 1024 }),
|
||||
'',
|
||||
);
|
||||
assert.equal(
|
||||
validateCommissionEvidenceFile({
|
||||
name: 'invoice.xlsx',
|
||||
size: 10 * 1024 * 1024,
|
||||
}),
|
||||
'',
|
||||
);
|
||||
});
|
||||
|
||||
test('rejects unsupported or oversized evidence files before upload', () => {
|
||||
assert.equal(
|
||||
validateCommissionEvidenceFile({ name: 'notes.txt', size: 1024 }),
|
||||
'凭证支持 PDF、JPG、PNG、WEBP、Word 或 Excel 文件',
|
||||
);
|
||||
assert.equal(
|
||||
validateCommissionEvidenceFile({
|
||||
name: 'large.pdf',
|
||||
size: 10 * 1024 * 1024 + 1,
|
||||
}),
|
||||
'凭证文件不能超过 10MB',
|
||||
);
|
||||
});
|
||||
|
||||
test('turns network and server errors into actionable upload messages', () => {
|
||||
assert.equal(
|
||||
commissionEvidenceErrorMessage({ message: 'Network Error' }),
|
||||
'上传服务不可用,请检查后端服务和平台私有文件存储配置',
|
||||
);
|
||||
assert.equal(
|
||||
commissionEvidenceErrorMessage({
|
||||
response: {
|
||||
data: { message: '请先配置平台私有文件存储;也可填写线下凭证编号' },
|
||||
},
|
||||
message: 'Request failed',
|
||||
}),
|
||||
'请先配置平台私有文件存储;也可填写线下凭证编号',
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,128 @@
|
||||
/* Commission operation forms follow the same compact layout as the prototype. */
|
||||
.commission-form-section {
|
||||
grid-column: 1 / -1;
|
||||
min-width: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.commission-form-section > h3 {
|
||||
margin: 0 0 14px;
|
||||
color: var(--text-primary);
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
line-height: 22px;
|
||||
}
|
||||
|
||||
.commission-form-section-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 16px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.commission-form-section-grid > .ant-alert,
|
||||
.commission-form-section-grid > .commission-tier-targets,
|
||||
.commission-form-section-grid > .commission-checklist,
|
||||
.commission-form-section-grid > .commission-form-span,
|
||||
.commission-form-section-grid > .commission-form-field:has(textarea),
|
||||
.commission-form-section-grid
|
||||
> .commission-form-field:has(.commission-evidence-input) {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.commission-form-section-grid .commission-form-field {
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.commission-form-section-grid .ant-input-number,
|
||||
.commission-form-section-grid .ant-picker {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.commission-required {
|
||||
margin-right: 4px;
|
||||
color: var(--commission-danger);
|
||||
}
|
||||
|
||||
.commission-partner-sheet {
|
||||
--commission-control-height: 32px;
|
||||
}
|
||||
|
||||
.commission-partner-sheet .ant-drawer-body {
|
||||
padding: 24px;
|
||||
background: var(--surface-card);
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
|
||||
.commission-partner-sheet .commission-operation-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.commission-partner-sheet .commission-form-section {
|
||||
padding: 20px;
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: 6px;
|
||||
background: var(--surface-card);
|
||||
}
|
||||
|
||||
.commission-partner-sheet .commission-form-section > h3 {
|
||||
margin-bottom: 16px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.commission-partner-sheet-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.commission-partner-sheet .ant-radio-group {
|
||||
min-height: 32px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.commission-partner-sheet .commission-evidence-upload-button {
|
||||
height: 32px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.commission-partner-sheet .commission-evidence-meta {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.commission-settlement-context {
|
||||
grid-column: 1 / -1;
|
||||
padding: 12px 16px;
|
||||
border-radius: 4px;
|
||||
background: var(--surface-card);
|
||||
}
|
||||
|
||||
.commission-settlement-context .ant-descriptions-item {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.commission-modal--settlement .commission-checklist {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
padding: 12px 0;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.commission-form-section-grid {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.commission-partner-sheet .ant-drawer-body {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.commission-partner-sheet .commission-form-section {
|
||||
padding: 16px;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
// Keep API codes unchanged; translate only known display labels.
|
||||
export const commissionLabels = {
|
||||
level: {
|
||||
default: '默认',
|
||||
standard: '标准',
|
||||
premium: '高级',
|
||||
},
|
||||
status: {
|
||||
estimated: '本月预估',
|
||||
checking: '待核对',
|
||||
pending_confirmation: '待确认',
|
||||
confirmed: '已确认',
|
||||
completed: '已完成',
|
||||
draft: '草稿',
|
||||
active: '合作中',
|
||||
suspended: '已暂停',
|
||||
terminated: '已终止',
|
||||
protected: '保护期内',
|
||||
protected_extended: '保护期已延长',
|
||||
pending_conversion: '待转正',
|
||||
formal: '正式归属',
|
||||
expired: '已过期',
|
||||
transferred: '已转移',
|
||||
applied: '已生效',
|
||||
pending: '待处理',
|
||||
open: '待处理',
|
||||
resolved: '已处理',
|
||||
voided: '已作废',
|
||||
},
|
||||
operation: {
|
||||
status_transition: '状态流转',
|
||||
completed: '登记完成',
|
||||
adjustment_applied: '应用调整',
|
||||
fee_set: '录入手续费',
|
||||
issued: '正式出账',
|
||||
deadline_changed: '修改确认截止日期',
|
||||
partner_confirmed: '伙伴确认',
|
||||
partner_rejected: '伙伴驳回',
|
||||
auto_confirmed: '逾期视同确认',
|
||||
adjustment_created: '创建调整单',
|
||||
adjustment_updated: '修改调整单',
|
||||
adjustment_voided: '作废调整单',
|
||||
payment_recorded: '登记已打款',
|
||||
statement_refreshed: '刷新金额',
|
||||
blocked: '出账阻断',
|
||||
unblocked: '解除出账阻断',
|
||||
created: '新增',
|
||||
extended: '延期',
|
||||
converted: '转正',
|
||||
rejected: '驳回',
|
||||
transferred: '转移',
|
||||
terminated: '终止',
|
||||
activated: '启用',
|
||||
suspended: '暂停',
|
||||
resumed: '恢复',
|
||||
partner_created: '新增伙伴',
|
||||
partner_updated: '更新伙伴档案',
|
||||
partner_activated: '启用伙伴',
|
||||
partner_suspended: '暂停伙伴',
|
||||
partner_terminated: '终止伙伴',
|
||||
agreement_created: '登记协议',
|
||||
agreement_renewed: '续签协议',
|
||||
assignment_created: '建立归属',
|
||||
assignment_extended: '延期保护期',
|
||||
assignment_converted: '确认转正',
|
||||
assignment_rejected: '驳回转化',
|
||||
assignment_transferred: '转移归属',
|
||||
assignment_terminated: '终止归属',
|
||||
tier_created: '新增档位',
|
||||
tier_version_created: '新增档位',
|
||||
tier_updated: '更新档位',
|
||||
tier_enabled: '启用档位',
|
||||
tier_disabled: '停用档位',
|
||||
pending_conversion: '待转正',
|
||||
expired: '已过期',
|
||||
resolved: '已处理',
|
||||
},
|
||||
partnerType: {
|
||||
individual: '个人伙伴',
|
||||
enterprise: '企业伙伴',
|
||||
company: '企业伙伴',
|
||||
},
|
||||
subjectType: {
|
||||
user: '个人用户',
|
||||
organization: '企业组织',
|
||||
},
|
||||
sourceType: {
|
||||
channel: '渠道档位',
|
||||
model: '模型档位',
|
||||
level: '等级档位',
|
||||
},
|
||||
adjustmentType: {
|
||||
sales_amount: '销售额',
|
||||
commission_amount: '提成金额',
|
||||
},
|
||||
entityType: {
|
||||
statement: '账单',
|
||||
partner: '伙伴',
|
||||
assignment: '客户归属',
|
||||
tier: '分佣档位',
|
||||
},
|
||||
};
|
||||
|
||||
export const statusColors = {
|
||||
estimated: 'blue',
|
||||
checking: 'orange',
|
||||
pending_confirmation: 'amber',
|
||||
confirmed: 'green',
|
||||
completed: 'grey',
|
||||
draft: 'grey',
|
||||
active: 'green',
|
||||
suspended: 'orange',
|
||||
terminated: 'grey',
|
||||
protected: 'blue',
|
||||
protected_extended: 'cyan',
|
||||
pending_conversion: 'orange',
|
||||
formal: 'green',
|
||||
expired: 'grey',
|
||||
transferred: 'grey',
|
||||
applied: 'green',
|
||||
pending: 'orange',
|
||||
open: 'orange',
|
||||
resolved: 'green',
|
||||
voided: 'grey',
|
||||
};
|
||||
|
||||
// Semi 时代的状态色名 → antd 语义色(UI_COMPONENT_STANDARDS 第 11 节:状态用语义色)。
|
||||
// 只影响 Tag 的视觉,不改变状态判定。
|
||||
const STATUS_TAG_COLORS = {
|
||||
blue: 'processing',
|
||||
cyan: 'cyan',
|
||||
orange: 'warning',
|
||||
amber: 'warning',
|
||||
green: 'success',
|
||||
red: 'error',
|
||||
grey: 'default',
|
||||
};
|
||||
|
||||
export const statusTagColor = (status) =>
|
||||
STATUS_TAG_COLORS[statusColors[status]] || 'default';
|
||||
|
||||
// The API keeps immutable event codes for auditability. These aliases translate
|
||||
// the codes emitted by the V2 statement/adjustment services into the existing
|
||||
// display labels without changing persisted data or export values.
|
||||
const operationAliases = {
|
||||
ADJ_CREATED: 'adjustment_created',
|
||||
ADJ_UPDATED: 'adjustment_updated',
|
||||
ADJ_DELETED: 'adjustment_voided',
|
||||
BILL_CREATED: 'created',
|
||||
BILL_ISSUED: 'issued',
|
||||
FEE_ENTERED: 'fee_set',
|
||||
PAID_REGISTERED: 'payment_recorded',
|
||||
PARTNER_CONFIRMED: 'partner_confirmed',
|
||||
PARTNER_REJECTED: 'partner_rejected',
|
||||
AUTO_CONFIRMED: 'auto_confirmed',
|
||||
BLOCK_DETECTED: 'blocked',
|
||||
BLOCK_CLEARED: 'unblocked',
|
||||
DEADLINE_CHANGED: 'deadline_changed',
|
||||
RECALC: 'statement_refreshed',
|
||||
agreement_registered: 'agreement_created',
|
||||
agreement_expired: 'expired',
|
||||
partner_status_changed: 'status_transition',
|
||||
exception_resolved: 'resolved',
|
||||
binding_created: 'created',
|
||||
transferred_in: 'transferred',
|
||||
pending_conversion: 'pending_conversion',
|
||||
conversion_rejected: 'rejected',
|
||||
};
|
||||
|
||||
export function commissionLabel(t, category, value) {
|
||||
const labels = commissionLabels[category];
|
||||
const normalizedValue =
|
||||
category === 'operation' && typeof value === 'string'
|
||||
? operationAliases[value] ||
|
||||
operationAliases[value.toUpperCase()] ||
|
||||
value
|
||||
: value;
|
||||
return labels && Object.hasOwn(labels, normalizedValue)
|
||||
? t(labels[normalizedValue])
|
||||
: value || '-';
|
||||
}
|
||||
|
||||
export function commissionLevelName(t, { key, name }) {
|
||||
return name && name !== key ? name : commissionLabel(t, 'level', key);
|
||||
}
|
||||
|
||||
export function commissionActorName(t, { actor_id, actor_username }) {
|
||||
if (actor_id === 0 || actor_id === '0') return t('系统');
|
||||
return actor_username || t('未知用户');
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import test from 'node:test';
|
||||
import { createInstance } from 'i18next';
|
||||
import { LANGUAGE_CODES } from '../../i18n/catalog.js';
|
||||
import {
|
||||
commissionLabel,
|
||||
commissionLabels,
|
||||
commissionLevelName,
|
||||
commissionActorName,
|
||||
} from './labels.js';
|
||||
|
||||
const resources = Object.fromEntries(
|
||||
LANGUAGE_CODES.map((code) => [
|
||||
code,
|
||||
JSON.parse(
|
||||
readFileSync(
|
||||
new URL(`../../i18n/locales/${code}.json`, import.meta.url),
|
||||
'utf8',
|
||||
),
|
||||
),
|
||||
]),
|
||||
);
|
||||
|
||||
test('audit operators show account names, distinguish system actions and missing accounts', () => {
|
||||
const t = (key) => key;
|
||||
assert.equal(
|
||||
commissionActorName(t, { actor_id: 5, actor_username: 'admin.account' }),
|
||||
'admin.account',
|
||||
);
|
||||
assert.equal(commissionActorName(t, { actor_id: 0 }), '系统');
|
||||
assert.equal(commissionActorName(t, { actor_id: '0' }), '系统');
|
||||
assert.equal(commissionActorName(t, { actor_id: 99 }), '未知用户');
|
||||
assert.equal(commissionActorName(t, {}), '未知用户');
|
||||
});
|
||||
|
||||
test('commission labels follow the selected language and preserve custom values', async () => {
|
||||
const i18n = createInstance();
|
||||
await i18n.init({
|
||||
lng: 'zh',
|
||||
resources,
|
||||
fallbackLng: false,
|
||||
keySeparator: false,
|
||||
nsSeparator: false,
|
||||
});
|
||||
assert.equal(commissionLabel(i18n.t, 'level', 'default'), '默认');
|
||||
assert.equal(commissionLabel(i18n.t, 'level', 'standard'), '标准');
|
||||
assert.equal(commissionLabel(i18n.t, 'level', 'premium'), '高级');
|
||||
assert.equal(commissionLabel(i18n.t, 'operation', 'fee_set'), '录入手续费');
|
||||
for (const [action, expected] of Object.entries({
|
||||
ADJ_CREATED: '创建调整单',
|
||||
ADJ_UPDATED: '修改调整单',
|
||||
ADJ_DELETED: '作废调整单',
|
||||
BILL_CREATED: '新增',
|
||||
BILL_ISSUED: '正式出账',
|
||||
FEE_ENTERED: '录入手续费',
|
||||
PAID_REGISTERED: '登记已打款',
|
||||
PARTNER_CONFIRMED: '伙伴确认',
|
||||
PARTNER_REJECTED: '伙伴驳回',
|
||||
AUTO_CONFIRMED: '逾期视同确认',
|
||||
BLOCK_DETECTED: '出账阻断',
|
||||
BLOCK_CLEARED: '解除出账阻断',
|
||||
DEADLINE_CHANGED: '修改确认截止日期',
|
||||
RECALC: '刷新金额',
|
||||
})) {
|
||||
assert.equal(commissionLabel(i18n.t, 'operation', action), expected);
|
||||
}
|
||||
await i18n.changeLanguage('en');
|
||||
assert.equal(commissionLabel(i18n.t, 'level', 'default'), 'Default');
|
||||
assert.equal(commissionLabel(i18n.t, 'level', 'premium'), 'Premium');
|
||||
assert.equal(commissionLabel(i18n.t, 'status', 'active'), 'Active');
|
||||
assert.equal(commissionLabel(i18n.t, 'operation', 'fee_set'), 'Set fee');
|
||||
assert.equal(commissionLabel(i18n.t, 'level', 'VIP-custom'), 'VIP-custom');
|
||||
assert.equal(
|
||||
commissionLabel(i18n.t, 'operation', 'new_action'),
|
||||
'new_action',
|
||||
);
|
||||
assert.equal(commissionLabel(i18n.t, 'level', 'toString'), 'toString');
|
||||
assert.equal(commissionLabel(i18n.t, 'level', null), '-');
|
||||
assert.equal(
|
||||
commissionLevelName(i18n.t, { key: 'default', name: 'default' }),
|
||||
'Default',
|
||||
);
|
||||
assert.equal(
|
||||
commissionLevelName(i18n.t, { key: 'default', name: '定制等级' }),
|
||||
'定制等级',
|
||||
);
|
||||
await i18n.changeLanguage('zh-TW');
|
||||
assert.equal(commissionLabel(i18n.t, 'level', 'default'), '預設');
|
||||
});
|
||||
|
||||
test('every supported language has non-empty commission enum translations', () => {
|
||||
for (const code of LANGUAGE_CODES) {
|
||||
for (const labels of Object.values(commissionLabels)) {
|
||||
for (const key of Object.values(labels)) {
|
||||
assert.ok(
|
||||
resources[code].translation[key]?.trim(),
|
||||
`${code} is missing ${key}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('commission page translations retain interpolation variables in every language', () => {
|
||||
const source = ['index.jsx', 'operations.jsx']
|
||||
.map((file) => readFileSync(new URL(`./${file}`, import.meta.url), 'utf8'))
|
||||
.join('\n');
|
||||
const keys = new Set(
|
||||
[...source.matchAll(/\bt\('([^']+)'/gu)].map((match) => match[1]),
|
||||
);
|
||||
const variables = (text) =>
|
||||
[...text.matchAll(/\{\{(\w+)\}\}/gu)].map((match) => match[1]).sort();
|
||||
for (const code of LANGUAGE_CODES) {
|
||||
for (const key of keys) {
|
||||
const translated = resources[code].translation[key];
|
||||
assert.ok(translated?.trim(), `${code} is missing ${key}`);
|
||||
assert.deepEqual(
|
||||
variables(translated),
|
||||
variables(key),
|
||||
`${code}: ${key}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
export function latestTierURL(filters = {}, page = 1, snapshot = {}) {
|
||||
const params = new URLSearchParams({
|
||||
view: 'latest',
|
||||
p: String(page),
|
||||
page_size: '100',
|
||||
});
|
||||
if (filters.query?.trim()) params.set('q', filters.query.trim());
|
||||
if (filters.type) params.set('source_type', filters.type);
|
||||
const status =
|
||||
{ enabled: 'active', scheduled: 'pending' }[filters.status] ||
|
||||
filters.status;
|
||||
if (status && status !== 'all') params.set('status', status);
|
||||
if (snapshot.as_of) params.set('as_of', String(snapshot.as_of));
|
||||
if (snapshot.revision != null)
|
||||
params.set('revision', String(snapshot.revision));
|
||||
return `/api/commission/v2/tiers?${params}`;
|
||||
}
|
||||
|
||||
export async function fetchAllLatestTiers(fetchJSON, filters = {}) {
|
||||
const rows = [];
|
||||
let snapshot;
|
||||
let total;
|
||||
for (let page = 1; ; page++) {
|
||||
const result = await fetchJSON(latestTierURL(filters, page, snapshot));
|
||||
if (!snapshot) {
|
||||
snapshot = { as_of: result.as_of, revision: result.revision };
|
||||
total = result.total;
|
||||
}
|
||||
if (
|
||||
result.as_of !== snapshot.as_of ||
|
||||
result.revision !== snapshot.revision ||
|
||||
result.total !== total
|
||||
)
|
||||
throw new Error('档位配置已变化,请重新加载或重新导出');
|
||||
if (
|
||||
!Array.isArray(result.items) ||
|
||||
(rows.length < total && !result.items.length)
|
||||
)
|
||||
throw new Error('无法取得完整档位列表,请重试');
|
||||
rows.push(...result.items);
|
||||
if (rows.length === total) return rows;
|
||||
if (rows.length > total) throw new Error('档位配置已变化,请重新导出');
|
||||
}
|
||||
}
|
||||
|
||||
export function mergeIdentityOptions(previous, next, selected) {
|
||||
return [
|
||||
...new Map(
|
||||
[...(selected ? [selected] : []), ...previous, ...next].map((item) => [
|
||||
Number(item.id),
|
||||
item,
|
||||
]),
|
||||
).values(),
|
||||
];
|
||||
}
|
||||
|
||||
export function createRequestGeneration() {
|
||||
let generation = 0;
|
||||
return { next: () => ++generation, current: (value) => generation === value };
|
||||
}
|
||||
|
||||
export function identityOptionLabel(item) {
|
||||
const name =
|
||||
item.name || item.display_name || item.username || item.code || '';
|
||||
const identifier = item.name ? item.code : item.username;
|
||||
return `${name}${identifier && identifier !== name ? ` · ${identifier}` : ''} (#${item.id})${item.disabled_reason ? ` · ${item.disabled_reason}` : ''}`;
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
latestTierURL,
|
||||
fetchAllLatestTiers,
|
||||
mergeIdentityOptions,
|
||||
createRequestGeneration,
|
||||
identityOptionLabel,
|
||||
} from './latestTiers.js';
|
||||
|
||||
test('identity labels distinguish duplicate display names by account and organization code', () => {
|
||||
assert.equal(
|
||||
identityOptionLabel({ id: 8, display_name: '红星', username: 'hongxing' }),
|
||||
'红星 · hongxing (#8)',
|
||||
);
|
||||
assert.equal(
|
||||
identityOptionLabel({
|
||||
id: 8,
|
||||
display_name: 'hongxing',
|
||||
username: 'hongxing',
|
||||
}),
|
||||
'hongxing (#8)',
|
||||
);
|
||||
assert.equal(
|
||||
identityOptionLabel({
|
||||
id: 9,
|
||||
name: '红星公司',
|
||||
code: 'red-star',
|
||||
disabled_reason: '已关联',
|
||||
}),
|
||||
'红星公司 · red-star (#9) · 已关联',
|
||||
);
|
||||
});
|
||||
|
||||
test('latest all status is omitted and export pins server snapshot across all pages', async () => {
|
||||
assert.equal(
|
||||
new URL(latestTierURL({ status: 'all' }), 'http://local').searchParams.has(
|
||||
'status',
|
||||
),
|
||||
false,
|
||||
);
|
||||
const urls = [];
|
||||
const rows = await fetchAllLatestTiers(
|
||||
async (url) => {
|
||||
urls.push(url);
|
||||
const p = Number(new URL(url, 'http://local').searchParams.get('p'));
|
||||
return {
|
||||
items: p === 1 ? [{ id: 1 }] : [{ id: 2 }],
|
||||
total: 2,
|
||||
as_of: 123,
|
||||
revision: 7,
|
||||
};
|
||||
},
|
||||
{ query: '中文', type: 'level' },
|
||||
);
|
||||
assert.equal(rows.length, 2);
|
||||
assert.match(urls[1], /as_of=123/);
|
||||
assert.match(urls[1], /revision=7/);
|
||||
});
|
||||
test('export refuses changed revision and incomplete pages', async () => {
|
||||
let p = 0;
|
||||
await assert.rejects(
|
||||
fetchAllLatestTiers(async () => ({
|
||||
items: [{ id: ++p }],
|
||||
total: 2,
|
||||
as_of: 123,
|
||||
revision: p,
|
||||
})),
|
||||
/变化/,
|
||||
);
|
||||
await assert.rejects(
|
||||
fetchAllLatestTiers(async () => ({
|
||||
items: [],
|
||||
total: 2,
|
||||
as_of: 123,
|
||||
revision: 1,
|
||||
})),
|
||||
/完整/,
|
||||
);
|
||||
});
|
||||
test('remote identity pages retain selection and stale lifecycle is invalidated synchronously', () => {
|
||||
assert.deepEqual(
|
||||
mergeIdentityOptions([{ id: 1 }], [{ id: 2 }], { id: 500 }),
|
||||
[{ id: 500 }, { id: 1 }, { id: 2 }],
|
||||
);
|
||||
const gate = createRequestGeneration();
|
||||
const old = gate.next();
|
||||
gate.next();
|
||||
assert.equal(gate.current(old), false);
|
||||
});
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
export function tierStatus(row, now = Date.now() / 1000) {
|
||||
if (row.effective_to && row.effective_to <= now) return 'disabled';
|
||||
if (row.effective_from > now) return 'scheduled';
|
||||
return 'enabled';
|
||||
}
|
||||
|
||||
export function matchesStatus(row, status, key, now = Date.now() / 1000) {
|
||||
if (!status || status === 'all') return true;
|
||||
if (key === 'tiers') return tierStatus(row, now) === status;
|
||||
if (status === 'protect')
|
||||
return ['protected', 'protected_extended'].includes(row.status);
|
||||
if (status === 'history')
|
||||
return ['expired', 'transferred', 'terminated'].includes(row.status);
|
||||
return row.status === status;
|
||||
}
|
||||
|
||||
export function filterCommissionRows(rows, filters, key, searchableText) {
|
||||
const query = (filters.query || '').trim().toLocaleLowerCase();
|
||||
return rows.filter(
|
||||
(row) =>
|
||||
matchesStatus(row, filters.status, key) &&
|
||||
(!filters.type ||
|
||||
(key === 'partners'
|
||||
? row.type
|
||||
: key === 'tiers'
|
||||
? row.source_type
|
||||
: row.subject_type) === filters.type) &&
|
||||
(!filters.partner ||
|
||||
Number(row.partner_id) === Number(filters.partner)) &&
|
||||
(!query || searchableText(row).toLocaleLowerCase().includes(query)),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
filterCommissionRows,
|
||||
matchesStatus,
|
||||
tierStatus,
|
||||
} from './listFilters.js';
|
||||
|
||||
test('assignment protection and history tabs include all corresponding lifecycle states', () => {
|
||||
assert.equal(
|
||||
matchesStatus({ status: 'protected_extended' }, 'protect', 'assignments'),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
matchesStatus({ status: 'pending_conversion' }, 'protect', 'assignments'),
|
||||
false,
|
||||
);
|
||||
for (const status of ['expired', 'transferred', 'terminated'])
|
||||
assert.equal(matchesStatus({ status }, 'history', 'assignments'), true);
|
||||
});
|
||||
test('future tier end dates remain enabled and future versions are scheduled', () => {
|
||||
assert.equal(
|
||||
tierStatus({ effective_from: 10, effective_to: 200 }, 100),
|
||||
'enabled',
|
||||
);
|
||||
assert.equal(
|
||||
tierStatus({ effective_from: 150, effective_to: 0 }, 100),
|
||||
'scheduled',
|
||||
);
|
||||
assert.equal(
|
||||
tierStatus({ effective_from: 10, effective_to: 100 }, 100),
|
||||
'disabled',
|
||||
);
|
||||
});
|
||||
test('search, customer type, partner and status combine without modifying the source', () => {
|
||||
const rows = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Acme',
|
||||
subject_type: 'organization',
|
||||
partner_id: 3,
|
||||
status: 'formal',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'Acme',
|
||||
subject_type: 'user',
|
||||
partner_id: 4,
|
||||
status: 'formal',
|
||||
},
|
||||
];
|
||||
assert.deepEqual(
|
||||
filterCommissionRows(
|
||||
rows,
|
||||
{ query: ' ACME ', type: 'organization', partner: '3', status: 'formal' },
|
||||
'assignments',
|
||||
(r) => r.name,
|
||||
).map((r) => r.id),
|
||||
[1],
|
||||
);
|
||||
assert.equal(rows.length, 2);
|
||||
});
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
export function validateContractSignedConversion(
|
||||
form,
|
||||
translate = (key) => key,
|
||||
) {
|
||||
if (
|
||||
!form.reference?.trim() ||
|
||||
!form.contract_subject?.trim() ||
|
||||
!form.signed_at
|
||||
) {
|
||||
return translate('请填写合同编号、签约主体和签署日期');
|
||||
}
|
||||
if (form.signed_at > form.fact_at) {
|
||||
return translate('合同签署日期不能晚于实际转化事实时间');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
export function partnerIdentityPayload(form, translate = (key) => key) {
|
||||
if (
|
||||
!form.name?.trim() ||
|
||||
(form.type === 'company' ? !form.organization_id : !form.user_id)
|
||||
)
|
||||
throw new Error(translate('请完整填写伙伴名称和关联身份'));
|
||||
const payload = { ...form };
|
||||
if (form.type === 'company') delete payload.user_id;
|
||||
else delete payload.organization_id;
|
||||
return payload;
|
||||
}
|
||||
|
||||
export function levelBindingPayload(form, level, translate = (key) => key) {
|
||||
if (!level || !form.config_id)
|
||||
throw new Error(translate('请选择客户等级及等级档位'));
|
||||
if (level.is_default || level.key === 'default')
|
||||
throw new Error(translate('默认等级跟随渠道,不能绑定等级档位'));
|
||||
return {
|
||||
level_type: level.type,
|
||||
level_key: level.key,
|
||||
config_id: form.config_id,
|
||||
effective_from: form.effective_from || form.effective_at,
|
||||
};
|
||||
}
|
||||
|
||||
export function getInitialOperationForm(operation, now = Date.now()) {
|
||||
const kind = operation?.kind || '';
|
||||
const row = operation?.row || {};
|
||||
const seconds = Math.floor(now / 1000);
|
||||
|
||||
return {
|
||||
type: 'individual',
|
||||
status: 'protected',
|
||||
method: 'contract_signed',
|
||||
days: 30,
|
||||
effective_at: seconds,
|
||||
fact_at: seconds,
|
||||
source_type: 'channel',
|
||||
rate_bps: 0,
|
||||
effective_from: seconds,
|
||||
...row,
|
||||
...(kind === 'tier-create'
|
||||
? {
|
||||
channel_ids: row.channel_ids?.length
|
||||
? [...row.channel_ids]
|
||||
: row.source_type === 'channel' && row.source_id
|
||||
? [row.source_id]
|
||||
: [],
|
||||
model_names: [...(row.model_names || [])],
|
||||
previous_tier_id: row.id || undefined,
|
||||
effective_from: seconds,
|
||||
}
|
||||
: {}),
|
||||
...(kind === 'partner-create' ? { status: 'draft' } : {}),
|
||||
...(kind === 'assignment-transfer' ? { partner_id: undefined } : {}),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
getInitialOperationForm,
|
||||
validateContractSignedConversion,
|
||||
partnerIdentityPayload,
|
||||
levelBindingPayload,
|
||||
} from './operationForm.js';
|
||||
|
||||
test('company payload requires only organization and omits legacy administrator identity', () => {
|
||||
assert.deepEqual(
|
||||
partnerIdentityPayload({
|
||||
type: 'company',
|
||||
name: '企业',
|
||||
organization_id: 44,
|
||||
user_id: 9,
|
||||
}),
|
||||
{ type: 'company', name: '企业', organization_id: 44 },
|
||||
);
|
||||
assert.throws(
|
||||
() =>
|
||||
partnerIdentityPayload({
|
||||
type: 'individual',
|
||||
name: '个人',
|
||||
organization_id: 44,
|
||||
}),
|
||||
/身份/,
|
||||
);
|
||||
assert.deepEqual(
|
||||
partnerIdentityPayload({
|
||||
type: 'individual',
|
||||
name: '个人',
|
||||
user_id: 9,
|
||||
organization_id: 44,
|
||||
}),
|
||||
{ type: 'individual', name: '个人', user_id: 9 },
|
||||
);
|
||||
});
|
||||
|
||||
test('binding submits configuration identity and selected time for server-side version resolution', () => {
|
||||
assert.deepEqual(
|
||||
levelBindingPayload(
|
||||
{ config_id: 55, tier_id: 999, effective_from: 123 },
|
||||
{ type: 'enterprise', key: 'gold' },
|
||||
),
|
||||
{
|
||||
config_id: 55,
|
||||
effective_from: 123,
|
||||
level_type: 'enterprise',
|
||||
level_key: 'gold',
|
||||
},
|
||||
);
|
||||
assert.throws(
|
||||
() =>
|
||||
levelBindingPayload(
|
||||
{ config_id: 55, effective_from: 123 },
|
||||
{ type: 'enterprise', key: 'default' },
|
||||
),
|
||||
/默认/,
|
||||
);
|
||||
});
|
||||
|
||||
test('contract signing validation explains when the signed date is after conversion time', () => {
|
||||
assert.equal(
|
||||
validateContractSignedConversion(
|
||||
{
|
||||
reference: '1488999',
|
||||
contract_subject: '测试公司',
|
||||
signed_at: 1_000,
|
||||
fact_at: 900,
|
||||
},
|
||||
(key) => key,
|
||||
),
|
||||
'合同签署日期不能晚于实际转化事实时间',
|
||||
);
|
||||
});
|
||||
|
||||
test('contract signing validation accepts a signed date at or before conversion time', () => {
|
||||
assert.equal(
|
||||
validateContractSignedConversion(
|
||||
{
|
||||
reference: '1488999',
|
||||
contract_subject: '测试公司',
|
||||
signed_at: 900,
|
||||
fact_at: 900,
|
||||
},
|
||||
(key) => key,
|
||||
),
|
||||
'',
|
||||
);
|
||||
});
|
||||
|
||||
test('tier editing hydrates legacy channels and starts a new effective version', () => {
|
||||
const form = getInitialOperationForm(
|
||||
{
|
||||
kind: 'tier-create',
|
||||
row: { id: 12, source_type: 'channel', source_id: 7, effective_from: 10 },
|
||||
},
|
||||
200000,
|
||||
);
|
||||
assert.deepEqual(form.channel_ids, [7]);
|
||||
assert.equal(form.previous_tier_id, 12);
|
||||
assert.equal(form.effective_from, 200);
|
||||
});
|
||||
|
||||
test('shared tier editing preserves every model or channel target', () => {
|
||||
const form = getInitialOperationForm({
|
||||
kind: 'tier-create',
|
||||
row: {
|
||||
id: 13,
|
||||
source_type: 'model',
|
||||
model_names: ['gpt-4o', 'gpt-4o-mini'],
|
||||
},
|
||||
});
|
||||
assert.deepEqual(form.model_names, ['gpt-4o', 'gpt-4o-mini']);
|
||||
assert.deepEqual(form.channel_ids, []);
|
||||
});
|
||||
|
||||
test('new partner form always starts in draft status', () => {
|
||||
const form = getInitialOperationForm(
|
||||
{
|
||||
kind: 'partner-create',
|
||||
row: { status: 'protected', display_name: '测试伙伴' },
|
||||
},
|
||||
1_700_000_000_000,
|
||||
);
|
||||
|
||||
assert.equal(form.status, 'draft');
|
||||
assert.equal(form.display_name, '测试伙伴');
|
||||
});
|
||||
|
||||
test('customer assignment form keeps protected status', () => {
|
||||
const form = getInitialOperationForm(
|
||||
{ kind: 'assignment-create', row: {} },
|
||||
1_700_000_000_000,
|
||||
);
|
||||
|
||||
assert.equal(form.status, 'protected');
|
||||
});
|
||||
|
||||
test('editing a partner preserves the row status', () => {
|
||||
const form = getInitialOperationForm(
|
||||
{ kind: 'partner-edit', row: { status: 'active' } },
|
||||
1_700_000_000_000,
|
||||
);
|
||||
|
||||
assert.equal(form.status, 'active');
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
export const PARTNER_NAVIGATION = [
|
||||
{ key: 'overview', label: '分佣概览' },
|
||||
{ key: 'customers', label: '我的客户' },
|
||||
{ key: 'estimate', label: '本月预估' },
|
||||
{ key: 'bills', label: '我的提成' },
|
||||
{ key: 'rules', label: '分佣规则' },
|
||||
];
|
||||
|
||||
export function partnerView(search) {
|
||||
const view = new URLSearchParams(search).get('view');
|
||||
return PARTNER_NAVIGATION.some((item) => item.key === view)
|
||||
? view
|
||||
: 'overview';
|
||||
}
|
||||
@@ -0,0 +1,545 @@
|
||||
.partner-portal .commission-v2-sider {
|
||||
width: 220px !important;
|
||||
flex-basis: 220px !important;
|
||||
}
|
||||
|
||||
/* Organization owns the global header, sidebar and scroll container. */
|
||||
.partner-portal-scope--embedded {
|
||||
display: flex;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
.commission-admin-workspace.partner-portal--embedded {
|
||||
/* 与企业中心其他页面同底色与标准卡片色(不再用分佣旧版灰卡) */
|
||||
--commission-surface-raised: var(--surface-card);
|
||||
flex: 1;
|
||||
margin-top: 0;
|
||||
min-height: 0;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
/* 企业中心「企业分佣」:按带侧栏页面统一规格(GLOBAL_UI_BASELINE §4.4)——
|
||||
面包屑 12/18px、距顶 30px、与标题 24px;标题 28/32px/650;副标题 14/22px;页头与首块 18px;
|
||||
内容边距取 --uc-page-pad-*(桌面 30/36/36,≤768px 16/16/24),不再使用白色面包屑横条。 */
|
||||
.partner-portal--embedded .commission-workspace-bar {
|
||||
flex: none;
|
||||
height: auto;
|
||||
padding: var(--uc-page-pad-top) var(--uc-page-pad-x) 0;
|
||||
border-bottom: 0;
|
||||
background: transparent;
|
||||
color: var(--text-secondary);
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.partner-portal--embedded .commission-workspace-bar b {
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.partner-portal--embedded .commission-crumb-slash {
|
||||
padding: 0 10px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.partner-portal--embedded .commission-v2-content {
|
||||
padding: 24px var(--uc-page-pad-x) var(--uc-page-pad-bottom);
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.partner-portal--embedded .commission-page-header {
|
||||
align-items: flex-end;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.partner-portal--embedded .commission-page-heading h4.ant-typography {
|
||||
color: var(--uc-heading);
|
||||
font-size: 28px;
|
||||
line-height: 32px;
|
||||
font-weight: 650;
|
||||
letter-spacing: -0.6px;
|
||||
}
|
||||
|
||||
.partner-portal--embedded
|
||||
.commission-page-heading
|
||||
> .ant-typography:last-child {
|
||||
margin-top: 6px;
|
||||
color: var(--uc-subtitle);
|
||||
font-size: 14px;
|
||||
line-height: 22px;
|
||||
}
|
||||
|
||||
/* 嵌入控制台(/console/my-commission):伙伴导航按卡片呈现,与内容区间距 24px;
|
||||
窄屏导航堆叠在上方时改为上距 16px(GLOBAL_UI_BASELINE §5 间距 8/16/24) */
|
||||
.console-page
|
||||
.partner-portal:not(.partner-portal--embedded)
|
||||
.commission-v2-sider {
|
||||
align-self: flex-start;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: 10px;
|
||||
}
|
||||
.console-page
|
||||
.partner-portal:not(.partner-portal--embedded)
|
||||
.commission-v2-content {
|
||||
padding: 0 0 0 24px;
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
/* antd 6 Layout hasSider 固定 flex-direction: row,窄屏需显式改为导航在上、内容在下 */
|
||||
.commission-admin-workspace.partner-portal.ant-layout-has-sider {
|
||||
flex-direction: column;
|
||||
}
|
||||
.commission-admin-workspace.partner-portal.ant-layout-has-sider
|
||||
> .ant-layout {
|
||||
width: auto;
|
||||
}
|
||||
.console-page
|
||||
.partner-portal:not(.partner-portal--embedded)
|
||||
.commission-v2-content {
|
||||
padding: 16px 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* antd 6 Layout:内容列允许收缩,避免宽表格撑开侧栏布局 */
|
||||
.commission-admin-workspace.partner-portal > .ant-layout {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* 卡片内边距:UI_COMPONENT_STANDARDS §3(桌面 24px,移动 16px) */
|
||||
.partner-portal-card.ant-card > .ant-card-body {
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
/* 宽卡片铺满,窄屏保留可横向滚动的最小宽度(含账单详情页签) */
|
||||
.commission-v2.partner-portal .ant-table table {
|
||||
min-width: max(100%, 720px);
|
||||
}
|
||||
|
||||
.partner-portal .partner-portal-estimate-table .ant-table table {
|
||||
min-width: max(100%, 520px);
|
||||
}
|
||||
|
||||
.partner-portal .ant-alert,
|
||||
.partner-portal-modal .ant-alert {
|
||||
border-radius: var(--commission-radius);
|
||||
}
|
||||
|
||||
.partner-portal-welcome {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
padding: 10px 14px;
|
||||
border: 1px solid
|
||||
color-mix(in srgb, var(--commission-primary) 24%, transparent);
|
||||
border-radius: 4px;
|
||||
background: var(--commission-primary-soft);
|
||||
color: var(--text-primary);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.partner-portal-welcome > svg {
|
||||
flex-shrink: 0;
|
||||
color: var(--commission-primary-readable);
|
||||
}
|
||||
|
||||
.partner-portal-metrics {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.partner-portal-metrics-three {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.partner-portal-metric {
|
||||
min-width: 0;
|
||||
min-height: 118px;
|
||||
padding: 16px 20px;
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: 4px;
|
||||
background: var(--commission-surface-raised);
|
||||
}
|
||||
|
||||
.partner-portal-metric-label {
|
||||
color: var(--text-tertiary);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.partner-portal-metric-value {
|
||||
margin-top: 6px;
|
||||
color: var(--text-primary);
|
||||
font-size: 28px;
|
||||
font-weight: 600;
|
||||
font-variant-numeric: tabular-nums;
|
||||
line-height: 36px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.partner-portal-metric.is-primary .partner-portal-metric-value {
|
||||
color: var(--commission-primary-readable);
|
||||
}
|
||||
|
||||
.partner-portal-metric-note {
|
||||
margin-top: 6px;
|
||||
color: var(--text-tertiary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.partner-portal-two-columns {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
align-items: stretch;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.partner-portal-two-columns > .commission-card {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.partner-portal-card-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-bottom: 16px;
|
||||
color: var(--text-primary);
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.partner-portal-card-title > span {
|
||||
color: var(--text-tertiary);
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.partner-portal-chart {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: space-around;
|
||||
gap: 12px;
|
||||
min-height: 208px;
|
||||
padding: 12px 4px 0;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.partner-portal-chart-column {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
min-width: max-content;
|
||||
}
|
||||
|
||||
.partner-portal-chart-value {
|
||||
margin-bottom: 7px;
|
||||
color: var(--text-secondary);
|
||||
font-size: 11px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.partner-portal-chart-bar {
|
||||
width: min(100%, 40px);
|
||||
border-radius: 2px 2px 0 0;
|
||||
background: var(--commission-primary-hover);
|
||||
}
|
||||
|
||||
.partner-portal-chart-bar.is-negative {
|
||||
background: #f76560;
|
||||
}
|
||||
|
||||
.partner-portal-chart-label {
|
||||
margin-top: 10px;
|
||||
color: var(--text-tertiary);
|
||||
font-size: 11px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.partner-portal-reminders {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.partner-portal-reminder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
min-height: 66px;
|
||||
padding: 12px 0;
|
||||
border: 0;
|
||||
border-bottom: 1px solid var(--surface-bg-base);
|
||||
background: var(--surface-card);
|
||||
color: var(--text-secondary);
|
||||
font: inherit;
|
||||
font-size: 13px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
button.partner-portal-reminder {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button.partner-portal-reminder:hover {
|
||||
color: var(--commission-primary-readable);
|
||||
}
|
||||
|
||||
.partner-portal-reminder:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.partner-portal-reminder > span:nth-child(2) {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.partner-portal-reminder small {
|
||||
display: block;
|
||||
margin-top: 3px;
|
||||
color: var(--text-tertiary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.partner-portal-reminder-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
border-radius: 4px;
|
||||
background: var(--commission-primary-soft);
|
||||
color: var(--commission-primary-readable);
|
||||
}
|
||||
|
||||
.partner-portal-reminder-icon.is-warning {
|
||||
background: var(--commission-warning-soft);
|
||||
color: var(--commission-warning);
|
||||
}
|
||||
|
||||
.partner-portal-filters {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.partner-portal-filters > .ant-input-affix-wrapper,
|
||||
.partner-portal-filters > .ant-input {
|
||||
width: 280px;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.partner-portal-filters > .ant-select {
|
||||
min-width: 150px;
|
||||
}
|
||||
|
||||
.partner-portal-filters > .ant-typography {
|
||||
margin-left: auto;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.partner-portal-card .ant-alert {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
/* 行操作:UI_COMPONENT_STANDARDS §5.2 link + small,间距 8px,危险操作 danger */
|
||||
.partner-portal-row-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.partner-portal .partner-portal-row-actions .ant-btn-link {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.partner-portal-mono {
|
||||
font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace;
|
||||
}
|
||||
|
||||
.partner-portal-hint {
|
||||
margin: 12px 0 0;
|
||||
color: var(--text-tertiary);
|
||||
font-size: 12px;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.partner-portal-detail-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
color: var(--text-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.partner-portal-detail-meta + .ant-alert {
|
||||
margin-top: 12px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.partner-portal .partner-portal-back.ant-btn {
|
||||
height: 24px;
|
||||
margin: 0 0 8px;
|
||||
padding: 0;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.partner-portal .commission-tier-summary > .ant-typography {
|
||||
/* The surrounding partner card already names this summary. */
|
||||
display: none;
|
||||
}
|
||||
|
||||
.partner-portal-detail-search {
|
||||
max-width: 360px;
|
||||
margin: 8px 0 12px;
|
||||
}
|
||||
|
||||
.partner-portal-loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 220px;
|
||||
}
|
||||
|
||||
.partner-portal-rule-block {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.partner-portal-rule-block h3 {
|
||||
margin: 0 0 8px;
|
||||
color: var(--text-primary);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.partner-portal-rule-block p,
|
||||
.partner-portal-rule-list {
|
||||
margin: 0;
|
||||
color: var(--text-secondary);
|
||||
font-size: 13px;
|
||||
line-height: 1.9;
|
||||
}
|
||||
|
||||
.partner-portal-rule-list {
|
||||
margin-bottom: 16px;
|
||||
padding-left: 22px;
|
||||
}
|
||||
|
||||
.partner-portal-rule-list li {
|
||||
margin-bottom: 14px;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.partner-portal-modal .ant-alert {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.partner-portal-reason-label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
color: var(--text-primary);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.partner-portal-reason-label span {
|
||||
margin-left: 4px;
|
||||
color: var(--ant-color-error);
|
||||
}
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
.partner-portal-metrics {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.partner-portal-two-columns {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.partner-portal-metrics-three > :last-child {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.partner-portal .commission-v2-sider {
|
||||
width: 168px !important;
|
||||
flex-basis: 168px !important;
|
||||
}
|
||||
|
||||
.partner-portal .commission-brand {
|
||||
padding: 0 12px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.partner-portal .commission-page-header {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.partner-portal .commission-actions {
|
||||
max-width: 100%;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.partner-portal .commission-workspace-role {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.partner-portal--embedded .commission-page-header {
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.partner-portal--embedded .commission-page-heading {
|
||||
flex: 1;
|
||||
min-width: 180px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.partner-portal .commission-v2-sider {
|
||||
width: 100% !important;
|
||||
flex-basis: auto !important;
|
||||
}
|
||||
|
||||
.partner-portal .partner-portal-card.ant-card > .ant-card-body {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.partner-portal-filters {
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.partner-portal-filters > .ant-input-affix-wrapper,
|
||||
.partner-portal-filters > .ant-input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.partner-portal-filters > .ant-select {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.partner-portal-filters > .ant-typography {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.partner-portal-metric {
|
||||
min-height: 104px;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.partner-portal-metric-value {
|
||||
font-size: 24px;
|
||||
line-height: 32px;
|
||||
}
|
||||
|
||||
.partner-portal-card-title {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
const PARTNER_PREFIX = '/api/partner/v2';
|
||||
|
||||
export function partnerScope(userId, organizationId = null) {
|
||||
const enterprise = organizationId !== null && organizationId !== undefined;
|
||||
const org = Number(organizationId);
|
||||
return {
|
||||
key: `${Number(userId) || 0}:${enterprise ? org : 'personal'}`,
|
||||
valid:
|
||||
Number(userId) > 0 &&
|
||||
(!enterprise || (Number.isSafeInteger(org) && org > 0)),
|
||||
enterprise,
|
||||
organizationId: enterprise ? org : null,
|
||||
headers: enterprise ? { 'X-Org-Id': String(org) } : {},
|
||||
url(value) {
|
||||
if (!value.startsWith(`${PARTNER_PREFIX}/`))
|
||||
throw new Error('仅允许访问伙伴接口');
|
||||
return enterprise
|
||||
? `/api/org/commission${value.slice(PARTNER_PREFIX.length)}`
|
||||
: value;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// Capture one immutable scope. Neither future localStorage changes nor callers'
|
||||
// headers may reinterpret a queued operation as another enterprise's request.
|
||||
export function createPartnerTransport(scope, api, isCurrent) {
|
||||
const check = () => {
|
||||
if (!scope.valid || !isCurrent())
|
||||
throw new Error('企业或登录身份已切换,请重新操作');
|
||||
};
|
||||
const configFor = (config = {}) => ({
|
||||
...config,
|
||||
skipErrorHandler: true,
|
||||
headers: { ...config.headers, ...scope.headers },
|
||||
});
|
||||
return {
|
||||
async fetchJSON(url, config) {
|
||||
check();
|
||||
const response = await api.get(scope.url(url), configFor(config));
|
||||
check();
|
||||
if (!response.data?.success)
|
||||
throw new Error(response.data?.message || '加载失败');
|
||||
return response.data.data || [];
|
||||
},
|
||||
async mutateJSON(method, url, body) {
|
||||
check();
|
||||
const response = await api[method](scope.url(url), body, configFor());
|
||||
check();
|
||||
if (!response.data?.success)
|
||||
throw new Error(response.data?.message || '操作失败');
|
||||
return response.data.data;
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { partnerScope, createPartnerTransport } from './partnerScope.js';
|
||||
|
||||
test('enterprise transport pins organization headers for both reads and confirmations', async () => {
|
||||
const calls = [];
|
||||
const api = {
|
||||
get: async (...args) => {
|
||||
calls.push(args);
|
||||
return { data: { success: true, data: { id: 3 } } };
|
||||
},
|
||||
post: async (...args) => {
|
||||
calls.push(args);
|
||||
return { data: { success: true } };
|
||||
},
|
||||
};
|
||||
const scope = partnerScope(9, 101);
|
||||
const client = createPartnerTransport(scope, api, () => true);
|
||||
await client.fetchJSON('/api/partner/v2/statements', {
|
||||
headers: { 'X-Org-Id': '102' },
|
||||
});
|
||||
await client.mutateJSON('post', '/api/partner/v2/statements/3/transition', {
|
||||
to: 'confirmed',
|
||||
});
|
||||
assert.equal(calls[0][0], '/api/org/commission/statements');
|
||||
assert.equal(calls[0][1].headers['X-Org-Id'], '101');
|
||||
assert.equal(calls[1][0], '/api/org/commission/statements/3/transition');
|
||||
assert.equal(calls[1][2].headers['X-Org-Id'], '101');
|
||||
});
|
||||
|
||||
test('old scope cannot dispatch queued confirmations and late reads are discarded', async () => {
|
||||
let current = true,
|
||||
writes = 0,
|
||||
resolve;
|
||||
const response = new Promise((done) => {
|
||||
resolve = done;
|
||||
});
|
||||
const api = {
|
||||
get: () => response,
|
||||
post: async () => {
|
||||
writes++;
|
||||
return { data: { success: true } };
|
||||
},
|
||||
};
|
||||
const client = createPartnerTransport(
|
||||
partnerScope(9, 101),
|
||||
api,
|
||||
() => current,
|
||||
);
|
||||
const pending = client.fetchJSON('/api/partner/v2/summary');
|
||||
current = false;
|
||||
await assert.rejects(
|
||||
client.mutateJSON('post', '/api/partner/v2/statements/1/transition', {}),
|
||||
/切换/,
|
||||
);
|
||||
assert.equal(writes, 0);
|
||||
resolve({ data: { success: true, data: { name: 'old organization' } } });
|
||||
await assert.rejects(pending, /切换/);
|
||||
});
|
||||
|
||||
test('personal and enterprise identities never share cache keys or endpoints', () => {
|
||||
const personal = partnerScope(9),
|
||||
enterprise = partnerScope(9, 101);
|
||||
assert.notEqual(personal.key, enterprise.key);
|
||||
assert.notEqual(enterprise.key, partnerScope(9, 102).key);
|
||||
assert.notEqual(enterprise.key, partnerScope(10, 101).key);
|
||||
assert.equal(
|
||||
personal.url('/api/partner/v2/summary'),
|
||||
'/api/partner/v2/summary',
|
||||
);
|
||||
// 入口探测:个人与企业作用域分别命中各自的 access 接口
|
||||
assert.equal(
|
||||
personal.url('/api/partner/v2/access'),
|
||||
'/api/partner/v2/access',
|
||||
);
|
||||
assert.equal(
|
||||
enterprise.url('/api/partner/v2/access'),
|
||||
'/api/org/commission/access',
|
||||
);
|
||||
assert.equal(partnerScope(9, 0).valid, false);
|
||||
assert.throws(
|
||||
() => enterprise.url('/api/commission/v2/partners'),
|
||||
/伙伴接口/,
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,978 @@
|
||||
/* Product prototype tokens are scoped to the commission workspace and portals. */
|
||||
.commission-v2,
|
||||
.commission-modal,
|
||||
.commission-profile-drawer,
|
||||
.commission-partner-sheet {
|
||||
/* 新版分佣只消费全局主题 token,主题色和明暗模式由控制台统一驱动。 */
|
||||
--commission-primary: var(--brand-primary);
|
||||
--commission-primary-hover: var(--brand-primary-hover);
|
||||
--commission-primary-soft: var(--brand-primary-soft);
|
||||
/* Links on dark surfaces need a lighter reading color than the brand swatch. */
|
||||
--commission-primary-readable: color-mix(
|
||||
in srgb,
|
||||
var(--commission-primary) 58%,
|
||||
var(--text-primary)
|
||||
);
|
||||
/* White text on the default brand blue is below AA contrast; deepen solid fills. */
|
||||
--commission-primary-solid: color-mix(
|
||||
in srgb,
|
||||
var(--commission-primary) 78%,
|
||||
#000
|
||||
);
|
||||
--commission-success: color-mix(in srgb, #22c55e 78%, var(--text-primary));
|
||||
--commission-success-soft: color-mix(
|
||||
in srgb,
|
||||
#22c55e 12%,
|
||||
var(--surface-card)
|
||||
);
|
||||
--commission-warning: color-mix(in srgb, #f59e0b 82%, var(--text-primary));
|
||||
--commission-warning-soft: color-mix(
|
||||
in srgb,
|
||||
#f59e0b 12%,
|
||||
var(--surface-card)
|
||||
);
|
||||
--commission-danger: color-mix(in srgb, #f56c7a 82%, var(--text-primary));
|
||||
--commission-danger-soft: color-mix(
|
||||
in srgb,
|
||||
#f56c7a 12%,
|
||||
var(--surface-card)
|
||||
);
|
||||
--commission-info: color-mix(in srgb, #22d3ee 78%, var(--text-primary));
|
||||
--commission-info-soft: color-mix(in srgb, #22d3ee 12%, var(--surface-card));
|
||||
--text-tertiary: var(--text-secondary);
|
||||
--commission-radius: 4px;
|
||||
--commission-control-height: 32px;
|
||||
--commission-surface-raised: color-mix(
|
||||
in srgb,
|
||||
var(--surface-card) 94%,
|
||||
var(--text-primary)
|
||||
);
|
||||
--commission-surface-toolbar: color-mix(
|
||||
in srgb,
|
||||
var(--surface-card) 86%,
|
||||
var(--surface-bg-base)
|
||||
);
|
||||
--commission-surface-control: color-mix(
|
||||
in srgb,
|
||||
var(--surface-card) 78%,
|
||||
var(--surface-bg-base)
|
||||
);
|
||||
--commission-border-strong: color-mix(
|
||||
in srgb,
|
||||
var(--border-subtle) 78%,
|
||||
var(--text-primary)
|
||||
);
|
||||
/* Controls need a distinct resting edge on dark cards. Keep the value
|
||||
* derived from the global theme so custom brand and light themes still
|
||||
* follow the console palette. */
|
||||
--commission-control-border: var(--commission-border-strong);
|
||||
--commission-control-border-hover: color-mix(
|
||||
in srgb,
|
||||
var(--commission-primary) 52%,
|
||||
var(--commission-control-border)
|
||||
);
|
||||
--commission-control-focus-ring: color-mix(
|
||||
in srgb,
|
||||
var(--commission-primary) 28%,
|
||||
transparent
|
||||
);
|
||||
color: var(--text-primary);
|
||||
font-family:
|
||||
-apple-system, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Arial,
|
||||
sans-serif;
|
||||
font-size: 14px;
|
||||
line-height: 1.5715;
|
||||
}
|
||||
.commission-v2 {
|
||||
min-height: calc(100vh - var(--app-header-height, 64px));
|
||||
background: var(--surface-bg-base);
|
||||
}
|
||||
.commission-admin-workspace {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-top: var(--app-header-height, 64px);
|
||||
width: 100%;
|
||||
align-items: stretch;
|
||||
}
|
||||
/* 嵌入控制台外壳(ConsolePageContainer 已提供页头、面包屑与内边距)时:
|
||||
去掉旧布局为固定顶栏预留的偏移与整屏最小高度,并隐藏重复的面包屑条 */
|
||||
.console-page .commission-admin-workspace {
|
||||
margin-top: 0;
|
||||
min-height: 0;
|
||||
}
|
||||
.console-page .commission-admin-workspace .commission-workspace-bar {
|
||||
display: none;
|
||||
}
|
||||
.console-page .commission-admin-workspace .commission-v2-content {
|
||||
padding: 0;
|
||||
}
|
||||
/* 嵌入控制台时与其他控制台页面同一套底色:外层透出控制台页面底,卡片用标准卡片色,区块间距 18px。
|
||||
原 !important 用于压 Semi Layout 背景,Semi 已移除,故去掉以便此处按作用域覆盖。 */
|
||||
.console-page .commission-admin-workspace,
|
||||
.console-page .commission-admin-workspace .commission-v2-content {
|
||||
background: transparent;
|
||||
}
|
||||
.console-page .commission-admin-workspace {
|
||||
--commission-surface-raised: var(--surface-card);
|
||||
}
|
||||
.console-page .commission-admin-workspace .commission-card {
|
||||
margin-top: 18px;
|
||||
}
|
||||
.console-page
|
||||
.commission-admin-workspace
|
||||
.commission-v2-content
|
||||
> .commission-card:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
/* 嵌入控制台时页面标题即控制台页标题:沿用控制台页头规格(28/32px/650、副标题 14/22px、与首块 18px) */
|
||||
.console-page .commission-admin-workspace .commission-page-header {
|
||||
align-items: flex-end;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
.console-page
|
||||
.commission-admin-workspace
|
||||
.commission-page-heading
|
||||
h4.ant-typography {
|
||||
color: var(--text-primary);
|
||||
font-size: 28px;
|
||||
line-height: 32px;
|
||||
font-weight: 650;
|
||||
letter-spacing: -0.6px;
|
||||
}
|
||||
.console-page
|
||||
.commission-admin-workspace
|
||||
.commission-page-heading
|
||||
> .ant-typography:last-child {
|
||||
margin-top: 6px;
|
||||
color: var(--text-secondary);
|
||||
font-size: 14px;
|
||||
line-height: 22px;
|
||||
}
|
||||
.commission-admin-workspace > .commission-admin-main {
|
||||
display: flex;
|
||||
flex: auto;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
}
|
||||
.commission-v2-sider {
|
||||
flex: 0 0 220px;
|
||||
width: 220px;
|
||||
background: var(--surface-sidebar);
|
||||
border-right: 1px solid var(--border-subtle);
|
||||
}
|
||||
.commission-brand {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
height: 56px;
|
||||
padding: 0 20px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
border-bottom: 1px solid var(--border-subtle);
|
||||
}
|
||||
.commission-brand-mark {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
flex-shrink: 0;
|
||||
border-radius: 4px;
|
||||
background: var(--commission-primary-solid);
|
||||
}
|
||||
.commission-navigation {
|
||||
padding: 8px 8px 16px;
|
||||
}
|
||||
.commission-nav-group {
|
||||
padding: 14px 12px 6px;
|
||||
color: var(--text-tertiary);
|
||||
font-size: 12px;
|
||||
}
|
||||
.commission-nav-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
height: 38px;
|
||||
margin: 2px 0;
|
||||
padding: 0 12px;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
background: transparent;
|
||||
color: var(--text-secondary);
|
||||
font: inherit;
|
||||
font-size: 14px;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
.commission-nav-item svg {
|
||||
flex-shrink: 0;
|
||||
stroke-width: 2px;
|
||||
}
|
||||
.commission-nav-item:hover {
|
||||
background: var(--surface-bg-base);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.commission-nav-item.is-active {
|
||||
background: var(--commission-primary-soft);
|
||||
color: var(--commission-primary-readable);
|
||||
font-weight: 500;
|
||||
box-shadow: inset 2px 0 0 var(--commission-primary);
|
||||
}
|
||||
.commission-nav-item:focus-visible {
|
||||
outline: 2px solid var(--commission-primary);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
.commission-nav-badge {
|
||||
margin-left: auto;
|
||||
padding: 0 6px;
|
||||
border-radius: 8px;
|
||||
color: #fff;
|
||||
background: #f53f3f;
|
||||
font-size: 12px;
|
||||
line-height: 16px;
|
||||
}
|
||||
.commission-workspace-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex: 0 0 56px;
|
||||
height: 56px;
|
||||
padding: 0 20px;
|
||||
background: var(--surface-header);
|
||||
border-bottom: 1px solid var(--border-subtle);
|
||||
color: var(--text-tertiary);
|
||||
font-size: 13px;
|
||||
}
|
||||
.commission-workspace-bar b {
|
||||
color: var(--text-primary);
|
||||
font-weight: 500;
|
||||
}
|
||||
.commission-crumb-slash {
|
||||
padding: 0 8px;
|
||||
color: #c9cdd4;
|
||||
}
|
||||
.commission-workspace-role {
|
||||
padding: 3px 12px;
|
||||
border-radius: 3px;
|
||||
background: var(--commission-primary-soft);
|
||||
color: var(--commission-primary-readable);
|
||||
}
|
||||
.commission-v2-content {
|
||||
min-width: 0;
|
||||
padding: 16px 20px 32px;
|
||||
background: var(--surface-bg-base);
|
||||
}
|
||||
.commission-page-header {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.commission-page-heading {
|
||||
min-width: 0;
|
||||
}
|
||||
.commission-page-heading h4.ant-typography {
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
line-height: 28px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.commission-page-heading > .ant-typography:last-child {
|
||||
display: block;
|
||||
margin-top: 2px;
|
||||
color: var(--text-tertiary);
|
||||
font-size: 13px;
|
||||
}
|
||||
.commission-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
flex-shrink: 0;
|
||||
max-width: 65%;
|
||||
}
|
||||
.commission-actions .ant-picker {
|
||||
width: 138px;
|
||||
}
|
||||
.commission-card {
|
||||
margin-top: 12px;
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: 10px;
|
||||
background: var(--commission-surface-raised);
|
||||
box-shadow: none;
|
||||
}
|
||||
.commission-v2-content > .commission-card:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
.commission-card > .ant-card-body > h5.ant-typography {
|
||||
margin: 0 0 12px;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
}
|
||||
.commission-row-actions {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: nowrap;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.commission-row-actions .commission-more-actions {
|
||||
position: relative;
|
||||
}
|
||||
.commission-entity {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
min-width: 100px;
|
||||
}
|
||||
.commission-entity-name {
|
||||
color: var(--text-primary);
|
||||
font-weight: 500;
|
||||
}
|
||||
.commission-entity-reference {
|
||||
max-width: 380px;
|
||||
color: var(--text-tertiary);
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.commission-entity--compact .commission-entity-reference {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
}
|
||||
.commission-v2 .commission-status {
|
||||
height: 22px;
|
||||
padding: 0 8px;
|
||||
border-radius: 2px;
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.commission-muted {
|
||||
color: var(--text-tertiary);
|
||||
font-size: 12px;
|
||||
}
|
||||
.commission-money {
|
||||
font-variant-numeric: tabular-nums;
|
||||
font-weight: 500;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.commission-list-tabs {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
gap: 4px;
|
||||
overflow-x: auto;
|
||||
border-bottom: 1px solid var(--commission-border-strong);
|
||||
padding: 0 4px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.commission-list-tabs > button {
|
||||
position: relative;
|
||||
flex-shrink: 0;
|
||||
padding: 10px 16px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
font: inherit;
|
||||
color: var(--text-secondary);
|
||||
cursor: pointer;
|
||||
}
|
||||
.commission-list-tabs > button:hover {
|
||||
color: var(--commission-primary-readable);
|
||||
}
|
||||
.commission-list-tabs > button.is-active {
|
||||
color: var(--commission-primary-readable);
|
||||
font-weight: 500;
|
||||
}
|
||||
.commission-list-tabs > button.is-active::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 12px;
|
||||
right: 12px;
|
||||
height: 2px;
|
||||
background: var(--commission-primary);
|
||||
}
|
||||
.commission-list-tabs > button > span {
|
||||
margin-left: 6px;
|
||||
padding: 0 6px;
|
||||
border-radius: 8px;
|
||||
background: var(--surface-bg-base);
|
||||
color: var(--text-tertiary);
|
||||
font-size: 12px;
|
||||
}
|
||||
.commission-list-tabs > button.is-active > span {
|
||||
color: var(--commission-primary-readable);
|
||||
background: var(--commission-primary-soft);
|
||||
}
|
||||
.commission-filter-bar {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: 4px;
|
||||
background: var(--commission-surface-toolbar);
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.commission-filter-bar > .ant-input-affix-wrapper {
|
||||
width: 220px;
|
||||
}
|
||||
.commission-filter-bar > .ant-select {
|
||||
min-width: 140px;
|
||||
max-width: 200px;
|
||||
}
|
||||
.commission-filter-end {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-left: auto;
|
||||
color: var(--text-tertiary);
|
||||
font-size: 12px;
|
||||
}
|
||||
.commission-loading {
|
||||
min-height: 360px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
}
|
||||
/* 页面级提示与弹层内提示统一使用 antd Alert 默认外观,只补块间距。 */
|
||||
.commission-v2 .ant-alert,
|
||||
.commission-inline-alert.ant-alert {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.commission-modal {
|
||||
max-width: calc(100vw - 32px);
|
||||
}
|
||||
.commission-modal .ant-modal-body {
|
||||
max-height: min(68vh, 680px);
|
||||
overflow-y: auto;
|
||||
}
|
||||
.commission-modal .ant-modal-body > .ant-spin {
|
||||
min-height: 160px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.commission-modal .ant-modal-body > .ant-typography {
|
||||
display: block;
|
||||
margin-top: 12px;
|
||||
font-size: 12px;
|
||||
line-height: 20px;
|
||||
}
|
||||
.commission-modal-alert {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.commission-operation-form {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 16px;
|
||||
padding: 0;
|
||||
}
|
||||
.commission-operation-form > .ant-alert,
|
||||
.commission-operation-form > .commission-tier-targets,
|
||||
.commission-operation-form > .ant-descriptions,
|
||||
.commission-operation-form > .commission-evidence-input,
|
||||
.commission-operation-form > .commission-tier-summary,
|
||||
.commission-operation-form > .commission-form-field:has(textarea),
|
||||
.commission-operation-form
|
||||
> .commission-form-field:has(.commission-evidence-input) {
|
||||
grid-column: 1/-1;
|
||||
}
|
||||
.commission-form-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
gap: 6px;
|
||||
color: var(--text-secondary);
|
||||
font-size: 14px;
|
||||
}
|
||||
.commission-form-field .ant-select {
|
||||
width: 100%;
|
||||
}
|
||||
.commission-tier-targets {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
gap: 8px;
|
||||
}
|
||||
.commission-tier-targets .ant-select {
|
||||
height: auto;
|
||||
min-height: 32px;
|
||||
}
|
||||
.commission-field-hint {
|
||||
color: var(--text-tertiary);
|
||||
font-size: 12px;
|
||||
line-height: 20px;
|
||||
}
|
||||
.commission-checklist {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
padding: 12px 14px;
|
||||
grid-column: 1/-1;
|
||||
border-radius: 4px;
|
||||
background: var(--surface-bg-base);
|
||||
}
|
||||
.commission-checklist .ant-checkbox-wrapper {
|
||||
line-height: 22px;
|
||||
}
|
||||
.commission-picker-content,
|
||||
.commission-confirm-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
.commission-picker-content .ant-typography,
|
||||
.commission-confirm-content .ant-typography {
|
||||
margin: 0;
|
||||
line-height: 20px;
|
||||
}
|
||||
.commission-history-table {
|
||||
grid-column: 1/-1;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
.commission-history-table table {
|
||||
min-width: 760px;
|
||||
table-layout: fixed;
|
||||
}
|
||||
.commission-history-table .ant-table-thead > tr > th {
|
||||
padding: 10px 14px;
|
||||
background: var(--surface-bg-base);
|
||||
color: var(--text-primary);
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.commission-history-table .ant-table-tbody > tr > td {
|
||||
padding: 11px 14px;
|
||||
color: var(--text-secondary);
|
||||
line-height: 20px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.commission-history-nowrap {
|
||||
white-space: nowrap;
|
||||
}
|
||||
.commission-exception-content {
|
||||
grid-column: 1/-1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
.commission-exception-content .ant-descriptions {
|
||||
padding: 12px;
|
||||
border-radius: 4px;
|
||||
background: var(--surface-bg-base);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.commission-evidence-input {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
gap: 8px;
|
||||
}
|
||||
.commission-evidence-input-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
}
|
||||
.commission-evidence-upload-button {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 108px;
|
||||
height: 32px;
|
||||
gap: 7px;
|
||||
padding: 0 14px;
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: 4px;
|
||||
background: var(--surface-card);
|
||||
color: var(--commission-primary-readable);
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
}
|
||||
.commission-evidence-upload-button:hover {
|
||||
border-color: var(--commission-primary);
|
||||
background: var(--commission-primary-soft);
|
||||
}
|
||||
.commission-evidence-upload-button input {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
.commission-evidence-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
gap: 10px;
|
||||
color: var(--text-tertiary);
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
}
|
||||
.commission-evidence-file {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
color: var(--text-secondary);
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.commission-evidence-meta .ant-btn {
|
||||
height: 24px;
|
||||
padding: 0 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.commission-detail-toolbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.commission-detail-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.statement-summary-heading {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
gap: 16px;
|
||||
}
|
||||
.statement-summary-heading .ant-typography {
|
||||
margin-top: 0;
|
||||
}
|
||||
.statement-summary-values {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.statement-summary-values > div {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
padding: 16px 20px;
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: 4px;
|
||||
background: var(--surface-card);
|
||||
}
|
||||
.statement-summary-values > div:last-child {
|
||||
border-color: color-mix(in srgb, var(--commission-primary) 24%, transparent);
|
||||
background: var(--commission-primary-soft);
|
||||
}
|
||||
.statement-summary-values .ant-typography {
|
||||
color: var(--text-tertiary);
|
||||
font-size: 13px;
|
||||
}
|
||||
.statement-summary-values strong {
|
||||
font-size: 26px;
|
||||
color: var(--text-primary);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.statement-summary-values > div:last-child strong {
|
||||
color: var(--commission-primary-readable);
|
||||
}
|
||||
.commission-detail-tabs {
|
||||
margin-top: 12px;
|
||||
padding: 0 20px 16px;
|
||||
border-radius: 4px;
|
||||
background: var(--surface-card);
|
||||
}
|
||||
.commission-tier-summary {
|
||||
margin: 12px 0;
|
||||
overflow: auto;
|
||||
}
|
||||
.commission-tier-summary > .ant-typography {
|
||||
margin: 0 0 12px;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
}
|
||||
.commission-bill-steps {
|
||||
display: flex;
|
||||
margin: 20px 0 4px;
|
||||
}
|
||||
.commission-bill-step {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
color: var(--text-tertiary);
|
||||
font-size: 13px;
|
||||
}
|
||||
.commission-bill-step::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
left: 50%;
|
||||
width: 100%;
|
||||
height: 1px;
|
||||
background: var(--border-subtle);
|
||||
}
|
||||
.commission-bill-step:last-child::after {
|
||||
display: none;
|
||||
}
|
||||
.commission-bill-step > span {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border-radius: 50%;
|
||||
background: var(--surface-bg-base);
|
||||
}
|
||||
.commission-bill-step.is-current {
|
||||
color: var(--commission-primary-readable);
|
||||
font-weight: 500;
|
||||
}
|
||||
.commission-bill-step.is-current > span,
|
||||
.commission-bill-step.is-done > span {
|
||||
background: var(--commission-primary);
|
||||
color: #fff;
|
||||
}
|
||||
.commission-bill-step.is-done::after {
|
||||
background: var(--commission-primary);
|
||||
}
|
||||
.commission-profile-drawer .ant-drawer-body {
|
||||
padding: 24px;
|
||||
background: var(--surface-bg-base);
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
.commission-drawer-spin {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 48px 0;
|
||||
}
|
||||
.commission-drawer-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 14px;
|
||||
}
|
||||
.commission-profile-section {
|
||||
margin-bottom: 12px;
|
||||
padding: 16px 20px;
|
||||
border-radius: 4px;
|
||||
background: var(--surface-card);
|
||||
}
|
||||
.commission-profile-section h3 {
|
||||
margin: 0 0 12px;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
}
|
||||
.commission-profile-section .ant-descriptions {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.commission-timeline > div {
|
||||
position: relative;
|
||||
padding: 0 0 16px 20px;
|
||||
border-left: 1px solid var(--border-subtle);
|
||||
}
|
||||
.commission-timeline > div::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 6px;
|
||||
left: -4px;
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
border-radius: 50%;
|
||||
background: var(--commission-primary);
|
||||
}
|
||||
.commission-timeline p {
|
||||
margin: 4px 0 0;
|
||||
color: var(--text-tertiary);
|
||||
font-size: 12px;
|
||||
}
|
||||
.partner-statements {
|
||||
margin-top: calc(var(--app-header-height, 64px) - 24px);
|
||||
padding: 16px 20px 32px;
|
||||
}
|
||||
.partner-statements > .commission-v2-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.partner-statements > .commission-v2-header h4 {
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
}
|
||||
.commission-detail-total {
|
||||
margin: 10px 0;
|
||||
color: var(--commission-primary-readable);
|
||||
font-size: 30px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.commission-todos {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
padding-top: 12px;
|
||||
}
|
||||
@media (max-width: 1100px) {
|
||||
.commission-v2-sider {
|
||||
flex-basis: 200px;
|
||||
width: 200px;
|
||||
}
|
||||
.commission-page-header {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.commission-actions {
|
||||
max-width: 100%;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
.statement-summary-values {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
.commission-admin-workspace {
|
||||
flex-direction: column;
|
||||
}
|
||||
.commission-v2-sider {
|
||||
flex: 0 0 auto;
|
||||
width: 100%;
|
||||
border-right: 0;
|
||||
border-bottom: 1px solid var(--border-subtle);
|
||||
}
|
||||
.commission-brand {
|
||||
display: none;
|
||||
}
|
||||
.commission-navigation {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
overflow-x: auto;
|
||||
padding: 8px;
|
||||
}
|
||||
.commission-nav-group {
|
||||
display: none;
|
||||
}
|
||||
.commission-nav-item {
|
||||
width: auto;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
.commission-workspace-bar {
|
||||
height: 44px;
|
||||
flex-basis: 44px;
|
||||
padding: 0 16px;
|
||||
}
|
||||
.commission-v2-content,
|
||||
.partner-statements {
|
||||
padding: 16px;
|
||||
}
|
||||
.commission-page-header {
|
||||
gap: 12px;
|
||||
}
|
||||
.commission-actions {
|
||||
gap: 8px;
|
||||
}
|
||||
.commission-filter-end {
|
||||
margin-left: 0;
|
||||
}
|
||||
.commission-filter-bar > .ant-input-affix-wrapper {
|
||||
width: 100%;
|
||||
}
|
||||
.commission-filter-bar > .ant-select {
|
||||
flex: 1;
|
||||
min-width: 120px;
|
||||
}
|
||||
.commission-list > .ant-card-body {
|
||||
padding: 12px !important;
|
||||
}
|
||||
.commission-list-tabs > button {
|
||||
padding: 10px 12px;
|
||||
}
|
||||
.commission-operation-form {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.commission-evidence-input-row {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.commission-evidence-upload-button {
|
||||
width: 100%;
|
||||
}
|
||||
.commission-modal {
|
||||
max-width: calc(100vw - 24px);
|
||||
}
|
||||
.commission-detail-toolbar {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
}
|
||||
.commission-detail-actions {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
.statement-summary-heading {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.statement-summary-values > div {
|
||||
padding: 12px;
|
||||
}
|
||||
.statement-summary-values strong {
|
||||
font-size: 22px;
|
||||
}
|
||||
.commission-history-table table {
|
||||
min-width: 680px;
|
||||
}
|
||||
}
|
||||
|
||||
.commission-code {
|
||||
font-family: Consolas, Menlo, monospace;
|
||||
font-size: 13px;
|
||||
}
|
||||
.commission-protection-period {
|
||||
white-space: nowrap;
|
||||
font-size: 13px;
|
||||
}
|
||||
.commission-protection-period span {
|
||||
color: var(--text-tertiary);
|
||||
margin-right: 4px;
|
||||
}
|
||||
.commission-protection-period small {
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
.commission-protection-period small.is-urgent {
|
||||
color: var(--commission-warning);
|
||||
}
|
||||
.commission-context-filter {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
color: var(--commission-primary-readable);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.commission-deduction-summary {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
margin: 12px 0 20px;
|
||||
padding: 16px;
|
||||
background: var(--surface-bg-base);
|
||||
border-radius: 4px;
|
||||
}
|
||||
.commission-deduction-summary > div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
font-size: 13px;
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.commission-deduction-summary {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user