From 2cc85c64f1c64a2dbaeae276a3e2ca8420de76b7 Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期三, 22 四月 2026 18:09:58 +0800
Subject: [PATCH] 上报转运调试

---
 pages/case/transfer.vue |  226 +++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 166 insertions(+), 60 deletions(-)

diff --git a/pages/case/transfer.vue b/pages/case/transfer.vue
index 3b931f7..b9e34fe 100644
--- a/pages/case/transfer.vue
+++ b/pages/case/transfer.vue
@@ -24,7 +24,7 @@
         <text
           v-for="(type, index) in transportTypes"
           :key="index"
-          :class="{ active: currentType === type.value }"
+          :class="{ active: currentType == type.value }"
           @tap="selectType(type.value)"
           >{{ type.label }}</text
         >
@@ -131,7 +131,7 @@
             </button>
             <button
               class="action-btn secondary"
-              v-if="item.transitStatus === 1 || item.transitStatus === 5"
+              v-if="item.transitStatus != 3"
               @tap.stop="editTransport(item)"
             >
               缂栬緫
@@ -144,8 +144,13 @@
       </view>
 
       <!-- 鍔犺浇鏇村 -->
-      <view class="load-more" v-if="loading">
+      <view class="load-more" v-if="loadingMore">
         <u-loading-icon text="鍔犺浇涓�..."></u-loading-icon>
+      </view>
+
+      <!-- 鏃犳洿澶氭暟鎹� -->
+      <view class="no-more" v-if="!hasMore && filteredTransports.length > 0">
+        <text>宸插姞杞藉叏閮ㄦ暟鎹�</text>
       </view>
 
       <!-- 绌虹姸鎬� -->
@@ -176,12 +181,20 @@
         </view>
       </view>
     </view>
+
+    <!-- 鍔犺浇鐘舵�� -->
+    <u-loading-page v-if="initLoading" :loading="true" text="鏁版嵁鍔犺浇涓�..." />
+    
+    <!-- 娴姩鎸夐挳 -->
+    <!-- <view class="float-button" @tap="createTransport">
+      <u-icon name="plus" color="#fff" size="24"></u-icon>
+    </view> -->
   </view>
 </template>
 
 <script setup>
 import { ref, computed, onMounted } from "vue";
-import { onLoad, onShow } from "@dcloudio/uni-app";
+import { onLoad, onShow, onReachBottom } from "@dcloudio/uni-app";
 import { useDict } from "@/utils/dict";
 
 // 瀛楀吀鏁版嵁
@@ -197,6 +210,8 @@
 // 杞繍鍗曟暟鎹�
 const transports = ref([]);
 const loading = ref(false);
+const initLoading = ref(false);
+const loadingMore = ref(false);
 const refreshing = ref(false);
 const hasMore = ref(true);
 const pageNum = ref(1);
@@ -225,9 +240,13 @@
   // 鑾峰彇瀛楀吀鏁版嵁
   dict.value = await useDict("sys_user_sex");
   // 鍒濆鍖栨暟鎹�
-  loadTransports();
-  // 鍔犺浇缁熻鏁版嵁
-  loadStats();
+  await loadInitialData();
+});
+
+onReachBottom(() => {
+  if (hasMore.value && !loading.value && !loadingMore.value) {
+    onLoadMore();
+  }
 });
 
 onShow(() => {
@@ -264,25 +283,15 @@
   };
 };
 
-// 绛涢�夎褰�
+// 璁$畻灞炴�э細绛涢�夎褰�
 const filteredTransports = computed(() => {
   let result = transports.value;
-
-  // 鐘舵�佺瓫閫�
+  
+  // 鍓嶇鐘舵�佺瓫閫�
   if (currentType.value !== "") {
     result = result.filter((item) => item.transitStatus === currentType.value);
   }
-
-  // 鏃ユ湡绛涢��
-  if (startDate.value && endDate.value) {
-    result = result.filter((item) => {
-      const transportDate = item.createTime
-        ? item.createTime.split(" ")[0]
-        : "";
-      return transportDate >= startDate.value && transportDate <= endDate.value;
-    });
-  }
-
+  
   return result;
 });
 
@@ -329,15 +338,28 @@
 // 閫夋嫨绫诲瀷
 const selectType = (type) => {
   currentType.value = type;
+  // 閲嶇疆鍒嗛〉锛岄噸鏂板姞杞芥暟鎹�
+  pageNum.value = 1;
+  loadTransports(true);
 };
 
 // 鏃ユ湡閫夋嫨
 const onStartDateChange = (e) => {
   startDate.value = e.detail.value;
+  // 濡傛灉缁撴潫鏃ユ湡宸查�夋嫨锛岀珛鍗宠Е鍙戠瓫閫�
+  if (endDate.value) {
+    pageNum.value = 1;
+    loadTransports(true);
+  }
 };
 
 const onEndDateChange = (e) => {
   endDate.value = e.detail.value;
+  // 濡傛灉寮�濮嬫棩鏈熷凡閫夋嫨锛岀珛鍗宠Е鍙戠瓫閫�
+  if (startDate.value) {
+    pageNum.value = 1;
+    loadTransports(true);
+  }
 };
 
 // 鏌ョ湅璇︽儏
@@ -348,14 +370,21 @@
 // 鏌ョ湅璇︽儏
 const viewDetails = (item) => {
   uni.navigateTo({
-    url: `/pages/transport/detail?id=${item.id}`,
+    url: `/pages/case/transferinfo?id=${item.id}`,
   });
 };
 
 // 缂栬緫杞繍鍗�
 const editTransport = (item) => {
   uni.navigateTo({
-    url: `/pages/transport/detail?id=${item.id}&edit=true`,
+    url: `/pages/case/transferinfo?id=${item.id}&edit=true`,
+  });
+};
+
+// 鍒涘缓杞繍鍗�
+const createTransport = () => {
+  uni.navigateTo({
+    url: '/pages/transport/create'
   });
 };
 
@@ -404,59 +433,105 @@
   showActionModal.value = false;
 };
 
+// 鏁版嵁鍔犺浇鍑芥暟
+const loadInitialData = async () => {
+  initLoading.value = true;
+  try {
+    await Promise.all([loadTransports(true), loadStats()]);
+  } catch (error) {
+    console.error("鍒濆鍖栨暟鎹け璐�:", error);
+  } finally {
+    initLoading.value = false;
+  }
+};
+
 // 涓嬫媺鍒锋柊
-const onRefresh = () => {
+const onRefresh = async () => {
   refreshing.value = true;
   pageNum.value = 1;
-  loadTransports();
-  loadStats();
+  await loadTransports(true);
+  await loadStats();
   setTimeout(() => {
     refreshing.value = false;
   }, 1000);
 };
 
 // 鍔犺浇鏇村
-const onLoadMore = () => {
-  if (!hasMore.value || loading.value) return;
-  pageNum.value++;
-  loadTransports();
+const onLoadMore = async () => {
+  if (!hasMore.value || loading.value || loadingMore.value) return;
+  await loadTransports();
 };
 
-// 鍔犺浇璁板綍
-const loadTransports = async () => {
-  if (loading.value) return;
-
-  loading.value = true;
+// 鍔犺浇杞繍鍗曞垪琛�
+const loadTransports = async (reset = false) => {
+  if (reset) {
+    pageNum.value = 1;
+    hasMore.value = true;
+  }
+  
+  if (loading.value || loadingMore.value || !hasMore.value) return;
+  
+  if (reset) {
+    loading.value = true;
+  } else {
+    loadingMore.value = true;
+  }
+  
   try {
     const params = {
       pageNum: pageNum.value,
       pageSize: pageSize.value,
     };
-
-    if (currentType.value) {
+    
+    // 绛涢�夋潯浠�
+    if (currentType.value !== "") {
       params.transitStatus = currentType.value;
     }
-
+    
+    // 鏃堕棿绛涢�夋潯浠�
     if (startDate.value && endDate.value) {
       params.startDate = startDate.value;
       params.endDate = endDate.value;
     }
-
+    
+    console.log("璇锋眰鍙傛暟:", params);
+    
     const res = await uni.$uapi.post("/project/transport/list", params);
-
-    if (res) {
-      const data = res || [];
+    
+    console.log("鎺ュ彛杩斿洖鏁版嵁:", res);
+  
+    if (res && res.code === 200) {
+      // 澶勭悊涓嶅悓鐨勬暟鎹粨鏋�
+      let data = [];
+      
+      if (res.rows && Array.isArray(res.rows)) {
+        data = res.rows;
+      } else if (res.data && Array.isArray(res.data)) {
+        data = res.data;
+      } else if (Array.isArray(res)) {
+        data = res;
+      } else {
+        console.error("鎺ュ彛杩斿洖鏍煎紡涓嶆纭�:", res);
+        throw new Error("鎺ュ彛杩斿洖鏍煎紡涓嶆纭�");
+      }
+      
       const mappedData = data.map((item) => mapApiDataToTransportItem(item));
-
-      if (pageNum.value === 1) {
+      
+      if (reset || pageNum.value === 1) {
         transports.value = mappedData;
       } else {
         transports.value = [...transports.value, ...mappedData];
       }
-
-      hasMore.value = (res.rows || []).length >= pageSize.value;
+      
+      // 鍒ゆ柇鏄惁杩樻湁鏇村鏁版嵁
+      hasMore.value = data.length >= pageSize.value;
+      
+      // 濡傛灉鏈夋暟鎹姞杞芥垚鍔燂紝澧炲姞椤电爜
+      if (data.length > 0) {
+        pageNum.value++;
+      }
     } else {
-      throw new Error(res.msg || "鍔犺浇澶辫触");
+      throw new Error(res?.msg || "鍔犺浇澶辫触");
     }
   } catch (error) {
     console.error("鍔犺浇杞繍鍗曞垪琛ㄥけ璐�:", error);
@@ -466,6 +541,7 @@
     });
   } finally {
     loading.value = false;
+    loadingMore.value = false;
   }
 };
 
@@ -473,11 +549,12 @@
 const loadStats = async () => {
   try {
     const res = await uni.$uapi.post("/api/totalServiceTransportState");
-    if (res) {
+    if (res.data) {
       stats.value = {
-        totalTransports: res.reduce((sum, item) => sum + item.count, 0) || 0,
-        pendingTransports: res[0].count || 0,
-        completedTransports: res[3].count || 0,
+        totalTransports:
+          res.data.reduce((sum, item) => sum + item.count, 0) || 0,
+        pendingTransports: res.data[0].count || 0,
+        completedTransports: res.data[3].count || 0,
       };
     }
   } catch (error) {
@@ -492,10 +569,10 @@
       id: currentTransport.value.id,
       transitStatus: newStatus,
     };
-
+    
     const res = await uni.$uapi.post("/project/transport/edit", updateData);
-
-    if (res.code === 200) {
+    
+    if (res && res.code === 200) {
       // 鏇存柊鏈湴鏁版嵁
       const index = transports.value.findIndex(
         (item) => item.id === currentTransport.value.id,
@@ -503,19 +580,19 @@
       if (index !== -1) {
         transports.value[index].transitStatus = newStatus;
       }
-
+      
       // 鏇存柊缁熻鏁版嵁
       await loadStats();
-
+      
       // 瀛樺偍鐘舵�佹洿鏂�
       uni.setStorageSync("transportStatusUpdate", {
         orderId: currentTransport.value.id,
         status: newStatus,
       });
-
+      
       return true;
     } else {
-      throw new Error(res.msg || `${actionName}澶辫触`);
+      throw new Error(res?.msg || `${actionName}澶辫触`);
     }
   } catch (error) {
     console.error(`${actionName}澶辫触:`, error);
@@ -535,10 +612,10 @@
 </script>
 
 <style lang="scss" scoped>
-/* 淇濇寔鍘熸湁鏍峰紡瀹屽叏涓嶅彉 */
 .transport-record {
   min-height: 100vh;
   background: linear-gradient(135deg, #fafdff 0%, #e3f0ff 100%);
+  padding-bottom: 100rpx;
 
   .stats-card {
     margin: 20rpx;
@@ -809,6 +886,13 @@
       }
     }
 
+    .load-more, .no-more {
+      text-align: center;
+      padding: 40rpx 0;
+      color: #86868b;
+      font-size: 28rpx;
+    }
+
     .empty-state {
       padding: 120rpx 0;
       text-align: center;
@@ -901,5 +985,27 @@
       }
     }
   }
+  
+  /* 娴姩鎸夐挳 */
+  .float-button {
+    position: fixed;
+    bottom: 100rpx;
+    right: 40rpx;
+    width: 100rpx;
+    height: 100rpx;
+    background: #0071e3;
+    border-radius: 50%;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    box-shadow: 0 8rpx 20rpx rgba(0, 113, 227, 0.3);
+    z-index: 100;
+    transition: all 0.3s ease;
+    
+    &:active {
+      opacity: 0.8;
+      transform: scale(0.95);
+    }
+  }
 }
-</style>
+</style>
\ No newline at end of file

--
Gitblit v1.9.3