down.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <div class="list-box" :class="{ 'mobile-down': isMobile }">
  3. <template v-if="pageData.count">
  4. <div class="items">
  5. <div class="down-item" v-for="item in pageData.list" :key="item.id">
  6. <span class="down-title" @click="toDetail(item)">{{
  7. item?.report.title
  8. }}</span>
  9. <span class="down-file-type">下载文件类型:{{ item.fileName?.split(".")[1] }}</span>
  10. </div>
  11. </div>
  12. <div class="pagination">
  13. <n-pagination :page="queryParams?.pageNo" :page-count="pageData?.count" :page-size="queryParams?.pageSize" size="large" :on-update-page="changePage" :page-slot="7" />
  14. </div>
  15. </template>
  16. <div class="empty" v-else>
  17. <n-empty description="暂无数据" size="huge"> </n-empty>
  18. </div>
  19. </div>
  20. </template>
  21. <script lang="ts" setup>
  22. import { ref, reactive, onMounted } from "vue";
  23. import { NButton, NPagination, NEmpty, createDiscreteApi } from "naive-ui";
  24. import { useRouter, useRoute } from "vue-router";
  25. const router = useRouter(); // 传递参数
  26. const props = defineProps({
  27. isMobile: {
  28. type: Boolean,
  29. default: false,
  30. },
  31. });
  32. const queryParams = reactive({
  33. pageNo: 1,
  34. pageSize: 5,
  35. });
  36. const pageData = ref({});
  37. onMounted(() => {
  38. getList();
  39. });
  40. const message = createDiscreteApi(["message"]);
  41. const getList = async () => {
  42. const { code, data } = await getMyDoen_Api(queryParams);
  43. if (code === 200) {
  44. pageData.value = data;
  45. }
  46. };
  47. const toDetail = (item: object) => {
  48. router.push({
  49. name: "bulletinDetail",
  50. params: {
  51. webTitle: item?.report?.webTitle + "-" + item?.report?.id,
  52. },
  53. });
  54. };
  55. // 改变页数
  56. const changePage = (page: number) => {
  57. document.documentElement.scrollTop = 0;
  58. queryParams.pageNo = page;
  59. getList();
  60. };
  61. </script>
  62. <style lang="scss" scoped>
  63. .list-box {
  64. height: 100%;
  65. .items {
  66. height: calc(100% - 50px);
  67. overflow: hidden;
  68. overflow-y: scroll;
  69. }
  70. .pagination {
  71. display: flex;
  72. justify-content: center;
  73. align-items: center;
  74. height: 50px;
  75. }
  76. .empty {
  77. padding: 50px 0;
  78. }
  79. }
  80. .down-item {
  81. display: flex;
  82. align-items: center;
  83. padding: 30px 0 20px;
  84. border-bottom: 1px dashed #e6e6e6;
  85. &:first-child {
  86. padding-top: 0;
  87. }
  88. .down-title {
  89. flex: 1;
  90. width: 0;
  91. font-size: 24px;
  92. color: #1a1a1a;
  93. overflow: hidden;
  94. text-overflow: ellipsis;
  95. white-space: nowrap;
  96. cursor: pointer;
  97. }
  98. .down-file-type {
  99. margin-left: 30px;
  100. font-size: 16px;
  101. color: #808080;
  102. flex-shrink: 0;
  103. }
  104. }
  105. .mobile-down {
  106. .down-item {
  107. padding: 15px 0;
  108. &:first-child {
  109. padding-top: 0;
  110. }
  111. .down-title {
  112. font-size: 18px;
  113. display: -webkit-box;
  114. -webkit-box-orient: vertical;
  115. -webkit-line-clamp: 2;
  116. overflow: hidden;
  117. text-overflow: ellipsis;
  118. white-space: normal;
  119. }
  120. .down-file-type {
  121. margin-left: 15px;
  122. font-size: 14px;
  123. }
  124. }
  125. }
  126. </style>