import Vue from 'vue'
import Router from 'vue-router'


// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const Login = () => import('@/components/Login')
const Index = () => import('@/components/Index')
const Home01 = () => import( /* webpackChunkName: "shouye" */ '@/components/home/Home01')
const UserManger = () => import('@/components/UserManger')


//---------------------------------------溯源模块------------------------------农场管理----------------------
const FarmUserManger = () => import('@/Pages/symanger/farm/User')
const FarmFieldsManger = () => import('@/Pages/symanger/farm/Fields')
const FarmBaseManger = () => import( /* webpackChunkName: "syFarmBase" */ '@/Pages/symanger/farm/Base')
const FarmAddBase = () => import( /* webpackChunkName: "syFarmBase" */ '@/Pages/symanger/farm/AddBase')
const FarmEditBase = () => import( /* webpackChunkName: "syFarmBase" */ '@/Pages/symanger/farm/EditBase')

//---------------------------------------溯源模块------------------------------溯源信息----------------------
const ResultInfoList = () => import( /* webpackChunkName: "resultInfo" */ '@/Pages/symanger/resultInfo/resultInfoList')
const ResultInfoEdit = () => import( /* webpackChunkName: "resultInfo" */ '@/Pages/symanger/resultInfo/resultInfoEdit')
const TracebackDetail = () => import( /* webpackChunkName: "resultInfo" */ '@/Pages/symanger/resultInfo/tracebackDetail')
const TracebackDetailApp = () => import( /* webpackChunkName: "resultInfo" */ '@/Pages/symanger/resultInfo/tracebackDetailApp')

//---------------------------------------溯源模块------------------------------农事管理----------------------
const FarmThingPlant = () => import('@/Pages/symanger/farmThing/plant')
const FarmThingspray = () => import('@/Pages/symanger/farmThing/spray')
const FarmThingApplyFertilizer = () => import('@/Pages/symanger/farmThing/applyFertilizer')
const FarmThingWatering = () => import('@/Pages/symanger/farmThing/watering')
const FarmThingHarvest = () => import('@/Pages/symanger/farmThing/harvest')
const FarmThingMore = () => import('@/Pages/symanger/farmThing/more')
const FarmThingStockIn = () => import('@/Pages/symanger/farmThing/stockIn')
const FarmThingStockOut = () => import('@/Pages/symanger/farmThing/stockOut')
const FarmThingStock = () => import('@/Pages/symanger/farmThing/stock')
const FarmThingSale = () => import('@/Pages/symanger/farmThing/sale')
const FarmThingTransport = () => import('@/Pages/symanger/farmThing/transport')

Vue.use(Router)

export default new Router({
  routes: [{
      path: '',
      redirect: '/index/farmBaseManger'
    },
    {
      path: '/login',
      component: Login
    },
    {
      path: '/index',
      component: Index,
      children: [{
          path: '',
          redirect: '/index/farmBaseManger'
        },
        {
          path: 'home',
          component: Home01
        },
        //-------------------溯源模块-----------农场管理----------
        {
          path: 'farmUserManger',
          component: FarmUserManger
        },
        {
          path: 'farmFieldsManger',
          component: FarmFieldsManger
        },
        {
          path: 'farmBaseManger',
          component: FarmBaseManger
        },
        {
          path: 'farmAddBase',
          component: FarmAddBase
        },
        {
          path: 'farmEditBase',
          component: FarmEditBase
        },
        //-------------------溯源模块-----------溯源信息----------
        {
          path: 'resultInfoList',
          component: ResultInfoList
        },
        {
          path: 'resultInfoEdit',
          component: ResultInfoEdit
        },
        //-------------------溯源模块-----------农事管理----------
        {
          path: 'farmThingPlant',
          component: FarmThingPlant
        },
        {
          path: 'farmThingspray',
          component: FarmThingspray
        },
        {
          path: 'farmThingApplyFerti',
          component: FarmThingApplyFertilizer
        },
        {
          path: 'farmThingWatering',
          component: FarmThingWatering
        },
        {
          path: 'farmThingHarvest',
          component: FarmThingHarvest
        },
        {
          path: 'farmThingMore',
          component: FarmThingMore
        },
        {
          path: 'farmThingStockIn',
          component: FarmThingStockIn
        },
        {
          path: 'farmThingStockOut',
          component: FarmThingStockOut
        },
        {
          path: 'farmThingStock',
          component: FarmThingStock
        },
        {
          path: 'farmThingSale',
          component: FarmThingSale
        },
        {
          path: 'farmThingTransport',
          component: FarmThingTransport
        },
        {
          path: 'userManger',
          component: UserManger
        },
      ]
    },
    //-------------------溯源模块-----------溯源中心----------
    {
      path: '/tracebackDetail/:backcode',
      name:'TracebackDetail',
      component: TracebackDetail,
    },
    {
      path: '/tracebackDetailApp/:backcode',
      name:'TracebackDetailApp',
      component: TracebackDetailApp,
    },
  ],
  // mode:'history'
})