import Mock from 'mockjs';

import './system';

const menusList = [
  {
    id: 1,
    title: '服务单元管理',
    parentId: 0,
    url: '/service-unit',
    sort: 1,
    name: 'ServiceUnit',
  },
  {
    id: 2,
    title: '派单管理',
    parentId: 1,
    url: '/service-unit/dispatch',
    sort: 1,
    name: 'Dispatch',
  },
  {
    id: 3,
    title: '派单管理',
    parentId: 2,
    url: '/service-unit/dispatch/dispatch-manage',
    sort: 1,
    name: 'DispatchManage',
  },
  {
    id: 4,
    title: '服务单元管理',
    parentId: 1,
    url: '/service-unit/service-unit-manage',
    sort: 2,
    name: 'ServiceUnitManage',
  },
  {
    id: 5,
    title: '服务单元管理',
    parentId: 4,
    url: '/service-unit/service-unit-manage/unit-manage',
    sort: 1,
    name: 'UnitManage',
  },
  {
    id: 6,
    title: '服务范围管理',
    parentId: 4,
    url: '/service-unit/service-unit-manage/range-manage',
    sort: 2,
    name: 'RangeManage',
  },
  {
    id: 7,
    title: '服务区域规划',
    parentId: 4,
    url: '/service-unit/service-unit-manage/regional-planning',
    sort: 3,
    name: 'RegionalPlanning',
  },
  {
    id: 8,
    title: 'SOP管理',
    parentId: 0,
    url: '/sop',
    sort: 2,
    name: 'Sop',
  },
  {
    id: 9,
    title: 'SOP管理',
    parentId: 8,
    url: '/sop/sop-manage',
    sort: 1,
    name: 'SopManage',
  },
  {
    id: 10,
    title: '教务处SOP管理',
    parentId: 9,
    url: '/sop/sop-manage/office-sop',
    sort: 1,
    name: 'OfficeSop',
  },
  {
    id: 11,
    title: '研究生SOP管理',
    parentId: 9,
    url: '/sop/sop-manage/student-sop',
    sort: 2,
    name: 'StudentSop',
  },
  {
    id: 12,
    title: '研究生SOP管理',
    parentId: 9,
    url: '/sop/sop-manage/device-out-in',
    sort: 3,
    name: 'DeviceOutIn',
  },
  {
    id: 14,
    title: '项目计划变更报备',
    parentId: 9,
    url: '/sop/sop-manage/project-change-report',
    sort: 4,
    name: 'ProjectChangeReport',
  },
  {
    id: 15,
    title: 'SOP监控',
    parentId: 8,
    url: '/sop/sop-monitor',
    sort: 2,
    name: 'SopMonitor',
  },
  {
    id: 16,
    title: '延期预警',
    parentId: 15,
    url: '/sop/sop-monitor/delay-warning',
    sort: 2,
    name: 'DelayWarning',
  },
  {
    id: 17,
    title: '违规登记',
    parentId: 15,
    url: '/sop/sop-monitor/violation-registration',
    sort: 2,
    name: 'ViolationRegistration',
  },
  {
    id: 18,
    title: '资源保障',
    parentId: 0,
    url: '/resource-guard',
    sort: 3,
    name: 'ResourceGuard',
  },
  {
    id: 19,
    title: '人资保障',
    parentId: 18,
    url: '/resource-guard/person-guard',
    sort: 1,
    name: 'PersonGuard',
  },
  {
    id: 20,
    title: '人员档案管理',
    parentId: 19,
    url: '/resource-guard/person-guard/person-files',
    sort: 1,
    name: 'PersonFiles',
  },
  {
    id: 21,
    title: '人员调配',
    parentId: 19,
    url: '/resource-guard/person-guard/person-allocate',
    sort: 2,
    name: 'PersonAllocate',
  },
  {
    id: 22,
    title: '设备保障',
    parentId: 18,
    url: '/resource-guard/device-guard',
    sort: 2,
    name: 'DeviceGuard',
  },
  {
    id: 23,
    title: '出入库登记查询',
    parentId: 22,
    url: '/resource-guard/device-guard/registration-query',
    sort: 1,
    name: 'RegistrationQuery',
  },
  {
    id: 24,
    title: '设备资源监控',
    parentId: 22,
    url: '/resource-guard/device-guard/device-monitor',
    sort: 2,
    name: 'DeviceMonitor',
  },
  {
    id: 25,
    title: '工时管理',
    parentId: 0,
    url: '/work-hours',
    sort: 4,
    name: 'WorkHours',
  },
  {
    id: 26,
    title: '工时管理',
    parentId: 25,
    url: '/work-hours/work-hours-manage',
    sort: 1,
    name: 'WorkHoursManage',
  },
  {
    id: 27,
    title: '异常审核',
    parentId: 26,
    url: '/work-hours/work-hours-manage/abnormal-check',
    sort: 1,
    name: 'AbnormalCheck',
  },
  {
    id: 28,
    title: '考勤提交',
    parentId: 26,
    url: '/work-hours/work-hours-manage/work-attendance',
    sort: 2,
    name: 'WorkAttendance',
  },
  {
    id: 29,
    title: '工时统计',
    parentId: 26,
    url: '/work-hours/work-hours-manage/work-statistics',
    sort: 3,
    name: 'WorkStatistics',
  },
  {
    id: 30,
    title: '项目质量管理',
    parentId: 0,
    url: '/project-quality',
    sort: 6,
    name: 'ProjectQuality',
  },
  {
    id: 31,
    title: '项目质量管理',
    parentId: 30,
    url: '/project-quality/project-quality-manage',
    sort: 1,
    name: 'ProjectQualityManage',
  },
  {
    id: 32,
    title: '质量问题反馈',
    parentId: 31,
    url: '/project-quality/project-quality-manage/issues-feedback',
    sort: 1,
    name: 'IssuesFeedback',
  },
  {
    id: 51,
    title: '质量问题查询',
    parentId: 31,
    url: '/project-quality/project-quality-manage/issues-query',
    sort: 2,
    name: 'IssuesQuery',
  },
  {
    id: 33,
    title: '用户管理',
    parentId: 0,
    url: '/user',
    sort: 7,
    name: 'User',
  },
  {
    id: 34,
    title: '组织架构管理',
    parentId: 33,
    url: '/user/org-struct-manage',
    sort: 1,
    name: 'OrgStructManage',
  },
  {
    id: 35,
    title: '组织架构管理',
    parentId: 34,
    url: '/user/org-struct-manage/struct-manage',
    sort: 1,
    name: 'StructManage',
  },
  {
    id: 36,
    title: '用户权限管理',
    parentId: 33,
    url: '/user/auth-manage',
    sort: 1,
    name: 'AuthManage',
  },
  {
    id: 37,
    title: '用户管理',
    parentId: 36,
    url: '/user/auth-manage/user-manage',
    sort: 1,
    name: 'UserManage',
  },
  {
    id: 38,
    title: '角色管理',
    parentId: 36,
    url: '/user/auth-manage/role-manage',
    sort: 2,
    name: 'RoleManage',
  },
  {
    id: 39,
    title: '密码管理',
    parentId: 33,
    url: '/user/password-manage',
    sort: 3,
    name: 'PasswordManage',
  },
  {
    id: 40,
    title: '密码修改',
    parentId: 39,
    url: '/user/password-manage/password-modify',
    sort: 1,
    name: 'PasswordModify',
  },
  {
    id: 41,
    title: '系统管理',
    parentId: 0,
    url: '/system',
    sort: 8,
    name: 'System',
  },
  {
    id: 42,
    title: '配置管理',
    parentId: 41,
    url: '/system/config-manage',
    sort: 1,
    name: 'ConfigManage',
  },
  {
    id: 43,
    title: '客户配置',
    parentId: 42,
    url: '/system/config-manage/customer-manage',
    sort: 1,
    name: 'CustomerManage',
  },
  {
    id: 44,
    title: '供应商配置',
    parentId: 42,
    url: '/system/config-manage/supplier-manage',
    sort: 1,
    name: 'SupplierManage',
  },
  {
    id: 45,
    title: '设备配置',
    parentId: 42,
    url: '/system/config-manage/device-manage',
    sort: 1,
    name: 'DeviceManage',
  },
  {
    id: 46,
    title: '服务档位配置',
    parentId: 42,
    url: '/system/config-manage/service-level-manage',
    sort: 1,
    name: 'ServiceLevelManage',
  },
  {
    id: 47,
    title: '考勤配置',
    parentId: 42,
    url: '/system/config-manage/checkin-manage',
    sort: 1,
    name: 'CheckinManage',
  },
  {
    id: 48,
    title: '通知日志',
    parentId: 41,
    url: '/system/notice-log',
    sort: 2,
    name: 'NoticeLog',
  },
  {
    id: 49,
    title: '通知公告管理',
    parentId: 48,
    url: '/system/notice-log/notice-manage',
    sort: 1,
    name: 'NoticeManage',
  },
  {
    id: 50,
    title: '日志查询',
    parentId: 48,
    url: '/system/notice-log/log-manage',
    sort: 2,
    name: 'LogManage',
  },
];

export const menusApi = Mock.mock('/api/getMenus', 'get', () => {
  return menusList;
});

export const loginApi = Mock.mock('/api/login', 'post', (data) => {
  return {
    userName: '路人甲',
    id: Math.floor(Math.random() * 100 + 1),
    token: '123',
  };
});

export const addApi = Mock.mock('/api/add', 'post', (data) => {
  return {
    ok: true,
  };
});
export const editApi = Mock.mock('/api/edit', 'post', (data) => {
  return {
    ok: true,
  };
});

//模拟一个分页请求
const listTemplate = {
  'records|10': [
    {
      'id|+1': 1,
      'a|1-3': '11',
      'b|1-3': '22',
      'c|1-3': '33',
      'd|1-3': '44',
      'e|1-3': '55',
      'f|1-3': '66',
      'g|1-3': '77',
      'h|1-3': '88',
      'i|1-3': '99',
      'j|1-3': '11',
      'k|1-3': '22',
      'l|1-3': '33',
      'm|1-3': '44',
      'n|1-3': '55',
      'o|1-3': '66',
      'p|1-3': '77',
      'q|1-3': '88',
    },
  ],
  'total': 80,
};
export const tableApi = Mock.mock('/api/table', 'post', listTemplate);
export const dataListApi = Mock.mock(/\/api\/.*\/list$/, 'post', listTemplate);
export const dataListQueryApi = Mock.mock(
  /\/api\/.*\/query$/,
  'post',
  listTemplate
);
export const actionApi = Mock.mock(/\/api\/.*/, 'post', {
  ok: true,
});
