index.tsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import { NTabPane, NTabs } from 'naive-ui';
  2. import { defineComponent, nextTick, onMounted, ref, toRefs } from 'vue';
  3. import styles from './index.module.less';
  4. import SelectItem from './select-item';
  5. import { useResizeObserver } from '@vueuse/core';
  6. import { useCatchStore } from '/src/store/modules/catchData';
  7. export default defineComponent({
  8. name: 'select-resources',
  9. props: {
  10. type: {
  11. type: String,
  12. default: 'myResources'
  13. },
  14. searchGroup: {
  15. type: Object,
  16. default: () => ({})
  17. },
  18. /** 从哪里使用 */
  19. from: {
  20. type: String,
  21. default: ''
  22. },
  23. instrumentId: {
  24. type: String,
  25. default: ''
  26. }
  27. },
  28. emits: ['select'],
  29. setup(props) {
  30. const { type } = toRefs(props);
  31. const tabType = ref(type.value);
  32. const catchStore = useCatchStore();
  33. onMounted(async () => {
  34. nextTick(() => {
  35. useResizeObserver(
  36. document.querySelector(
  37. '.select-resource .n-tabs-nav--top'
  38. ) as HTMLElement,
  39. (entries: any) => {
  40. const entry = entries[0];
  41. const { height } = entry.contentRect;
  42. console.log(height, 'height - 11');
  43. document.documentElement.style.setProperty(
  44. '--modal-lesson-tab-height',
  45. height + 'px'
  46. );
  47. }
  48. );
  49. });
  50. // 获取教材分类列表
  51. await catchStore.getMusicSheetCategory(true);
  52. });
  53. return () => (
  54. <div class={[styles.selectMusic, 'select-resource']}>
  55. <NTabs
  56. animated
  57. value={tabType.value}
  58. paneClass={styles.paneTitle}
  59. justifyContent="center"
  60. paneWrapperClass={styles.paneWrapperContainer}
  61. onUpdate:value={(val: string) => {
  62. tabType.value = val;
  63. }}>
  64. {props.from !== 'class' && (
  65. <NTabPane name="relateResources" tab={'相关资源'}>
  66. <SelectItem
  67. type="relateResources"
  68. searchGroup={props.searchGroup}
  69. from={props.from}
  70. instrumentId={props.instrumentId}
  71. />
  72. </NTabPane>
  73. )}
  74. <NTabPane
  75. name="shareResources"
  76. tab={props.from === 'class' ? '共享曲目' : '共享资源'}>
  77. <SelectItem
  78. type="shareResources"
  79. from={props.from}
  80. searchGroup={props.searchGroup}
  81. instrumentId={props.instrumentId}
  82. />
  83. </NTabPane>
  84. <NTabPane
  85. name="myResources"
  86. tab={props.from === 'class' ? '我的曲目' : '我的资源'}>
  87. <SelectItem
  88. type="myResources"
  89. from={props.from}
  90. searchGroup={props.searchGroup}
  91. instrumentId={props.instrumentId}
  92. />
  93. </NTabPane>
  94. <NTabPane name="myCollect" tab="我的收藏">
  95. <SelectItem
  96. type="myCollect"
  97. from={props.from}
  98. searchGroup={props.searchGroup}
  99. instrumentId={props.instrumentId}
  100. />
  101. </NTabPane>
  102. </NTabs>
  103. </div>
  104. );
  105. }
  106. });