diff --git a/src/utils/String.ts b/src/utils/String.ts new file mode 100644 index 0000000..0f95434 --- /dev/null +++ b/src/utils/String.ts @@ -0,0 +1,10 @@ +// 字符串操作 + +// 1.去除字符串中的特殊符号 +export const clearSymbol = (str: string) => { + let string = '' + // 替换字符串中的所有特殊字符(包含空格) + const Exp = /[\-\_\,\!\|\~\`\(\)\#\$\%\^\&\*\{\}\:\;\"\L\<\>\±\<\≤\>\≥\<\>?]/g + string = str.replace(Exp, '') + return string +} diff --git a/src/utils/String.ts b/src/utils/String.ts new file mode 100644 index 0000000..0f95434 --- /dev/null +++ b/src/utils/String.ts @@ -0,0 +1,10 @@ +// 字符串操作 + +// 1.去除字符串中的特殊符号 +export const clearSymbol = (str: string) => { + let string = '' + // 替换字符串中的所有特殊字符(包含空格) + const Exp = /[\-\_\,\!\|\~\`\(\)\#\$\%\^\&\*\{\}\:\;\"\L\<\>\±\<\≤\>\≥\<\>?]/g + string = str.replace(Exp, '') + return string +} diff --git a/src/views/business/measure/item/components/ninth/templateDetail.vue b/src/views/business/measure/item/components/ninth/templateDetail.vue index c043141..6170a46 100644 --- a/src/views/business/measure/item/components/ninth/templateDetail.vue +++ b/src/views/business/measure/item/components/ninth/templateDetail.vue @@ -11,6 +11,7 @@ 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, @@ -57,7 +58,7 @@ valueFour: '', // 数值4 }) watch(() => props.form, (newVal) => { - form.value = newVal + form.value = JSON.parse(JSON.stringify(newVal)) }) const tableLoading = ref(false) const list = ref([]) // 全部数据 @@ -99,7 +100,7 @@ }) // 表格对应的 选择状态 let chekedDict = {} as { [key: string]: any } -watch(() => form.value, () => { +watch(() => [props.form, form.value], () => { chekedDict = { '1-频率显示': form.value.frequencyDisplay, '2-扫频宽度': form.value.sweepWidth, @@ -151,7 +152,7 @@ { 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: true, type: 'number', width: '400' }, + { text: '技术指标', value: 'valueOne', align: 'center', required: true, type: 'number', width: '400' }, ]) const columns_intermediate_frequency_bandwidth = ref([ // 中频带宽 @@ -162,7 +163,7 @@ { 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: 'technicalIndexRight', align: 'center', required: true, width: '400' }, + { text: '技术指标', value: 'valueTwo', align: 'center', required: true, width: '400' }, ]) const columns_transition_deviation = ref([ // 中频带宽转换偏差 @@ -344,6 +345,8 @@ amplitude: '', // 幅度 amplitudeUnit: '', // 幅度单位 technicalIndex: '', // 技术指标 + valueOne: '', // 技术指标数值 + technicalIndexSymbol: '±', // 技术指标符号 editable: true, } as any) break @@ -360,8 +363,9 @@ amplitude: '', // 幅度 amplitudeUnit: '', // 幅度单位 technicalIndex: '', // 技术指标 - technicalIndexLeft: '', // 技术指标 - technicalIndexRight: '', // 技术指标 + valueOne: '', // 技术指标 + valueTwo: '', // 技术指标 + technicalIndexSymbol: '±', // 技术指标符号 editable: true, } as any) break @@ -379,6 +383,7 @@ amplitudeUnit: '', // 幅度单位 technicalIndex: '', // 技术指标 technicalIndexUnit: 'dB', // 技术指标单位 + technicalIndexSymbol: '±', // 技术指标符号 referencePoint: '1', editable: true, } as any) @@ -398,6 +403,7 @@ technicalIndex: '', // 技术指标 technicalIndexUnit: 'dB', // 技术指标单位 referencePoint: '1', + technicalIndexSymbol: '±', // 技术指标符号 standardAttenuatorAttenuation: '', // 标准衰减器衰减量 standardAttenuatorAttenuationUnit: '', // 标准衰减器衰减量单位 editable: true, @@ -422,6 +428,7 @@ amplitudeUnit: '', // 幅度单位 technicalIndex: '', // 技术指标 technicalIndexUnit: 'dB', // 技术指标单位 + technicalIndexSymbol: '±', // 技术指标符号 editable: true, } as any) break @@ -437,6 +444,7 @@ amplitudeUnit: '', // 幅度单位 technicalIndex: '', // 技术指标 technicalIndexUnit: 'dB', // 技术指标单位 + technicalIndexSymbol: '±', // 技术指标符号 referencePoint: '1', editable: true, } as any) @@ -496,6 +504,7 @@ technicalIndex: '', // 技术指标 technicalIndexUnit: 'dB', // 技术指标单位 referencePoint: '1', + technicalIndexSymbol: '±', // 技术指标符号 editable: true, } as any) break @@ -515,7 +524,7 @@ amplitudeUnit: '', // 幅度单位 technicalIndex: '', // 技术指标 technicalIndexUnit: 'dB', // 技术指标单位 - + technicalIndexSymbol: '±', // 技术指标符号 editable: true, } as any) break @@ -527,6 +536,7 @@ params: '校准信号', technicalIndex: '', // 技术指标 technicalIndexUnit: '', // 技术指标单位 + technicalIndexSymbol: '±', // 技术指标符号 typeValue: '', // 类型 nominalValue: '', // 标称值 unit: '', // 标称值单位 @@ -598,7 +608,7 @@ function checkAllList() { let result = true for (const i in columnsDict.value) { - console.log(i, listDict.value[i], columnsDict.value[i]) + console.log(listDict.value[i]) const requireLength = !!((chekedDict[i] === '1' || chekedDict[i] === 1) && chekedDict[i]) if (!useCheckList(listDict.value[i], columnsDict.value[i], i.substring(2), '', '', '', requireLength)) { result = false @@ -644,27 +654,27 @@ break case '2': // 扫频宽度 - sweepWidthList.value.push({ ...item, params: '扫频宽度' }) + sweepWidthList.value.push({ ...item, params: '扫频宽度', technicalIndexSymbol: '±' }) break case '3': // 中频带宽 - intermediateFrequencyBandwidthList.value.push({ ...item, params: '中频带宽' }) + intermediateFrequencyBandwidthList.value.push({ ...item, params: '中频带宽', technicalIndexSymbol: '±' }) break case '4': // 中频带宽转换偏差 - transitionDeviationList.value.push({ ...item, params: '中频带宽转换偏差' }) + transitionDeviationList.value.push({ ...item, params: '中频带宽转换偏差', technicalIndexSymbol: '±', technicalIndex: Number(clearSymbol(item.technicalIndex)), referencePoint: String(item.referencePoint) }) break case '5': // 参考电平 - referenceElectricalLevelList.value.push({ ...item, params: '参考电平' }) + referenceElectricalLevelList.value.push({ ...item, params: '参考电平', technicalIndexSymbol: '±', technicalIndex: Number(clearSymbol(item.technicalIndex)), referencePoint: String(item.referencePoint) }) break case '6': // 垂直刻度 - verticalGraduatedList.value.push({ ...item, params: '垂直刻度' }) + verticalGraduatedList.value.push({ ...item, params: '垂直刻度', technicalIndexSymbol: '±', technicalIndex: Number(clearSymbol(item.technicalIndex)) }) break case '7': // 输入频响 - inputFrequencyResponseList.value.push({ ...item, params: '输入频响' }) + inputFrequencyResponseList.value.push({ ...item, params: '输入频响', technicalIndexSymbol: '±', technicalIndex: Number(clearSymbol(item.technicalIndex)), referencePoint: String(item.referencePoint) }) break case '8': // 平均噪声电平 @@ -676,22 +686,31 @@ break case '10': // 输入衰减 - inputAttenuatorList.value.push({ ...item, params: '输入衰减' }) + inputAttenuatorList.value.push({ ...item, params: '输入衰减', technicalIndexSymbol: '±', technicalIndex: Number(clearSymbol(item.technicalIndex)), referencePoint: String(item.referencePoint) }) break case '11': // 1dB增益压缩点 - gainCompressionPointList.value.push({ ...item, params: '1dB增益压缩点' }) + gainCompressionPointList.value.push({ ...item, params: '1dB增益压缩点', technicalIndexSymbol: item.technicalIndex.substring(0, 1), technicalIndex: Number(clearSymbol(item.technicalIndex)) }) break case '12': // 校准信号 - calibratingSignalList.value.push({ ...item, params: '校准信号' }) + calibratingSignalList.value.push({ ...item, params: '校准信号', technicalIndexSymbol: '±', technicalIndex: Number(clearSymbol(item.technicalIndex)) }) break } }) } }) - -defineExpose({ list, checkAllList, form }) +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) => ({ ...item, technicalIndex: item.technicalIndexSymbol ? `${item.technicalIndexSymbol}${item.technicalIndex}` : '' })) + result = [...result, ...data] + } + } + return result +} +defineExpose({ list, checkAllList, form, getList }) // 表格下拉框等内容是否禁用 const disabled = ({ scope, column }, fun) => { @@ -708,6 +727,13 @@ list[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') { @@ -742,6 +768,7 @@ 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 fetchDict = async () => { // 标称值单位 const res1 = await getDictByCode('bizFirstStandardFrequencyUnit') @@ -758,6 +785,9 @@ // 校准信号类型 const res5 = await getDictByCode('calibratingSignalType') typeValue.value = res5.data + // 技术指标符号 + const res6 = await getDictByCode('standardTechnicalIndexSymbol') + symbolList.value = res6.data tableDict.value = { 标称值单位: nominalValueUnit.value, @@ -784,7 +814,6 @@ // 自定义下拉框内容 const customSelect = (data: any, fun: any) => { - console.log(data, fun, 'data') if (data.title === '校准信号' && data.text === '标称值单位') { if (data.scope.row.typeValue === '频率') { fun(nominalValueUnit.value) @@ -807,7 +836,7 @@