Newer
Older
xc-business-system / src / views / equipement / standard / checkData / components / fourteen / checkDataCom.vue
lyg on 19 Apr 2024 61 KB 铯原子核查数据重构
<!-- 核查数据管理详情--核查项---第14套:铯原子标准装置 -->
<script lang="ts" setup name="checkDataDetail">
import { ref, watch } from 'vue'
import { ElLoading, ElMessage } from 'element-plus'
import saveCheckRecord from '../../dialog/saveCheckRecord.vue'
import { clearDateValue, handleDetailTableTableHead, handleSaveDateParams, solveHistoryIndicationTableData } from '../useStabilityCaculate'
import type { IList } from './fourteen-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 { useCheckList } from '@/commonMethods/useCheckList'
import multiTable from '@/components/MultiHeaderTable/index.vue'
import { addCheckData, calculateHandle, getHistoryIndication, getInfo, updateCheckData } from '@/api/equipment/standard/checkData'
import { getCheckItemDetail, getJobInstructionList } from '@/api/equipment/standard/book'

const props = defineProps({
  selectStandardId: { // 选择的标准装置id
    type: String,
  },
  pageType: { // 页面类型
    type: String,
  },
  checkDate: { // 核查日期
    type: String,
  },
})
const user = useUserStore() // 用户信息
const $router = useRouter() // 关闭页面使用
const $route = useRoute() // 路由参数
const infoId = ref('')
const belongStandardEquipment = ref('16')
const itemCategoryId = ref('') // 核查项分类id
const itemCategoryName = ref('') // 核查项分类名称
const form = ref({
  remark: '/', // 备注
  qualified: '', // 稳定性考核是否合格
})
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: 'repeatability' },
  { name: '稳定性', value: 'stability' },
])
const current = ref('repeatability') // 选择的tab 默认基本信息
const columns_repeatability_frequency = ref<TableColumn[]>([ // 重复性表头--铯原子频标核查
  { text: '核查项目', value: 'params', align: 'center', required: false, type: 'text' },
  { text: '核查方法', value: 'checkMethod', align: 'center', required: true, type: 'text' },
  { text: '频率点', value: 'checkPoint', align: 'center', required: true, type: 'text', unit: 'unit' },
  {
    text: '测量值',
    value: 'indicatingValue',
    align: 'center',
    required: false,
    width: '160',
    children: [
      { text: 'X1', value: 'testValueOne', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X2', value: 'testValueTwo', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X3', value: 'testValueThree', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X4', value: 'testValueFour', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X5', value: 'testValueFive', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X6', value: 'testValueSix', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X7', value: 'testValueSeven', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X8', value: 'testValueEight', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X9', value: 'testValueNine', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X10', value: 'testValueTen', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
    ],
  },
  { text: '平均值', value: 'averageValue', align: 'center', required: false, type: 'text' },
  { text: '重复性S(x)', value: 'standardDeviation', align: 'center', required: false, type: 'text' },
])

const columns_repeatability_power_level = ref<TableColumn[]>([ // 重复性表头--函数信号发生器核查
  { text: '核查项目', value: 'params', align: 'center', required: false, type: 'text' },
  { text: '频率点', value: 'checkPoint', align: 'center', required: true, type: 'text', unit: 'unit' },
  { text: '电平', value: 'electricalLevel', align: 'center', required: true, type: 'text', unit: 'electricalLevelUnit' },
  {
    text: '测量值',
    value: 'indicatingValue',
    align: 'center',
    required: false,
    width: '160',
    children: [
      { text: 'X1', value: 'testValueOne', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X2', value: 'testValueTwo', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X3', value: 'testValueThree', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X4', value: 'testValueFour', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X5', value: 'testValueFive', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X6', value: 'testValueSix', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X7', value: 'testValueSeven', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X8', value: 'testValueEight', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X9', value: 'testValueNine', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X10', value: 'testValueTen', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
    ],
  },
  { text: '平均值', value: 'averageValue', align: 'center', required: false, type: 'text', unit: 'powerUnit' },
  { text: '重复性S(x)', value: 'standardDeviation', align: 'center', required: false, type: 'text' },
])

const columns_repeatability_relative_level = ref<TableColumn[]>([ // 重复性表头--信号源核查
  { text: '核查项目', value: 'params', align: 'center', required: false, type: 'text' },
  { text: '频率点', value: 'checkPoint', align: 'center', required: true, type: 'text', unit: 'unit' },
  { text: '幅度', value: 'amplitude', align: 'center', required: true, type: 'text', unit: 'amplitudeUnit' },
  {
    text: '测量值',
    value: 'indicatingValue',
    align: 'center',
    required: false,
    width: '160',
    children: [
      { text: 'X1', value: 'testValueOne', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X2', value: 'testValueTwo', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X3', value: 'testValueThree', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X4', value: 'testValueFour', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X5', value: 'testValueFive', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X6', value: 'testValueSix', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X7', value: 'testValueSeven', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X8', value: 'testValueEight', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X9', value: 'testValueNine', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
      { text: 'X10', value: 'testValueTen', align: 'center', required: true, width: '180', type: 'inputNumber', unit: 'unit', precision: 3 },
    ],
  },
  { text: '平均值', value: 'averageValue', align: 'center', required: false, type: 'text' },
  { text: '重复性S(x)', value: 'standardDeviation', align: 'center', required: false, type: 'text' },
])

const columns_stability_frequency = ref<TableColumn[]>([ // 稳定性表头--铯原子频标核查
  { text: '核查项目', value: 'params', align: 'center', required: false, type: 'text' },
  { text: '核查方法', value: 'checkMethod', align: 'center', required: true, type: 'text' },
  { text: '频率点', value: 'checkPoint', align: 'center', required: true, type: 'text', unit: 'unit' },
  {
    text: '测量值',
    value: 'indicatingValue',
    align: 'center',
    required: false,
    width: '110',
    children: [
      { text: '-', value: 'testValueOneDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueTwoDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueThreeDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueFourDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueFiveDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueSixDate', align: 'center', required: true, type: 'text' },
    ],
  },
  { text: '平均值', value: 'averageValue', align: 'center', required: false, type: 'text' },
  { text: '稳定性', value: 'stability', align: 'center', required: false, type: 'text' },
  { text: 'U(k=2)', value: 'urel', align: 'center', type: 'text' },
  { text: '结论', value: 'lessThan', align: 'center', type: 'text' },
])
const columns_stability_frequency_checkDate = ref<TableColumn[]>([ // 稳定性表头--铯原子频标核查
  { text: '核查项目', value: 'params', align: 'center', required: false, type: 'text' },
  { text: '核查方法', value: 'checkMethod', align: 'center', required: true, type: 'text' },
  { text: '频率点', value: 'checkPoint', align: 'center', required: true, type: 'text', unit: 'unit' },
  {
    text: '测量值',
    value: 'indicatingValue',
    align: 'center',
    required: false,
    width: '110',
    children: [
      { text: '-', value: 'testValueOneDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueTwoDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueThreeDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueFourDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueFiveDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueSixDate', align: 'center', required: true, type: 'text' },
    ],
  },
  { text: '平均值', value: 'averageValue', align: 'center', required: false, type: 'text' },
  { text: '稳定性', value: 'stability', align: 'center', required: false, type: 'text' },
  { text: 'U(k=2)', value: 'urel', align: 'center', type: 'text' },
  { text: '结论', value: 'lessThan', align: 'center', type: 'text' },
])

const columns_stability_power_level = ref<TableColumn[]>([ // 稳定性表头--函数信号发生器核查
  { text: '核查项目', value: 'params', align: 'center', required: false, type: 'text' },
  { text: '频率点', value: 'checkPoint', align: 'center', required: true, type: 'text', unit: 'unit' },
  { text: '电平', value: 'electricalLevel', align: 'center', required: true, type: 'text', unit: 'electricalLevelUnit' },
  {
    text: '测量值/1MΩ',
    value: 'indicatingValue',
    align: 'center',
    required: false,
    width: '110',
    children: [
      { text: '-', value: 'testValueOneDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueTwoDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueThreeDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueFourDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueFiveDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueSixDate', align: 'center', required: true, type: 'text' },
    ],
  },
  { text: '平均值', value: 'averageValue', align: 'center', required: false, type: 'text' },
  { text: '稳定性', value: 'stability', align: 'center', required: false, type: 'text' },
  { text: 'U(k=2)', value: 'urel', align: 'center', type: 'text' },
  { text: '结论', value: 'lessThan', align: 'center', type: 'text' },
])
const columns_stability_power_level_checkDate = ref<TableColumn[]>([ // 稳定性表头--函数信号发生器核查
  { text: '核查项目', value: 'params', align: 'center', required: false, type: 'text' },
  { text: '频率点', value: 'checkPoint', align: 'center', required: true, type: 'text', unit: 'unit' },
  { text: '电平', value: 'electricalLevel', align: 'center', required: true, type: 'text', unit: 'electricalLevelUnit' },
  {
    text: '测量值/1MΩ',
    value: 'indicatingValue',
    align: 'center',
    required: false,
    width: '110',
    children: [
      { text: '-', value: 'testValueOneDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueTwoDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueThreeDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueFourDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueFiveDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueSixDate', align: 'center', required: true, type: 'text' },
    ],
  },
  { text: '平均值', value: 'averageValue', align: 'center', required: false, type: 'text' },
  { text: '稳定性', value: 'stability', align: 'center', required: false, type: 'text' },
  { text: 'U(k=2)', value: 'urel', align: 'center', type: 'text' },
  { text: '结论', value: 'lessThan', align: 'center', type: 'text' },
])

const columns_stability_relative_level = ref<TableColumn[]>([ // 稳定性表头--信号源核查
  { text: '核查项目', value: 'params', align: 'center', required: false, type: 'text' },
  { text: '频率点', value: 'checkPoint', align: 'center', required: true, type: 'text', unit: 'unit' },
  { text: '幅度', value: 'amplitude', align: 'center', required: true, type: 'text', unit: 'amplitudeUnit' },
  {
    text: '测量值',
    value: 'indicatingValue',
    align: 'center',
    required: false,
    width: '110',
    children: [
      { text: '-', value: 'testValueOneDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueTwoDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueThreeDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueFourDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueFiveDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueSixDate', align: 'center', required: true, type: 'text' },
    ],
  },
  { text: '平均值', value: 'averageValue', align: 'center', required: false, type: 'text' },
  { text: '稳定性', value: 'stability', align: 'center', required: false, type: 'text' },
  { text: 'U(k=2)', value: 'urel', align: 'center', type: 'text' },
  { text: '结论', value: 'lessThan', align: 'center', type: 'text' },
])
const columns_stability_relative_level_checkDate = ref<TableColumn[]>([ // 稳定性表头--信号源核查
  { text: '核查项目', value: 'params', align: 'center', required: false, type: 'text' },
  { text: '频率点', value: 'checkPoint', align: 'center', required: true, type: 'text', unit: 'unit' },
  { text: '幅度', value: 'amplitude', align: 'center', required: true, type: 'text', unit: 'amplitudeUnit' },
  {
    text: '测量值',
    value: 'indicatingValue',
    align: 'center',
    required: false,
    width: '110',
    children: [
      { text: '-', value: 'testValueOneDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueTwoDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueThreeDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueFourDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueFiveDate', align: 'center', required: true, type: 'text' },
      { text: '-', value: 'testValueSixDate', align: 'center', required: true, type: 'text' },
    ],
  },
  { text: '平均值', value: 'averageValue', align: 'center', required: false, type: 'text' },
  { text: '稳定性', value: 'stability', align: 'center', required: false, type: 'text' },
  { text: 'U(k=2)', value: 'urel', align: 'center', type: 'text' },
  { text: '结论', value: 'lessThan', align: 'center', type: 'text' },
])

// 重复性
const listFrequencyRepeatability = ref<IList[]>([]) // 铯原子频标核查-重复性
const listPowerLevelRepeatability = ref<IList[]>([]) // 函数信号发生器核查-重复性
const listRelativeLevelRepeatability = ref<IList[]>([]) // 信号源核查-重复性

// 重复性checkDate
const listFrequencyRepeatabilityCheckDate = ref<IList[]>([]) // 铯原子频标核查-重复性
const listPowerLevelRepeatabilityCheckDate = ref<IList[]>([]) // 函数信号发生器核查-重复性
const listRelativeLevelRepeatabilityCheckDate = ref<IList[]>([]) // 信号源核查-重复性

// 重复性Loading
const listFrequencyRepeatabilityLoading = ref(false) // 铯原子频标核查-重复性
const listPowerLevelRepeatabilityLoading = ref(false) // 函数信号发生器核查-重复性
const listRelativeLevelRepeatabilityLoading = ref(false) // 信号源核查-重复性
// 稳定性
const listFrequencyStability = ref<any[]>([]) // 铯原子频标核查-稳定性
const listPowerLevelStability = ref<any[]>([]) // 函数信号发生器核查-稳定性
const listRelativeLevelStability = ref<any[]>([]) // 信号源核查-稳定性
// 稳定性checkDate
const listFrequencyStabilityCheckDate = ref<any[]>([]) // 铯原子频标核查-稳定性
const listPowerLevelStabilityCheckDate = ref<any[]>([]) // 函数信号发生器核查-稳定性
const listRelativeLevelStabilityCheckDate = ref<any[]>([]) // 信号源核查-稳定性

// 稳定性Loading
const listFrequencyStabilityLoading = ref(false) // 铯原子频标核查-稳定性
const listPowerLevelStabilityLoading = ref(false) // 函数信号发生器核查-稳定性
const listRelativeLevelStabilityLoading = ref(false) // 信号源核查-稳定性

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

// 初始化数据(查询配置检定项)
function handleData(list: any, type = 'edit') {
  // 铯原子频标核查
  listFrequencyRepeatability.value = list.filter((item: { params: string }) => item.params === '铯原子频标核查' || item.params === '1')
  // 铯原子频标核查重复性
  listFrequencyRepeatability.value = listFrequencyRepeatability.value.map((e: any) => {
    return {
      ...e,
      paramsName: '铯原子频标核查',
      editable: type === 'edit',
      dataId: e.id, //	核查数据管理基础信息表id
      id: '', //	id,更新/删除使用参数
      checkType: '重复性',
      dataType: '1',
      params: '铯原子频标核查', // 核查项目
      unit: e.unit, //	单位(直接存字典value)
      checkMethod: e.checkMethod,
      averageValue: '', // 平均值
      standardDeviation: '', // 重复性
      urel: e.urel, // u(k=2)
      checkPoint: e.checkPoint,
      testValueOne: 0, //	测量值1/测量值(上升时间)
      testValueTwo: 0, //	测量值2(示值)
      testValueThree: 0, //	测量值3(示值)
      testValueFour: 0, //	测量值4(示值)
      testValueFive: 0, //	测量值5(示值)
      testValueSix: 0, //	测量值6(本次示值)
      testValueSeven: 0, //	测量值7
      testValueEight: 0, //	测量值8
      testValueNine: 0, //	测量值9
      testValueTen: 0, //	测量值10

      showUnitData: e.unit,
    }
  }) as any
  // 铯原子频标核查稳定性
  listFrequencyStability.value = listFrequencyRepeatability.value.map((e: any) => {
    return {
      paramsName: '铯原子频标核查',
      editable: props.pageType !== 'detail',
      dataId: e.dataId, //	核查数据管理基础信息表id
      id: '', //	id,更新/删除使用参数
      params: '铯原子频标核查', // 核查项目
      dataType: '1',
      checkPoint: e.checkPoint,
      checkType: '稳定性',
      checkMethod: e.checkMethod,
      urel: e.urel, // u(k=2)
      averageValue: '', // 平均值
      stability: '', // 稳定性
      lessThan: '', // 结论
      lessThanValue: '',
    }
  })

  // 函数信号发生器核查
  listPowerLevelRepeatability.value = list.filter((item: { params: string }) => item.params === '函数信号发生器核查' || item.params === '2')
  // 函数信号发生器核查重复性
  listPowerLevelRepeatability.value = listPowerLevelRepeatability.value.map((e: any) => {
    return {
      paramsName: '函数信号发生器核查',
      editable: type === 'edit',
      dataId: e.id, //	核查数据管理基础信息表id
      id: '', //	id,更新/删除使用参数
      checkType: '重复性',
      dataType: '2',
      params: '函数信号发生器核查', // 核查项目
      checkPoint: e.checkPoint,
      unit: e.unit, //	单位(直接存字典value)
      electricalLevel: e.electricalLevel,
      electricalLevelUnit: e.electricalLevelUnit,
      averageValue: '', // 平均值
      standardDeviation: '', // 重复性
      urel: e.urel, // u(k=2)
      testValueOne: 0, //	测量值1/测量值(上升时间)
      testValueTwo: 0, //	测量值2(示值)
      testValueThree: 0, //	测量值3(示值)
      testValueFour: 0, //	测量值4(示值)
      testValueFive: 0, //	测量值5(示值)
      testValueSix: 0, //	测量值6(本次示值)
      testValueSeven: 0, //	测量值7
      testValueEight: 0, //	测量值8
      testValueNine: 0, //	测量值9
      testValueTen: 0, //	测量值10
      showUnitData: e.unit,
    }
  }) as any
  // 函数信号发生器核查稳定性
  listPowerLevelStability.value = listPowerLevelRepeatability.value.map((e: any) => {
    return {
      paramsName: '函数信号发生器核查',
      editable: props.pageType !== 'detail',
      dataId: e.dataId, //	核查数据管理基础信息表id
      id: '', //	id,更新/删除使用参数
      params: '函数信号发生器核查', // 核查项目
      dataType: '2',
      checkPoint: e.checkPoint,
      unit: e.unit, //	单位(直接存字典value)
      electricalLevel: e.electricalLevel,
      electricalLevelUnit: e.electricalLevelUnit,
      checkType: '稳定性',
      urel: e.urel, // u(k=2)
      // unit: e.unit, //	单位(直接存字典value)
      averageValue: '', // 平均值
      stability: '', // 稳定性
      lessThan: '', // 结论
      lessThanValue: '', // 结论
      showUnitData: e.unit,
    }
  }) as any

  // 信号源核查
  listRelativeLevelRepeatability.value = list.filter((item: { params: string }) => item.params === '信号源核查' || item.params === '3')
  // 信号源核查重复性
  listRelativeLevelRepeatability.value = listRelativeLevelRepeatability.value.map((e: any) => {
    return {
      paramsName: '信号源核查',
      editable: type === 'edit',
      dataId: e.id, //	核查数据管理基础信息表id
      id: '', //	id,更新/删除使用参数
      checkType: '重复性',
      dataType: '3',
      params: '信号源核查', // 核查项目
      // nominalValue: e.nominalValue + e.unit,
      checkPoint: e.checkPoint,
      unit: e.unit, //	单位(直接存字典value)
      amplitude: e.amplitude,
      amplitudeUnit: e.amplitudeUnit,
      averageValue: '', // 平均值
      standardDeviation: '', // 重复性
      urel: e.urel, // u(k=2)

      // unit: e.unit, //	单位(直接存字典value)
      testValueOne: 0, //	测量值1/测量值(上升时间)
      testValueTwo: 0, //	测量值2(示值)
      testValueThree: 0, //	测量值3(示值)
      testValueFour: 0, //	测量值4(示值)
      testValueFive: 0, //	测量值5(示值)
      testValueSix: 0, //	测量值6(本次示值)
      testValueSeven: 0, //	测量值7
      testValueEight: 0, //	测量值8
      testValueNine: 0, //	测量值9
      testValueTen: 0, //	测量值10
      showUnitData: e.unit,
    }
  }) as any
  // 信号源核查稳定性
  listRelativeLevelStability.value = listRelativeLevelRepeatability.value.map((e: any) => {
    return {
      paramsName: '信号源核查',
      editable: props.pageType !== 'detail',
      dataId: e.dataId, //	核查数据管理基础信息表id
      id: '', //	id,更新/删除使用参数
      params: '信号源核查', // 核查项目
      dataType: '3',
      checkPoint: e.checkPoint,
      unit: e.unit, //	单位(直接存字典value)
      amplitude: e.amplitude,
      amplitudeUnit: e.amplitudeUnit,
      checkType: '稳定性',
      urel: e.urel, // u(k=2)
      averageValue: '', // 平均值
      stability: '', // 稳定性
      lessThan: '', // 结论
      lessThanValue: '', // 结论
      showUnitData: e.unit,
    }
  }) as any
}

// 点击计算结果
const createResult = (type: string) => {
  let dict = {}
  if (!isNaN(Number(type))) {
    // 数字
    dict = {
      1: '铯原子频标核查',
      2: '函数信号发生器核查',
      3: '信号源核查',
    }
  }
  else {
    dict = {
      铯原子频标核查: '铯原子频标核查',
      函数信号发生器核查: '函数信号发生器核查',
      信号源核查: '信号源核查',
    }
  }
  type = dict[type]
  let checkDataCesiumAtomList: any // 要传的重复或者稳定性参数
  if (current.value === 'stability') { // 计算稳定性先校验重复性
    if (!checkList()) { return false }
    checkDataCesiumAtomList = listFrequencyStability.value.concat(
      listPowerLevelStability.value,
      listRelativeLevelStability.value,
    )
  }

  if (current.value === 'repeatability') {
    switch (type) {
      case '铯原子频标核查':
        if (!useCheckList(listFrequencyRepeatability.value, columns_repeatability_frequency.value, `${type}-重复性`)) {
          return false
        }
        checkDataCesiumAtomList = listFrequencyRepeatability.value
        break
      case '函数信号发生器核查':
        if (!useCheckList(listPowerLevelRepeatability.value, columns_repeatability_power_level.value, `${type}-重复性`)) {
          return false
        }
        checkDataCesiumAtomList = listPowerLevelRepeatability.value
        break
      case '信号源核查':
        if (!useCheckList(listRelativeLevelRepeatability.value, columns_repeatability_relative_level.value, `${type}-重复性`)) {
          return false
        }
        checkDataCesiumAtomList = listRelativeLevelRepeatability.value
        break
    }
  }

  const params = {
    belongStandardEquipment: belongStandardEquipment.value, // 检校标准装置
    checkDataCesiumAtomList: checkDataCesiumAtomList.map((item: { conclusion: string }) => {
      return {
        ...item,
        conclusion: '',
      }
    }),
    itemCategoryId: itemCategoryId.value, // 核查项分类id
    itemCategoryName: itemCategoryName.value, // 核查项分类id
  }
  // 重复性Loading
  listFrequencyRepeatabilityLoading.value = type === '铯原子频标核查' && current.value === 'repeatability'
  listPowerLevelRepeatabilityLoading.value = type === '函数信号发生器核查' && current.value === 'repeatability'
  listRelativeLevelRepeatabilityLoading.value = type === '信号源核查' && current.value === 'repeatability'
  // 稳定性loading
  listFrequencyStabilityLoading.value = true // 铯原子频标核查-稳定性
  listPowerLevelStabilityLoading.value = true // 函数信号发生器核查-稳定性
  listRelativeLevelStabilityLoading.value = true // 信号源核查-稳定性

  calculateHandle(params).then((res) => {
    const result = res.data.filter((item: { params: string }) => item.params === type).map((item: any) => {
      return {
        ...item,
        editable: props.pageType !== 'detail',
        paramsName: type,
      }
    })
    if (current.value === 'repeatability') { // 重复性
      switch (type) {
        case '铯原子频标核查':
          listFrequencyRepeatability.value = result.map((item: any) => ({ ...item, showUnitData: item.unit }))
          // 填充稳定性最后一列的日期和数值
          listFrequencyStability.value = listFrequencyStability.value.map((item, index: number) => {
            return {
              ...item,
              testValueSix: listFrequencyRepeatability.value[index].averageValue, //	测量差值
              testValueSixDate: props.checkDate, //	核查读数6日期(本次核查日期)
            }
          })
          break
        case '函数信号发生器核查':
          listPowerLevelRepeatability.value = result.map((item: any) => ({ ...item, showUnitData: item.unit }))
          // 填充稳定性最后一列的日期和数值
          listPowerLevelStability.value = listPowerLevelStability.value.map((item, index: number) => {
            return {
              ...item,
              testValueSix: listPowerLevelRepeatability.value[index].averageValue, //	测量差值
              testValueSixDate: props.checkDate, //	核查读数6日期(本次核查日期)
            }
          })
          break
        case '信号源核查':
          listRelativeLevelRepeatability.value = result.map((item: any) => ({ ...item, showUnitData: item.unit }))
          // 填充稳定性最后一列的日期和数值
          listRelativeLevelStability.value = listRelativeLevelStability.value.map((item, index: number) => {
            return {
              ...item,
              testValueSix: listRelativeLevelRepeatability.value[index].averageValue, //	测量差值
              testValueSixDate: props.checkDate, //	核查读数6日期(本次核查日期)
            }
          })
          break
      }
    }
    else if (current.value === 'stability') { // 稳定性
      const resultList = res.data.map((item: any) => {
        return {
          ...item,
          lessThanValue: (`${item.lessThan}` === '1' || `${item.lessThan}` === '') ? '合格' : '不合格',
          // checkPointDefineFront: item.checkPoint + item.unit, // 核查点
          // powerDefineFront: item.power + item.powerUnit, // 函数信号发生器核查
          // relativeLevelDefineFront: item.relativeLevel + item.relativeLevelUnit, // 信号源核查
          // frequencyDeviationDefineFront: item.frequencyDeviation + item.frequencyDeviationUnit, //	平坦度单位
          // phaseDeviationDefineFront: item.phaseDeviation + item.phaseDeviationUnit, //	调相相偏单位
          editable: props.pageType !== 'detail',
        }
      })
      listFrequencyStability.value = resultList.filter((item: { params: string }) => item.params === '铯原子频标核查')
      listPowerLevelStability.value = resultList.filter((item: { params: string }) => item.params === '函数信号发生器核查')
      listRelativeLevelStability.value = resultList.filter((item: { params: string }) => item.params === '信号源核查')

      // 计算稳定性考核是否合格
      if (resultList.every((item: { lessThanValue: string | number }) => item.lessThanValue === '合格')) {
        form.value.qualified = '合格'
      }
      else {
        form.value.qualified = '不合格'
      }
    }

    // 重复性Loading
    listFrequencyRepeatabilityLoading.value = false
    listPowerLevelRepeatabilityLoading.value = false
    listRelativeLevelRepeatabilityLoading.value = false
    // 稳定性loading
    listFrequencyStabilityLoading.value = false // 铯原子频标核查-稳定性
    listPowerLevelStabilityLoading.value = false // 函数信号发生器核查-稳定性
    listRelativeLevelStabilityLoading.value = false // 信号源核查-稳定性
  }).catch(() => {
    // 重复性Loading
    listFrequencyRepeatabilityLoading.value = false
    listPowerLevelRepeatabilityLoading.value = false
    listRelativeLevelRepeatabilityLoading.value = false
    // 稳定性loading
    listFrequencyStabilityLoading.value = false // 铯原子频标核查-稳定性
    listPowerLevelStabilityLoading.value = false // 函数信号发生器核查-稳定性
    listRelativeLevelStabilityLoading.value = false // 信号源核查-稳定性
  })
}
// ------------------------------------------------------------------------------------------
// 处理详情数据
const solveGetDetailData = (responseList: any) => {
  console.log('处理详情数据', props.pageType)
  form.value.qualified = responseList[0].qualified === 1 ? '合格' : '不合格'
  const list = responseList.map((item: any) => {
    return {
      ...item,
      editable: props.pageType !== 'detail',
      lessThanValue: `${item.lessThan}` === '1' ? '合格' : '不合格',
      testValueOne: item.checkType === '稳定性' ? item.testValueOne : Number(item.testValueOne), //	测量值1/测量值(上升时间)
      testValueTwo: item.checkType === '稳定性' ? item.testValueTwo : Number(item.testValueTwo), //	测量值2(示值)
      testValueThree: item.checkType === '稳定性' ? item.testValueThree : Number(item.testValueThree), //	测量值3(示值)
      testValueFour: item.checkType === '稳定性' ? item.testValueFour : Number(item.testValueFour), //	测量值4(示值)
      testValueFive: item.checkType === '稳定性' ? item.testValueFive : Number(item.testValueFive), //	测量值5(示值)
      testValueSix: item.checkType === '稳定性' ? item.testValueSix : Number(item.testValueSix), //	测量值6(本次示值)
      testValueSeven: item.checkType === '稳定性' ? item.testValueSeven : Number(item.testValueSeven), //	测量值7
      testValueEight: item.checkType === '稳定性' ? item.testValueEight : Number(item.testValueEight), //	测量值8
      testValueNine: item.checkType === '稳定性' ? item.testValueNine : Number(item.testValueNine), //	测量值9
      testValueTen: item.checkType === '稳定性' ? item.testValueTen : Number(item.testValueTen), //	测量值10
    }
  })

  const listFrequencyRepeatability = list.filter((item: { params: string; checkType: string }) => item.checkType === '重复性' && (item.params === '铯原子频标核查' || item.params === '1')) // 铯原子频标核查-重复性
  const listPowerLevelRepeatability = list.filter((item: { params: string; checkType: string }) => item.checkType === '重复性' && (item.params === '函数信号发生器核查' || item.params === '2')) // 函数信号发生器核查-重复性
  const listRelativeLevelRepeatability = list.filter((item: { params: string; checkType: string }) => item.checkType === '重复性' && (item.params === '信号源核查' || item.params === '3')) // 信号源核查-重复性

  // 稳定性
  const listFrequencyStability = list.filter((item: { params: string; checkType: string }) => item.checkType === '稳定性' && (item.params === '铯原子频标核查' || item.params === '1')) // 铯原子频标核查-稳定性
  const listPowerLevelStability = list.filter((item: { params: string; checkType: string }) => item.checkType === '稳定性' && (item.params === '函数信号发生器核查' || item.params === '2')) // 函数信号发生器核查-稳定性
  const listRelativeLevelStability = list.filter((item: { params: string; checkType: string }) => item.checkType === '稳定性' && (item.params === '信号源核查' || item.params === '3')) // 信号源核查 -稳定性
  return {
    templistFrequencyRepeatability: listFrequencyRepeatability,
    templistPowerLevelRepeatability: listPowerLevelRepeatability,
    templistRelativeLevelRepeatability: listRelativeLevelRepeatability,

    templistFrequencyStability: listFrequencyStability,
    templistPowerLevelStability: listPowerLevelStability,
    templistRelativeLevelStability: listRelativeLevelStability,
  }
}

// 获取详情
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 {
      templistFrequencyRepeatability,
      templistPowerLevelRepeatability,
      templistRelativeLevelRepeatability,

      templistFrequencyStability,
      templistPowerLevelStability,
      templistRelativeLevelStability,
    } = solveGetDetailData(res.data.checkDataCesiumAtomList)
    if (id !== '') { // 查询的日期获得的数据
      listFrequencyRepeatabilityCheckDate.value = templistFrequencyRepeatability// 铯原子频标核查-重复性
      listPowerLevelRepeatabilityCheckDate.value = templistPowerLevelRepeatability// 函数信号发生器核查-重复性
      listRelativeLevelRepeatabilityCheckDate.value = templistRelativeLevelRepeatability// 信号源核查-重复性

      listFrequencyStabilityCheckDate.value = templistFrequencyStability// 铯原子频标核查-稳定性
      listPowerLevelStabilityCheckDate.value = templistPowerLevelStability// 函数信号发生器核查-稳定性
      listRelativeLevelStabilityCheckDate.value = templistRelativeLevelStability// 信号源核查-稳定性
    }
    else {
      listFrequencyRepeatability.value = templistFrequencyRepeatability// 铯原子频标核查-重复性
      listPowerLevelRepeatability.value = templistPowerLevelRepeatability// 函数信号发生器核查-重复性
      listRelativeLevelRepeatability.value = templistRelativeLevelRepeatability// 信号源核查-重复性

      listFrequencyStability.value = templistFrequencyStability// 铯原子频标核查-稳定性
      listPowerLevelStability.value = templistPowerLevelStability// 函数信号发生器核查-稳定性
      listRelativeLevelStability.value = templistRelativeLevelStability// 信号源核查-稳定性
    }

    nextTick(() => {
      if (id !== '') { // 稳定性表头---查询历史的稳定性日期数据
        const tempColumn = [
          { 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 },
        ] as any
        columns_stability_frequency.value[3].children = [...tempColumn]
        columns_stability_power_level.value[3].children = [...tempColumn]
        columns_stability_relative_level.value[3].children = [...tempColumn]

        fetchHistoryIndication(currentDate.value) // 获取稳定性
      }
      else { // 正常核查数据处理表头
        columns_stability_frequency.value = handleDetailTableTableHead(columns_stability_frequency.value, listFrequencyStability.value, 3)
        columns_stability_power_level.value = handleDetailTableTableHead(columns_stability_power_level.value, listPowerLevelStability.value, 3)
        columns_stability_relative_level.value = handleDetailTableTableHead(columns_stability_relative_level.value, listRelativeLevelStability.value, 3)
      }
    })

    if (props.pageType === 'edit' || props.pageType === 'detail') {
      fetchHistoryIndication() // 重新拉取稳定性日期
    }
    loading.close()
  })
}

/**
 * 获取稳定性示值
 * @param date 查询日期
 */
function fetchHistoryIndication(date = '') {
  if (!equipmentId.value || !props.selectStandardId) { return false }
  const params = {
    belongStandardEquipment: belongStandardEquipment.value,	// 检校标准装置(字典code)
    checkDate: date || props.checkDate!,	// 核查日期
    checkParam: '',	// 核查参数
    conclusion: '合格',	// 结论
    equipmentId: equipmentId.value,	// 被核查设备id
    params: '',	// 核查项目
    stabilityExamine: '1',	// 是否用于稳定性考核(1/0)
    standardEquipmentId: props.selectStandardId!,	// 被核查标准装置id
  }
  if (props.selectStandardId && equipmentId.value) {
    // 稳定性Loading
    listFrequencyStabilityLoading.value = true // 铯原子频标核查-稳定性
    listPowerLevelStabilityLoading.value = true // 函数信号发生器核查-稳定性
    listRelativeLevelStabilityLoading.value = true // 信号源核查-稳定性
  }
  getHistoryIndication(params).then((res) => {
    if (date === '') { // 正常核查数据
      const num = (props.pageType === 'edit' || props.pageType === 'detail') ? 5 : 4
      // '铯原子频标核查':
      listFrequencyStability.value = listFrequencyStability.value.map((item) => {
        const { itemData, columnsData } = solveHistoryIndicationTableData(res.data.data.filter((item: { params: string }) => item.params === '铯原子频标核查' || item.params === '1'), item, columns_stability_frequency.value, num, 3, '14')
        columns_stability_frequency.value = columnsData
        return item = itemData
      })
      listFrequencyStability.value = handleSaveDateParams(columns_stability_frequency.value, listFrequencyStability.value, 3)
      //  '函数信号发生器核查':
      listPowerLevelStability.value = listPowerLevelStability.value.map((item) => {
        const { itemData, columnsData } = solveHistoryIndicationTableData(res.data.data.filter((item: { params: string }) => item.params === '函数信号发生器核查' || item.params === '2'), item, columns_stability_power_level.value, num, 3, '14')
        columns_stability_power_level.value = columnsData
        return item = itemData
      })
      listPowerLevelStability.value = handleSaveDateParams(columns_stability_power_level.value, listPowerLevelStability.value, 3)
      //  '信号源核查':
      listRelativeLevelStability.value = listRelativeLevelStability.value.map((item) => {
        const { itemData, columnsData } = solveHistoryIndicationTableData(res.data.data.filter((item: { params: string }) => item.params === '信号源核查' || item.params === '3'), item, columns_stability_relative_level.value, num, 3, '14')
        columns_stability_relative_level.value = columnsData
        return item = itemData
      })
      listRelativeLevelStability.value = handleSaveDateParams(columns_stability_relative_level.value, listRelativeLevelStability.value, 3)
    }
    else {
      initColumnsCheckDate()
      const num = 5
      // '铯原子频标核查':
      listFrequencyStabilityCheckDate.value = listFrequencyStabilityCheckDate.value.map((item) => {
        clearDateValue(item)
        const { itemData, columnsData } = solveHistoryIndicationTableData(res.data.data.filter((item: { params: string }) => item.params === '铯原子频标核查' || item.params === '1'), item, columns_stability_frequency_checkDate.value, num, 3, '14')
        columns_stability_frequency_checkDate.value = columnsData
        return item = itemData
      })
      listFrequencyStabilityCheckDate.value = handleSaveDateParams(columns_stability_frequency_checkDate.value, listFrequencyStabilityCheckDate.value, 3)
      //  '函数信号发生器核查':
      listPowerLevelStabilityCheckDate.value = listPowerLevelStabilityCheckDate.value.map((item) => {
        clearDateValue(item)
        const { itemData, columnsData } = solveHistoryIndicationTableData(res.data.data.filter((item: { params: string }) => item.params === '函数信号发生器核查' || item.params === '2'), item, columns_stability_power_level_checkDate.value, num, 3, '14')
        columns_stability_power_level_checkDate.value = columnsData
        return item = itemData
      })
      listPowerLevelStabilityCheckDate.value = handleSaveDateParams(columns_stability_power_level_checkDate.value, listPowerLevelStabilityCheckDate.value, 3)
      //  '信号源核查':
      listRelativeLevelStabilityCheckDate.value = listRelativeLevelStabilityCheckDate.value.map((item) => {
        clearDateValue(item)
        const { itemData, columnsData } = solveHistoryIndicationTableData(res.data.data.filter((item: { params: string }) => item.params === '信号源核查' || item.params === '3'), item, columns_stability_relative_level_checkDate.value, num, 3, '14')
        columns_stability_relative_level_checkDate.value = columnsData
        return item = itemData
      })
      listRelativeLevelStabilityCheckDate.value = handleSaveDateParams(columns_stability_relative_level_checkDate.value, listRelativeLevelStabilityCheckDate.value, 3)
    }

    listFrequencyStabilityLoading.value = false // 铯原子频标核查-稳定性
    listPowerLevelStabilityLoading.value = false // 函数信号发生器核查-稳定性
    listRelativeLevelStabilityLoading.value = false // 信号源核查-稳定性
  }).catch(() => {
    listFrequencyStabilityLoading.value = false // 铯原子频标核查-稳定性
    listPowerLevelStabilityLoading.value = false // 函数信号发生器核查-稳定性
    listRelativeLevelStabilityLoading.value = false // 信号源核查-稳定性
  })
}

/**
 * 保存之前的校验
 */
function checkList() {
  // 新建核查数据的时候,在保存之前要先校验一下本次核查日期有没有数据,没有不允许保存
  if (listFrequencyRepeatability.value.length && `${listFrequencyRepeatability.value[0].averageValue}` === '') {
    ElMessage.warning('请先计算 铯原子频标核查 的重复性')
    return false
  }
  if (listPowerLevelRepeatability.value.length && `${listPowerLevelRepeatability.value[0].averageValue}` === '') {
    ElMessage.warning('请先计算 函数信号发生器核查 重复性')
    return false
  }
  if (listRelativeLevelRepeatability.value.length && `${listRelativeLevelRepeatability.value[0].averageValue}` === '') {
    ElMessage.warning('请先计算 信号源核查 重复性')
    return false
  }
  return true
}

// 保存之前处理数据
const solveDataBeforeSave = () => {
  // 数据处理
  let tempList = [] as any

  tempList = tempList.concat(
    // 重复性
    listFrequencyRepeatability.value, // 铯原子频标核查-重复性
    listPowerLevelRepeatability.value, // 函数信号发生器核查-重复性
    listRelativeLevelRepeatability.value, // 信号源核查-重复性
    listFrequencyStability.value, // 铯原子频标核查-稳定性
    listPowerLevelStability.value, // 函数信号发生器核查-稳定性
    listRelativeLevelStability.value, // 信号源核查-稳定性
  )
  return tempList
}

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

// 日期变化
const handleChangeRadio = (date: string) => {
  currentDate.value = date
}

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

  // 统计有几个日期
  columns[3].children?.forEach((item) => {
    if (item.text !== '-' && item.text !== '') {
      dateNum += 1
    }
  })
  return dateNum
}

watch(() => props.pageType, (newValue) => {
  if (newValue === 'detail') {
    listFrequencyRepeatability.value = listFrequencyRepeatability.value.map(item => ({ ...item, editable: false }))
    listPowerLevelRepeatability.value = listPowerLevelRepeatability.value.map(item => ({ ...item, editable: false }))
    listRelativeLevelRepeatability.value = listRelativeLevelRepeatability.value.map(item => ({ ...item, editable: false }))
  }
})
/**
 * 初始化表头
 * @param soveLastColumnDate 是否处理最后一列
 */
function initColumns() {
  const tempColumn = [
    { 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 },
  ] as any
  columns_stability_frequency.value[3].children = [...tempColumn]
  columns_stability_power_level.value[3].children = [...tempColumn]
  columns_stability_relative_level.value[3].children = [...tempColumn]

  columns_stability_frequency.value[3].children![5].text = props.checkDate! // 最后一列的表头日期
  columns_stability_power_level.value[3].children![5].text = props.checkDate! // 最后一列的表头日期
  columns_stability_relative_level.value[3].children![5].text = props.checkDate!
}
/**
 * 初始化CheckDate表头
 * @param soveLastColumnDate 是否处理最后一列
 */
function initColumnsCheckDate() {
  columns_stability_frequency_checkDate.value[2].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 },
  ]
  columns_stability_power_level_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 },
  ]
  columns_stability_relative_level_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 },
  ]
}
// 监听核查日期变化
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, checkList, solveDataBeforeSave, form })
</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>
    <!-- 铯原子频标核查 -->
    <template v-if="listFrequencyRepeatability.length">
      <div style="display: flex;justify-content: space-between;align-items: center;">
        <h5>铯原子频标核查</h5>
        <el-button v-if="pageType !== 'detail' && current === 'repeatability'" type="primary" @click="createResult('铯原子频标核查')">
          计算结果
        </el-button>
        <el-button
          v-if="pageType !== 'detail' && current === 'stability'" type="primary"
          @click="createResult('stability')"
        >
          计算结果
        </el-button>
      </div>
      <multi-table
        v-show="current === 'repeatability' && (currentDate === '核查数据' || currentDate === '')"
        v-loading="listFrequencyRepeatabilityLoading" :table-data="listFrequencyRepeatability"
        :table-header="columns_repeatability_frequency" :merge-rows="[]" :need-index="true" max-height="300"
      />
      <!-- 历史日期重复性数据 -->
      <multi-table
        v-show="current === 'repeatability' && (currentDate !== '核查数据' && currentDate !== '')"
        v-loading="listFrequencyRepeatabilityLoading" :table-data="listFrequencyRepeatabilityCheckDate"
        :table-header="columns_repeatability_frequency" :merge-rows="[]" :need-index="true" max-height="300"
      />

      <!-- 铯原子频标核查稳定性  -->
      <multi-table
        v-show="current === 'stability' && (currentDate === '核查数据' || currentDate === '')"
        v-loading="listFrequencyStabilityLoading" :table-data="listFrequencyStability"
        :table-header="columns_stability_frequency" :merge-rows="[]" :need-index="true" max-height="500"
        @handle-click-header="handleClickHeader"
      />
      <!-- 历史日期稳定性数据 -->
      <multi-table
        v-show="current === 'stability' && (currentDate !== '核查数据' && currentDate !== '')"
        v-loading="listFrequencyStabilityLoading" :table-data="listFrequencyStabilityCheckDate"
        :table-header="columns_stability_frequency_checkDate" :merge-rows="[]" :need-index="true" max-height="500"
        @handle-click-header="handleClickHeader"
      />
    </template>

    <!-- 函数信号发生器核查 -->
    <template v-if="listPowerLevelRepeatability.length">
      <div style="display: flex;justify-content: space-between;align-items: center;">
        <h5>函数信号发生器核查</h5>
        <el-button
          v-if="pageType !== 'detail' && current === 'repeatability'" type="primary"
          @click="createResult('函数信号发生器核查')"
        >
          计算结果
        </el-button>
      </div>
      <multi-table
        v-show="current === 'repeatability' && (currentDate === '核查数据' || currentDate === '')"
        v-loading="listPowerLevelRepeatabilityLoading" :table-data="listPowerLevelRepeatability"
        :table-header="columns_repeatability_power_level" :merge-rows="[]" :need-index="true" max-height="300"
      />
      <!-- 历史日期重复性数据 -->
      <multi-table
        v-show="current === 'repeatability' && (currentDate !== '核查数据' && currentDate !== '')"
        v-loading="listPowerLevelRepeatabilityLoading" :table-data="listPowerLevelRepeatabilityCheckDate"
        :table-header="columns_repeatability_power_level" :merge-rows="[]" :need-index="true" max-height="300"
      />

      <!-- 函数信号发生器核查稳定性  -->
      <multi-table
        v-show="current === 'stability' && (currentDate === '核查数据' || currentDate === '')"
        v-loading="listPowerLevelStabilityLoading" :table-data="listPowerLevelStability"
        :table-header="columns_stability_power_level" :merge-rows="[]" :need-index="true" max-height="500"
        @handle-click-header="handleClickHeader"
      />
      <!-- 历史日期稳定性数据 -->
      <multi-table
        v-show="current === 'stability' && (currentDate !== '核查数据' && currentDate !== '')"
        v-loading="listPowerLevelStabilityLoading" :table-data="listPowerLevelStabilityCheckDate"
        :table-header="columns_stability_power_level_checkDate" :merge-rows="[]" :need-index="true" max-height="500"
        @handle-click-header="handleClickHeader"
      />
    </template>

    <!-- 信号源核查 -->
    <template v-if="listRelativeLevelRepeatability.length">
      <div style="display: flex;justify-content: space-between;align-items: center;">
        <h5>信号源核查</h5>
        <el-button
          v-if="pageType !== 'detail' && current === 'repeatability'" type="primary"
          @click="createResult('信号源核查')"
        >
          计算结果
        </el-button>
      </div>
      <multi-table
        v-show="current === 'repeatability' && (currentDate === '核查数据' || currentDate === '')"
        v-loading="listRelativeLevelRepeatabilityLoading" :table-data="listRelativeLevelRepeatability"
        :table-header="columns_repeatability_relative_level" :merge-rows="[]" :need-index="true" max-height="300"
      />
      <!-- 历史日期重复性数据 -->
      <multi-table
        v-show="current === 'repeatability' && (currentDate !== '核查数据' && currentDate !== '')"
        v-loading="listRelativeLevelRepeatabilityLoading" :table-data="listRelativeLevelRepeatabilityCheckDate"
        :table-header="columns_repeatability_relative_level" :merge-rows="[]" :need-index="true" max-height="300"
      />

      <!-- 稳定性  -->
      <multi-table
        v-show="current === 'stability' && (currentDate === '核查数据' || currentDate === '')"
        v-loading="listRelativeLevelStabilityLoading" :table-data="listRelativeLevelStability"
        :table-header="columns_stability_relative_level" :merge-rows="[]" :need-index="true" max-height="500"
        @handle-click-header="handleClickHeader"
      />
      <!-- 历史日期稳定性数据 -->
      <multi-table
        v-show="current === 'stability' && (currentDate !== '核查数据' && currentDate !== '')"
        v-loading="listRelativeLevelStabilityLoading" :table-data="listRelativeLevelStabilityCheckDate"
        :table-header="columns_stability_relative_level_checkDate" :merge-rows="[]" :need-index="true" max-height="500"
        @handle-click-header="handleClickHeader"
      />
    </template>

    <el-form
      v-if="current === 'stability'" style="margin-top: 20px;" :model="form" label-width="160"
      label-position="right"
    >
      <el-row :gutter="24">
        <el-col :span="12">
          <el-form-item label="稳定性考核是否合格:">
            <el-input
              v-model="form.qualified" class="full-width-input" disabled
              :placeholder="pageType === 'detail' ? ' ' : '稳定性考核是否合格'"
            />
          </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>

    <!-- 保存核查记录  -->
    <save-check-record ref="saveCheckRecordRef" />
  </detail-block>
</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>