list.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <CommonListPage
  3. title="非遗传承人"
  4. itemType="article-character"
  5. detailsPage="/pages/inhert/inheritor/details"
  6. showTotal
  7. :dropDownNames="dropdownNames"
  8. :load="loadData"
  9. />
  10. </template>
  11. <script setup lang="ts">
  12. import CommonContent, { GetContentListParams } from '@/api/CommonContent';
  13. import InheritorContent from '@/api/inheritor/InheritorContent';
  14. import CommonListPage, { type DropDownNames } from '@/pages/article/common/CommonListPage.vue';
  15. import { onLoad } from '@dcloudio/uni-app';
  16. import { onMounted, ref } from 'vue';
  17. const dropdownNames = ref<DropDownNames[]>([]);
  18. async function loadData(
  19. page: number,
  20. pageSize: number,
  21. searchText: string,
  22. dropDownValues: number[]
  23. ) {
  24. const res = (await InheritorContent.getContentList(new GetContentListParams().setSelfValues({
  25. ichType: dropDownValues[0] == 0 ? undefined: dropDownValues[0],
  26. level: dropDownValues[1] == 0 ? undefined: dropDownValues[1],
  27. region: dropDownValues[2] == 0 ? undefined: dropDownValues[2],
  28. keywords: searchText,
  29. }), page, pageSize));
  30. res.list.forEach((p) => {
  31. p.desc = p.ichName as string;
  32. p.bottomTags = [
  33. p.levelText,
  34. p.nation,
  35. ];
  36. })
  37. return res;
  38. }
  39. onLoad(async (querys) => {
  40. dropdownNames.value.push({
  41. options: [{
  42. id: 0,
  43. name: '全部类别'
  44. }].concat((await CommonContent.getCategoryList(4)).map((item) => ({
  45. id: item.id,
  46. name: item.title,
  47. }))),
  48. defaultSelectedValue: 0,
  49. });
  50. const levels = await CommonContent.getCategoryList(2);
  51. dropdownNames.value.push({
  52. options: [{
  53. id: 0,
  54. name: '全部级别'
  55. }].concat(levels.map((item) => ({
  56. id: item.id,
  57. name: item.title,
  58. }))),
  59. activeTab: [0],
  60. defaultSelectedValue: querys?.level ? (levels.find(p => p.title == querys.level)?.id ?? 0) : 0,
  61. });
  62. dropdownNames.value.push({
  63. options: [{
  64. id: 0,
  65. name: '全部区域'
  66. }].concat((await CommonContent.getCategoryList(1)).map((item) => ({
  67. id: item.id,
  68. name: item.title,
  69. }))),
  70. defaultSelectedValue: 0,
  71. });
  72. })
  73. </script>