list.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <div class="main-background main-background main-background-type2">
  3. <div class="nav-placeholder"></div>
  4. <section class="main-section">
  5. <div class="content">
  6. <div class="details w-100">
  7. <!-- 传统村落 -->
  8. <CommonListBlock
  9. ref="list"
  10. :title="'传统村落'"
  11. showNav
  12. :dropDownNames="[]"
  13. :pageSize="8"
  14. :rowCount="1"
  15. :rowType="3"
  16. :load="loadData"
  17. :showDetail="showDetail"
  18. />
  19. </div>
  20. </div>
  21. </section>
  22. </div>
  23. </template>
  24. <script setup lang="ts">
  25. import { ref, watch } from 'vue';
  26. import { useRoute, useRouter } from 'vue-router';
  27. import CommonContent, { GetContentListParams } from '@/api/CommonContent';
  28. import CommonListBlock from '@/components/content/CommonListBlock.vue';
  29. const router = useRouter();
  30. const route = useRoute();
  31. const list = ref();
  32. async function showDetail(item: any) {
  33. router.push({ path: '/village/content', query: { id: item.id } });
  34. }
  35. async function loadData(
  36. page: number,
  37. pageSize: number,
  38. selectedTag: number,
  39. searchText: string,
  40. dropDownValues: number[]
  41. ) {
  42. const res = await CommonContent.getContentList(new GetContentListParams()
  43. .setModelId(Number(route.query.model_id))
  44. .setMainBodyColumnId(Number(route.query.main_body_column_id))
  45. .setKeywords(searchText)
  46. .setSelfValues({
  47. region: Number(route.query.region),
  48. })
  49. , page, pageSize);
  50. return {
  51. page: page,
  52. total: res.total,
  53. data: res.list.map((item, index) => {
  54. return {
  55. id: item.id,
  56. title: item.title,
  57. desc: item.desc,
  58. image: item.thumbnail || item.image,
  59. addItems: [
  60. { name: '传承项目', text: item.title },
  61. ],
  62. };
  63. }),
  64. }
  65. }
  66. watch(route, (newVal) => {
  67. list.value.reload();
  68. })
  69. </script>
  70. <style>
  71. </style>