Newer
Older
xc-business-system / src / views / business / measure / item / components / ninth / templateDetail.vue
liyaguang on 5 Mar 66 KB bug修复
<!-- 第9套:频谱分析仪标准装置 -->
<script lang="ts" setup name="TemplateDetailNinth">
import { ElMessage } from 'element-plus'
import type { IList } from './templateDetail-interface'
import templateTable from './templateTable.vue'
import type { dictType } from '@/global'
import { getDictByCode } from '@/api/system/dict'
import { calc } from '@/utils/useCalc'
import { useCheckList } from '@/commonMethods/useCheckList'
import { calculate, recalculate } from '@/api/business/measure/caculate'
import type { TableColumn } from '@/components/NormalTable/table_interface'
import templateTable1 from '@/views/business/measure/item/components/second/templateTable.vue'
import { differenceArray, setSelectList } from '@/utils/Array'
import { clearSymbol } from '@/utils/String'
const props = defineProps({
  pageType: {
    type: String,
    default: 'add',
  },
  itemCategoryName: {
    type: String,
    require: true,
  }, // 设备检定项分类名称
  belongStandardEquipment: { // 检校标准装置code
    type: String,
    require: true,
  },
  list: {
    type: Array as any,
  },
  form: { // 检定项表单
    type: Object as any,
  },
  itemId: { // 检定项id
    type: String,
    default: '',
  },
})
const form = ref({
  appearanceFunctionCheck: 1, // 外观及功能性检查
  frequencyDisplay: 1, // 频率显示
  sweepWidth: 1, // 扫频宽度
  middleFrequencyWidth: 1, // 中频带宽
  middleConversionDeviation: 1, // 中频带宽转换偏差
  referenceLevel: 1, // 参考电平
  verticalScale: 1, // 垂直刻度(显示位置从上到下)
  inputFrequency: 1, // 输入频响
  averageNoiseLevel: 1, // 平均噪声电平
  harmonicDistortion: 1, // 谐波失真
  inputAttenuation: 1, // 输入衰减
  gainCompression: 1, // 1dB增益压缩点
  calibratingSignal: 1, // 校准信号

  frequencyReferenceAccuracy: '', // 频率基准精度
  valueOne: '', // 数值1
  valueTwo: '', // 数值2
  valueThree: '', // 数值3
  valueFour: '', // 数值4
})
watch(() => props.form, (newVal) => {
  form.value = JSON.parse(JSON.stringify(newVal))
})
const tableLoading = ref(false)
const list = ref<IList[]>([]) // 全部数据
const frequencyList = ref<IList[]>([]) // 频率显示
const sweepWidthList = ref<IList[]>([]) // 扫频宽度
const intermediateFrequencyBandwidthList = ref<IList[]>([]) // 中频带宽
const transitionDeviationList = ref<IList[]>([]) // 中频带宽转换偏差
const referenceElectricalLevelList = ref<IList[]>([]) // 参考电平
const verticalGraduatedList = ref<IList[]>([]) // 垂直刻度(显示位置从上到下)
const inputFrequencyResponseList = ref<IList[]>([]) // 输入频响
const averageNoiseLevelList = ref<IList[]>([]) // 平均噪声电平
const harmonicDistortionList = ref<IList[]>([]) // 谐波失真
const inputAttenuatorList = ref<IList[]>([]) // 输入衰减
const gainCompressionPointList = ref<IList[]>([]) // 1dB增益压缩点
const calibratingSignalList = ref<IList[]>([]) // 校准信号
// 表格数据对应 list 字典
const listDict = ref<{ [key: string]: any }>()
watch(() => [frequencyList.value, sweepWidthList.value, intermediateFrequencyBandwidthList.value, transitionDeviationList.value, referenceElectricalLevelList.value, verticalGraduatedList.value, inputFrequencyResponseList.value, averageNoiseLevelList.value, harmonicDistortionList.value, inputAttenuatorList.value, gainCompressionPointList.value, calibratingSignalList.value], () => {
  listDict.value = {
    '1-频率显示': frequencyList.value,
    '2-扫频宽度': sweepWidthList.value,
    '3-中频带宽': intermediateFrequencyBandwidthList.value,
    '4-中频带宽转换偏差': transitionDeviationList.value,
    '5-参考电平': referenceElectricalLevelList.value,
    '6-垂直刻度(显示位置从上到下)': verticalGraduatedList.value,
    '7-输入频响': inputFrequencyResponseList.value,
    '8-平均噪声电平': averageNoiseLevelList.value,
    '9-谐波失真': harmonicDistortionList.value,
    '10-输入衰减': inputAttenuatorList.value,
    '11-1dB增益压缩点': gainCompressionPointList.value,
    '12-校准信号': calibratingSignalList.value,
  }
  list.value = []
  for (const i in listDict.value) {
    list.value = [...list.value, ...listDict.value[i]]
  }
}, {
  deep: true,
})
watch(() => frequencyList.value, (newVal) => {
  if(newVal) {
    if(newVal.length) {

      const data = frequencyList.value[0]
      form.value.frequencyReferenceAccuracy = data.frequencyReferenceAccuracy
      form.value.valueOne = data.valueOne
      form.value.valueTwo = data.valueTwo
      form.value.valueThree = data.valueThree
      form.value.valueFour = data.valueFour
    }
  }
}, {
  deep: true
})
// 表格对应的 选择状态
let chekedDict = {} as { [key: string]: any }
watch(() => [props.form, form.value], () => {
  chekedDict = {
    '1-频率显示': form.value.frequencyDisplay,
    '2-扫频宽度': form.value.sweepWidth,
    '3-中频带宽': form.value.middleFrequencyWidth,
    '4-中频带宽转换偏差': form.value.middleConversionDeviation,
    '5-参考电平': form.value.referenceLevel,
    '6-垂直刻度(显示位置从上到下)': form.value.verticalScale,
    '7-输入频响': form.value.inputFrequency,
    '8-平均噪声电平': form.value.averageNoiseLevel,
    '9-谐波失真': form.value.harmonicDistortion,
    '10-输入衰减': form.value.inputAttenuation,
    '11-1dB增益压缩点': form.value.gainCompression,
    '12-校准信号': form.value.calibratingSignal,
  }
  frequencyList.value.forEach((item: any) => {
    if(String(form.value.frequencyReferenceAccuracy) !== 'undefined') {
      item.frequencyReferenceAccuracy = form.value.frequencyReferenceAccuracy
    }
    if(String(form.value.valueOne) !== 'undefined') {
      item.valueOne = form.value.valueOne
    }

    if(String(form.value.valueTwo) !== 'undefined') {
      item.valueTwo = form.value.valueTwo
    }
    if(String(form.value.valueThree) !== 'undefined') {
      item.valueThree = form.value.valueThree
    }
    if(String(form.value.valueFour) !== 'undefined') {
      item.valueFour = form.value.valueFour
    }

  })
  // console.log(form.value, 'form.value')

}, {
  deep: true,
})
// ----------------------------------------表头------------------------------------------------
const columns_frequency = ref<TableColumn[]>([ // 频率显示
  { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '标称值', value: 'nominalValue', align: 'center', required: true, type: 'select-dict', code: 'frequencyNominalValue' },
  { text: '标称值单位', value: 'unit', align: 'center', required: true, type: 'select' },
  { text: '扫频宽度', value: 'sweepWidth', align: 'center', required: true, type: 'select-dict', code: 'frequencysweepWidth' },
  { text: '扫频宽度单位', value: 'sweepWidthUnit', align: 'center', required: true, type: 'select' },
  { text: '水平分辨率', value: 'horizontalResolution', align: 'center', required: true, type: 'number' },
  { text: '水平分辨率单位', value: 'horizontalResolutionUnit', align: 'center', required: true, type: 'select' },
  { text: '分辨率带宽', value: 'resolutionBandwidth', align: 'center', required: true, type: 'number' },
  { text: '分辨率带宽单位', value: 'resolutionBandwidthUnit', align: 'center', required: true, type: 'select' },
  { text: '频率', value: 'frequency', align: 'center', required: false, type: 'text' },
  { text: '频率单位', value: 'frequencyUnit', align: 'center', required: false, type: 'text' },
  { text: '幅度', value: 'amplitude', align: 'center', required: true, type: 'number' },
  { text: '幅度单位', value: 'amplitudeUnit', align: 'center', required: true, type: 'select' },
])

const columns_sweep_width = ref<TableColumn[]>([ // 扫频宽度
  { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '标称值', value: 'nominalValue', align: 'center', required: true, type: 'select-dict', code: 'sweepWidthNominalValue' },
  { text: '标称值单位', value: 'unit', align: 'center', required: true, type: 'select' },
  { text: '水平分辨率', value: 'horizontalResolution', align: 'center', required: true, type: 'number' },
  { text: '水平分辨率单位', value: 'horizontalResolutionUnit', align: 'center', required: true, type: 'select' },
  { text: '频率', value: 'frequency', align: 'center', required: true, type: 'number' },
  { text: '频率单位', value: 'frequencyUnit', align: 'center', required: true, type: 'select' },
  { text: '幅度', value: 'amplitude', align: 'center', required: true, type: 'number' },
  { text: '幅度单位', value: 'amplitudeUnit', align: 'center', required: true, type: 'select' },
  { text: '技术指标', value: 'valueOne', align: 'center', required: false, type: 'number', width: '400' },
])

const columns_intermediate_frequency_bandwidth = ref<TableColumn[]>([ // 中频带宽
  { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '标称值', value: 'nominalValue', align: 'center', required: true, type: 'select-dict', code: 'sweepWidthNominalValue' },
  { text: '标称值单位', value: 'unit', align: 'center', required: true, type: 'select' },
  { text: '频率', value: 'frequency', align: 'center', required: true, type: 'number' },
  { text: '频率单位', value: 'frequencyUnit', align: 'center', required: true, type: 'select' },
  { text: '幅度', value: 'amplitude', align: 'center', required: true, type: 'number' },
  { text: '幅度单位', value: 'amplitudeUnit', align: 'center', required: true, type: 'select' },
  { text: '技术指标', value: 'valueTwo', align: 'center', required: false, width: '400' },
])

const columns_transition_deviation = ref<TableColumn[]>([ // 中频带宽转换偏差
  { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '标称值', value: 'nominalValue', align: 'center', required: true, type: 'select-dict', code: 'sweepWidthNominalValue' },
  { text: '标称值单位', value: 'unit', align: 'center', required: true, type: 'select' },
  { text: '频率', value: 'frequency', align: 'center', required: true, type: 'number' },
  { text: '频率单位', value: 'frequencyUnit', align: 'center', required: true, type: 'select' },
  { text: '幅度', value: 'amplitude', align: 'center', required: true, type: 'number' },
  { text: '幅度单位', value: 'amplitudeUnit', align: 'center', required: true, type: 'select' },
  { text: '技术指标', value: 'technicalIndex', align: 'center', required: false, type: 'number', width: '250' },
  { text: '是否为参考点', value: 'referencePoint', align: 'center', required: true, type: 'radio' },
])

const columns_reference_electrical_level = ref<TableColumn[]>([ // 参考电平
  { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '标称值', value: 'nominalValue', align: 'center', required: true, type: 'select-dict', code: 'sweepWidthNominalValue' },
  { text: '标称值单位', value: 'unit', align: 'center', required: true, type: 'select' },
  { text: '标准衰减器衰减量', value: 'standardAttenuatorAttenuation', align: 'center', required: true, type: 'select-dict', code: 'standardAttenuatorAttenuation' },
  { text: '标准衰减器衰减量单位', value: 'standardAttenuatorAttenuationUnit', align: 'center', required: true, type: 'select' },
  { text: '频率', value: 'frequency', align: 'center', required: true, type: 'number' },
  { text: '频率单位', value: 'frequencyUnit', align: 'center', required: true, type: 'select' },
  { text: '幅度', value: 'amplitude', align: 'center', required: true, type: 'number' },
  { text: '幅度单位', value: 'amplitudeUnit', align: 'center', required: true, type: 'select' },
  { text: '技术指标', value: 'technicalIndex', align: 'center', required: false, type: 'number' },
  { text: '是否为参考点', value: 'referencePoint', align: 'center', required: true, type: 'radio' },
])

const columns_vertical_graduated = ref<TableColumn[]>([ // 垂直刻度(显示位置从上到下)
  { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '标称值', value: 'nominalValue', align: 'center', required: true, type: 'select-dict', code: 'verticalGraduatedValue' },
  { text: '标称值单位', value: 'unit', align: 'center', required: true, type: 'select' },
  { text: '标准衰减器衰减量', value: 'standardAttenuatorAttenuation', align: 'center', required: true, type: 'select-dict', code: 'standardAttenuatorAttenuation' },
  { text: '标准衰减器衰减量单位', value: 'standardAttenuatorAttenuationUnit', align: 'center', required: true, type: 'select' },
  { text: '信号源幅度', value: 'signalSourceAmplitude', align: 'center', required: true, type: 'select-dict', code: 'signalSourceAmplitude' },
  { text: '信号源幅度单位', value: 'signalSourceAmplitudeUnit', align: 'center', required: true, type: 'select' },
  { text: '垂直刻度', value: 'verticalScale', align: 'center', required: true, type: 'select' },
  { text: '频率', value: 'frequency', align: 'center', required: true, type: 'select-dict', code: 'verticalScaleFrequency' },
  { text: '频率单位', value: 'frequencyUnit', align: 'center', required: true, type: 'select' },
  { text: '幅度', value: 'amplitude', align: 'center', required: true, type: 'number' },
  { text: '幅度单位', value: 'amplitudeUnit', align: 'center', required: true, type: 'select' },
  { text: '技术指标', value: 'technicalIndex', align: 'center', required: false, type: 'number', width: 180 },
])

const columns_input_frequency_response = ref<TableColumn[]>([ // 输入频响
  { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '频率', value: 'frequency', align: 'center', required: true, type: 'select-dict', code: 'inputFrequencyValue' },
  { text: '频率单位', value: 'frequencyUnit', align: 'center', required: true, type: 'select' },
  { text: '幅度', value: 'amplitude', align: 'center', required: true, type: 'number' },
  { text: '幅度单位', value: 'amplitudeUnit', align: 'center', required: true, type: 'select' },
  { text: '技术指标', value: 'technicalIndex', align: 'center', required: false, type: 'number' },
  { text: '是否为参考点', value: 'referencePoint', align: 'center', required: true, type: 'radio' },
])
const columns_average_noise_level = ref<TableColumn[]>([ // 平均噪声电平
  { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '前置放大器设置', value: 'preAmplifier', align: 'center', required: true, type: 'select' },
  { text: '起始频率', value: 'startFrequency', align: 'center', required: true, type: 'select-dict', code: 'averageNoiseLevelStartFrequency' },
  { text: '起始频率单位', value: 'startFrequencyUnit', align: 'center', required: true, type: 'select' },
  { text: '终止频率', value: 'endFrequency', align: 'center', required: true, type: 'select-dict', code: 'averageNoiseLevelEndFrequency' },
  { text: '终止频率单位', value: 'endFrequencyUnit', align: 'center', required: true, type: 'select' },
  { text: '修正值', value: 'correctedValue', align: 'center', required: true, type: 'number' },
  { text: '指标上限', value: 'upperIndex', align: 'center', required: false, type: 'number' },
])

const columns_harmonic_distortion = ref<TableColumn[]>([ // 谐波失真
  { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '频率', value: 'frequency', align: 'center', required: true, type: 'select-dict', code: 'harmonicDistortionFrequency' },
  { text: '频率单位', value: 'frequencyUnit', align: 'center', required: true, type: 'select' },
  { text: '幅度', value: 'amplitude', align: 'center', required: true, type: 'number' },
  { text: '幅度单位', value: 'amplitudeUnit', align: 'center', required: true, type: 'select' },
  { text: 'RBW', value: 'rbwValue', align: 'center', required: true, type: 'number' },
  { text: 'RBW单位', value: 'rbwValueUnit', align: 'center', required: true, type: 'select' },
  { text: 'VBW', value: 'vbwValue', align: 'center', required: true, type: 'number' },
  { text: 'VBW单位', value: 'vbwValueUnit', align: 'center', required: true, type: 'select' },
  { text: '二次谐波失真指标上限', value: 'upperIndexTwice', align: 'center', required: true, type: 'number' },
  { text: '三次谐波失真指标上限', value: 'upperIndexThrice', align: 'center', required: false, type: 'number' },
  { text: '四次谐波失真指标上限', value: 'upperIndexQuartic', align: 'center', required: false, type: 'number' },
])

const columns_input_attenuator = ref<TableColumn[]>([ // 输入衰减
  { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '标准衰减器衰减量', value: 'standardAttenuatorAttenuation', align: 'center', required: true, type: 'select-dict', code: 'inputAttenuationStandardAttenuatorAttenuation' },
  { text: '标准衰减器衰减量单位', value: 'standardAttenuatorAttenuationUnit', align: 'center', required: true, type: 'select' },
  { text: '输入衰减器', value: 'inputAttenuator', align: 'center', required: true, type: 'select-dict', code: 'inputAttenuationStandardAttenuatorAttenuation' },
  { text: '输入衰减器单位', value: 'inputAttenuatorUnit', align: 'center', required: true, type: 'select' },
  { text: '频谱仪参考电平', value: 'spectrumLevel', align: 'center', required: true, type: 'select-dict', code: 'inputAttenuationSpectrumLevel' },
  { text: '频谱仪参考电平单位', value: 'spectrumLevelUnit', align: 'center', required: true, type: 'select' },
  { text: '频率', value: 'frequency', align: 'center', required: true, type: 'select-dict', code: 'inputAttenuationFrequency' },
  { text: '频率单位', value: 'frequencyUnit', align: 'center', required: true, type: 'select' },
  { text: '幅度', value: 'amplitude', align: 'center', required: true, type: 'number' },
  { text: '幅度单位', value: 'amplitudeUnit', align: 'center', required: true, type: 'select' },
  { text: '技术指标', value: 'technicalIndex', align: 'center', required: false, type: 'number', width: 140 },
  { text: '是否为参考点', value: 'referencePoint', align: 'center', required: true, type: 'radio', width: 140 },
])

const columns_gain_compression_point = ref<TableColumn[]>([ // 1dB增益压缩点
  { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '输入衰减器', value: 'inputAttenuator', align: 'center', required: true, type: 'select-dict', code: 'inputAttenuationStandardAttenuatorAttenuation' },
  { text: '输入衰减器单位', value: 'inputAttenuatorUnit', align: 'center', required: true, type: 'select' },
  { text: '参考电平', value: 'spectrumLevel', align: 'center', required: true, type: 'select-dict', code: 'inputAttenuationSpectrumLevel' },
  { text: '参考电平单位', value: 'spectrumLevelUnit', align: 'center', required: true, type: 'select' },
  { text: '频率', value: 'frequency', align: 'center', required: true, type: 'select-dict', code: 'inputAttenuationFrequency' },
  { text: '频率单位', value: 'frequencyUnit', align: 'center', required: true, type: 'select' },
  { text: '幅度', value: 'amplitude', align: 'center', required: true, type: 'number' },
  { text: '幅度单位', value: 'amplitudeUnit', align: 'center', required: true, type: 'select' },
  { text: '技术指标', value: 'technicalIndex', align: 'center', required: false, type: 'number', width: 220 },
])
const columns_calibrating_signal = ref<TableColumn[]>([ // 校准信号
  { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '类型', value: 'typeValue', align: 'center', required: true, type: 'select' },
  { text: '标称值', value: 'nominalValue', align: 'center', required: true, type: 'number' },
  { text: '标称值单位', value: 'unit', align: 'center', required: true, type: 'select' },
  { text: '技术指标', value: 'technicalIndex', align: 'center', required: false, type: 'number' },
])
// --------------------------------表格操作---------------------------------------------------
// 表格对应 columns字典
const columnsDict = ref<{ [key: string]: any }>(
  {
    '1-频率显示': columns_frequency.value,
    '2-扫频宽度': columns_sweep_width.value,
    '3-中频带宽': columns_intermediate_frequency_bandwidth.value,
    '4-中频带宽转换偏差': columns_transition_deviation.value,
    '5-参考电平': columns_reference_electrical_level.value,
    '6-垂直刻度(显示位置从上到下)': columns_vertical_graduated.value,
    '7-输入频响': columns_input_frequency_response.value,
    '8-平均噪声电平': columns_average_noise_level.value,
    '9-谐波失真': columns_harmonic_distortion.value,
    '10-输入衰减': columns_input_attenuator.value,
    '11-1dB增益压缩点': columns_gain_compression_point.value,
    '12-校准信号': columns_calibrating_signal.value,
  },
)
/**
 * 增加行公共方法
 * @param list 要操作的数组
 * @param title 操作的表格
 */
const addRow = (list: IList[], title: string, index: string) => {
  if (checkList(list, columnsDict.value[`${index}-${title}`], `${title}表格`)) {
    switch (title) {
      case '频率显示': // 频率显示
        frequencyList.value.length
          ? frequencyList.value.push(JSON.parse(JSON.stringify({ ...frequencyList.value[frequencyList.value.length - 1], id: `custom-${new Date().getTime()}` })))
          : frequencyList.value.push({
            dataType: '1',
            params: '频率显示',
            unit: '', // 标称值单位
            nominalValue: '', // 标称值
            sweepWidth: '', // 扫频宽度
            sweepWidthUnit: '', // 扫频宽度单位
            horizontalResolution: '', // 水平分辨率
            horizontalResolutionUnit: '', // 水平分辨率单位
            resolutionBandwidth: '', // 分辨率带宽
            resolutionBandwidthUnit: '', // 分辨率带宽单位
            frequency: '', // 频率
            frequencyUnit: '', // 频率单位
            amplitude: '', // 幅度
            amplitudeUnit: '', // 幅度单位
            frequencyReferenceAccuracy: form.value.frequencyReferenceAccuracy, // 频率基准精度
            valueOne: form.value.valueOne, // 数值1
            valueTwo: form.value.valueTwo, // 数值2
            valueThree: form.value.valueThree, // 数值3
            valueFour: form.value.valueFour, // 数值4
            editable: true,
            id: `custom-${new Date().getTime()}`,
          } as any)
        break
      case '扫频宽度': // 扫频宽度
        sweepWidthList.value.length
          ? sweepWidthList.value.push(JSON.parse(JSON.stringify({ ...sweepWidthList.value[sweepWidthList.value.length - 1], id: `custom-${new Date().getTime()}` })))
          : sweepWidthList.value.push({
            dataType: '2',
            params: '扫频宽度',
            unit: '', // 标称值单位
            nominalValue: '', // 标称值
            horizontalResolution: '', // 水平分辨率
            horizontalResolutionUnit: '', // 水平分辨率单位
            frequency: '', // 频率
            frequencyUnit: '', // 频率单位
            amplitude: '', // 幅度
            amplitudeUnit: '', // 幅度单位
            technicalIndex: '', // 技术指标
            valueOne: '', // 技术指标数值
            technicalIndexSymbol: '±', // 技术指标符号
            editable: true,
            id: `custom-${new Date().getTime()}`,
          } as any)
        break
      case '中频带宽': // 中频带宽
        intermediateFrequencyBandwidthList.value.length
          ? intermediateFrequencyBandwidthList.value.push(JSON.parse(JSON.stringify({ ...intermediateFrequencyBandwidthList.value[intermediateFrequencyBandwidthList.value.length - 1], id: `custom-${new Date().getTime()}` })))
          : intermediateFrequencyBandwidthList.value.push({
            dataType: '3',
            params: '中频带宽',
            unit: '', // 标称值单位
            nominalValue: '', // 标称值
            frequency: '', // 频率
            frequencyUnit: '', // 频率单位
            amplitude: '', // 幅度
            amplitudeUnit: '', // 幅度单位
            technicalIndex: '', // 技术指标
            valueOne: '', // 技术指标
            valueTwo: '', // 技术指标
            technicalIndexSymbol: '±', // 技术指标符号
            editable: true,
            id: `custom-${new Date().getTime()}`,
          } as any)
        break
      case '中频带宽转换偏差': // 中频带宽转换偏差
        transitionDeviationList.value.length
          ? transitionDeviationList.value.push(JSON.parse(JSON.stringify({ ...transitionDeviationList.value[transitionDeviationList.value.length - 1], id: `custom-${new Date().getTime()}`, referencePoint: transitionDeviationList.value.every((item: any) => item.referencePoint === '0') ? '1' : '0' } as any)))
          : transitionDeviationList.value.push({
            dataType: '4',
            params: '中频带宽转换偏差',
            unit: '', // 标称值单位
            nominalValue: '', // 标称值
            frequency: '', // 频率
            frequencyUnit: '', // 频率单位
            amplitude: '', // 幅度
            amplitudeUnit: '', // 幅度单位
            technicalIndex: '', // 技术指标
            technicalIndexUnit: 'dB', // 技术指标单位
            technicalIndexSymbol: '±', // 技术指标符号
            referencePoint: '1',
            editable: true,
            id: `custom-${new Date().getTime()}`,
          } as any)
        break
      case '参考电平': // 参考电平
        referenceElectricalLevelList.value.length
          ? referenceElectricalLevelList.value.push(JSON.parse(JSON.stringify({ ...referenceElectricalLevelList.value[referenceElectricalLevelList.value.length - 1], id: `custom-${new Date().getTime()}`, referencePoint: referenceElectricalLevelList.value.every((item: any) => item.referencePoint === '0') ? '1' : '0' } as any)))
          : referenceElectricalLevelList.value.push({
            dataType: '5',
            params: '参考电平',
            unit: '', // 标称值单位
            nominalValue: '', // 标称值
            frequency: '', // 频率
            frequencyUnit: '', // 频率单位
            amplitude: '', // 幅度
            amplitudeUnit: '', // 幅度单位
            technicalIndex: '', // 技术指标
            technicalIndexUnit: 'dB', // 技术指标单位
            referencePoint: '1',
            technicalIndexSymbol: '±', // 技术指标符号
            standardAttenuatorAttenuation: '', // 标准衰减器衰减量
            standardAttenuatorAttenuationUnit: '', // 标准衰减器衰减量单位
            editable: true,
            id: `custom-${new Date().getTime()}`,
          } as any)
        break
      case '垂直刻度(显示位置从上到下)': // 频率显示
        verticalGraduatedList.value.length
          ? verticalGraduatedList.value.push(JSON.parse(JSON.stringify({
            ...verticalGraduatedList.value[verticalGraduatedList.value.length - 1], id: `custom-${new Date().getTime()}`,
            verticalScale: verticalGraduatedList.value[verticalGraduatedList.value.length - 1].verticalScale ?
              verticalGraduatedList.value[verticalGraduatedList.value.length - 1].verticalScale.length === '4' ?
                '第1格' :
                `第${Number((verticalGraduatedList.value[verticalGraduatedList.value.length - 1]?.verticalScale || '0').replace(/[^\d]/g, ' ') || '0') + 1}格`
              : '起始幅度'

          })))
          : verticalGraduatedList.value.push({
            dataType: '6',
            params: '垂直刻度',
            unit: '', // 标称值单位
            nominalValue: '', // 标称值
            standardAttenuatorAttenuation: '', // 标准衰减器衰减量
            standardAttenuatorAttenuationUnit: '', // 标准衰减器衰减量单位
            signalSourceAmplitude: '', // 信号源幅度
            signalSourceAmplitudeUnit: '', // 信号源幅度单位
            verticalScale: '起始幅度', // 垂直刻度
            frequency: '', // 频率
            frequencyUnit: '', // 频率单位
            amplitude: '', // 幅度
            amplitudeUnit: '', // 幅度单位
            technicalIndex: '', // 技术指标
            technicalIndexUnit: 'dB', // 技术指标单位
            technicalIndexSymbol: '±', // 技术指标符号
            editable: true,
            id: `custom-${new Date().getTime()}`,
          } as any)
        break
      case '输入频响': // 输入频响
        inputFrequencyResponseList.value.length
          ? inputFrequencyResponseList.value.push(JSON.parse(JSON.stringify({ ...inputFrequencyResponseList.value[inputFrequencyResponseList.value.length - 1], id: `custom-${new Date().getTime()}`, referencePoint: inputFrequencyResponseList.value.every((item: any) => item.referencePoint === '0') ? '1' : '0' } as any)))
          : inputFrequencyResponseList.value.push({
            dataType: '7',
            params: '输入频响',
            frequency: '', // 频率
            frequencyUnit: '', // 频率单位
            amplitude: '', // 幅度
            amplitudeUnit: '', // 幅度单位
            technicalIndex: '', // 技术指标
            technicalIndexUnit: 'dB', // 技术指标单位
            technicalIndexSymbol: '±', // 技术指标符号
            referencePoint: '1',
            editable: true,
            id: `custom-${new Date().getTime()}`,
          } as any)
        break
      case '平均噪声电平': // 平均噪声电平
        averageNoiseLevelList.value.length
          ? averageNoiseLevelList.value.push(JSON.parse(JSON.stringify({ ...averageNoiseLevelList.value[averageNoiseLevelList.value.length - 1], id: `custom-${new Date().getTime()}` })))
          : averageNoiseLevelList.value.push({
            dataType: '8',
            preAmplifier: '',
            params: '平均噪声电平',
            startFrequency: '', // 起始频率
            startFrequencyUnit: '', // 起始频率单位
            endFrequency: '', // 终止频率
            endFrequencyUnit: '', // 终止频率单位
            correctedValue: '', // 修正值
            upperIndex: '', // 指标上限
            editable: true,
            id: `custom-${new Date().getTime()}`,
          } as any)
        break
      case '谐波失真': // 谐波失真
        harmonicDistortionList.value.length
          ? harmonicDistortionList.value.push(JSON.parse(JSON.stringify({ ...harmonicDistortionList.value[harmonicDistortionList.value.length - 1], id: `custom-${new Date().getTime()}` })))
          : harmonicDistortionList.value.push({
            dataType: '9',
            params: '谐波失真',
            frequency: '', // 频率
            frequencyUnit: '', // 频率
            amplitude: '', // 幅度
            amplitudeUnit: '', // 幅度单位
            rbwValue: '1', // RBW
            rbwValueUnit: '', // RBW单位
            vbwValue: '1', // VBW
            vbwValueUnit: '', // VBW单位
            upperIndexTwice: '', // 二次谐波失真指标上限
            upperIndexThrice: '', // 三次谐波失真指标上限
            upperIndexQuartic: '', // 四次谐波失真指标上限
            id: `custom-${new Date().getTime()}`,
            editable: true,
          } as any)
        break
      case '输入衰减': // 输入衰减
        inputAttenuatorList.value.length
          ? inputAttenuatorList.value.push(JSON.parse(JSON.stringify({ ...inputAttenuatorList.value[inputAttenuatorList.value.length - 1], id: `custom-${new Date().getTime()}`, referencePoint: inputAttenuatorList.value.every((item: any) => item.referencePoint === '0') ? '1' : '0' } as any)))
          : inputAttenuatorList.value.push({
            dataType: '10',
            params: '输入衰减',
            frequency: '', // 频率
            frequencyUnit: '', // 频率单位
            amplitude: '', // 幅度
            amplitudeUnit: '', // 幅度单位
            spectrumLevel: '', // 频谱仪参考电平
            spectrumLevelUnit: '', // 频谱仪参考电平单位
            standardAttenuatorAttenuation: '', // 衰减器衰减量
            standardAttenuatorAttenuationUnit: '', // 衰减器衰减量单位
            inputAttenuator: '', // 输入衰减器
            inputAttenuatorUnit: '', // 输入衰减器单位
            technicalIndex: '', // 技术指标
            technicalIndexUnit: 'dB', // 技术指标单位
            referencePoint: '1',
            technicalIndexSymbol: '±', // 技术指标符号
            editable: true,
            id: `custom-${new Date().getTime()}`,
          } as any)
        break
      case '1dB增益压缩点': // 1dB增益压缩点
        gainCompressionPointList.value.length
          ? gainCompressionPointList.value.push(JSON.parse(JSON.stringify({ ...gainCompressionPointList.value[gainCompressionPointList.value.length - 1], id: `custom-${new Date().getTime()}` })))
          : gainCompressionPointList.value.push({
            dataType: '11',
            params: '1dB增益压缩点',
            inputAttenuator: '', // 输入衰减器
            inputAttenuatorUnit: '', // 输入衰减器单位
            spectrumLevel: '', // 参考电平
            spectrumLevelUnit: '', // 参考电平单位
            frequency: '', // 频率
            frequencyUnit: '', // 频率单位
            amplitude: '', // 幅度
            amplitudeUnit: '', // 幅度单位
            technicalIndex: '', // 技术指标
            technicalIndexUnit: 'dB', // 技术指标单位
            technicalIndexSymbol: '±', // 技术指标符号
            editable: true,
            id: `custom-${new Date().getTime()}`,
          } as any)
        break
      case '校准信号': // 校准信号
        calibratingSignalList.value.length
          ? calibratingSignalList.value.push(JSON.parse(JSON.stringify({ ...calibratingSignalList.value[calibratingSignalList.value.length - 1], id: `custom-${new Date().getTime()}` })))
          : calibratingSignalList.value.push({
            dataType: '12',
            params: '校准信号',
            technicalIndex: '', // 技术指标
            technicalIndexUnit: '', // 技术指标单位
            technicalIndexSymbol: '±', // 技术指标符号
            typeValue: '', // 类型
            nominalValue: '', // 标称值
            unit: '', // 标称值单位
            editable: true,
            id: `custom-${new Date().getTime()}`,
          } as any)
        break
    }
  }
}
/**
 * 删除行公共方法
 * @param checkoutList 选中的数组
 * @param list 操作的数组
 */
const delRow = (checkoutList: IList[], list: IList[], title: string) => {
  if (!checkoutList.length) {
    ElMessage.warning('请选中要删除的行')
  }
  else {
    let data = [] as any[]
    data = differenceArray(list, checkoutList)
    switch (title) {
      case '频率显示': // 频率显示
        frequencyList.value = data
        break
      case '扫频宽度': // 扫频宽度
        sweepWidthList.value = data
        break
      case '中频带宽': // 中频带宽
        intermediateFrequencyBandwidthList.value = data
        break
      case '中频带宽转换偏差': // 中频带宽转换偏差
        transitionDeviationList.value = data
        break
      case '参考电平': // 参考电平
        referenceElectricalLevelList.value = data
        break
      case '垂直刻度(显示位置从上到下)': // 垂直刻度(显示位置从上到下)
        verticalGraduatedList.value = data
        break
      case '输入频响': // 垂直刻度(显示位置从上到下)
        inputFrequencyResponseList.value = data
        break
      case '平均噪声电平': // 平均噪声电平
        averageNoiseLevelList.value = data
        break
      case '谐波失真': // 谐波失真
        harmonicDistortionList.value = data
        break
      case '输入衰减': // 输入衰减
        inputAttenuatorList.value = data
        break
      case '1dB增益压缩点': // 1dB增益压缩点
        gainCompressionPointList.value = data
        break
      case '校准信号': // 校准信号
        calibratingSignalList.value = data
        break
    }

    // 垂直刻度的垂直刻度字段需要重新排序
    if (title === '垂直刻度(显示位置从上到下)') {
      verticalGraduatedList.value.forEach((item: any, index: number) => {
        verticalGraduatedList
        if (index === 0) {
          item.verticalScale = '起始幅度'
        }
        else {
          item.verticalScale = `第${index}格`
        }
      })
    }
  }
}
//  表格公共操作方法(需要单独处理)
const handlerType = () => {
  verticalGraduatedList.value.forEach((item: any, index: number) => {
    verticalGraduatedList
    if (index === 0) {
      item.verticalScale = '起始幅度'
    }
    else {
      item.verticalScale = `第${index}格`
    }
  })
}

// ---------------------------------------------校验---------------------------------------------------
// 校验表格(点击保存的时候用、生成标准器示值)
function checkList(list: any[], columns: any[], title: string) {
  return useCheckList(list, columns, title)
}
// 校验所有表格
function checkAllList() {
  let result = true
  for (const i in columnsDict.value) {
    if (!Number(chekedDict[i])) {
      result = true
    }
    else {
      const requireLength = !!((chekedDict[i] === '1' || chekedDict[i] === 1) && chekedDict[i])
      if (!useCheckList(listDict.value[i], columnsDict.value[i], i.substring(2), '', '', '', requireLength)) {
        result = false
        break
      }
    }
  }
  return result
}

// -----------------------------------------------------------------------------------------------------
const clearAllList = () => {
  list.value = []
  frequencyList.value = []
  sweepWidthList.value = []
  intermediateFrequencyBandwidthList.value = []
  transitionDeviationList.value = []
  referenceElectricalLevelList.value = []
  verticalGraduatedList.value = []
  inputFrequencyResponseList.value = []
  averageNoiseLevelList.value = []
  harmonicDistortionList.value = []
  inputAttenuatorList.value = []
  gainCompressionPointList.value = []
  calibratingSignalList.value = []
  for (const i in listDict.value) {
    listDict.value[i] = []
  }
}
watch(() => props.list, (newVal) => { // 检定项表格
  if (newVal) {
    clearAllList()
    newVal.forEach((item: any) => {
      switch (item.dataType) {
        case '1':
          // 频率显示
          frequencyList.value.push({ ...item, params: '频率显示' })
          form.value
          form.value.frequencyReferenceAccuracy = item.frequencyReferenceAccuracy
          form.value.valueOne = item.valueOne
          form.value.valueTwo = item.valueTwo
          form.value.valueThree = item.valueThree
          form.value.valueFour = item.valueFour
          break
        case '2':
          // 扫频宽度
          sweepWidthList.value.push({ ...item, params: '扫频宽度', technicalIndexSymbol: '±', technicalIndex: item.technicalIndex.includes('/') ? '/' : Number(clearSymbol(item.technicalIndex)) })
          break
        case '3':
          // 中频带宽
          intermediateFrequencyBandwidthList.value.push({ ...item, params: '中频带宽', technicalIndexSymbol: '±', technicalIndex: item.technicalIndex.includes('/') ? '/' : Number(clearSymbol(item.technicalIndex)) })
          break
        case '4':
          // 中频带宽转换偏差
          transitionDeviationList.value.push({ ...item, params: '中频带宽转换偏差', technicalIndexSymbol: '±', technicalIndex: item.technicalIndex.includes('/') ? '/' : Number(clearSymbol(item.technicalIndex)), referencePoint: String(item.referencePoint) })
          break
        case '5':
          // 参考电平
          referenceElectricalLevelList.value.push({ ...item, params: '参考电平', technicalIndexSymbol: '±', technicalIndex: item.technicalIndex.includes('/') ? '/' : Number(clearSymbol(item.technicalIndex)), referencePoint: String(item.referencePoint) })
          break
        case '6':
          // 垂直刻度
          verticalGraduatedList.value.push({ ...item, params: '垂直刻度', technicalIndexSymbol: '±', technicalIndex: item.technicalIndex.includes('/') ? '/' : Number(clearSymbol(item.technicalIndex)) })
          break
        case '7':
          // 输入频响
          inputFrequencyResponseList.value.push({ ...item, params: '输入频响', technicalIndexSymbol: '±', technicalIndex: item.technicalIndex.includes('/') ? '/' : Number(clearSymbol(item.technicalIndex)), referencePoint: String(item.referencePoint) })
          break
        case '8':
          // 平均噪声电平
          averageNoiseLevelList.value.push({ ...item, params: '平均噪声电平' })
          break
        case '9':
          // 谐波失真
          harmonicDistortionList.value.push({ ...item, params: '谐波失真' })
          break
        case '10':
          // 输入衰减
          inputAttenuatorList.value.push({ ...item, params: '输入衰减', technicalIndexSymbol: '±', technicalIndex: item.technicalIndex.includes('/') ? '/' : Number(clearSymbol(item.technicalIndex)), referencePoint: String(item.referencePoint) })
          break
        case '11':
          // 1dB增益压缩点
          gainCompressionPointList.value.push({ ...item, params: '1dB增益压缩点', technicalIndexSymbol: item.technicalIndex.substring(0, 1) === '/' ? '±' : item.technicalIndex.substring(0, 1), technicalIndex: item.technicalIndex.includes('/') ? '/' : Number(clearSymbol(item.technicalIndex)) })
          break
        case '12':
          // 校准信号
          calibratingSignalList.value.push({ ...item, params: '校准信号', technicalIndexSymbol: '±', technicalIndex: Number(clearSymbol(item.technicalIndex)) })
          break
      }
    })
  }
})
const getList = () => {
  let result = [] as any[]
  for (const i in chekedDict) {
    if ((chekedDict[i] === '1' || chekedDict[i] === 1) && chekedDict[i]) {
      const data = listDict.value[i].map((item: any) => {
        return {
          ...item,
          technicalIndex: clearSymbol(String(item.technicalIndex === 0 ? '0' : item.technicalIndex ? item.technicalIndex : '') || '+') ? `${item.technicalIndexSymbol || ''}${item.technicalIndex}` : '/',
          valueOne: item.valueOne ? item.valueOne : '',
          valueTwo: item.valueTwo ? item.valueTwo : '',
        }
      },

      )
      result = [...result, ...data]
    }
  }
  return result
}

// 表格下拉框等内容是否禁用
const disabled = ({ scope, column }, fun) => {
  if (scope.row.params === '垂直刻度' && column.text === '垂直刻度') {
    fun(true)
    return
  }
  fun(props.pageType === 'detail')
}
// 每个table对应的下拉框内容 字典
const tableDict = ref<{ [key: string]: { value: string; name: string; id: string }[] }>({})
const changeLoadSituationa = (value: any, index: number, text: string, type: string, list: any[], item: string) => {
  if (item === '频率显示') {
    if (text === '标称值') {
      frequencyList.value[index].frequency = value
    }
    if (text === '标称值单位') {
      frequencyList.value[index].frequencyUnit = typeof value === 'string' ? value : ''
    }
  }
  if (item === '中频带宽') {
    if (text === '技术指标') {
      if (String(list[index].valueOne) && String(list[index].valueTwo)) {
        list[index].technicalIndex = '0'
      }
    }
  }
  if (item === '中频带宽转换偏差' || item === '参考电平' || item === '输入频响' || item === '输入衰减') {
    if (text === '是否为参考点') {
      if (value === '1') {
        list.forEach((citem: any, cindex: number) => {
          list[cindex].referencePoint = '0'
        })
        list[index].referencePoint = '1'
      }
      else {
        if (list.every((item: { referencePoint: any }) => item.referencePoint === '0' || item.referencePoint === 0)) {
          list[0].referencePoint = '1'
        }
      }
    }
  }
  if (item === '谐波失真') {
    if (text === '二次谐波失真指标上限') {
      list[index].upperIndexThrice = value
      list[index].upperIndexQuartic = value
      // list[index].upperIndexThrice ? '' : list[index].upperIndexThrice = value
      // list[index].upperIndexQuartic ? '' : list[index].upperIndexQuartic = value
    }
  }
  if (item === '校准信号') {
    if (text === '标称值单位') {
      list[index].technicalIndexUnit = typeof value === 'string' ? value : ''
    }
    if (text === '类型') {
      typeof value === 'string' ? list[index].unit = '' : ''
    }
  }
}

// 获取字典
const nominalValueUnit = ref<{ value: string; name: string; id: string }[]>([]) // 标称值单位
const amplitudeUnit = ref<{ value: string; name: string; id: string }[]>([]) // 幅度单位
const standardAttenuatorAttenuationUnit = ref<{ value: string; name: string; id: string }[]>([]) // 标准衰减器衰减量单位
const verticalScale = ref<{ value: string; name: string; id: string }[]>([]) // 垂直刻度
const typeValue = ref<{ value: string; name: string; id: string }[]>([]) // 校准信号类型
const symbolList = ref<{ value: string; name: string; id: string }[]>([]) // 技术指标符号
const inputAttenuationFrequency = ref<{ value: string; name: string; id: string }[]>([]) // 频率
const inputAttenuationSpectrumLevel = ref<{ value: string; name: string; id: string }[]>([]) // 参考电平
const inputAttenuationStandardAttenuatorAttenuation = ref<{ value: string; name: string; id: string }[]>([]) // 输入衰减器
const averageNoiseLevelStartFrequency = ref<{ value: string; name: string; id: string }[]>([]) // 起始频率|终止频率
const signalSourceAmplitude = ref<{ value: string; name: string; id: string }[]>([]) // 信号源幅度
const standardAttenuatorAttenuation = ref<{ value: string; name: string; id: string }[]>([]) // 标准衰减器衰减量
const sweepWidthNominalValue = ref<{ value: string; name: string; id: string }[]>([]) // 标称值
const frequencysweepWidth = ref<{ value: string; name: string; id: string }[]>([]) // 扫频宽度
const preAmplifier = ref<{ value: string; name: string; id: string }[]>([]) // 前置放大器设置
const fetchDict = async () => {
  // 标称值单位
  const res1 = await getDictByCode('standardFrequencyUnit')
  nominalValueUnit.value = res1.data
  // 幅度单位
  const res2 = await getDictByCode('standardAmplitudeUnit')
  amplitudeUnit.value = res2.data
  // 标准衰减器衰减量单位
  const res3 = await getDictByCode('standardDBunit')
  standardAttenuatorAttenuationUnit.value = res3.data
  // 垂直刻度
  const res4 = await getDictByCode('verticalScale')
  verticalScale.value = res4.data
  // 校准信号类型
  const res5 = await getDictByCode('calibratingSignalType')
  typeValue.value = res5.data
  // 技术指标符号
  const res6 = await getDictByCode('standardTechnicalIndexSymbol')
  symbolList.value = res6.data
  // 频率
  const res7 = await getDictByCode('inputAttenuationFrequency')
  inputAttenuationFrequency.value = res7.data
  // 频率
  const res8 = await getDictByCode('inputAttenuationSpectrumLevel')
  inputAttenuationSpectrumLevel.value = res8.data
  // 输入衰减器
  const res9 = await getDictByCode('inputAttenuationStandardAttenuatorAttenuation')
  inputAttenuationStandardAttenuatorAttenuation.value = res9.data
  // 起始频率|终止频率
  const res10 = await getDictByCode('averageNoiseLevelStartFrequency')
  averageNoiseLevelStartFrequency.value = res10.data
  // 信号源幅度
  const res11 = await getDictByCode('signalSourceAmplitude')
  signalSourceAmplitude.value = res11.data
  // 标称值
  const res12 = await getDictByCode('sweepWidthNominalValue')
  sweepWidthNominalValue.value = res12.data
  // 扫频宽度
  const res13 = await getDictByCode('frequencysweepWidth')
  frequencysweepWidth.value = res13.data

  preAmplifier.value = [
    {
      name: '前置放大器开',
      value: '前置放大器开',
      id: '1',
    },
    {
      name: '前置放大器关',
      value: '前置放大器关',
      id: '2',
    },
  ]
  tableDict.value = {
    标称值单位: nominalValueUnit.value,
    频率单位: nominalValueUnit.value,
    VBW单位: nominalValueUnit.value,
    RBW单位: nominalValueUnit.value,
    起始频率单位: nominalValueUnit.value,
    终止频率单位: nominalValueUnit.value,
    扫频宽度单位: nominalValueUnit.value,
    水平分辨率单位: nominalValueUnit.value,
    分辨率带宽单位: nominalValueUnit.value,
    幅度单位: amplitudeUnit.value,
    信号源幅度单位: amplitudeUnit.value,
    标准衰减器衰减量单位: standardAttenuatorAttenuationUnit.value,
    输入衰减器单位: standardAttenuatorAttenuationUnit.value,
    输入衰减单位: standardAttenuatorAttenuationUnit.value,
    频谱仪参考电平单位: standardAttenuatorAttenuationUnit.value,
    参考电平单位: amplitudeUnit.value,
    垂直刻度: verticalScale.value,
    类型: typeValue.value,
    频率: inputAttenuationFrequency.value,
    参考电平: inputAttenuationSpectrumLevel.value,
    频谱仪参考电平: inputAttenuationSpectrumLevel.value,
    输入衰减器: inputAttenuationStandardAttenuatorAttenuation.value,
    标准衰减器衰减量: inputAttenuationStandardAttenuatorAttenuation.value,
    起始频率: averageNoiseLevelStartFrequency.value,
    终止频率: averageNoiseLevelStartFrequency.value,
    信号源幅度: signalSourceAmplitude.value,
    // 标准衰减器衰减量: standardAttenuatorAttenuation.value,
    标称值: sweepWidthNominalValue.value,
    扫频宽度: frequencysweepWidth.value,
    前置放大器设置: preAmplifier.value,
  }
}
fetchDict()

// 自定义下拉框内容
const customSelect = (data: any, fun: any) => {
  if (data.title === '校准信号' && data.text === '标称值单位') {
    if (data.scope.row.typeValue === '频率') {
      fun(nominalValueUnit.value)
    }
    else {
      fun(amplitudeUnit.value)
    }
  }
  else if (data.title === '垂直刻度(显示位置从上到下)' && data.text === '标称值单位') {
    fun(amplitudeUnit.value)
  }
  else if (data.title === '参考电平' && data.text === '标称值单位') {
    fun(amplitudeUnit.value)
  }
  else {
    fun(tableDict.value[data.text])
  }
}

// 清空配置方法
const clearConfig = () => {
  frequencyList.value = []// 频率显示
  sweepWidthList.value = []// 扫频宽度
  intermediateFrequencyBandwidthList.value = []// 中频带宽
  transitionDeviationList.value = []// 中频带宽转换偏差
  referenceElectricalLevelList.value = []// 参考电平
  verticalGraduatedList.value = []// 垂直刻度(显示位置从上到下)
  inputFrequencyResponseList.value = []// 输入频响
  averageNoiseLevelList.value = []// 平均噪声电平
  harmonicDistortionList.value = []// 谐波失真
  inputAttenuatorList.value = []// 输入衰减
  gainCompressionPointList.value = []// 1dB增益压缩点
  calibratingSignalList.value = []// 校准信号

  form.value.frequencyReferenceAccuracy = '' // 频率基准精度
  form.value.valueOne = '' // 数值1
  form.value.valueTwo = '' // 数值2
  form.value.valueThree = '' // 数值3
  form.value.valueFour = '' // 数值4
}

defineExpose({ list, checkAllList, form, getList, clearConfig })
</script>

<template>
  <div style="padding: 0 10px;">
    <el-checkbox v-model="form.appearanceFunctionCheck" :checked="true" :true-label="1" :false-label="0"
      :disabled="pageType === 'detail'">
      外观及功能性检查
    </el-checkbox>
  </div>
  <!-- 频率显示 -->
  <template-table1 :show="Boolean(form.frequencyDisplay)" :data="frequencyList" :columns="columns_frequency"
    :page-type="pageType" title="频率显示" index="1" :show-btn="pageType !== 'detail'" :select-all-list="tableDict"
    @disabled="disabled" @add-row="addRow" @del-row="delRow" @change-load-situationa="changeLoadSituationa">
    <template #custom-check>
      <el-checkbox v-model="form.frequencyDisplay" :checked="true" :true-label="1" :false-label="0"
        :disabled="pageType === 'detail'">
        频率显示
      </el-checkbox>
      <div v-if="form.frequencyDisplay" style="display: flex;align-items: center;margin-bottom: 10px;">
        <span style="white-space: nowrap;"> 技术指标:± ( 标称值 ×</span>
        <!-- <el-input-number
          v-model="form.frequencyReferenceAccuracy"
          :placeholder="pageType === 'detail' ? '' : '频率基准精度'"
          :disabled="pageType === 'detail'"
          :precision="4"
          :step="0.1"
          :min="0"
          style="width: 180px !important;margin: 0 10px;"
        /> -->
        <scientific-notation v-model="form.frequencyReferenceAccuracy"
          :placeholder="pageType === 'detail' ? '' : '频率基准精度'" :disabled="pageType === 'detail'" number-digit="4"
          :step="0.1" :min="0" style="width: 180px !important;margin: 0 10px;" :required="true" />
        <span style="white-space: nowrap;"> + </span>
        <precision-input-number v-model="form.valueOne" :placeholder="pageType === 'detail' ? '' : '数值(%)'"
          :disabled="pageType === 'detail'" :precision="4" :step="0.1" :min="0" style="width: 140px;margin: 0 10px;" />
        <span style="white-space: nowrap;"> × 扫频宽度 + </span>
        <precision-input-number v-model="form.valueTwo" :placeholder="pageType === 'detail' ? '' : '数值(%)'"
          :disabled="pageType === 'detail'" :precision="4" :step="0.1" :min="0" style="width: 140px;margin: 0 10px;" />
        <span style="white-space: nowrap;"> × 分辨率带宽 + </span>
        <precision-input-number v-model="form.valueThree" :placeholder="pageType === 'detail' ? '' : '数值(Hz)'"
          :disabled="pageType === 'detail'" :precision="4" :step="0.1" :min="0" style="width: 140px;margin: 0 10px;" />
        <span style="white-space: nowrap;"> + </span>
        <precision-input-number v-model="form.valueFour" :placeholder="pageType === 'detail' ? '' : '数值'"
          :disabled="pageType === 'detail'" :precision="4" :step="0.1" :min="0" style="width: 140px;margin: 0 10px;" />
        <span style="white-space: nowrap;"> × 水平分辨率) </span>
      </div>
    </template>
  </template-table1>
  <!-- 扫频宽度 -->
  <template-table1 :show="Boolean(form.sweepWidth)" :data="sweepWidthList" :columns="columns_sweep_width"
    :page-type="pageType" title="扫频宽度" index="2" :show-btn="pageType !== 'detail'" :select-all-list="tableDict"
    @disabled="disabled" @add-row="addRow" @del-row="delRow" @change-load-situationa="changeLoadSituationa">
    <template #custom-check>
      <el-checkbox v-model="form.sweepWidth" :checked="true" :true-label="1" :false-label="0"
        :disabled="pageType === 'detail'">
        扫频宽度
      </el-checkbox>
    </template>
    <!-- 符号 -->
    <template #pre-content="{ column }">
      <template v-if="column.text === '技术指标'">
        ±
      </template>
    </template>
    <!-- 技术指标 -->
    <template #next-content="{ scope, column }">
      <template v-if="column.text === '技术指标'">
        <span style="display: inline-block;">%</span>
        <span style="display: inline-block;">×</span>
        <el-input v-model="scope.nominalValue" placeholder="标称值" disabled style="width: 80px;" />
        +
        <el-input v-model="scope.horizontalResolution" placeholder="水平分辨力" style="width: 80px;" disabled />
      </template>
    </template>
  </template-table1>
  <!-- 中频带宽 -->
  <template-table1 :show="Boolean(form.middleFrequencyWidth)" :data="intermediateFrequencyBandwidthList"
    :columns="columns_intermediate_frequency_bandwidth" :page-type="pageType" title="中频带宽" index="3"
    :show-btn="pageType !== 'detail'" :select-all-list="tableDict" @disabled="disabled" @add-row="addRow"
    @del-row="delRow" @change-load-situationa="changeLoadSituationa">
    <template #custom-check>
      <el-checkbox v-model="form.middleFrequencyWidth" :checked="true" :true-label="1" :false-label="0"
        :disabled="pageType === 'detail'">
        中频带宽
      </el-checkbox>
    </template>
    <template #next-content="{ scope, column }">
      <template v-if="column.text === '技术指标'">
        <precision-input-number v-model="scope.valueOne" placeholder="数值" controls-position="right"
          :disabled="pageType === 'detail'" />
        <span style="display: inline-block;">×</span>
        <el-input v-model="scope.nominalValue" placeholder="标称值" disabled style="width: 80px;" />

        <span style="display: inline-block;"> ~ </span>
        <precision-input-number v-model="scope.valueTwo" placeholder="数值" controls-position="right"
          :disabled="pageType === 'detail'" />
        <span style="display: inline-block;">×</span>
        <el-input v-model="scope.nominalValue" placeholder="标称值" disabled style="width: 80px;" />
      </template>
    </template>
  </template-table1>
  <!-- 中频带宽转换偏差 -->
  <template-table1 :show="Boolean(form.middleConversionDeviation)" :data="transitionDeviationList"
    :columns="columns_transition_deviation" :page-type="pageType" title="中频带宽转换偏差" index="4"
    :show-btn="pageType !== 'detail'" :select-all-list="tableDict" @disabled="disabled" @add-row="addRow"
    @del-row="delRow" @change-load-situationa="changeLoadSituationa">
    <template #custom-check>
      <el-checkbox v-model="form.middleConversionDeviation" :checked="true" :true-label="1" :false-label="0"
        :disabled="pageType === 'detail'">
        中频带宽转换偏差
      </el-checkbox>
    </template>
    <template #pre-content="{ column }">
      <template v-if="column.text === '技术指标'">
        <span style="display: inline-block;">±</span>
      </template>
    </template>
    <template #next-content="{ column }">
      <template v-if="column.text === '技术指标'">
        <span style="display: inline-block;">d</span>
        <span style="display: inline-block;">B</span>
      </template>
    </template>
  </template-table1>
  <!--  参考电平 -->
  <template-table1 :show="Boolean(form.referenceLevel)" :data="referenceElectricalLevelList"
    :columns="columns_reference_electrical_level" :page-type="pageType" title="参考电平" index="5"
    :show-btn="pageType !== 'detail'" :select-all-list="tableDict" :custom-select="true" @disabled="disabled"
    @custom-select="customSelect" @add-row="addRow" @del-row="delRow" @change-load-situationa="changeLoadSituationa">
    <template #custom-check>
      <el-checkbox v-model="form.referenceLevel" :checked="true" :true-label="1" :false-label="0"
        :disabled="pageType === 'detail'">
        参考电平
      </el-checkbox>
    </template>
    <template #pre-content="{ column }">
      <template v-if="column.text === '技术指标'">
        <span style="display: inline-block;">±</span>
      </template>
    </template>
    <template #next-content="{ column }">
      <template v-if="column.text === '技术指标'">
        <span style="display: inline-block;">d</span>
        <span style="display: inline-block;">B</span>
      </template>
    </template>
  </template-table1>

  <!--  垂直刻度(显示位置从上到下) -->
  <template-table1 :show="Boolean(form.verticalScale)" :data="verticalGraduatedList"
    :columns="columns_vertical_graduated" :page-type="pageType" title="垂直刻度(显示位置从上到下)" index="6"
    :show-btn="pageType !== 'detail'" :select-all-list="tableDict" :custom-select="true" @disabled="disabled"
    @custom-select="customSelect" @add-row="addRow" @del-row="delRow" @change-load-situationa="changeLoadSituationa"
    @handlerType="handlerType">
    <template #custom-check>
      <el-checkbox v-model="form.verticalScale" :checked="true" :true-label="1" :false-label="0"
        :disabled="pageType === 'detail'">
        垂直刻度(显示位置从上到下)
      </el-checkbox>
    </template>
    <template #pre-content="{ column }">
      <template v-if="column.text === '技术指标'">
        <span style="display: inline-block;">±</span>
      </template>
    </template>
    <template #next-content="{ column }">
      <template v-if="column.text === '技术指标'">
        <span style="display: inline-block;">d</span>
        <span style="display: inline-block;">B</span>
      </template>
    </template>
  </template-table1>

  <!--  输入频响 -->
  <template-table1 :show="Boolean(form.inputFrequency)" :data="inputFrequencyResponseList"
    :columns="columns_input_frequency_response" :page-type="pageType" title="输入频响" index="7"
    :show-btn="pageType !== 'detail'" :select-all-list="tableDict" @disabled="disabled" @add-row="addRow"
    @del-row="delRow" @change-load-situationa="changeLoadSituationa">
    <template #custom-check>
      <el-checkbox v-model="form.inputFrequency" :checked="true" :true-label="1" :false-label="0"
        :disabled="pageType === 'detail'">
        输入频响
      </el-checkbox>
    </template>
    <template #pre-content="{ column }">
      <template v-if="column.text === '技术指标'">
        <span style="display: inline-block;">±</span>
      </template>
    </template>
    <template #next-content="{ column }">
      <template v-if="column.text === '技术指标'">
        <span style="display: inline-block;">d</span>
        <span style="display: inline-block;">B</span>
      </template>
    </template>
  </template-table1>

  <!--  平均噪声电平 -->
  <template-table1 :show="Boolean(form.averageNoiseLevel)" :data="averageNoiseLevelList"
    :columns="columns_average_noise_level" :page-type="pageType" title="平均噪声电平" index="8"
    :show-btn="pageType !== 'detail'" :select-all-list="tableDict" @disabled="disabled" @add-row="addRow"
    @del-row="delRow" @change-load-situationa="changeLoadSituationa">
    <template #custom-check>
      <el-checkbox v-model="form.averageNoiseLevel" :checked="true" :true-label="1" :false-label="0"
        :disabled="pageType === 'detail'">
        平均噪声电平
      </el-checkbox>
    </template>
    <template #next-content="{ column }">
      <template v-if="column.text === '修正值'">
        <span style="display: inline-block;">d</span>
        <span style="display: inline-block;">B</span>
      </template>
      <template v-if="column.text === '指标上限'">
        <span style="display: inline-block;">d</span>
        <span style="display: inline-block;">B</span>
        <span style="display: inline-block;">m</span>
        <span style="display: inline-block;">/</span>
        <span style="display: inline-block;">H</span>
        <span style="display: inline-block;">z</span>
      </template>
    </template>
  </template-table1>

  <!--  谐波失真 -->
  <template-table1 :show="Boolean(form.harmonicDistortion)" :data="harmonicDistortionList"
    :columns="columns_harmonic_distortion" :page-type="pageType" title="谐波失真" index="9"
    :show-btn="pageType !== 'detail'" :select-all-list="tableDict" @disabled="disabled" @add-row="addRow"
    @del-row="delRow" @change-load-situationa="changeLoadSituationa">
    <template #custom-check>
      <el-checkbox v-model="form.harmonicDistortion" :checked="true" :true-label="1" :false-label="0"
        :disabled="pageType === 'detail'">
        谐波失真
      </el-checkbox>
    </template>
    <template #next-content="{ column }">
      <template v-if="column.text.includes('谐波失真指标上限')">
        <span style="display: inline-block;">d</span>
        <span style="display: inline-block;">B</span>
        <span style="display: inline-block;">c</span>
      </template>
    </template>
  </template-table1>

  <!--  输入衰减 -->
  <template-table1 :show="Boolean(form.inputAttenuation)" :data="inputAttenuatorList"
    :columns="columns_input_attenuator" :page-type="pageType" title="输入衰减" index="10" :show-btn="pageType !== 'detail'"
    :select-all-list="tableDict" @disabled="disabled" @add-row="addRow" @del-row="delRow"
    @change-load-situationa="changeLoadSituationa">
    <template #custom-check>
      <el-checkbox v-model="form.inputAttenuation" :checked="true" :true-label="1" :false-label="0"
        :disabled="pageType === 'detail'">
        输入衰减
      </el-checkbox>
    </template>
    <template #pre-content="{ column }">
      <template v-if="column.text === '技术指标'">
        <!-- 选择下拉框 -->
        <span style="display: inline-block;">±</span>
      </template>
    </template>
    <template #next-content="{ column }">
      <template v-if="column.text === '技术指标'">
        <span style="display: inline-block;">d</span>
        <span style="display: inline-block;">B</span>
        <!-- <span style="display: inline-block;">m</span> -->
      </template>
    </template>
  </template-table1>

  <!--  1dB增益压缩点 -->
  <template-table1 :show="Boolean(form.gainCompression)" :data="gainCompressionPointList"
    :columns="columns_gain_compression_point" :page-type="pageType" title="1dB增益压缩点" index="11"
    :show-btn="pageType !== 'detail'" :select-all-list="tableDict" @disabled="disabled" @add-row="addRow"
    @del-row="delRow" @change-load-situationa="changeLoadSituationa">
    <template #custom-check>
      <el-checkbox v-model="form.gainCompression" :checked="true" :true-label="1" :false-label="0"
        :disabled="pageType === 'detail'">
        1dB增益压缩点
      </el-checkbox>
    </template>
    <template #pre-content="{ scope, column }">
      <template v-if="column.text === '技术指标'">
        <!-- 选择下拉框 -->
        <!-- <span style="display: inline-block;">≥</span> -->
        <el-select v-model="scope.technicalIndexSymbol" :disabled="pageType === 'detail'" style="width: 120px;">
          <!-- standardTechnicalIndexSymbol -->
          <el-option v-for="item in symbolList" :key="item.name" :value="item.name" :label="item.name" />
        </el-select>
      </template>
    </template>
    <template #next-content="{ column }">
      <template v-if="column.text === '技术指标'">
        <span style="display: inline-block;">d</span>
        <span style="display: inline-block;">B</span>
      </template>
    </template>
  </template-table1>

  <!--  校准信号 -->
  <template-table1 :show="Boolean(form.calibratingSignal)" :data="calibratingSignalList"
    :columns="columns_calibrating_signal" :page-type="pageType" title="校准信号" index="12"
    :show-btn="pageType !== 'detail'" :select-all-list="tableDict" :custom-select="true" @disabled="disabled"
    @custom-select="customSelect" @add-row="addRow" @del-row="delRow" @change-load-situationa="changeLoadSituationa">
    <template #custom-check>
      <el-checkbox v-model="form.calibratingSignal" :checked="true" :true-label="1" :false-label="0"
        :disabled="pageType === 'detail'">
        校准信号
      </el-checkbox>
    </template>
    <template #pre-content="{ column }">
      <template v-if="column.text === '技术指标'">
        <!-- 选择下拉框 -->
        <span style="display: inline-block;">±</span>
      </template>
    </template>
    <template #next-content="{ scope, column }">
      <template v-if="column.text === '技术指标'">
        <!-- <span style="display: inline-block;">d</span>
        <span style="display: inline-block;">B</span> -->
        <span v-for="item in scope?.technicalIndexUnit" :key="item" style="display: inline-block;">{{ item }}</span>
      </template>
    </template>
  </template-table1>
</template>