<template>

<div class = "dialog">
    <div class="dialog-title">    
        <el-progress
            style="width: 90%"
            :percentage="percentage"
            :color="customColors"
          />

            <el-button
              type="primary"
              v-if="!isPause && activeIndex < activeTotalNum"
              :disabled="activeIndex===0"
              :icon="VideoPause"
              @click="handlePauseTest"
              >暂停检测</el-button
            >
            <el-button
              type="warning"
              v-if="isPause && activeIndex < activeTotalNum"
              :icon="Refresh"
              @click="handlePauseTest"
              >继续检测</el-button
            >

            <el-button
              type="warning"
              v-if="activeIndex >= activeTotalNum"
              :icon="Refresh"
              @click="handleReCheck"
              >重新检测</el-button
            >
            <!-- <el-button type="danger" :icon="Close" @click="handleFinishTest"
              >停止检测</el-button
            > -->

    </div>
    <!-- background: '#f5f7fa', color: '#606266' -->
      <!-- v-on:cell-click="handleClick" -->
       <!-- <el-table :key="tableKey" :data="tableData" :row-class-name="tableRowClassName" row-key="id" height="545px" :header-cell-style="{ background: '#003078', color: '#eee', textAlign: 'center' } " :cell-style="{ textAlign: 'center' }" style="width: 100%" border> -->
          <!-- <el-table :data="tableData" :row-class-name="tableRowClassName" row-key="id" height="545px" :header-cell-style="{ background: '#003078', color: '#eee', textAlign: 'center' } "  style="width: 100%" border> -->
    <div class="dialog-content ">
      <el-table :data="tableData" :cell-class-name="tableCell" row-key="id" height="450px" :header-cell-style="{ background: '#003078', color: '#eee', textAlign: 'center' } " style="width: 100%" border>
            <el-table-column fixed  prop="scriptItemName" label="检测项目" width="250px">
              <!-- <template #default="scope">
                <div :style="{ backgroundColor: '#003078' }">
                  {{ scope.row.name }}
                </div>
              </template> -->
            </el-table-column>

            <el-table-column label="被检通道1" :min-width="minwidth" align="center">
              <template #header>
                <span>被检通道1</span>
                 <el-tooltip content = "240001被检通道1" placement="top" style="align-items: bottom;">
                  <el-icon><InfoFilled  /></el-icon>
                </el-tooltip>
              </template>
              <template #default="scope">
              <!-- <el-tooltip content = "info" placement="top">
                <i class="el-icon-info"></i>
              </el-tooltip> -->
              <el-tooltip :content="scope.row.resultType1==='info' ? '暂无数据' : '点击查看详情'" placement="top">
                <el-button
                :disabled = "scope.row.resultType1=='info'"
                :type="scope.row.resultType1"
                size="small"
                @click="handleClick(scope.row)"
              >
                {{ scope.row.resultValue1 }}
              </el-button>
            </el-tooltip>
              
            </template>
            </el-table-column>
            <el-table-column label="被检通道2" :min-width="minwidth" align="center">
              <template #header>
                <span>被检通道2</span>
                 <el-tooltip content = "240001被检通道2" placement="top">
                  <el-icon><InfoFilled  /></el-icon>
                </el-tooltip>
              </template>
              <template #default="scope">
                <el-tooltip :content="scope.row.resultType2==='info' ? '暂无数据' : '点击查看详情'" placement="top">
                  <el-button
                  :disabled = "scope.row.resultType2=='info'"
                  :type="scope.row.resultType2"
                  size="small"
                  @click="handleClick(scope.row)"
                >
                  {{ scope.row.resultValue2 }}
                </el-button>
                </el-tooltip>

              </template>
            </el-table-column>
            <el-table-column label="被检通道3" :min-width="minwidth" align="center">
              <template #header>
                <span>被检通道3</span>
                 <el-tooltip content = "240001被检通道3" placement="top">
                  <el-icon><InfoFilled  /></el-icon>
                </el-tooltip>
              </template>
              <template #default="scope">
                <el-tooltip :content="scope.row.resultType3==='info' ? '暂无数据' : '点击查看详情'" placement="top">
                  <el-button
                  :disabled = "scope.row.resultType3=='info'"
                  :type="scope.row.resultType3"
                  size="small"
                  @click="handleClick(scope.row)"
                >
                  {{ scope.row.resultValue3 }}
                </el-button>
                </el-tooltip>

              </template>
            </el-table-column>
            <el-table-column label="被检通道4" :min-width="minwidth" align="center">
              <template #header>
                <span>被检通道4</span>
                 <el-tooltip content = "240001被检通道4" placement="top">
                  <el-icon><InfoFilled  /></el-icon>
                </el-tooltip>
              </template>
                            <template #default="scope">
                              <el-tooltip :content="scope.row.resultType4==='info' ? '暂无数据' : '点击查看详情'" placement="top">
                                <el-button
                  :disabled = "scope.row.resultType4=='info'"
                  :type="scope.row.resultType4"
                  size="small"
                  @click="handleClick(scope.row)"
                >
                  {{ scope.row.resultValue4 }}
                </el-button>
                              </el-tooltip>

              </template>
            </el-table-column>
            <el-table-column p label="被检通道5" :min-width="minwidth" align="center">
              <template #header>
                <span>被检通道5</span>
                 <el-tooltip content = "240002被检通道1" placement="top">
                  <el-icon><InfoFilled  /></el-icon>
                </el-tooltip>
              </template>
                            <template #default="scope">
                              <el-tooltip :content="scope.row.resultType5==='info' ? '暂无数据' : '点击查看详情'" placement="top">
                                <el-button
                  :disabled = "scope.row.resultType5=='info'"
                  :type="scope.row.resultType5"
                  size="small"
                  @click="handleClick(scope.row)"
                >
                  {{ scope.row.resultValue5 }}
                </el-button>
                              </el-tooltip>

              </template>
            </el-table-column>
            <el-table-column label="被检通道6" :min-width="minwidth" align="center">
              <template #header>
                <span>被检通道6</span>
                 <el-tooltip content = "240002被检通道2" placement="top">
                  <el-icon><InfoFilled  /></el-icon>
                </el-tooltip>
              </template>
                            <template #default="scope">
                              <el-tooltip :content="scope.row.resultType6==='info' ? '暂无数据' : '点击查看详情'" placement="top">
                                <el-button
                  tip
                  :disabled = "scope.row.resultType6=='info'"
                  :type="scope.row.resultType6"
                  size="small"
                  @click="handleClick(scope.row)"
                >
                  {{ scope.row.resultValue6 }}
                </el-button>
                              </el-tooltip>

              </template>
            </el-table-column>
            <el-table-column label="被检通道7" :min-width="minwidth" align="center">
              <template #header>
                <span>被检通道7</span>
                 <el-tooltip content = "240002被检通道3" placement="top">
                  <el-icon><InfoFilled  /></el-icon>
                </el-tooltip>
              </template>
                            <template #default="scope">
                              <el-tooltip :content="scope.row.resultType7==='info' ? '暂无数据' : '点击查看详情'" placement="top">
                                <el-button
                  :disabled = "scope.row.resultType7=='info'"
                  :type="scope.row.resultType7"
                  size="small"
                  @click="handleClick(scope.row)"
                >
                  {{ scope.row.resultValue7 }}
                </el-button>
                              </el-tooltip>

              </template>
            </el-table-column>
            <el-table-column label="被检通道8" :min-width="minwidth" align="center">
              <template #header>
                <span>被检通道8</span>
                 <el-tooltip content = "240002被检通道4" placement="top">
                  <el-icon><InfoFilled  /></el-icon>
                </el-tooltip>
              </template>
                            <template #default="scope">
                              <el-tooltip :content="scope.row.resultType8==='info' ? '暂无数据' : '点击查看详情'" placement="top">
                                <el-button
                  :disabled = "scope.row.resultType8=='info'"
                  :type="scope.row.resultType8"
                  size="small"
                  @click="handleClick(scope.row)"
                >
                  {{ scope.row.resultValue8 }}
                </el-button>
                              </el-tooltip>

              </template>
            </el-table-column>
            <!-- <el-table-column  v-for="(item, index) in monitorList" :key="index"  :prop="item.prop" :label="item.label">
          </el-table-column> -->
        </el-table>
    </div>
    <div style="height: 98px;">
        <el-collapse model-value="1" accordion>
            <el-collapse-item title="检测日志：" name="1">
                <div ref="scrollContainer"  class="dialog-log"> 
                  <p v-for="(item, index) in testLogList" :key="index" :style="{color:item.type==='error'?'#F56C6C':'var(--el-text-color-regular)'}">
                    {{ item.log }} <br />
                  </p>
                </div>
            </el-collapse-item>
        </el-collapse>
    </div>
</div>

<resultPopup
    :visible="resultDialogVisible"
    @update:visible="resultDialogVisible = $event"
></resultPopup>
<dataCheckSingleChannelSingleTestPopup
    :visible="dataCheckSingleChannelSingleTestDialogVisable"
    @update:visible="dataCheckSingleChannelSingleTestDialogVisable = $event"
></dataCheckSingleChannelSingleTestPopup>
</template>
<script lang="tsx" setup name="test">
import { VideoPause,Refresh,Close,InfoFilled } from '@element-plus/icons-vue'
import resultPopup from './resultPopup.vue'
import dataCheckSingleChannelSingleTestPopup from './dataCheckSingleChannelSingleTestPopup.vue'
import temptest from './temptest.vue'
const minwidth = ref(110)
const activeIndex = ref(0)
const activeTotalNum = ref(12)

const currentRow = ref<{ id: number; scriptItemName: string; name: string; address: string; hasChildren?: boolean; children?: User[] } | null>(null);
// const currentRow = ref(null); // 用于存储当前选中的行

const monitorList = ref([
  {
    deviceID: '1',
    deviceName: '被检设备1',
    monitorIdx: 1,
    label:'被检设备1通道1',
    prop: 'Result1',
  },
  {
    deviceID: '1',
    deviceName: '被检设备1',
    monitorIdx: 2,
    label:'被检设备1通道2',
    prop: 'Result2',
  },
  {
    deviceID: '2',
    deviceName: '被检设备2',
    monitorIdx: 1,
    label:'被检设备2通道1',
    prop: 'Result3',
  },
  {
    deviceID: '2',
    deviceName: '被检设备2',
    monitorIdx: 2,
    label:'被检设备2通道2',
    prop: 'Result4',
  }
])
const tableData1= [
  {
    date: '2016-05-03',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-02',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-01',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
]
const scrollContainer = ref<HTMLElement | null>(null); // 声明 scrollContainer

const scrollToBottom = () => {
      if (scrollContainer.value) {
        scrollContainer.value.scrollTop = scrollContainer.value.scrollHeight;
      }
    };

function getRandomInt(max: number): number {
  return Math.floor(Math.random() * max);
}
const updateLog = () => {
  const currentTime = ref(new Date().toLocaleString());

  switch(activeIndex.value)
    {
      case 1:
      testLogList.value.length = 0; // 清空数组
      testLogList.value.push({
        type: 'info',
        log: currentTime.value + '：频率准确度检测开始',
      })
        
      break;
      case 2:

      testLogList.value.push({
        type: 'info',
        log:currentTime.value + '：频率准确度检测完成',
      })
      testLogList.value.push({
        type: 'info',
        log:currentTime.value + '：电压准确度检测开始',
      })
      break;
      case 3:
      testLogList.value.push({
        type: 'error',
        log:currentTime.value + '：电压准确度检测不合格',
      })
      testLogList.value.push({
        type: 'info',
        log:currentTime.value + '：谐波电压准确度检测开始',
      })
      case 4:
      case 5:
      case 6:
      case 7:
      case 8:
      case 9:
      case 10:
      case 11:
      case 12:
            updateTableData(activeIndex.value.toString())
      break;

    }

    scrollToBottom();
}
const testLogList = ref([
  {
    type: 'info',
    log:'暂无数据，等待检测开始',
  },
])
const columnList = ref([]);
const tableKey = ref(0);
function tableCell ({row,columnIndex}){


  let items = columnList?.value.filter((item) => item === row.id)

  if(columnIndex === 0 && items.length > 0)
  {
      console.log(row.id,columnList?.value,items)
    return 'warning-row'
  }

  if(columnIndex === 0)
  {
    return 'header-row'
  }

}

const tableRowClassName = ({
  row,
  rowIndex,
}: {
  row: any
  rowIndex: number
}) => {
  if (row.rowIndex === activeIndex.value.toString()) {
    return 'warning-row'
  } 
  // else if (rowIndex === 3) {
  //   return 'success-row'
  // }
  return ''
}
const percentage = ref(0);
const customColors = [
  { color: "#5cb87a", percentage: 100 }, //绿
];
//暂停检测
const isPause = ref<boolean>(false);
const resultDialogVisible = ref(false)
const dataCheckSingleChannelSingleTestDialogVisable = ref(false);

function clear() {
}

function traverseTableData(data: any[],id: string): void {
  data.forEach(item => {
    // 处理当前节点的数据
    if(item.id === id)
    {
      for(let i = 1;i<=8;i++)
      {
        let field1 = "resultType"+i
        let field2 = "resultValue"+i

        if(getRandomInt(10)>8 && activeIndex.value>2)
        {
          item[field1] = "danger";
          item[field2] = "×";
          columnList.value.push(activeIndex.value.toString());
        }
        else
        {
          item[field1] = "success";
          item[field2] = "√";
        }
      }
      return;
    }

    // 如果当前节点有 children，并且 children 是一个数组，则递归遍历
    if (Array.isArray(item.children)) {
      traverseTableData(item.children,id);
    }
  });
}

const updateTableData = (id: string) => {
  traverseTableData(tableData.value,id);
};

const handleReCheck = () => {
    activeIndex.value = 0;
    percentage.value = 0;
    tableData.value.length = 0;
    testLogList.value.length = 0;
    columnList.value.length = 0;
    tableData.value = JSON.parse(JSON.stringify(operatorTableData.value));
    resumeTimer()
};
let timer: any = ref("");
const handlePauseTest = () => {

  
  if (!isPause.value) {
    pauseTimer()
  } else {
    resumeTimer()
  }
  isPause.value = !isPause.value;
};
//完成检测
const handleFinishTest = () => {
  resultDialogVisible.value = true
  ElMessage.success("完成检测");
};

const handleClick = (row:any) => {
  dataCheckSingleChannelSingleTestDialogVisable.value = true;
};

interface User {
  id: number
  scriptItemName: string
  name: string
  address: string
  hasChildren?: boolean
  children?: User[]
}
//resultType2: 'success',
 //   resultValue2:'√',
 //   resultType3: 'danger',
 //   resultValue3:'×',


 const operatorTableData = ref([
  {
    id: '1',
    scriptItemName: '频率',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
    children: [
      {
        id: '1-1',
        scriptItemName: '额定条件下的测量',
        resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
        children: [
          {
            id: '1-1-1',
            scriptItemName: '频率：42.5Hz',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
          {
            id: '1-1-2',
            scriptItemName: '频率：50Hz',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
          {
            id: '1-1-3',
            scriptItemName: '频率：50.5Hz',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
          {
            id: '1-1-4',
            scriptItemName: '频率：57.5Hz',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
        ],
      },
      {
        id: '1-2',
        scriptItemName: '电压对频率测量的影响',
        resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
        children: [
          {
            id: '1-2-1',
            scriptItemName: '频率：50.5Hz 电压：10%Un',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
        ],
      },
      {
        id: '1-3',
        scriptItemName: '谐波对频率测量的影响',
        resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
        children: [
          {
            id: '1-3-1',
            scriptItemName: '频率：50.5Hz 谐波电压：h3 10%Un;h7 10%Un;h11 10%Un;h15 4%Un; h19 5%Un; h23 5%Un',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
        ],
      },
    ],
  },
  {
    id: '2',
    scriptItemName: '电压',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
    children: [
      {
        id: '2-1',
        scriptItemName: '额定条件下的测量',
        resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
        children: [
          {
            id: '2-1-1',
            scriptItemName: '频率：50Hz 电压：10%Un',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
          {
            id: '2-1-2',
            scriptItemName: '频率：50Hz 电压：45%Un',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
          {
            id: '2-1-3',
            scriptItemName: '频率：50Hz 电压：80%Un',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
          {
            id: '2-1-4',
            scriptItemName: '频率：50Hz 电压：115%Un',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
          {
            id: '2-1-5',
            scriptItemName: '频率：50Hz 电压：150%Un',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
        ],
      },
      {
        id: '2-2',
        scriptItemName: '频率对电压测量的影响',
        resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
        children: [
          {
            id: '2-2-1',
            scriptItemName: '频率：42.5Hz 电压：80%Un',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
        ],
      },
      {
        id: '2-3',
        scriptItemName: '谐波对电压测量的影响',
        resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
        children: [
          {
            id: '2-3-1',
            scriptItemName: '频率：50Hz 电压：80%Un 谐波电压：h3 10%Un;h7 10%Un;h11 10%Un;h15 4%Un; h19 5%Un; h23 5%Un',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
        ],
      },
    ],
  },
  {
    id: '3',
    scriptItemName: '谐波电压',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
  },
  {
    id: '4',
    scriptItemName: '谐波电流',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
  },
  {
    id: '5',
    scriptItemName: '谐波有功功率',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
  },
  {
    id: '6',
    scriptItemName: '间谐波电压',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
  },
  {
    id: '7',
    scriptItemName: '间谐波电流',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
  },
  {
    id: '8',
    scriptItemName: '暂态',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
  },
  {
    id: '9',
    scriptItemName: '电流',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
  },
  {
    id: '10',
    scriptItemName: '电压不平衡度',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
  },
  {
    id: '11',
    scriptItemName: '电流不平衡度',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
  },
  {
    id: '12',
    scriptItemName: '短时闪变',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
  },
])
const tableData = ref([
  {
    id: '1',
    scriptItemName: '频率',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
    children: [
      {
        id: '1-1',
        scriptItemName: '额定条件下的测量',
        resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
        children: [
          {
            id: '1-1-1',
            scriptItemName: '频率：42.5Hz',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
          {
            id: '1-1-2',
            scriptItemName: '频率：50Hz',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
          {
            id: '1-1-3',
            scriptItemName: '频率：50.5Hz',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
          {
            id: '1-1-4',
            scriptItemName: '频率：57.5Hz',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
        ],
      },
      {
        id: '1-2',
        scriptItemName: '电压对频率测量的影响',
        resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
        children: [
          {
            id: '1-2-1',
            scriptItemName: '频率：50.5Hz 电压：10%Un',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
        ],
      },
      {
        id: '1-3',
        scriptItemName: '谐波对频率测量的影响',
        resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
        children: [
          {
            id: '1-3-1',
            scriptItemName: '频率：50.5Hz 谐波电压：h3 10%Un;h7 10%Un;h11 10%Un;h15 4%Un; h19 5%Un; h23 5%Un',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
        ],
      },
    ],
  },
  {
    id: '2',
    scriptItemName: '电压',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
    children: [
      {
        id: '2-1',
        scriptItemName: '额定条件下的测量',
        resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
        children: [
          {
            id: '2-1-1',
            scriptItemName: '频率：50Hz 电压：10%Un',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
          {
            id: '2-1-2',
            scriptItemName: '频率：50Hz 电压：45%Un',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
          {
            id: '2-1-3',
            scriptItemName: '频率：50Hz 电压：80%Un',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
          {
            id: '2-1-4',
            scriptItemName: '频率：50Hz 电压：115%Un',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
          {
            id: '2-1-5',
            scriptItemName: '频率：50Hz 电压：150%Un',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
        ],
      },
      {
        id: '2-2',
        scriptItemName: '频率对电压测量的影响',
        resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
        children: [
          {
            id: '2-2-1',
            scriptItemName: '频率：42.5Hz 电压：80%Un',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
        ],
      },
      {
        id: '2-3',
        scriptItemName: '谐波对电压测量的影响',
        resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
        children: [
          {
            id: '2-3-1',
            scriptItemName: '频率：50Hz 电压：80%Un 谐波电压：h3 10%Un;h7 10%Un;h11 10%Un;h15 4%Un; h19 5%Un; h23 5%Un',
            resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
          },
        ],
      },
    ],
  },
  {
    id: '3',
    scriptItemName: '谐波电压',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
  },
  {
    id: '4',
    scriptItemName: '谐波电流',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
  },
  {
    id: '5',
    scriptItemName: '谐波有功功率',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
  },
  {
    id: '6',
    scriptItemName: '间谐波电压',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
  },
  {
    id: '7',
    scriptItemName: '间谐波电流',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
  },
  {
    id: '8',
    scriptItemName: '暂态',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
  },
  {
    id: '9',
    scriptItemName: '电流',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
  },
  {
    id: '10',
    scriptItemName: '电压不平衡度',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
  },
  {
    id: '11',
    scriptItemName: '电流不平衡度',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
  },
  {
    id: '12',
    scriptItemName: '短时闪变',
    resultType1: 'info',
    resultValue1:'-',
    resultType2: 'info',
    resultValue2:'-',
    resultType3: 'info',
    resultValue3:'-',
    resultType4: 'info',
    resultValue4:'-',
    resultType5: 'info',
    resultValue5:'-',
    resultType6: 'info',
    resultValue6:'-',
    resultType7: 'info',
    resultValue7:'-',
    resultType8: 'info',
    resultValue8:'-',
  },
])

const currentStepStatus = ref<'error' | 'finish' | 'wait' | 'success' | 'process'>('finish');

  const props = defineProps({
    testStatus: {
    type: String,
    default: 'wait'
  }
})
const testStatus = toRef(props, 'testStatus');
const ts = ref('');

const startTimer = () => {
  //if (timer.value !== null) return; // 如果定时器已经启动，则不再重复启动
  timer.value = setInterval(() => {

    if(activeIndex.value <= activeTotalNum.value)
        {

          activeIndex.value++;
          updateLog()

          switch(activeIndex.value)
          {
            case 1:
              updateTableData("1-1-1")
              updateTableData("1-1-2")
              updateTableData("1-1-3")
              updateTableData("1-1-4")
              updateTableData("1-1")
              updateTableData("1-2-1")
              updateTableData("1-2")
              updateTableData("1-3-1")
              updateTableData("1-3")
              updateTableData("1")
            break;
            case 2:
            updateTableData("2-1-1")
              updateTableData("2-1-2")
              updateTableData("2-1-3")
              updateTableData("2-1-4")
              updateTableData("2-1-5")
              updateTableData("2-1")
              updateTableData("2-2-1")
              updateTableData("2-2")
              updateTableData("2-3-1")
              updateTableData("2-3")
              updateTableData("2")
            break;
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
                  updateTableData(activeIndex.value.toString())
            break;

          }

          if (percentage.value < 100) {
          percentage.value = Math.trunc(activeIndex.value/activeTotalNum.value * 100);

        } else {
          percentage.value = 100;
          clearInterval(timer.value)
          timer.value = null;

          ts.value = 'success'
          ElMessageBox.alert('检测全部结束,你可以停留在此页面查看检测结果，或返回首页进行复检、报告生成和归档等操作', '检测完成', {
          // if you want to disable its autofocus
          // autofocus: false,
          confirmButtonText: '确定',
        })
        clear();
        }

        }
        else 
        {
            clearInterval(timer.value)
            timer.value = null;
            ts.value = 'success'
        }

  }, 2000);
};

const pauseTimer = () => {
  if (timer.value !== null) {
    clearInterval(timer.value);
    timer.value = null;
  }
};

const resumeTimer = () => {
  if (timer.value === null) {
    console.log('startTimer')
    startTimer();
  }
};
//监听goods_sn的变化
watch(testStatus, function (newValue, oldValue) {
  ts.value = props.testStatus;
  if(ts.value==='start')
  {
    ts.value = 'process'

    startTimer()
  }
})

const emit = defineEmits(['update:testStatus']);
//监听sn
watch(ts, function (newValue, oldValue) {
  //修改父组件
  emit('update:testStatus',ts.value)
})

</script>
<style scoped lang="scss">
:deep(.el-table .header-row) {
  // background-color:var(--el-color-warning-light-9);
  background-color:#f5f7fa;
  // color:red;
  // font-size:30px;
  // --el-table-tr-bg-color: var(--el-color-warning-light-9);
}
:deep(.el-table .warning-row) {
  // background-color:var(--el-color-warning-light-9);
  background-color:#bed96557;
  // color:red;
  // font-size:30px;
  // --el-table-tr-bg-color: var(--el-color-warning-light-9);
}
.el-table .success-row {
  --el-table-tr-bg-color: var(--el-color-success-light-9);
}

.dialog{
    display: flex;
    flex-direction: column;
}

.dialog-title{
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-right:10px;
    margin-bottom:10px;
}
.dialog-content{
  max-height: 450px;
  overflow-y: auto;
}

.dialog-log{
  max-height: 50px;
  overflow-y: auto;
  // flex-grow: 1;
  // display: flex;
  // flex-direction: column-reverse;
}


</style>
<style lang="scss" scoped>
:deep(.el-button--small) {
    height: 20px !important;
    width: 20px !important;
}
:deep(.el-table--default  td ){
  padding: 5px 0 !important;
}
</style>
