From 5f2ee03958a1a16dc27195c76ea7cffb422c95d1 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期五, 19 十二月 2025 22:40:34 +0800
Subject: [PATCH] feat: 任务修改接口,删除一些不要的字段同步

---
 app/pages/task/index.vue |  804 ++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 594 insertions(+), 210 deletions(-)

diff --git a/app/pages/task/index.vue b/app/pages/task/index.vue
index ff9746c..36fdbb6 100644
--- a/app/pages/task/index.vue
+++ b/app/pages/task/index.vue
@@ -108,20 +108,26 @@
       
       <scroll-view class="task-list-scroll" scroll-y="true">
         <view class="task-list">
-          <view class="task-item" v-for="task in filteredTaskList" :key="task.id">
+          <view class="task-item" v-for="task in filteredTaskList" :key="task.taskId">
             <view class="task-main" @click="viewTaskDetail(task)">
-              <view class="task-title">{{ getTaskTypeText(task.type) }} - {{ task.vehicle }}</view>
-              <view class="task-info">
-                <view class="info-row">
-                  <view class="info-item">
-                    <view class="label">浠诲姟缂栧彿:</view>
-                    <view class="value">{{ task.taskNo }}</view>
-                  </view>
-                  <view class="info-item">
-                    <view class="label">浠诲姟鐘舵��:</view>
-                    <view class="value">{{ getStatusText(task.status) }}</view>
-                  </view>
+              <!-- 浠诲姟澶撮儴锛氭爣棰樺拰鐘舵�佹爣绛� -->
+              <view class="task-header">
+                <view class="task-title">
+                  {{ getTaskTypeText(task.taskType) }} - {{ task.vehicle }}
+                  <text v-if="task.isHeadPush === '1'" class="head-push-tag">鎬�</text>
                 </view>
+                <view class="task-status" :class="task.taskStatus === 'PENDING' ? 'status-pending' : task.taskStatus === 'DEPARTING' ? 'status-departing' : task.taskStatus === 'ARRIVED' ? 'status-arrived' : task.taskStatus === 'RETURNING' ? 'status-returning' : task.taskStatus === 'COMPLETED' ? 'status-completed' : task.taskStatus === 'CANCELLED' ? 'status-cancelled' : task.taskStatus === 'IN_PROGRESS' ? 'status-in-progress' : 'status-default'">
+                  {{ getStatusText(task.taskStatus) }}
+                </view>
+              </view>
+              
+              <!-- 浠诲姟缂栧彿鍗曠嫭涓�琛� -->
+              <view class="task-code-row">
+                <text class="task-code">{{ task.showTaskCode }}</text>
+              </view>
+              
+              <!-- 浠诲姟璇︾粏淇℃伅 -->
+              <view class="task-info">
                 <view class="info-row">
                   <view class="info-item">
                     <view class="label">鍑哄彂鍦�:</view>
@@ -147,52 +153,73 @@
             
             <!-- 鎿嶄綔鎸夐挳 -->
             <view class="task-actions">
-              <button 
-                class="action-btn" 
-                :class="{ disabled: isActionDisabled(task, 'depart') }"
-                @click="handleTaskAction(task, 'depart')"
-                v-if="task.status !== 'completed'"
-              >
-                鍑哄彂
-              </button>
-              <button 
-                class="action-btn" 
-                :class="{ disabled: isActionDisabled(task, 'arrive') }"
-                @click="handleTaskAction(task, 'arrive')"
-                v-if="task.status !== 'completed'"
-              >
-                宸插埌杈�
-              </button>
-              <button 
-                class="action-btn" 
-                :class="{ disabled: isActionDisabled(task, 'return') }"
-                @click="handleTaskAction(task, 'return')"
-                v-if="task.status !== 'completed'"
-              >
-                杩旂▼
-              </button>
-              <button 
-                class="action-btn" 
-                :class="{ disabled: isActionDisabled(task, 'settle') }"
-                @click="handleTaskAction(task, 'settle')"
-                v-if="task.status !== 'completed'"
-              >
-                缁撶畻
-              </button>
-              <button 
-                class="action-btn primary" 
-                :class="{ disabled: isActionDisabled(task, 'complete') }"
-                @click="handleTaskAction(task, 'complete')"
-                v-if="task.status !== 'completed'"
-              >
-                宸插畬鎴�
-              </button>
+              <!-- 寰呭鐞嗙姸鎬�: 鏄剧ず鍑哄彂銆佸彇娑� -->
+              <template v-if="task.taskStatus === 'PENDING'">
+                <button 
+                  class="action-btn primary" 
+                  @click="handleTaskAction(task, 'depart')"
+                >
+                  鍑哄彂
+                </button>
+                <button 
+                  class="action-btn cancel" 
+                  @click="handleTaskAction(task, 'cancel')"
+                >
+                  鍙栨秷
+                </button>
+              </template>
+              
+              <!-- 鍑哄彂涓姸鎬�: 鏄剧ず宸插埌杈俱�佸己鍒剁粨鏉� -->
+              <template v-else-if="task.taskStatus === 'DEPARTING'">
+                <button 
+                  class="action-btn primary" 
+                  @click="handleTaskAction(task, 'arrive')"
+                >
+                  宸插埌杈�
+                </button>
+                <button 
+                  class="action-btn cancel" 
+                  @click="handleTaskAction(task, 'forceCancel')"
+                >
+                  寮哄埗缁撴潫
+                </button>
+              </template>
+              
+              <!-- 宸插埌杈剧姸鎬�: 鏄剧ず宸茶繑绋� -->
+              <template v-else-if="task.taskStatus === 'ARRIVED'">
+                <button 
+                  class="action-btn primary" 
+                  @click="handleTaskAction(task, 'return')"
+                >
+                  宸茶繑绋�
+                </button>
+              </template>
+              
+              <!-- 杩旂▼涓姸鎬�: 鏄剧ず宸插畬鎴� -->
+              <template v-else-if="task.taskStatus === 'RETURNING'">
+                <button 
+                  class="action-btn primary" 
+                  @click="handleTaskAction(task, 'complete')"
+                >
+                  宸插畬鎴�
+                </button>
+              </template>
+              
+              <!-- 宸插畬鎴�/宸插彇娑�: 涓嶆樉绀烘寜閽� -->
             </view>
           </view>
           
           <view class="no-data" v-if="filteredTaskList.length === 0">
             <uni-icons type="info" size="40" color="#ccc"></uni-icons>
             <text>鏆傛棤浠诲姟鏁版嵁</text>
+          </view>
+          <!-- 鍔犺浇鏇村鎻愮ず -->
+          <view class="load-more" v-if="filteredTaskList.length > 0 && hasMore">
+            <uni-icons type="spinner-cycle" size="20" color="#999"></uni-icons>
+            <text>姝e湪鍔犺浇鏇村鏁版嵁...</text>
+          </view>
+          <view class="load-more no-more" v-else-if="filteredTaskList.length > 0 && !hasMore">
+            <text>娌℃湁鏇村鏁版嵁浜�</text>
           </view>
         </view>
       </scroll-view>
@@ -202,6 +229,10 @@
 
 <script>
   import uniDatetimePicker from '@/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue'
+  import { listTask, changeTaskStatus } from '@/api/task'
+  import { mapState } from 'vuex'
+  import { formatDateTime } from '@/utils/common'
+  import { checkTaskCanDepart } from '@/utils/taskValidator'
   
   export default {
     components: {
@@ -226,119 +257,71 @@
         currentFilter: 'all',
         
         // 浠诲姟鍒楄〃
-        taskList: [
-          {
-            id: 1,
-            title: '绱ф�ョ淮淇换鍔�',
-            type: 'maintenance', // 缁翠慨淇濆吇
-            startLocation: '骞垮窞甯傚ぉ娌冲尯XX璺�123鍙�',
-            endLocation: '骞垮窞甯傜櫧浜戝尯YY璺�456鍙�',
-            startTime: '2023-05-15 15:00',
-            assignee: '寮犱笁',
-            status: 'pending',
-            vehicle: '绮12345',
-            taskNo: 'RW20230515001'
-          },
-          {
-            id: 2,
-            title: '瀹氭湡淇濆吇浠诲姟',
-            type: 'maintenance', // 缁翠慨淇濆吇
-            startLocation: '娣卞湷甯傚崡灞卞尯XX璺�789鍙�',
-            endLocation: '娣卞湷甯傜鐢板尯YY璺�999鍙�',
-            startTime: '2023-05-14 10:00',
-            assignee: '鏉庡洓',
-            status: 'processing',
-            vehicle: '绮67890',
-            taskNo: 'RW20230514002'
-          },
-          {
-            id: 3,
-            title: '璁惧宸℃浠诲姟',
-            type: 'inspection', // 宸℃浠诲姟
-            startLocation: '鐝犳捣甯傞娲插尯XX璺�321鍙�',
-            endLocation: '鐝犳捣甯傞噾婀惧尯YY璺�654鍙�',
-            startTime: '2023-05-13 17:00',
-            assignee: '鐜嬩簲',
-            status: 'completed',
-            vehicle: '绮11111',
-            taskNo: 'RW20230513003'
-          },
-          {
-            id: 4,
-            title: '鍔犳补浠诲姟',
-            type: 'refuel', // 鍔犳补
-            startLocation: '浣涘北甯傜鍩庡尯AA璺�555鍙�',
-            endLocation: '浣涘北甯傚崡娴峰尯BB璺�888鍙�',
-            startTime: '2023-05-12 09:00',
-            assignee: '璧靛叚',
-            status: 'completed',
-            vehicle: '绮22222',
-            taskNo: 'RW20230512004'
-          },
-          {
-            id: 5,
-            title: '鎬ユ晳杞繍浠诲姟',
-            type: 'emergency', // 鎬ユ晳杞繍
-            startLocation: '骞垮窞甯傝秺绉�鍖哄尰闄㈣矾1鍙�',
-            endLocation: '骞垮窞甯傛捣鐝犲尯鍖婚櫌璺�2鍙�',
-            startTime: '2023-05-16 14:00',
-            assignee: '寮犲尰鐢�,鏉庢姢澹�',
-            status: 'pending',
-            vehicle: '绮33333',
-            taskNo: 'RW20230516005'
-          },
-          {
-            id: 6,
-            title: '绂忕杞︿换鍔�',
-            type: 'welfare', // 绂忕杞�
-            startLocation: '骞垮窞甯傝崝婀惧尯绀惧尯璺�10鍙�',
-            endLocation: '骞垮窞甯傚ぉ娌冲尯鍏昏�侀櫌璺�20鍙�',
-            startTime: '2023-05-17 08:00',
-            assignee: '鐜嬪徃鏈�',
-            status: 'processing',
-            vehicle: '绮44444',
-            taskNo: 'RW20230517006'
-          }
-        ]
+        taskList: [],
+        loading: false,
+        refreshing: false,
+        
+        // 鍒嗛〉鐩稿叧
+        currentPage: 1,
+        pageSize: 10,
+        total: 0,
+        hasMore: true
       }
     },
     computed: {
+      ...mapState({
+        currentUser: state => state.user
+      }),
       filteredTaskList() {
         let filtered = this.taskList;
         
         // 搴旂敤绛涢�夊櫒
         if (this.currentFilter !== 'all') {
           filtered = filtered.filter(task => {
-            if (this.currentFilter === 'pending') return task.status === 'pending';
-            if (this.currentFilter === 'processing') return task.status === 'processing';
-            if (this.currentFilter === 'completed') return task.status === 'completed';
+            if (this.currentFilter === 'pending') return task.taskStatus === 'PENDING';
+            if (this.currentFilter === 'processing') return ['DEPARTING', 'ARRIVED', 'RETURNING', 'IN_PROGRESS'].includes(task.taskStatus);
+            if (this.currentFilter === 'completed') return task.taskStatus === 'COMPLETED';
             return true;
           });
         }
         
         // 搴旂敤鐘舵�佺瓫閫�
         if (this.selectedStatus) {
-          filtered = filtered.filter(task => task.status === this.selectedStatus);
+          const statusMap = {
+            'pending': ['PENDING'],
+            'processing': ['DEPARTING', 'ARRIVED', 'RETURNING', 'IN_PROGRESS'],
+            'completed': ['COMPLETED']
+          }
+          const validStatuses = statusMap[this.selectedStatus];
+          if (validStatuses) {
+            filtered = filtered.filter(task => validStatuses.includes(task.taskStatus));
+          }
         }
         
-        // 搴旂敤杞︾墝鍙风瓫閫�
+        // 搴旂敤杞︾墝鍙风瓫閫� - 鎼滅储assignedVehicles鏁扮粍涓殑杞﹁締
         if (this.searchForm.vehicle) {
-          filtered = filtered.filter(task => 
-            task.vehicle.includes(this.searchForm.vehicle)
-          );
+          filtered = filtered.filter(task => {
+            // 鍦ㄨ溅杈嗗垪琛ㄤ腑鏌ユ壘鍖归厤鐨勮溅鐗屽彿
+            if (task.vehicleList && task.vehicleList.length > 0) {
+              return task.vehicleList.some(vehicle => 
+                vehicle.vehicleNo && vehicle.vehicleNo.includes(this.searchForm.vehicle)
+              )
+            }
+            return false
+          });
         }
         
-        // 搴旂敤浠诲姟缂栧彿绛涢��
+        // 搴旂敤浠诲姟缂栧彿绛涢�� - 浣跨敤taskCode鑰屼笉鏄痶askNo
         if (this.searchForm.taskNo) {
           filtered = filtered.filter(task => 
-            task.taskNo.includes(this.searchForm.taskNo)
+            task.showTaskCode && task.showTaskCode.includes(this.searchForm.taskNo)
           );
         }
         
         // 搴旂敤鏃堕棿鑼冨洿绛涢��
         if (this.startDate) {
           filtered = filtered.filter(task => 
-            task.startTime >= this.startDate
+            task.plannedStartTime && task.plannedStartTime >= this.startDate
           );
         }
         
@@ -349,14 +332,162 @@
           const endDateStr = end.toISOString().split('T')[0];
           
           filtered = filtered.filter(task => 
-            task.startTime < endDateStr
+            task.plannedStartTime && task.plannedStartTime < endDateStr
           );
         }
         
         return filtered;
       }
     },
+    onLoad() {
+      this.loadTaskList()
+      
+      // 鐩戝惉浠诲姟鍒楄〃鍒锋柊浜嬩欢
+      uni.$on('refreshTaskList', this.handleRefreshEvent)
+    },
+    onShow() {
+      // 椤甸潰鏄剧ず鏃跺埛鏂板垪琛紙浠庡叾浠栭〉闈㈣繑鍥炴椂锛�
+      this.loadTaskList()
+    },
+    onUnload() {
+      // 椤甸潰閿�姣佹椂绉婚櫎浜嬩欢鐩戝惉
+      uni.$off('refreshTaskList', this.handleRefreshEvent)
+    },
+    onPullDownRefresh() {
+      this.refreshList()
+    },
+    // 鐩戝惉婊氬姩鍒板簳閮ㄤ簨浠�
+    onReachBottom() {
+      if (this.hasMore && !this.loading) {
+        this.loadMore()
+      }
+    },
     methods: {
+      // 澶勭悊鍒锋柊浜嬩欢
+      handleRefreshEvent() {
+        console.log('鏀跺埌鍒锋柊浠诲姟鍒楄〃浜嬩欢')
+        this.refreshList()
+      },
+      
+      // 鍔犺浇浠诲姟鍒楄〃
+      loadTaskList() {
+        this.loading = true
+        // 閲嶇疆鍒嗛〉鍙傛暟
+        this.currentPage = 1
+        this.hasMore = true
+        this.taskList = []
+        
+        // 鍚庣浼氳嚜鍔ㄨ幏鍙栧綋鍓嶇敤鎴蜂俊鎭紝瀹炵幇缁煎悎鏌ヨ
+        // 缁煎悎鏌ヨ锛氬綋鍓嶇敤鎴锋墍鍦ㄦ満鏋勪换鍔� + 褰撳墠鐢ㄦ埛鍒涘缓鐨勪换鍔� + 鍒嗛厤缁欏綋鍓嶇敤鎴风殑浠诲姟
+        const queryParams = {
+          pageNum: this.currentPage,
+          pageSize: this.pageSize,
+          orderByColumn: 'create_time',
+          isAsc: 'desc'
+        }
+        
+        listTask(queryParams).then(response => {
+          this.loading = false
+          const data = response.data || response.rows || []
+          // 璁剧疆鎬绘暟鍜屾槸鍚︽湁鏇村鏁版嵁
+          this.total = response.total || data.length || 0
+          this.hasMore = data.length === this.pageSize
+          
+          this.taskList = data.map(task => {
+            // 浠巃ssignedVehicles鏁扮粍涓幏鍙栬溅杈嗕俊鎭�
+            let vehicleInfo = '鏈垎閰嶈溅杈�'
+            if (task.assignedVehicles && task.assignedVehicles.length > 0) {
+              // 濡傛灉鏈夊涓溅杈�,鏄剧ず绗竴涓�,骞舵爣娉ㄦ暟閲�
+              const firstVehicle = task.assignedVehicles[0]
+              vehicleInfo = firstVehicle.vehicleNo || '鏈煡杞︾墝'
+              if (task.assignedVehicles.length > 1) {
+                vehicleInfo += ` 绛�${task.assignedVehicles.length}杈哷
+              }
+            }
+            
+            return {
+              ...task,
+              // 鏍煎紡鍖栨樉绀哄瓧娈� - 浣跨敤鍚庣杩斿洖鐨刟ssignedVehicles鏁版嵁
+              vehicle: vehicleInfo,
+              vehicleList: task.assignedVehicles || [],
+              startLocation: this.formatAddress(task.departureAddress || task.startLocation || '鏈缃�'),
+              endLocation: this.formatAddress(task.destinationAddress || task.endLocation || '鏈缃�'),
+              startTime: task.plannedStartTime ? formatDateTime(task.plannedStartTime, 'YYYY-MM-DD HH:mm') : '鏈缃�',
+              assignee: task.assigneeName || '鏈垎閰�'
+            }
+          })
+        }).catch(error => {
+          this.loading = false
+          console.error('鍔犺浇浠诲姟鍒楄〃澶辫触:', error)
+          this.$modal.showToast('鍔犺浇浠诲姟鍒楄〃澶辫触')
+        })
+      },
+      
+      // 鍔犺浇鏇村鏁版嵁
+      loadMore() {
+        if (!this.hasMore || this.loading) return
+        
+        this.loading = true
+        this.currentPage++
+        
+        const queryParams = {
+          pageNum: this.currentPage,
+          pageSize: this.pageSize,
+          orderByColumn: 'create_time',
+          isAsc: 'desc'
+        }
+        
+        listTask(queryParams).then(response => {
+          this.loading = false
+          const data = response.data || response.rows || []
+          // 鏇存柊鏄惁鏈夋洿澶氭暟鎹�
+          this.hasMore = data.length === this.pageSize
+          
+          const newTasks = data.map(task => {
+            // 浠巃ssignedVehicles鏁扮粍涓幏鍙栬溅杈嗕俊鎭�
+            let vehicleInfo = '鏈垎閰嶈溅杈�'
+            if (task.assignedVehicles && task.assignedVehicles.length > 0) {
+              // 濡傛灉鏈夊涓溅杈�,鏄剧ず绗竴涓�,骞舵爣娉ㄦ暟閲�
+              const firstVehicle = task.assignedVehicles[0]
+              vehicleInfo = firstVehicle.vehicleNo || '鏈煡杞︾墝'
+              if (task.assignedVehicles.length > 1) {
+                vehicleInfo += ` 绛�${task.assignedVehicles.length}杈哷
+              }
+            }
+            
+            return {
+              ...task,
+              // 鏍煎紡鍖栨樉绀哄瓧娈� - 浣跨敤鍚庣杩斿洖鐨刟ssignedVehicles鏁版嵁
+              vehicle: vehicleInfo,
+              vehicleList: task.assignedVehicles || [],
+              startLocation: this.formatAddress(task.departureAddress || task.startLocation || '鏈缃�'),
+              endLocation: this.formatAddress(task.destinationAddress || task.endLocation || '鏈缃�'),
+              startTime: task.plannedStartTime ? formatDateTime(task.plannedStartTime, 'YYYY-MM-DD HH:mm') : '鏈缃�',
+              assignee: task.assigneeName || '鏈垎閰�'
+            }
+          })
+          
+          // 灏嗘柊鏁版嵁杩藉姞鍒扮幇鏈夊垪琛ㄤ腑
+          this.taskList = [...this.taskList, ...newTasks]
+        }).catch(error => {
+          this.loading = false
+          this.currentPage-- // 鍑洪敊鏃跺洖閫�椤电爜
+          console.error('鍔犺浇鏇村浠诲姟澶辫触:', error)
+          this.$modal.showToast('鍔犺浇鏇村浠诲姟澶辫触')
+        })
+      },
+      
+      // 鏍煎紡鍖栧湴鍧� - 鍙樉绀�-鍓嶉潰鐨勯儴鍒�
+      formatAddress(address) {
+        if (!address) return '鏈缃�'
+        // 濡傛灉鍦板潃鍖呭惈-锛屽彧杩斿洖-鍓嶉潰鐨勯儴鍒�
+        const dashIndex = address.indexOf('-')
+        if (dashIndex > 0) {
+          return address.substring(0, dashIndex)
+        }
+        return address
+      },
+      
       // 鍒囨崲鏌ヨ鐣岄潰鏄剧ず/闅愯棌
       toggleSearch() {
         this.showSearch = !this.showSearch;
@@ -370,17 +501,10 @@
       
       // 鏌ヨ
       handleSearch() {
+        this.loadTaskList()
         this.$modal.showToast('鏌ヨ鎴愬姛');
-        console.log('鏌ヨ鏉′欢:', {
-          status: this.selectedStatus,
-          startDate: this.startDate,
-          endDate: this.endDate,
-          vehicle: this.searchForm.vehicle,
-          taskNo: this.searchForm.taskNo
-        });
         // 鏌ヨ瀹屾垚鍚庨殣钘忔煡璇㈢晫闈�
         this.showSearch = false;
-        // 杩欓噷鍙互璋冪敤API杩涜鏌ヨ
       },
       
       // 閲嶇疆鏌ヨ鏉′欢
@@ -395,8 +519,14 @@
       
       // 鍒锋柊鍒楄〃
       refreshList() {
-        this.$modal.showToast('鍒楄〃宸插埛鏂�');
-        // 杩欓噷鍙互閲嶆柊鍔犺浇鏁版嵁
+        this.refreshing = true
+        this.loadTaskList()
+        setTimeout(() => {
+          this.refreshing = false
+          // this.$modal.showToast('鍒楄〃宸插埛鏂�');
+          // 鍋滄涓嬫媺鍒锋柊
+          uni.stopPullDownRefresh()
+        }, 1000)
       },
       
       // 绛涢��
@@ -406,93 +536,238 @@
       
       // 鏌ョ湅浠诲姟璇︽儏
       viewTaskDetail(task) {
-        // 璺宠浆鍒颁换鍔¤鎯呴〉闈�
-        this.$tab.navigateTo(`/pages/task/detail?id=${task.id}`);
-      },
-      
-      // 鍒ゆ柇鎿嶄綔鎸夐挳鏄惁绂佺敤
-      isActionDisabled(task, action) {
-        // 鏍规嵁浠诲姟鐘舵�佸拰鎿嶄綔绫诲瀷鍒ゆ柇鏄惁绂佺敤
-        switch (action) {
-          case 'depart':
-            return task.status !== 'pending';
-          case 'arrive':
-            return task.status !== 'processing';
-          case 'return':
-            return task.status !== 'processing';
-          case 'settle':
-            return task.status !== 'processing';
-          case 'complete':
-            return task.status !== 'processing';
-          default:
-            return false;
+        // 闃插尽鎬ф鏌�
+        if (!task || !task.taskId) {
+          console.error('浠诲姟鏁版嵁鏃犳晥:', task)
+          this.$modal.showToast('浠诲姟鏁版嵁寮傚父')
+          return
         }
+        
+        // 璺宠浆鍒颁换鍔¤鎯呴〉闈� - 浣跨敤uni.navigateTo
+        uni.navigateTo({
+          url: `/pagesTask/detail?id=${task.taskId}`
+        });
       },
       
       // 澶勭悊浠诲姟鎿嶄綔
-      handleTaskAction(task, action) {
-        if (this.isActionDisabled(task, action)) {
-          return;
-        }
-        
+      async handleTaskAction(task, action) {
         switch (action) {
           case 'depart':
-            // 鍑哄彂鎿嶄綔锛屾牴鎹换鍔$被鍨嬫樉绀轰笉鍚岀殑纭淇℃伅
-            let departMessage = '纭畾瑕佹爣璁颁负宸插嚭鍙戝悧锛�';
-            if (task.type !== 'maintenance' && task.type !== 'refuel' && task.type !== 'inspection') {
-              departMessage = '鍙戝嚭鍘荤洰鐨勫湴,纭锛�';
+            // 鍑哄彂 -> 鐘舵�佸彉涓哄嚭鍙戜腑
+            // 鏄剧ず鍔犺浇鎻愮ず
+            uni.showLoading({
+              title: '妫�鏌ヤ换鍔$姸鎬�...'
+            });
+            
+            try {
+              // 璋冪敤宸ュ叿绫绘鏌ヤ换鍔℃槸鍚﹀彲浠ュ嚭鍙戯紙鍖呭惈鍩烘湰鏍¢獙鍜屽啿绐佹鏌ワ級
+              const checkResult = await checkTaskCanDepart(task)
+              
+              uni.hideLoading();
+              
+              console.log('鍑哄彂妫�鏌ョ粨鏋�:', checkResult);
+              console.log('valid:', checkResult.valid);
+              console.log('conflicts:', checkResult.conflicts);
+              
+              if (!checkResult.valid) {
+                // 鏍¢獙澶辫触锛屾樉绀烘彁绀轰俊鎭苟鎻愪緵璺宠浆閫夐」
+                const conflicts = checkResult.conflicts || [];
+                const conflictInfo = conflicts.length > 0 ? conflicts[0] : null;
+                
+                console.log('鍐茬獊淇℃伅:', conflictInfo);
+                
+                // 濡傛灉鏈夊啿绐佷换鍔′俊鎭紝鎻愪緵璺宠浆鎸夐挳
+                if (conflictInfo && conflictInfo.taskId) {
+                  console.log('鏄剧ず甯﹁烦杞寜閽殑寮圭獥锛屼换鍔D:', conflictInfo.taskId);
+                  
+                  const conflictTaskId = conflictInfo.taskId;
+                  const message = checkResult.message || conflictInfo.message || '瀛樺湪鍐茬獊浠诲姟';
+                  
+                  uni.showModal({
+                    title: '鎻愮ず',
+                    content: message,
+                    confirmText: '鍘诲鐞�',
+                    cancelText: '鐭ラ亾浜�',
+                    success: function(res) {
+                      console.log('寮圭獥鐐瑰嚮缁撴灉:', res);
+                      if (res.confirm) {
+                        // 鐢ㄦ埛鐐瑰嚮"鐜板湪鍘诲鐞�"锛岃烦杞埌鍐茬獊浠诲姟璇︽儏椤�
+                        console.log('鍑嗗璺宠浆鍒颁换鍔¤鎯呴〉:', conflictTaskId);
+                        uni.navigateTo({
+                          url: `/pagesTask/detail?id=${conflictTaskId}`
+                        });
+                      }
+                    },
+                    fail: function(err) {
+                      console.error('鏄剧ず寮圭獥澶辫触:', err);
+                    }
+                  });
+                } else {
+                  // 娌℃湁鍐茬獊浠诲姟ID锛屽彧鏄剧ず鎻愮ず
+                  console.log('鏄剧ず鏅�氭彁绀哄脊绐�');
+                  uni.showModal({
+                    title: '鎻愮ず',
+                    content: checkResult.message || '浠诲姟鏍¢獙澶辫触',
+                    showCancel: false,
+                    confirmText: '鐭ラ亾浜�',
+                    fail: function(err) {
+                      console.error('鏄剧ず寮圭獥澶辫触:', err);
+                    }
+                  });
+                }
+                return;
+              }
+              
+              // 鎵�鏈夋鏌ラ�氳繃锛屽彲浠ュ嚭鍙�
+              this.$modal.confirm('纭畾瑕佸嚭鍙戝悧锛�').then(() => {
+                this.updateTaskStatus(task.taskId, 'DEPARTING', '浠诲姟宸插嚭鍙�')
+              }).catch(() => {});
+              
+            } catch (error) {
+              uni.hideLoading();
+              console.error('妫�鏌ヤ换鍔$姸鎬佸け璐�:', error);
+              // 妫�鏌ュけ璐ユ椂锛屼粛鐒跺厑璁稿嚭鍙�
+              this.$modal.confirm('妫�鏌ヤ换鍔$姸鎬佸け璐ワ紝鏄惁缁х画鍑哄彂锛�').then(() => {
+                this.updateTaskStatus(task.taskId, 'DEPARTING', '浠诲姟宸插嚭鍙�')
+              }).catch(() => {});
             }
-            this.$modal.confirm(departMessage).then(() => {
-              task.status = 'processing';
-              this.$modal.showToast('宸插嚭鍙�');
-              // 杩欓噷鍙互璋冪敤API鏇存柊浠诲姟鐘舵��
+            break;
+            
+          case 'cancel':
+            // 鍙栨秷 -> 浜屾纭鍚庣姸鎬佸彉涓哄凡鍙栨秷
+            this.$modal.confirm('纭畾瑕佸彇娑堟浠诲姟鍚楋紵').then(() => {
+              this.updateTaskStatus(task.taskId, 'CANCELLED', '浠诲姟宸插彇娑�')
             }).catch(() => {});
             break;
+            
           case 'arrive':
-            // 宸插埌杈炬搷浣�
-            this.$modal.confirm('宸茬粡鍒拌揪鐩殑鍦帮紝纭锛�').then(() => {
-              this.$modal.showToast('宸插埌杈�');
-              // 杩欓噷鍙互璋冪敤API鏇存柊浠诲姟鐘舵��
+            // 宸插埌杈� -> 鐘舵�佸彉涓哄凡鍒拌揪
+            this.$modal.confirm('纭宸插埌杈剧洰鐨勫湴锛�').then(() => {
+              this.updateTaskStatus(task.taskId, 'ARRIVED', '宸插埌杈剧洰鐨勫湴')
             }).catch(() => {});
             break;
+            
+          case 'forceCancel':
+            // 寮哄埗缁撴潫 -> 鐘舵�佸彉涓哄凡鍙栨秷
+            this.$modal.confirm('纭畾瑕佸己鍒剁粨鏉熸浠诲姟鍚楋紵').then(() => {
+              this.updateTaskStatus(task.taskId, 'CANCELLED', '浠诲姟宸插己鍒剁粨鏉�')
+            }).catch(() => {});
+            break;
+            
           case 'return':
-            // 杩旂▼鎿嶄綔
-            this.$modal.confirm('鐜板湪宸茬粡杩旂▼涓紝纭锛�').then(() => {
-              this.$modal.showToast('杩旂▼涓�');
-              // 杩欓噷鍙互璋冪敤API鏇存柊浠诲姟鐘舵��
+            // 宸茶繑绋� -> 鐘舵�佸彉涓鸿繑绋嬩腑
+            this.$modal.confirm('纭寮�濮嬭繑绋嬶紵').then(() => {
+              this.updateTaskStatus(task.taskId, 'RETURNING', '宸插紑濮嬭繑绋�')
             }).catch(() => {});
             break;
-          case 'settle':
-            // 缁撶畻鎿嶄綔锛岃烦杞埌缁撶畻椤甸潰
-            this.$tab.navigateTo(`/pages/task/settlement?id=${task.id}`);
-            break;
+            
           case 'complete':
-            // 宸插畬鎴愭搷浣�
-            this.$modal.confirm('浠诲姟鏄惁宸茬粡鍏ㄩ儴瀹屾垚锛岀‘璁わ紵').then(() => {
-              task.status = 'completed';
-              this.$modal.showToast('浠诲姟宸插畬鎴�');
-              // 杩欓噷鍙互璋冪敤API鏇存柊浠诲姟鐘舵��
+            // 宸插畬鎴� -> 鐘舵�佸彉涓哄凡瀹屾垚
+            this.$modal.confirm('纭浠诲姟宸插畬鎴愶紵').then(() => {
+              this.updateTaskStatus(task.taskId, 'COMPLETED', '浠诲姟宸插畬鎴�')
             }).catch(() => {});
             break;
         }
+      },
+      
+      // 鏇存柊浠诲姟鐘舵��
+      updateTaskStatus(taskId, status, remark) {
+        // 鑾峰彇GPS浣嶇疆淇℃伅
+        this.getLocationAndUpdateStatus(taskId, status, remark)
+      },
+      
+      // 鑾峰彇浣嶇疆淇℃伅骞舵洿鏂扮姸鎬�
+      getLocationAndUpdateStatus(taskId, status, remark) {
+        const that = this
+        
+        // 浣跨敤uni.getLocation鑾峰彇GPS浣嶇疆
+        uni.getLocation({
+          type: 'gcj02',
+          geocode: true,
+          altitude: true,
+          success: function(res) {
+            console.log('GPS瀹氫綅鎴愬姛:', res)
+            
+            const statusData = {
+              taskStatus: status,
+              remark: remark,
+              latitude: res.latitude,
+              longitude: res.longitude,
+              locationAddress: res.address ? res.address.street || res.address.poiName || '' : '',
+              locationProvince: res.address ? res.address.province || '' : '',
+              locationCity: res.address ? res.address.city || '' : '',
+              locationDistrict: res.address ? res.address.district || '' : '',
+              gpsAccuracy: res.accuracy,
+              altitude: res.altitude,
+              speed: res.speed,
+              heading: res.direction || res.heading
+            }
+            
+            changeTaskStatus(taskId, statusData).then(response => {
+              that.$modal.showToast('鐘舵�佹洿鏂版垚鍔�')
+              // 鍒锋柊浠诲姟鍒楄〃
+              that.loadTaskList()
+            }).catch(error => {
+              console.error('鏇存柊浠诲姟鐘舵�佸け璐�:', error)
+              that.$modal.showToast('鐘舵�佹洿鏂板け璐ワ紝璇烽噸璇�')
+            })
+          },
+          fail: function(err) {
+            console.error('GPS瀹氫綅澶辫触:', err)
+            
+            that.$modal.confirm('GPS瀹氫綅澶辫触锛屾槸鍚︾户缁洿鏂扮姸鎬侊紵').then(() => {
+              const statusData = {
+                taskStatus: status,
+                remark: remark
+              }
+              
+              changeTaskStatus(taskId, statusData).then(response => {
+                that.$modal.showToast('鐘舵�佹洿鏂版垚鍔�')
+                // 鍒锋柊浠诲姟鍒楄〃
+                that.loadTaskList()
+              }).catch(error => {
+                console.error('鏇存柊浠诲姟鐘舵�佸け璐�:', error)
+                that.$modal.showToast('鐘舵�佹洿鏂板け璐ワ紝璇烽噸璇�')
+              })
+            }).catch(() => {})
+          }
+        })
       },
       
       getStatusText(status) {
         const statusMap = {
-          'pending': '寰呭鐞�',
-          'processing': '澶勭悊涓�',
-          'completed': '宸插畬鎴�'
+          'PENDING': '寰呭鐞�',
+          'DEPARTING': '鍑哄彂涓�',
+          'ARRIVED': '宸插埌杈�',
+          'RETURNING': '杩旂▼涓�',
+          'COMPLETED': '宸插畬鎴�',
+          'CANCELLED': '宸插彇娑�',
+          'IN_PROGRESS': '澶勭悊涓�' // 鍏煎鏃ф暟鎹�
         }
         return statusMap[status] || '鏈煡'
       },
       
+      // 鑾峰彇鐘舵�佹牱寮忕被
+      getStatusClass(status) {
+        const statusClassMap = {
+          'PENDING': 'status-pending',
+          'DEPARTING': 'status-departing',
+          'ARRIVED': 'status-arrived',
+          'RETURNING': 'status-returning',
+          'COMPLETED': 'status-completed',
+          'CANCELLED': 'status-cancelled',
+          'IN_PROGRESS': 'status-in-progress'
+        }
+        return statusClassMap[status] || 'status-default'
+      },
+      
       getTaskTypeText(type) {
         const typeMap = {
-          'maintenance': '缁翠慨淇濆吇',
-          'refuel': '鍔犳补',
-          'inspection': '宸℃',
-          'emergency': '鎬ユ晳杞繍',
-          'welfare': '绂忕杞�'
+          'MAINTENANCE': '缁翠慨淇濆吇',
+          'FUEL': '鍔犳补',
+          'OTHER': '鍏朵粬',
+          'EMERGENCY_TRANSFER': '杞繍浠诲姟',
+          'WELFARE': '绂忕杞�'
         }
         return typeMap[type] || '鏈煡绫诲瀷'
       }
@@ -524,6 +799,17 @@
     * {
       -ms-overflow-style: none; /* IE 10+ */
     }
+  }
+  
+  // 鎬婚儴鎺ㄩ�佹爣璁版牱寮�
+  .head-push-tag {
+    color: #ff0000;
+    font-size: 24rpx;
+    font-weight: bold;
+    margin-left: 10rpx;
+    padding: 2rpx 8rpx;
+    border: 1rpx solid #ff0000;
+    border-radius: 4rpx;
   }
   
   // 浠诲姟鍒楄〃鍖哄煙
@@ -715,10 +1001,90 @@
         padding: 30rpx;
         border-bottom: 1rpx solid #f0f0f0;
         
-        .task-title {
-          font-size: 32rpx;
-          font-weight: bold;
-          margin-bottom: 20rpx;
+        // 浠诲姟澶撮儴锛氭爣棰樺拰鐘舵��
+        .task-header {
+          display: flex;
+          justify-content: space-between;
+          align-items: flex-start;
+          margin-bottom: 15rpx;
+          
+          .task-title {
+            flex: 1;
+            font-size: 32rpx;
+            font-weight: bold;
+            padding-right: 20rpx;
+            line-height: 1.4;
+          }
+          
+          .task-status {
+            padding: 8rpx 20rpx;
+            border-radius: 30rpx;
+            font-size: 24rpx;
+            white-space: nowrap;
+            flex-shrink: 0;
+            
+            // 寰呭鐞� - 姗欒壊
+            &.status-pending {
+              background-color: #fff3e0;
+              color: #ff9500;
+            }
+            
+            // 鍑哄彂涓� - 钃濊壊
+            &.status-departing {
+              background-color: #e3f2fd;
+              color: #007AFF;
+            }
+            
+            // 宸插埌杈� - 绱壊
+            &.status-arrived {
+              background-color: #f3e5f5;
+              color: #9c27b0;
+            }
+            
+            // 杩旂▼涓� - 闈掕壊
+            &.status-returning {
+              background-color: #e0f2f1;
+              color: #009688;
+            }
+            
+            // 宸插畬鎴� - 缁胯壊
+            &.status-completed {
+              background-color: #e8f5e9;
+              color: #34C759;
+            }
+            
+            // 宸插彇娑� - 鐏拌壊
+            &.status-cancelled {
+              background-color: #f5f5f5;
+              color: #999;
+            }
+            
+            // 澶勭悊涓� (鍏煎鏃ф暟鎹�) - 钃濊壊
+            &.status-in-progress {
+              background-color: #e3f2fd;
+              color: #007AFF;
+            }
+            
+            // 榛樿鏍峰紡
+            &.status-default {
+              background-color: #f5f5f5;
+              color: #666;
+            }
+          }
+        }
+        
+        // 浠诲姟缂栧彿鍗曠嫭涓�琛�
+        .task-code-row {
+          margin-bottom: 15rpx;
+          padding: 10rpx 0;
+          border-bottom: 1rpx dashed #e0e0e0;
+          
+          .task-code {
+            font-size: 28rpx;
+            color: #333;
+            font-weight: 500;
+            font-family: monospace;
+          }
         }
         
         .task-info {
@@ -769,6 +1135,11 @@
             color: white;
           }
           
+          &.cancel {
+            background-color: #ff3b30;
+            color: white;
+          }
+          
           &.disabled {
             opacity: 0.5;
           }
@@ -794,5 +1165,18 @@
         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;
+      }
+    }
   }
 </style>
\ No newline at end of file

--
Gitblit v1.9.1