diff --git a/src/commonMethods/useArrayDataUnique.ts b/src/commonMethods/useArrayDataUnique.ts index b8ff292..78f6980 100644 --- a/src/commonMethods/useArrayDataUnique.ts +++ b/src/commonMethods/useArrayDataUnique.ts @@ -1,41 +1,11 @@ -import { ElMessage } from 'element-plus' - /** - * 检查数组中不能存在属性数组中同时一样的两条数据 + * js检查数组中的属性值不能重复 * @param list 要检查的数组 - * @param property 属性数组 + * @param prop key */ -export function useArrayDataUnique(list: any, property: string[]) { - for (let i = 0; i < list.length - 1; i++) { - const j = i + 1 - for (let z = 0; z < property.length; z++) { - if (list[i].property[z] === list[j].property[z]) { - continue - } - else { - ElMessage.warning(`表格第${i}与第${j}行的两个属性不能完全一样`) - return false - } - } - } - return true +export function useArrayDataUnique(list: any, prop: string) { + return ( + new Set(list.map((item: { [key: string]: string | number }) => item[prop])) + .size === list.length + ) } - -// export function useArrayDataUnique(list: any, property: string[]) { -// const list1 = new list() -// const set = new Set() -// var arr = [] -// for (let i = 0; i < any.length; i++) { -// var obj = new Object() -// for (const j in property) { -// obj.j = any[i].j -// } -// list1.add(obj) -// set.add(obj) -// if (set.size != list1.size) { -// arr.add(i) -// arr.add(Array.from(mySet).indexOf(obj)) -// break -// } -// } -// } diff --git a/src/commonMethods/useArrayDataUnique.ts b/src/commonMethods/useArrayDataUnique.ts index b8ff292..78f6980 100644 --- a/src/commonMethods/useArrayDataUnique.ts +++ b/src/commonMethods/useArrayDataUnique.ts @@ -1,41 +1,11 @@ -import { ElMessage } from 'element-plus' - /** - * 检查数组中不能存在属性数组中同时一样的两条数据 + * js检查数组中的属性值不能重复 * @param list 要检查的数组 - * @param property 属性数组 + * @param prop key */ -export function useArrayDataUnique(list: any, property: string[]) { - for (let i = 0; i < list.length - 1; i++) { - const j = i + 1 - for (let z = 0; z < property.length; z++) { - if (list[i].property[z] === list[j].property[z]) { - continue - } - else { - ElMessage.warning(`表格第${i}与第${j}行的两个属性不能完全一样`) - return false - } - } - } - return true +export function useArrayDataUnique(list: any, prop: string) { + return ( + new Set(list.map((item: { [key: string]: string | number }) => item[prop])) + .size === list.length + ) } - -// export function useArrayDataUnique(list: any, property: string[]) { -// const list1 = new list() -// const set = new Set() -// var arr = [] -// for (let i = 0; i < any.length; i++) { -// var obj = new Object() -// for (const j in property) { -// obj.j = any[i].j -// } -// list1.add(obj) -// set.add(obj) -// if (set.size != list1.size) { -// arr.add(i) -// arr.add(Array.from(mySet).indexOf(obj)) -// break -// } -// } -// } diff --git a/src/views/equipement/standard/book/components/config/thirteenth/config.vue b/src/views/equipement/standard/book/components/config/thirteenth/config.vue index 7aa3ec1..e3adea6 100644 --- a/src/views/equipement/standard/book/components/config/thirteenth/config.vue +++ b/src/views/equipement/standard/book/components/config/thirteenth/config.vue @@ -179,12 +179,24 @@ const addRow = (list: IList[], title: string) => { if (checkList(list, `${title}表格`)) { if (list.length) { // 增加行时默认上一行数据 - list.push({ ...list[list.length - 1], referencePoint: 0 }) + if (title === '稳幅正弦信号电压平坦度') { // 处理参考点 + const tempList = listVoltageFlatness.value.filter(item => item.typeValue === list[list.length - 1].typeValue) + if (tempList.every(item => item.referencePoint === 0)) { + list.push({ ...list[list.length - 1], referencePoint: 1 }) + } + else { + list.push({ ...list[list.length - 1], referencePoint: 0 }) + } + } + else { + list.push({ ...list[list.length - 1] }) + } } else { switch (title) { case '时标': list.push({ + equipmentId: infoId.value, // 配套设备id id: '', params: title, // 核查项目 checkPoint: '', // 核查点 @@ -199,6 +211,7 @@ break case '方波电压(50Ω)': list.push({ + equipmentId: infoId.value, // 配套设备id id: '', params: title, // 核查项目 checkPoint: '', // 核查点 @@ -213,6 +226,7 @@ break case '方波电压(1MΩ)': list.push({ + equipmentId: infoId.value, // 配套设备id id: '', params: title, // 核查项目 checkPoint: '', // 核查点 @@ -227,6 +241,7 @@ break case '直流电压(50Ω)': list.push({ + equipmentId: infoId.value, // 配套设备id id: '', params: title, // 核查项目 checkPoint: '', // 核查点 @@ -241,6 +256,7 @@ break case '直流电压(1MΩ)': list.push({ + equipmentId: infoId.value, // 配套设备id id: '', params: title, // 核查项目 checkPoint: '', // 核查点 @@ -255,6 +271,7 @@ break case '输入阻抗': list.push({ + equipmentId: infoId.value, // 配套设备id id: '', params: title, // 核查项目 checkPoint: '', // 核查点 @@ -269,6 +286,7 @@ break case '稳幅正弦信号电压平坦度': list.push({ + equipmentId: infoId.value, // 配套设备id id: '', params: title, // 核查项目 typeValue: '5Vp-p', // 类型 @@ -285,6 +303,7 @@ break case '上升时间': list.push({ + equipmentId: infoId.value, // 配套设备id id: '', params: title, // 核查项目 checkPoint: '', // 快沿 @@ -348,20 +367,33 @@ // 上升时间选好设备 const confirmSelectedEquipment = (equipmentInfo: any, index: number) => { - listRisetime.value[index].equipmentId = equipmentInfo.equipmentId // 配套设备id listRisetime.value[index].equipmentName = equipmentInfo.equipmentName // 探头设备名称 listRisetime.value[index].manufactureNo = equipmentInfo.manufactureNo // 探头出厂编号 listRisetime.value[index].model = equipmentInfo.model // 探头规格型号 } // 参考点改变 -const selectReferencePoint = (val: number, row: any) => { - +const selectReferencePoint = (val: number, row: any, getIndex: number) => { + if (val === 1) { + listVoltageFlatness.value = listVoltageFlatness.value.map((item, index: number) => { + return { + ...item, + referencePoint: item.typeValue === row.typeValue ? 0 : item.referencePoint, + } + }) + listVoltageFlatness.value[getIndex].referencePoint = 1 + } } // 类型改变 -const changeSelectTypeValue = (val: number, row: any) => { - console.log(val, row) +const changeSelectTypeValue = (val: string, row: any) => { + const length = listVoltageFlatness.value.filter(item => item.typeValue === val).length + if (length === 1) { + row.referencePoint = 1 + } + else { + row.referencePoint = 0 + } } // ---------------------------------------按钮----------------------------------------------------- // 点击关闭 @@ -393,36 +425,37 @@ } // 保存之前校验 const checkListBeforeSave = () => { + console.log('保存之前校验') // 验空 if (timeMark.value && !listTimeMark.value.length) { // 时标 ElMessage.warning('时标 不能为空') return false } - else if (squareWaveVoltage50Ω.value && !listSquareWaveVoltage50Ω.value.length) { // 方波电压(50Ω) + if (squareWaveVoltage50Ω.value && !listSquareWaveVoltage50Ω.value.length) { // 方波电压(50Ω) ElMessage.warning('方波电压(50Ω) 不能为空') return false } - else if (squareWaveVoltage1MΩ.value && !listSquareWaveVoltage1MΩ.value.length) { // 方波电压(1MΩ) + if (squareWaveVoltage1MΩ.value && !listSquareWaveVoltage1MΩ.value.length) { // 方波电压(1MΩ) ElMessage.warning('方波电压(1MΩ) 不能为空') return false } - else if (directVoltage50Ω.value && !listDirectVoltage50Ω.value.length) { // 直流电压(50Ω) + if (directVoltage50Ω.value && !listDirectVoltage50Ω.value.length) { // 直流电压(50Ω) ElMessage.warning('直流电压(50Ω) 不能为空') return false } - else if (directVoltage1MΩ.value && !listDirectVoltage1MΩ.value.length) { // 直流电压(1MΩ) + if (directVoltage1MΩ.value && !listDirectVoltage1MΩ.value.length) { // 直流电压(1MΩ) ElMessage.warning('直流电压(1MΩ) 不能为空') return false } - else if (inputImpedance.value && !listInputImpedance.value.length) { // 输入阻抗 + if (inputImpedance.value && !listInputImpedance.value.length) { // 输入阻抗 ElMessage.warning('输入阻抗 不能为空') return false } - else if (voltageFlatness.value && !listVoltageFlatness.value.length) { // 稳幅正弦信号电压平坦度 + if (voltageFlatness.value && !listVoltageFlatness.value.length) { // 稳幅正弦信号电压平坦度 ElMessage.warning('稳幅正弦信号电压平坦度 不能为空') return false } - else if (risetime.value && !listRisetime.value.length) { // 上升时间 + if (risetime.value && !listRisetime.value.length) { // 上升时间 ElMessage.warning('上升时间 不能为空') return false } @@ -437,36 +470,91 @@ if (timeMark.value) { timeMarkResult = checkList(listTimeMark.value, '时标') } - else if (squareWaveVoltage50Ω.value) { - squareWaveVoltage50ΩResult = checkList(listSquareWaveVoltage50Ω.value, '方波电压(50Ω)') + if (squareWaveVoltage50Ω.value) { + squareWaveVoltage50ΩResult = checkList(listSquareWaveVoltage50Ω.value, '方波电压(50Ω)') } - else if (squareWaveVoltage1MΩ.value) { - squareWaveVoltage1MΩResult = checkList(listSquareWaveVoltage1MΩ.value, '方波电压(1MΩ)') + if (squareWaveVoltage1MΩ.value) { + squareWaveVoltage1MΩResult = checkList(listSquareWaveVoltage1MΩ.value, '方波电压(1MΩ)') } - else if (directVoltage50Ω.value) { - directVoltage50ΩResult = checkList(listDirectVoltage50Ω.value, '直流电压(50Ω)') + if (directVoltage50Ω.value) { + directVoltage50ΩResult = checkList(listDirectVoltage50Ω.value, '直流电压(50Ω)') } - else if (directVoltage1MΩ.value) { - directVoltage1MΩResult = checkList(listDirectVoltage1MΩ.value, '直流电压(1MΩ)') + if (directVoltage1MΩ.value) { + directVoltage1MΩResult = checkList(listDirectVoltage1MΩ.value, '直流电压(1MΩ)') } - else if (inputImpedance.value) { + if (inputImpedance.value) { inputImpedanceResult = checkList(listInputImpedance.value, '输入阻抗') } - else if (voltageFlatness.value) { + if (voltageFlatness.value) { voltageFlatnessResult = checkList(listVoltageFlatness.value, '稳幅正弦信号电压平坦度') } - else if (risetime.value) { + if (risetime.value) { risetimeResult = checkList(listRisetime.value, '上升时间') } if (timeMarkResult && squareWaveVoltage50ΩResult && squareWaveVoltage1MΩResult && directVoltage50ΩResult && directVoltage1MΩResult && inputImpedanceResult && voltageFlatnessResult && risetimeResult) { // return true - console.log('---') + console.log('checkList校验通过') + } + else { + console.log('checkList校验不通过') + return false + } + + // 检查核查点和核查点单位不能同时完全一样 + const listTimeMarkCheckPointResult = checkArrayDataUnique(listTimeMark.value) + const listSquareWaveVoltage50ΩCheckPointResult = checkArrayDataUnique(listSquareWaveVoltage50Ω.value) + const listSquareWaveVoltage1MΩCheckPointResult = checkArrayDataUnique(listSquareWaveVoltage1MΩ.value) + const listDirectVoltage50ΩCheckPointResult = checkArrayDataUnique(listDirectVoltage50Ω.value) + const listDirectVoltage1MΩCheckPointResult = checkArrayDataUnique(listDirectVoltage1MΩ.value) + const listInputImpedanceCheckPointResult = checkArrayDataUnique(listInputImpedance.value) + const listVoltageFlatnessCheckPointResult = checkArrayDataUnique(listVoltageFlatness.value) + const listRisetimeCheckPointResult = checkArrayDataUnique(listRisetime.value) + if (listTimeMarkCheckPointResult + && listSquareWaveVoltage50ΩCheckPointResult + && listSquareWaveVoltage1MΩCheckPointResult + && listDirectVoltage50ΩCheckPointResult + && listDirectVoltage1MΩCheckPointResult + && listInputImpedanceCheckPointResult + && listVoltageFlatnessCheckPointResult + && listRisetimeCheckPointResult + ) { + return true } else { return false } +} - // console.log(useArrayDataUnique(listTimeMark.value), ['checkPoint', 'unit']); +// 校验4个表格中不能同时出现核查项目和核查点、单位两个属性同时相同的两条数据 +function checkArrayDataUnique(list: any) { + for (let i = 0; i < list.length; i++) { + const j = i + 1 + for (let j = 0; j < list.length; j++) { + if (i !== j && list[i].params === list[j].params && (list[i].checkPoint + list[i].unit) === (list[j].checkPoint + list[j].unit)) { + if (list[i].params === '上升时间') { + ElMessage.warning(`${list[i].params} 第${i + 1}行第${j + 1}行的 快沿和单位不能同时完全一样`) + return false + } + else { + ElMessage.warning(`${list[i].params} 第${i + 1}行第${j + 1}行的 核查点和单位不能同时完全一样`) + return false + } + } + } + } + return true +} + +// 校验参考点 +const checkReferencePoint = () => { + for (let i = 0; i < listVoltageFlatness.value.length; i++) { + const tempList = listVoltageFlatness.value.filter(item => item.typeValue === listVoltageFlatness.value[i].typeValue) + if (tempList.length && tempList.every(item => item.referencePoint === 0)) { + ElMessage.warning(`稳幅正弦信号电压平坦度 ${tempList[0].typeValue}类型需至少一个参考点`) + return false + } + } + return true } // 保存之前处理数据 @@ -510,7 +598,8 @@ // 点击保存 const save = () => { - if (!checkListBeforeSave) { return false } + if (!checkReferencePoint()) { return false } + if (!checkListBeforeSave()) { return false } const list = solveDataBeforeSave() const params = { itemCategoryId: form.value.itemCategoryId, // 核查项分类id @@ -544,16 +633,15 @@ } getCheckItemDetail(params).then((res) => { if (res.data && res.data.checkItemDataOscilloscopeList && res.data.checkItemDataOscilloscopeList.length) { - console.log('0000') + listTimeMark.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '时标') + listSquareWaveVoltage50Ω.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '方波电压(50Ω)') + listSquareWaveVoltage1MΩ.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '方波电压(1MΩ)') + listDirectVoltage50Ω.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '直流电压(50Ω)') + listDirectVoltage1MΩ.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '直流电压(1MΩ)') + listInputImpedance.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '输入阻抗') + listVoltageFlatness.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '稳幅正弦信号电压平坦度') + listRisetime.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '上升时间') } - listTimeMark.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '时标') - listSquareWaveVoltage50Ω.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '方波电压(50Ω)') - listSquareWaveVoltage1MΩ.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '方波电压(1MΩ)') - listDirectVoltage50Ω.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '直流电压(50Ω)') - listDirectVoltage1MΩ.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '直流电压(1MΩ)') - listInputImpedance.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '输入阻抗') - listVoltageFlatness.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '稳幅正弦信号电压平坦度') - listRisetime.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '上升时间') loading.close() }) } diff --git a/src/commonMethods/useArrayDataUnique.ts b/src/commonMethods/useArrayDataUnique.ts index b8ff292..78f6980 100644 --- a/src/commonMethods/useArrayDataUnique.ts +++ b/src/commonMethods/useArrayDataUnique.ts @@ -1,41 +1,11 @@ -import { ElMessage } from 'element-plus' - /** - * 检查数组中不能存在属性数组中同时一样的两条数据 + * js检查数组中的属性值不能重复 * @param list 要检查的数组 - * @param property 属性数组 + * @param prop key */ -export function useArrayDataUnique(list: any, property: string[]) { - for (let i = 0; i < list.length - 1; i++) { - const j = i + 1 - for (let z = 0; z < property.length; z++) { - if (list[i].property[z] === list[j].property[z]) { - continue - } - else { - ElMessage.warning(`表格第${i}与第${j}行的两个属性不能完全一样`) - return false - } - } - } - return true +export function useArrayDataUnique(list: any, prop: string) { + return ( + new Set(list.map((item: { [key: string]: string | number }) => item[prop])) + .size === list.length + ) } - -// export function useArrayDataUnique(list: any, property: string[]) { -// const list1 = new list() -// const set = new Set() -// var arr = [] -// for (let i = 0; i < any.length; i++) { -// var obj = new Object() -// for (const j in property) { -// obj.j = any[i].j -// } -// list1.add(obj) -// set.add(obj) -// if (set.size != list1.size) { -// arr.add(i) -// arr.add(Array.from(mySet).indexOf(obj)) -// break -// } -// } -// } diff --git a/src/views/equipement/standard/book/components/config/thirteenth/config.vue b/src/views/equipement/standard/book/components/config/thirteenth/config.vue index 7aa3ec1..e3adea6 100644 --- a/src/views/equipement/standard/book/components/config/thirteenth/config.vue +++ b/src/views/equipement/standard/book/components/config/thirteenth/config.vue @@ -179,12 +179,24 @@ const addRow = (list: IList[], title: string) => { if (checkList(list, `${title}表格`)) { if (list.length) { // 增加行时默认上一行数据 - list.push({ ...list[list.length - 1], referencePoint: 0 }) + if (title === '稳幅正弦信号电压平坦度') { // 处理参考点 + const tempList = listVoltageFlatness.value.filter(item => item.typeValue === list[list.length - 1].typeValue) + if (tempList.every(item => item.referencePoint === 0)) { + list.push({ ...list[list.length - 1], referencePoint: 1 }) + } + else { + list.push({ ...list[list.length - 1], referencePoint: 0 }) + } + } + else { + list.push({ ...list[list.length - 1] }) + } } else { switch (title) { case '时标': list.push({ + equipmentId: infoId.value, // 配套设备id id: '', params: title, // 核查项目 checkPoint: '', // 核查点 @@ -199,6 +211,7 @@ break case '方波电压(50Ω)': list.push({ + equipmentId: infoId.value, // 配套设备id id: '', params: title, // 核查项目 checkPoint: '', // 核查点 @@ -213,6 +226,7 @@ break case '方波电压(1MΩ)': list.push({ + equipmentId: infoId.value, // 配套设备id id: '', params: title, // 核查项目 checkPoint: '', // 核查点 @@ -227,6 +241,7 @@ break case '直流电压(50Ω)': list.push({ + equipmentId: infoId.value, // 配套设备id id: '', params: title, // 核查项目 checkPoint: '', // 核查点 @@ -241,6 +256,7 @@ break case '直流电压(1MΩ)': list.push({ + equipmentId: infoId.value, // 配套设备id id: '', params: title, // 核查项目 checkPoint: '', // 核查点 @@ -255,6 +271,7 @@ break case '输入阻抗': list.push({ + equipmentId: infoId.value, // 配套设备id id: '', params: title, // 核查项目 checkPoint: '', // 核查点 @@ -269,6 +286,7 @@ break case '稳幅正弦信号电压平坦度': list.push({ + equipmentId: infoId.value, // 配套设备id id: '', params: title, // 核查项目 typeValue: '5Vp-p', // 类型 @@ -285,6 +303,7 @@ break case '上升时间': list.push({ + equipmentId: infoId.value, // 配套设备id id: '', params: title, // 核查项目 checkPoint: '', // 快沿 @@ -348,20 +367,33 @@ // 上升时间选好设备 const confirmSelectedEquipment = (equipmentInfo: any, index: number) => { - listRisetime.value[index].equipmentId = equipmentInfo.equipmentId // 配套设备id listRisetime.value[index].equipmentName = equipmentInfo.equipmentName // 探头设备名称 listRisetime.value[index].manufactureNo = equipmentInfo.manufactureNo // 探头出厂编号 listRisetime.value[index].model = equipmentInfo.model // 探头规格型号 } // 参考点改变 -const selectReferencePoint = (val: number, row: any) => { - +const selectReferencePoint = (val: number, row: any, getIndex: number) => { + if (val === 1) { + listVoltageFlatness.value = listVoltageFlatness.value.map((item, index: number) => { + return { + ...item, + referencePoint: item.typeValue === row.typeValue ? 0 : item.referencePoint, + } + }) + listVoltageFlatness.value[getIndex].referencePoint = 1 + } } // 类型改变 -const changeSelectTypeValue = (val: number, row: any) => { - console.log(val, row) +const changeSelectTypeValue = (val: string, row: any) => { + const length = listVoltageFlatness.value.filter(item => item.typeValue === val).length + if (length === 1) { + row.referencePoint = 1 + } + else { + row.referencePoint = 0 + } } // ---------------------------------------按钮----------------------------------------------------- // 点击关闭 @@ -393,36 +425,37 @@ } // 保存之前校验 const checkListBeforeSave = () => { + console.log('保存之前校验') // 验空 if (timeMark.value && !listTimeMark.value.length) { // 时标 ElMessage.warning('时标 不能为空') return false } - else if (squareWaveVoltage50Ω.value && !listSquareWaveVoltage50Ω.value.length) { // 方波电压(50Ω) + if (squareWaveVoltage50Ω.value && !listSquareWaveVoltage50Ω.value.length) { // 方波电压(50Ω) ElMessage.warning('方波电压(50Ω) 不能为空') return false } - else if (squareWaveVoltage1MΩ.value && !listSquareWaveVoltage1MΩ.value.length) { // 方波电压(1MΩ) + if (squareWaveVoltage1MΩ.value && !listSquareWaveVoltage1MΩ.value.length) { // 方波电压(1MΩ) ElMessage.warning('方波电压(1MΩ) 不能为空') return false } - else if (directVoltage50Ω.value && !listDirectVoltage50Ω.value.length) { // 直流电压(50Ω) + if (directVoltage50Ω.value && !listDirectVoltage50Ω.value.length) { // 直流电压(50Ω) ElMessage.warning('直流电压(50Ω) 不能为空') return false } - else if (directVoltage1MΩ.value && !listDirectVoltage1MΩ.value.length) { // 直流电压(1MΩ) + if (directVoltage1MΩ.value && !listDirectVoltage1MΩ.value.length) { // 直流电压(1MΩ) ElMessage.warning('直流电压(1MΩ) 不能为空') return false } - else if (inputImpedance.value && !listInputImpedance.value.length) { // 输入阻抗 + if (inputImpedance.value && !listInputImpedance.value.length) { // 输入阻抗 ElMessage.warning('输入阻抗 不能为空') return false } - else if (voltageFlatness.value && !listVoltageFlatness.value.length) { // 稳幅正弦信号电压平坦度 + if (voltageFlatness.value && !listVoltageFlatness.value.length) { // 稳幅正弦信号电压平坦度 ElMessage.warning('稳幅正弦信号电压平坦度 不能为空') return false } - else if (risetime.value && !listRisetime.value.length) { // 上升时间 + if (risetime.value && !listRisetime.value.length) { // 上升时间 ElMessage.warning('上升时间 不能为空') return false } @@ -437,36 +470,91 @@ if (timeMark.value) { timeMarkResult = checkList(listTimeMark.value, '时标') } - else if (squareWaveVoltage50Ω.value) { - squareWaveVoltage50ΩResult = checkList(listSquareWaveVoltage50Ω.value, '方波电压(50Ω)') + if (squareWaveVoltage50Ω.value) { + squareWaveVoltage50ΩResult = checkList(listSquareWaveVoltage50Ω.value, '方波电压(50Ω)') } - else if (squareWaveVoltage1MΩ.value) { - squareWaveVoltage1MΩResult = checkList(listSquareWaveVoltage1MΩ.value, '方波电压(1MΩ)') + if (squareWaveVoltage1MΩ.value) { + squareWaveVoltage1MΩResult = checkList(listSquareWaveVoltage1MΩ.value, '方波电压(1MΩ)') } - else if (directVoltage50Ω.value) { - directVoltage50ΩResult = checkList(listDirectVoltage50Ω.value, '直流电压(50Ω)') + if (directVoltage50Ω.value) { + directVoltage50ΩResult = checkList(listDirectVoltage50Ω.value, '直流电压(50Ω)') } - else if (directVoltage1MΩ.value) { - directVoltage1MΩResult = checkList(listDirectVoltage1MΩ.value, '直流电压(1MΩ)') + if (directVoltage1MΩ.value) { + directVoltage1MΩResult = checkList(listDirectVoltage1MΩ.value, '直流电压(1MΩ)') } - else if (inputImpedance.value) { + if (inputImpedance.value) { inputImpedanceResult = checkList(listInputImpedance.value, '输入阻抗') } - else if (voltageFlatness.value) { + if (voltageFlatness.value) { voltageFlatnessResult = checkList(listVoltageFlatness.value, '稳幅正弦信号电压平坦度') } - else if (risetime.value) { + if (risetime.value) { risetimeResult = checkList(listRisetime.value, '上升时间') } if (timeMarkResult && squareWaveVoltage50ΩResult && squareWaveVoltage1MΩResult && directVoltage50ΩResult && directVoltage1MΩResult && inputImpedanceResult && voltageFlatnessResult && risetimeResult) { // return true - console.log('---') + console.log('checkList校验通过') + } + else { + console.log('checkList校验不通过') + return false + } + + // 检查核查点和核查点单位不能同时完全一样 + const listTimeMarkCheckPointResult = checkArrayDataUnique(listTimeMark.value) + const listSquareWaveVoltage50ΩCheckPointResult = checkArrayDataUnique(listSquareWaveVoltage50Ω.value) + const listSquareWaveVoltage1MΩCheckPointResult = checkArrayDataUnique(listSquareWaveVoltage1MΩ.value) + const listDirectVoltage50ΩCheckPointResult = checkArrayDataUnique(listDirectVoltage50Ω.value) + const listDirectVoltage1MΩCheckPointResult = checkArrayDataUnique(listDirectVoltage1MΩ.value) + const listInputImpedanceCheckPointResult = checkArrayDataUnique(listInputImpedance.value) + const listVoltageFlatnessCheckPointResult = checkArrayDataUnique(listVoltageFlatness.value) + const listRisetimeCheckPointResult = checkArrayDataUnique(listRisetime.value) + if (listTimeMarkCheckPointResult + && listSquareWaveVoltage50ΩCheckPointResult + && listSquareWaveVoltage1MΩCheckPointResult + && listDirectVoltage50ΩCheckPointResult + && listDirectVoltage1MΩCheckPointResult + && listInputImpedanceCheckPointResult + && listVoltageFlatnessCheckPointResult + && listRisetimeCheckPointResult + ) { + return true } else { return false } +} - // console.log(useArrayDataUnique(listTimeMark.value), ['checkPoint', 'unit']); +// 校验4个表格中不能同时出现核查项目和核查点、单位两个属性同时相同的两条数据 +function checkArrayDataUnique(list: any) { + for (let i = 0; i < list.length; i++) { + const j = i + 1 + for (let j = 0; j < list.length; j++) { + if (i !== j && list[i].params === list[j].params && (list[i].checkPoint + list[i].unit) === (list[j].checkPoint + list[j].unit)) { + if (list[i].params === '上升时间') { + ElMessage.warning(`${list[i].params} 第${i + 1}行第${j + 1}行的 快沿和单位不能同时完全一样`) + return false + } + else { + ElMessage.warning(`${list[i].params} 第${i + 1}行第${j + 1}行的 核查点和单位不能同时完全一样`) + return false + } + } + } + } + return true +} + +// 校验参考点 +const checkReferencePoint = () => { + for (let i = 0; i < listVoltageFlatness.value.length; i++) { + const tempList = listVoltageFlatness.value.filter(item => item.typeValue === listVoltageFlatness.value[i].typeValue) + if (tempList.length && tempList.every(item => item.referencePoint === 0)) { + ElMessage.warning(`稳幅正弦信号电压平坦度 ${tempList[0].typeValue}类型需至少一个参考点`) + return false + } + } + return true } // 保存之前处理数据 @@ -510,7 +598,8 @@ // 点击保存 const save = () => { - if (!checkListBeforeSave) { return false } + if (!checkReferencePoint()) { return false } + if (!checkListBeforeSave()) { return false } const list = solveDataBeforeSave() const params = { itemCategoryId: form.value.itemCategoryId, // 核查项分类id @@ -544,16 +633,15 @@ } getCheckItemDetail(params).then((res) => { if (res.data && res.data.checkItemDataOscilloscopeList && res.data.checkItemDataOscilloscopeList.length) { - console.log('0000') + listTimeMark.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '时标') + listSquareWaveVoltage50Ω.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '方波电压(50Ω)') + listSquareWaveVoltage1MΩ.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '方波电压(1MΩ)') + listDirectVoltage50Ω.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '直流电压(50Ω)') + listDirectVoltage1MΩ.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '直流电压(1MΩ)') + listInputImpedance.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '输入阻抗') + listVoltageFlatness.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '稳幅正弦信号电压平坦度') + listRisetime.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '上升时间') } - listTimeMark.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '时标') - listSquareWaveVoltage50Ω.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '方波电压(50Ω)') - listSquareWaveVoltage1MΩ.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '方波电压(1MΩ)') - listDirectVoltage50Ω.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '直流电压(50Ω)') - listDirectVoltage1MΩ.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '直流电压(1MΩ)') - listInputImpedance.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '输入阻抗') - listVoltageFlatness.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '稳幅正弦信号电压平坦度') - listRisetime.value = res.data.checkItemDataOscilloscopeList.filter((item: { params: string }) => item.params === '上升时间') loading.close() }) } diff --git a/src/views/equipement/standard/book/components/config/thirteenth/templateTable.vue b/src/views/equipement/standard/book/components/config/thirteenth/templateTable.vue index fd6e12c..fca5b5f 100644 --- a/src/views/equipement/standard/book/components/config/thirteenth/templateTable.vue +++ b/src/views/equipement/standard/book/components/config/thirteenth/templateTable.vue @@ -165,11 +165,11 @@ } // -------------------------------------参考点相关-------------------------------------------- -const selectReferencePoint = (val: number, row: any) => { - emit('selectReferencePoint', val, row) +const selectReferencePoint = (val: number, row: any, index: number) => { + emit('selectReferencePoint', val, row, index) } -const changeSelectTypeValue = (val: string, row: any) => { - emit('changeSelectTypeValue', val, row) +const changeSelectTypeValue = (val: string, row: any, index: number) => { + emit('changeSelectTypeValue', val, row, index) } // -------------------------------------------------------------------------------------- defineExpose({ @@ -229,7 +229,7 @@ /> --> -