From f08739f46afe856f60ebb1d21ab23d72947629ed Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期日, 21 十二月 2025 00:03:12 +0800
Subject: [PATCH] feat:优化任务搜索查询 app

---
 app/pages/index.vue |  182 ++++++++++++++++++++++++++++++++++++++------
 1 files changed, 155 insertions(+), 27 deletions(-)

diff --git a/app/pages/index.vue b/app/pages/index.vue
index 1260e73..d86d564 100644
--- a/app/pages/index.vue
+++ b/app/pages/index.vue
@@ -89,15 +89,21 @@
     </view>
 
     <!-- 姝e湪杩愯鐨勪换鍔″垪琛� -->
-    <scroll-view class="running-tasks-section" scroll-y="true">
+    <scroll-view 
+      class="running-tasks-section" 
+      scroll-y="true"
+      @scrolltolower="onScrollToLower"
+    >
       <view class="task-list">
         <view class="task-item" v-for="task in runningTasks" :key="task.id">
           <view class="task-main" @click="viewTaskDetail(task)">
             <!-- 浠诲姟澶撮儴锛氭爣棰樺拰鐘舵�佹爣绛� -->
             <view class="task-header">
-              <view class="task-title"
-                >{{ getTaskTypeText(task.type) }} - {{ task.vehicle }}</view
-              >
+              <view class="task-title">
+                {{ getTaskTypeText(task.type) }} - {{ task.vehicle }}
+                <text v-if="task.emergencyInfo && task.emergencyInfo.serviceOrdVip === '1'" class="vip-tag">VIP</text>
+                <text v-if="task.emergencyInfo && task.emergencyInfo.fromHq2Is === '1'" class="hq-tag">骞挎��</text>
+              </view>
               <view
                 class="task-status"
                 :class="
@@ -122,9 +128,10 @@
               </view>
             </view>
 
-            <!-- 浠诲姟缂栧彿鍗曠嫭涓�琛� -->
+            <!-- 浠诲姟缂栧彿鍜屽紑濮嬫椂闂村湪鍚屼竴琛屾樉绀猴紝浣嗗垎寮�涓�浜� -->
             <view class="task-code-row">
               <text class="task-code">{{ task.showTaskCode }}</text>
+              <text class="task-time">{{ task.startTime }}</text>
             </view>
 
             <!-- 浠诲姟璇︾粏淇℃伅 -->
@@ -132,18 +139,18 @@
               <view class="info-row">
                 <view class="info-item">
                   <view class="label">鍑哄彂鍦�:</view>
-                  <view class="value">{{ task.startLocation }}</view>
+                  <view class="value">{{ getStartLocationDisplay(task) }}</view>
                 </view>
-                <view class="info-item">
-                  <view class="label">鐩殑鍦�:</view>
-                  <view class="value">{{ task.endLocation }}</view>
-                </view>
+                
               </view>
               <view class="info-row">
                 <view class="info-item">
-                  <view class="label">鍑哄彂鏃堕棿:</view>
-                  <view class="value">{{ task.startTime }}</view>
+                  <view class="label">鐩殑鍦�:</view>
+                  <view class="value">{{ getEndLocationDisplay(task) }}</view>
                 </view>
+              </view>
+              <view class="info-row">
+               
                 <view class="info-item">
                   <view class="label">鎵ц浜哄憳:</view>
                   <view class="value">{{ task.assignee }}</view>
@@ -214,6 +221,15 @@
           <uni-icons type="info" size="40" color="#ccc"></uni-icons>
           <text>鏆傛棤姝e湪杩愯鐨勪换鍔�</text>
         </view>
+        
+        <!-- 鍔犺浇鏇村鎻愮ず -->
+        <view class="load-more" v-if="runningTasks.length > 0 && hasMore && loading">
+          <uni-icons type="spinner-cycle" size="20" color="#999"></uni-icons>
+          <text>姝e湪鍔犺浇鏇村鏁版嵁...</text>
+        </view>
+        <view class="load-more no-more" v-else-if="runningTasks.length > 0 && !hasMore">
+          <text>娌℃湁鏇村鏁版嵁浜�</text>
+        </view>
       </view>
     </scroll-view>
   </view>
@@ -240,11 +256,17 @@
       unreadMessageCount: 0,
 
       // 姝e湪杩愯鐨勪换鍔″垪琛�
-      taskList: [],
+      allTaskList: [], // 瀛樺偍鎵�鏈変换鍔℃暟鎹�
+      displayedTaskList: [], // 瀛樺偍褰撳墠鏄剧ず鐨勪换鍔℃暟鎹�
       loading: false,
 
       // 璁㈤槄鐘舵��
       hasSubscribed: false,
+      
+      // 鍓嶇鍒嗛〉鐩稿叧
+      currentPage: 1,
+      pageSize: 10,
+      hasMore: true,
     };
   },
   computed: {
@@ -255,7 +277,7 @@
 
     // 姝e湪杩愯鐨勪换鍔★紙寰呭鐞嗗拰鍚勭澶勭悊涓殑浠诲姟锛�
     runningTasks() {
-      return this.taskList.filter((task) => {
+      return this.displayedTaskList.filter((task) => {
         // 鍖呭惈寰呭鐞嗐�佸嚭鍙戜腑銆佸凡鍒拌揪銆佽繑绋嬩腑绛夋墍鏈夋湭瀹屾垚鐨勭姸鎬�
         return [
           "PENDING",
@@ -279,7 +301,7 @@
     this.hasSubscribed = true;//subscribeManager.checkLocalSubscribeStatus();
 
     // 鑷姩璁㈤槄锛堝鏋滄湭璁㈤槄鍒欐樉绀虹‘璁ゅ脊绐楋級
-    this.autoSubscribeOnLaunch();
+    // this.autoSubscribeOnLaunch();
 
     // 鍔犺浇鐢ㄦ埛缁戝畾杞﹁締淇℃伅
     this.loadUserVehicle();
@@ -298,10 +320,16 @@
 
     // 姣忔鏄剧ず椤甸潰鏃跺埛鏂颁换鍔″垪琛ㄣ�佺粦瀹氳溅杈嗗拰娑堟伅鏁伴噺
     this.loadUserVehicle();
+    // 閲嶆柊鍔犺浇浠诲姟鍒楄〃鏃堕噸缃垎椤�
+    this.currentPage = 1;
+    this.hasMore = true;
     this.loadRunningTasks();
     this.loadUnreadMessageCount();
   },
   onPullDownRefresh() {
+    // 涓嬫媺鍒锋柊鏃堕噸缃垎椤靛弬鏁�
+    this.currentPage = 1;
+    this.hasMore = true;
     // 涓嬫媺鍒锋柊
     this.loadRunningTasks();
     setTimeout(() => {
@@ -309,6 +337,13 @@
     }, 1000);
   },
   methods: {
+    // 婊氬姩鍒板簳閮ㄦ椂鍔犺浇鏇村
+    onScrollToLower() {
+      if (this.hasMore && !this.loading) {
+        this.loadMoreTasks();
+      }
+    },
+    
     // 鑷姩璁㈤槄锛堝皬绋嬪簭鍚姩鏃惰皟鐢級
     autoSubscribeOnLaunch() {
       subscribeManager.autoSubscribe()
@@ -437,9 +472,16 @@
           this.loading = false;
           // 鏍规嵁鍚庣杩斿洖鐨勬暟鎹粨鏋勮繘琛岃В鏋�
           const data = response.data || response.rows || response || [];
-          // 杩囨护鍑烘湭瀹屾垚鐨勪换鍔�
-          const allTasks = Array.isArray(data) ? data : [];
-          this.taskList = allTasks
+          
+          // 濡傛灉鏄涓�椤碉紝鐩存帴鏇挎崲鏁版嵁锛涘惁鍒欒拷鍔犳暟鎹�
+          if (this.currentPage === 1) {
+            this.allTaskList = data;
+          } else {
+            this.allTaskList = [...this.allTaskList, ...data];
+          }
+          
+          // 鏍煎紡鍖栦换鍔℃暟鎹�
+          this.allTaskList = this.allTaskList
             .filter((task) => {
               // 鍙樉绀烘湭瀹屾垚鍜屾湭鍙栨秷鐨勪换鍔�
               return (
@@ -465,12 +507,8 @@
                 type: task.taskType,
                 vehicle: vehicleInfo,
                 vehicleList: task.assignedVehicles || [],
-                startLocation: this.formatAddress(
-                  task.departureAddress || task.startLocation || "鏈缃�"
-                ),
-                endLocation: this.formatAddress(
-                  task.destinationAddress || task.endLocation || "鏈缃�"
-                ),
+                startLocation: task.departureAddress || task.startLocation || "鏈缃�",
+                endLocation: task.destinationAddress || task.endLocation || "鏈缃�",
                 startTime: task.plannedStartTime
                   ? formatDateTime(task.plannedStartTime, "YYYY-MM-DD HH:mm")
                   : "鏈缃�",
@@ -479,11 +517,30 @@
                 status: this.convertStatus(task.taskStatus), // 杞崲鐘舵�佹牸寮忎互鍏煎鏃I
               };
             });
+
+          // 鏇存柊鏄剧ず鐨勪换鍔″垪琛�
+          this.updateDisplayedTaskList();
         })
         .catch((error) => {
           this.loading = false;
           console.error("鍔犺浇浠诲姟鍒楄〃澶辫触:", error);
         });
+    },
+    
+    // 鏇存柊鏄剧ず鐨勪换鍔″垪琛紙鍓嶇鍒嗛〉锛�
+    updateDisplayedTaskList() {
+      const start = 0;
+      const end = this.currentPage * this.pageSize;
+      this.displayedTaskList = this.allTaskList.slice(start, end);
+      this.hasMore = end < this.allTaskList.length;
+    },
+    
+    // 鍔犺浇鏇村浠诲姟锛堝墠绔垎椤碉級
+    loadMoreTasks() {
+      if (!this.hasMore || this.loading) return;
+      
+      this.currentPage++;
+      this.updateDisplayedTaskList();
     },
 
     // 鏍煎紡鍖栧湴鍧� - 鍙樉绀�-鍓嶉潰鐨勯儴鍒�
@@ -494,6 +551,33 @@
         return address.substring(0, dashIndex);
       }
       return address;
+    },
+
+    // 鑾峰彇鍑哄彂鍦版樉绀哄唴瀹癸紙杞繍浠诲姟鏄剧ず杞嚭鍖婚櫌鍚嶇О锛�
+    getStartLocationDisplay(task) {
+      // 濡傛灉鏄浆杩愪换鍔′笖鏈塭mergencyInfo淇℃伅
+      if (task.taskType === 'EMERGENCY_TRANSFER' && task.emergencyInfo && task.emergencyInfo.hospitalOutName) {
+        return task.emergencyInfo.hospitalOutName;
+      }
+      // 鍏朵粬鎯呭喌浣跨敤鍘熸潵鐨剆tartLocation
+      return this.formatAddress(task.startLocation || "鏈缃�");
+    },
+
+    // 鑾峰彇鐩殑鍦版樉绀哄唴瀹癸紙杞繍浠诲姟鏄剧ず杞叆鍖婚櫌鍚嶇О鎴栬缁嗗湴鍧�锛�
+    getEndLocationDisplay(task) {
+      // 濡傛灉鏄浆杩愪换鍔′笖鏈塭mergencyInfo淇℃伅
+      if (task.taskType === 'EMERGENCY_TRANSFER' && task.emergencyInfo) {
+        // 浼樺厛鏄剧ず杞叆鍖婚櫌鍚嶇О
+        if (task.emergencyInfo.hospitalInName) {
+          if(task.emergencyInfo.hospitalInName.includes("瀹朵腑")){
+            return task.emergencyInfo.destinationAddress;
+          }
+          return task.emergencyInfo.hospitalInName;
+        }
+      
+      }
+      // 鍏朵粬鎯呭喌浣跨敤鍘熸潵鐨別ndLocation
+      return this.formatAddress(task.endLocation || "鏈缃�");
     },
 
     // 杞崲鐘舵�佹牸寮忥紙灏嗘暟鎹簱鐘舵�佽浆鎹负UI浣跨敤鐨勭姸鎬侊級
@@ -755,12 +839,12 @@
     height: 0 !important;
     background: transparent;
   }
-
+  
   // Firefox婊氬姩鏉¢殣钘�
   * {
     scrollbar-width: none; /* Firefox */
   }
-
+  
   // IE/Edge婊氬姩鏉¢殣钘�
   * {
     -ms-overflow-style: none; /* IE 10+ */
@@ -1045,13 +1129,22 @@
           }
         }
 
-        // 浠诲姟缂栧彿鍗曠嫭涓�琛�
+        // 浠诲姟缂栧彿鍜屾椂闂村湪鍚屼竴琛屾樉绀�
         .task-code-row {
           margin-bottom: 15rpx;
           padding: 10rpx 0;
           border-bottom: 1rpx dashed #e0e0e0;
+          display: flex;
+          justify-content: space-between;
 
           .task-code {
+            font-size: 28rpx;
+            color: #333;
+            font-weight: 500;
+            font-family: monospace;
+          }
+          
+          .task-time {
             font-size: 28rpx;
             color: #333;
             font-weight: 500;
@@ -1137,6 +1230,41 @@
         margin-top: 20rpx;
       }
     }
+    
+    .load-more {
+      display: flex;
+      justify-content: center;
+      align-items: center;
+      padding: 20rpx 0;
+      color: #999;
+      font-size: 28rpx;
+      
+      &.no-more {
+        color: #666;
+      }
+    }
+    
+    .vip-tag {
+      display: inline-block;
+      padding: 2rpx 8rpx;
+      font-size: 20rpx;
+      color: #fff;
+      background-color: #ff0000;
+      border-radius: 4rpx;
+      margin-left: 10rpx;
+      vertical-align: middle;
+    }
+    
+    .hq-tag {
+      display: inline-block;
+      padding: 2rpx 8rpx;
+      font-size: 20rpx;
+      color: #fff;
+      background-color: #5856d6;
+      border-radius: 4rpx;
+      margin-left: 10rpx;
+      vertical-align: middle;
+    }
   }
 }
 </style>
\ No newline at end of file

--
Gitblit v1.9.1