index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <view class="page">
  3. <scroll-view
  4. scroll-y
  5. @scrolltolower="loadMore"
  6. refresher-enabled
  7. :refresher-triggered="isRefreshing"
  8. @refresherrefresh="onRefresh"
  9. v-if="zjxxList.length > 0"
  10. class="warehouse-list"
  11. >
  12. <view
  13. v-for="(zjxxItem, index) in zjxxList"
  14. :key="index"
  15. class="warehouse-item"
  16. @click="goPage(zjxxItem)"
  17. >
  18. <view class="warehouse-details">
  19. <view class="detail-row">
  20. <text class="label"
  21. >业务时间:<text class="blackValue">{{
  22. zjxxItem.jcsj || "--"
  23. }}</text></text
  24. >
  25. <text class="label"
  26. >粮食品种:<text class="blackValue">{{
  27. getDictLabelSync(DICT_TYPE.SYSTEM_LSPZ, zjxxItem.lspzmc) || "--"
  28. }}</text></text
  29. >
  30. </view>
  31. <view class="detail-row">
  32. <text class="label"
  33. >检测类型:<text class="blackValue">{{
  34. zjxxItem.jclx || "--"
  35. }}</text></text
  36. >
  37. <text class="label"
  38. >是否合格:<text class="blackValue">{{
  39. zjxxItem.sfhg == 0 ? "不合格" : "合格" || "--"
  40. }}</text></text
  41. >
  42. </view>
  43. </view>
  44. </view>
  45. <!-- 添加加载更多提示 -->
  46. <view class="loading-more" v-if="zjxxList.length > 0">
  47. <text v-if="isLoading">加载中...</text>
  48. <text v-else-if="!hasMore">没有更多数据了</text>
  49. </view>
  50. </scroll-view>
  51. <view v-else class="no-data">暂无数据</view>
  52. </view>
  53. </template>
  54. <script setup>
  55. import { ref, onMounted } from "vue";
  56. import { getDictOptions, DICT_TYPE, getDictLabelSync } from "@/utils/dict.js";
  57. import { getZjxxByCfId } from "@/api/grainDepositor";
  58. const props = defineProps({
  59. caId: {
  60. type: String || Number,
  61. },
  62. });
  63. // 添加下拉刷新和上拉加载状态
  64. const isRefreshing = ref(false);
  65. const isLoading = ref(false);
  66. const page = ref(1);
  67. const pageSize = ref(10);
  68. const hasMore = ref(true);
  69. const zjxxList = ref([]);
  70. // 请求数据
  71. const getZjxxList = async (isLoadMore = false) => {
  72. try {
  73. const res = await getZjxxByCfId({
  74. caId: props.caId,
  75. page: page.value,
  76. pageSize: pageSize.value,
  77. });
  78. if (res.code === 0 && res.data !== null) {
  79. // 判断是否还有更多数据
  80. hasMore.value = res.data.records.length === pageSize.value;
  81. // 如果是加载更多,则追加数据,否则替换数据
  82. if (isLoadMore) {
  83. zjxxList.value = [...zjxxList.value, ...res.data.records];
  84. } else {
  85. zjxxList.value = res.data.records;
  86. }
  87. }
  88. } catch (error) {
  89. console.error("获取质检信息失败:", error);
  90. uni.showToast({
  91. title: "获取数据失败",
  92. icon: "none",
  93. });
  94. }
  95. };
  96. onMounted(async () => {
  97. await getZjxxList();
  98. });
  99. // 下拉刷新
  100. const onRefresh = async () => {
  101. try {
  102. isRefreshing.value = true;
  103. page.value = 1;
  104. await getZjxxList();
  105. } finally {
  106. isRefreshing.value = false;
  107. }
  108. };
  109. // 上拉加载更多
  110. const loadMore = async () => {
  111. if (!hasMore.value || isLoading.value) return;
  112. try {
  113. isLoading.value = true;
  114. page.value++;
  115. await getZjxxList(true);
  116. } finally {
  117. isLoading.value = false;
  118. }
  119. };
  120. const goPage = async (item) => {
  121. const serializedData = JSON.stringify(item);
  122. const encodedData = encodeURIComponent(serializedData);
  123. uni.navigateTo({
  124. url: `/pages/infoDetails/zj/detail?getData=${encodedData}`,
  125. });
  126. };
  127. </script>
  128. <style lang="scss" scoped>
  129. .page {
  130. position: relative; // 确保伪元素相对于 .page 定位
  131. }
  132. .page::before {
  133. content: "";
  134. position: absolute;
  135. top: 0;
  136. left: 0;
  137. width: 100%;
  138. height: 200rpx; // 设置渐变的高度
  139. background: linear-gradient(180deg, #cfddfc, #eff2f5);
  140. z-index: -1; // 确保它在内容之下
  141. }
  142. .warehouse-list {
  143. padding: 40rpx 20rpx 120rpx 40rpx;
  144. box-sizing: border-box;
  145. height: 100vh;
  146. .warehouse-item {
  147. border-left: 2px solid #3872e3;
  148. background: linear-gradient(180deg, #ffffff, #f5f8ff);
  149. border-radius: 10px;
  150. padding: 10rpx 0 10rpx 20rpx;
  151. margin-bottom: 20rpx;
  152. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  153. box-sizing: border-box;
  154. .warehouse-details {
  155. padding-top: 20rpx;
  156. font-size: 30rpx;
  157. color: #747476;
  158. .detail-row {
  159. margin-bottom: 10px;
  160. text.label {
  161. width: 50%;
  162. display: inline-flex;
  163. .blackValue {
  164. color: #000000;
  165. }
  166. }
  167. }
  168. }
  169. }
  170. }
  171. .button-container {
  172. position: fixed;
  173. bottom: 0;
  174. background-color: #ffffff;
  175. width: 100vw;
  176. padding: 40rpx 0;
  177. .button-pad {
  178. padding: 0 40rpx;
  179. display: flex;
  180. justify-content: space-between;
  181. }
  182. .select-all,
  183. .confirm {
  184. width: 44%;
  185. height: 70rpx;
  186. line-height: 70rpx;
  187. border-radius: 10rpx;
  188. background-color: #1e5fdf;
  189. color: #fff;
  190. font-size: 28rpx;
  191. text-align: center;
  192. }
  193. }
  194. .warehouse-info {
  195. padding-top: 20rpx;
  196. }
  197. .navbar {
  198. display: flex;
  199. height: 40px;
  200. padding: 0 5px;
  201. position: relative;
  202. z-index: 10;
  203. .nav-item {
  204. flex: 1;
  205. display: flex;
  206. justify-content: center;
  207. align-items: center;
  208. height: 100%;
  209. font-size: 35rpx;
  210. position: relative;
  211. color: #334b68;
  212. &.current {
  213. color: #0f2239;
  214. &:after {
  215. content: "";
  216. position: absolute;
  217. left: 50%;
  218. bottom: 0;
  219. transform: translateX(-50%);
  220. width: 60%;
  221. height: 0;
  222. border-bottom: 4px solid #789fec;
  223. }
  224. }
  225. }
  226. }
  227. .swiper-box {
  228. height: calc(100vh - 80rpx);
  229. }
  230. .list-scroll-content {
  231. height: calc(100vh - 200rpx);
  232. }
  233. .info-scroll-content {
  234. height: calc(100vh - 120rpx);
  235. }
  236. .no-data {
  237. text-align: center;
  238. color: #999;
  239. font-size: 30rpx;
  240. margin-top: 20rpx;
  241. }
  242. .loading-more {
  243. text-align: center;
  244. padding: 20rpx 0;
  245. color: #999;
  246. font-size: 24rpx;
  247. }
  248. </style>