list.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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.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. console.log('level', querys?.level);
  63. dropdownNames.value.push({
  64. options: [{
  65. id: 0,
  66. name: '全部区域'
  67. }].concat((await CommonContent.getCategoryList(1)).map((item) => ({
  68. id: item.id,
  69. name: item.title,
  70. }))),
  71. defaultSelectedValue: 0,
  72. });
  73. })
  74. </script>