list.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <CommonListPage
  3. title="非遗传习所"
  4. itemType="article-character"
  5. detailsPage="/pages/inhert/seminar/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 SeminarContent from '@/api/inheritor/SeminarContent';
  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 SeminarContent.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.titleBox = Boolean(p.deathBirth);
  32. p.desc = p.ichName as string;
  33. p.bottomTags = [
  34. p.levelText,
  35. p.nation,
  36. ];
  37. })
  38. return res;
  39. }
  40. onLoad(async (querys) => {
  41. dropdownNames.value.push({
  42. options: [{
  43. id: 0,
  44. name: '全部类别'
  45. }].concat((await CommonContent.getCategoryList(4)).map((item) => ({
  46. id: item.id,
  47. name: item.title,
  48. }))),
  49. defaultSelectedValue: 0,
  50. });
  51. const levels = await CommonContent.getCategoryList(2);
  52. dropdownNames.value.push({
  53. options: [{
  54. id: 0,
  55. name: '全部级别'
  56. }].concat(levels.map((item) => ({
  57. id: item.id,
  58. name: item.title,
  59. }))),
  60. defaultSelectedValue: querys?.level ?? 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: querys?.region ?? 0,
  71. });
  72. })
  73. </script>