Newer
Older
xc-business-system / src / views / equipement / standard / checkData / components / fifth / checkDataCom.vue
<!-- 核查数据管理详情--核查项---第5套:二等铂电阻温度计标准装置  -->
<script lang="ts" setup name="checkDataDetail">
import { ref, watch } from 'vue'
import { ElLoading, ElMessage, ElMessageBox } from 'element-plus'
import saveCheckRecord from '../../dialog/saveCheckRecord.vue'
import { clearDateValue, handleDetailTableTableHead, handleSaveDateParams, solveHistoryIndicationTableData } from '../useStabilityCaculate'
import type { IList } from './fifth-interface'
import type { TableColumn } from '@/components/NormalTable/table_interface'
import useUserStore from '@/store/modules/user'
import type { dictType } from '@/global'
import { getDictByCode } from '@/api/system/dict'
import multiTable from '@/components/MultiHeaderTable/index.vue'
import { getCheckItemDetail, getJobInstructionList } from '@/api/equipment/standard/book'
import { addCheckData, calculateHandle, getHistoryIndication, getInfo, updateCheckData } from '@/api/equipment/standard/checkData'
import { useCheckList } from '@/commonMethods/useCheckList'
const props = defineProps({
  selectStandardId: { // 选择的标准装置id
    type: String,
  },
  pageType: { // 页面类型
    type: String,
  },
  checkDate: { // 核查日期
    type: String,
  },
})
const $route = useRoute() // 路由参数
const infoId = ref('')
const form = ref({
  isCheckTemperature: 1, // 是否进行温度核查
  isCheckRTP: 1, // 是否进行RTP核查
  temperatureConclusion: '', // 温度值结论
  RTPConclusion: '', // RTP结论
  resistanceConclusion: '', // 绝缘电阻表校准结论
  thermodetectorConclusion: '', // 测温仪电阻核查
  remark: '/', // 备注
})

const belongStandardEquipment = ref('5')
const itemCategoryId = ref('') // 核查项分类id
const itemCategoryName = ref('') // 核查项分类名称

const equipmentId = ref('') // 设备id
const dateArrStability = ref<string[]>([]) // 稳定性日期数组
const currentDate = ref('') // 要查询历史稳定性的日期
// ----------------------------------路由参数------------------------------------------------
if ($route.params && $route.params.type) {
  if ($route.params.id) {
    infoId.value = $route.params.id as string
  }
}

// ----------------------------------------核查数据----------------------------------------------
const radioMenus = ref([ // 标签内容
  { name: '温度值', value: 'temperature' },
  { name: 'RTP', value: 'RTP' },
  { name: '绝缘电阻表校准', value: 'insulation-resistance' },
  { name: '测温仪电阻核查', value: 'thermodetector' },
])
const current = ref('temperature') // 选择的tab 默认基本信息
const columns_repeatability_temperature = ref<TableColumn[]>([ // 重复性表头--温度值
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '温度点', value: 'checkPoint', align: 'center', required: true, type: 'text' },
  { text: '单位', value: 'unit', align: 'center', required: true, type: 'text' },
  {
    text: '1',
    value: 'indicatingValue',
    align: 'center',
    required: false,
    width: '180',
    children: [
      { text: '核查标准示值', value: 'testValueOne', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '测量标准示值', value: 'measureValueOne', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '差值', value: 'differentValueOne', align: 'center', required: false, type: 'text' },
    ],
  },
  {
    text: '2',
    value: 'indicatingValue',
    align: 'center',
    required: true,
    width: '180',
    children: [
      { text: '核查标准示值', value: 'testValueTwo', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '测量标准示值', value: 'measureValueTwo', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '差值', value: 'differentValueTwo', align: 'center', required: false, type: 'text' },
    ],
  },
  {
    text: '3',
    value: 'indicatingValue',
    align: 'center',
    required: true,
    width: '180',
    children: [
      { text: '核查标准示值', value: 'testValueThree', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '测量标准示值', value: 'measureValueThree', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '差值', value: 'differentValueThree', align: 'center', required: false, type: 'text' },
    ],
  },
  {
    text: '4',
    value: 'indicatingValue',
    align: 'center',
    required: true,
    width: '180',
    children: [
      { text: '核查标准示值', value: 'testValueFour', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '测量标准示值', value: 'measureValueFour', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '差值', value: 'differentValueFour', align: 'center', required: false, type: 'text' },
    ],
  },
  {
    text: '5',
    value: 'indicatingValue',
    align: 'center',
    required: true,
    width: '180',
    children: [
      { text: '核查标准示值', value: 'testValueFive', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '测量标准示值', value: 'measureValueFive', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '差值', value: 'differentValueFive', align: 'center', required: false, type: 'text' },
    ],
  },
  {
    text: '6',
    value: 'indicatingValue',
    align: 'center',
    required: true,
    width: '180',
    children: [
      { text: '核查标准示值', value: 'testValueSix', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '测量标准示值', value: 'measureValueSix', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '差值', value: 'differentValueSix', align: 'center', required: false, type: 'text' },
    ],
  },
  { text: '差值平均值', value: 'averageValue', align: 'center', required: false, type: 'text' },
  { text: 'Sn', value: 'standardDeviation', align: 'center', required: false, type: 'text' },
])
const columns_repeatability_RTP = ref<TableColumn[]>([ // 重复性表头--RTP
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '水三相点', value: 'checkPoint', align: 'center', required: true, type: 'text' },
  { text: '单位', value: 'unit', align: 'center', required: true, type: 'text' },
  {
    text: '被校示值(Ω)',
    value: 'indicatingValue',
    align: 'center',
    required: false,
    width: '180',
    children: [
      { text: '1', value: 'testValueOne', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '2', value: 'testValueTwo', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '3', value: 'testValueThree', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '4', value: 'testValueFour', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '5', value: 'testValueFive', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '6', value: 'testValueSix', align: 'center', required: true, width: '180', type: 'inputNumber' },
    ],
  },
  { text: '平均值', value: 'averageValue', align: 'center', required: false, type: 'text' },
])
const columns_insulation_resistance = ref<TableColumn[]>([ // 绝缘电阻表校准表头
  { text: '核查项目', value: 'params', align: 'center', required: true },
  { text: '单位', value: 'unit', align: 'center', required: true },
  { text: '确认点', value: 'checkPoint', align: 'center', required: true },
  { text: '测量值', value: 'measureValue', align: 'center', required: true },
  { text: '示值误差', value: 'indicatingError', align: 'center', required: false },
  { text: '最大允许误差', value: 'maximumError', align: 'center', required: true },
])
const columns_thermodetector = ref<TableColumn[]>([ // 测温仪电阻核查
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text', width: '120' },
  { text: '核查点', value: 'checkPoint', align: 'center', required: true, type: 'text' },
  { text: '单位', value: 'unit', align: 'center', required: true, type: 'text' },
  { text: '通道', value: 'thoroughfare', align: 'center', required: true, type: 'text' },
  {
    text: '测温仪示值',
    value: 'indicatingValue',
    align: 'center',
    required: false,
    width: '180',
    children: [
      { text: '第一次', value: 'testValueOne', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '第二次', value: 'testValueTwo', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '第三次', value: 'testValueThree', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '第四次', value: 'testValueFour', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '第五次', value: 'testValueFive', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '第六次', value: 'testValueSix', align: 'center', required: true, width: '180', type: 'inputNumber' },
    ],
  },
  { text: '平均值', value: 'averageValue', align: 'center', required: false, type: 'text' },
  { text: '最大偏差', value: 'maximumDeviation', align: 'center', required: false, type: 'text' },
  { text: '最大允许误差绝对值|MPE|', value: 'maximumError', align: 'center', required: false, type: 'text' },
])

// 稳定性表头--温度值
const columns_stability_temperature = ref<TableColumn[]>([
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '温度点', value: 'checkPoint', align: 'center', required: true, type: 'text' },
  { text: '单位', value: 'unit', align: 'center', required: true, type: 'text' },
  {
    text: '测量差值',
    value: 'measureDifference',
    align: 'center',
    required: false,
    width: '180',
    children: [
      { width: '180', text: '-', value: 'differentValueOne', align: 'center', required: false, type: 'text', customHeader: true },
      { width: '180', text: '-', value: 'differentValueTwo', align: 'center', required: false, type: 'text', customHeader: true },
      { width: '180', text: '-', value: 'differentValueThree', align: 'center', required: false, type: 'text', customHeader: true },
      { width: '180', text: '-', value: 'differentValueFour', align: 'center', required: false, type: 'text', customHeader: true },
      { width: '180', text: '-', value: 'differentValueFive', align: 'center', required: false, type: 'text', customHeader: true },
      { width: '180', text: '-', value: 'differentValueSix', align: 'center', required: false, type: 'text', customHeader: true },
    ],
  },
  { text: '平均值', value: 'averageValue', align: 'center', required: false, type: 'text' },
  { text: 'Sm', value: 'standardDeviation', align: 'center', required: false, type: 'text' },
  { text: '扩展不确定度U', value: 'urel', align: 'center', type: 'text', required: true },
  { text: '是否Sm≤U', value: 'lessThan', align: 'center', type: 'text', required: false },
])
// 稳定性表头--RTP
const columns_stability_RTP = ref<TableColumn[]>([
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '水三相点', value: 'checkPoint', align: 'center', required: true, type: 'text' },
  { text: '单位', value: 'unit', align: 'center', required: true, type: 'text' },
  {
    text: '被校示值平均值(Ω)',
    value: 'indicatingValue',
    align: 'center',
    required: false,
    width: '180',
    children: [
      { width: '180', text: '-', value: 'testValueOne', align: 'center', required: false, type: 'text', customHeader: true },
      { width: '180', text: '-', value: 'testValueTwo', align: 'center', required: false, type: 'text', customHeader: true },
      { width: '180', text: '-', value: 'testValueThree', align: 'center', required: false, type: 'text', customHeader: true },
      { width: '180', text: '-', value: 'testValueFour', align: 'center', required: false, type: 'text', customHeader: true },
      { width: '180', text: '-', value: 'testValueFive', align: 'center', required: false, type: 'text', customHeader: true },
      { width: '180', text: '-', value: 'testValueSix', align: 'center', required: false, type: 'text', customHeader: true },
    ],
  },
  { text: '测量极差值', value: 'measureValue', align: 'center', required: true, type: 'text' },
  { text: '允许值', value: 'allowValue', align: 'center', required: true, type: 'text' },
  { text: '结论', value: 'illustration', align: 'center', type: 'text' },
])

// 查询历史日期---稳定性表头--温度值
const columns_stability_temperature_checkDate = ref<TableColumn[]>([
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '温度点', value: 'checkPoint', align: 'center', required: true, type: 'text' },
  { text: '单位', value: 'unit', align: 'center', required: true, type: 'text' },
  {
    text: '测量差值',
    value: 'measureDifference',
    align: 'center',
    required: false,
    width: '180',
    children: [
      { width: '180', text: '-', value: 'differentValueOne', align: 'center', required: false, type: 'text', customHeader: true },
      { width: '180', text: '-', value: 'differentValueTwo', align: 'center', required: false, type: 'text', customHeader: true },
      { width: '180', text: '-', value: 'differentValueThree', align: 'center', required: false, type: 'text', customHeader: true },
      { width: '180', text: '-', value: 'differentValueFour', align: 'center', required: false, type: 'text', customHeader: true },
      { width: '180', text: '-', value: 'differentValueFive', align: 'center', required: false, type: 'text', customHeader: true },
      { width: '180', text: '-', value: 'differentValueSix', align: 'center', required: false, type: 'text', customHeader: true },
    ],
  },
  { text: '平均值', value: 'averageValue', align: 'center', required: false, type: 'text' },
  { text: 'Sm', value: 'standardDeviation', align: 'center', required: false, type: 'text' },
  { text: '扩展不确定度U', value: 'urel', align: 'center', type: 'text', required: true },
  { text: '是否Sm≤U', value: 'lessThan', align: 'center', type: 'text', required: false },
])
// 查询历史日期稳定性表头--RTP
const columns_stability_RTP_checkDate = ref<TableColumn[]>([
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '水三相点', value: 'checkPoint', align: 'center', required: true, type: 'text' },
  { text: '单位', value: 'unit', align: 'center', required: true, type: 'text' },
  {
    text: '被校示值平均值(Ω)',
    value: 'indicatingValue',
    align: 'center',
    required: false,
    width: '180',
    children: [
      { width: '180', text: '-', value: 'testValueOne', align: 'center', required: false, type: 'text', customHeader: true },
      { width: '180', text: '-', value: 'testValueTwo', align: 'center', required: false, type: 'text', customHeader: true },
      { width: '180', text: '-', value: 'testValueThree', align: 'center', required: false, type: 'text', customHeader: true },
      { width: '180', text: '-', value: 'testValueFour', align: 'center', required: false, type: 'text', customHeader: true },
      { width: '180', text: '-', value: 'testValueFive', align: 'center', required: false, type: 'text', customHeader: true },
      { width: '180', text: '-', value: 'testValueSix', align: 'center', required: false, type: 'text', customHeader: true },
    ],
  },
  { text: '测量极差值', value: 'measureValue', align: 'center', required: true, type: 'text' },
  { text: '允许值', value: 'allowValue', align: 'center', required: true, type: 'text' },
  { text: '结论', value: 'illustration', align: 'center', type: 'text' },
])
const repeatabilityTableLoading = ref(false) // 重复性表格loading
const stabilityTableLoading = ref(false) // 稳定性表格loading
const temperatureListRepeatability = ref<any[]>([]) // 温度值重复性
const temperatureListStability = ref<any[]>([]) // 温度值稳定性
const RTPListRepeatability = ref<any[]>([]) // RTP重复性
const RTPListStability = ref<any[]>([]) // RTP稳定性
const listinsulationResistance = ref<any[]>([]) // 绝缘电阻表校准
const listThermodetector = ref<any[]>([]) // 测温仪电阻核查

const temperatureListRepeatabilityCheckDate = ref<any[]>([]) // 温度值重复性--查询历史日期
const temperatureListStabilityCheckDate = ref<any[]>([]) // 温度值稳定性--查询历史日期
const RTPListRepeatabilityCheckDate = ref<any[]>([]) // RTP重复性--查询历史日期
const RTPListStabilityCheckDate = ref<any[]>([]) // RTP稳定性--查询历史日期

// 获取配置详情
function fetchCheckItemDetail(equipmentIdParam: string, belongStandardEquipmentParam: string, itemCategoryIdParam: string, itemCategoryNameParam: string) {
  belongStandardEquipment.value = belongStandardEquipmentParam // 检校标准装置
  itemCategoryId.value = itemCategoryIdParam // 核查分类id
  itemCategoryName.value = itemCategoryNameParam // 核查分类名称
  equipmentId.value = equipmentIdParam // 设备id
  const loading = ElLoading.service({
    lock: true,
    background: 'rgba(255, 255, 255, 0.8)',
  })
  const params = {
    equipmentId: equipmentIdParam, // 设备id
    belongStandardEquipment: belongStandardEquipment.value, // 检校标准装置code
    itemCategoryId: itemCategoryId.value, // 核查项分类id
    itemCategoryName: itemCategoryName.value, // 核查项分类名称
  }
  getCheckItemDetail(params).then((res) => {
    loading.close()
    handleData(res.data.checkItemDataResistanceThermometerList)
    fetchHistoryIndication() // 获取稳定性
  })
}

// 初始化数据(查询配置检定项)
function handleData(list: any, type = 'edit') {
  // 温度值
  temperatureListRepeatability.value = list.filter((item: { params: string }) => item.params === '温度值')
  // 温度值传重复性
  temperatureListRepeatability.value = temperatureListRepeatability.value.map((e: any) => {
    return {
      editable: type === 'edit',
      dataId: e.id, //	核查数据管理基础信息表id
      id: '', //	id,更新/删除使用参数
      checkType: '重复性',
      params: e.params, // 核查项目
      checkPoint: e.checkPoint,
      unit: e.unit, //	单位(直接存字典value)
      urel: e.urel, // 扩展不确定度U

      testValueOne: 0, //	核查标准示值1(温度值-重复性)
      testValueTwo: 0, //	核查标准示值2(温度值-重复性)
      testValueThree: 0, //	核查标准示值3(温度值-重复性)
      testValueFour: 0, //	核查标准示值4(温度值-重复性)
      testValueFive: 0, //	核查标准示值5(温度值-重复性)
      testValueSix: 0, //	核查标准示值6(温度值-重复性)

      measureValueOne: 0, //	测量标准示值1
      measureValueTwo: 0, //	测量标准示值2
      measureValueThree: 0, //	测量标准示值3
      measureValueFour: 0, //	测量标准示值4
      measureValueFive: 0, //	测量标准示值5
      measureValueSix: 0, //	测量标准示值6

      differentValueOne: '', //	差值1(温度值-重复性)
      differentValueTwo: '', // 差值2(温度值-重复性)
      differentValueThree: '', //	差值3(温度值-重复性)
      differentValueFour: '', //	差值4(温度值-重复性)
      differentValueFive: '', //	差值5(温度值-重复性)
      differentValueSix: '', //	差值6(温度值-重复性)

      averageValue: '', // 差值平均值
      standardDeviation: '', // Sn
      conclusion: '', // 结论(设备性能正常/设备性能异常)
    }
  })
  // 温度值稳定性
  temperatureListStability.value = temperatureListRepeatability.value.map((e) => {
    return {
      editable: props.pageType !== 'detail',
      dataId: e.dataId, //	核查数据管理基础信息表id
      id: '', //	id,更新/删除使用参数
      params: e.params, // 核查项目
      checkPoint: e.checkPoint,
      unit: e.unit, // 单位
      checkType: '稳定性',
      urel: e.urel, // 扩展不确定度U
    }
  })

  // RTP
  RTPListRepeatability.value = list.filter((item: { params: string }) => item.params === 'RTP值')
  // RTP
  RTPListRepeatability.value = RTPListRepeatability.value.map((e: any) => {
    return {
      editable: type === 'edit',
      id: '', //	id,更新/删除使用参数
      checkType: '重复性',
      dataId: e.id, //	核查数据管理基础信息表id
      params: e.params, // 核查项目
      checkPoint: e.checkPoint,
      unit: e.unit, //	单位(直接存字典value)
      allowValue: e.allowValue, // 允许值

      testValueOne: 0, //	被校示值1(RTP值-重复性)
      testValueTwo: 0, //	被校示值2(RTP值-重复性)
      testValueThree: 0, //	被校示值3(RTP值-重复性)
      testValueFour: 0, //	被校示值4(RTP值-重复性)
      testValueFive: 0, //	被校示值5(RTP值-重复性)
      testValueSix: 0, //	被校示值6(RTP值-重复性)

      averageValue: '', // 平均值
      conclusion: '', // 结论(设备性能正常/设备性能异常)
    }
  })

  // RTP稳定性
  RTPListStability.value = RTPListRepeatability.value.map((e) => {
    return {
      editable: props.pageType !== 'detail',
      dataId: e.dataId, //	核查数据管理基础信息表id
      id: '', //	id,更新/删除使用参数
      params: e.params, // 核查项目
      checkPoint: e.checkPoint,
      unit: e.unit, // 单位
      allowValue: e.allowValue, // 允许值
      checkType: '稳定性',
      urel: e.urel,
      measureValue: '', // 测量极差值
      illustration: '', // 结论
    }
  })

  // 绝缘电阻表校准
  listinsulationResistance.value = list.filter((item: { params: string }) => item.params === '绝缘电阻表校准')
  listinsulationResistance.value = listinsulationResistance.value.map((e: IList) => {
    return {
      editable: props.pageType !== 'detail',
      dataId: e.id, //	核查数据管理基础信息表id
      id: '', //	id,更新/删除使用参数
      params: e.params, // 核查项目
      checkPoint: e.checkPoint,
      unit: e.unit, // 单位
      measureValue: 0, // 测量值
      indicatingError: '', // 示值误差
      maximumError: e.maximumError, // 最大允许误差
    }
  })

  // 测温仪电阻核查
  const tempListThermodetector = list.filter((item: { params: string }) => item.params === '测温仪电阻核查')
  for (let i = 0; i < tempListThermodetector.length; i++) {
    for (let j = 0; j < 8; j++) {
      listThermodetector.value.push({
        editable: props.pageType !== 'detail',
        dataId: tempListThermodetector[i].id, //	核查数据管理基础信息表id
        id: '', //	id,更新/删除使用参数
        params: tempListThermodetector[i].params, // 核查项目
        checkPoint: tempListThermodetector[i].checkPoint,
        thoroughfare: `通道${j + 3}`, // 通道
        unit: tempListThermodetector[i].unit, // 单位
        maximumDeviation: '', // 最大偏差
        averageValue: '', // 平均值
        maximumError: tempListThermodetector[i].maximumError, // 最大允许误差绝对值|MPE|
        testValueOne: 0,
        testValueTwo: 0,
        testValueThree: 0,
        testValueFour: 0,
        testValueFive: 0,
        testValueSix: 0,
      })
    }
  }
}

// 点击计算结果
const createResult = (type: 'repeatability' | 'stability' | 'resistance' | 'thermodetector') => {
  if (current.value === 'temperature' && !temperatureListRepeatability.value.length) { // 温度值
    ElMessage.warning('温度值未配置重复性,请检查')
    return false
  }
  if (current.value === 'RTP' && !RTPListRepeatability.value.length) { // RTP值
    ElMessage.warning('RTP值未配置重复性,请检查')
    return false
  }
  if (type === 'repeatability') {
    if (current.value === 'temperature' && !useCheckList(temperatureListRepeatability.value, columns_repeatability_temperature.value, '温度值-重复性')) { return false }
    if (current.value === 'RTP' && !useCheckList(RTPListRepeatability.value, columns_repeatability_RTP.value, 'RTP值-重复性')) { return false }
    if (current.value === 'insulation-resistance' && !useCheckList(listinsulationResistance.value, columns_insulation_resistance.value, '绝缘电阻表校准')) { return false }
  }

  if (type === 'stability') {
    if (current.value === 'temperature' && `${temperatureListRepeatability.value[0].averageValue}` === '') { // 温度值
      ElMessage.warning('请先计算温度值重复性')
      return false
    }
    if (current.value === 'RTP' && `${RTPListRepeatability.value[0].averageValue}` === '') { // RTP值
      ElMessage.warning('请先计算RTP值重复性')
      return false
    }
  }
  let checkDataResistanceThermometerListParams: any // 要传的重复或者稳定性参数
  if (current.value === 'temperature') { // 温度值
    checkDataResistanceThermometerListParams = type === 'repeatability' ? temperatureListRepeatability.value : temperatureListStability.value
  }
  else if (current.value === 'RTP') { // RTP值
    checkDataResistanceThermometerListParams = type === 'repeatability' ? RTPListRepeatability.value : RTPListStability.value
  }
  else if (current.value === 'insulation-resistance') { // 绝缘电阻表校准
    checkDataResistanceThermometerListParams = listinsulationResistance.value.map((item) => {
      if (item.checkPoint === '∞(开路)') { item.checkPoint = '∞' }
      return item
    })
  }
  else if (current.value === 'thermodetector') { // 测温仪电阻核查
    checkDataResistanceThermometerListParams = listThermodetector.value
  }

  const params = {
    belongStandardEquipment: belongStandardEquipment.value, // 检校标准装置
    checkDataResistanceThermometerList: checkDataResistanceThermometerListParams.map((item: { lessThan: string; illustration: string }) => {
      return {
        ...item,
        lessThan: item.lessThan === '是' ? '1' : item.lessThan === '否' ? '0' : '', // 温度点 是否小于相对扩展不确定度Urel(0/1)
        illustration: item.illustration === '是' ? '1' : item.illustration === '否' ? '0' : '', // RTP 结论,平均值是否在允许值内,如是,则合格,否则不合格
      }
    }),
    itemCategoryId: itemCategoryId.value, // 核查项分类id
    itemCategoryName: itemCategoryName.value, // 核查项分类id
  }
  repeatabilityTableLoading.value = type === 'repeatability' || type === 'resistance' || type === 'thermodetector' // 重复性表\电阻、测温仪loading
  stabilityTableLoading.value = type === 'stability' // 稳定性表loading

  calculateHandle(params).then((res) => {
    if (current.value === 'temperature') { // 温度值
      const result = res.data.map((item: any) => {
        return {
          ...item,
          editable: props.pageType !== 'detail',
        }
      })
      if (type === 'repeatability') { // 重复性
        temperatureListRepeatability.value = result
        // 填充稳定性最后一列的日期和数值
        temperatureListStability.value = temperatureListStability.value.map((item, index: number) => {
          return {
            ...item,
            differentValueSix: temperatureListRepeatability.value[index].averageValue, //	测量差值
            testValueSixDate: props.checkDate, //	核查读数6日期(本次核查日期)
          }
        })
      }
      else { // 稳定性
        temperatureListStability.value = result.map((item: { lessThan: string | number }) => {
          return {
            ...item,
            lessThan: `${item.lessThan}` === '1' ? '是' : '否',
          }
        })
      }
    }
    else if (current.value === 'RTP') { // RTP
      const result = res.data.map((item: any) => {
        return {
          ...item,
          editable: props.pageType !== 'detail',
        }
      })
      if (type === 'repeatability') { // 重复性
        RTPListRepeatability.value = result
        RTPListStability.value = RTPListStability.value.map((item, index: number) => {
          return {
            ...item,
            testValueSix: RTPListRepeatability.value[index].averageValue, //	核查读数6(本次重复性示值算术平均值)
            testValueSixDate: props.checkDate, //	核查读数6日期(本次核查日期)
          }
        })
      }
      else { // 稳定性
        RTPListStability.value = result.map((item: { illustration: string | number }) => {
          return {
            ...item,
            illustration: `${item.illustration}` === '1' ? '是' : '否',
          }
        })
      }
    }
    else if (current.value === 'insulation-resistance' && type === 'resistance') { //  绝缘电阻表校准
      listinsulationResistance.value = res.data.map((item: any) => {
        return {
          ...item,
          editable: props.pageType !== 'detail',
          checkPoint: item.checkPoint === '∞' ? '∞(开路)' : item.checkPoint,
        }
      })
    }
    else if (current.value === 'thermodetector' && type === 'thermodetector') { //  测温仪电阻核查
      listThermodetector.value = res.data.map((item: any) => {
        return {
          ...item,
          editable: props.pageType !== 'detail',
        }
      })
      listThermodetector.value
    }
    form.value.temperatureConclusion = temperatureListStability.value.length ? temperatureListStability.value[0].conclusion : ''// 温度值结论
    form.value.RTPConclusion = RTPListStability.value.length ? RTPListStability.value[0].conclusion : '' // RTP结论
    form.value.resistanceConclusion = listinsulationResistance.value.length ? listinsulationResistance.value[0].conclusion : ''// 绝缘电阻表校准结论
    form.value.thermodetectorConclusion = listThermodetector.value.length ? listThermodetector.value[0].conclusion : ''// 测温仪电阻核查结论
    repeatabilityTableLoading.value = false
    stabilityTableLoading.value = false
  }).catch(() => {
    repeatabilityTableLoading.value = false
    stabilityTableLoading.value = false
  })
}

// 点击生成图表
const xData = ref([]) as any // 横坐标
const yData = ref([]) as any // 纵坐标
const chart = ref() // 图标ref
const createChart = () => {
  if (form.value.isCheckRTP && `${RTPListRepeatability.value[0].averageValue}` === '') { // RTP值
    ElMessage.warning('请计算RTP值重复性')
    return false
  }
  // 横坐标
  const dateArr: { [key: string]: string }[] = []
  columns_stability_RTP.value[3].children?.forEach((item) => {
    if (item.text && item.text !== '-') {
      dateArr.push({ text: item.text, value: item.value })
    }
  })
  xData.value = dateArr.map(item => item.text)
  console.log('横坐标', xData.value)
  // 纵坐标
  const yObj: { [key: string]: any } = {} // 纵坐标对象,对象值为数组
  for (let i = 0; i < RTPListStability.value.length; i++) {
    const name = `yValue${i}`
    yObj[name] = [] // 初始化为一个空数组
  }

  RTPListStability.value.forEach((item: any, index: number) => {
    const tempData = [] as any
    if (dateArr.length) {
      dateArr.forEach((i) => {
        tempData.push(Number(item[i.value]))
      })
      yObj[`yValue${index}`].push({ name: `水相三点:${item.checkPoint}`, data: tempData })
    }
  })
  yData.value = []
  for (const i in yObj) {
    yData.value.push(yObj[i][0])
  }
  console.log('纵坐标', yData.value)
  chart.value.refreshChart()
}
// ------------------------------------------------------------------------------------------

// 处理详情数据
const solveGetDetailData = (responseList: any) => {
  console.log('处理详情数据', props.pageType)

  const temperatureListRepeatability = responseList.filter((item: { params: string; checkType: string }) => item.params === '温度值' && item.checkType === '重复性').map((item: any) => {
    return {
      ...item,
      editable: props.pageType !== 'detail',
    }
  })
  const RTPListRepeatability = responseList.filter((item: { params: string ; checkType: string }) => item.params === 'RTP值' && item.checkType === '重复性').map((item: any) => {
    return {
      ...item,
      editable: props.pageType !== 'detail',
    }
  })

  const temperatureListStability = responseList.filter((item: { params: string ; checkType: string }) => item.params === '温度值' && item.checkType === '稳定性').map((item: any) => {
    return {
      ...item,
      lessThan: `${item.lessThan}` === '1' ? '是' : `${item.lessThan}` === '0' ? '否' : item.lessThan,
    }
  })
  const RTPListStability = responseList.filter((item: { params: string; checkType: string }) => item.params === 'RTP值' && item.checkType === '稳定性').map((item: any) => {
    return {
      ...item,
      illustration: `${item.illustration}` === '1' ? '是' : `${item.illustration}` === '0' ? '否' : item.illustration,
    }
  })

  return {
    tempTemperatureListRepeatability: temperatureListRepeatability,
    tempRTPListRepeatability: RTPListRepeatability,
    tempemperatureListStability: temperatureListStability,
    tempRTPListStability: RTPListStability,
  }
}

// 获取详情
function fetchInfo(id = '') {
  const loading = ElLoading.service({
    lock: true,
    background: 'rgba(255, 255, 255, 0.8)',
  })
  getInfo({ id: id || infoId.value }).then((res) => {
    form.value = { ...res.data }
    equipmentId.value = res.data.equipmentId
    const { tempTemperatureListRepeatability, tempRTPListRepeatability, tempemperatureListStability, tempRTPListStability } = solveGetDetailData(res.data.checkDataResistanceThermometerList)
    if (id !== '') { // 查询的日期获得的数据
      temperatureListRepeatabilityCheckDate.value = tempTemperatureListRepeatability// 温度值重复性查询数据
      temperatureListStabilityCheckDate.value = tempemperatureListStability// 温度值稳定性查询数据
      RTPListRepeatabilityCheckDate.value = tempRTPListRepeatability// RTP值重复性查询数据
      RTPListStabilityCheckDate.value = tempRTPListStability // RTP值稳定性查询数据
    }
    else {
      temperatureListRepeatability.value = tempTemperatureListRepeatability// 温度值重复性查询数据
      temperatureListStability.value = tempemperatureListStability// 温度值稳定性查询数据
      RTPListRepeatability.value = tempRTPListRepeatability// RTP值重复性查询数据
      RTPListStability.value = tempRTPListStability // RTP值稳定性查询数据
    }

    nextTick(() => {
      if (id !== '') { // 稳定性表头---查询历史的稳定性日期数据
        columns_stability_temperature_checkDate.value[3].children = [
          { width: '180', text: '-', value: 'differentValueOne', align: 'center', required: false, type: 'text', customHeader: true },
          { width: '180', text: '-', value: 'differentValueTwo', align: 'center', required: false, type: 'text', customHeader: true },
          { width: '180', text: '-', value: 'differentValueThree', align: 'center', required: false, type: 'text', customHeader: true },
          { width: '180', text: '-', value: 'differentValueFour', align: 'center', required: false, type: 'text', customHeader: true },
          { width: '180', text: '-', value: 'differentValueFive', align: 'center', required: false, type: 'text', customHeader: true },
          { width: '180', text: '-', value: 'differentValueSix', align: 'center', required: false, type: 'text', customHeader: true },
        ]
        columns_stability_RTP_checkDate.value[3].children = [
          { width: '180', text: '-', value: 'testValueOne', align: 'center', required: false, type: 'text', customHeader: true },
          { width: '180', text: '-', value: 'testValueTwo', align: 'center', required: false, type: 'text', customHeader: true },
          { width: '180', text: '-', value: 'testValueThree', align: 'center', required: false, type: 'text', customHeader: true },
          { width: '180', text: '-', value: 'testValueFour', align: 'center', required: false, type: 'text', customHeader: true },
          { width: '180', text: '-', value: 'testValueFive', align: 'center', required: false, type: 'text', customHeader: true },
          { width: '180', text: '-', value: 'testValueSix', align: 'center', required: false, type: 'text', customHeader: true },
        ]
        fetchHistoryIndication(currentDate.value) // 获取稳定性
      }
      else { // 正常核查数据处理表头
        columns_stability_temperature.value = handleDetailTableTableHead(columns_stability_temperature.value, temperatureListStability.value, 3)
        columns_stability_RTP.value = handleDetailTableTableHead(columns_stability_RTP.value, RTPListStability.value, 3)
      }
    })
    if (props.pageType === 'edit') {
      fetchHistoryIndication() // 重新拉取稳定性日期
    }
    // 绝缘电阻表校准
    listinsulationResistance.value = res.data.checkDataResistanceThermometerList.filter((item: { params: string }) => item.params === '绝缘电阻表校准')
    // 测温仪电阻核查
    listThermodetector.value = res.data.checkDataResistanceThermometerList.filter((item: { params: string }) => item.params === '测温仪电阻核查')
    listThermodetector.value = listThermodetector.value.map((item) => {
      return {
        ...item,
        editable: props.pageType !== 'detail',
      }
    })
    // ===================计算是否进行此核查================
    form.value.isCheckTemperature = temperatureListRepeatability.value.concat(temperatureListStability.value)[0].thisItemCheck
    form.value.isCheckRTP = RTPListRepeatability.value.concat(RTPListStability.value)[0].thisItemCheck
    // ======================计算结论======================
    form.value.temperatureConclusion = temperatureListStability.value.length ? temperatureListStability.value[0].conclusion : ''// 温度值结论
    form.value.RTPConclusion = RTPListStability.value.length ? RTPListStability.value[0].conclusion : '' // RTP结论
    form.value.resistanceConclusion = listinsulationResistance.value.length ? listinsulationResistance.value[0].conclusion : ''// 绝缘电阻表校准结论
    form.value.thermodetectorConclusion = listThermodetector.value.length ? listThermodetector.value[0].conclusion : ''// 测温仪电阻核查结论
    loading.close()
  })
}

/**
 * 获取稳定性示值
 * @param date 查询日期
 */
function fetchHistoryIndication(date = '') {
  const params = {
    belongStandardEquipment: belongStandardEquipment.value,	// 检校标准装置(字典code)
    checkDate: date || props.checkDate!,	// 核查日期
    checkParam: '',	// 核查参数((直流稳压电源-直接电流(间接测量))
    conclusion: '是',	// 结论
    equipmentId: equipmentId.value,	// 被核查设备id
    params: current.value === 'temperature' ? '温度值' : 'RTP值',	// 核查项目
    stabilityExamine: '1',	// 是否用于稳定性考核(1/0)
    standardEquipmentId: props.selectStandardId!,	// 被核查标准装置id
  }
  if (props.selectStandardId && equipmentId.value) {
    stabilityTableLoading.value = true
    getHistoryIndication(params).then((res) => {
      if (date === '') { // 正常核查数据
        const num = props.pageType === 'edit' ? 5 : 4
        // 温度值
        temperatureListStability.value = temperatureListStability.value.map((item) => {
          clearDateValue(item)
          const { itemData, columnsData } = solveHistoryIndicationTableData(res.data.data, item, columns_stability_temperature.value, num, 3)
          columns_stability_temperature.value = columnsData
          return item = itemData
        })
        temperatureListStability.value = handleSaveDateParams(columns_stability_temperature.value, temperatureListStability.value, 3)
        // RTP值
        RTPListStability.value = RTPListStability.value.map((item) => {
          clearDateValue(item)
          const { itemData, columnsData } = solveHistoryIndicationTableData(res.data.data, item, columns_stability_RTP.value, num, 3)
          columns_stability_RTP.value = columnsData
          return item = itemData
        })
        RTPListStability.value = handleSaveDateParams(columns_stability_RTP.value, RTPListStability.value, 3)
      }
      else {
        // 温度值
        temperatureListStabilityCheckDate.value = temperatureListStabilityCheckDate.value.map((item) => {
          clearDateValue(item)
          const { itemData, columnsData } = solveHistoryIndicationTableData(res.data.data, item, columns_stability_temperature_checkDate.value, 5, 3)
          columns_stability_temperature_checkDate.value = columnsData
          return item = itemData
        })
        temperatureListStabilityCheckDate.value = handleSaveDateParams(columns_stability_temperature_checkDate.value, temperatureListStabilityCheckDate.value, 3)
        // RTP值
        RTPListStabilityCheckDate.value = RTPListStabilityCheckDate.value.map((item) => {
          clearDateValue(item)
          const { itemData, columnsData } = solveHistoryIndicationTableData(res.data.data, item, columns_stability_RTP_checkDate.value, 5, 3)
          columns_stability_RTP_checkDate.value = columnsData
          return item = itemData
        })
        RTPListStabilityCheckDate.value = handleSaveDateParams(columns_stability_RTP_checkDate.value, RTPListStabilityCheckDate.value, 3)
      }

      stabilityTableLoading.value = false
    }).catch(() => { stabilityTableLoading.value = false })
  }
}

/**
 * 保存之前的校验
 * 重复性和稳定性必须要计算才能保存
 * 因为如果不计算稳定性
 */
function checkList() {
  // 新建核查数据的时候,在保存之前要先校验一下本次核查日期有没有数据,没有不允许保存
  if (form.value.isCheckTemperature && `${temperatureListRepeatability.value[0].averageValue}` === '') { // 温度值
    ElMessage.warning('请计算温度值重复性')
    return false
  }
  if (form.value.isCheckRTP && `${RTPListRepeatability.value[0].averageValue}` === '') { // RTP值
    ElMessage.warning('请计算RTP值重复性')
    return false
  }
  // 温度值重复性
  temperatureListRepeatability.value = temperatureListRepeatability.value.map((item) => { item.thisItemCheck = form.value.isCheckTemperature; return item })
  // RTP重复性
  RTPListRepeatability.value = RTPListRepeatability.value.map((item) => { item.thisItemCheck = form.value.isCheckTemperature; return item })
  // 温度值稳定性
  temperatureListStability.value = temperatureListStability.value.map((item) => {
    return {
      ...item,
      lessThan: item.lessThan === '是' ? '1' : item.lessThan === '否' ? '0' : '', // 是否小于相对扩展不确定度Urel(0/1)
      thisItemCheck: form.value.isCheckTemperature, // 是否进行此项核查(1/0)
      conclusion: form.value.temperatureConclusion, // 结论
    }
  })
  // RTP稳定性
  RTPListStability.value = RTPListStability.value.map((item) => {
    return {
      ...item,
      lessThan: item.illustration === '是' ? '1' : item.lessThan === '否' ? '0' : '', // RTP结论
      thisItemCheck: form.value.isCheckRTP, // 是否进行此项核查(1/0)
      conclusion: form.value.RTPConclusion, // 结论
    }
  })
  listinsulationResistance.value = listinsulationResistance.value.map((item) => {
    return {
      ...item,
      conclusion: form.value.resistanceConclusion, // 结论
    }
  })
  return true
}

// 点击表头日期查询历史稳定性数据
const handleClickHeader = (val: any, checkDateDetailId: string) => {
  dateArrStability.value = ['核查数据', val.label]
  fetchInfo(checkDateDetailId) // 获取此次历史日期的详情
}

// 日期变化
const handleChangeRadio = (date: string) => {
  currentDate.value = date
}
// 是否进行本次核查点击
const changeCheckbox = (value: any) => {
  if (`${value}` === '1') {
    if (current.value === 'temperature') {
      temperatureListRepeatability.value = temperatureListRepeatability.value.map((item) => {
        return {
          ...item,
          editable: true,
        }
      })
    }
    if (current.value === 'RTP') {
      temperatureListRepeatability.value = temperatureListRepeatability.value.map((item) => {
        return {
          ...item,
          editable: true,
        }
      })
    }
  }
  else {
    ElMessageBox.alert('不进行此项核查,保存时会清空此次填写的数据', '提示', {
      confirmButtonText: '确定',
      callback: () => {
        if (current.value === 'temperature') {
          temperatureListRepeatability.value = temperatureListRepeatability.value.map((item) => {
            return {
              ...item,
              editable: false,
            }
          })
        }
        if (current.value === 'RTP') {
          temperatureListRepeatability.value = temperatureListRepeatability.value.map((item) => {
            return {
              ...item,
              editable: false,
            }
          })
        }
      },
    })
  }
}

// -------------------------------------钩子-----------------------------------------------------
// 统计日期
const dateCount = (columns: TableColumn[]) => {
  let dateNum = 0 // 稳定性表格有几个日期

  // 统计有几个日期
  columns[3].children?.forEach((item) => {
    if (item.text !== '-' && item.text !== '') {
      dateNum += 1
    }
  })
  return dateNum
}
// 监听稳定性表格--判断结论
// watch([() => temperatureListStability.value, () => RTPListStability.value, () => listinsulationResistance.value], (newValue: any) => {
//   console.log('监听数据')
//   if (newValue[0] && newValue[0].length) { // 温度值
//     const result = newValue[0].every((item: { lessThan: string }) => {
//       return item.lessThan === '是'
//     })
//     const dateNum = dateCount(columns_stability_temperature.value)
//     form.value.temperatureConclusion = dateNum < 4 ? '设备性能正常' : result ? '设备性能正常' : '设备性能异常'// 温度值结论
//   }
//   if (newValue[1] && newValue[1].length) { // RTP值
//     const result = newValue[1].every((item: { illustration: string }) => {
//       return item.illustration === '合格'
//     })
//     const dateNum = dateCount(columns_stability_RTP.value)
//     form.value.RTPConclusion = dateNum < 4 ? '设备性能正常' : result ? '设备性能正常' : '设备性能异常'// 温度值结论
//   }
//   if (newValue[2] && newValue[2].length) { // 绝缘电阻表校准结论
//     const result = newValue[2].every((item: IList) => {
//       return Math.abs(Number(item.indicatingError)) < Math.abs(Number(item.maximumError?.slice(1)))
//     })
//     form.value.resistanceConclusion = result ? '设备性能正常' : '设备性能异常'
//   }
// }, { deep: true, immediate: true })

watch(() => props.pageType, (newValue) => {
  if (newValue === 'detail') {
    temperatureListRepeatability.value = temperatureListRepeatability.value.map((item) => { item.editable = false; return item })
    RTPListRepeatability.value = RTPListRepeatability.value.map((item) => { item.editable = false; return item })
    listinsulationResistance.value = listinsulationResistance.value.map((item) => { item.editable = false; return item })
    listThermodetector.value = listThermodetector.value.map((item) => { item.editable = false; return item })
  }
})
/**
 * 初始化表头
 * @param soveLastColumnDate 是否处理最后一列
 */
function initColumns() {
  columns_stability_temperature.value[3].children = [
    { width: '180', text: '-', value: 'differentValueOne', align: 'center', required: false, type: 'text', customHeader: true },
    { width: '180', text: '-', value: 'differentValueTwo', align: 'center', required: false, type: 'text', customHeader: true },
    { width: '180', text: '-', value: 'differentValueThree', align: 'center', required: false, type: 'text', customHeader: true },
    { width: '180', text: '-', value: 'differentValueFour', align: 'center', required: false, type: 'text', customHeader: true },
    { width: '180', text: '-', value: 'differentValueFive', align: 'center', required: false, type: 'text', customHeader: true },
    { width: '180', text: '-', value: 'differentValueSix', align: 'center', required: false, type: 'text', customHeader: true },
  ]
  columns_stability_RTP.value[3].children = [
    { width: '180', text: '-', value: 'testValueOne', align: 'center', required: false, type: 'text', customHeader: true },
    { width: '180', text: '-', value: 'testValueTwo', align: 'center', required: false, type: 'text', customHeader: true },
    { width: '180', text: '-', value: 'testValueThree', align: 'center', required: false, type: 'text', customHeader: true },
    { width: '180', text: '-', value: 'testValueFour', align: 'center', required: false, type: 'text', customHeader: true },
    { width: '180', text: '-', value: 'testValueFive', align: 'center', required: false, type: 'text', customHeader: true },
    { width: '180', text: '-', value: 'testValueSix', align: 'center', required: false, type: 'text', customHeader: true },
  ]
  const index = columns_stability_temperature.value.findIndex(item => item.text === '测量差值')
  if (index !== -1) {
    columns_stability_temperature.value[index].children![5].text = props.checkDate! // 最后一列的表头日期
  }
  const indexWorst = columns_stability_RTP.value.findIndex(item => item.text === '被校示值平均值(Ω)')
  if (index !== -1) {
    columns_stability_RTP.value[indexWorst].children![5].text = props.checkDate! // 最后一列的表头日期
  }
}
// 监听核查日期变化
watch(() => props.checkDate, (newValue) => {
  initColumns()
  nextTick(() => {
    fetchHistoryIndication() // 重新拉取稳定性日期
  })
}, { immediate: true })

onMounted(async () => {
  belongStandardEquipment.value = $route.query.belongStandardEquipment as string // 检校标准装置
  itemCategoryId.value = $route.query.itemCategoryId as string // 核查项分类id
  itemCategoryName.value = $route.query.itemCategoryName as string // 核查项分类名称
  if (props.pageType !== 'add') {
    fetchInfo()
  }
})
defineExpose({
  fetchCheckItemDetail,
  form,
  checkList,
  temperatureListRepeatability,
  temperatureListStability,
  RTPListRepeatability,
  RTPListStability,
  listinsulationResistance,
  listThermodetector,
})
</script>

<template>
  <!-- 核查数据 -->
  <detail-block :title="dateArrStability.length > 1 ? ' ' : '核查数据'" :title-menus="dateArrStability" @handle-change-radio="handleChangeRadio">
    <div style="display: flex;justify-content: space-between;">
      <el-radio-group v-model="current" style="margin-bottom: 20px;">
        <el-radio-button v-for="item in radioMenus" :key="item.value" :label="item.value">
          {{ item.name }}
        </el-radio-button>
      </el-radio-group>
    </div>
    <div style="padding: 0 10px;">
      <el-checkbox v-if="current === 'temperature'" v-model="form.isCheckTemperature" :true-label="1" :false-label="0" :disabled="pageType === 'detail'" @change="changeCheckbox">
        是否进行此项核查
      </el-checkbox>
      <el-checkbox v-if="current === 'RTP'" v-model="form.isCheckRTP" :true-label="1" :false-label="0" :disabled="pageType === 'detail'" @change="changeCheckbox">
        是否进行此项核查
      </el-checkbox>
    </div>
    <div v-if="current === 'temperature' || current === 'RTP'" style="display: flex;justify-content: space-between;align-items: center;">
      <h5>核查类型--重复性</h5>
      <el-button v-if="pageType !== 'detail'" type="primary" @click="createResult('repeatability')">
        计算结果
      </el-button>
    </div>

    <multi-table
      v-show="(current === 'temperature' || current === 'RTP') && (currentDate === '核查数据' || currentDate === '')"
      v-loading="repeatabilityTableLoading"
      :table-data="current === 'temperature' ? temperatureListRepeatability : RTPListRepeatability"
      :table-header="current === 'temperature' ? columns_repeatability_temperature : columns_repeatability_RTP"
      :merge-rows="[]"
      :need-index="true"
      max-height="300"
    />
    <!-- 历史日期重复性数据 -->
    <multi-table
      v-show="(current === 'temperature' || current === 'RTP') && (currentDate !== '核查数据' && currentDate !== '')"
      v-loading="repeatabilityTableLoading"
      :table-data="current === 'temperature' ? temperatureListRepeatabilityCheckDate : RTPListRepeatabilityCheckDate"
      :table-header="current === 'temperature' ? columns_repeatability_temperature : columns_repeatability_RTP"
      :merge-rows="[]"
      :need-index="true"
      max-height="300"
    />

    <div v-if="current === 'temperature' || current === 'RTP'" style="display: flex;justify-content: space-between;align-items: center;">
      <h5>核查类型--稳定性</h5>
      <div>
        <el-button v-if="pageType !== 'detail'" type="primary" @click="createResult('stability')">
          计算结果
        </el-button>
        <el-button v-if="pageType !== 'detail' && current === 'RTP'" type="primary" @click="createChart">
          生成图表
        </el-button>
      </div>
    </div>

    <multi-table
      v-show="(current === 'temperature' || current === 'RTP') && (currentDate === '核查数据' || currentDate === '')"
      v-loading="stabilityTableLoading"
      :table-data="current === 'temperature' ? temperatureListStability : RTPListStability"
      :table-header="current === 'temperature' ? columns_stability_temperature : columns_stability_RTP"
      :merge-rows="[]"
      :need-index="true"
      max-height="500"
      @handle-click-header="handleClickHeader"
    />

    <multi-table
      v-show="(current === 'temperature' || current === 'RTP') && (currentDate !== '核查数据' && currentDate !== '')"
      v-loading="stabilityTableLoading"
      :table-data="current === 'temperature' ? temperatureListStabilityCheckDate : RTPListStabilityCheckDate"
      :table-header="current === 'temperature' ? columns_stability_temperature_checkDate : columns_stability_RTP_checkDate"
      :merge-rows="[]"
      :need-index="true"
      max-height="500"
      @handle-click-header="handleClickHeader"
    />

    <div v-if="current === 'insulation-resistance'" style="display: flex;justify-content: flex-end;align-items: center;padding-bottom: 10px;">
      <el-button v-if="pageType !== 'detail'" type="primary" @click="createResult('resistance')">
        计算结果
      </el-button>
    </div>
    <!-- 绝缘电阻表校准 -->
    <el-table
      v-if="current === 'insulation-resistance'"
      ref="tableRef"
      v-loading="repeatabilityTableLoading"
      :data="listinsulationResistance"
      border
      style="width: 100%;"
    >
      <el-table-column align="center" label="序号" width="80" type="index" />
      <el-table-column
        v-for="item in columns_insulation_resistance"
        :key="item.value"
        :prop="item.value"
        :label="item.text"
        :width="item.width"
        align="center"
      >
        <template #header>
          <span v-show="item.required" style="color: red;">*</span><span>{{ item.text }}</span>
        </template>
        <template #default="scope">
          <!-- 测量值  -->
          <el-input-number
            v-if="props.pageType !== 'detail' && item.value === 'measureValue'"
            v-model="scope.row[item.value]"
            clearable
            placeholder="Urel"
            class="full-width-input"
          />
        </template>
      </el-table-column>
    </el-table>

    <div v-if="current === 'thermodetector'" style="display: flex;justify-content: flex-end;align-items: center;padding-bottom: 10px;">
      <el-button v-if="pageType !== 'detail'" type="primary" @click="createResult('thermodetector')">
        计算结果
      </el-button>
    </div>
    <!-- 测温仪电阻核查 -->
    <multi-table
      v-show="current === 'thermodetector'"
      v-loading="repeatabilityTableLoading"
      :table-data="listThermodetector"
      :table-header="columns_thermodetector"
      :merge-rows="['checkPoint', 'unit']"
      :need-index="true"
      max-height="500"
    />
    <!-- 结论 -->
    <el-form
      style="margin-top: 20px;"
      :model="form"
      label-width="180"
      label-position="right"
    >
      <el-row :gutter="24">
        <el-col :span="12">
          <el-form-item v-if="current === 'temperature'" label="结论:">
            <el-input v-model="form.temperatureConclusion" class="full-width-input" disabled placeholder="结论" />
          </el-form-item>
          <el-form-item v-if="current === 'RTP'" label="结论:">
            <el-input v-model="form.RTPConclusion" class="full-width-input" disabled placeholder="结论" />
          </el-form-item>
          <el-form-item v-if="current === 'insulation-resistance'" label="结论:">
            <el-input v-model="form.resistanceConclusion" class="full-width-input" disabled placeholder="结论" />
          </el-form-item>
          <el-form-item v-if="current === 'thermodetector'" label="结论:">
            <el-input v-model="form.thermodetectorConclusion" class="full-width-input" disabled placeholder="结论" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="备注:" prop="remark">
            <el-input
              v-model="form.remark"
              autosize
              type="textarea"
              :disabled="pageType === 'detail'"
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </detail-block>
  <detail-block v-show="current === 'RTP'" title="RTP稳定性趋势">
    <line-chart
      ref="chart"
      :x-axis-data="xData"
      :data="yData"
      height="200px"
      :legend="{
        show: true,
        icon: 'circle',
        orient: 'horizontal', // 图例方向
        align: 'left', // 图例标记和文本的对齐,默认自动
        itemWidth: 12,
        itemHeight: 12,
        padding: [0, 0, 0, 120],
      }"
    />
  </detail-block>

  <!-- 保存核查记录  -->
  <save-check-record ref="saveCheckRecordRef" />
</template>

<style lang="scss" scoped>
.link {
  text-decoration: underline;
  color: #3d7eff;
  cursor: pointer;
}

.file-area {
  display: flex;
  align-items: center;
  font-size: 14px;
  color: #60627f;
  margin-bottom: 10px;
  margin-left: 40px;
  white-space: nowrap;

  .tech-file {
    display: flex;
    align-items: center;
    margin-left: 20px;

    .file-text {
      margin-right: 10px;
    }
  }
}
</style>