inheritor.vue 3.0 KB

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