huang
2025-11-20 366ba040d2447bacd3455299425e3166f1f992bb
mes-web/src/views/plcTest/components/MultiDeviceTest/ExecutionMonitor.vue
@@ -30,8 +30,16 @@
          {{ row.currentStep || 0 }} / {{ row.totalSteps || 0 }}
        </template>
      </el-table-column>
      <el-table-column label="开始时间" min-width="160" prop="startTime" />
      <el-table-column label="结束时间" min-width="160" prop="endTime" />
      <el-table-column label="开始时间" min-width="160">
        <template #default="{ row }">
          {{ formatDateTime(row.startTime) }}
        </template>
      </el-table-column>
      <el-table-column label="结束时间" min-width="160">
        <template #default="{ row }">
          {{ formatDateTime(row.endTime) }}
        </template>
      </el-table-column>
    </el-table>
    <el-drawer v-model="drawerVisible" size="40%" title="任务步骤详情">
@@ -39,7 +47,7 @@
        <el-timeline-item
          v-for="step in steps"
          :key="step.id"
          :timestamp="step.startTime || '-'"
          :timestamp="formatDateTime(step.startTime) || '-'"
          :type="step.status === 'COMPLETED' ? 'success' : step.status === 'FAILED' ? 'danger' : 'primary'"
        >
          <div class="step-title">{{ step.stepName }}</div>
@@ -123,6 +131,28 @@
  return `${(ms / 1000).toFixed(1)} s`
}
// 格式化日期时间
const formatDateTime = (dateTime) => {
  if (!dateTime) return '-'
  try {
    const date = new Date(dateTime)
    // 检查日期是否有效
    if (isNaN(date.getTime())) {
      return dateTime // 如果无法解析,返回原始值
    }
    const year = date.getFullYear()
    const month = String(date.getMonth() + 1).padStart(2, '0')
    const day = String(date.getDate()).padStart(2, '0')
    const hours = String(date.getHours()).padStart(2, '0')
    const minutes = String(date.getMinutes()).padStart(2, '0')
    const seconds = String(date.getSeconds()).padStart(2, '0')
    return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
  } catch (error) {
    console.warn('格式化时间失败:', dateTime, error)
    return dateTime
  }
}
watch(
  () => props.groupId,
  () => {