Przeglądaj źródła

【优化】存粮人加分页

xiangpengfei 1 rok temu
rodzic
commit
74b5ab80c1

+ 126 - 50
pages/grainDepositor/components/myWarehouse.vue

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

+ 126 - 50
pages/grainDepositor/components/selectWarehouse.vue

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

+ 3 - 3
pages/myTask-verification/components/CheckInfo.vue

@@ -530,9 +530,9 @@ export default {
530 530
     font-size: 48rpx;
531 531
   }
532 532
 
533
-  &:active {
534
-    opacity: 0.8;
535
-  }
533
+  // &:active {
534
+  //   opacity: 0.8;
535
+  // }
536 536
 }
537 537
 
538 538
 .info-section {