From 847a7773ef1a8ad418c6934d35b5f205a97c04d0 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期六, 06 十二月 2025 17:03:24 +0800
Subject: [PATCH] fix:在任务状态更新时,需要更新日志到旧系统

---
 app/pagesTask/detail.vue |  114 +++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 74 insertions(+), 40 deletions(-)

diff --git a/app/pagesTask/detail.vue b/app/pagesTask/detail.vue
index 0e96658..277d825 100644
--- a/app/pagesTask/detail.vue
+++ b/app/pagesTask/detail.vue
@@ -37,7 +37,7 @@
           <view 
             class="assignee-item" 
             v-for="(assignee, index) in taskDetail.assignees" 
-            :key="assignee.userId || index"
+            :key="'assignee-' + (assignee.userId || assignee.userName || index)"
           >
             <view class="assignee-index">{{ index + 1 }}</view>
             <view class="assignee-info">
@@ -131,12 +131,12 @@
         </view>
       </view>
       
-      <view class="detail-section" v-if="taskDetail.taskDescription">
+      <view class="detail-section" v-if="taskDetail.taskDescription && taskDetail.taskType !== 'EMERGENCY_TRANSFER'">
         <view class="section-title">浠诲姟鎻忚堪</view>
         <view class="description">{{ taskDetail.taskDescription }}</view>
       </view>
       
-      <view class="detail-section" v-if="taskDetail.remark">
+      <view class="detail-section" v-if="taskDetail.remark && taskDetail.taskType !== 'EMERGENCY_TRANSFER'">
         <view class="section-title">澶囨敞淇℃伅</view>
         <view class="description">{{ taskDetail.remark }}</view>
       </view>
@@ -250,8 +250,8 @@
         <view class="section-title">鏀粯璁板綍</view>
         <view 
           class="payment-record-item" 
-          v-for="payment in paymentInfo.paidPayments" 
-          :key="payment.id"
+          v-for="(payment, index) in paymentInfo.paidPayments" 
+          :key="'payment-' + (payment.id || index)"
         >
           <view class="payment-header">
             <view 
@@ -449,6 +449,7 @@
   import { checkVehicleActiveTasks } from '@/api/task'
   import { getPaymentInfo } from '@/api/payment'
   import { formatDateTime } from '@/utils/common'
+  import { validateTaskForDepart, validateTaskForSettlement, getTaskVehicleId, checkTaskCanDepart } from '@/utils/taskValidator'
   import AttachmentUpload from './components/AttachmentUpload.vue'
   
   export default {
@@ -752,6 +753,15 @@
       
       // 澶勭悊缁撶畻
       handleSettlement() {
+        // 鏍¢獙浠诲姟鏄惁鍙互缁撶畻
+        const validation = validateTaskForSettlement(this.taskDetail)
+        if (!validation.valid) {
+          this.$modal.confirm(`${validation.message}锛岄渶瑕佸厛淇敼浠诲姟鍚庢墠鑳界粨绠椼�傛槸鍚︾幇鍦ㄥ幓淇敼锛焋).then(() => {
+            this.handleEdit()
+          }).catch(() => {})
+          return
+        }
+        
         uni.navigateTo({
           url: '/pagesTask/settlement?taskId=' + this.taskId
         })
@@ -803,60 +813,84 @@
       },
       
       // 妫�鏌ヨ溅杈嗙姸鎬佸苟鍑哄彂
-      checkVehicleAndDepart() {
-        // 鑾峰彇浠诲姟杞﹁締ID
-        const vehicleId = this.getVehicleId();
-        if (!vehicleId) {
-          this.$modal.showToast('鏈壘鍒颁换鍔¤溅杈嗕俊鎭�');
-          return;
-        }
-        
+      async checkVehicleAndDepart() {
         // 鏄剧ず鍔犺浇鎻愮ず
         uni.showLoading({
-          title: '妫�鏌ヨ溅杈嗙姸鎬�...'
+          title: '妫�鏌ヤ换鍔$姸鎬�...'
         });
         
-        checkVehicleActiveTasks(vehicleId).then(response => {
+        try {
+          // 璋冪敤宸ュ叿绫绘鏌ヤ换鍔℃槸鍚﹀彲浠ュ嚭鍙戯紙鍖呭惈鍩烘湰鏍¢獙鍜屽啿绐佹鏌ワ級
+          const checkResult = await checkTaskCanDepart(this.taskDetail)
+          
           uni.hideLoading();
           
-          const activeTasks = response.data || [];
+          console.log('鍑哄彂妫�鏌ョ粨鏋�:', checkResult);
+          console.log('valid:', checkResult.valid);
+          console.log('conflicts:', checkResult.conflicts);
           
-          // 杩囨护鎺夊綋鍓嶄换鍔℃湰韬紙淇锛氶槻姝� activeTasks 涓� null锛�
-          const otherActiveTasks = (activeTasks && Array.isArray(activeTasks)) ? activeTasks.filter(task => task.taskId !== this.taskId) : [];
-          
-          if (otherActiveTasks.length > 0) {
-            // 杞﹁締鏈夊叾浠栨鍦ㄨ繘琛屼腑鐨勪换鍔�
-            const task = otherActiveTasks[0];
-            const taskStatus = this.getStatusText(task.taskStatus);
-            const message = `璇ヨ溅杈嗗凡鏈夋鍦ㄨ浆杩愪腑鐨勪换鍔★紒
-
-浠诲姟鍗曞彿锛�${task.taskCode}
-浠诲姟鐘舵�侊細${taskStatus}
-
-璇峰厛瀹屾垚褰撳墠浠诲姟鍚庡啀鍑哄彂鏂颁换鍔°�俙;
+          if (!checkResult.valid) {
+            // 鏍¢獙澶辫触锛屾樉绀烘彁绀轰俊鎭苟鎻愪緵璺宠浆閫夐」
+            const conflicts = checkResult.conflicts || [];
+            const conflictInfo = conflicts.length > 0 ? conflicts[0] : null;
             
-            uni.showModal({
-              title: '鎻愮ず',
-              content: message,
-              showCancel: false,
-              confirmText: '鎴戠煡閬撲簡'
-            });
+            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.redirectTo({
+                      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;
           }
           
-          // 杞﹁締娌℃湁鍏朵粬姝e湪杩涜涓殑浠诲姟锛屽彲浠ュ嚭鍙�
+          // 鎵�鏈夋鏌ラ�氳繃锛屽彲浠ュ嚭鍙�
           this.$modal.confirm('纭畾瑕佸嚭鍙戝悧锛�').then(() => {
             this.updateTaskStatus('DEPARTING', '浠诲姟宸插嚭鍙�')
           }).catch(() => {});
           
-        }).catch(error => {
+        } catch (error) {
           uni.hideLoading();
-          console.error('妫�鏌ヨ溅杈嗙姸鎬佸け璐�:', error);
+          console.error('妫�鏌ヤ换鍔$姸鎬佸け璐�:', error);
           // 妫�鏌ュけ璐ユ椂锛屼粛鐒跺厑璁稿嚭鍙�
-          this.$modal.confirm('妫�鏌ヨ溅杈嗙姸鎬佸け璐ワ紝鏄惁缁х画鍑哄彂锛�').then(() => {
+          this.$modal.confirm('妫�鏌ヤ换鍔$姸鎬佸け璐ワ紝鏄惁缁х画鍑哄彂锛�').then(() => {
             this.updateTaskStatus('DEPARTING', '浠诲姟宸插嚭鍙�')
           }).catch(() => {});
-        });
+        }
       },
       
       // 鑾峰彇浠诲姟杞﹁締ID

--
Gitblit v1.9.1