// Static reference data — sidebar tree, mega-nav, dropdowns. Not backed by backend.
// Copied from prototype/src/data.jsx. USER_TYPES and LANGUAGES trimmed to match
// backend enum constraints (UserServiceImpl.USER_TYPES / LANGUAGES).

export interface NavNode {
  id: string;
  label: string;
  icon?: string;
  leaf?: boolean;
  badge?: string;
  children?: NavNode[];
  screen?: string;
}

export const COMPANIES = [
  { id: "std", name: "标准版 (Standard Edition) / 8s" },
  { id: "ent", name: "企业版 (Enterprise Edition) / 8s" },
  { id: "trial", name: "试用版 (Trial Edition) / 30d" },
];

// Backend USER_TYPES enum: 普通用户 | 超级管理员
export const USER_TYPES = ["超级管理员", "普通用户"];

// Visual-only — permission grid in UserDetail. Backend persistence (by IDs)
// not yet wired; toggling these does not round-trip.
export const PERMISSION_GROUPS = [
  "默认显示(必选)",
  "禁止查看价格",
  "客服跟单",
  "报价组员工",
  "物控部员工",
  "供应链 PMC",
  "允许查看订单价格",
  "储运部员工",
  "外部供应商",
  "品质部员工",
  "技术中心员工",
  "机修组员工",
  "生产部计划员工",
  "外发组员工",
  "模烫车间",
  "装订车间",
  "粘接工车间",
  "品质部管理",
  "精品车间",
  "人事组",
  "统计组",
  "机修主管",
  "样品开发部员工",
  "设计开发",
  "总经办",
  "财务部",
  "销售员",
  "采购员",
  "仓库管理员",
];

// Visual-only — scope tabs in UserDetail (客户/供应商/人员/工序/司机).
export const SCOPE_ITEMS: Record<string, { label: string; items: string[] }> = {
  customer: {
    label: "客户",
    items: [
      "上海印行包装",
      "锐尚文创",
      "京华彩印",
      "广印纸品",
      "万象图文",
      "联合包装",
      "鼎盛印刷",
      "九洲胶印",
    ],
  },
  supplier: {
    label: "供应商",
    items: ["华东油墨", "正信纸业", "宝洁化工", "日新油墨", "三鼎纸业", "鸿丰胶辊", "永利印材"],
  },
  staff: {
    label: "人员",
    items: ["管广飞", "李斌", "孟威", "王宽明", "潘强", "杨柳"],
  },
  process: {
    label: "工序",
    items: ["印前", "印刷", "覆膜", "模切", "装订", "胶装", "丝网", "烫金", "包装"],
  },
  driver: {
    label: "司机",
    items: ["陈师傅", "李师傅", "王师傅", "钱师傅", "赵师傅"],
  },
};

// Backend LANGUAGES enum: zh | en | zh-TW. Display strings for the form.
export const LANGUAGE_OPTIONS: { value: string; label: string }[] = [
  { value: "zh", label: "中文" },
  { value: "en", label: "英文" },
  { value: "zh-TW", label: "繁体" },
];

// Backend list-API field names (Chinese — see UserServiceImpl.FIELD_MAP)
export const USER_LIST_FIELDS: { value: string; label: string }[] = [
  { value: "员工名", label: "员工名" },
  { value: "用户名", label: "用户名" },
  { value: "用户号", label: "用户号" },
  { value: "部门", label: "部门" },
];
export const USER_LIST_MATCHES: { value: string; label: string }[] = [
  { value: "包含", label: "包含" },
  { value: "不包含", label: "不包含" },
  { value: "等于", label: "等于" },
];

export const NAV_TREE: NavNode[] = [
  { id: "home", label: "首页", icon: "home", leaf: true },
  {
    id: "kpi",
    label: "KPI 流程作业单",
    icon: "doc",
    children: [
      {
        id: "quote",
        label: "估价管理流程",
        children: [
          { id: "quote-01", label: "01/04 【新增】新报价单", leaf: true, badge: "估价" },
          { id: "quote-02", label: "02/04 审核报价单->客户确认...", leaf: true },
          { id: "quote-03", label: "03/04 客户确认->二次确认", leaf: true },
          { id: "quote-04", label: "04/04 报价单->销售订单", leaf: true },
        ],
      },
      { id: "order", label: "订单生产流程" },
      { id: "panel", label: "自动拼版流程" },
      { id: "ship", label: "销售送货流程" },
      { id: "purch", label: "物料采购流程" },
    ],
  },
  { id: "crm", label: "CRM 管理", icon: "folder" },
  { id: "plm", label: "PLM 管理", icon: "folder" },
  { id: "prod", label: "产品管理", icon: "folder" },
  { id: "sales", label: "销售管理", icon: "folder" },
  { id: "mfg", label: "生产管理", icon: "folder" },
  {
    id: "sys",
    label: "系统管理",
    icon: "settings",
    children: [
      { id: "roles", label: "角色管理", leaf: true },
      { id: "menucfg", label: "菜单配置", leaf: true },
      { id: "log", label: "操作日志", leaf: true },
    ],
  },
];

export const MEGA_NAV = [
  { id: "sales-mgmt", label: "销售管理" },
  { id: "dcs", label: "DCS 系统" },
  { id: "prod-mgmt", label: "产品管理" },
  { id: "prod-ops", label: "生产运营" },
  { id: "prod-exec", label: "生产执行" },
  { id: "mold", label: "模具管理" },
  { id: "purch", label: "采购管理" },
  { id: "matwh", label: "材料库存" },
  { id: "fgwh", label: "成品库存" },
  { id: "outsrc", label: "外协管理" },
  { id: "logistics", label: "物流管理" },
  { id: "qc", label: "质量管理" },
  { id: "fin", label: "财务管理" },
  { id: "cost-pro", label: "成本管理(专)" },
  { id: "cost", label: "成本管理" },
  { id: "equip", label: "设备管理" },
  { id: "hr", label: "人事行政" },
  { id: "oa", label: "OA 系统" },
  { id: "base", label: "基础设置" },
  { id: "sys", label: "系统设置", active: true },
];

export const MEGA_COLUMNS: Record<
  string,
  { title: string; items: { label: string; screen?: string; featured?: boolean }[] }[]
> = {
  sys: [
    {
      title: "期初设置",
      items: [
        { label: "客户期初" },
        { label: "供应商期初" },
        { label: "材料期初" },
        { label: "产品期初" },
        { label: "数据导入" },
        { label: "离线导出下载" },
      ],
    },
    {
      title: "用户管理",
      items: [
        { label: "用户列表", screen: "userlist", featured: true },
        { label: "系统权限" },
        { label: "系统权限稽查表" },
        { label: "权限组" },
      ],
    },
    {
      title: "系统参数",
      items: [
        { label: "系统参数" },
        { label: "财务结账" },
        { label: "系统常量配置" },
      ],
    },
    {
      title: "计算方案",
      items: [{ label: "方案列表" }, { label: "计算参数" }],
    },
    {
      title: "日志",
      items: [
        { label: "个性化模块" },
        { label: "操作日志" },
        { label: "异常清除KPI任务表" },
        { label: "MYSQL监听器" },
      ],
    },
    {
      title: "开发平台",
      items: [
        { label: "自定义开发范例" },
        { label: "系统功能模块设置" },
        { label: "EBC流程清单" },
        { label: "功能模块界面设置" },
        { label: "增删改存业务处理" },
      ],
    },
    {
      title: "API对接管理",
      items: [
        { label: "调用第三方接口(TOKEN配置)" },
        { label: "调用第三方接口(接口定义)" },
        { label: "被第三方调用(生成token)" },
        { label: "数据同步" },
        { label: "被第三方调用(API定义)" },
      ],
    },
    {
      title: "系统模块",
      items: [
        { label: "系统模块配置", screen: "module", featured: true },
        { label: "菜单配置" },
        { label: "模块字段配置" },
      ],
    },
  ],
};

export const MODULE_DISPLAY_TYPES = ["手机端", "前端业务", "系统配置", "接口"];
