smart.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <div class="smart_container">
  3. <el-card class="mb10">
  4. <div class="smart_tabs">
  5. <div
  6. class="tab pointer"
  7. v-for="item in tabList"
  8. :class="tabActive == item.code ? 'tab_active' : ''"
  9. @click="switchTab(item.code)"
  10. >
  11. {{ item.label }}
  12. </div>
  13. </div>
  14. </el-card>
  15. <div>
  16. <SmartOnline :requireFields="requireFields" :tabActive="tabActive" :queryParams="queryParams"></SmartOnline>
  17. </div>
  18. </div>
  19. </template>
  20. <script>
  21. import SmartOnline from './components/smart-online'
  22. export default {
  23. components:{
  24. SmartOnline
  25. },
  26. data() {
  27. return {
  28. tabActive:0,
  29. tabList:[
  30. {
  31. label:'同步在线练习',
  32. code:0
  33. },
  34. {
  35. label:'知识点在线练习',
  36. code:1
  37. }
  38. ],
  39. }
  40. },
  41. created() {
  42. // 设置默认高亮
  43. this.tabActive = this.$route.query.tabActive ? this.$route.query.tabActive : 0
  44. },
  45. computed:{
  46. queryParams(){
  47. if(this.tabActive == 0) return {
  48. exeSubject: '',
  49. exeOrder: '',
  50. exeGrade: ''
  51. }
  52. if(this.tabActive == 1) return { exeSubject: '',}
  53. },
  54. requireFields(){
  55. if(this.tabActive == 0) return ['exeSubject','exeOrder','exeGrade']
  56. if(this.tabActive == 1) return ['exeSubject']
  57. },
  58. },
  59. methods:{
  60. switchTab(code) {
  61. this.tabActive = code
  62. }
  63. }
  64. }
  65. </script>
  66. <style scoped>
  67. .smart_container {
  68. padding: 20px;
  69. background: #f7f7f7;
  70. }
  71. .smart_tabs {
  72. display: flex;
  73. align-items: center;
  74. margin-bottom: 12px;
  75. }
  76. .smart_tabs .tab {
  77. text-align: center;
  78. flex: 1;
  79. padding: 8px 0 24px 0;
  80. border-bottom: 4px solid transparent;
  81. }
  82. .smart_tabs .tab_active {
  83. color: #47c6a2;
  84. border-bottom: 4px solid #47c6a2;
  85. }
  86. </style>