fix(ui): 统一三中心表格交互并优化企业及配套页面
- 公共表格:统一分组标签、状态开关和危险操作确认,支持防重复提交和失败重试,修复浮层触发组件的 ref 转发。 - 控制台:统一用户和渠道编辑抽屉,修正分组回填与提交格式,对齐系统设置操作区和预约列表。 - 企业中心:调整技能中心页签和窄屏布局,优化质量监控提示栏、效能分析及成本对账,统一消耗明细和审计日志筛选。 - 用户中心及公共页面:优化密钥和消费记录展示,对齐模型超市筛选,统一公开与内嵌客户端下载页。 - 同步多语言文案、组件规范与移动端视口要求。
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { Popconfirm } from '@/components/ui';
|
||||
import TableActionPopconfirm from '@/components/common/table/TableActionPopconfirm';
|
||||
import {
|
||||
formatIdReference,
|
||||
formatNumber,
|
||||
@@ -5,20 +7,23 @@ import {
|
||||
} from '../../helpers/safeDisplay';
|
||||
|
||||
import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
|
||||
import { RefreshCw as ActionRefreshCw } from '@/components/common/icons/ActionIcons';
|
||||
import {
|
||||
Plus as ActionPlus,
|
||||
RefreshCw as ActionRefreshCw,
|
||||
Search as ActionSearch,
|
||||
} from '@/components/common/icons/ActionIcons';
|
||||
import { Card } from 'antd';
|
||||
import TableEmpty from '../../components/common/table/TableEmpty';
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import {
|
||||
Button,
|
||||
Input,
|
||||
InputNumber,
|
||||
Modal,
|
||||
Popconfirm,
|
||||
Select,
|
||||
Table,
|
||||
Tag,
|
||||
TextArea,
|
||||
Toast,
|
||||
Typography,
|
||||
} from '@/components/ui';
|
||||
import { Activity, FlaskConical, Gauge, ShieldAlert } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
@@ -29,11 +34,10 @@ import {
|
||||
PageGuideDrawer,
|
||||
PageGuideTrigger,
|
||||
} from '../../components/common/PageGuide';
|
||||
import OrgPanel from './components/OrgPanel';
|
||||
import { OrgListCard } from './components/OrgListCard';
|
||||
import OrgModal from './components/OrgModal';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import './org-effectiveness.css';
|
||||
import OrgBreadcrumb from './components/OrgBreadcrumb';
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
|
||||
const dimensions = [
|
||||
{ value: 'organization', label: '企业总览' },
|
||||
@@ -206,7 +210,7 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
|
||||
);
|
||||
if (!response.data?.success) {
|
||||
Toast.error(response.data?.message || t('操作失败'));
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
Toast.success(t('实验已删除'));
|
||||
await load();
|
||||
@@ -228,7 +232,7 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
|
||||
} catch {
|
||||
ids = [];
|
||||
}
|
||||
Modal.info({
|
||||
OrgModal.info({
|
||||
title: t('告警任务样本'),
|
||||
content: (
|
||||
<div className='org-effect-samples'>
|
||||
@@ -326,75 +330,81 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
|
||||
],
|
||||
});
|
||||
return (
|
||||
<div className='org-effect-page'>
|
||||
<header className='org-effect-hero'>
|
||||
<div>
|
||||
<OrgBreadcrumb />
|
||||
<Title heading={2}>{t('效能分析')}</Title>
|
||||
<Text type='tertiary'>
|
||||
{t('回答谁在用、节省多少时间、成本是否对账、质量与安全是否改善。')}
|
||||
</Text>
|
||||
</div>
|
||||
<div className='org-effect-toolbar'>
|
||||
<PageGuideTrigger guide={guide} />
|
||||
<Select
|
||||
value={dimension}
|
||||
optionList={dimensions.map((d) => ({
|
||||
...d,
|
||||
label: t(d.label),
|
||||
}))}
|
||||
onChange={setDimension}
|
||||
/>
|
||||
{dimension !== 'organization' && (
|
||||
<InputNumber
|
||||
min={1}
|
||||
value={dimensionId}
|
||||
onChange={setDimensionId}
|
||||
<div className='org-effect-page oc-page'>
|
||||
<OrgPageHeader
|
||||
title={t('效能分析')}
|
||||
subtitle={t(
|
||||
'回答谁在用、节省多少时间、成本是否对账、质量与安全是否改善。',
|
||||
)}
|
||||
actions={
|
||||
<div className='org-effect-toolbar'>
|
||||
<PageGuideTrigger guide={guide} />
|
||||
<Select
|
||||
aria-label={t('维度')}
|
||||
value={dimension}
|
||||
optionList={dimensions.map((d) => ({
|
||||
...d,
|
||||
label: t(d.label),
|
||||
}))}
|
||||
onChange={setDimension}
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
icon={<ActionRefreshCw size={15} />}
|
||||
loading={loading}
|
||||
onClick={load}
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
{canManagePolicy && (
|
||||
<Button onClick={aggregateToday}>{t('重算今日')}</Button>
|
||||
)}
|
||||
</div>
|
||||
</header>
|
||||
{dimension !== 'organization' && (
|
||||
<InputNumber
|
||||
aria-label={t('维度') + ' ID'}
|
||||
min={1}
|
||||
value={dimensionId || null}
|
||||
onChange={setDimensionId}
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
icon={<ActionRefreshCw size={16} />}
|
||||
loading={loading}
|
||||
onClick={load}
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
{canManagePolicy && (
|
||||
<Button onClick={aggregateToday}>{t('重算今日')}</Button>
|
||||
)}
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
<PageGuideDrawer guide={guide} />
|
||||
|
||||
<section className='org-effect-grid'>
|
||||
{cards.map(({ label, value: cardValue, detail, icon: Icon }) => (
|
||||
<article className='org-effect-card' key={label}>
|
||||
<Icon size={20} />
|
||||
<Text>{label}</Text>
|
||||
<Card className='org-effect-card' key={label}>
|
||||
<div className='org-effect-card-label'>
|
||||
<span className='org-effect-card-icon'>
|
||||
<Icon size={20} strokeWidth={1.75} aria-hidden='true' />
|
||||
</span>
|
||||
<span>{label}</span>
|
||||
</div>
|
||||
<strong>{cardValue}</strong>
|
||||
<small>{detail}</small>
|
||||
</article>
|
||||
</Card>
|
||||
))}
|
||||
</section>
|
||||
|
||||
<OrgPanel title={t('网关直连技能使用(近 30 天)')}>
|
||||
<OrgListCard title={t('网关直连技能使用(近 30 天)')}>
|
||||
{directUsage.length === 0 ? (
|
||||
<Text type='tertiary'>
|
||||
<p className='org-effect-direct-note'>
|
||||
{t(
|
||||
'暂无数据。开启密钥的「技能注入」后,用该密钥直连调用的技能使用情况会回流到这里。',
|
||||
)}
|
||||
</Text>
|
||||
</p>
|
||||
) : (
|
||||
<>
|
||||
<Text type='tertiary' size='small'>
|
||||
<p className='org-effect-direct-note'>
|
||||
{t(
|
||||
'统计口径:token 与额度是整条请求的量级,多技能同时命中时全额计入每个技能,不是按技能分摊的成本,勿相加。',
|
||||
)}
|
||||
</Text>
|
||||
</p>
|
||||
<Table
|
||||
size='small'
|
||||
pagination={{ resetOnDataChange: true }}
|
||||
dataSource={directUsage}
|
||||
empty={<TableEmpty />}
|
||||
rowKey='skill_id'
|
||||
columns={[
|
||||
{
|
||||
@@ -420,35 +430,42 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</OrgPanel>
|
||||
</OrgListCard>
|
||||
|
||||
<div className='org-effect-columns'>
|
||||
<OrgPanel title={t('成本对账')}>
|
||||
<div className='org-effect-reconcile'>
|
||||
<span>{t('运行结算')}</span>
|
||||
<b>{Math.round(value('efficiency.quota')).toLocaleString()}</b>
|
||||
<span>{t('消费明细')}</span>
|
||||
<b>
|
||||
{Math.round(
|
||||
value('efficiency.settlement_quota') +
|
||||
value('efficiency.adjustment_quota'),
|
||||
).toLocaleString()}
|
||||
</b>
|
||||
<span>{t('差额')}</span>
|
||||
<b
|
||||
className={
|
||||
value('efficiency.reconciliation_gap') ? 'is-risk' : 'is-ok'
|
||||
}
|
||||
>
|
||||
{Math.round(
|
||||
value('efficiency.reconciliation_gap'),
|
||||
).toLocaleString()}
|
||||
</b>
|
||||
</div>
|
||||
</OrgPanel>
|
||||
<OrgPanel title={t('质量告警')}>
|
||||
<OrgListCard title={t('成本对账')}>
|
||||
<dl className='org-effect-reconcile'>
|
||||
<div>
|
||||
<dt>{t('运行结算')}</dt>
|
||||
<dd>{Math.round(value('efficiency.quota')).toLocaleString()}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{t('消费明细')}</dt>
|
||||
<dd>
|
||||
{Math.round(
|
||||
value('efficiency.settlement_quota') +
|
||||
value('efficiency.adjustment_quota'),
|
||||
).toLocaleString()}
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{t('差额')}</dt>
|
||||
<dd
|
||||
className={
|
||||
value('efficiency.reconciliation_gap') ? 'is-risk' : 'is-ok'
|
||||
}
|
||||
>
|
||||
{Math.round(
|
||||
value('efficiency.reconciliation_gap'),
|
||||
).toLocaleString()}
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</OrgListCard>
|
||||
<OrgListCard title={t('质量告警')}>
|
||||
{isMobile ? (
|
||||
<div className='org-effect-mobile-list'>
|
||||
{!data.alerts?.length && <TableEmpty />}
|
||||
{(data.alerts || []).map((row) => (
|
||||
<article key={row.id}>
|
||||
<div>
|
||||
@@ -476,6 +493,8 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
|
||||
size='small'
|
||||
pagination={{ resetOnDataChange: true }}
|
||||
dataSource={data.alerts || []}
|
||||
empty={<TableEmpty />}
|
||||
rowKey='id'
|
||||
columns={[
|
||||
{ title: t('Skill'), dataIndex: 'dimension_id' },
|
||||
{
|
||||
@@ -504,25 +523,40 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
</OrgPanel>
|
||||
</OrgListCard>
|
||||
</div>
|
||||
|
||||
<OrgPanel
|
||||
<OrgListCard
|
||||
title={t('灰度版本质量对比')}
|
||||
actions={
|
||||
<div className='flex gap-2'>
|
||||
tools={
|
||||
<form
|
||||
className='org-effect-drilldown'
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
void loadComparison();
|
||||
}}
|
||||
>
|
||||
<label htmlFor='org-effect-skill-id'>Skill ID</label>
|
||||
<InputNumber
|
||||
id='org-effect-skill-id'
|
||||
min={1}
|
||||
placeholder='Skill ID'
|
||||
value={comparisonSkillId}
|
||||
value={comparisonSkillId || null}
|
||||
onChange={setComparisonSkillId}
|
||||
/>
|
||||
<Button onClick={loadComparison}>{t('下钻版本')}</Button>
|
||||
</div>
|
||||
<Button
|
||||
htmlType='submit'
|
||||
icon={<ActionSearch size={16} />}
|
||||
disabled={!comparisonSkillId}
|
||||
>
|
||||
{t('下钻版本')}
|
||||
</Button>
|
||||
</form>
|
||||
}
|
||||
>
|
||||
{isMobile ? (
|
||||
<div className='org-effect-mobile-list'>
|
||||
{!comparison.length && <TableEmpty />}
|
||||
{comparison.map((row) => (
|
||||
<article key={row.version_id}>
|
||||
<strong>
|
||||
@@ -559,6 +593,8 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
|
||||
<Table
|
||||
pagination={{ resetOnDataChange: true }}
|
||||
dataSource={comparison}
|
||||
empty={<TableEmpty />}
|
||||
rowKey='version_id'
|
||||
columns={[
|
||||
{ title: t('版本'), dataIndex: 'version_id' },
|
||||
{ title: t('首次交付样本'), dataIndex: 'first_delivery_count' },
|
||||
@@ -589,13 +625,17 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
</OrgPanel>
|
||||
</OrgListCard>
|
||||
|
||||
<OrgPanel
|
||||
<OrgListCard
|
||||
title={t('Skill A/B 实验')}
|
||||
actions={
|
||||
tools={
|
||||
canManageSkills ? (
|
||||
<Button onClick={() => setExperimentVisible(true)}>
|
||||
<Button
|
||||
type='primary'
|
||||
icon={<ActionPlus size={16} />}
|
||||
onClick={() => setExperimentVisible(true)}
|
||||
>
|
||||
{t('新建实验')}
|
||||
</Button>
|
||||
) : null
|
||||
@@ -603,6 +643,7 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
|
||||
>
|
||||
{isMobile ? (
|
||||
<div className='org-effect-mobile-list'>
|
||||
{!experiments.length && <TableEmpty />}
|
||||
{experiments.map((row) => (
|
||||
<article key={row.id}>
|
||||
<div>
|
||||
@@ -657,6 +698,8 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
|
||||
<Table
|
||||
pagination={{ resetOnDataChange: true }}
|
||||
dataSource={experiments}
|
||||
empty={<TableEmpty />}
|
||||
rowKey='id'
|
||||
columns={[
|
||||
{ title: t('实验'), dataIndex: 'name' },
|
||||
{ title: 'Skill', dataIndex: 'skill_id' },
|
||||
@@ -688,7 +731,7 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
|
||||
>
|
||||
{row.status === 'draft' ? t('开始') : t('停止并回退')}
|
||||
</Button>
|
||||
<Popconfirm
|
||||
<TableActionPopconfirm
|
||||
title={t('确认删除该实验?')}
|
||||
content={t(
|
||||
'删除后实验配置与分桶结果一并清除,起停记录已在审计中留痕。',
|
||||
@@ -697,22 +740,22 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
|
||||
>
|
||||
<Button
|
||||
size='small'
|
||||
theme='light'
|
||||
type='danger'
|
||||
type='link'
|
||||
danger
|
||||
disabled={row.status === 'running'}
|
||||
>
|
||||
{t('删除')}
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</TableActionPopconfirm>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
</OrgPanel>
|
||||
</OrgListCard>
|
||||
|
||||
<Modal
|
||||
<OrgModal
|
||||
title={t('新建 Skill A/B 实验')}
|
||||
visible={experimentVisible}
|
||||
onCancel={() => setExperimentVisible(false)}
|
||||
@@ -776,7 +819,7 @@ const OrgEffectiveness = ({ orgId, canManagePolicy, canManageSkills }) => {
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</Modal>
|
||||
</OrgModal>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user