Newer
Older
xc-business-system / src / views / equipement / standard / book / components / config / sixteen / config.vue
dutingting on 29 Nov 34 KB 解决冲突
<!-- 标准库台账信息详情 配置核查项 第16套: 低频信号源 -->
<script name="StandardBookEquipmentConfig" lang="ts" setup>
import { ElLoading, ElMessage, ElMessageBox } from 'element-plus'
import type { IList } from './sixteen-interface'
import TemplateTable from './templateTable.vue'
import type { dictType } from '@/global'
import { useCheckList } from '@/commonMethods/useCheckList'
import type { TableColumn } from '@/components/NormalTable/table_interface'
import { config, getCheckItemDetail } from '@/api/equipment/standard/book'
import { calc } from '@/utils/useCalc'
import { getDictByCode } from '@/api/system/dict'
import { differenceArray, setSelectList } from '@/utils/Array'
import templateTable1 from '@/views/business/measure/item/components/second/templateTable.vue'

const textMap: { [key: string]: string } = {
  edit: '编辑',
  detail: '详情',
}// 页面类型字典
const form = ref({ // 表单
  equipmentNo: '', // 统一编号
  equipmentName: '', // 智能模型名称
  model: '', // 规格型号
  manufactureNo: '', // 出厂编号
  measureRange: '', // 测量范围
  uncertainty: '', // 不确定度或允许误差极限或准确度等级
  itemCategoryName: '', // 核查项分类名称
  itemCategoryId: '', // 核查项分类id
  remark: '', // 核查项备注
  belongStandardEquipment: '', // 检校标准库
  belongStandardEquipmentName: '', // 检校标准库名称
})
const pageType = ref('detail') // 页面类型: add, edit, detail
const infoId = ref('') // id
const $router = useRouter() // 路由实例
const loading = ref(false) // loading
const equipmentId = ref('') // 智能模型id
// -----------------------------------路由参数------------------------------------------------------
// 从路由中获取页面类型参数
const $route = useRoute()
if ($route.params && $route.params.type) {
  pageType.value = $route.params.type as string
  if ($route.params.id) {
    infoId.value = $route.params.id as string
  }
}
// -------------------------------------------核查项-----------------------------------------------
const listFrequency = ref<IList[]>([]) // 频率
const listAcVoltage = ref<IList[]>([]) // 交流电压
const listDcVoltage = ref<IList[]>([]) // 直流电压
const listRiseTime = ref<IList[]>([]) // 上升下降时间
const listFlatness = ref<IList[]>([]) // 平坦度
// const listDistortionHK = ref<IList[]>([]) // 失真(海口)
const listDistortionXC = ref<IList[]>([]) // 失真(西昌)

const form1 = ref({
  frequency: 1, // 频率
  acVoltage: 1, // 交流电压
  dcVoltage: 1, // 直流电压
  riseTime: 1, // 上升下降时间
  flatness: 1, // 平坦度
  // distortionHK: 1, // 失真(海口)
  distortionXC: 1, // 失真(西昌)
})
const listDict = ref<{ [key: string]: any }>()
watch(() => [listFrequency.value, listAcVoltage.value, listDcVoltage.value, listRiseTime.value, listFlatness.value, listDistortionXC.value], () => {
  listDict.value = {
    '1-频率': listFrequency.value,
    '2-交流电压': listAcVoltage.value,
    '3-直流电压': listDcVoltage.value,
    '4-上升下降时间': listRiseTime.value,
    '5-平坦度': listFlatness.value,
    // '6-失真(海口)': listDistortionHK.value,
    '6-失真': listDistortionXC.value,
  }
}, {
  deep: true,
  immediate: true,
})
// 表格对应的 选择状态
let chekedDict = {
  '1-频率': form1.value.frequency,
  '2-交流电压': form1.value.acVoltage,
  '3-直流电压': form1.value.dcVoltage,
  '4-上升下降时间': form1.value.riseTime,
  '5-平坦度': form1.value.flatness,
  // '6-失真(海口)': form1.value.distortionHK,
  '6-失真': form1.value.distortionXC,
} as { [key: string]: any }
watch(() => form1.value, () => {
  chekedDict = {
    '1-频率': form1.value.frequency,
    '2-交流电压': form1.value.acVoltage,
    '3-直流电压': form1.value.dcVoltage,
    '4-上升下降时间': form1.value.riseTime,
    '5-平坦度': form1.value.flatness,
    // '6-失真(海口)': form1.value.distortionHK,
    '6-失真': form1.value.distortionXC,
  }
}, {
  deep: true,
  // immediate: true,
})
const columns_frequency = ref<TableColumn[]>([ // 频率
  { text: '核查项目', value: 'paramsName', align: 'center', required: false, type: 'text' },
  { text: '标称值', value: 'nominalValue', align: 'center', required: true, type: 'number' },
  { text: '标称值单位', value: 'unit', 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: 'gateTime', align: 'center', required: true, type: 'number' },
  { text: '闸门时间单位', value: 'gateTimeUnit', align: 'center', required: true, type: 'select' },
  { text: '有效位数', value: 'validDigit', align: 'center', required: true, type: '' },
  { text: '循环次数', value: 'cycleNumber', align: 'center', required: true, type: 'number' },
  { text: '核查类型', value: 'checkType', align: 'center', required: false, type: 'select-multi' },
  { text: 'U(k=2)', value: 'urel', align: 'center', required: true, type: 'number' },
])

const columns_ac_voltage = ref<TableColumn[]>([ // 交流电压
  { text: '核查项目', value: 'paramsName', align: 'center', required: false, type: 'text' },
  { text: '标称值', value: 'nominalValue', align: 'center', required: true, type: 'number' },
  { 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: 'impedance', align: 'center', required: true, type: 'select' },
  { text: '循环次数', value: 'cycleNumber', align: 'center', required: true, type: 'number' },
  { text: '核查类型', value: 'checkType', align: 'center', required: false, type: 'select-multi' },
  { text: 'U(k=2)', value: 'urel', align: 'center', required: true, type: 'number' },
])

const columns_dc_voltage = ref<TableColumn[]>([ // 直流电压
  { text: '核查项目', value: 'paramsName', align: 'center', required: false, type: 'text' },
  { text: '标称值', value: 'nominalValue', align: 'center', required: true, type: 'number' },
  { text: '标称值单位', value: 'unit', align: 'center', required: true, type: 'select' },
  { text: '阻抗', value: 'impedance', align: 'center', required: true, type: 'select' },
  { text: '循环次数', value: 'cycleNumber', align: 'center', required: true, type: 'number' },
  { text: '核查类型', value: 'checkType', align: 'center', required: false, type: 'select-multi' },
  { text: 'U(k=2)', value: 'urel', align: 'center', required: true, type: 'number' },
])
const columns_rise_time = ref<TableColumn[]>([ // 上升下降时间
  { text: '核查项目', value: 'paramsName', align: 'center', required: false, type: 'text' },
  { 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: 'impedance', align: 'center', required: true, type: 'select' },
  { text: '循环次数', value: 'cycleNumber', align: 'center', required: true, type: 'number' },
  { text: '核查类型', value: 'checkType', align: 'center', required: false, type: 'select-multi' },
  { text: 'U(k=2)', value: 'urel', align: 'center', required: true, type: 'number' },
])
const columns_flatness = ref<TableColumn[]>([ // 平坦度
  { text: '核查项目', value: 'paramsName', align: 'center', required: false, type: 'text' },
  { text: '幅度', value: 'amplitude', align: 'center', required: true, type: 'number' },
  { text: '幅度单位', value: 'amplitudeUnit', 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: 'referencePoint', align: 'center', required: true, type: 'radio' },
  { text: '循环次数', value: 'cycleNumber', align: 'center', required: true, type: 'number' },
  { text: '核查类型', value: 'checkType', align: 'center', required: false, type: 'select-multi' },
  { text: 'U(k=2)', value: 'urel', align: 'center', required: true, type: 'number' },
])

const columns_distortion_HK = ref<TableColumn[]>([ // 失真(海口)
  { text: '核查项目', value: 'paramsName', align: 'center', required: false, type: 'text' },
  { text: '频率', value: 'frequency', align: 'center', required: true, type: 'number' },
  { text: '频率单位', value: 'frequencyUnit', align: 'center', required: true, type: 'select' },
  { text: '标称值%', value: 'nominalValue', align: 'center', required: true, type: 'number' },
  { text: '循环次数', value: 'cycleNumber', align: 'center', required: true, type: 'number' },
  { text: '核查类型', value: 'checkType', align: 'center', required: false, type: 'select-multi' },
  { text: 'U(k=2)', value: 'urel', align: 'center', required: true, type: 'number' },
])
const columns_distortion_XC = ref<TableColumn[]>([ // 失真(西昌)
  { text: '核查项目', value: 'paramsName', align: 'center', required: false, type: 'text' },
  { text: '频率', value: 'frequency', align: 'center', required: true, type: 'number' },
  { text: '频率单位', value: 'frequencyUnit', align: 'center', required: true, type: 'select' },
  { text: '电压', value: 'voltage', align: 'center', required: true, type: 'number' },
  { text: '电压单位', value: 'voltageUnit', align: 'center', required: true, type: 'select' },
  { text: '循环次数', value: 'cycleNumber', align: 'center', required: true, type: 'number' },
  { text: '核查类型', value: 'checkType', align: 'center', required: false, type: 'select-multi' },
  { text: 'U(k=2)', value: 'urel', align: 'center', required: true, type: 'number' },
])

// 表格对应 columns字典
const columnsDict = ref<{ [key: string]: any }>(
  {
    '1-频率': columns_frequency.value,
    '2-交流电压': columns_ac_voltage.value,
    '3-直流电压': columns_dc_voltage.value,
    '4-上升下降时间': columns_rise_time.value,
    '5-平坦度': columns_flatness.value,
    // '6-失真(海口)': columns_distortion_HK.value,
    '6-失真': columns_distortion_XC.value,
  },
)
/**
 * 增加行公共方法
 * @param list 要操作的数组
 * @param title 操作的表格
 */
const addRow = (list: IList[], title: string, index: string, item: any) => {
  if (checkList(list, columnsDict.value[`${index}-${title}`], `${title}表格`)) {
    const params = {
      urel: '',
      checkType: ['重复性', '稳定性'],
      cycleNumber: '10',
      amplitude: '', // 幅度
      amplitudeUnit: '', // 幅度单位
      gateTime: '', // 闸门时间
      gateTimeUnit: '', // 闸门时间单位
      nominalValue: '', // 标称值
      unit: '', // 单位
      validDigit: '', // 有效位数
      frequency: '', // 频率
      frequencyUnit: '', // 频率单位
      voltage: '', // 电压
      voltageUnit: '', // 电压单位
      impedance: '', // 阻抗
      referencePoint: '', // 是否为参考点
      id: `custom-${new Date().getTime()}`,
    }
    switch (title) {
      case '频率':
        if (item) {
          listFrequency.value.push({ ...JSON.parse(JSON.stringify({ ...item, id: `custom-${new Date().getTime()}` })), paramsName: '频率' })
        }
        else {
          listFrequency.value.length
            ? listFrequency.value.push({ ...JSON.parse(JSON.stringify({ ...listFrequency.value[listFrequency.value.length - 1], id: `custom-${new Date().getTime()}` })) })
            : listFrequency.value.push({
              paramsName: '频率',
              ...params,
              params: '频率',
              id: `custom-${new Date().getTime()}`,
            } as any)
        }
        break
      case '交流电压':
        if (item) {
          listAcVoltage.value.push({ ...JSON.parse(JSON.stringify({ ...item, id: `custom-${new Date().getTime()}` })), paramsName: '交流电压' })
        }
        else {
          listAcVoltage.value.length
            ? listAcVoltage.value.push({ ...JSON.parse(JSON.stringify({ ...listAcVoltage.value[listAcVoltage.value.length - 1], id: `custom-${new Date().getTime()}` })) })
            : listAcVoltage.value.push({
              paramsName: '交流电压',
              ...params,
              params: '交流电压',
              id: `custom-${new Date().getTime()}`,
            } as any)
        }
        break
      case '直流电压':
        if (item) {
          listDcVoltage.value.push({ ...JSON.parse(JSON.stringify({ ...item, id: `custom-${new Date().getTime()}` })), paramsName: '直流电压' })
        }
        else {
          listDcVoltage.value.length
            ? listDcVoltage.value.push({ ...JSON.parse(JSON.stringify({ ...listDcVoltage.value[listDcVoltage.value.length - 1], id: `custom-${new Date().getTime()}` })) })
            : listDcVoltage.value.push({
              paramsName: '直流电压',
              ...params,
              params: '直流电压',
              id: `custom-${new Date().getTime()}`,
            } as any)
        }
        break
      case '上升下降时间':
        if (item) {
          // listRiseTime.value.push({ ...JSON.parse(JSON.stringify(item)), paramsName: '上升下降时间' })
          listRiseTime.value.push({ ...JSON.parse(JSON.stringify({ ...item, id: `custom-${new Date().getTime()}` })), paramsName: listRiseTime.value.length ? '下降时间' : '上升时间' })
        }
        else {
          listRiseTime.value.length
            ? listRiseTime.value.push({ ...JSON.parse(JSON.stringify({ ...listRiseTime.value[listRiseTime.value.length - 1], id: `custom-${new Date().getTime()}` })), paramsName: '下降时间' })
            : listRiseTime.value.push({
              paramsName: '上升时间',
              ...params,
              params: '上升下降时间',
              id: `custom-${new Date().getTime()}`,
            } as any)
        }
        break
      case '平坦度':
        if (item) {
          listFlatness.value.push({ ...JSON.parse(JSON.stringify({ ...item, id: `custom-${new Date().getTime()}` })), paramsName: '平坦度' })
        }
        else {
          listFlatness.value.length
            ? listFlatness.value.push({ ...JSON.parse(JSON.stringify({ ...listFlatness.value[listFlatness.value.length - 1], id: `custom-${new Date().getTime()}` })), referencePoint: '0' })
            : listFlatness.value.push({
              paramsName: '平坦度',
              ...params,
              params: '平坦度',
              referencePoint: '1',
              id: `custom-${new Date().getTime()}`,
            } as any)
        }
        break
      // case '失真(海口)':
      //   if (item) {
      //     listDistortionHK.value.push({ ...JSON.parse(JSON.stringify(item)), paramsName: '失真(海口)' })
      //   }
      //   else {
      //     listDistortionHK.value.length
      //       ? listDistortionHK.value.push({ ...JSON.parse(JSON.stringify(listDistortionHK.value[listDistortionHK.value.length - 1])) })
      //       : listDistortionHK.value.push({
      //         paramsName: '失真(海口)',
      //         ...params,
      //         params: '6',
      //       } as any)
      //   }
      //   break
      case '失真':
        if (item) {
          listDistortionXC.value.push({ ...JSON.parse(JSON.stringify({ ...item, id: `custom-${new Date().getTime()}` })), paramsName: '失真' })
        }
        else {
          listDistortionXC.value.length
            ? listDistortionXC.value.push({ ...JSON.parse(JSON.stringify({ ...listDistortionXC.value[listDistortionXC.value.length - 1], id: `custom-${new Date().getTime()}` })) })
            : listDistortionXC.value.push({
              paramsName: '失真',
              ...params,
              params: '失真',
              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 '频率':
        listFrequency.value = data
        break
      case '交流电压':
        listAcVoltage.value = data
        break
      case '直流电压':
        listDcVoltage.value = data
        break
      case '上升下降时间':
        listRiseTime.value = data
        break
      case '平坦度':
        listFlatness.value = data
        break
      // case '失真(海口)':
      //   listDistortionHK.value = data
      //   break
      case '失真':
        listDistortionXC.value = data
        break
    }
  }
}
// ---------------------------------------------校验---------------------------------------------------
// 校验表格(点击保存的时候用、生成标准器示值)
function checkList(list: any[], columns: any[], title: string) {
  return useCheckList(list, columns, title)
}
// 校验所有表格
function checkAllList() {
  let result = true
  for (const i in columnsDict.value) {
    const requireLength = !!((chekedDict[i] === '1' || chekedDict[i] === 1))
    // console.log(i, listDict.value[i], columnsDict.value[i], i.substring(2), requireLength)
    if ((chekedDict[i] === '1' || chekedDict[i] === 1)) {
      if (!useCheckList(listDict.value[i], columnsDict.value[i], i.substring(2), '', '', '', requireLength)) {
        result = false
        break
      }
    }
  }
  return result
}

// -----------------------------------------------------------------------------------------------------
const clearAllList = () => {
  listFrequency.value = []
  listAcVoltage.value = []
  listDcVoltage.value = []
  listRiseTime.value = []
  listFlatness.value = []
  // listDistortionHK.value = []
  listDistortionXC.value = []
  // // list.value = []
  form.value.remark = '' // 核查项备注清空
  addRow([], '上升下降时间', '4', null)
  addRow([], '上升下降时间', '4', null)
  form1.value.frequency = 1
  form1.value.acVoltage = 1
  form1.value.dcVoltage = 1
  form1.value.riseTime = 1
  form1.value.flatness = 1
  // form1.value.distortionHK = 1
  form1.value.distortionXC = 1
}
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]
      result = [...result, ...data]
    }
  }
  return result
}
// ---------------------------------------按钮-----------------------------------------------------
// 点击关闭
const close = () => {
  $router.back()
}
// 清空配置
const clear = () => {
  ElMessageBox.confirm(
    '确认清空配置项吗?',
    '提示',
    {
      confirmButtonText: '确认',
      cancelButtonText: '取消',
      type: 'warning',
    },
  )
    .then(() => {
      clearAllList()
    })
}

// 点击保存
const save = () => {
  if (!getList().length) { ElMessage.warning('核查项不能为空'); return false }
  if (!checkAllList()) { return }
  // const dict = {
  //   频率: '1',
  //   交流电压: '2',
  //   直流电压: '3',
  //   上升下降时间: '4',
  //   平坦度: '5',
  //   失真: '6',
  // }
  const params = {
    itemCategoryId: form.value.itemCategoryId, // 核查项分类id
    checkItemDataLowFrequencySignalList: getList().map((item: any) => ({ ...item, equipmentId: equipmentId.value, id: '', remark: form.value.remark })),
    equipmentId: equipmentId.value,
    standardId: $route.query.standardId,
  }
  const loading = ElLoading.service({
    lock: true,
    text: '加载中',
    background: 'rgba(255, 255, 255, 0.6)',
  })
  config(params).then((res) => {
    ElMessage.success('已保存')
    pageType.value = 'detail'
    loading.close()
  }).catch(() => {
    loading.close()
  })
}

// 获取详情
const getInfo = () => {
  const loading = ElLoading.service({
    lock: true,
    text: '加载中',
    background: 'rgba(255, 255, 255, 0.6)',
  })
  const params = {
    equipmentId: equipmentId.value, // 智能模型id
    belongStandardEquipment: form.value.belongStandardEquipment, // 检校标准装置code
    itemCategoryId: form.value.itemCategoryId, // 核查项分类id
    itemCategoryName: form.value.itemCategoryName, // 核查项分类名称
  }
  getCheckItemDetail(params).then((res) => {
    const data = res.data?.checkItemDataLowFrequencySignalList || []
    const dict = {
      频率: '1',
      交流电压: '2',
      直流电压: '3',
      上升下降时间: '4',
      平坦度: '5',
      失真: '6',
    }
    data.forEach((item: any) => {
      addRow([], item.params, dict[item.params], { ...item, checkType: ['重复性', '稳定性'] })
      form.value.remark = item.remark
    })

    form1.value.frequency = !res.data ? 1 : listFrequency.value.length ? 1 : 0
    form1.value.acVoltage = !res.data ? 1 : listAcVoltage.value.length ? 1 : 0
    form1.value.dcVoltage = !res.data ? 1 : listDcVoltage.value.length ? 1 : 0
    form1.value.riseTime = !res.data ? 1 : listRiseTime.value.length ? 1 : 0
    form1.value.flatness = !res.data ? 1 : listFlatness.value.length ? 1 : 0
    // form1.value.distortionHK = !res.data ? 1 : listDistortionHK.value.length ? 1 : 0
    form1.value.distortionXC = !res.data ? 1 : listDistortionXC.value.length ? 1 : 0
    if (!data.some((item: { params: string }) => item.params === '上升下降时间')) {
      addRow([], '上升下降时间', '4', null)
      addRow([], '上升下降时间', '4', null)
    }
    loading.close()
  })
}

// ------------------------------------------钩子--------------------------------------------------

onMounted(() => {
  form.value.equipmentNo = $route.query.equipmentNo as string // 统一编号
  form.value.equipmentName = $route.query.equipmentName as string // 智能模型名称
  form.value.model = $route.query.model as string // 规格型号
  form.value.manufactureNo = $route.query.manufactureNo as string // 出厂编号
  form.value.measureRange = $route.query.measureRange as string // 测量范围
  form.value.uncertainty = $route.query.uncertainty as string // 不确定度或允许误差极限或准确度等级
  form.value.itemCategoryName = $route.query.itemCategoryName as string // 核查项分类名称
  form.value.itemCategoryId = $route.query.itemCategoryId as string // 核查项分类id
  form.value.belongStandardEquipment = $route.query.belongStandardEquipment as string // 核查项标准库id
  form.value.belongStandardEquipmentName = $route.query.belongStandardEquipmentName as string // 核查项标准库id
  // form.value.remark = $route.query.remark as string //
  equipmentId.value = $route.query.equipmentId as string // 智能模型id
  getInfo()
})

// 表格下拉框等内容是否禁用
const disabled = ({ scope, column }, fun: any) => {
  if (column.text === '核查类型' || column.text === '循环次数' || column.text === '是否为参考点') {
    fun(true)
    return
  }
  fun(pageType.value === 'detail')
}

// 每个table对应的下拉框内容 字典
const tableDict = ref<{ [key: string]: { value: string;name: string;id: string }[] }>({})
// 获取字典
const checkTypeList = ref<{ value: string;name: string;id: string }[]>([]) // 核查类型
const frequencyUnitList = ref<{ value: string;name: string;id: string }[]>([]) // 频率
const amplitudeUnitList = ref<{ value: string;name: string;id: string }[]>([]) // 幅度
const levelUnit = ref<{ value: string;name: string;id: string }[]>([]) // 电平单位
const secondUnit = ref<{ value: string;name: string;id: string }[]>([]) // 秒单位
const SixteennominalValueUnit = ref<{ value: string;name: string;id: string }[]>([])
const standardVoltage = ref<{ value: string;name: string;id: string }[]>([])
const impedanceValue = ref<{ value: string;name: string;id: string }[]>([]) // 阻抗
const fetchDict = async () => {
  // 核查类型
  const res1 = await getDictByCode('bizFirstStandardCheckType')
  checkTypeList.value = res1.data
  // 频率
  const res2 = await getDictByCode('standardFrequencyUnit')
  frequencyUnitList.value = res2.data
  // 幅度
  const res3 = await getDictByCode('standardAmplitudeUnit')
  amplitudeUnitList.value = res3.data

  const res4 = await getDictByCode('standardLevelUnit')
  levelUnit.value = res4.data

  const res5 = await getDictByCode('standardSecondUnit')
  secondUnit.value = res5.data

  const res6 = await getDictByCode('SixteennominalValueUnit')
  SixteennominalValueUnit.value = res6.data

  const res7 = await getDictByCode('standardVoltage')
  standardVoltage.value = res7.data

  const res8 = await getDictByCode('impedanceValue')
  impedanceValue.value = res8.data

  // table字典
  tableDict.value = {
    核查类型: checkTypeList.value,
    频率单位: frequencyUnitList.value,
    幅度单位: amplitudeUnitList.value,
    电平单位: levelUnit.value,
    标称值单位: frequencyUnitList.value,
    闸门时间单位: secondUnit.value,
    阻抗: impedanceValue.value,
    电压单位: SixteennominalValueUnit.value,
  }
}
fetchDict()

// 自定义下拉框内容
const customSelect = (data: any, fun: any) => {
  if ((data.title === '交流电压') && data.text === '标称值单位') {
    fun(SixteennominalValueUnit.value)
  }
  else if ((data.title === '直流电压') && data.text === '标称值单位') {
    fun(standardVoltage.value)
  }
  else if ((data.title === '平坦度') && data.text === '幅度单位') {
    fun(levelUnit.value)
  }
  else {
    fun(tableDict.value[data.text])
  }
}
</script>

<template>
  <app-container>
    <detail-page v-loading="loading" :title="`配置核查项(${textMap[pageType]})`">
      <template #btns>
        <el-button v-if="pageType === 'edit'" type="warning" @click="clear">
          清空配置
        </el-button>
        <el-button v-if="pageType === 'edit'" type="primary" @click="save">
          保存
        </el-button>
        <el-button type="info" @click="close">
          关闭
        </el-button>
      </template>
      <el-form
        ref="ruleFormRef"
        :model="form"
        :label-width="130"
        label-position="right"
      >
        <el-row :gutter="24" class="marg">
          <el-col :span="6">
            <el-form-item label="统一编号:" prop="equipmentNo">
              <el-input
                v-model="form.equipmentNo"
                disabled
                :placeholder="pageType === 'detail' ? '' : '统一编号'"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="智能模型名称:" prop="equipmentName">
              <el-input
                v-model="form.equipmentName"
                disabled
                :placeholder="pageType === 'detail' ? '' : '智能模型名称'"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="规格型号:" prop="model">
              <el-input
                v-model="form.model"
                disabled
                :placeholder="pageType === 'detail' ? '' : '规格型号'"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="出厂编号:" prop="manufactureNo">
              <el-input
                v-model="form.manufactureNo"
                disabled
                :placeholder="pageType === 'detail' ? '' : '出厂编号'"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="测量范围:" prop="measureRange">
              <el-input
                v-model="form.measureRange"
                disabled
                type="textarea"
                autosize
                :placeholder="pageType === 'detail' ? '' : '测量范围'"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label-width="260" label="不确定度或允许误差极限或准确度等级:" prop="uncertainty">
              <el-input
                v-model="form.uncertainty"
                type="textarea"
                autosize
                disabled
                :placeholder="pageType === 'detail' ? '' : '不确定度或允许误差极限或准确度等级'"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="核查项分类名称:" prop="itemCategoryName">
              <el-input
                v-model="form.itemCategoryName"
                disabled
                :placeholder="pageType === 'detail' ? '' : '核查项分类名称'"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </detail-page>

    <!-- 频率 -->
    <template-table1
      :show="Boolean(form1.frequency)"
      :data="listFrequency" :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="() => {}"
    >
      <template #custom-check>
        <el-checkbox v-model="form1.frequency" :checked="true" :true-label="1" :false-label="0" :disabled="pageType === 'detail'">
          频率
        </el-checkbox>
      </template>
      <!-- 有效位数 -->
      <template #next-content="{ scope, column }">
        <template v-if="column.text === '有效位数'">
          <el-input-number v-model="scope.validDigit" controls-position="right" placeholder="有效位数" :disabled="pageType === 'detail'" :precision="0" :min="0" />
        </template>
      </template>
    </template-table1>

    <!-- 交流电压 -->
    <template-table1
      :show="Boolean(form1.acVoltage)"
      :data="listAcVoltage" :columns="columns_ac_voltage" :page-type="pageType" title="交流电压" index="2" :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="() => {}"
    >
      <template #custom-check>
        <el-checkbox v-model="form1.acVoltage" :checked="true" :true-label="1" :false-label="0" :disabled="pageType === 'detail'">
          交流电压
        </el-checkbox>
      </template>
    </template-table1>

    <!-- 直流电压 -->
    <template-table1
      :show="Boolean(form1.dcVoltage)"
      :data="listDcVoltage" :columns="columns_dc_voltage" :page-type="pageType" title="直流电压" index="3" :show-btn="pageType !== 'detail'"
      :select-all-list="tableDict"
      :custom-select="true"
      @custom-select="customSelect"
      @disabled="disabled"
      @add-row="addRow"
      @del-row="delRow"
      @change-load-situationa="() => {}"
    >
      <template #custom-check>
        <el-checkbox v-model="form1.dcVoltage" :checked="true" :true-label="1" :false-label="0" :disabled="pageType === 'detail'">
          直流电压
        </el-checkbox>
      </template>
    </template-table1>

    <!-- 上升下降时间 -->
    <template-table1
      :show="Boolean(form1.riseTime)"
      :data="listRiseTime" :columns="columns_rise_time" :page-type="pageType" title="上升下降时间" index="4" :show-btn="false"
      :select-all-list="tableDict"
      :custom-select="true"
      @custom-select="customSelect"
      @disabled="disabled"
      @add-row="addRow"
      @del-row="delRow"
      @change-load-situationa="() => {}"
    >
      <template #custom-check>
        <el-checkbox v-model="form1.riseTime" :checked="true" :true-label="1" :false-label="0" :disabled="pageType === 'detail'">
          上升下降时间
        </el-checkbox>
      </template>
    </template-table1>

    <!-- 平坦度 -->
    <template-table1
      :show="Boolean(form1.flatness)"
      :data="listFlatness" :columns="columns_flatness" :page-type="pageType" title="平坦度" index="5" :show-btn="pageType !== 'detail'"
      :select-all-list="tableDict"
      :custom-select="true"
      @custom-select="customSelect"
      @disabled="disabled"
      @add-row="addRow"
      @del-row="delRow"
      @change-load-situationa="() => {}"
    >
      <template #custom-check>
        <el-checkbox v-model="form1.flatness" :checked="true" :true-label="1" :false-label="0" :disabled="pageType === 'detail'">
          平坦度
        </el-checkbox>
      </template>
    </template-table1>

    <!-- 失真(海口) -->
    <!-- <template-table1
      :data="listDistortionHK" :columns="columns_distortion_HK" :page-type="pageType" title="失真(海口)" index="6" :show-btn="pageType !== 'detail'"
      :select-all-list="tableDict"
      :custom-select="true"
      @custom-select="customSelect"
      @disabled="disabled"
      @add-row="addRow"
      @del-row="delRow"
      @change-load-situationa="() => {}"
    >
      <template #custom-check>
        <el-checkbox v-model="form1.distortionHK" :checked="true" :true-label="1" :false-label="0" :disabled="pageType === 'detail'">
          失真(海口)
        </el-checkbox>
      </template>
    </template-table1> -->

    <!-- 失真 -->
    <template-table1
      :show="Boolean(form1.distortionXC)"
      :data="listDistortionXC" :columns="columns_distortion_XC" :page-type="pageType" title="失真" index="6" :show-btn="pageType !== 'detail'"
      :select-all-list="tableDict"
      :custom-select="true"
      @custom-select="customSelect"
      @disabled="disabled"
      @add-row="addRow"
      @del-row="delRow"
      @change-load-situationa="() => {}"
    >
      <template #custom-check>
        <el-checkbox v-model="form1.distortionXC" :checked="true" :true-label="1" :false-label="0" :disabled="pageType === 'detail'">
          失真
        </el-checkbox>
      </template>
    </template-table1>

    <!-- 核查项备注 -->
    <el-form
      :model="form"
      label-width="120"
      label-position="right"
      style="margin-top: 20px;"
    >
      <el-row>
        <el-col :span="12">
          <el-form-item label="核查项备注:" prop="remark">
            <el-input
              v-model="form.remark"
              class="full-width-input"
              autosize
              type="textarea"
              :disabled="pageType === 'detail'"
              :placeholder="pageType === 'detail' ? ' ' : '请输入核查项备注'"
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </app-container>
</template>

./fourteen-interface