IntangibleDetail.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <script setup lang="ts">
  2. import Tab from '@/components/small/Tab.vue';
  3. import CommonDetail from './CommonDetail.vue';
  4. import { computed, ref, watch } from 'vue';
  5. import type { GetContentDetailItem } from '@/api/CommonContent';
  6. import SimpleRichHtml from '@/components/SimpleRichHtml.vue';
  7. import { ScrollRect } from '@imengyu/vue-scroll-rect';
  8. import TabCommonList from '../Content/TabCommonList.vue';
  9. import { useRoute } from 'vue-router';
  10. import { CommonHtmlStyles } from '@/composeable/HtmlStyles';
  11. const route = useRoute();
  12. const currentContent = ref<GetContentDetailItem>();
  13. const activeSubTab = ref(0);
  14. const activeSubTabId = computed(() => {
  15. return tabs.value[activeSubTab.value]?.id || tabs.value[0]?.id || 0;
  16. });
  17. const tabs = computed(() => {
  18. const res = [
  19. { label: '简介', id: 0 }
  20. ] as { label: string, id: number }[];
  21. if (currentContent.value?.audio)
  22. res.push({ label: '音频', id: 1 });
  23. if (currentContent.value?.video)
  24. res.push({ label: '视频', id: 2 });
  25. if (currentContent.value?.associationMeList && (currentContent.value?.associationMeList as any[]).length > 0)
  26. res.push({ label: '相关非遗', id: 5 });
  27. if (currentContent.value?.worksList && (currentContent.value?.worksList as any[]).length > 0)
  28. res.push({ label: '非遗作品', id: 3 });
  29. if (currentContent.value?.inheritorsList && (currentContent.value?.inheritorsList as any[]).length > 0)
  30. res.push({ label: '非遗传承人', id: 4 });
  31. return res;
  32. });
  33. watch(route, () => {
  34. activeSubTab.value = 0;
  35. });
  36. async function loadSubList(page: number, pageSize: number, content: any, subList: string) {
  37. const list = content[subList] as any[] || [];
  38. if (subList == 'associationMeList') {
  39. list.forEach((p) => {
  40. p.bottomTags = [
  41. p.levelText,
  42. p.ichTypeText,
  43. p.batchText,
  44. ];
  45. })
  46. } else if (subList == 'ichSitesList') {
  47. list.forEach((p) => {
  48. p.bottomTags = [
  49. content.ichTypeText,
  50. ];
  51. })
  52. } else if (subList == 'inheritorsList') {
  53. list.forEach((p) => {
  54. p.bottomTags = [
  55. p.levelText,
  56. p.nation,
  57. content.ichTypeText,
  58. ];
  59. })
  60. }
  61. return {
  62. page: page,
  63. total: list.length,
  64. list: list.slice((page - 1) * pageSize, page * pageSize)
  65. };
  66. }
  67. </script>
  68. <template>
  69. <CommonDetail @contentLoaded="currentContent = $event">
  70. <template #afterTitle="{ content }">
  71. <div class="desc">
  72. <div v-if="content.address">地址: {{ content.address }}</div>
  73. <div v-if="content.ichTypeText">项目类别: {{ content.ichTypeText }}</div>
  74. <div v-if="content.levelText">项目级别: {{ content.levelText }}</div>
  75. <div v-if="content.batchText">批次时间: {{ content.batchText }}</div>
  76. <div v-if="content.regionText">所属区域: {{ content.regionText }}</div>
  77. <div v-if="content.unit">保护单位: {{ content.unit }}</div>
  78. </div>
  79. </template>
  80. <template #content="{ content }">
  81. <Tab
  82. v-model="activeSubTab"
  83. :tabs="tabs"
  84. autoSize
  85. itemWidth="100px"
  86. />
  87. <ScrollRect v-if="activeSubTabId === 0" scroll="vertical">
  88. <SimpleRichHtml :contents="[ content.intro as string, content.content ]" :tagStyle="CommonHtmlStyles" />
  89. </ScrollRect>
  90. <video
  91. v-else-if="activeSubTabId === 1"
  92. controls
  93. :src="content.audio"
  94. />
  95. <video
  96. v-else-if="activeSubTabId === 2"
  97. controls
  98. :src="content.video"
  99. />
  100. <TabCommonList
  101. v-else-if="activeSubTabId === 3"
  102. :loader="(page, size) => loadSubList(page, size, content, 'worksList')"
  103. detailPageNames="IntangibleDetail"
  104. />
  105. <TabCommonList
  106. v-else-if="activeSubTabId === 5"
  107. :loader="(page, size) => loadSubList(page, size, content, 'associationMeList')"
  108. detailPageNames="IntangibleDetail"
  109. />
  110. <TabCommonList
  111. v-else-if="activeSubTabId === 4"
  112. :loader="(page, size) => loadSubList(page, size, content, 'inheritorsList')"
  113. detailPageNames="IntangibleDetail"
  114. />
  115. </template>
  116. </CommonDetail>
  117. </template>
  118. <style lang="scss" scoped>
  119. h3 {
  120. font-size: 0.8rem;
  121. color: var(--color-text-primary);
  122. text-align: left;
  123. width: 100%;
  124. margin-top: 0.5rem;
  125. }
  126. .desc {
  127. display: flex;
  128. flex-direction: row;
  129. flex-wrap: wrap;
  130. justify-content: space-between;
  131. div {
  132. width: 48%;
  133. color: var(--color-text-primary);
  134. font-size: 0.8rem;
  135. }
  136. }
  137. </style>