一、需求

image.png

image.png
image.png

二、配置路由

1、添加路由

  1. // 课程管理
  2. {
  3. path: '/edu/course',
  4. component: Layout,
  5. redirect: '/edu/course/list',
  6. name: 'Course',
  7. meta: { title: '课程管理', icon: 'form' },
  8. children: [
  9. {
  10. path: 'list',
  11. name: 'EduCourseList',
  12. component: () => import('@/views/edu/course/list'),
  13. meta: { title: '课程列表' }
  14. },
  15. {
  16. path: 'info',
  17. name: 'EduCourseInfo',
  18. component: () => import('@/views/edu/course/info'),
  19. meta: { title: '发布课程' }
  20. },
  21. {
  22. path: 'info/:id',
  23. name: 'EduCourseInfoEdit',
  24. component: () => import('@/views/edu/course/info'),
  25. meta: { title: '编辑课程基本信息', noCache: true },
  26. hidden: true
  27. },
  28. {
  29. path: 'chapter/:id',
  30. name: 'EduCourseChapterEdit',
  31. component: () => import('@/views/edu/course/chapter'),
  32. meta: { title: '编辑课程大纲', noCache: true },
  33. hidden: true
  34. },
  35. {
  36. path: 'publish/:id',
  37. name: 'EduCoursePublishEdit',
  38. component: () => import('@/views/edu/course/publish'),
  39. meta: { title: '发布课程', noCache: true },
  40. hidden: true
  41. }
  42. ]
  43. },

2、添加vue组件

image.png

三、整合步骤条组件

参考 http://element-cn.eleme.io/#/zh-CN/component/steps

1、课程信息页面

info.vue

  1. <template>
  2. <div class="app-container">
  3. <h2 style="text-align: center;">发布新课程</h2>
  4. <el-steps :active="1" process-status="wait" align-center style="margin-bottom: 40px;">
  5. <el-step title="填写课程基本信息"/>
  6. <el-step title="创建课程大纲"/>
  7. <el-step title="提交审核"/>
  8. </el-steps>
  9. <el-form label-width="120px">
  10. <el-form-item>
  11. <el-button :disabled="saveBtnDisabled" type="primary" @click="next">保存并下一步</el-button>
  12. </el-form-item>
  13. </el-form>
  14. </div>
  15. </template>
  16. <script>
  17. export default {
  18. data() {
  19. return {
  20. saveBtnDisabled: false // 保存按钮是否禁用
  21. }
  22. },
  23. created() {
  24. console.log('info created')
  25. },
  26. methods: {
  27. next() {
  28. console.log('next')
  29. this.$router.push({ path: '/edu/course/chapter/1' })
  30. }
  31. }
  32. }
  33. </script>

2、课程大纲页面

chapter.vue

<template>


  <div class="app-container">


    <h2 style="text-align: center;">发布新课程</h2>


    <el-steps :active="2" process-status="wait" align-center style="margin-bottom: 40px;">
      <el-step title="填写课程基本信息"/>
      <el-step title="创建课程大纲"/>
      <el-step title="提交审核"/>
    </el-steps>


    <el-form label-width="120px">


      <el-form-item>
        <el-button @click="previous">上一步</el-button>
        <el-button :disabled="saveBtnDisabled" type="primary" @click="next">下一步</el-button>
      </el-form-item>
    </el-form>
  </div>

</template>


  <script>


  iport default {
  data() {
    return {
      saveBtnDisabled: false // 保存按钮是否禁用
    }
  },


  created() {
    console.log('chapter created')
  },


  methods: {
    previous() {
      console.log('previous')
      this.$router.push({ path: '/edu/course/info/1' })
    },


    next() {
      console.log('next')
      this.$router.push({ path: '/edu/course/publish/1' })
    }
  }

}
</script>

3、课程发布页面

publish.vue

<template>


  <div class="app-container">


    <h2 style="text-align: center;">发布新课程</h2>


    <el-steps :active="3" process-status="wait" align-center style="margin-bottom: 40px;">
      <el-step title="填写课程基本信息"/>
      <el-step title="创建课程大纲"/>
      <el-step title="提交审核"/>
    </el-steps>


    <el-form label-width="120px">


      <el-form-item>
        <el-button @click="previous">返回修改</el-button>
        <el-button :disabled="saveBtnDisabled" type="primary" @click="publish">发布课程</el-button>
      </el-form-item>
    </el-form>
  </div>

</template>
<script>
export default {
  data() {
    return {
      saveBtnDisabled: false // 保存按钮是否禁用
    }
  },


  created() {
    console.log('publish created')
  },



  methods: {
    previous() {
      console.log('previous')
      this.$router.push({ path: '/edu/course/chapter/1' })
    },


    publish() {
      console.log('publish')
      this.$router.push({ path: '/edu/course/list' })
    }
  }

}
</script>