import { defineConfig } from '@umijs/max';

import locale from 'antd/es/calendar/locale/zh_CN';
import moment from 'moment';
moment.locale('zh-cn');

export default defineConfig({
  hash: true,
  antd: {},
  dva: {},
  access: {},
  model: {},
  initialState: {},
  request: {},
  layout: {
    title: '金科环境数字化管理平台',
    locale: false,
  },
  locale: {
    antd: true, // 如果项目依赖中包含 `antd`，则默认为 true
    baseNavigator: true,
    baseSeparator: '-',
    default: 'zh-CN',
    title: false,
    useLocalStorage: true,
  },
  title: '金科环境数字化管理平台',
  publicPath: process.env.NODE_ENV == 'development' ? '/' : '/gt-dig/',
  proxy: {
    '/api': {
      // target: 'http://47.96.12.136:8888/',
      target: 'http://47.96.12.136:8895/',
      // target: 'http://120.55.44.4:8902/',
      changeOrigin: true,
    },
  },
  // chainWebpack(config) {
  //   config.module
  //     .rule()
  //     .test(/\.(pdf|svg|docx|doc)$/)
  //     .use('file-loader?name=[path][name].[ext]')
  //     .loader('file-loader')
  //     .end()
  // },
  routes: [
    {
      path: '/',
      redirect: '/home',
    },
    {
      name: '首页',
      path: '/home',
      component: './Home/index',
      menuRender: false,
      icon: 'https://gt-digitization.oss-cn-hangzhou.aliyuncs.com/doc/department/2023-04/homeIcon.png',
    },
    {
      name: '审批流管理',
      path: '/flow',
      access: 'isAdmin',
      hideChildrenInMenu: true,
      icon: 'https://gt-digitization.oss-cn-hangzhou.aliyuncs.com/doc/department/2023-04/flowIcon.png',
      routes: [
        // {
        //   path: '/flow',
        //   redirect: '/flow/list',
        // },
        {
          name: '审批流管理',
          path: '/flow',
          component: './Flow/index',
        },
        {
          name: '审批流详情',
          path: '/flow/audit',
          component: './Flow/Audit',
          hideInMenu: true,
        },
      ],
    },
    {
      name: 'OA审批',
      path: '/oa',
      hideChildrenInMenu: true,
      icon: 'https://gt-digitization.oss-cn-hangzhou.aliyuncs.com/doc/department/2023-04/oaIcon.png',
      routes: [
        {
          name: 'OA审批',
          path: '/oa',
          component: './Flow/Oa',
        },
        {
          name: 'OA详情',
          path: '/oa/detail/:oaId',
          component: './Flow/OaDetail',
        },
      ],
    },
    // {
    //   name: '权限演示',
    //   path: '/access',
    //   component: './Access',
    // },
    // {
    //   name: 'CRUD 示例',
    //   path: '/table',
    //   component: './Table',
    // },
    {
      name: '登录',
      path: '/login',
      component: './Login/index',
      layout: false,
    },
    {
      name: '文档管理',
      path: '/fileManagement',
      component: './FileManagement/index',
      icon: 'https://gt-digitization.oss-cn-hangzhou.aliyuncs.com/doc/department/2023-04/fileIcon.png',
    },
    {
      name: '合同管理',
      path: '/contract-manager',
      component: './ContractManager/index',
      icon: 'https://gt-digitization.oss-cn-hangzhou.aliyuncs.com/doc/department/2023-04/contractIcon.png',
    },
    // {
    //   name: '授权管理',
    //   path: '/permission',
    //   routes: [
    //     {
    //       name: '菜单授权',
    //       path: '/permission/menu',
    //       component: './Permission/menu',
    //     },
    //     {
    //       name: '文档管理',
    //       path: '/permission/file',
    //       component: './Permission/file',
    //     },
    //   ],
    // },
    {
      name: '个人中心',
      path: '/profile',
      icon: 'https://gt-digitization.oss-cn-hangzhou.aliyuncs.com/doc/department/2023-04/profileIcon.png',
      routes: [
        {
          name: '我的申请',
          path: '/profile/apply',
          component: './Profile/apply',
        },
        {
          name: '我的审批',
          path: '/profile/approve',
          component: './Profile/approve',
        },
        {
          name: '已审核',
          path: '/profile/approved',
          component: './Profile/approved',
        },
      ],
      // component: './Profile/index',
      // hideInMenu: true,
    },
    // {
    //   name: '个人中心',
    //   path: '/profile',
    //   component: './Profile/index',
    //   hideInMenu: true,
    // },
    {
      name: '审批详情',
      path: '/profile/:id',
      component: './Flow/OaAuditDetail',
      hideInMenu: true,
    },
    {
      name: '供应商管理',
      path: '/manufacturer',
      component: './ManufacturerMng/Firm',
      icon: 'https://gt-digitization.oss-cn-hangzhou.aliyuncs.com/doc/department/2023-04/manufacturerIcon.png',
    },
    {
      name: '人日立项',
      path: '/workload',
      icon: 'https://gt-digitization.oss-cn-hangzhou.aliyuncs.com/doc/department/2023-04/manufacturerIcon.png',
      routes: [
        {
          name: '工时管理',
          path: '/workload',
          icon: 'https://gt-digitization.oss-cn-hangzhou.aliyuncs.com/doc/department/2023-04/manufacturerIcon.png',
          routes: [
            {
              name: '上报工时',
              path: 'work-hours',
              component: './PurchaseList/WorkingHours/index',
            },
            {
              name: '审批工时',
              path: 'work-hours-auth',
              component: './PurchaseList/WorkingHours/Auth',
            },
          ],
        },
        {
          name: '项目立项',
          path: '/workload/approval',
          icon: 'https://gt-digitization.oss-cn-hangzhou.aliyuncs.com/doc/department/2023-04/manufacturerIcon.png',
          routes: [
            {
              name: '项目列表',
              path: 'list',
              component: './PurchaseList/Approval/List',
            },
            {
              name: '审核列表',
              path: 'auth',
              component: './PurchaseList/Approval/Auth',
            },
          ],
        },
        {
          name: '工时报表',
          path: '/workload/report',
          icon: 'https://gt-digitization.oss-cn-hangzhou.aliyuncs.com/doc/department/2023-04/manufacturerIcon.png',
          routes: [
            {
              name: '项目报表',
              path: 'project',
              component: './PurchaseList/Report/ProjectTree',
            },
            {
              name: '部门报表',
              path: 'department',
              component: './PurchaseList/Report/Department',
            },
          ],
        },
        {
          name: '财务报表',
          path: '/workload/finance',
          icon: 'https://gt-digitization.oss-cn-hangzhou.aliyuncs.com/doc/department/2023-04/manufacturerIcon.png',
          routes: [
            {
              name: '资源总表',
              path: 'index',
              component: './PurchaseList/Report/Finance',
            },
            {
              name: '资源中心人日使用汇总表',
              path: 'resources',
              component: './PurchaseList/Report/Finance/Resources',
            },
            {
              name: '执行项目人日汇总表',
              path: 'project',
              component: './PurchaseList/Report/Finance/Project',
            },
          ],
        },
      ],
    },

    // {checkReport(3) && (
    //   // <Menu.Item key="/home/report/finance">
    //   //   <Link to="/home/report/finance">财务报表</Link>
    //   // </Menu.Item>
    //   <SubMenu key="/home/report/finance" title="财务报表">
    //     <Menu.Item key="/home/report/finance">
    //       <Link to="/home/report/finance">资源总表</Link>
    //     </Menu.Item>
    //     <Menu.Item key="/home/report/finance/resources">
    //       <Link to="/home/report/finance/resources">
    //         资源中心人日使用汇总表
    //       </Link>
    //     </Menu.Item>
    //     <Menu.Item key="/home/report/finance/project">
    //       <Link to="/home/report/finance/project">
    //         执行项目人日汇总表
    //       </Link>
    //     </Menu.Item>
    //   </SubMenu>
    // )}
  ],
  npmClient: 'yarn',
});
