fix(ui): 修复登录与并发请求并统一表格、主题和页面展示
验证:868 项单测、ESLint、Prettier、UI 依赖审计和差异检查通过。
This commit is contained in:
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import { formatIdReference } from '../../helpers/safeDisplay';
|
||||
import {
|
||||
RefreshCw as ActionRefreshCw,
|
||||
Plus as ActionPlus,
|
||||
@@ -106,10 +107,14 @@ const OrgBudgets = ({ orgId, featureFlags }) => {
|
||||
if (!orgId) return;
|
||||
setLoading(true);
|
||||
try {
|
||||
const options = {
|
||||
headers: getOrgHeaders(orgId),
|
||||
requestGroup: new AbortController(),
|
||||
};
|
||||
const [b, d, p] = await Promise.all([
|
||||
API.get('/api/org/budget', { headers: getOrgHeaders(orgId) }),
|
||||
API.get('/api/org/dept', { headers: getOrgHeaders(orgId) }),
|
||||
API.get('/api/org/project', { headers: getOrgHeaders(orgId) }),
|
||||
API.get('/api/org/budget', options),
|
||||
API.get('/api/org/dept', options),
|
||||
API.get('/api/org/project', options),
|
||||
]);
|
||||
if (b.data.success) {
|
||||
// 新后端返回 {items, enforcement_enabled, engine_enabled};兼容旧后端直接返回数组。
|
||||
@@ -122,7 +127,7 @@ const OrgBudgets = ({ orgId, featureFlags }) => {
|
||||
if (d.data.success) setDepts(d.data.data || []);
|
||||
if (p.data.success) setProjects(p.data.data || []);
|
||||
} catch (err) {
|
||||
showError(err.message);
|
||||
if (!err?.isAxiosError) showError(err);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -139,7 +144,7 @@ const OrgBudgets = ({ orgId, featureFlags }) => {
|
||||
const st = r.subject_type;
|
||||
if (r.subject_exists !== undefined) {
|
||||
return {
|
||||
name: r.subject_name || `#${r.subject_id}`,
|
||||
name: r.subject_name || formatIdReference(r.subject_id),
|
||||
exists: !!r.subject_exists,
|
||||
disabled: r.subject_status === 2,
|
||||
};
|
||||
@@ -147,7 +152,7 @@ const OrgBudgets = ({ orgId, featureFlags }) => {
|
||||
if (st === 'department') {
|
||||
const d = depts.find((x) => x.id === r.subject_id);
|
||||
return {
|
||||
name: d?.name || `#${r.subject_id}`,
|
||||
name: d?.name || formatIdReference(r.subject_id),
|
||||
exists: !!d,
|
||||
disabled: d?.status === 2,
|
||||
};
|
||||
@@ -155,13 +160,17 @@ const OrgBudgets = ({ orgId, featureFlags }) => {
|
||||
if (st === 'project') {
|
||||
const p = projects.find((x) => x.id === r.subject_id);
|
||||
return {
|
||||
name: p?.name || `#${r.subject_id}`,
|
||||
name: p?.name || formatIdReference(r.subject_id),
|
||||
exists: !!p,
|
||||
disabled: p?.status === 2,
|
||||
};
|
||||
}
|
||||
// 旧后端下成员/密钥无从解析,按存在处理,避免误标「已删除」
|
||||
return { name: `#${r.subject_id}`, exists: true, disabled: false };
|
||||
return {
|
||||
name: formatIdReference(r.subject_id),
|
||||
exists: true,
|
||||
disabled: false,
|
||||
};
|
||||
},
|
||||
[depts, projects],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user