selectWarehouse.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <!-- <view class="warehouse-list"> -->
  3. <scroll-view
  4. scroll-y
  5. @scrolltolower="loadMore"
  6. class="warehouse-list"
  7. refresher-enabled
  8. :refresher-triggered="isRefreshing"
  9. @refresherrefresh="onRefresh"
  10. >
  11. <view
  12. v-for="(kuqItem, index) in kuqList"
  13. :key="index"
  14. @click="goDetailPage(kuqItem)"
  15. class="warehouse-item"
  16. >
  17. <view class="warehouse-header">
  18. <view class="info-container">
  19. <view class="warehouse-name">
  20. <image src="@/static/icons/warehouse-ico.png" class="icon"></image>
  21. <view class="text-container">
  22. <view class="labeltext">库区名称:</view>
  23. <view class="valuetext">{{ kuqItem.kqmc }}</view>
  24. </view>
  25. </view>
  26. <view class="warehouse-address">
  27. <image src="@/static/icons/location-ico.png" class="icon"></image>
  28. <view class="text-container">
  29. <text class="labeltext">库区地址:</text>
  30. <text class="valuetext">{{ kuqItem.jtdz }}</text>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="warehouse-details">
  36. <view class="detail-row">
  37. <text>联系人: {{ kuqItem.kqfzr }}</text>
  38. <text>联系电话: {{ kuqItem.lxdh }}</text>
  39. </view>
  40. </view>
  41. </view>
  42. <!-- 添加底部提示 -->
  43. <view v-if="finished || !kuqList.length" class="no-more">没有更多数据了~</view>
  44. </scroll-view>
  45. <!-- </view> -->
  46. </template>
  47. <script setup>
  48. import { ref, reactive, onMounted } from "vue";
  49. import { getAllStoreroomList } from "@/api/grainDepositor";
  50. const kuqList = ref([]);
  51. const pageNo = ref(1);
  52. const pageSize = ref(10);
  53. const finished = ref(false);
  54. const loading = ref(false);
  55. const isRefreshing = ref(false);
  56. // 获取数据的方法
  57. const getData = async (isRefresh = false) => {
  58. if (loading.value) return;
  59. loading.value = true;
  60. try {
  61. const res = await getAllStoreroomList({
  62. pageNo: pageNo.value,
  63. pageSize: pageSize.value,
  64. });
  65. if (isRefresh || pageNo.value === 1) {
  66. kuqList.value = res.data.records;
  67. } else {
  68. kuqList.value = [...kuqList.value, ...res.data.records];
  69. }
  70. // 判断是否还有更多数据
  71. if (res.data.records.length < pageSize.value) {
  72. finished.value = true;
  73. } else {
  74. finished.value = false;
  75. }
  76. } catch (error) {
  77. console.error(error);
  78. } finally {
  79. loading.value = false;
  80. isRefreshing.value = false;
  81. uni.hideLoading();
  82. }
  83. };
  84. // 下拉刷新
  85. const onRefresh = async () => {
  86. isRefreshing.value = true;
  87. pageNo.value = 1;
  88. finished.value = false;
  89. await getData(true);
  90. };
  91. // 上拉加载更多
  92. const loadMore = async () => {
  93. if (finished.value || loading.value) return;
  94. pageNo.value++;
  95. await getData();
  96. };
  97. onMounted(() => {
  98. getData();
  99. });
  100. const goDetailPage = (info) => {
  101. uni.navigateTo({
  102. url: `/pages/warehouse/warehouse?kqId=${info.kqId}&source=all`,
  103. });
  104. };
  105. </script>
  106. <style lang="scss" scoped>
  107. .warehouse-list {
  108. padding: 40rpx 20rpx 100rpx 20rpx;
  109. box-sizing: border-box;
  110. height: 100vh;
  111. .warehouse-item {
  112. background: linear-gradient(180deg, #ffffff, #f5f8ff);
  113. border-radius: 10px;
  114. padding: 20px 15px 10px;
  115. margin-bottom: 25rpx;
  116. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  117. .warehouse-header {
  118. display: flex;
  119. justify-content: space-between;
  120. align-items: flex-start; // 对齐到顶部
  121. padding-bottom: 30rpx;
  122. border-bottom: 1px solid #e7e8ea;
  123. font-size: 35rpx;
  124. color: #00122f;
  125. .info-container {
  126. flex-grow: 1;
  127. .warehouse-name,
  128. .warehouse-address {
  129. display: flex;
  130. margin-bottom: 5px;
  131. line-height: 55rpx;
  132. &:last-child {
  133. margin-bottom: 0;
  134. }
  135. .icon {
  136. padding-top: 7rpx;
  137. width: 22px;
  138. height: 22px;
  139. margin-right: 15rpx;
  140. }
  141. .text-container {
  142. display: flex;
  143. flex: 1;
  144. word-break: break-all;
  145. .labeltext {
  146. // flex-wrap: nowrap;
  147. // 文字禁止换行
  148. white-space: nowrap;
  149. }
  150. .valuetext {
  151. text-align: right;
  152. }
  153. }
  154. }
  155. }
  156. }
  157. .warehouse-details {
  158. padding-top: 30rpx;
  159. font-size: 30rpx;
  160. color: #747476;
  161. .detail-row {
  162. display: flex;
  163. justify-content: space-between;
  164. margin-bottom: 10px;
  165. }
  166. }
  167. }
  168. .no-more {
  169. text-align: center;
  170. color: #999;
  171. font-size: 24rpx;
  172. padding: 20rpx 0;
  173. }
  174. }
  175. </style>