index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <script setup>
  2. import {
  3. ref
  4. } from 'vue'
  5. import {
  6. onLoad,
  7. onUnload,
  8. onPullDownRefresh,
  9. onReachBottom,
  10. onPageScroll
  11. } from "@dcloudio/uni-app"
  12. import {
  13. goToPage
  14. } from "@/utils/common.js"
  15. import {
  16. getProjectInfoList,
  17. } from "@/api/work/projectInfo.js"
  18. let scrollTop = ref(0);
  19. let loading = ref(true);
  20. // 参数
  21. let searchInfo = ref({
  22. pageNo: 1,
  23. pageSize: 10,
  24. })
  25. // 触底加载flag
  26. let moreListFlag = true
  27. let projectList = ref([])
  28. let listTotal = ref(0)
  29. // 获取列表
  30. function getList() {
  31. if (searchInfo.value.pageNo == 1) {
  32. loading.value = true
  33. }
  34. getProjectInfoList(searchInfo.value).then(res => {
  35. loading.value = false
  36. projectList.value = projectList.value.concat(res.data.list)
  37. listTotal.value = res.data.total
  38. if (res.data.total == searchInfo.value.pageNo * searchInfo.value.pageSize - (10 - res.data.list.length))
  39. moreListFlag = false;
  40. }).catch(() => {
  41. loading.value = false
  42. })
  43. }
  44. // 去详情页
  45. function goToDetail(id, subName) {
  46. goToPage(`/pages/projectInfo/detail/index?id=${id}&subName=${subName}`)
  47. }
  48. // 去录入页
  49. function goToInput(subId) {
  50. goToPage(`/pages/questionInput/input/index?subId=${subId}`)
  51. }
  52. // 去搜索页
  53. function searchClick() {
  54. goToPage('/pages/questionInput/search/index')
  55. }
  56. onLoad(() => {
  57. uni.$on('questionInputSearch', resolve => {
  58. searchInfo.value = Object.assign(searchInfo.value, resolve);
  59. searchInfo.value.pageNo = 1;
  60. projectList.value = [];
  61. listTotal.value = 0;
  62. moreListFlag = true;
  63. getList();
  64. })
  65. getList();
  66. })
  67. onUnload(() => {
  68. uni.$off('questionInputSearch');
  69. });
  70. onPageScroll((e) => {
  71. scrollTop.value = e.scrollTop
  72. })
  73. onPullDownRefresh(() => {
  74. searchInfo.value.pageNo = 1;
  75. projectList.value = [];
  76. moreListFlag = true;
  77. try {
  78. getList();
  79. } finally {
  80. uni.stopPullDownRefresh()
  81. }
  82. })
  83. onReachBottom(() => {
  84. if (!moreListFlag) {
  85. return uni.showToast({
  86. title: "已经到底了。",
  87. icon: "none",
  88. duration: 2000
  89. })
  90. }
  91. searchInfo.value.pageNo++;
  92. getList();
  93. })
  94. </script>
  95. <template>
  96. <view class="container">
  97. <page-title @searchClick='searchClick' showSearch>问题录入</page-title>
  98. <view class="cards-list">
  99. <view class="card" v-for="(item,index) in projectList" :key="index">
  100. <view v-if="item.usersub == 1">
  101. <view style="height:20rpx"></view>
  102. <view class="special-item">
  103. <card-title :numerator="index+1" :denominator="listTotal" isSpecial></card-title>
  104. <view class="card-name">
  105. <view class="card-name-title">
  106. <text class="card-name-description">项目名称</text>
  107. </view>
  108. <text class="card-name-text">{{item.subName || "--"}}</text>
  109. </view>
  110. </view>
  111. </view>
  112. <view v-else>
  113. <card-title :numerator="index+1" :denominator="listTotal"></card-title>
  114. <!-- 项目名称 -->
  115. <view class="card-name">
  116. <view class="card-name-title">
  117. <text class="card-name-description">项目名称</text>
  118. </view>
  119. <text class="card-name-text">{{item.subName || "--"}}</text>
  120. </view>
  121. </view>
  122. <view class="card-item">
  123. <view class="card-item-name">监管单位</view>
  124. <view class="card-item-content">{{item.manageName || "--"}}</view>
  125. </view>
  126. <view class="card-item">
  127. <view class="card-btn" @click="goToDetail(item.id,item.subName)">项目查看</view>
  128. <view class="card-btn empty-btn" @click="goToInput(item.id)">问题录入</view>
  129. </view>
  130. </view>
  131. <empty-show v-if="projectList.length===0"></empty-show>
  132. </view>
  133. <u-back-top :scroll-top="scrollTop"></u-back-top>
  134. <u-loading-page :loading="loading"></u-loading-page>
  135. </view>
  136. </template>
  137. <style lang="scss">
  138. </style>