inheritor.vue 3.0 KB

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