inheritor.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <!-- 文化传承 - -->
  3. <CommonListPage
  4. :title="'非遗传承人'"
  5. :prevPage="{ title: '保护传承' }"
  6. :dropDownNames="dropdownNames"
  7. :pageSize="8"
  8. :load="loadData"
  9. :loadDetail="loadDetail"
  10. :tagsData="tagsData"
  11. :defaultSelectTag="tagsData[0].id"
  12. detailsPage="/inheritor/intangible-detail"
  13. />
  14. </template>
  15. <script setup lang="ts">
  16. import { GetContentListParams } from '@/api/CommonContent';
  17. import InheritorContent from '@/api/inheritor/InheritorContent';
  18. import IndexContent from '@/api/introduction/IndexContent';
  19. import type { DropDownNames } from '@/components/content/CommonListPage.vue';
  20. import { onMounted, ref } from 'vue';
  21. async function loadDetail(id: number, item: any) {
  22. item = await InheritorContent.getContentDetail(id);
  23. item.content = item.content || item.intro as string;
  24. item.addItems = [
  25. { name: '传承项目', text: item.ichName },
  26. { name: '级别', text: item.levelText },
  27. { name: '民族', text: item.nation },
  28. ];
  29. return item;
  30. }
  31. async function loadData(
  32. page: number,
  33. pageSize: number,
  34. selectedTag: number,
  35. searchText: string,
  36. dropDownValues: number[]
  37. ) {
  38. const res = await InheritorContent.getContentList(new GetContentListParams().setSelfValues({
  39. ichType: selectedTag == 0 ? undefined: selectedTag,
  40. level: dropDownValues[0] == 0 ? undefined: dropDownValues[0],
  41. region: dropDownValues[1] == 0 ? undefined: dropDownValues[1],
  42. keywords: searchText,
  43. }), page, pageSize);
  44. return {
  45. page: page,
  46. total: res.total,
  47. data: res.list.map((item, index) => {
  48. return {
  49. id: item.id,
  50. title: item.title,
  51. desc: item.desc,
  52. image: item.image,
  53. addItems: [
  54. { name: '传承项目', text: item.ichName },
  55. { name: '级别', text: item.levelText },
  56. { name: '民族', text: item.nation },
  57. ],
  58. };
  59. }),
  60. }
  61. }
  62. const dropdownNames = ref<DropDownNames[]>([]);
  63. //子分类
  64. const tagsData = ref([
  65. { id: 0, name: '全部' },
  66. ]);
  67. onMounted(async () => {
  68. // tagsData.value = tagsData.value.concat((await IndexContent.getCategoryList(4)).map((item) => ({
  69. // id: item.id,
  70. // name: item.title,
  71. // })));
  72. dropdownNames.value.push({
  73. options: [{
  74. id: 0,
  75. name: '全部'
  76. }].concat((await IndexContent.getCategoryList(2)).map((item) => ({
  77. id: item.id,
  78. name: item.title,
  79. }))),
  80. defaultSelectedValue: 0,
  81. });
  82. dropdownNames.value.push({
  83. options: [{
  84. id: 0,
  85. name: '全部'
  86. }].concat((await IndexContent.getCategoryList(1)).map((item) => ({
  87. id: item.id,
  88. name: item.title,
  89. }))),
  90. defaultSelectedValue: 0,
  91. });
  92. })
  93. </script>
  94. <style>
  95. </style>