From 93ad376d868efc7ff5f42a6e54bae720f9322eed Mon Sep 17 00:00:00 2001
From: rain <1679827795@qq.com>
Date: Tue, 22 Apr 2025 14:22:04 +0800
Subject: [PATCH] 增加状态为已完结任务总耗时时间

---
 src/views/tickets/ticket.vue |   99 ++++++++++++++++++++++++-------------------------
 1 files changed, 49 insertions(+), 50 deletions(-)

diff --git a/src/views/tickets/ticket.vue b/src/views/tickets/ticket.vue
index 3e5e526..e40e967 100644
--- a/src/views/tickets/ticket.vue
+++ b/src/views/tickets/ticket.vue
@@ -156,6 +156,10 @@
     <el-dialog v-model="detailVisible" title="工单详情" width="80%" append-to-body>
       <div class="detail-container">
         <div class="event-title-center">{{ currentDetail.orderName || '事件名称' }}</div>
+        <div v-if="totalTime" class="event-total-time"
+          style="text-align:center;color:#666;font-size:15px;margin-bottom:12px;">
+          总耗时:{{ totalTime }}
+        </div>
         <!-- 工单状态流程 -->
         <div class="custom-steps-container">
           <!-- 标题行 -->
@@ -286,13 +290,9 @@
               <div class="media-box">
                 <div class="media-title">事件图片</div>
                 <div class="media-content">
-                  <el-image
-                    v-if="currentDetail.mediaUrl"
-                    :src="getThumbUrl(currentDetail.mediaUrl)"
-                    :preview-src-list="[currentDetail.mediaUrl]"
-                    fit="cover"
-                    style="width: 100%; height: 300px; cursor: pointer;"
-                  >
+                  <el-image v-if="currentDetail.mediaUrl" :src="getThumbUrl(currentDetail.mediaUrl)"
+                    :preview-src-list="[currentDetail.mediaUrl]" fit="cover"
+                    style="width: 100%; height: 300px; cursor: pointer;">
                     <template #placeholder>
                       <div class="image-placeholder">
                         <i class="el-icon-picture-outline"></i>
@@ -316,13 +316,9 @@
                 <template v-if="currentDetail.status === 5">
                   <div class="media-title">工单处理图片</div>
                   <div class="media-content">
-                    <el-image
-                      v-if="currentDetail.updatePhotoUrl"
-                      :src="getThumbUrl(currentDetail.updatePhotoUrl)"
-                      :preview-src-list="[currentDetail.updatePhotoUrl]"
-                      fit="cover"
-                      style="width: 100%; height: 300px; cursor: pointer;"
-                    >
+                    <el-image v-if="currentDetail.updatePhotoUrl" :src="getThumbUrl(currentDetail.updatePhotoUrl)"
+                      :preview-src-list="[currentDetail.updatePhotoUrl]" fit="cover"
+                      style="width: 100%; height: 300px; cursor: pointer;">
                       <template #placeholder>
                         <div class="image-placeholder">
                           <i class="el-icon-picture-outline"></i>
@@ -356,23 +352,29 @@
         <div class="dialog-footer">
           <template v-if="currentDetail.status === 2">
             <!-- 待审核 -->
-            <el-button v-if="hasReviewBtnPermission()" type="primary" :loading="approveLoading" @click="approveTicket">通过</el-button>
-            <el-button v-if="hasReviewBtnPermission()" type="danger" :loading="rejectLoading" @click="rejectTicket">不通过</el-button>
+            <el-button v-if="hasReviewBtnPermission()" type="primary" :loading="approveLoading"
+              @click="approveTicket">通过</el-button>
+            <el-button v-if="hasReviewBtnPermission()" type="danger" :loading="rejectLoading"
+              @click="rejectTicket">不通过</el-button>
             <el-button @click="detailVisible = false">取消</el-button>
           </template>
           <template v-else-if="currentDetail.status === 0">
-            <el-button v-if="hasProcessingBtnPermission()" type="primary" :loading="dispatchLoading" @click="approveAndDispatch">通过并派发</el-button>
-            <el-button v-if="hasProcessingBtnPermission()" type="danger" :loading="rejectLoading" @click="rejectTicket">不通过</el-button>
+            <el-button v-if="hasProcessingBtnPermission()" type="primary" :loading="dispatchLoading"
+              @click="approveAndDispatch">通过并派发</el-button>
+            <el-button v-if="hasProcessingBtnPermission()" type="danger" :loading="rejectLoading"
+              @click="rejectTicket">不通过</el-button>
             <el-button @click="detailVisible = false">取消</el-button>
           </template>
           <template v-if="currentDetail.status === 3">
             <!-- 处理中 -->
-            <el-button v-if="hasProcessedAndOverBtnPermission()" type="primary" :loading="completeLoading" @click="completeTicket">完成工单</el-button>
+            <el-button v-if="hasProcessedAndOverBtnPermission()" type="primary" :loading="completeLoading"
+              @click="completeTicket">完成工单</el-button>
             <el-button @click="detailVisible = false">取消</el-button>
           </template>
           <template v-else-if="currentDetail.status === 4">
             <!-- 已完成 -->
-            <el-button v-if="hasProcessedAndOverBtnPermission()" type="primary" :loading="finalizeLoading" @click="finalizeTicket">完结工单</el-button>
+            <el-button v-if="hasProcessedAndOverBtnPermission()" type="primary" :loading="finalizeLoading"
+              @click="finalizeTicket">完结工单</el-button>
             <el-button @click="detailVisible = false">取消</el-button>
           </template>
           <template v-else-if="currentDetail.status === 5">
@@ -413,15 +415,9 @@
           </div>
 
           <div class="review-image-container">
-            <el-image
-              v-if="currentReviewImage"
-              :src="getThumbUrl(currentReviewImage)"
-              fit="cover"
-              :preview-src-list="getImageList()"
-              :initial-index="currentImageIndex - 1"
-              class="preview-image"
-              style="cursor: pointer;"
-            >
+            <el-image v-if="currentReviewImage" :src="getThumbUrl(currentReviewImage)" fit="cover"
+              :preview-src-list="getImageList()" :initial-index="currentImageIndex - 1" class="preview-image"
+              style="cursor: pointer;">
               <template #error>
                 <div class="image-error">
                   <i class="el-icon-picture-outline"></i>
@@ -516,7 +512,7 @@
         selection: true, // 添加多选功能
         index: true,     // 保留序号功能
         indexLabel: '序号',
-        indexWidth: 60,  
+        indexWidth: 60,
         menuWidth: 150,
         searchMenuSpan: 6,
         viewBtn: false,
@@ -621,6 +617,7 @@
       reviewDialogVisible: false, // 新增:审核对话框可见性
       currentReviewImage: '', // 新增:当前审核图片
       currentImageIndex: 1, // 新增:当前图片索引
+      totalTime: '',
       isShowInfo: false,
     };
   },
@@ -1180,27 +1177,27 @@
     },
 
     async fetchTabCounts() {
-  try {
-    // 判断是否有部门筛选
-    let params = {};
-    if (this.filters.department) {
-      params.deptId = this.filters.department;
-    }
-    const response = await getstatusCount(params);
-    const { statusCount, totalCount, userCount } = response.data.data;
-    this.tabs.forEach(tab => {
-      if (tab.name === 'all') {
-        tab.count = totalCount || 0; // 总工单数
-      } else if (tab.name === 'myTickets') {
-        tab.count = userCount || 0; // 我发起的工单数
-      } else {
-        tab.count = statusCount[String(tab.value)] || 0; // 根据状态值映射
+      try {
+        // 判断是否有部门筛选
+        let params = {};
+        if (this.filters.department) {
+          params.deptId = this.filters.department;
+        }
+        const response = await getstatusCount(params);
+        const { statusCount, totalCount, userCount } = response.data.data;
+        this.tabs.forEach(tab => {
+          if (tab.name === 'all') {
+            tab.count = totalCount || 0; // 总工单数
+          } else if (tab.name === 'myTickets') {
+            tab.count = userCount || 0; // 我发起的工单数
+          } else {
+            tab.count = statusCount[String(tab.value)] || 0; // 根据状态值映射
+          }
+        });
+      } catch (error) {
+        this.$message.error('获取 tab 数据失败');
       }
-    });
-  } catch (error) {
-    this.$message.error('获取 tab 数据失败');
-  }
-},
+    },
 
     handleTabChange(tab) {
       this.activeTab = tab.props?.name || tab.name;
@@ -1300,6 +1297,8 @@
         const steps = Array.isArray(stepResponse.data.data)
           ? stepResponse.data.data
           : stepResponse.data.data?.steps || [];
+        const finishedStep = steps.find(s => String(s.status) === '5');
+        this.totalTime = finishedStep && finishedStep.total_time ? finishedStep.total_time : '';
         if (this.activeTab !== 'myTickets') {
           this.stepInfos = steps.map(step => ({
             status: String(step.status),

--
Gitblit v1.9.3