dataScope.ts 627 Bytes
import type { FieldOption } from '@/components';

/** 系统通用的数据域选项与展示文案。 */
export const dataScopeOptions = [
  { label: '全部数据', value: 1 },
  { label: '本部门及下级', value: 2 },
  { label: '本部门', value: 3 },
  { label: '仅本人', value: 4 },
] satisfies FieldOption[];

const dataScopeLabels: Record<number, string> = Object.fromEntries(
  dataScopeOptions.map((item) => [item.value, item.label]),
);

export function getDataScopeLabel(scope: number | undefined, fallback = '—'): string {
  return scope === undefined ? fallback : (dataScopeLabels[scope] ?? fallback);
}