rightMenu.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. FileOutlined
  41. } from '@ant-design/icons-vue'
  42. const formRef = ref()
  43. const rightItem = ref({})
  44. const selectedKeys = ref([''])
  45. const btnList = ref([
  46. // {
  47. // title: '视频',
  48. // key: '1',
  49. // icon: PlaySquareOutlined,
  50. // type: 1
  51. // },
  52. {
  53. title: '讲义',
  54. key: '2',
  55. icon: FileTextOutlined,
  56. type: 1
  57. },
  58. {
  59. title: '字幕',
  60. key: '3',
  61. icon: AlignCenterOutlined,
  62. type: 1
  63. },
  64. {
  65. title: '作业',
  66. key: '4',
  67. icon: SnippetsOutlined,
  68. type: 3,
  69. routerUrl: '/student/do',
  70. routerSrc: '/student/read'
  71. },
  72. {
  73. title: '测验',
  74. key: '5',
  75. icon: CopyOutlined,
  76. type: 3,
  77. routerUrl: '/student/do',
  78. routerSrc: '/student/read'
  79. },
  80. {
  81. title: '笔记',
  82. key: '6',
  83. icon: ReadOutlined,
  84. type: 2
  85. },
  86. {
  87. title: '问答',
  88. key: '7',
  89. icon: QuestionCircleOutlined,
  90. type: 4
  91. },
  92. {
  93. title: '考试',
  94. key: '8',
  95. icon: FileOutlined,
  96. type: 3,
  97. routerUrl: '/student/paper/1',
  98. relateId: route.query.id
  99. }
  100. ])
  101. const selectBtn = (event, edit) => {
  102. if (event.type == 3) {
  103. if (event.relateId) {
  104. if (event.key == '4' || event.key == '5') {
  105. window.open(`${event.status == 2 ? event.routerSrc : event.routerUrl}?id=${event.relateId}`, '_blank')
  106. } else {
  107. router.push({
  108. path: event.routerUrl,
  109. query: {
  110. id: event.relateId
  111. }
  112. })
  113. }
  114. } else {
  115. message.error(`没有${event.key == 5 ? '测试' : '作业'}`)
  116. }
  117. } else {
  118. rightItem.value = event
  119. formRef.value.onOpen(edit ? edit : '')
  120. }
  121. }
  122. const listBtn = computed(() => {
  123. return btnList.value.map((r) => {
  124. const match = props.dataList.length && props.dataList.find((e) => r.key == e.funcType)
  125. return match ? { ...r, ...match } : r
  126. })
  127. })
  128. const videoSpeed = (e) => {
  129. emit('videoSpeed', e)
  130. }
  131. const onClose = () => {
  132. formRef.value.onClose()
  133. }
  134. defineExpose({
  135. selectBtn,
  136. onClose
  137. })
  138. </script>
  139. <style scoped lang="less">
  140. .rightBtn {
  141. position: fixed;
  142. right: 0;
  143. top: 150px;
  144. z-index: 99999;
  145. }
  146. .fcc {
  147. display: flex;
  148. justify-content: center;
  149. align-items: center;
  150. }
  151. :deep(.btnItem) {
  152. height: auto;
  153. line-height: normal;
  154. padding: 10px 0 !important;
  155. }
  156. </style>