<template>

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

            <el-button
              type="primary"
              v-if="!isPause"
              :icon="VideoPause"
              @click="handlePauseTest"
              >暂停检测</el-button
            >
            <el-button
              type="warning"
              v-if="isPause"
              :icon="Refresh"
              @click="handlePauseTest"
              >继续检测</el-button
            >
            <el-button type="danger" :icon="Close" @click="handleFinishTest"
              >停止检测</el-button
            >

    </div>
    <!-- background: '#f5f7fa', color: '#606266' -->
      <!-- v-on:cell-click="handleClick" -->
    <div class="dialog-content">

        <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> -->
            <el-table-column fixed  prop="scriptItemName" label="检测项目" class="table-first-column"  />

            <el-table-column label="被检通道1" >
              <template #default="scope">

              <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">
              <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">
              <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">
                            <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">
                            <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">
                            <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">
                            <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">
                            <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 class="dialog-log">
        <el-collapse model-value="1" accordion>
            <el-collapse-item title="检测日志：" name="1">
                <div>
                    暂无数据，等待检测开始
                </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 } from '@element-plus/icons-vue'
import resultPopup from './resultPopup.vue'
import dataCheckSingleChannelSingleTestPopup from './dataCheckSingleChannelSingleTestPopup.vue'
import { log } from 'console';
import temptest from './temptest.vue'
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 tableKey = ref(0);
const currentIdx = ref(0);

const tableRowClassName = ({
  row,
  rowIndex,
}: {
  row: any
  rowIndex: number
}) => {
  //  console.log(currentIdx.value,rowIndex,row)

  if (row.id === currentIdx.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() {
}
const updateTableData = (id: string, field: string, value: any) => {
  const item = tableData.value.find(item => item.id === id);

  if (item) {
    item[field] = value;
  }
};

let timer: any = ref("");
const handlePauseTest = () => {

  timer.value = setInterval(() => {
    currentIdx.value++;

    updateTableData(currentIdx.value.toString(),"resultType1","success")
    updateTableData(currentIdx.value.toString(),"resultValue1","√")
    tableKey.value ++;
    if (percentage.value < 100) {
    percentage.value = Math.trunc(currentIdx.value/12 * 100);

  } else {

    clearInterval(timer.value)
    clear();
    ElMessageBox.confirm(
    '检测全部结束,你可以停留在此页面查看检测结果，或返回首页进行复检、报告生成和归档等操作',
    '检测完成',
    {
      confirmButtonText: '确定',
      type: 'success',
    })
  }
  }, 5000);
  

  return;
  if (!isPause.value) {

  } else {

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

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

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



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 selectRow = (id: number) => {

// console.log(id);

// const row = tableData.find(item => item.id === id);

// console.log(row);
// if (row) {
//   currentRow.value = row ;
// }
// };
// selectRow(2)

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('');
//监听goods_sn的变化
watch(testStatus, function (newValue, oldValue) {
  ts.value = props.testStatus;
  if(ts.value==='start')
  {
    ts.value = 'process'

    let timer = setInterval(() => {
        if(activeIndex.value < activeTotalNum.value - 2)
            activeIndex.value++
        else if(activeIndex.value === activeTotalNum.value -2)
        {
            activeIndex.value++
            activeIndex.value++
        }
        else 
        {
            clearInterval(timer)
            ts.value = 'success'
        }
        
  }, 1000);
  }
})

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

</script>
<style scoped>
.el-table .warning-row {
  --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);
}
/* .table-first-column{
  min-width: 250px !important;
  text-align: left !important;
} */
.dialog{
    display: flex;
    flex-direction: column;
}

.dialog-title{
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-right:10px;
    margin-bottom:10px;
}

</style>
