products.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <!-- 文化传承 - 非遗产品 -->
  3. <CommonListPage
  4. :title="'非遗产品(作品)'"
  5. :prevPage="{ title: '保护传承' }"
  6. :dropDownNames="dropdownNames"
  7. :pageSize="8"
  8. :load="loadData"
  9. :loadDetail="loadDetail"
  10. :tagsData="tagsData"
  11. :defaultSelectTag="tagsData[0].id"
  12. detailsPage="/inheritor/intangible-detail"
  13. />
  14. </template>
  15. <script setup lang="ts">
  16. import CommonContent, { GetContentListParams } from '@/api/CommonContent';
  17. import ProductsContent from '@/api/inheritor/ProductsContent';
  18. import type { DropDownNames } from '@/components/content/CommonListPage.vue';
  19. import { onMounted, ref } from 'vue';
  20. async function loadDetail(id: number, item: any) {
  21. const res = await ProductsContent.getContentDetail(id);
  22. res.addItems = [
  23. { name: '产地', text: res.regionText, span: 12 },
  24. { name: '特点', text: res.keywords, span: 12 },
  25. { name: '艺术分类', text: res.ichTypeText, span: 12 },
  26. ];
  27. return res;
  28. }
  29. async function loadData(
  30. page: number,
  31. pageSize: number,
  32. selectedTag: number,
  33. searchText: string,
  34. dropDownValues: number[]
  35. ) {
  36. const res = await ProductsContent.getContentList(new GetContentListParams().setSelfValues({
  37. ichType: selectedTag == 0 ? undefined: selectedTag,
  38. level: dropDownValues[0] == 0 ? undefined: dropDownValues[0],
  39. region: dropDownValues[1] == 0 ? undefined: dropDownValues[1],
  40. keywords: searchText,
  41. }), page, pageSize);
  42. return {
  43. page: page,
  44. total: res.total,
  45. data: res.list.map((item, index) => {
  46. return {
  47. id: item.id,
  48. title: item.title ?? '!!title!!',
  49. desc: item.desc,
  50. image: item.image,
  51. addItems: [
  52. { name: '产地', text: item.regionText, span: 12 },
  53. { name: '特点', text: item.keywords?.join(' '), span: 12 },
  54. { name: '艺术分类', text: item.ichTypeText, span: 12 },
  55. ],
  56. };
  57. }),
  58. }
  59. }
  60. const dropdownNames = ref<DropDownNames[]>([]);
  61. //子分类
  62. const tagsData = ref([
  63. { id: 0, name: '全部' },
  64. ]);
  65. onMounted(async () => {
  66. // tagsData.value = tagsData.value.concat((await CommonContent.getCategoryList(4)).map((item) => ({
  67. // id: item.id,
  68. // name: item.title,
  69. // })));
  70. dropdownNames.value.push({
  71. options: [{
  72. id: 0,
  73. name: '全部'
  74. }].concat((await CommonContent.getCategoryList(2)).map((item) => ({
  75. id: item.id,
  76. name: item.title,
  77. }))),
  78. defaultSelectedValue: 0,
  79. });
  80. dropdownNames.value.push({
  81. options: [{
  82. id: 0,
  83. name: '全部'
  84. }].concat((await CommonContent.getCategoryList(1)).map((item) => ({
  85. id: item.id,
  86. name: item.title,
  87. }))),
  88. defaultSelectedValue: 0,
  89. });
  90. })
  91. </script>
  92. <style>
  93. </style>