<template>
    <el-dialog  title="数据查询" :model-value='visible' @close="handleCancel" v-bind="dialogBig">
        <div class="change-errsys-dialog">
            <div class="change-errsys-title">
                <el-form-item label="设备名称:"  >
                    <el-input v-model='deviceName' :disabled="true"/>
                </el-form-item>
                <el-form-item label="检测脚本:"  >
                <el-input v-model='testScriptName' :disabled="true"/>
                </el-form-item>    
                <el-form-item label="数据处理原则"  >
                    <el-input v-model='dataRule' :disabled="true"/>
                </el-form-item>

                <el-form-item label="误差体系">
                <el-select v-model="error_Sys_Id" autocomplete="off">
                    <el-option
                            v-for="plan in testErrSystDataList"
                            :key="plan.id"
                            :label="plan.label"
                            :value="plan.id">
                    </el-option>
                </el-select>
                </el-form-item>

                <el-button type="primary" :icon="VideoPlay">数据计算</el-button>
                <el-button type="primary" :icon="Postcard" @click="openReportDlg">报告生成</el-button>
            </div>
            <div class="change-errsys-content">
                <div class="tabs-title"><el-button type="primary" loading >合格92项/共103项</el-button> </div>
                <el-table :data="testData" :header-cell-style="{ textAlign: 'center' } " :cell-style="{ textAlign: 'center' }" style="width: 100%" border>
                <el-table-column fixed  prop="deviceName" label="检测项目" />
                <el-table-column prop="updataTime" label="被检通道1" />
                <el-table-column prop="ErrorValue" label="被检通道2" />
                <el-table-column prop="Result" label="被检通道3" />
                </el-table>
            </div>
        </div>
        <ReportPopup :visible="reportDialogVisible" @update:visible="reportDialogVisible = $event"></ReportPopup>
    </el-dialog>

</template>
<script setup lang='ts'>

import IPAddress from '@/components/IpAddress/index.vue'
import { dialogBig } from '@/utils/elementBind'
import { type Device } from '@/api/device/interface/device'
import { ElMessage, type FormItemRule } from 'element-plus'
import { addPqDev, updatePqDev } from '@/api/device/device'
import { computed, reactive, type Ref, ref } from 'vue'
import { useDictStore } from '@/stores/modules/dict'
import { CirclePlus, Delete, EditPen,Postcard, VideoPlay} from '@element-plus/icons-vue'
// 使用 dayjs 库格式化
import dayjs from 'dayjs'
import { getPqMonList } from '@/api/device/monitor'
import { type ColumnProps } from '@/components/ProTable/interface'
import { type Monitor } from '@/api/device/interface/monitor'
import { data } from "@/api/plan/autoTest.json";
import DataCheckResultTable from './dataCheckResultTable.vue'
import DataCheckRawDataTable from './dataCheckRawDataTable.vue'
import {dictPattern,dictTestState,dictReportState,dictResult,testPlanDataList,sourceDataList,deviceDataList,testSoureDataList,testScriptDataList,testErrSystDataList,planData,testFatherPlanList} from '@/api/plan/planData'
import ReportPopup from './reportPopup.vue'

  const reportDialogVisible = ref(false)
  const deviceName = ref('被检设备1');
  const error_Sys_Id = ref('2');
  const testScriptName = ref('Q/GDW 10650.4-2021 模拟式');
  const errorSysName = ref('Q/GDW 10650.2-2021');
  const dataRule = ref('所有值');
  const scriptSwitch = ref(true);
  const currentScriptDsc = ref('频率准确度检测：频率：42.5Hz Ua=46.192V 0° Ub=46.192V -120° Uc=46.192V 120° Ia=1A 0° Ib=1A -120° Ic=1A 120°');
  const defaultProps = {
  children: "children",
  label: "name",
  pid: "pid",
};

const testData = ref([
      {
        deviceName: '额定条件下频率检测42.5Hz',
        updataTime: '√', 
        ErrorValue:'×',
        Result: '/', 
      },
      {
        deviceName: '额定条件下频率检测50Hz',
        updataTime: '/', 
        ErrorValue:'√',
        Result: '×', 
      },
      {
        deviceName: '额定条件下频率检测50.05Hz',
        updataTime: '—', 
        ErrorValue:'—',
        Result: '—', 
      },
      {
        deviceName: '额定条件下频率检测57.5Hz',
        updataTime: '—', 
        ErrorValue:'—',
        Result: '—', 
      },
    ])

const handleNodeClick = (data) => {
  console.log(data);
};
const MonIsShow = ref(false)
const DevIsShow = ref(false)
const IsPasswordShow = ref(false)
const dictStore = useDictStore()
// 定义弹出组件元信息
const dialogFormRef = ref()
const disabledDate = (time: Date) => {
  return time.getTime() > Date.now()
}

const props = defineProps<{
    visible: boolean;
  }>();

  const emit = defineEmits<{
    (e: 'update:visible', value: boolean): void;
    (e: 'submit', data: any): void;
  }>();

  const handleCancel = () => {
    emit('update:visible', false); // 关闭对话框
  };

const openReportDlg = () => {
  reportDialogVisible.value = true
}

</script>
<style scoped>

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

.change-errsys-title{
    display: flex;
    flex-direction: row;
    margin-top: 10px;
}

.change-errsys-content{
    display: flex;
    flex-direction: column;
}

.tabs-title{
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

</style>