import { createRouter,createWebHashHistory } from "vue-router";
import layout from "@/layout/index"; //layout直接引用 其他使用路由懒加载
import store from "@/store";

// import Home from '../views/Home.vue'
/**
 * 关于路由配置描述
 * 1.meta && meta.title && meta.icon  则在菜单栏显示
 * 2.如果存在children , 则以el-sub-menu子菜单显示
 * 否则不在menu菜单显示
 * 如果只展示单级别菜单  需要像developer这样配置
 */

/**
 * 私有路由表
 */

export const privateRoutes = [
  {
    path: "/systemConfig",
    component: layout,
    name: "systemConfigModel",
    redirect: "/dict/index",
    meta: {
      title: "系统管理",
      icon: "article"
    },
    children: [
      {
        path: "/user/department-ist",
        name: "departmentList",
        component: () => import("@/views/backOfficeSystem/systemConfig/department-list/index"),
        meta: {
          title: "部门管理",
          icon: "article-ranking"
        }
      },

      {
        path: "/user/userList",
        name: "userList",
        component: () => import("@/views/backOfficeSystem/systemConfig/user-list/index"),
        meta: {
          title: "用户管理",
          icon: "article-ranking"
        }
      },
      {
        path: "/user/role",
        name: "userRoleIndex",
        component: () => import("@/views/backOfficeSystem/systemConfig/role-list/index"),
        meta: {
          title: "角色列表",
          icon: "article-ranking"
        }
      },
      {
        path: "/user/menuList",
        name: "menuList",
        component: () => import("@/views/backOfficeSystem/systemConfig/menu-list/index"),
        meta: {
          title: "菜单管理",
          icon: "article-ranking"
        }
      },
      
      {
        path: "/dict/detail",
        name: "dictDetail",
        component: () => import("@/views/backOfficeSystem/systemConfig/dict/detail"),
        meta: {
          title: "字典数据"
        }
      },
      {
        path: "/dict/index",
        name: "dictIndex",
        component: () => import("@/views/backOfficeSystem/systemConfig/dict/index"),
        meta: {
          title: "字典列表",
          icon: "article-ranking"
        }
      },
     
      {
        path: "/user/deptAllocationUser/:id",
        name: "deptAllocationUser",
        component: () =>
          import("@/views/backOfficeSystem/systemConfig/department-list/deptAllocationUser"),
        meta: {
          title: "管理用户"
        }
      },
      {
        path: "/user/allocationUser/:id",
        name: "allocationUser",
        component: () =>
          import("@/views/backOfficeSystem/systemConfig/role-list/allocationUser"),
        meta: {
          title: "分配用户"
        }
      },
     
      {
        path: "/user/systemConfig",
        name: "systemConfig",
        component: () =>
          import("@/views/backOfficeSystem/systemConfig/system-config-list/index"),
        meta: {
          title: "系统配置",
          icon: "article-ranking"
        }
      },
    ]
  },
];

/**
 * 公开路由表
 */
export const publicRoutes = [
  
  {
    path: "/login",
    name:'login',
    component: () => import("@/views/login/index") 
  },
  {
    path: "/",
    name:'home',
    component: () => import("@/views/home/index") //系统登录
  },
  {
    path: "/KeyPopulations",
    name:'KeyPopulations',
    component: () => import("@/views/KeyPopulations/index") //系统登录
  },
  {
    path: "/editPassword",// 注意：带有路径“/”的记录中的组件“默认”是一个不返回 Promise 的函数
    component: layout,
    redirect: "/IdentityManage",
    children: [
      
    {
      path: "/FourColorWarning",
      name: "FourColorWarning",
      meta: { title: "四色预警管理", icon: "article" },
      children: [
        {
          path: "/IdentityManage",
          name: "IdentityManage",
          component: () => import("@/views/backOfficeSystem/fourColorManage/IdentityManage/index"),
          meta: {
            title: "身份标签管理",
            icon: "article"
          }
        },
        {
          path: "/BehaviorLabels",
          name: "BehaviorLabels",
          component: () => import("@/views/backOfficeSystem/fourColorManage/BehaviorLabels/index"),
          meta: {
            title: "行为标签管理",
            icon: "article"
          }
        },
        {
          path: "/tagManage",
          name: "tagManage",
          component: () => import("@/views/backOfficeSystem/fourColorManage/tagManage/index"),
          meta: {
            title: "标签组合管理",
            icon: "article"
          }
        },
      ],
    },

    {
      path: "/IntelligentControl",
      name: "IntelligentControl",
      meta: { title: "智能布控", icon: "article" },
      children: [
        {
          path: "/warningControl",
          name: "warningControl",
          component: () => import("@/views/backOfficeSystem/IntelligentControl/warningControl/index"),
          meta: {
            title: "预警布控",
            icon: "article"
          }
        },
        {
          path: "/myControl",
          name: "myControl",
          component: () => import("@/views/backOfficeSystem/IntelligentControl/myControl/index"),
          meta: {
            title: "我的布控",
            icon: "article"
          }
        },
        {
          path: "/ControlApproval",
          name: "ControlApproval",
          component: () => import("@/views/backOfficeSystem/IntelligentControl/ControlApproval/index"),
          meta: {
            title: "布控审批",
            icon: "article"
          }
        },
      ]
    },
    {
      path: "/ResearchJudgment",
      name: "ResearchJudgment",
      meta: { title: "线索研判盯办系统", icon: "article" },
      children: [
        {
          path: "/DatAcquisition",
          name: "DatAcquisition",
          component: () => import("@/views/backOfficeSystem/ResearchJudgment/DatAcquisition/index"),
          meta: {
            title: "情报数据采集",
            icon: "article"
          }
        },
        {
          path: "/MoralAnalysis",
          name: "MoralAnalysis",
          component: () => import("@/views/backOfficeSystem/ResearchJudgment/MoralAnalysis/index"),
          meta: {
            title: "情报语义分析",
            icon: "article"
          }
        },
        {
          path: "/IntelligenceManagement",
          name: "IntelligenceManagement",
          component: () => import("@/views/backOfficeSystem/ResearchJudgment/IntelligenceManagement/index"),
          meta: {
            title: "情报管理",
            icon: "article"
          }
        },
        {
          path: "/InformationFlows",
          name: "InformationFlows",
          meta: { title: "情报流转", icon: "article" },
          redirect: "/InformationFlow",
          children: [
            {
              path: "/InformationFlow",
              name: "InformationFlow",
              component: () => import("@/views/backOfficeSystem/ResearchJudgment/InformationFlows/InformationFlow/index"),
              meta: {
                title: "情报信息流转",
                icon: "article"
              }
            },
            {
              path: "/InstructionInformation",
              name: "InstructionInformation",
              component: () => import("@/views/backOfficeSystem/ResearchJudgment/InformationFlows/InstructionInformation/index"),
              meta: {
                title: "指令信息",
                icon: "article"
              }
            },
            {
              path: "/StatisticalAnalysis",
              name: "StatisticalAnalysis",
              component: () => import("@/views/backOfficeSystem/ResearchJudgment/InformationFlows/StatisticalAnalysis/index"),
              meta: {
                title: "情报统计分析",
                icon: "article"
              }
            },
          ]
        },
        {
          path: "/RecordsOperations",
          name: "RecordsOperations",
          component: () => import("@/views/backOfficeSystem/ResearchJudgment/RecordsOperations/index"),
          meta: {
            title: "操作记录",
            icon: "article"
          }
        },
      ],
    },
    {
      path: "/HumanIntelligence",
      name: "HumanIntelligence",
      meta: { title: "人力情报采集管理系统", icon: "article" },
      children: [
        {
          path: "/RlStatisticalAnalysis",
          name: "RlStatisticalAnalysis",
          component: () => import("@/views/backOfficeSystem/HumanIntelligence/RlStatisticalAnalysis/index"),
          meta: {
            title: "人力情报统计分析",
            icon: "article"
          }
        },
        {
          path: "/CollectCrculate",
          name: "CollectCrculate",
          component: () => import("@/views/backOfficeSystem/HumanIntelligence/CollectCrculate/index"),
          meta: {
            title: "人力情报信息采集流转",
            icon: "article"
          }
        },
        {
          path: "/TaskScheduling",
          name: "TaskScheduling",
          component: () => import("@/views/backOfficeSystem/HumanIntelligence/TaskScheduling/index"),
          meta: {
            title: "人力情报信息搜索任务调度",
            icon: "article"
          }
        },
        {
          path: "/ConstructionManagement",
          name: "ConstructionManagement",
          component: () => import("@/views/backOfficeSystem/HumanIntelligence/ConstructionManagement/index"),
          meta: {
            title: "社会信息人员建设管理",
            icon: "article"
          }
        },
      ],
    },
    {
      path: "/ExcavationResearch",
      name: "ExcavationResearch",
      meta: { title: "重点人发掘研判", icon: "article" },
      children: [
        {
          path: "/ZdryFjyp",
          name: "ZdryFjyp",
          component: () => import("@/views/backOfficeSystem/ExcavationResearch/ZdryFjyp/index"),
          meta: {
            title: "重点人员发掘研判",
            icon: "article"
          }
        },
        {
          path: "/PreliminaryExcavations",
          name: "PreliminaryExcavations",
          component: () => import("@/views/backOfficeSystem/ExcavationResearch/PreliminaryExcavations/index"),
          meta: {
            title: "重点人员初步发掘",
            icon: "article"
          }
        },
        {
          path: "/LandingAudit",
          name: "LandingAudit",
          component: () => import("@/views/backOfficeSystem/ExcavationResearch/LandingAudit/index"),
          meta: {
            title: "重点人员落地审核",
            icon: "article"
          }
        },
        {
          path: "/WarningModel",
          name: "WarningModel",
          component: () => import("@/views/backOfficeSystem/ExcavationResearch/WarningModel/index"),
          meta: {
            title: "重点人员预警模型",
            icon: "article"
          }
        },
      ],
    },

     // ）））））））））））））））））））））
    
    
    {
      path: "/CivilExplosives",
      name: "CivilExplosives",
      meta: { title: "民爆业务", icon: "article" },
      children: [
        {
          path: "/BlastingAccidents",
          name: "BlastingAccidents",
          component: () => import("@/views/backOfficeSystem/CivilExplosives/BlastingAccidents/index"),
          meta: {
            title: "爆破事故登记信息",
            icon: "article"
          }
        },
        {
          path: "/BlastingOperations",
          name: "BlastingOperations",
        component: () => import("@/views/backOfficeSystem/CivilExplosives/BlastingOperations/index"),
          meta: {
            title: "爆破作业项目信息",
            icon: "article"
          }
        },
        {
          path: "/ExplosionAccidents",
          name: "ExplosionAccidents",
        component: () => import("@/views/backOfficeSystem/CivilExplosives/ExplosionAccidents/index"),
          meta: {
            title: "爆炸事故单位信息",
            icon: "article"
          }
        },
        {
          path: "/PersonnelInformation",
          name: "PersonnelInformation",
        component: () => import("@/views/backOfficeSystem/CivilExplosives/PersonnelInformation/index"),
          meta: {
            title: "爆炸事故人员信息",
            icon: "article"
          }
        },
        {
          path: "/ExplosivesRelated",
          name: "ExplosivesRelated",
        component: () => import("@/views/backOfficeSystem/CivilExplosives/ExplosivesRelated/index"),
          meta: {
            title: "涉爆从业单位",
            icon: "article"
          }
        },
        {
          path: "/Illegal",
          name: "Illegal",
          component: () => import("@/views/backOfficeSystem/CivilExplosives/Illegal/index"),
          meta: {
            title: "涉爆违章项目信息",
            icon: "article"
          }
        },
        {
          path: "/KeyPersonnel",
          name: "KeyPersonnel",
          component: () => import("@/views/backOfficeSystem/CivilExplosives/KeyPersonnel/index"),
          meta: {
            title: "涉爆重点人员",
            icon: "article"
          }
        },
        {
          path: "/SuspensionInfo",
          name: "SuspensionInfo",
          component: () => import("@/views/backOfficeSystem/CivilExplosives/SuspensionInfo/index"),
          meta: {
            title: "停产停业信息",
            icon: "article"
          }
        },
        {
          path: "/ViolationRegistration",
          name: "ViolationRegistration",
          component: () => import("@/views/backOfficeSystem/CivilExplosives/ViolationRegistration/index"),
          meta: {
            title: "违章登记信息",
            icon: "article"
          }
        },
        {
          path: "/ViolationPersonnel",
          name: "ViolationPersonnel",
          component: () => import("@/views/backOfficeSystem/CivilExplosives/ViolationPersonnel/index"),
          meta: {
            title: "违章人员信息",
            icon: "article"
          }
        },
        {
          path: "/Warehouse",
          name: "Warehouse",
          component: () => import("@/views/backOfficeSystem/CivilExplosives/Warehouse/index"),
          meta: {
            title: "库房管理",
            icon: "article"
          }
        },
      ],
    },
    {
      path: "/ThriftTrading",
      name: "ThriftTrading",
      meta: { title: "旧货交易", icon: "article" },
      children: [
        {
          path: "/TradeTtems",
          name: "TradeTtems",
          component: () => import("@/views/backOfficeSystem/ThriftTrading/TradeTtems/index"),
          meta: {
            title: "交易物品信息管理",
            icon: "article"
          }
        },
        {
          path: "/TradingVenues",
          name: "TradingVenues",
          component: () => import("@/views/backOfficeSystem/ThriftTrading/TradingVenues/index"),
          meta: {
            title: "旧货交易业场所管理",
            icon: "article"
          }
        },
        {
          path: "/TradingBusiness",
          name: "TradingBusiness",
          component: () => import("@/views/backOfficeSystem/ThriftTrading/TradingBusiness/index"),
          meta: {
            title: "旧货交易业务信息管理",
            icon: "article"
          }
        },
      ],
    },
  ]},
];


const router = createRouter({
  history: createWebHashHistory(),
  routes: publicRoutes
});
//初始化路由表
export function resetRouter() {
  if (store.getters ?.routeReady && store.getters ?.userInfo ?.permission ?.menus) {
    const menus = store.getters.userInfo.permission.menus;
    menus.forEach((menu) => {
      router.removeRoute(menu);
    });
  }
}
export default router;
