Newer
Older
xc-business-system / src / views / equipement / standard / checkData / components / seventeenth / checkDataCom.vue
dutingting on 29 Nov 68 KB 解决冲突
<!-- 核查数据管理详情--核查数据---第17套:S参数 -->
<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 './tenth-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'
import { getDataNum, getDataUnit } from '@/utils/validate'
import { useRound } from '@/commonMethods/useRound'
import { useScientificNotation } from '@/commonMethods/useScientificNotation'
const props = defineProps({
  selectStandardId: { // 选择的标准库id
    type: String,
  },
  pageType: { // 页面类型
    type: String,
  },
  checkDate: { // 核查日期
    type: String,
  },
})

const emits = defineEmits(['isConfigCheck'])

const user = useUserStore() // 用户信息
const $router = useRouter() // 关闭页面使用
const $route = useRoute() // 路由参数
const infoId = ref('')
const belongStandardEquipment = ref('17')
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_mismatch = ref<TableColumn[]>([ // 重复性表头--失配测量
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '类型', value: 'typeValue', align: 'center', required: true, type: 'text' },
  { text: 'VSMR', value: 'vsmr', align: 'center', required: true, type: 'text' },
  { text: '频率', value: 'frequencyDefineFront', 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: '220', type: 'inputNumber', precision: 3 },
      { text: '第2次', value: 'testValueTwo', align: 'center', required: true, width: '220', type: 'inputNumber', precision: 3 },
      { text: '第3次', value: 'testValueThree', align: 'center', required: true, width: '220', type: 'inputNumber', precision: 3 },
      { text: '第4次', value: 'testValueFour', align: 'center', required: true, width: '220', type: 'inputNumber', precision: 3 },
      { text: '第5次', value: 'testValueFive', align: 'center', required: true, width: '220', type: 'inputNumber', precision: 3 },
      { text: '第6次', value: 'testValueSix', align: 'center', required: true, width: '220', type: 'inputNumber', precision: 3 },
      { text: '第7次', value: 'testValueSeven', align: 'center', required: true, width: '220', type: 'inputNumber', precision: 3 },
      { text: '第8次', value: 'testValueEight', align: 'center', required: true, width: '220', type: 'inputNumber', precision: 3 },
      { text: '第9次', value: 'testValueNine', align: 'center', required: true, width: '220', type: 'inputNumber', precision: 3 },
      { text: '第10次', value: 'testValueTen', align: 'center', required: true, width: '220', type: 'inputNumber', 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_attenuation = ref<TableColumn[]>([ // 重复性表头--衰减测量
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '类型', value: 'typeValue', align: 'center', required: true, type: 'text' },
  { text: '频率', value: 'frequencyDefineFront', align: 'center', required: true, type: 'text' },
  { text: '幅度', value: 'amplitudeDefineFront', 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: '220', type: 'inputNumber', showUnit: true, precision: 3 },
      { text: '第2次', value: 'testValueTwo', align: 'center', required: true, width: '220', type: 'inputNumber', showUnit: true, precision: 3 },
      { text: '第3次', value: 'testValueThree', align: 'center', required: true, width: '220', type: 'inputNumber', showUnit: true, precision: 3 },
      { text: '第4次', value: 'testValueFour', align: 'center', required: true, width: '220', type: 'inputNumber', showUnit: true, precision: 3 },
      { text: '第5次', value: 'testValueFive', align: 'center', required: true, width: '220', type: 'inputNumber', showUnit: true, precision: 3 },
      { text: '第6次', value: 'testValueSix', align: 'center', required: true, width: '220', type: 'inputNumber', showUnit: true, precision: 3 },
      { text: '第7次', value: 'testValueSeven', align: 'center', required: true, width: '220', type: 'inputNumber', showUnit: true, precision: 3 },
      { text: '第8次', value: 'testValueEight', align: 'center', required: true, width: '220', type: 'inputNumber', showUnit: true, precision: 3 },
      { text: '第9次', value: 'testValueNine', align: 'center', required: true, width: '220', type: 'inputNumber', showUnit: true, precision: 3 },
      { text: '第10次', value: 'testValueTen', align: 'center', required: true, width: '220', type: 'inputNumber', showUnit: true, 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_phase = ref<TableColumn[]>([ // 重复性表头--相移测量
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '类型', value: 'typeValue', align: 'center', required: true, type: 'text' },
  { text: '频率', value: 'frequencyDefineFront', align: 'center', required: true, type: 'text' },
  { text: '相位', value: 'phaseDefineFront', 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: '220', type: 'inputNumber', showUnit: true, precision: 3 },
      { text: '第2次', value: 'testValueTwo', align: 'center', required: true, width: '220', type: 'inputNumber', showUnit: true, precision: 3 },
      { text: '第3次', value: 'testValueThree', align: 'center', required: true, width: '220', type: 'inputNumber', showUnit: true, precision: 3 },
      { text: '第4次', value: 'testValueFour', align: 'center', required: true, width: '220', type: 'inputNumber', showUnit: true, precision: 3 },
      { text: '第5次', value: 'testValueFive', align: 'center', required: true, width: '220', type: 'inputNumber', showUnit: true, precision: 3 },
      { text: '第6次', value: 'testValueSix', align: 'center', required: true, width: '220', type: 'inputNumber', showUnit: true, precision: 3 },
      { text: '第7次', value: 'testValueSeven', align: 'center', required: true, width: '220', type: 'inputNumber', showUnit: true, precision: 3 },
      { text: '第8次', value: 'testValueEight', align: 'center', required: true, width: '220', type: 'inputNumber', showUnit: true, precision: 3 },
      { text: '第9次', value: 'testValueNine', align: 'center', required: true, width: '220', type: 'inputNumber', showUnit: true, precision: 3 },
      { text: '第10次', value: 'testValueTen', align: 'center', required: true, width: '220', type: 'inputNumber', showUnit: true, 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_mismatch = ref<TableColumn[]>([ // 稳定性表头--失配测量
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '类型', value: 'typeValue', align: 'center', required: true, type: 'text' },
  { text: 'VSMR', value: 'vsmr', align: 'center', required: true, type: 'text' },
  { text: '频率', value: 'frequencyDefineFront', align: 'center', required: true, type: 'text' },
  {
    text: '测量值',
    value: '-',
    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: 'averageValue', align: 'center', required: false, type: 'text' },
  { text: '稳定性', value: 'stability', align: 'center', required: false, type: 'text' },
  { text: 'U(k=2)', value: 'urel', align: 'center', required: true, type: 'text' },
  { text: '结论', value: 'lessThan', align: 'center', required: false, type: 'text' },
])
const columns_stability_mismatch_checkDate = ref<TableColumn[]>([ // 稳定性表头--失配测量
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '类型', value: 'typeValue', align: 'center', required: true, type: 'text' },
  { text: 'VSMR', value: 'vsmr', align: 'center', required: true, type: 'text' },
  { text: '频率', value: 'frequencyDefineFront', align: 'center', required: true, type: 'text' },
  {
    text: '测量值',
    value: '-',
    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: 'averageValue', align: 'center', required: false, type: 'text' },
  { text: '稳定性', value: 'stability', align: 'center', required: false, type: 'text' },
  { text: 'U(k=2)', value: 'urel', align: 'center', required: true, type: 'text' },
  { text: '结论', value: 'lessThan', align: 'center', required: false, type: 'text' },
])

const columns_stability_attenuation = ref<TableColumn[]>([ // 稳定性表头--衰减测量
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '类型', value: 'typeValue', align: 'center', required: true, type: 'text' },
  { text: '频率', value: 'frequencyDefineFront', align: 'center', required: true, type: 'text' },
  { text: '幅度', value: 'amplitudeDefineFront', align: 'center', required: true, type: 'text' },
  {
    text: '测量值',
    value: '-',
    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: 'averageValue', align: 'center', required: false, type: 'text' },
  { text: '稳定性', value: 'stability', align: 'center', required: false, type: 'text' },
  { text: 'U(k=2)', value: 'urel', align: 'center', required: true, type: 'text' },
  { text: '结论', value: 'lessThan', align: 'center', required: false, type: 'text' },
])
const columns_stability_attenuation_checkDate = ref<TableColumn[]>([ // 稳定性表头--衰减测量
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '类型', value: 'typeValue', align: 'center', required: true, type: 'text' },
  { text: '频率', value: 'frequencyDefineFront', align: 'center', required: true, type: 'text' },
  { text: '幅度', value: 'amplitudeDefineFront', align: 'center', required: true, type: 'text' },
  {
    text: '测量值',
    value: '-',
    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: 'averageValue', align: 'center', required: false, type: 'text' },
  { text: '稳定性', value: 'stability', align: 'center', required: false, type: 'text' },
  { text: 'U(k=2)', value: 'urel', align: 'center', required: true, type: 'text' },
  { text: '结论', value: 'lessThan', align: 'center', required: false, type: 'text' },
])

const columns_stability_phase = ref<TableColumn[]>([ // 稳定性表头--相移测量
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '类型', value: 'typeValue', align: 'center', required: true, type: 'text' },
  { text: '频率', value: 'frequencyDefineFront', align: 'center', required: true, type: 'text' },
  { text: '相位', value: 'phaseDefineFront', align: 'center', required: true, type: 'text' },
  {
    text: '测量值',
    value: '-',
    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: 'averageValue', align: 'center', required: false, type: 'text' },
  { text: '稳定性', value: 'stability', align: 'center', required: false, type: 'text' },
  { text: 'U(k=2)', value: 'urel', align: 'center', required: true, type: 'text' },
  { text: '结论', value: 'lessThan', align: 'center', required: false, type: 'text' },
])
const columns_stability_phase_checkDate = ref<TableColumn[]>([ // 稳定性表头--相移测量
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '类型', value: 'typeValue', align: 'center', required: true, type: 'text' },
  { text: '频率', value: 'frequencyDefineFront', align: 'center', required: true, type: 'text' },
  { text: '相位', value: 'phaseDefineFront', align: 'center', required: true, type: 'text' },
  {
    text: '测量值',
    value: '-',
    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: 'averageValue', align: 'center', required: false, type: 'text' },
  { text: '稳定性', value: 'stability', align: 'center', required: false, type: 'text' },
  { text: 'U(k=2)', value: 'urel', align: 'center', required: true, type: 'text' },
  { text: '结论', value: 'lessThan', align: 'center', required: false, type: 'text' },
])

// 重复性
const listMismatchRepeatability = ref<IList[]>([]) // 失配测量-重复性
const listAttenuationRepeatability = ref<IList[]>([]) // 衰减测量-重复性
const listPhaseRepeatability = ref<IList[]>([]) // 相移测量-重复性

// 重复性checkDate
const listMismatchRepeatabilityCheckDate = ref<IList[]>([]) // 失配测量-重复性
const listAttenuationRepeatabilityCheckDate = ref<IList[]>([]) // 衰减测量-重复性
const listPhaseRepeatabilityCheckDate = ref<IList[]>([]) // 相移测量-重复性

// 重复性Loading
const listMismatchRepeatabilityLoading = ref(false) // 失配测量-重复性
const listAttenuationRepeatabilityLoading = ref(false) // 衰减测量-重复性
const listPhaseRepeatabilityLoading = ref(false) // 相移测量-重复性

// 稳定性
const listMismatchStability = ref<any[]>([]) // 失配测量-稳定性
const listAttenuationStability = ref<any[]>([]) // 衰减测量-稳定性
const listPhaseStability = ref<any[]>([]) // 相移测量-稳定性

// 稳定性checkDate
const listMismatchStabilityCheckDate = ref<any[]>([]) // 失配测量-稳定性
const listAttenuationStabilityCheckDate = ref<any[]>([]) // 衰减测量-稳定性
const listPhaseStabilityCheckDate = ref<any[]>([]) // 相移测量-稳定性

// 稳定性Loading
const listMismatchStabilityLoading = ref(false) // 失配测量-稳定性
const listAttenuationStabilityLoading = ref(false) // 衰减测量-稳定性
const listPhaseStabilityLoading = 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()
    if (!res.data) {
      emits('isConfigCheck', false)
    }
    else {
      handleData(res.data.checkItemDataSParamList)
      fetchHistoryIndication() // 重新拉取稳定性
    }
  })
}

// 初始化数据(查询配置检定项)
function handleData(list: any, type = 'edit') {
  // 失配测量
  listMismatchRepeatability.value = list.filter((item: { params: string }) => item.params === '失配测量')
  // 失配测量重复性
  listMismatchRepeatability.value = listMismatchRepeatability.value.map((e: any) => {
    return {
      editable: type === 'edit',
      dataId: e.id, //	核查数据管理基础信息表id
      id: '', //	id,更新/删除使用参数
      checkType: '重复性',
      dataType: '1',
      params: e.params, // 核查项目
      typeValue: e.typeValue, // 类型
      vsmr: e.vswr, // VSMR
      frequency: e.frequency, //	频率
      frequencyUnit: e.frequencyUnit, //	频率单位
      frequencyDefineFront: e.frequency + e.frequencyUnit, // 频率
      averageValue: '', // 平均值
      standardDeviation: '', // 重复性
      urel: e.urel, // u(k=2)

      testValueOne: undefined, //	测量值1
      testValueTwo: undefined, //	测量值2
      testValueThree: undefined, //	测量值3
      testValueFour: undefined, //	测量值4
      testValueFive: undefined, //	测量值5
      testValueSix: undefined, //	测量值6
      testValueSeven: undefined, //	测量值7
      testValueEight: undefined, //	测量值8
      testValueNine: undefined, //	测量值9
      testValueTen: undefined, //	测量值10
    }
  }) as any
  // 失配测量稳定性
  listMismatchStability.value = listMismatchRepeatability.value.map((e: any) => {
    return {
      editable: props.pageType !== 'detail',
      dataId: e.dataId, //	核查数据管理基础信息表id
      id: '', //	id,更新/删除使用参数
      params: e.params, // 核查项目
      dataType: '1',
      checkPoint: e.checkPoint,
      unit: e.unit, //	单位(直接存字典value)
      typeValue: e.typeValue, // 类型
      vsmr: e.vsmr, // VSMR
      frequency: e.frequency, //	频率
      frequencyUnit: e.frequencyUnit, //	频率单位
      frequencyDefineFront: e.frequency + e.frequencyUnit, // 频率
      checkType: '稳定性',
      urel: e.urel, // u(k=2)
      averageValue: '', // 平均值
      stability: '', // 稳定性
      lessThan: '', // 结论
    }
  })

  // 衰减测量
  listAttenuationRepeatability.value = list.filter((item: { params: string }) => item.params === '衰减测量')
  // 衰减测量重复性
  listAttenuationRepeatability.value = listAttenuationRepeatability.value.map((e: any) => {
    return {
      editable: type === 'edit',
      dataId: e.id, //	核查数据管理基础信息表id
      id: '', //	id,更新/删除使用参数
      checkType: '重复性',
      dataType: '2',
      params: e.params, // 核查项目
      typeValue: e.typeValue, // 类型
      frequency: e.frequency, //	频率
      frequencyUnit: e.frequencyUnit, //	频率单位
      frequencyDefineFront: e.frequency + e.frequencyUnit, // 频率
      amplitude: e.amplitude, //	幅度
      amplitudeUnit: e.amplitudeUnit, //	幅度单位
      amplitudeDefineFront: e.amplitude + e.amplitudeUnit, // 幅度
      averageValue: '', // 平均值
      standardDeviation: '', // 重复性
      urel: e.urel, // u(k=2)

      testValueOne: undefined, //	测量值1
      testValueTwo: undefined, //	测量值2
      testValueThree: undefined, //	测量值3
      testValueFour: undefined, //	测量值4
      testValueFive: undefined, //	测量值5
      testValueSix: undefined, //	测量值6
      testValueSeven: undefined, //	测量值7
      testValueEight: undefined, //	测量值8
      testValueNine: undefined, //	测量值9
      testValueTen: undefined, //	测量值10

      showUnitData: e.amplitudeUnit,
    }
  }) as any
  // 衰减测量稳定性
  listAttenuationStability.value = listAttenuationRepeatability.value.map((e: any) => {
    return {
      editable: props.pageType !== 'detail',
      dataId: e.dataId, //	核查数据管理基础信息表id
      id: '', //	id,更新/删除使用参数
      params: e.params, // 核查项目
      dataType: '2',
      typeValue: e.typeValue, // 类型
      frequency: e.frequency, //	频率
      frequencyUnit: e.frequencyUnit, //	频率单位
      frequencyDefineFront: e.frequency + e.frequencyUnit, // 频率
      amplitude: e.amplitude, //	幅度
      amplitudeUnit: e.amplitudeUnit, //	幅度单位
      amplitudeDefineFront: e.amplitude + e.amplitudeUnit, // 幅度
      checkType: '稳定性',
      urel: e.urel, // u(k=2)
      averageValue: '', // 平均值
      stability: '', // 稳定性
      lessThan: '', // 结论
    }
  }) as any
  console.log('00000000000000', listAttenuationStability.value)

  // 相移测量
  listPhaseRepeatability.value = list.filter((item: { params: string }) => item.params === '相移测量')
  // 相移测量重复性
  listPhaseRepeatability.value = listPhaseRepeatability.value.map((e: any) => {
    return {
      editable: type === 'edit',
      dataId: e.id, //	核查数据管理基础信息表id
      id: '', //	id,更新/删除使用参数
      checkType: '重复性',
      dataType: '3',
      params: e.params, // 核查项目
      typeValue: e.typeValue, // 类型
      frequency: e.frequency, //	频率
      frequencyUnit: e.frequencyUnit, //	频率单位
      frequencyDefineFront: e.frequency + e.frequencyUnit, // 频率
      phase: e.phase, //	相位
      phaseUnit: e.phaseUnit, //	相位单位
      phaseDefineFront: e.phase + e.phaseUnit, // 相位
      averageValue: '', // 平均值
      standardDeviation: '', // 重复性
      urel: e.urel, // u(k=2)

      testValueOne: undefined, //	测量值1
      testValueTwo: undefined, //	测量值2
      testValueThree: undefined, //	测量值3
      testValueFour: undefined, //	测量值4
      testValueFive: undefined, //	测量值5
      testValueSix: undefined, //	测量值6
      testValueSeven: undefined, //	测量值7
      testValueEight: undefined, //	测量值8
      testValueNine: undefined, //	测量值9
      testValueTen: undefined, //	测量值10
      showUnitData: e.phaseUnit,
    }
  }) as any
  // 相移测量稳定性
  listPhaseStability.value = listPhaseRepeatability.value.map((e: any) => {
    return {
      editable: props.pageType !== 'detail',
      dataId: e.dataId, //	核查数据管理基础信息表id
      id: '', //	id,更新/删除使用参数
      params: e.params, // 核查项目
      dataType: '3',
      checkPoint: e.checkPoint,
      unit: e.unit, //	单位(直接存字典value)
      typeValue: e.typeValue, // 类型
      frequency: e.frequency, //	频率
      frequencyUnit: e.frequencyUnit, //	频率单位
      frequencyDefineFront: e.frequency + e.frequencyUnit, // 频率
      phase: e.phase, //	相位
      phaseUnit: e.phaseUnit, //	相位单位
      phaseDefineFront: e.phase + e.phaseUnit, // 相位
      checkType: '稳定性',
      urel: e.urel, // u(k=2)
      averageValue: '', // 平均值
      stability: '', // 稳定性
      lessThan: '', // 结论
    }
  }) as any
}

// 点击计算结果
const createResult = (type: string) => {
  let checkDataSParamListParams: any // 要传的重复或者稳定性参数
  if (current.value === 'stability') { // 计算稳定性先校验重复性
    if (!checkList()) { return false }
    const tempList = [] as any
    checkDataSParamListParams = tempList.concat(
      listMismatchStability.value,
      listAttenuationStability.value,
      listPhaseStability.value,
    )
  }

  if (current.value === 'repeatability') {
    switch (type) {
      case '失配测量':
        if (!useCheckList(listMismatchRepeatability.value, columns_repeatability_mismatch.value, `${type}-重复性`)) {
          return false
        }
        checkDataSParamListParams = listMismatchRepeatability.value
        break
      case '衰减测量':
        if (!useCheckList(listAttenuationRepeatability.value, columns_repeatability_attenuation.value, `${type}-重复性`)) {
          return false
        }
        checkDataSParamListParams = listAttenuationRepeatability.value
        break
      case '相移测量':
        if (!useCheckList(listPhaseRepeatability.value, columns_repeatability_phase.value, `${type}-重复性`)) {
          return false
        }
        checkDataSParamListParams = listPhaseRepeatability.value
        break
      default:
        break
    }
  }
  else {
    // 稳定性loading
    listMismatchStabilityLoading.value = true // 失配测量-稳定性
    listAttenuationStabilityLoading.value = true // 衰减测量-稳定性
    listPhaseStabilityLoading.value = true // 相移测量-稳定性
  }

  const params = {
    belongStandardEquipment: belongStandardEquipment.value, // 检校标准库
    checkDataSParamList: checkDataSParamListParams.map((item: IList) => {
      return {
        ...item,
        conclusion: '',
        lessThan: '',
        testValueOne: getDataNum(item.testValueOne) == null ? '' : getDataNum(item.testValueOne), //	测量值1
        testValueTwo: getDataNum(item.testValueTwo) == null ? '' : getDataNum(item.testValueTwo), //	测量值2
        testValueThree: getDataNum(item.testValueThree) == null ? '' : getDataNum(item.testValueThree), //	测量值3
        testValueFour: getDataNum(item.testValueFour) == null ? '' : getDataNum(item.testValueFour), //	测量值4
        testValueFive: getDataNum(item.testValueFive) == null ? '' : getDataNum(item.testValueFive), //	测量值5
        testValueSix: getDataNum(item.testValueSix) == null ? '' : getDataNum(item.testValueSix), //	测量值6
      }
    }),
    itemCategoryId: itemCategoryId.value, // 核查项分类id
    itemCategoryName: itemCategoryName.value, // 核查项分类id
  }
  // 重复性Loading
  listMismatchRepeatabilityLoading.value = type === '失配测量' && current.value === 'repeatability' // 失配测量-重复性
  listAttenuationRepeatabilityLoading.value = type === '衰减测量' && current.value === 'repeatability' // 衰减测量-重复性
  listPhaseRepeatabilityLoading.value = type === '相移测量' && current.value === 'repeatability' // 相移测量-重复性

  calculateHandle(params).then((res) => {
    const result = res.data.filter((item: { params: string }) => item.params === type).map((item: any) => {
      let unit = ''
      switch (item.params) {
        case '衰减测量':
          unit = item.amplitudeUnit
          break
        case '相移测量':
          unit = item.phaseUnit
          break
      }
      return {
        ...item,
        frequencyDefineFront: item.frequency + item.frequencyUnit, // 频率
        phaseDefineFront: item.phase + item.phaseUnit, // 相位
        amplitudeDefineFront: item.amplitude + item.amplitudeUnit, // 幅度
        editable: props.pageType !== 'detail',
        showUnitData: unit,
        averageValue: (current.value === 'repeatability' && `${item.averageValue}` !== '') ? item.averageValue + unit : item.averageValue, // 平均值
        averageValueNoUnit: item.averageValue, // 平均值
        standardDeviation: useScientificNotation(item.standardDeviation),
        stability: useScientificNotation(item.stability),
      }
    })
    if (current.value === 'repeatability') { // 重复性
      switch (type) {
        case '失配测量':
          listMismatchRepeatability.value = result
          // 填充稳定性最后一列的日期和数值
          listMismatchStability.value = listMismatchStability.value.map((item, index: number) => {
            return {
              ...item,
              testValueSix: listMismatchRepeatability.value[index].averageValueNoUnit, //	平均值
              testValueSixDate: props.checkDate, //	核查读数6日期(本次核查日期)
            }
          })
          break
        case '衰减测量':
          listAttenuationRepeatability.value = result
          // 填充稳定性最后一列的日期和数值
          listAttenuationStability.value = listAttenuationStability.value.map((item, index: number) => {
            return {
              ...item,
              testValueSix: listAttenuationRepeatability.value[index].averageValueNoUnit, //	测量差值
              testValueSixDate: props.checkDate, //	核查读数6日期(本次核查日期)
            }
          })
          break
        case '相移测量':
          listPhaseRepeatability.value = result
          // 填充稳定性最后一列的日期和数值
          listPhaseStability.value = listPhaseStability.value.map((item, index: number) => {
            return {
              ...item,
              testValueSix: listPhaseRepeatability.value[index].averageValueNoUnit, //	测量差值
              testValueSixDate: props.checkDate, //	核查读数6日期(本次核查日期)
            }
          })
          break
        default:
          break
      }
    }
    else if (current.value === 'stability') { // 稳定性
      const resultList = res.data.map((item: any) => {
        return {
          ...item,
          lessThan: (`${item.lessThan}` === '1' || `${item.lessThan}` === '') ? '合格' : '不合格',
          frequencyDefineFront: item.frequency + item.frequencyUnit, // 频率
          amplitudeDefineFront: item.amplitude + item.amplitudeUnit, // 幅度
          phaseDefineFront: item.phase + item.phaseUnit, // 相位
          editable: props.pageType !== 'detail',
        }
      })
      listMismatchStability.value = resultList.filter((item: { params: string }) => item.params === '失配测量')
      listAttenuationStability.value = resultList.filter((item: { params: string }) => item.params === '衰减测量')
      listPhaseStability.value = resultList.filter((item: { params: string }) => item.params === '相移测量')

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

    // 重复性Loading
    listMismatchRepeatabilityLoading.value = false // 失配测量-重复性
    listAttenuationRepeatabilityLoading.value = false // 衰减测量-重复性
    listPhaseRepeatabilityLoading.value = false // 相移测量-重复性
    // 稳定性loading
    listMismatchStabilityLoading.value = false // 失配测量-稳定性
    listAttenuationStabilityLoading.value = false // 衰减测量-稳定性
    listPhaseStabilityLoading.value = false // 相移测量-稳定性
  }).catch(() => {
    // 重复性Loading
    listMismatchRepeatabilityLoading.value = false // 失配测量-重复性
    listAttenuationRepeatabilityLoading.value = false // 衰减测量-重复性
    listPhaseRepeatabilityLoading.value = false // 相移测量-重复性
    // 稳定性loading
    listMismatchStabilityLoading.value = false // 失配测量-稳定性
    listAttenuationStabilityLoading.value = false // 衰减测量-稳定性
    listPhaseStabilityLoading.value = false // 相移测量-稳定性
  })
}
// ------------------------------------------------------------------------------------------
// 处理详情数据
const solveGetDetailData = (responseList: any) => {
  console.log('处理详情数据', props.pageType)
  // form.value.qualified = responseList[0].qualified === 1 ? '合格' : '不合格'
  const list = responseList.map((item: any) => {
    let unit = ''
    switch (item.params) {
      case '失配测量':
        break
      case '衰减测量':
        unit = item.amplitudeUnit
        break
      case '相移测量':
        unit = item.phaseUnit
        break
    }
    return {
      ...item,
      editable: props.pageType !== 'detail',
      frequencyDefineFront: item.frequency + item.frequencyUnit, // 频率
      amplitudeDefineFront: item.amplitude + item.amplitudeUnit, // 幅度
      phaseDefineFront: item.phase + item.phaseUnit, // 相位
      lessThan: `${item.lessThan}` === '1' ? '合格' : '不合格',
      testValueOne: item.checkType === '稳定性' ? item.testValueOne : (item.checkType === '重复性' && `${item.testValueOne}` === '') ? undefined : useRound(Number(item.testValueOne), 3), //	测量值1/测量值(上升时间)
      testValueTwo: item.checkType === '稳定性' ? item.testValueTwo : (item.checkType === '重复性' && `${item.testValueTwo}` === '') ? undefined : useRound(Number(item.testValueTwo), 3), //	测量值2(示值)
      testValueThree: item.checkType === '稳定性' ? item.testValueThree : (item.checkType === '重复性' && `${item.testValueThree}` === '') ? undefined : useRound(Number(item.testValueThree), 3), //	测量值3(示值)
      testValueFour: item.checkType === '稳定性' ? item.testValueFour : (item.checkType === '重复性' && `${item.testValueFour}` === '') ? undefined : useRound(Number(item.testValueFour), 3), //	测量值4(示值)
      testValueFive: item.checkType === '稳定性' ? item.testValueFive : (item.checkType === '重复性' && `${item.testValueFive}` === '') ? undefined : useRound(Number(item.testValueFive), 3), //	测量值5(示值)
      testValueSix: item.checkType === '稳定性' ? item.testValueSix : (item.checkType === '重复性' && `${item.testValueSix}` === '') ? undefined : useRound(Number(item.testValueSix), 3), //	测量值6(本次示值)
      testValueSeven: item.checkType === '稳定性' ? item.testValueSeven : (item.checkType === '重复性' && `${item.testValueSeven}` === '') ? undefined : useRound(Number(item.testValueSeven), 3), //	测量值7
      testValueEight: item.checkType === '稳定性' ? item.testValueEight : (item.checkType === '重复性' && `${item.testValueEight}` === '') ? undefined : useRound(Number(item.testValueEight), 3), //	测量值8
      testValueNine: item.checkType === '稳定性' ? item.testValueNine : (item.checkType === '重复性' && `${item.testValueNine}` === '') ? undefined : useRound(Number(item.testValueNine), 3), //	测量值9
      testValueTen: item.checkType === '稳定性' ? item.testValueTen : (item.checkType === '重复性' && `${item.testValueTen}` === '') ? undefined : useRound(Number(item.testValueTen), 3), //	测量值10
      showUnitData: unit,
    }
  })

  // 稳定性考核是否合格
  let tempStabilityList = []
  tempStabilityList = list.filter((item: { checkType: string }) => item.checkType === '稳定性')
  if (tempStabilityList.length) {
    form.value.qualified = tempStabilityList[0].qualified === 1 ? '合格' : '不合格'
  }

  const listMismatchRepeatability = list.filter((item: { params: string; checkType: string }) => item.checkType === '重复性' && item.params === '失配测量') // 失配测量-重复性
  const listAttenuationRepeatability = list.filter((item: { params: string; checkType: string }) => item.checkType === '重复性' && item.params === '衰减测量') // 衰减测量-重复性
  const listPhaseRepeatability = list.filter((item: { params: string; checkType: string }) => item.checkType === '重复性' && item.params === '相移测量') // 相移测量-重复性
  // 稳定性
  const listMismatchStability = list.filter((item: { params: string; checkType: string }) => item.checkType === '稳定性' && item.params === '失配测量') // 失配测量-稳定性
  const listAttenuationStability = list.filter((item: { params: string; checkType: string }) => item.checkType === '稳定性' && item.params === '衰减测量') // 衰减测量-稳定性
  const listPhaseStability = list.filter((item: { params: string; checkType: string }) => item.checkType === '稳定性' && item.params === '相移测量') // 相移测量-稳定性

  return {
    templistMismatchRepeatability: listMismatchRepeatability,
    templistAttenuationRepeatability: listAttenuationRepeatability,
    templistPhaseRepeatability: listPhaseRepeatability,

    templistMismatchStability: listMismatchStability,
    templistAttenuationStability: listAttenuationStability,
    templistPhaseStability: listPhaseStability,
  }
}

// 获取详情
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 {
      templistMismatchRepeatability,
      templistAttenuationRepeatability,
      templistPhaseRepeatability,
      templistMismatchStability,
      templistAttenuationStability,
      templistPhaseStability,
    } = solveGetDetailData(res.data.checkDataSParamList)
    if (id !== '') { // 查询的日期获得的数据
      listMismatchRepeatabilityCheckDate.value = templistMismatchRepeatability// 失配测量-重复性
      listAttenuationRepeatabilityCheckDate.value = templistAttenuationRepeatability// 衰减测量-重复性
      listPhaseRepeatabilityCheckDate.value = templistPhaseRepeatability// 相移测量-重复性
      listMismatchStabilityCheckDate.value = templistMismatchStability // 失配测量-稳定性
      listAttenuationStabilityCheckDate.value = templistAttenuationStability // 衰减测量-稳定性
      listPhaseStabilityCheckDate.value = templistPhaseStability // 相移测量-稳定性
    }
    else {
      listMismatchRepeatability.value = templistMismatchRepeatability// 失配测量-重复性
      listAttenuationRepeatability.value = templistAttenuationRepeatability// 衰减测量-重复性
      listPhaseRepeatability.value = templistPhaseRepeatability// 相移测量-重复性
      listMismatchStability.value = templistMismatchStability // 失配测量-稳定性
      listAttenuationStability.value = templistAttenuationStability // 衰减测量-稳定性
      listPhaseStability.value = templistPhaseStability // 相移测量-稳定性
    }

    nextTick(() => {
      if (id !== '') { // 稳定性表头---查询历史的稳定性日期数据
        initColumnsCheckDate()
        fetchHistoryIndication(currentDate.value) // 获取稳定性
      }
      else { // 正常核查数据处理表头
        columns_stability_mismatch.value = handleDetailTableTableHead(columns_stability_mismatch.value, listMismatchStability.value, 4)
        columns_stability_attenuation.value = handleDetailTableTableHead(columns_stability_attenuation.value, listAttenuationStability.value, 4)
        columns_stability_phase.value = handleDetailTableTableHead(columns_stability_phase.value, listPhaseStability.value, 4)
      }
    })
    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
    listMismatchStabilityLoading.value = true // 失配测量-稳定性
    listAttenuationStabilityLoading.value = true // 衰减测量-稳定性
    listPhaseStabilityLoading.value = true // 相移测量-稳定性
  }
  getHistoryIndication(params).then((res) => {
    if (date === '') { // 正常核查数据
      const num = (props.pageType === 'edit' || props.pageType === 'detail') ? 5 : 4
      // '失配测量':
      listMismatchStability.value = listMismatchStability.value.map((item) => {
        const { itemData, columnsData } = solveHistoryIndicationTableData(res.data.data.filter((item: { params: string }) => item.params === '失配测量'), item, columns_stability_mismatch.value, num, 4, '17')
        columns_stability_mismatch.value = columnsData
        return item = itemData
      })
      listMismatchStability.value = handleSaveDateParams(columns_stability_mismatch.value, listMismatchStability.value, 4)
      //  '衰减测量':
      listAttenuationStability.value = listAttenuationStability.value.map((item) => {
        const { itemData, columnsData } = solveHistoryIndicationTableData(res.data.data.filter((item: { params: string }) => item.params === '衰减测量'), item, columns_stability_attenuation.value, num, 4, '17')
        columns_stability_attenuation.value = columnsData
        return item = itemData
      })
      listAttenuationStability.value = handleSaveDateParams(columns_stability_attenuation.value, listAttenuationStability.value, 4)
      //  '相移测量':
      listPhaseStability.value = listPhaseStability.value.map((item) => {
        const { itemData, columnsData } = solveHistoryIndicationTableData(res.data.data.filter((item: { params: string }) => item.params === '相移测量'), item, columns_stability_phase.value, num, 4, '17')
        columns_stability_phase.value = columnsData
        return item = itemData
      })
      listPhaseStability.value = handleSaveDateParams(columns_stability_phase.value, listPhaseStability.value, 4)
    }
    else {
      const num = 5
      initColumnsCheckDate()
      // '失配测量':
      if (listMismatchRepeatability.value && listMismatchRepeatability.value.length) {
        listMismatchStabilityCheckDate.value = listMismatchStabilityCheckDate.value.map((item) => {
          clearDateValue(item)
          const { itemData, columnsData } = solveHistoryIndicationTableData(res.data.data.filter((item: { params: string }) => item.params === '失配测量'), item, columns_stability_mismatch_checkDate.value, num, 4, '17')
          columns_stability_mismatch_checkDate.value = columnsData
          return item = itemData
        })
        listMismatchStabilityCheckDate.value = handleSaveDateParams(columns_stability_mismatch_checkDate.value, listMismatchStabilityCheckDate.value, 4)
      }
      //  '衰减测量':
      if (listAttenuationRepeatability.value && listAttenuationRepeatability.value.length) {
        listAttenuationStabilityCheckDate.value = listAttenuationStabilityCheckDate.value.map((item) => {
          clearDateValue(item)
          const { itemData, columnsData } = solveHistoryIndicationTableData(res.data.data.filter((item: { params: string }) => item.params === '衰减测量'), item, columns_stability_attenuation_checkDate.value, num, 4, '17')
          columns_stability_attenuation_checkDate.value = columnsData
          return item = itemData
        })
        listAttenuationStabilityCheckDate.value = handleSaveDateParams(columns_stability_attenuation_checkDate.value, listAttenuationStabilityCheckDate.value, 4)
      }
      //  '相移测量':
      if (listPhaseRepeatability.value && listPhaseRepeatability.value.length) {
        listPhaseStabilityCheckDate.value = listPhaseStabilityCheckDate.value.map((item) => {
          clearDateValue(item)
          const { itemData, columnsData } = solveHistoryIndicationTableData(res.data.data.filter((item: { params: string }) => item.params === '相移测量'), item, columns_stability_phase_checkDate.value, num, 4, '17')
          columns_stability_phase_checkDate.value = columnsData
          return item = itemData
        })
        listPhaseStabilityCheckDate.value = handleSaveDateParams(columns_stability_phase_checkDate.value, listPhaseStabilityCheckDate.value, 4)
      }
    }

    // 稳定性loading
    listMismatchStabilityLoading.value = false // 失配测量-稳定性
    listAttenuationStabilityLoading.value = false // 衰减测量-稳定性
    listPhaseStabilityLoading.value = false // 相移测量-稳定性
  }).catch(() => {
    // 稳定性loading
    listMismatchStabilityLoading.value = false // 失配测量-稳定性
    listAttenuationStabilityLoading.value = false // 衰减测量-稳定性
    listPhaseStabilityLoading.value = false // 相移测量-稳定性
  })
}

/**
 * 保存之前的校验
 */
function checkList() {
  // 新建核查数据的时候,在保存之前要先校验一下本次核查日期有没有数据,没有不允许保存
  if (listMismatchRepeatability.value.length && `${listMismatchRepeatability.value[0].averageValue}` === '') {
    ElMessage.warning('请先计算 失配测量 的重复性')
    return false
  }
  if (listAttenuationRepeatability.value.length && `${listAttenuationRepeatability.value[0].averageValue}` === '') {
    ElMessage.warning('请先计算 衰减测量 重复性')
    return false
  }
  if (listPhaseRepeatability.value.length && `${listPhaseRepeatability.value[0].averageValue}` === '') {
    ElMessage.warning('请先计算 相移测量 重复性')
    return false
  }
  return true
}

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

  tempList = tempList.concat(
    // 重复性
    listMismatchRepeatability.value, // 失配测量-重复性
    listAttenuationRepeatability.value, // 衰减测量-重复性
    listPhaseRepeatability.value, // 相移测量-重复性
    listMismatchStability.value, // 失配测量-稳定性
    listAttenuationStability.value, // 衰减测量-稳定性
    listPhaseStability.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') {
    listMismatchRepeatability.value = listMismatchRepeatability.value.map((item) => {
      return {
        ...item,
        editable: false,
        testValueOne: useRound(Number(item.testValueOne), 3), //	Pbu1/mW
        testValueTwo: useRound(Number(item.testValueTwo), 3), //	Pbu2/mW
        testValueThree: useRound(Number(item.testValueThree), 3), //	Pbu3/mW
        testValueFour: useRound(Number(item.testValueFour), 3), //	Pbu4/mW
        testValueFive: useRound(Number(item.testValueFive), 3), //	Pbu5/mW
        testValueSix: useRound(Number(item.testValueSix), 3), //	Pbu6/mW
        testValueSeven: useRound(Number(item.testValueSeven), 3), //	Pbu7/mW
        testValueEight: useRound(Number(item.testValueEight), 3), //	Pbu8/mW
        testValueNine: useRound(Number(item.testValueNine), 3), //	Pbu9/mW
        testValueTen: useRound(Number(item.testValueTen), 3), //	Pbu10/mW
      }
    }) as any
    // 失配测量-重复性
    listAttenuationRepeatability.value = listAttenuationRepeatability.value.map((item) => {
      return {
        ...item,
        editable: false,
        testValueOne: useRound(Number(item.testValueOne), 3), //	Pbu1/mW
        testValueTwo: useRound(Number(item.testValueTwo), 3), //	Pbu2/mW
        testValueThree: useRound(Number(item.testValueThree), 3), //	Pbu3/mW
        testValueFour: useRound(Number(item.testValueFour), 3), //	Pbu4/mW
        testValueFive: useRound(Number(item.testValueFive), 3), //	Pbu5/mW
        testValueSix: useRound(Number(item.testValueSix), 3), //	Pbu6/mW
        testValueSeven: useRound(Number(item.testValueSeven), 3), //	Pbu7/mW
        testValueEight: useRound(Number(item.testValueEight), 3), //	Pbu8/mW
        testValueNine: useRound(Number(item.testValueNine), 3), //	Pbu9/mW
        testValueTen: useRound(Number(item.testValueTen), 3), //	Pbu10/mW
      }
    }) as any// 衰减测量-重复性
    listPhaseRepeatability.value = listPhaseRepeatability.value.map((item) => {
      return {
        ...item,
        editable: false,
        testValueOne: useRound(Number(item.testValueOne), 3), //	Pbu1/mW
        testValueTwo: useRound(Number(item.testValueTwo), 3), //	Pbu2/mW
        testValueThree: useRound(Number(item.testValueThree), 3), //	Pbu3/mW
        testValueFour: useRound(Number(item.testValueFour), 3), //	Pbu4/mW
        testValueFive: useRound(Number(item.testValueFive), 3), //	Pbu5/mW
        testValueSix: useRound(Number(item.testValueSix), 3), //	Pbu6/mW
        testValueSeven: useRound(Number(item.testValueSeven), 3), //	Pbu7/mW
        testValueEight: useRound(Number(item.testValueEight), 3), //	Pbu8/mW
        testValueNine: useRound(Number(item.testValueNine), 3), //	Pbu9/mW
        testValueTen: useRound(Number(item.testValueTen), 3), //	Pbu10/mW
      }
    }) as any// 相移测量-重复性
  }
})
/**
 * 初始化表头
 * @param soveLastColumnDate 是否处理最后一列
 */
function initColumns() {
  const tempColumn_mismatch = [
    { width: '220', text: '-', value: 'testValueOne', align: 'center', required: false, type: 'text', customHeader: true },
    { width: '220', text: '-', value: 'testValueTwo', align: 'center', required: false, type: 'text', customHeader: true },
    { width: '220', text: '-', value: 'testValueThree', align: 'center', required: false, type: 'text', customHeader: true },
    { width: '220', text: '-', value: 'testValueFour', align: 'center', required: false, type: 'text', customHeader: true },
    { width: '220', text: '-', value: 'testValueFive', align: 'center', required: false, type: 'text', customHeader: true },
    { width: '220', text: '-', value: 'testValueSix', align: 'center', required: false, type: 'text', customHeader: true },
  ] as any
  const tempColumn = [
    { width: '220', text: '-', value: 'testValueOne', align: 'center', required: false, type: 'text', customHeader: true, precision: 3, showUnit: true },
    { width: '220', text: '-', value: 'testValueTwo', align: 'center', required: false, type: 'text', customHeader: true, precision: 3, showUnit: true },
    { width: '220', text: '-', value: 'testValueThree', align: 'center', required: false, type: 'text', customHeader: true, precision: 3, showUnit: true },
    { width: '220', text: '-', value: 'testValueFour', align: 'center', required: false, type: 'text', customHeader: true, precision: 3, showUnit: true },
    { width: '220', text: '-', value: 'testValueFive', align: 'center', required: false, type: 'text', customHeader: true, precision: 3, showUnit: true },
    { width: '220', text: '-', value: 'testValueSix', align: 'center', required: false, type: 'text', customHeader: true, precision: 3, showUnit: true },
  ] as any
  if (listMismatchRepeatability.value && listMismatchRepeatability.value.length) {
    columns_stability_mismatch.value[4].children = [...tempColumn_mismatch]
  }
  if (listAttenuationRepeatability.value && listAttenuationRepeatability.value.length) {
    columns_stability_attenuation.value[4].children = [...tempColumn]
  }
  if (listPhaseRepeatability.value && listPhaseRepeatability.value.length) {
    columns_stability_phase.value[4].children = [...tempColumn]
  }

  if (props.pageType === 'add') {
    columns_stability_mismatch.value[4].children![5].text = props.checkDate! // 最后一列的表头日期
    columns_stability_attenuation.value[4].children![5].text = props.checkDate! // 最后一列的表头日期
    columns_stability_phase.value[4].children![5].text = props.checkDate!
  }
}

/**
 * 初始化CheckDate表头
 * @param soveLastColumnDate 是否处理最后一列
 */
function initColumnsCheckDate() {
  const tempColumn_mismatch = [
    { width: '220', text: '-', value: 'testValueOne', align: 'center', required: false, type: 'text', customHeader: true },
    { width: '220', text: '-', value: 'testValueTwo', align: 'center', required: false, type: 'text', customHeader: true },
    { width: '220', text: '-', value: 'testValueThree', align: 'center', required: false, type: 'text', customHeader: true },
    { width: '220', text: '-', value: 'testValueFour', align: 'center', required: false, type: 'text', customHeader: true },
    { width: '220', text: '-', value: 'testValueFive', align: 'center', required: false, type: 'text', customHeader: true },
    { width: '220', text: '-', value: 'testValueSix', align: 'center', required: false, type: 'text', customHeader: true },
  ] as any
  const tempColumn = [
    { width: '220', text: '-', value: 'testValueOne', align: 'center', required: false, type: 'text', customHeader: true, precision: 3, showUnit: true },
    { width: '220', text: '-', value: 'testValueTwo', align: 'center', required: false, type: 'text', customHeader: true, precision: 3, showUnit: true },
    { width: '220', text: '-', value: 'testValueThree', align: 'center', required: false, type: 'text', customHeader: true, precision: 3, showUnit: true },
    { width: '220', text: '-', value: 'testValueFour', align: 'center', required: false, type: 'text', customHeader: true, precision: 3, showUnit: true },
    { width: '220', text: '-', value: 'testValueFive', align: 'center', required: false, type: 'text', customHeader: true, precision: 3, showUnit: true },
    { width: '220', text: '-', value: 'testValueSix', align: 'center', required: false, type: 'text', customHeader: true, precision: 3, showUnit: true },
  ] as any
  if (listMismatchRepeatability.value && listMismatchRepeatability.value.length) {
    columns_stability_mismatch_checkDate.value[4].children = [...tempColumn_mismatch]
  }
  if (listAttenuationRepeatability.value && listAttenuationRepeatability.value.length) {
    columns_stability_attenuation_checkDate.value[4].children = [...tempColumn]
  }
  if (listPhaseRepeatability.value && listPhaseRepeatability.value.length) {
    columns_stability_phase_checkDate.value[4].children = [...tempColumn]
  }
}
// 监听核查日期变化
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') {
    console.log('0000000', '获取详情')

    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>
    <div style="display: flex;justify-content: space-between;align-items: center; position: absolute; right: 20px;">
      <div />
      <el-button
        v-if="pageType !== 'detail' && current === 'stability'" type="primary"
        @click="createResult('stability')"
      >
        计算结果
      </el-button>
    </div>
    <!-- 失配测量 -->
    <div style="display: flex;justify-content: space-between;align-items: center;">
      <h5 v-if="listMismatchRepeatability.length">
        失配测量
      </h5>
      <div v-if="!listMismatchRepeatability.length" />
      <el-button v-if="pageType !== 'detail' && current === 'repeatability' && listMismatchRepeatability.length" 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 === '') && listMismatchRepeatability.length"
      v-loading="listMismatchRepeatabilityLoading"
      :table-data="listMismatchRepeatability"
      :table-header="columns_repeatability_mismatch"
      :merge-rows="[]"
      :need-index="true"
      max-height="300"
    />
    <!-- 历史日期重复性数据 -->
    <multi-table
      v-show="current === 'repeatability' && (currentDate !== '核查数据' && currentDate !== '') && listMismatchRepeatabilityCheckDate.length"
      v-loading="listMismatchRepeatabilityLoading"
      :table-data="listMismatchRepeatabilityCheckDate"
      :table-header="columns_repeatability_mismatch"
      :merge-rows="[]"
      :need-index="true"
      max-height="300"
    />

    <!-- 失配测量稳定性  -->
    <multi-table
      v-show="current === 'stability' && (currentDate === '核查数据' || currentDate === '') && listMismatchStability.length"
      v-loading="listMismatchStabilityLoading"
      :table-data="listMismatchStability"
      :table-header="columns_stability_mismatch"
      :merge-rows="[]"
      :need-index="true"
      max-height="500"
      @handle-click-header="handleClickHeader"
    />
    <!-- 历史日期稳定性数据 -->
    <multi-table
      v-show="current === 'stability' && (currentDate !== '核查数据' && currentDate !== '') && listMismatchStabilityCheckDate.length"
      v-loading="listMismatchStabilityLoading"
      :table-data="listMismatchStabilityCheckDate"
      :table-header="columns_stability_mismatch_checkDate"
      :merge-rows="[]"
      :need-index="true"
      max-height="500"
      @handle-click-header="handleClickHeader"
    />

    <!-- 衰减测量 -->
    <div v-if="listAttenuationRepeatability.length" 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 === '') && listAttenuationRepeatability.length"
      v-loading="listAttenuationRepeatabilityLoading"
      :table-data="listAttenuationRepeatability"
      :table-header="columns_repeatability_attenuation"
      :merge-rows="[]"
      :need-index="true"
      max-height="300"
    />
    <!-- 历史日期重复性数据 -->
    <multi-table
      v-show="current === 'repeatability' && (currentDate !== '核查数据' && currentDate !== '') && listAttenuationRepeatabilityCheckDate.length"
      v-loading="listAttenuationRepeatabilityLoading"
      :table-data="listAttenuationRepeatabilityCheckDate"
      :table-header="columns_repeatability_attenuation"
      :merge-rows="[]"
      :need-index="true"
      max-height="300"
    />

    <!-- 衰减测量稳定性  -->
    <multi-table
      v-show="current === 'stability' && (currentDate === '核查数据' || currentDate === '') && listAttenuationStability.length"
      v-loading="listAttenuationStabilityLoading"
      :table-data="listAttenuationStability"
      :table-header="columns_stability_attenuation"
      :merge-rows="[]"
      :need-index="true"
      max-height="500"
      @handle-click-header="handleClickHeader"
    />
    <!-- 历史日期稳定性数据 -->
    <multi-table
      v-show="current === 'stability' && (currentDate !== '核查数据' && currentDate !== '') && listAttenuationStabilityCheckDate.length"
      v-loading="listAttenuationStabilityLoading"
      :table-data="listAttenuationStabilityCheckDate"
      :table-header="columns_stability_attenuation_checkDate"
      :merge-rows="[]"
      :need-index="true"
      max-height="500"
      @handle-click-header="handleClickHeader"
    />

    <!-- 相移测量 -->
    <div v-if="listPhaseRepeatability.length" 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 === '') && listPhaseRepeatability.length"
      v-loading="listPhaseRepeatabilityLoading"
      :table-data="listPhaseRepeatability"
      :table-header="columns_repeatability_phase"
      :merge-rows="[]"
      :need-index="true"
      max-height="300"
    />
    <!-- 历史日期重复性数据 -->
    <multi-table
      v-show="current === 'repeatability' && (currentDate !== '核查数据' && currentDate !== '') && listPhaseRepeatabilityCheckDate.length"
      v-loading="listPhaseRepeatabilityLoading"
      :table-data="listPhaseRepeatabilityCheckDate"
      :table-header="columns_repeatability_phase"
      :merge-rows="[]"
      :need-index="true"
      max-height="300"
    />

    <!-- 稳定性  -->
    <multi-table
      v-show="current === 'stability' && (currentDate === '核查数据' || currentDate === '') && listPhaseStability.length"
      v-loading="listPhaseStabilityLoading"
      :table-data="listPhaseStability"
      :table-header="columns_stability_phase"
      :merge-rows="[]"
      :need-index="true"
      max-height="500"
      @handle-click-header="handleClickHeader"
    />
    <!-- 历史日期稳定性数据 -->
    <multi-table
      v-show="current === 'stability' && (currentDate !== '核查数据' && currentDate !== '') && listPhaseStabilityCheckDate.length"
      v-loading="listPhaseStabilityLoading"
      :table-data="listPhaseStabilityCheckDate"
      :table-header="columns_stability_phase_checkDate"
      :merge-rows="[]"
      :need-index="true"
      max-height="500"
      @handle-click-header="handleClickHeader"
    />

    <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>