list.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <CommonListPage
  3. title="非遗"
  4. itemType="image-large-2"
  5. detailsPage="/pages/inhert/intangible/details"
  6. :dropDownNames="dropdownNames"
  7. :tabs="[
  8. { id: 0, name: '非遗项目' },
  9. { id: 1, name: '非遗产品' },
  10. ]"
  11. :load="loadData"
  12. />
  13. </template>
  14. <script setup lang="ts">
  15. import CommonContent, { GetContentListParams } from '@/api/CommonContent';
  16. import ProductsContent from '@/api/inheritor/ProductsContent';
  17. import ProjectsContent from '@/api/inheritor/ProjectsContent';
  18. import CommonListPage, { type DropDownNames } from '@/pages/article/common/CommonListPage.vue';
  19. import { onMounted, ref } from 'vue';
  20. const dropdownNames = ref<DropDownNames[]>([]);
  21. async function loadData(
  22. page: number,
  23. pageSize: number,
  24. searchText: string,
  25. dropDownValues: number[],
  26. tabSelect: number,
  27. ) {
  28. let api;
  29. switch (tabSelect) {
  30. case 0: api = ProjectsContent; break;
  31. default:
  32. case 1: api = ProductsContent; break;
  33. }
  34. return (await api.getContentList(new GetContentListParams().setSelfValues({
  35. ichType: dropDownValues[0] == 0 ? undefined: dropDownValues[0],
  36. level: dropDownValues[1] == 0 ? undefined: dropDownValues[1],
  37. region: dropDownValues[2] == 0 ? undefined: dropDownValues[2],
  38. keyword: searchText,
  39. }), page, pageSize)).list;
  40. }
  41. onMounted(async () => {
  42. dropdownNames.value.push({
  43. options: [{
  44. id: 0,
  45. name: '全部分类'
  46. }].concat((await CommonContent.getCategoryList(4)).map((item) => ({
  47. id: item.id,
  48. name: item.title,
  49. }))),
  50. defaultSelectedValue: 0,
  51. });
  52. dropdownNames.value.push({
  53. options: [{
  54. id: 0,
  55. name: '全部级别'
  56. }].concat((await CommonContent.getCategoryList(2)).map((item) => ({
  57. id: item.id,
  58. name: item.title,
  59. }))),
  60. defaultSelectedValue: 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>