/*
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 .
For commercial licensing, please contact support@quantumnous.com
*/
import React, { useEffect, useState, useCallback, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import {
Building2,
Plus,
Search,
Pencil,
ExternalLink,
BarChart3,
Bell,
BellOff,
} from 'lucide-react';
import {
Table,
Button,
Input,
Tag,
Modal,
InputNumber,
Toast,
TextArea,
Select,
Switch,
Radio,
} from '@/components/ui';
import { API } from '../../helpers/api';
import { showError, isAdmin, isRoot } from '../../helpers';
import { renderQuota } from '../../helpers/render';
import QuotaInput from '../../components/common/ui/QuotaInput';
import OrgCredentialResult from '../../components/auth/OrgCredentialResult';
import { validateOrgOwnerLoginName } from '../../helpers/orgLoginName';
import OrgAlertSettingsModal from './OrgAlertSettingsModal';
import {
CLOUD_BRAIN_ORG_FEATURE_KEYS,
CLOUD_BRAIN_UI_ENABLED,
} from '../../config/cloudBrainUi';
// 企业功能开关(套餐能力,与后端 ValidOrgFeatureKeys 对齐,§28.8)
const ORG_FEATURE_KEYS = [
{ key: 'cloud_brain', label: '云端大脑(Beta)' },
{ key: 'expert', label: '专家能力' },
{ key: 'skill_market', label: 'Skill 市场' },
{ key: 'knowledge_base', label: '企业知识库' },
{ key: 'connector', label: '企业连接器' },
{ key: 'enterprise_knowledge', label: '企业知识能力' },
{ key: 'agent_effectiveness', label: 'Agent 效能分析' },
{ key: 'budget', label: '预算配置' },
{ key: 'budget_enforcement', label: '预算实时拦截' },
{ key: 'department_guardrail', label: '部门预算护栏(默认开启)' },
{ key: 'dept', label: '部门管理' },
{ key: 'project', label: '项目管理' },
{ key: 'approval', label: '审批中心' },
{ key: 'analytics', label: '用量分析' },
{ key: 'quality_monitor', label: '调用质量' },
{ key: 'enterprise_login', label: '企业登录入口' },
{ key: 'org_only_mode', label: '仅企业资源模式' },
{ key: 'content_moderation', label: '内容审核' },
{ key: 'no_training', label: '数据不用于训练' },
{ key: 'prompt_archive', label: '提示词采集' },
{ key: 'data_security', label: '数据安全自助配置' },
];
const VISIBLE_ORG_FEATURE_KEYS = CLOUD_BRAIN_UI_ENABLED
? ORG_FEATURE_KEYS
: ORG_FEATURE_KEYS.filter(
({ key }) => !CLOUD_BRAIN_ORG_FEATURE_KEYS.has(key),
);
const AdminOrganizations = () => {
const { t } = useTranslation();
const navigate = useNavigate();
const [orgs, setOrgs] = useState([]);
const [total, setTotal] = useState(0);
const [loading, setLoading] = useState(false);
const [page, setPage] = useState(1);
const [keyword, setKeyword] = useState('');
const [searchKeyword, setSearchKeyword] = useState('');
const [quotaModalVisible, setQuotaModalVisible] = useState(false);
const [quotaOrgId, setQuotaOrgId] = useState(null);
const [quotaAmount, setQuotaAmount] = useState(0);
const [createModalVisible, setCreateModalVisible] = useState(false);
const [createLoading, setCreateLoading] = useState(false);
const [createForm, setCreateForm] = useState({
name: '',
owner_mode: 'managed',
owner_id: '',
owner_login_name: '',
owner_display_name: '',
quota: 0,
group: 'default',
groups: ['default'],
level: '',
max_members: 50,
max_tokens: 100,
cloud_brain_concurrency: 12,
sales_rep: '',
});
const [createCredentialResult, setCreateCredentialResult] = useState(null);
const [editModalVisible, setEditModalVisible] = useState(false);
const [editLoading, setEditLoading] = useState(false);
const [editForm, setEditForm] = useState({
id: null,
name: '',
group: '',
groups: [],
level: '',
max_members: 50,
max_tokens: 100,
cloud_brain_concurrency: 12,
default_member_quota: 0,
description: '',
contact_name: '',
contact_phone: '',
contact_email: '',
sales_rep: '',
});
const [groupOptions, setGroupOptions] = useState([]);
const [levelOptions, setLevelOptions] = useState([]);
const [featureModalOrg, setFeatureModalOrg] = useState(null);
const [featureFlags, setFeatureFlags] = useState({});
const [effectUsageVisible, setEffectUsageVisible] = useState(false);
const [effectUsage, setEffectUsage] = useState([]);
// 多维筛选 + 服务端排序(分页在服务端,排序/筛选必须一并下推,前端本地排序只会排当前页)
const [statusFilter, setStatusFilter] = useState(undefined);
const [levelFilter, setLevelFilter] = useState(undefined);
const [salesRepFilter, setSalesRepFilter] = useState(undefined);
// 用户ID筛选:输入框值与已应用值分离,回车才下推请求(与关键字框同一交互)
const [userIdInput, setUserIdInput] = useState('');
const [userIdFilter, setUserIdFilter] = useState('');
const [salesRepOptions, setSalesRepOptions] = useState([]);
const [sortBy, setSortBy] = useState('');
const [sortOrder, setSortOrder] = useState('');
// 企业预警通知(方案 11 号 §8):设置弹窗 + 行内屏蔽开关,均 root-only。
// 屏蔽状态的存储是 org_alert_setting.excluded_org_ids 这条 option(与设置弹窗同源),
// 行内切换走专用 CAS 接口防两个管理员并发覆盖。
const [alertSettingsVisible, setAlertSettingsVisible] = useState(false);
const [alertExcludedIds, setAlertExcludedIds] = useState(() => new Set());
const [alertToggleLoading, setAlertToggleLoading] = useState(null);
const fetchAlertExcluded = useCallback(async () => {
if (!isRoot()) return;
try {
const res = await API.get('/api/option/');
if (res?.data?.success) {
const row = (res.data.data || []).find(
(o) => o.key === 'org_alert_setting.excluded_org_ids',
);
setAlertExcludedIds(
new Set(
(row?.value || '')
.split(',')
.map((s) => parseInt(s.trim(), 10))
.filter((n) => Number.isFinite(n) && n > 0),
),
);
}
} catch (err) {
// 静默:屏蔽状态加载失败不阻塞页面,仅开关反显缺失
}
}, []);
const toggleAlertExclude = async (record) => {
const excluded = !alertExcludedIds.has(record.id);
setAlertToggleLoading(record.id);
try {
const res = await API.post('/api/org_alert/toggle_exclude', {
org_id: record.id,
excluded,
});
if (res.data?.success) {
Toast.success(
excluded ? t('已屏蔽该企业的预警') : t('已恢复该企业的预警'),
);
setAlertExcludedIds((prev) => {
const next = new Set(prev);
if (excluded) {
next.add(record.id);
} else {
next.delete(record.id);
}
return next;
});
} else {
showError(res.data?.message || t('操作失败'));
}
} catch (err) {
// 传对象而非 err.message,否则 showError 走不到中文翻译分支
showError(err);
} finally {
setAlertToggleLoading(null);
}
};
const openEffectUsage = async () => {
try {
const response = await API.get(
'/api/admin/organizations/effectiveness/usage',
);
if (!response.data?.success) {
showError(response.data?.message || t('企业使用统计加载失败'));
return;
}
setEffectUsage(response.data.data || []);
setEffectUsageVisible(true);
} catch (error) {
showError(error.message);
}
};
const fetchGroups = useCallback(async () => {
try {
const res = await API.get('/api/group/');
if (res?.data?.data) {
setGroupOptions(res.data.data.map((g) => ({ label: g, value: g })));
}
} catch (err) {
// 静默处理,分组加载失败不阻塞页面
}
}, []);
const fetchLevels = useCallback(async () => {
try {
const res = await API.get('/api/group/enterprise_levels');
const levels = res?.data?.data?.levels || [];
setLevelOptions(levels.map((l) => ({ label: l, value: l })));
} catch (err) {
// 静默处理,等级加载失败不阻塞页面
}
}, []);
const fetchSalesReps = useCallback(async () => {
try {
const res = await API.get('/api/admin/organizations/meta/sales-reps');
if (res?.data?.success) {
setSalesRepOptions(
(res.data.data || []).map((name) => ({ label: name, value: name })),
);
}
} catch (err) {
// 静默处理,商务人员选项加载失败不阻塞页面
}
}, []);
// 解析企业可用分组:兼容后端返回的 JSON 字符串 / 数组;为空时回退为 [group]
const parseOrgGroups = (record) => {
if (Array.isArray(record?.groups)) return record.groups;
if (typeof record?.groups === 'string' && record.groups.trim()) {
try {
const arr = JSON.parse(record.groups);
if (Array.isArray(arr) && arr.length) return arr;
} catch (e) {
// 解析失败回退
}
}
return record?.group ? [record.group] : [];
};
// 默认分组的可选项来自"已选可用分组"
const buildDefaultOptions = (groups) =>
(groups || []).map((g) => ({ label: g, value: g }));
const resetCreateForm = () => {
setCreateCredentialResult(null);
setCreateForm({
name: '',
owner_mode: 'managed',
owner_id: '',
owner_login_name: '',
owner_display_name: '',
quota: 0,
group: 'default',
groups: ['default'],
level: '',
max_members: 50,
max_tokens: 100,
cloud_brain_concurrency: 12,
sales_rep: '',
});
};
// 筛选/排序可高频连续触发请求,用递增序号丢弃过期响应,防止慢网下旧结果覆盖新筛选
const fetchSeqRef = useRef(0);
const fetchOrgs = useCallback(async () => {
const seq = ++fetchSeqRef.current;
setLoading(true);
try {
const params = { p: page, page_size: 20 };
if (searchKeyword) params.keyword = searchKeyword;
if (statusFilter != null) params.status = statusFilter;
if (levelFilter) params.level = levelFilter;
if (salesRepFilter) params.sales_rep = salesRepFilter;
if (userIdFilter) params.user_id = userIdFilter;
if (sortBy) {
params.sort_by = sortBy;
params.sort_order = sortOrder || 'desc';
}
const res = await API.get('/api/admin/organizations/', { params });
if (seq !== fetchSeqRef.current) return;
if (res.data.success) {
setOrgs(res.data.data?.items || []);
setTotal(res.data.data?.total || 0);
}
} catch (err) {
if (seq === fetchSeqRef.current) showError(err.message);
} finally {
if (seq === fetchSeqRef.current) setLoading(false);
}
}, [
page,
searchKeyword,
statusFilter,
levelFilter,
salesRepFilter,
userIdFilter,
sortBy,
sortOrder,
]);
useEffect(() => {
fetchOrgs();
}, [fetchOrgs]);
useEffect(() => {
fetchGroups();
fetchLevels();
fetchSalesReps();
fetchAlertExcluded();
}, [fetchGroups, fetchLevels, fetchSalesReps, fetchAlertExcluded]);
// 筛选变化统一回到第 1 页,避免停留在筛选后不存在的页码
const applyFilter = (setter) => (value) => {
setter(value);
setPage(1);
};
const hasActiveFilters =
!!searchKeyword ||
statusFilter != null ||
!!levelFilter ||
!!salesRepFilter ||
!!userIdFilter ||
!!sortBy;
const resetFilters = () => {
setKeyword('');
setSearchKeyword('');
setStatusFilter(undefined);
setLevelFilter(undefined);
setSalesRepFilter(undefined);
setUserIdInput('');
setUserIdFilter('');
setSortBy('');
setSortOrder('');
setPage(1);
};
// 服务端排序:列头点击 → 下推 sort_by/sort_order 重新拉取
const sortOrderFor = (key) =>
sortBy === key ? (sortOrder === 'asc' ? 'ascend' : 'descend') : false;
const handleTableChange = ({ sorter }) => {
if (!sorter || !sorter.dataIndex) return;
const nextBy = sorter.sortOrder ? sorter.dataIndex : '';
const nextOrder = sorter.sortOrder
? sorter.sortOrder === 'ascend'
? 'asc'
: 'desc'
: '';
// onChange 在翻页时也会带当前 sorter 触发;排序没变就不动,避免翻页被重置回第 1 页
if (nextBy === sortBy && nextOrder === sortOrder) return;
setSortBy(nextBy);
setSortOrder(nextOrder);
setPage(1);
};
const handleStatusChange = async (orgId, status) => {
try {
const res = await API.put(`/api/admin/organizations/${orgId}/status`, {
status,
});
if (res.data.success) {
Toast.success(t('状态已更新'));
fetchOrgs();
} else {
showError(res.data.message);
}
} catch (err) {
showError(err.message);
}
};
const openFeatureModal = (record) => {
let flags = {};
try {
flags = record.feature_flags ? JSON.parse(record.feature_flags) : {};
} catch {
flags = {};
}
setFeatureFlags(flags || {});
setFeatureModalOrg(record);
};
const saveFeatureFlags = async () => {
if (!featureModalOrg) return;
try {
const res = await API.put(
`/api/admin/organizations/${featureModalOrg.id}/feature-flags`,
{ flags: featureFlags },
);
if (res.data.success) {
Toast.success(t('功能开关已更新'));
setFeatureModalOrg(null);
fetchOrgs();
} else {
showError(res.data.message);
}
} catch (err) {
showError(err.message);
}
};
const handleActivate = async (orgId) => {
try {
const res = await API.put(`/api/admin/organizations/${orgId}/activate`);
if (res.data.success) {
Toast.success(t('企业已激活'));
fetchOrgs();
} else {
showError(res.data.message);
}
} catch (err) {
showError(err.message);
}
};
const handleQuotaAdjust = async () => {
if (!quotaOrgId || !quotaAmount) return;
try {
const res = await API.put(
`/api/admin/organizations/${quotaOrgId}/quota`,
{ quota: quotaAmount },
);
if (res.data.success) {
Toast.success(t('额度已调整'));
setQuotaModalVisible(false);
fetchOrgs();
} else {
showError(res.data.message);
}
} catch (err) {
showError(err.message);
}
};
const handleCreateOrg = async () => {
const orgName = (createForm.name || '').trim();
const ownerMode = createForm.owner_mode || 'managed';
if (!orgName) {
Toast.warning(t('请输入企业名称'));
return;
}
let ownerId = 0;
if (ownerMode === 'existing') {
if (!createForm.owner_id) {
Toast.warning(t('请输入所有者用户ID'));
return;
}
ownerId = parseInt(createForm.owner_id);
if (isNaN(ownerId) || ownerId <= 0) {
Toast.warning(t('所有者用户ID必须为正整数'));
return;
}
}
const ownerLoginName = (createForm.owner_login_name || '').trim();
if (ownerMode === 'managed') {
// 与后端 normalizeOrgOwnerLoginName 同口径:必填、格式受限、保留名一律拒绝
const loginNameError = validateOrgOwnerLoginName(ownerLoginName);
if (loginNameError) {
Toast.warning(t(loginNameError));
return;
}
}
if (!createForm.groups || !createForm.groups.length) {
Toast.warning(t('请至少选择一个企业可用分组'));
return;
}
if (!createForm.group || !createForm.groups.includes(createForm.group)) {
Toast.warning(t('默认分组必须属于企业可用分组'));
return;
}
setCreateLoading(true);
try {
const data = {
name: orgName,
};
if (ownerMode === 'existing') {
data.owner_id = ownerId;
} else {
data.owner_login_name = ownerLoginName;
data.owner_display_name = (createForm.owner_display_name || '').trim();
}
if (createForm.quota) data.quota = createForm.quota;
data.group = createForm.group;
data.groups = createForm.groups;
if (createForm.level) data.level = createForm.level;
if (createForm.max_members != null)
data.max_members = createForm.max_members;
if (createForm.max_tokens != null)
data.max_tokens = createForm.max_tokens;
if (createForm.cloud_brain_concurrency != null)
data.cloud_brain_concurrency = createForm.cloud_brain_concurrency;
if ((createForm.sales_rep || '').trim())
data.sales_rep = createForm.sales_rep.trim();
const res = await API.post('/api/admin/organizations/', data);
if (res.data.success) {
Toast.success(t('企业创建成功'));
if (res.data.data?.initial_password) {
setCreateCredentialResult(res.data.data);
} else {
setCreateModalVisible(false);
resetCreateForm();
}
fetchOrgs();
fetchSalesReps();
} else {
showError(res.data.message);
}
} catch (err) {
showError(err.message);
} finally {
setCreateLoading(false);
}
};
const openEditModal = (record) => {
setEditForm({
id: record.id,
name: record.name || '',
group: record.group || 'default',
groups: parseOrgGroups(record),
level: record.level || '',
max_members: record.max_members ?? 50,
max_tokens: record.max_tokens ?? 100,
cloud_brain_concurrency: record.cloud_brain_concurrency ?? 12,
default_member_quota: record.default_member_quota || 0,
description: record.description || '',
contact_name: record.contact_name || '',
contact_phone: record.contact_phone || '',
contact_email: record.contact_email || '',
sales_rep: record.sales_rep || '',
});
setEditModalVisible(true);
};
const handleEditOrg = async () => {
const orgName = (editForm.name || '').trim();
if (!orgName) {
Toast.warning(t('请输入企业名称'));
return;
}
if (!editForm.groups || !editForm.groups.length) {
Toast.warning(t('请至少选择一个企业可用分组'));
return;
}
if (!editForm.group || !editForm.groups.includes(editForm.group)) {
Toast.warning(t('默认分组必须属于企业可用分组'));
return;
}
setEditLoading(true);
try {
const data = {
name: orgName,
group: editForm.group,
groups: editForm.groups,
level: editForm.level || '',
max_members:
editForm.max_members != null ? editForm.max_members : undefined,
max_tokens:
editForm.max_tokens != null ? editForm.max_tokens : undefined,
cloud_brain_concurrency:
editForm.cloud_brain_concurrency != null
? editForm.cloud_brain_concurrency
: undefined,
default_member_quota:
editForm.default_member_quota != null
? Math.max(0, Number(editForm.default_member_quota) || 0)
: undefined,
description: editForm.description,
contact_name: editForm.contact_name,
contact_phone: editForm.contact_phone,
contact_email: editForm.contact_email,
// 始终传字符串:后端为指针字段,传空串即可清除商务人员分配
sales_rep: (editForm.sales_rep || '').trim(),
};
const res = await API.put(
`/api/admin/organizations/${editForm.id}`,
data,
);
if (res.data.success) {
Toast.success(t('企业信息已更新'));
setEditModalVisible(false);
fetchOrgs();
fetchSalesReps();
} else {
showError(res.data.message);
}
} catch (err) {
showError(err.message);
} finally {
setEditLoading(false);
}
};
const handleDelete = async (orgId) => {
Modal.confirm({
title: t('确认删除'),
content: t('删除企业将无法恢复,确定继续?'),
onOk: async () => {
try {
const res = await API.delete(`/api/admin/organizations/${orgId}`);
if (res.data.success) {
Toast.success(t('企业已删除'));
fetchOrgs();
// 被删企业可能是某商务唯一跟进的企业,同步刷新筛选下拉防残留失效姓名
fetchSalesReps();
} else {
showError(res.data.message);
}
} catch (err) {
showError(err.message);
}
},
});
};
const handleEnterOrg = (orgId) => {
localStorage.setItem('current_org_id', String(orgId));
navigate('/org/dashboard');
};
// 列宽合计 ~1400px(含商务人员列),必须给横向滚动,否则 390px 屏上只看得到
// ID+企业名称,编辑/调额/冻结/删除 全在视口外且无任何可拖动提示
const columns = [
{
title: 'ID',
dataIndex: 'id',
width: 70,
sorter: true,
sortOrder: sortOrderFor('id'),
},
{
title: t('企业名称'),
dataIndex: 'name',
width: 150,
ellipsis: true,
sorter: true,
sortOrder: sortOrderFor('name'),
render: (text, record) => {
if (isRoot()) {
return (
);
}
return text;
},
},
{ title: t('企业代码'), dataIndex: 'code', width: 90 },
{
title: t('商务人员'),
dataIndex: 'sales_rep',
width: 100,
ellipsis: true,
render: (v) =>
v ? (
// maxWidth 约束住 Tag,超长姓名走 Tag 自带省略,不许溢出压过相邻列
{v}
) : (
{t('未分配')}
),
},
{ title: t('所有者ID'), dataIndex: 'owner_id', width: 80 },
{
title: t('状态'),
dataIndex: 'status',
// 90 而非 70:root 视角下会在状态标签下方叠一枚"预警已屏蔽"(5 个 CJK 字符),70 会裁切
width: 90,
sorter: true,
sortOrder: sortOrderFor('status'),
render: (status, record) => (
{status === 1
? t('正常')
: status === 2
? t('冻结')
: status === 4
? t('待激活')
: t('欠费')}
{isRoot() && alertExcludedIds.has(record.id) && (
{t('预警已屏蔽')}
)}
),
},
{
title: t('额度'),
dataIndex: 'quota',
width: 100,
sorter: true,
sortOrder: sortOrderFor('quota'),
render: (v) => renderQuota(v, 2),
},
{
title: t('已用额度'),
dataIndex: 'used_quota',
width: 110,
sorter: true,
sortOrder: sortOrderFor('used_quota'),
render: (v) => renderQuota(v, 2),
},
{
title: t('分组'),
dataIndex: 'group',
width: 150,
render: (_, record) => {
const groups = parseOrgGroups(record);
if (!groups.length) return '-';
return (
{groups.map((g) => (
{g === record.group ? `${g} (${t('默认')})` : g}
))}
);
},
},
{
title: t('限额'),
width: 90,
render: (_, record) => (
{record.max_members ?? '-'} / {record.max_tokens ?? '-'}
),
},
{
title: t('创建时间'),
dataIndex: 'created_at',
width: 110,
sorter: true,
sortOrder: sortOrderFor('created_at'),
render: (v) => (v ? new Date(v * 1000).toLocaleDateString() : '-'),
},
{
title: t('操作'),
width: 320,
render: (_, record) => (
{isAdmin() && (
<>
}
onClick={() => openEditModal(record)}
>
{t('编辑')}
{record.status === 4 ? (
) : record.status === 1 ? (
) : (
)}
{isRoot() && (
) : (
)
}
title={
alertExcludedIds.has(record.id)
? t('已屏蔽预警,点击恢复')
: t('屏蔽该企业的预警通知')
}
aria-label={
alertExcludedIds.has(record.id)
? t('恢复该企业的预警')
: t('屏蔽该企业的预警')
}
onClick={() => toggleAlertExclude(record)}
/>
)}
>
)}
),
},
];
return (
{t('企业管理')}
{t('管理所有企业账户')}
{CLOUD_BRAIN_UI_ENABLED && (
setEffectUsageVisible(false)}
footer={null}
width={860}
>
)}
{/* 额度调整 Modal */}
setQuotaModalVisible(false)}
okText={t('确认')}
cancelText={t('取消')}
>
{quotaOrgId &&
(() => {
const currentOrg = orgs.find((o) => o.id === quotaOrgId);
return currentOrg ? (
{t('当前额度')}
{renderQuota(currentOrg.quota, 2)}
{t('已用额度')}
{renderQuota(currentOrg.used_quota, 2)}
) : null;
})()}
{/* 企业预警通知设置 Modal(root-only,方案 11 号 §8-2) */}
setAlertSettingsVisible(false)}
onSaved={fetchAlertExcluded}
/>
{/* 创建企业 Modal */}
{
setCreateModalVisible(false);
resetCreateForm();
}}
okText={t('创建')}
cancelText={t('取消')}
confirmLoading={createLoading}
{...(createCredentialResult ? { footer: null } : {})}
bodyStyle={{
...(createCredentialResult ? { paddingBottom: 24 } : {}),
maxHeight: 'calc(100vh - 200px)',
overflowY: 'auto',
overscrollBehavior: 'contain',
scrollbarGutter: 'stable',
}}
>
{createCredentialResult ? (
) : (
setCreateForm({ ...createForm, name: v })}
placeholder={t('请输入企业名称')}
/>
setCreateForm({ ...createForm, owner_mode: e.target.value })
}
>
{t('自动生成 Owner')}
{t('指定现有用户')}
{t(
'自动生成模式会返回一次性企业代码、登录名和初始密码,不依赖个人账号。',
)}
{createForm.owner_mode === 'existing' ? (
setCreateForm({ ...createForm, owner_id: v })
}
placeholder={t('输入用户ID指定所有者')}
/>
) : (
)}
setCreateForm({ ...createForm, quota: v })}
style={{ width: '100%' }}
minQuota={0}
/>
setCreateForm({ ...createForm, max_members: v })
}
style={{ width: '100%' }}
min={1}
placeholder='50'
/>
setCreateForm({ ...createForm, max_tokens: v })
}
style={{ width: '100%' }}
min={1}
placeholder='100'
/>
{CLOUD_BRAIN_UI_ENABLED && (
setCreateForm({
...createForm,
cloud_brain_concurrency: v,
})
}
style={{ width: '100%' }}
min={1}
max={1000}
placeholder='12'
/>
)}
)}
{/* 编辑企业 Modal */}
setEditModalVisible(false)}
okText={t('保存')}
cancelText={t('取消')}
confirmLoading={editLoading}
>
setEditForm({ ...editForm, name: v })}
placeholder={t('请输入企业名称')}
/>
setEditForm({ ...editForm, max_members: v })}
style={{ width: '100%' }}
min={1}
/>
setEditForm({ ...editForm, max_tokens: v })}
style={{ width: '100%' }}
min={1}
/>
{CLOUD_BRAIN_UI_ENABLED && (
setEditForm({
...editForm,
cloud_brain_concurrency: v,
})
}
style={{ width: '100%' }}
min={1}
max={1000}
/>
{t('成员个人并发上限仍独立生效,企业总并发用于保护共享资源。')}
)}
setEditForm({ ...editForm, default_member_quota: v ?? 0 })
}
style={{ width: '100%' }}
minQuota={0}
placeholder={t('请输入金额,0 表示不限制')}
/>
{!(Number(editForm.default_member_quota) > 0) && (
{t(
'为 0 时:企业码自助加入的新成员可不受限制地使用企业额度池,存在被盗刷风险',
)}
)}
setEditForm({ ...editForm, contact_email: v })}
placeholder={t('联系邮箱')}
/>
{/* 功能开关 / 套餐 Modal(平台控制企业可用能力,§28.8) */}
setFeatureModalOrg(null)}
okText={t('保存')}
cancelText={t('取消')}
bodyStyle={{
maxHeight: 'min(70vh, 560px)',
overflowX: 'hidden',
overflowY: 'auto',
overscrollBehavior: 'contain',
scrollbarGutter: 'stable',
}}
>
{t(
'开启后企业方可使用对应能力;预算实时拦截需同时开启「预算配置」。',
)}
{VISIBLE_ORG_FEATURE_KEYS.map((f) => (
{t(f.label)}
setFeatureFlags((prev) => ({ ...prev, [f.key]: v }))
}
/>
))}
);
};
export default AdminOrganizations;