rightMenu.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div class="rightBtn">
  3. <a-menu v-model:selectedKeys="selectedKeys" style="width: 60px" mode="inline" theme="dark">
  4. <a-menu-item :key="item.key" class="btnItem" v-for="(item, idx) in listBtn" @click="selectBtn(item)">
  5. <div class="fcc">
  6. <component :is="item.icon"></component>
  7. </div>
  8. <div class="fcc">{{ item.title }}</div>
  9. </a-menu-item>
  10. </a-menu>
  11. <rightContent ref="formRef" :idsObj="props.idsObj" :rightItem="rightItem" @videoSpeed="videoSpeed"></rightContent>
  12. </div>
  13. </template>
  14. <script setup name="rightMenu">
  15. import classCentre from '@/api/student/classCentre'
  16. import rightContent from './form.vue'
  17. import { useRoute, useRouter } from 'vue-router'
  18. import { message } from 'ant-design-vue'
  19. const route = useRoute()
  20. const router = useRouter()
  21. const emit = defineEmits({ videoSpeed: null })
  22. const props = defineProps({
  23. dataList: {
  24. type: [Array, Object],
  25. default: () => []
  26. },
  27. idsObj: {
  28. type: [Array, Object],
  29. required: () => {}
  30. }
  31. })
  32. import {
  33. PlaySquareOutlined,
  34. FileTextOutlined,
  35. AlignCenterOutlined,
  36. SnippetsOutlined,
  37. CopyOutlined,
  38. ReadOutlined,
  39. QuestionCircleOutlined
  40. } from '@ant-design/icons-vue'
  41. const formRef = ref()
  42. const rightItem = ref({})
  43. const selectedKeys = ref([''])
  44. const btnList = ref([
  45. // {
  46. // title: '视频',
  47. // key: '1',
  48. // icon: PlaySquareOutlined,
  49. // type: 1
  50. // },
  51. {
  52. title: '讲义',
  53. key: '2',
  54. icon: FileTextOutlined,
  55. type: 1
  56. },
  57. {
  58. title: '字幕',
  59. key: '3',
  60. icon: AlignCenterOutlined,
  61. type: 1
  62. },
  63. {
  64. title: '作业',
  65. key: '4',
  66. icon: SnippetsOutlined,
  67. type: 3,
  68. routerUrl: '/student/do'
  69. },
  70. {
  71. title: '测验',
  72. key: '5',
  73. icon: CopyOutlined,
  74. type: 3,
  75. routerUrl: '/student/do'
  76. },
  77. {
  78. title: '笔记',
  79. key: '6',
  80. icon: ReadOutlined,
  81. type: 2
  82. },
  83. {
  84. title: '问答',
  85. key: '7',
  86. icon: QuestionCircleOutlined,
  87. type: 4
  88. }
  89. ])
  90. const selectBtn = (event, edit) => {
  91. if (event.type == 3) {
  92. if (event.relateId) {
  93. router.push({
  94. path: event.routerUrl,
  95. query: {
  96. id: event.relateId
  97. }
  98. })
  99. } else {
  100. message.error(`没有${event.key == 5 ? '测试' : '作业'}`)
  101. }
  102. } else {
  103. rightItem.value = event
  104. formRef.value.onOpen(edit ? edit : '')
  105. }
  106. }
  107. const listBtn = computed(() => {
  108. return btnList.value.map((r) => {
  109. const match = props.dataList.length && props.dataList.find((e) => r.key == e.funcType)
  110. return match ? { ...r, ...match } : r
  111. })
  112. })
  113. const videoSpeed = (e) => {
  114. emit('videoSpeed', e)
  115. }
  116. defineExpose({
  117. selectBtn
  118. })
  119. </script>
  120. <style scoped lang="less">
  121. .rightBtn {
  122. position: fixed;
  123. right: 0;
  124. top: 150px;
  125. z-index: 99999;
  126. }
  127. .fcc {
  128. display: flex;
  129. justify-content: center;
  130. align-items: center;
  131. }
  132. :deep(.btnItem) {
  133. height: auto;
  134. line-height: normal;
  135. padding: 10px 0 !important;
  136. }
  137. </style>