/* eslint-disable max-lines-per-function, complexity -- 页面组件集中编排筛选、表单与弹层,拆散会割裂数据流;纯逻辑已抽到 *-utils.ts */ import { Button, RadioGroup, Select, Tag } from '@douyinfe/semi-ui-19'; import { DICT_GROUPS, type DictItem, type DictItemListResponse, type DictTypeDetail, } from '@lingxi/shared'; import { ErrorState, PageEmpty } from '@lingxi/ui'; import { IconAdd, IconAlert, IconEdit, IconPause, IconPlay, IconView } from '@lingxi/ui/icons'; import type { ReactNode } from 'react'; import { useMemo } from 'react'; import { dictItemViewStats, dictScopeChips, dictTypeKindLabel, formatDictDateTime, } from './dict-utils'; import { DictGroupIcon } from './DictGroupIcon'; import { DictItemsView } from './DictItemsView'; export interface DictScopeOption { value: string | null; label: string; } const EMPTY_ITEMS: DictItemListResponse = { items: [], next_cursor: null, layers: [], effectiveCount: 0, overriddenCount: 0, disabledCount: 0, }; function groupNameOf(groupKey: DictTypeDetail['group']): string { return DICT_GROUPS.find((group) => group.key === groupKey)?.name ?? groupKey; } function DetailSkeleton(): ReactNode { return ( ); } function DetailHeader({ type, readOnly, typeDisabled, onAddItem, onEditType, onToggleType, }: { type: DictTypeDetail; readOnly: boolean; typeDisabled: boolean; onAddItem: () => void; onEditType: () => void; onToggleType: () => void; }): ReactNode { return (
{type.name} {type.builtin ? '内置' : '自定义'} {dictTypeKindLabel(type.kind)} {type.industryScoped ? '行业作用域' : '全平台'} {type.status === 'active' ? '启用' : '停用'}
{type.code} · {groupNameOf(type.group)} · {type.itemCount} 个条目 · {type.industryCount} 个行业覆盖
排序 {type.sortOrder} · 最近更新 {type.updatedBy ?? '—'} {formatDictDateTime(type.updatedAt)}
{type.description.trim() === '' ? null : (

{type.description}

)}
{readOnly ? ( 只读查看 ) : ( <> {typeDisabled ? ( ) : ( )} )}
); } function ScopeBar({ type, industryId, options, items, onIndustryChange, }: { type: DictTypeDetail; industryId: string | null; options: readonly DictScopeOption[]; items: DictItemListResponse; onIndustryChange: (industryId: string | null) => void; }): ReactNode { if (!type.industryScoped) { return (
行业视角 全平台通用 · 该类型不支持行业扩展 通用 {items.effectiveCount} 行业包只覆盖差异项
); } const chips = dictScopeChips(items, { scoped: industryId !== null }); return (
行业视角