From f5c900c58513bad824381e69750ac7667ef35de0 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期四, 26 二月 2026 22:29:46 +0800
Subject: [PATCH] feat: 修改增另任务单查询,使用单号查询

---
 ruoyi-ui/src/views/task/general/detail.vue |  146 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 142 insertions(+), 4 deletions(-)

diff --git a/ruoyi-ui/src/views/task/general/detail.vue b/ruoyi-ui/src/views/task/general/detail.vue
index bd5a736..2c0ab51 100644
--- a/ruoyi-ui/src/views/task/general/detail.vue
+++ b/ruoyi-ui/src/views/task/general/detail.vue
@@ -129,6 +129,16 @@
             @click="syncDispatchOrder"
             style="margin-left: 10px;"
           >鍚屾璋冨害鍗�</el-button>
+          <!-- 浠庢棫绯荤粺鍚屾鏁版嵁鍒版柊绯荤粺鎸夐挳 -->
+          <el-button
+            v-if="taskDetail.emergencyInfo.legacyServiceOrdId && taskDetail.emergencyInfo.legacyDispatchOrdId"
+            type="success"
+            size="mini"
+            icon="el-icon-download"
+            :loading="syncingFromLegacy"
+            @click="syncFromLegacySystem"
+            style="margin-left: 10px;"
+          >浠庢棫绯荤粺鍚屾</el-button>
         </el-descriptions-item>
         <el-descriptions-item label="璋冨害鍗曞彿">
           <span v-if="taskDetail.emergencyInfo.legacyDispatchOrdId">
@@ -150,12 +160,42 @@
           <span v-if="taskDetail.emergencyInfo.dispatchSyncErrorMsg" style="color: #F56C6C;">{{ taskDetail.emergencyInfo.dispatchSyncErrorMsg }}</span>
           <span v-else style="color: #C0C4CC;">--</span>
         </el-descriptions-item>
+        <el-descriptions-item label="浠诲姟鐘舵�佸悓姝�" :span="2">
+          <el-alert
+            title="鎻愮ず锛氫换鍔$姸鎬佷細鑷姩鍚屾鍒版棫绯荤粺鐨勮皟搴﹀崟涓紝濡傛灉鍥犵綉缁滅瓑鍘熷洜鏈悓姝ワ紝鍙偣鍑讳笅鏂规寜閽墜鍔ㄥ悓姝ャ��"
+            type="info"
+            :closable="false"
+            show-icon
+            style="margin-bottom: 10px;">
+          </el-alert>
+          <el-button
+            v-if="taskDetail.emergencyInfo.legacyDispatchOrdId && taskDetail.emergencyInfo.legacyDispatchOrdId > 0"
+            type="warning"
+            size="small"
+            icon="el-icon-refresh"
+            :loading="syncingTaskStatus"
+            @click="syncTaskStatus"
+          >鍚屾浠诲姟鐘舵�佸埌鏃х郴缁�</el-button>
+          <el-tag v-else type="info" size="small">
+            <i class="el-icon-warning"></i> 璇峰厛鍚屾璋冨害鍗�
+          </el-tag>
+        </el-descriptions-item>
       </el-descriptions>
 
       <!-- 鏀粯淇℃伅锛堜粎鎬ユ晳杞繍浠诲姟鏄剧ず锛� -->
       <el-card v-if="taskDetail.taskType === 'EMERGENCY_TRANSFER' && paymentInfo" class="box-card" style="margin-top: 20px;">
         <div slot="header" class="clearfix">
           <span>鏀粯淇℃伅</span>
+          <!-- 宸插畬鎴愪笖鏈敵璇峰彂绁ㄦ椂鏄剧ず鐢宠鍙戠エ鎸夐挳 -->
+          <el-button 
+            v-if="canApplyInvoice" 
+            style="float: right; padding: 3px 0" 
+            type="text" 
+            @click="handleApplyInvoice"
+            v-hasPermi="['system:invoice:add']"
+          >
+            <i class="el-icon-document-add"></i> 鐢宠鍙戠エ
+          </el-button>
         </div>
         
         <!-- 鏀粯姒傝 -->
@@ -758,7 +798,7 @@
 </template>
 
 <script>
-import { getTask, updateTask, assignTask, changeTaskStatus, uploadAttachment, deleteAttachment, getTaskVehicles, getAvailableVehicles, assignVehiclesToTask, unassignVehicleFromTask, getPaymentInfo, syncServiceOrder, syncDispatchOrder } from "@/api/task";
+import { getTask, updateTask, assignTask, changeTaskStatus, uploadAttachment, deleteAttachment, getTaskVehicles, getAvailableVehicles, assignVehiclesToTask, unassignVehicleFromTask, getPaymentInfo, syncServiceOrder, syncDispatchOrder, syncTaskStatus, syncFromLegacySystem, checkTaskInvoice } from "@/api/task";
 import { listUser } from "@/api/system/user";
 import { getToken } from "@/utils/auth";
 
@@ -850,7 +890,12 @@
       },
       // 鍚屾鍔犺浇鐘舵��
       syncingServiceOrder: false,
-      syncingDispatchOrder: false
+      syncingDispatchOrder: false,
+      syncingFromLegacy: false,
+      syncingTaskStatus: false,
+      // 鍙戠エ鐢宠鐘舵��
+      hasInvoiceApplied: false,
+      invoiceStatus: null // 0-寰呭鏍�, 1-宸查�氳繃, 2-宸查┏鍥�
     };
   },
   created() {
@@ -859,6 +904,19 @@
     this.getAdditionalFeeList();
     // 鍒濆鍖栦笂浼燯RL
     this.uploadUrl = process.env.VUE_APP_BASE_API + "/task/attachment/upload/" + this.$route.params.taskId;
+    // 妫�鏌ュ彂绁ㄧ敵璇风姸鎬�
+    this.checkInvoiceStatus();
+  },
+  computed: {
+    /** 鏄惁鍙互鐢宠鍙戠エ */
+    canApplyInvoice() {
+      // 鍙湁鎬ユ晳杞繍浠诲姟
+      if (this.taskDetail.taskType !== 'EMERGENCY_TRANSFER') return false;
+      // 浠诲姟蹇呴』宸插畬鎴�
+      if (this.taskDetail.taskStatus !== 'COMPLETED') return false;
+      // 鏈敵璇疯繃鍙戠エ锛屾垨鑰呮浘琚┏鍥�
+      return !this.hasInvoiceApplied || this.invoiceStatus === 2;
+    }
   },
   methods: {
     /** 鑾峰彇浠诲姟璇︽儏 */
@@ -1157,7 +1215,7 @@
       }).then(() => {
         this.$modal.msgSuccess("鏈嶅姟鍗曞悓姝ユ垚鍔�");
         // 閲嶆柊鍔犺浇浠诲姟璇︽儏
-        this.getDetail();
+        this.getTaskDetail();
       }).catch(() => {
         // 澶勭悊鍙栨秷鍜岄敊璇�
       }).finally(() => {
@@ -1172,12 +1230,92 @@
       }).then(() => {
         this.$modal.msgSuccess("璋冨害鍗曞悓姝ユ垚鍔�");
         // 閲嶆柊鍔犺浇浠诲姟璇︽儏
-        this.getDetail();
+        this.getTaskDetail();
       }).catch(() => {
         // 澶勭悊鍙栨秷鍜岄敊璇�
       }).finally(() => {
         this.syncingDispatchOrder = false;
       });
+    },
+    /** 浠庢棫绯荤粺鍚屾鏁版嵁鍒版柊绯荤粺 */
+    syncFromLegacySystem() {
+      // 妫�鏌ユ槸鍚﹀悓鏃舵湁serviceOrdID鍜宒ispatchOrdID
+      if (!this.taskDetail.emergencyInfo.legacyServiceOrdId || !this.taskDetail.emergencyInfo.legacyDispatchOrdId) {
+        this.$modal.msgError("缂哄皯蹇呰鐨勬棫绯荤粺ID淇℃伅");
+        return;
+      }
+      
+      this.$modal.confirm('鏄惁纭浠庢棫绯荤粺鍚屾鏁版嵁鍒版柊绯荤粺锛�').then(() => {
+        this.syncingFromLegacy = true;
+        return syncFromLegacySystem(
+          this.taskDetail.emergencyInfo.legacyServiceOrdId,
+          this.taskDetail.emergencyInfo.legacyDispatchOrdId
+        );
+      }).then(() => {
+        this.$modal.msgSuccess("浠庢棫绯荤粺鍚屾鎴愬姛");
+        // 閲嶆柊鍔犺浇浠诲姟璇︽儏
+        this.getTaskDetail();
+      }).catch((error) => {
+        if (error !== 'cancel') {
+          this.$modal.msgError("鍚屾澶辫触: " + (error.message || "鏈煡閿欒"));
+        }
+      }).finally(() => {
+        this.syncingFromLegacy = false;
+      });
+    },
+    /** 鎵嬪姩鍚屾浠诲姟鐘舵�� */
+    syncTaskStatus() {
+      this.$modal.confirm('鏄惁纭鍚屾浠诲姟鐘舵�佸埌鏃х郴缁燂紵').then(() => {
+        this.syncingTaskStatus = true;
+        return syncTaskStatus(this.taskDetail.taskId);
+      }).then(() => {
+        this.$modal.msgSuccess("浠诲姟鐘舵�佸悓姝ユ垚鍔�");
+        // 閲嶆柊鍔犺浇浠诲姟璇︽儏
+        this.getTaskDetail();
+      }).catch(() => {
+        // 澶勭悊鍙栨秷鍜岄敊璇�
+      }).finally(() => {
+        this.syncingTaskStatus = false;
+      });
+    },
+    
+    /** 妫�鏌ュ彂绁ㄧ敵璇风姸鎬� */
+    checkInvoiceStatus() {
+      // 璋冪敤鍚庣鎺ュ彛妫�鏌ヨ浠诲姟鏄惁宸茬敵璇峰彂绁�
+      checkTaskInvoice(this.$route.params.taskId)
+        .then(response => {
+          if (response.code === 200 && response.data) {
+            this.hasInvoiceApplied = true;
+            this.invoiceStatus = response.data.status;
+          }
+        })
+        .catch(() => {
+          // 蹇界暐閿欒锛岄粯璁ゆ湭鐢宠
+        });
+    },
+    
+    /** 鐢宠鍙戠エ */
+    handleApplyInvoice() {
+      // 璺宠浆鍒板彂绁ㄧ敵璇烽〉闈紝甯︿笂浠诲姟淇℃伅
+      const taskInfo = {
+        taskId: this.taskDetail.taskId,
+        taskCode: this.taskDetail.taskCode || this.taskDetail.showTaskCode,
+        legacyServiceOrderId: this.taskDetail.emergencyInfo?.legacyServiceOrdId,
+        serviceCode: this.taskDetail.emergencyInfo?.serviceCode,
+        departure: this.taskDetail.departureAddress,
+        destination: this.taskDetail.destinationAddress,
+        completionTime: this.parseTime(this.taskDetail.actualEndTime),
+        transferPrice: this.paymentInfo?.transferPrice || this.paymentInfo?.totalAmount
+      };
+      
+      // 灏嗕换鍔′俊鎭瓨鍌ㄥ埌 sessionStorage
+      sessionStorage.setItem('invoiceTaskInfo', JSON.stringify(taskInfo));
+      
+      // 璺宠浆鍒板彂绁ㄧ敵璇烽〉闈�
+      this.$router.push({
+        path: '/system/invoice/apply',
+        query: { taskId: this.taskDetail.taskId }
+      });
     }
   }
 };

--
Gitblit v1.9.1