<!-- 标准装置台账信息详情 配置核查项 第10套:信号发生器 -->
<script name="StandardBookEquipmentConfig" lang="ts" setup>
import { ElLoading, ElMessage, ElMessageBox } from 'element-plus'
import type { IList } from './tenth-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 } from '@/utils/Array'
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
}
console.log('pageType.value', pageType.value)
}
// -------------------------------------------核查项-----------------------------------------------
const listFrequency = ref<IList[]>([]) // 频率
const listPowerLevel = ref<IList[]>([]) // 功率
const listRelativeLevel = ref<IList[]>([]) // 相对电平
const listAMDepth = ref<IList[]>([]) // 调幅度
const listFrequencyModulationDeviation = ref<IList[]>([]) // 调频频偏
const listPhase = ref<IList[]>([]) // 调相相偏
const listFrequencySpectrum = ref<IList[]>([]) // 谐波
const checkoutFrequencyList = ref<IList[]>([]) // 频率多选
const checkoutPowerLevelList = ref<IList[]>([]) // 功率多选
const checkoutRelativeLevelList = ref<IList[]>([]) // 相对电平多选
const checkoutAMDepthList = ref<IList[]>([]) // 调幅度多选
const checkoutfrequencyModulationDeviationList = ref<IList[]>([]) // 调频频偏多选
const checkoutPhaseList = ref<IList[]>([]) // 调相相偏多选
const checkoutFrequencySpectrumList = ref<IList[]>([]) // 谐波多选
const frequency = ref(true) // 频率
const powerLevel = ref(true) // 功率
const relativeLevel = ref(true) // 相对电平
const AMDepth = ref(true) // 调幅度
const frequencyModulationDeviation = ref(true) // 调频频偏
const phase = ref(true) // 调相相偏
const frequencySpectrum = ref(true) // 谐波
const columns_frequency = ref<TableColumn[]>([ // 频率
{ text: '核查项目', value: 'params', align: 'center', required: true },
{ text: '频率点', value: 'checkPoint', align: 'center', required: true, width: '180' },
{ text: '频率点单位', value: 'unit', align: 'center', required: true, width: '100' },
{ text: '幅度', value: 'amplitude', align: 'center', required: true, width: '180' },
{ text: '幅度单位', value: 'amplitudeUnit', align: 'center', required: true, width: '100' },
{ text: '循环次数', value: 'cycleNumber', align: 'center', required: true },
{ text: '核查类型', value: 'checkType', align: 'center', required: true },
{ text: 'U(k=2)', value: 'urel', align: 'center', required: true, width: '180' },
])
const columns_powerLevel = ref<TableColumn[]>([ // 功率
{ text: '核查项目', value: 'params', align: 'center', required: true },
{ text: '频率点', value: 'checkPoint', align: 'center', required: true, width: '180' },
{ text: '频率点单位', value: 'unit', align: 'center', required: true, width: '100' },
{ text: '功率', value: 'power', align: 'center', required: true, width: '180' },
{ text: '功率单位', value: 'powerUnit', align: 'center', required: true, width: '100' },
{ text: '循环次数', value: 'cycleNumber', align: 'center', required: true },
{ text: '核查类型', value: 'checkType', align: 'center', required: true },
{ text: 'U(k=2)', value: 'urel', align: 'center', required: true, width: '180' },
])
const columns_relativeLevel = ref<TableColumn[]>([ // 相对电平
{ text: '核查项目', value: 'params', align: 'center', required: true },
{ text: '频率点', value: 'checkPoint', align: 'center', required: true, width: '180' },
{ text: '频率点单位', value: 'unit', align: 'center', required: true, width: '100' },
{ text: '相对电平', value: 'relativeLevel', align: 'center', required: true, width: '180' },
{ text: '相对电平单位', value: 'relativeLevelUnit', align: 'center', required: true, width: '100' },
{ text: '循环次数', value: 'cycleNumber', align: 'center', required: true },
{ text: '核查类型', value: 'checkType', align: 'center', required: true },
{ text: 'U(k=2)', value: 'urel', align: 'center', required: true, width: '180' },
])
const columns_AMDepth = ref<TableColumn[]>([ // 调幅度
{ text: '核查项目', value: 'params', align: 'center', required: true },
{ text: '频率点', value: 'checkPoint', align: 'center', required: true, width: '180' },
{ text: '频率点单位', value: 'unit', align: 'center', required: true, width: '100' },
{ text: '调幅度', value: 'modulation', align: 'center', required: true, width: '180' },
{ text: '幅度', value: 'amplitude', align: 'center', required: true, width: '180' },
{ text: '幅度单位', value: 'amplitudeUnit', align: 'center', required: true, width: '100' },
{ text: '高通滤波', value: 'highPassFilter', align: 'center', required: true, width: '180' },
{ text: '高通滤波单位', value: 'highPassFilterUnit', align: 'center', required: true, width: '100' },
{ text: '低通滤波', value: 'lowerPassFilter', align: 'center', required: true, width: '180' },
{ text: '低通滤波单位', value: 'lowerPassFilterUnit', align: 'center', required: true, width: '100' },
{ text: '调制速率', value: 'modulationRate', align: 'center', required: true, width: '180' },
{ text: '调制速率单位', value: 'modulationRateUnit', align: 'center', required: true, width: '100' },
{ text: '循环次数', value: 'cycleNumber', align: 'center', required: true },
{ text: '核查类型', value: 'checkType', align: 'center', required: true },
{ text: 'U(k=2)/%', value: 'urel', align: 'center', required: true, width: '180' },
])
const columns_frequencyModulationDeviation = ref<TableColumn[]>([ // 调频频偏
{ text: '核查项目', value: 'params', align: 'center', required: true },
{ text: '频率点', value: 'checkPoint', align: 'center', required: true, width: '180' },
{ text: '频率点单位', value: 'unit', align: 'center', required: true, width: '100' },
{ text: '调频频偏', value: 'frequencyDeviation', align: 'center', required: true, width: '180' },
{ text: '调频频偏单位', value: 'frequencyDeviationUnit', align: 'center', required: true, width: '100' },
{ text: '幅度', value: 'amplitude', align: 'center', required: true, width: '180' },
{ text: '幅度单位', value: 'amplitudeUnit', align: 'center', required: true, width: '100' },
{ text: '高通滤波', value: 'highPassFilter', align: 'center', required: true, width: '180' },
{ text: '高通滤波单位', value: 'highPassFilterUnit', align: 'center', required: true, width: '100' },
{ text: '低通滤波', value: 'lowerPassFilter', align: 'center', required: true, width: '180' },
{ text: '低通滤波单位', value: 'lowerPassFilterUnit', align: 'center', required: true, width: '100' },
{ text: '调制速率', value: 'modulationRate', align: 'center', required: true, width: '180' },
{ text: '调制速率单位', value: 'modulationRateUnit', align: 'center', required: true, width: '100' },
{ text: '循环次数', value: 'cycleNumber', align: 'center', required: true },
{ text: '核查类型', value: 'checkType', align: 'center', required: true },
{ text: 'U(k=2)/%', value: 'urel', align: 'center', required: true, width: '180' },
])
const columns_phase = ref<TableColumn[]>([ // 调相相偏
{ text: '核查项目', value: 'params', align: 'center', required: true },
{ text: '频率点', value: 'checkPoint', align: 'center', required: true, width: '180' },
{ text: '频率点单位', value: 'unit', align: 'center', required: true, width: '100' },
{ text: '调相相偏', value: 'phaseDeviation', align: 'center', required: true, width: '180' },
{ text: '调相相偏单位', value: 'phaseDeviationUnit', align: 'center', required: true },
{ text: '幅度', value: 'amplitude', align: 'center', required: true, width: '180' },
{ text: '幅度单位', value: 'amplitudeUnit', align: 'center', required: true, width: '100' },
{ text: '高通滤波', value: 'highPassFilter', align: 'center', required: true, width: '180' },
{ text: '高通滤波单位', value: 'highPassFilterUnit', align: 'center', required: true, width: '100' },
{ text: '低通滤波', value: 'lowerPassFilter', align: 'center', required: true, width: '180' },
{ text: '低通滤波单位', value: 'lowerPassFilterUnit', align: 'center', required: true, width: '100' },
{ text: '调制速率', value: 'modulationRate', align: 'center', required: true, width: '180' },
{ text: '调制速率单位', value: 'modulationRateUnit', align: 'center', required: true, width: '100' },
{ text: '循环次数', value: 'cycleNumber', align: 'center', required: true },
{ text: '核查类型', value: 'checkType', align: 'center', required: true },
{ text: 'U(k=2)/%', value: 'urel', align: 'center', required: true, width: '180' },
])
const columns_frequencySpectrum = ref<TableColumn[]>([ // 谐波
{ text: '核查项目', value: 'params', align: 'center', required: true },
{ text: '频率点', value: 'checkPoint', align: 'center', required: true, width: '180' },
{ text: '频率点单位', value: 'unit', align: 'center', required: true, width: '100' },
{ text: '幅度', value: 'amplitude', align: 'center', required: true, width: '180' },
{ text: '幅度单位', value: 'amplitudeUnit', align: 'center', required: true, width: '100' },
{ text: 'RBW', value: 'rbwValue', align: 'center', required: true, width: '180' },
{ text: 'RBW单位', value: 'rbwValueUnit', align: 'center', required: true, width: '100' },
{ text: 'VBW', value: 'vbwValue', align: 'center', required: true, width: '180' },
{ text: 'VBW单位', value: 'vbwValueUnit', align: 'center', required: true, width: '100' },
{ text: '循环次数', value: 'cycleNumber', align: 'center', required: true },
{ text: '核查类型', value: 'checkType', align: 'center', required: true },
{ text: 'U(k=2)', value: 'urel', align: 'center', required: true, width: '180' },
])
// 多选
const handleSelectionChange = (e: any, type: string) => {
switch (type) {
case '频率':
checkoutFrequencyList.value = e
break
case '功率':
checkoutPowerLevelList.value = e
break
case '相对电平':
checkoutRelativeLevelList.value = e
break
case '调幅度':
checkoutAMDepthList.value = e
break
case '调频频偏':
checkoutfrequencyModulationDeviationList.value = e
break
case '调相相偏':
checkoutPhaseList.value = e
break
case '谐波':
checkoutFrequencySpectrumList.value = e
break
}
}
// 校验表格(点击保存的时候、增加行用)
const checkList = (list: any, getTitle: string) => {
let title = ''
if (getTitle.slice(getTitle.length - 2) === '表格') {
title = getTitle.slice(0, getTitle.length - 2)
}
else {
title = getTitle
}
let columns
switch (title) {
case '频率':
columns = columns_frequency.value
break
case '功率':
columns = columns_powerLevel.value
break
case '相对电平':
columns = columns_relativeLevel.value
break
case '调幅度':
columns = columns_AMDepth.value
break
case '调频频偏':
columns = columns_frequencyModulationDeviation.value
break
case '调相相偏':
columns = columns_phase.value
break
case '谐波':
columns = columns_frequencySpectrum.value
break
}
return useCheckList(list, columns, `${title}表格`)
}
/**
* 增加行公共方法
* @param list 要操作的数组
* @param title 操作的表格
*/
const addRow = (list: IList[], title: string) => {
if (checkList(list, `${title}表格`)) {
if (list.length) { // 增加行时默认上一行数据
list.push({ ...list[list.length - 1] })
}
else {
switch (title) {
case '频率':
list.push({
equipmentId: infoId.value, // 配套设备id
itemCategoryId: form.value.itemCategoryId, // 核查项分类id(能够确定是哪个标准装置)
id: '',
params: title, // 核查项目
checkPoint: '', // 频率点
unit: 'MHz', // 频率点单位
amplitude: '', // 幅度
amplitudeUnit: 'dBm', // 幅度单位
cycleNumber: 10, // 循环次数
checkType: '重复性, 稳定性', // 核查类型(直接存字典value,多个逗号分隔)
remark: '', // 核查项备注
urel: 0, // U(k=2)
})
break
case '功率':
list.push({
equipmentId: infoId.value, // 配套设备id
itemCategoryId: form.value.itemCategoryId, // 核查项分类id(能够确定是哪个标准装置)
id: '',
params: title, // 核查项目
checkPoint: '', // 频率点
unit: 'MHz', // 频率点单位
power: '', // 功率
powerUnit: 'dBm', // 功率单位
cycleNumber: 10, // 循环次数
checkType: '重复性, 稳定性', // 核查类型(直接存字典value,多个逗号分隔)
remark: '', // 核查项备注
urel: 0, // U(k=2)
})
break
case '相对电平':
list.push({
equipmentId: infoId.value, // 配套设备id
itemCategoryId: form.value.itemCategoryId, // 核查项分类id(能够确定是哪个标准装置)
id: '',
params: title, // 核查项目
checkPoint: '', // 频率点
unit: 'MHz', // 频率点单位
relativeLevel: '', // 相对电平
relativeLevelUnit: 'dBm', // 相对电平单位
cycleNumber: 10, // 循环次数
checkType: '重复性, 稳定性', // 核查类型(直接存字典value,多个逗号分隔)
remark: '', // 核查项备注
urel: 0, // U(k=2)
})
break
case '调幅度':
list.push({
equipmentId: infoId.value, // 配套设备id
itemCategoryId: form.value.itemCategoryId, // 核查项分类id(能够确定是哪个标准装置)
id: '',
params: title, // 核查项目
checkPoint: '', // 频率点
unit: 'MHz', // 频率点单位
modulation: '', // 调幅度
amplitude: '', // 幅度
amplitudeUnit: 'dBm', // 幅度单位
highPassFilter: '50', // 高通滤波
highPassFilterUnit: 'Hz', // 高通滤波单位
lowerPassFilter: '3', // 低通滤波
lowerPassFilterUnit: 'kHz', // 低通滤波单位
modulationRate: '', // 调制速率
modulationRateUnit: 'Hz', // 调制速率单位
cycleNumber: 10, // 循环次数
checkType: '重复性, 稳定性', // 核查类型(直接存字典value,多个逗号分隔)
remark: '', // 核查项备注
urel: 0, // U(k=2)
})
break
case '调频频偏':
list.push({
equipmentId: infoId.value, // 配套设备id
itemCategoryId: form.value.itemCategoryId, // 核查项分类id(能够确定是哪个标准装置)
id: '',
params: title, // 核查项目
checkPoint: '', // 频率点
unit: 'MHz', // 频率点单位
frequencyDeviation: '', // 调频频偏
frequencyDeviationUnit: 'MHz', // 调频频偏单位
amplitude: '', // 幅度
amplitudeUnit: 'dBm', // 幅度单位
highPassFilter: '50', // 高通滤波
highPassFilterUnit: 'Hz', // 高通滤波单位
lowerPassFilter: '3', // 低通滤波
lowerPassFilterUnit: 'kHz', // 低通滤波单位
modulationRate: '', // 调制速率
modulationRateUnit: 'Hz', // 调制速率单位
cycleNumber: 10, // 循环次数
checkType: '重复性, 稳定性', // 核查类型(直接存字典value,多个逗号分隔)
remark: '', // 核查项备注
urel: 0, // U(k=2)
})
break
case '调相相偏':
list.push({
equipmentId: infoId.value, // 配套设备id
itemCategoryId: form.value.itemCategoryId, // 核查项分类id(能够确定是哪个标准装置)
id: '',
params: title, // 核查项目
checkPoint: '', // 频率点
unit: 'MHz', // 频率点单位
phaseDeviation: '', // 调相相偏
phaseDeviationUnit: 'rad', // 调相相偏单位
amplitude: '', // 幅度
amplitudeUnit: 'dBm', // 幅度单位
highPassFilter: '50', // 高通滤波
highPassFilterUnit: 'Hz', // 高通滤波单位
lowerPassFilter: '3', // 低通滤波
lowerPassFilterUnit: 'kHz', // 低通滤波单位
modulationRate: '', // 调制速率
modulationRateUnit: 'Hz', // 调制速率单位
cycleNumber: 10, // 循环次数
checkType: '重复性, 稳定性', // 核查类型(直接存字典value,多个逗号分隔)
remark: '', // 核查项备注
urel: 0, // U(k=2)
})
break
case '谐波':
list.push({
equipmentId: infoId.value, // 配套设备id
itemCategoryId: form.value.itemCategoryId, // 核查项分类id(能够确定是哪个标准装置)
id: '',
params: title, // 核查项目
checkPoint: '', // 频率点
unit: 'MHz', // 频率点单位
amplitude: '', // 幅度
amplitudeUnit: 'dBm', // 幅度单位
rbwValue: '1', // RBW
rbwValueUnit: 'kHz', // RBW单位
vbwValue: '1', // VBW
vbwValueUnit: 'kHz', // VBW单位
cycleNumber: 10, // 循环次数
checkType: '重复性, 稳定性', // 核查类型(直接存字典value,多个逗号分隔)
remark: '', // 核查项备注
urel: 0, // U(k=2)
})
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 '功率':
listPowerLevel.value = data
break
case '相对电平':
listRelativeLevel.value = data
break
case '调幅度':
listAMDepth.value = data
break
case '调频频偏':
listFrequencyModulationDeviation.value = data
break
case '调相相偏':
listPhase.value = data
break
case '谐波':
listFrequencySpectrum.value = data
break
}
}
}
// ---------------------------------------按钮-----------------------------------------------------
// 点击关闭
const close = () => {
$router.back()
}
// 清空配置
const clear = () => {
ElMessageBox.confirm(
'确认清空配置项吗?',
'提示',
{
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
},
)
.then(() => {
listFrequency.value = [] // 频率
listPowerLevel.value = [] // 功率
listRelativeLevel.value = [] // 相对电平
listAMDepth.value = [] // 调幅度
listFrequencyModulationDeviation.value = [] // 调频频偏
listPhase.value = [] // 调相相偏
listFrequencySpectrum.value = [] // 谐波
form.value.remark = ''
})
}
// 保存之前校验
const checkListBeforeSave = () => {
console.log('保存之前校验')
// 验空
if (frequency.value && !listFrequency.value.length) { // 频率
ElMessage.warning('频率 不能为空')
return false
}
if (powerLevel.value && !listPowerLevel.value.length) { // 功率
ElMessage.warning('功率 不能为空')
return false
}
if (relativeLevel.value && !listRelativeLevel.value.length) { // 相对电平
ElMessage.warning('相对电平 不能为空')
return false
}
if (AMDepth.value && !listAMDepth.value.length) { // 调幅度
ElMessage.warning('调幅度 不能为空')
return false
}
if (frequencyModulationDeviation.value && !listFrequencyModulationDeviation.value.length) { // 调频频偏
ElMessage.warning('调频频偏 不能为空')
return false
}
if (phase.value && !listPhase.value.length) { // 调相相偏
ElMessage.warning('调相相偏 不能为空')
return false
}
if (frequencySpectrum.value && !listFrequencySpectrum.value.length) { // 谐波
ElMessage.warning('谐波 不能为空')
return false
}
let frequencyResult = true // 频率
let powerLevelResult = true // 功率
let relativeLevelResult = true // 相对电平
let AMDepthResult = true // 调幅度
let frequencyModulationDeviationResult = true // 调频频偏
let phaseResult = true // 调相相偏
let frequencySpectrumResult = true // 谐波
if (frequency.value) {
frequencyResult = checkList(listFrequency.value, '频率')
}
if (powerLevel.value) {
powerLevelResult = checkList(listPowerLevel.value, '功率')
}
if (relativeLevel.value) {
relativeLevelResult = checkList(listRelativeLevel.value, '相对电平')
}
if (AMDepth.value) {
AMDepthResult = checkList(listAMDepth.value, '调幅度')
}
if (frequencyModulationDeviation.value) {
frequencyModulationDeviationResult = checkList(listFrequencyModulationDeviation.value, '调频频偏')
}
if (phase.value) {
phaseResult = checkList(listPhase.value, '调相相偏')
}
if (frequencySpectrum.value) {
frequencySpectrumResult = checkList(listFrequencySpectrum.value, '谐波')
}
if (frequencyResult && powerLevelResult && relativeLevelResult && AMDepthResult && frequencyModulationDeviationResult && phaseResult && frequencySpectrumResult) {
// return true
console.log('checkList校验通过')
}
else {
console.log('checkList校验不通过')
return false
}
// 检查频率点和频率点单位不能同时完全一样
const listFrequencyResult = frequency.value ? checkArrayDataUnique(listFrequency.value, '频率') : true
const listPowerLevelResult = powerLevel.value ? checkArrayDataUnique(listPowerLevel.value, '功率') : true
const listRelativeLevelResult = relativeLevel.value ? checkArrayDataUnique(listRelativeLevel.value, '相对电平') : true
const listAMDepthResult = AMDepth.value ? checkArrayDataUnique(listAMDepth.value, '调幅度') : true
const listFrequencyModulationDeviationResult = frequencyModulationDeviation.value ? checkArrayDataUnique(listFrequencyModulationDeviation.value, '调频频偏') : true
const listPhaseResult = phase.value ? checkArrayDataUnique(listPhase.value, '调相相偏') : true
const listFrequencySpectrumResult = frequencySpectrum.value ? checkArrayDataUnique(listFrequencySpectrum.value, '谐波') : true
if (listFrequencyResult
&& listPowerLevelResult
&& listRelativeLevelResult
&& listAMDepthResult
&& listFrequencyModulationDeviationResult
&& listPhaseResult
&& listFrequencySpectrumResult
) {
return true
}
else {
return false
}
}
function checkArrayDataUnique(list: any, type: string) {
for (let i = 0; i < list.length; i++) {
for (let j = 0; j < list.length; j++) {
switch (type) {
case '功率':
if (i !== j && list[i].params === list[j].params && (list[i].checkPoint + list[i].unit) === (list[j].checkPoint + list[j].unit) && (list[i].power + list[i].powerUnit) === (list[j].power + list[j].powerUnit)) {
ElMessage.warning(`${list[i].params} 第${i + 1}行第${j + 1}行的 频率点、频率点单位,功率、功率单位 不能同时完全一样`)
return false
}
break
case '相对电平':
if (i !== j && list[i].params === list[j].params && (list[i].checkPoint + list[i].unit) === (list[j].checkPoint + list[j].unit) && (list[i].modulation) === (list[j].modulation)) {
ElMessage.warning(`${list[i].params} 第${i + 1}行第${j + 1}行的 频率点、频率点单位,相对电平、相对电平单位 不能同时完全一样`)
return false
}
break
case '调幅度':
if (i !== j && list[i].params === list[j].params && (list[i].checkPoint + list[i].unit) === (list[j].checkPoint + list[j].unit) && (list[i].relativeLevel + list[i].relativeLevelUnit) === (list[j].relativeLevel + list[j].relativeLevelUnit)) {
ElMessage.warning(`${list[i].params} 第${i + 1}行第${j + 1}行的 频率点、频率点单位,调幅度 不能同时完全一样`)
return false
}
break
case '调频频偏':
if (i !== j && list[i].params === list[j].params && (list[i].checkPoint + list[i].unit) === (list[j].checkPoint + list[j].unit) && (list[i].frequencyDeviation + list[i].frequencyDeviationUnit) === (list[j].frequencyDeviation + list[j].frequencyDeviationUnit)) {
ElMessage.warning(`${list[i].params} 第${i + 1}行第${j + 1}行的 频率点、频率点单位,调频频偏、调频频偏单位 不能同时完全一样`)
return false
}
break
case '调相相偏':
if (i !== j && list[i].params === list[j].params && (list[i].checkPoint + list[i].unit) === (list[j].checkPoint + list[j].unit) && (list[i].phaseDeviation + list[i].phaseDeviationUnit) === (list[j].phaseDeviation + list[j].phaseDeviationUnit)) {
ElMessage.warning(`${list[i].params} 第${i + 1}行第${j + 1}行的 频率点、频率点单位,调相相偏、调相相偏单位 不能同时完全一样`)
return false
}
break
default :
if (i !== j && list[i].params === list[j].params && (list[i].checkPoint + list[i].unit) === (list[j].checkPoint + list[j].unit)) {
ElMessage.warning(`${list[i].params} 第${i + 1}行第${j + 1}行的 频率点、频率点单位不能同时完全一样`)
return false
}
break
}
}
}
return true
}
// 保存之前处理数据
const solveDataBeforeSave = () => {
// 数据处理
let tempList = [] as any
if (frequency.value) { // 频率
tempList = tempList.concat(listFrequency.value)
}
if (powerLevel.value) { // 功率
tempList = tempList.concat(listPowerLevel.value)
}
if (relativeLevel.value) { // 相对电平
tempList = tempList.concat(listRelativeLevel.value)
}
if (AMDepth.value) { // 调幅度
tempList = tempList.concat(listAMDepth.value)
}
if (frequencyModulationDeviation.value) { // 调频频偏
tempList = tempList.concat(listFrequencyModulationDeviation.value)
}
if (phase.value) { // 调相相偏
tempList = tempList.concat(listPhase.value)
}
if (frequencySpectrum.value) { // 谐波
tempList = tempList.concat(listFrequencySpectrum.value)
}
tempList = tempList.map((item: { id: string }) => {
return {
...item,
id: '',
remark: form.value.remark,
}
})
return tempList
}
// 点击保存
const save = () => {
if (!checkListBeforeSave()) { return false }
const list = solveDataBeforeSave()
const params = {
itemCategoryId: form.value.itemCategoryId, // 核查项分类id
checkItemDataSignalGeneratorList: list,
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()
})
}
// 获取详情
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) => {
if (res.data && res.data.checkItemDataSignalGeneratorList && res.data.checkItemDataSignalGeneratorList.length) {
listFrequency.value = res.data.checkItemDataSignalGeneratorList.filter((item: { params: string }) => item.params === '频率')
listPowerLevel.value = res.data.checkItemDataSignalGeneratorList.filter((item: { params: string }) => item.params === '功率')
listRelativeLevel.value = res.data.checkItemDataSignalGeneratorList.filter((item: { params: string }) => item.params === '相对电平')
listAMDepth.value = res.data.checkItemDataSignalGeneratorList.filter((item: { params: string }) => item.params === '调幅度')
listFrequencyModulationDeviation.value = res.data.checkItemDataSignalGeneratorList.filter((item: { params: string }) => item.params === '调频频偏')
listPhase.value = res.data.checkItemDataSignalGeneratorList.filter((item: { params: string }) => item.params === '调相相偏')
listFrequencySpectrum.value = res.data.checkItemDataSignalGeneratorList.filter((item: { params: string }) => item.params === '谐波')
form.value.remark = res.data.checkItemDataSignalGeneratorList[0].remark
frequency.value = listFrequency.value.length > 0 // 是否显示频率
powerLevel.value = listPowerLevel.value.length > 0 // 功率
relativeLevel.value = listRelativeLevel.value.length > 0 // 相对电平
AMDepth.value = listAMDepth.value.length > 0 // 调幅度
frequencyModulationDeviation.value = listFrequencyModulationDeviation.value.length > 0 // 调频频偏
phase.value = listPhase.value.length > 0 // 调相相偏
frequencySpectrum.value = listFrequencySpectrum.value.length > 0 // 谐波
}
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
equipmentId.value = $route.query.equipmentId as string // 设备id
getInfo()
})
</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>
<!-- 频率 -->
<detail-block title="" style="padding-bottom: 20px;">
<div style="display: flex;justify-content: space-between;">
<el-checkbox v-model="frequency" :disabled="pageType === 'detail'">
频率
</el-checkbox>
<div v-if="frequency && pageType !== 'detail'" style="padding: 0 10px;padding-bottom: 10px;">
<el-button type="primary" @click="addRow(listFrequency, '频率')">
增加行
</el-button>
<el-button type="info" @click="delRow(checkoutFrequencyList, listFrequency, '频率')">
删除行
</el-button>
</div>
</div>
<template-table v-if="frequency" :data="listFrequency" :columns="columns_frequency" :page-type="pageType" @selection-change="(e: any) => handleSelectionChange(e, '频率')" />
</detail-block>
<!-- 功率 -->
<detail-block title="" style="padding-bottom: 20px;">
<div style="display: flex;justify-content: space-between;">
<el-checkbox v-model="powerLevel" :disabled="pageType === 'detail'">
功率
</el-checkbox>
<div v-if="powerLevel && pageType !== 'detail'" style="padding: 0 10px;padding-bottom: 10px;">
<el-button type="primary" @click="addRow(listPowerLevel, '功率')">
增加行
</el-button>
<el-button type="info" @click="delRow(checkoutPowerLevelList, listPowerLevel, '功率')">
删除行
</el-button>
</div>
</div>
<template-table v-if="powerLevel" :data="listPowerLevel" :columns="columns_powerLevel" :page-type="pageType" @selection-change="(e: any) => handleSelectionChange(e, '功率')" />
</detail-block>
<!-- 相对电平 -->
<detail-block title="" style="padding-bottom: 20px;">
<div style="display: flex;justify-content: space-between;">
<el-checkbox v-model="relativeLevel" :disabled="pageType === 'detail'">
相对电平
</el-checkbox>
<div v-if="relativeLevel && pageType !== 'detail'" style="padding: 0 10px;padding-bottom: 10px;">
<el-button type="primary" @click="addRow(listRelativeLevel, '相对电平')">
增加行
</el-button>
<el-button type="info" @click="delRow(checkoutRelativeLevelList, listRelativeLevel, '相对电平')">
删除行
</el-button>
</div>
</div>
<template-table v-if="relativeLevel" :data="listRelativeLevel" :columns="columns_relativeLevel" :page-type="pageType" @selection-change="(e: any) => handleSelectionChange(e, '相对电平')" />
</detail-block>
<!-- 调幅度 -->
<detail-block title="" style="padding-bottom: 20px;">
<div style="display: flex;justify-content: space-between;">
<el-checkbox v-model="AMDepth" :disabled="pageType === 'detail'">
调幅度
</el-checkbox>
<div v-if="AMDepth && pageType !== 'detail'" style="padding: 0 10px;padding-bottom: 10px;">
<el-button type="primary" @click="addRow(listAMDepth, '调幅度')">
增加行
</el-button>
<el-button type="info" @click="delRow(checkoutAMDepthList, listAMDepth, '调幅度')">
删除行
</el-button>
</div>
</div>
<template-table v-if="AMDepth" :data="listAMDepth" :columns="columns_AMDepth" :page-type="pageType" @selection-change="(e: any) => handleSelectionChange(e, '调幅度')" />
</detail-block>
<!-- 调频频偏 -->
<detail-block title="" style="padding-bottom: 20px;">
<div style="display: flex;justify-content: space-between;">
<el-checkbox v-model="frequencyModulationDeviation" :disabled="pageType === 'detail'">
调频频偏
</el-checkbox>
<div v-if="frequencyModulationDeviation && pageType !== 'detail'" style="padding: 0 10px;padding-bottom: 10px;">
<el-button type="primary" @click="addRow(listFrequencyModulationDeviation, '调频频偏')">
增加行
</el-button>
<el-button type="info" @click="delRow(checkoutfrequencyModulationDeviationList, listFrequencyModulationDeviation, '调频频偏')">
删除行
</el-button>
</div>
</div>
<template-table v-if="frequencyModulationDeviation" :data="listFrequencyModulationDeviation" :columns="columns_frequencyModulationDeviation" :page-type="pageType" @selection-change="(e: any) => handleSelectionChange(e, '调频频偏')" />
</detail-block>
<!-- 调相相偏 -->
<detail-block title="" style="padding-bottom: 20px;">
<div style="display: flex;justify-content: space-between;">
<el-checkbox v-model="phase" :disabled="pageType === 'detail'">
调相相偏
</el-checkbox>
<div v-if="phase && pageType !== 'detail'" style="padding: 0 10px;padding-bottom: 10px;">
<el-button type="primary" @click="addRow(listPhase, '调相相偏')">
增加行
</el-button>
<el-button type="info" @click="delRow(checkoutPhaseList, listPhase, '调相相偏')">
删除行
</el-button>
</div>
</div>
<template-table v-if="phase" :data="listPhase" :columns="columns_phase" :page-type="pageType" @selection-change="(e: any) => handleSelectionChange(e, '调相相偏')" />
</detail-block>
<!-- 谐波 -->
<detail-block title="" style="padding-bottom: 20px;">
<div style="display: flex;justify-content: space-between;">
<el-checkbox v-model="frequencySpectrum" :disabled="pageType === 'detail'">
谐波
</el-checkbox>
<div v-if="frequencySpectrum && pageType !== 'detail'" style="padding: 0 10px;padding-bottom: 10px;">
<el-button type="primary" @click="addRow(listFrequencySpectrum, '谐波')">
增加行
</el-button>
<el-button type="info" @click="delRow(checkoutFrequencySpectrumList, listFrequencySpectrum, '谐波')">
删除行
</el-button>
</div>
</div>
<template-table v-if="frequencySpectrum" :data="listFrequencySpectrum" :columns="columns_frequencySpectrum" :page-type="pageType" @selection-change="(e: any) => handleSelectionChange(e, '谐波')" />
</detail-block>
<!-- 核查项备注 -->
<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>