图片.png

图片.png图片.png图片.png

一、需求


图片.png图片.png图片.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组件

图片.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

  1. <template>
  2. <div class="app-container">
  3. <h2 style="text-align: center;">发布新课程</h2>
  4. <el-steps :active="2" 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 @click="previous">上一步</el-button>
  12. <el-button :disabled="saveBtnDisabled" type="primary" @click="next">下一步</el-button>
  13. </el-form-item>
  14. </el-form>
  15. </div>
  16. </template>
  17. <script>
  18. export default {
  19. data() {
  20. return {
  21. saveBtnDisabled: false // 保存按钮是否禁用
  22. }
  23. },
  24. created() {
  25. console.log('chapter created')
  26. },
  27. methods: {
  28. previous() {
  29. console.log('previous')
  30. this.$router.push({ path: '/edu/course/info/1' })
  31. },
  32. next() {
  33. console.log('next')
  34. this.$router.push({ path: '/edu/course/publish/1' })
  35. }
  36. }
  37. }
  38. </script>

3、课程发布页面

publish.vue

  1. <template>
  2. <div class="app-container">
  3. <h2 style="text-align: center;">发布新课程</h2>
  4. <el-steps :active="3" 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 @click="previous">返回修改</el-button>
  12. <el-button :disabled="saveBtnDisabled" type="primary" @click="publish">发布课程</el-button>
  13. </el-form-item>
  14. </el-form>
  15. </div>
  16. </template>
  17. <script>
  18. export default {
  19. data() {
  20. return {
  21. saveBtnDisabled: false // 保存按钮是否禁用
  22. }
  23. },
  24. created() {
  25. console.log('publish created')
  26. },
  27. methods: {
  28. previous() {
  29. console.log('previous')
  30. this.$router.push({ path: '/edu/course/chapter/1' })
  31. },
  32. publish() {
  33. console.log('publish')
  34. this.$router.push({ path: '/edu/course/list' })
  35. }
  36. }
  37. }
  38. </script>