diff --git a/src/commonMethods/useArrayDataUnique.ts b/src/commonMethods/useArrayDataUnique.ts index 41b3ccc..f6ae9d6 100644 --- a/src/commonMethods/useArrayDataUnique.ts +++ b/src/commonMethods/useArrayDataUnique.ts @@ -1,4 +1,4 @@ -// import { ElMessage } from 'element-plus' +import { ElMessage } from 'element-plus' /** * 检查数组中不能存在属性数组中同时一样的两条数据 @@ -6,5 +6,34 @@ * @param property 属性数组 */ export function useArrayDataUnique(list: any, property: string[]) { - console.log('--', list, property) + 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}行的两个属性不能完全一样`) + } + } + } } + +// 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 41b3ccc..f6ae9d6 100644 --- a/src/commonMethods/useArrayDataUnique.ts +++ b/src/commonMethods/useArrayDataUnique.ts @@ -1,4 +1,4 @@ -// import { ElMessage } from 'element-plus' +import { ElMessage } from 'element-plus' /** * 检查数组中不能存在属性数组中同时一样的两条数据 @@ -6,5 +6,34 @@ * @param property 属性数组 */ export function useArrayDataUnique(list: any, property: string[]) { - console.log('--', list, property) + 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}行的两个属性不能完全一样`) + } + } + } } + +// 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/first/config.vue b/src/views/equipement/standard/book/components/config/first/config.vue index b37d416..00cc993 100644 --- a/src/views/equipement/standard/book/components/config/first/config.vue +++ b/src/views/equipement/standard/book/components/config/first/config.vue @@ -60,7 +60,9 @@ ]) // 校验表格(点击保存的时候、增加行用) const checkList = (list: any, title: string) => { - return useCheckList(list, columns.value, title) + if (!checkArrayDataUnique()) { return false } + if (!useCheckList(list, columns.value, title)) { return false } + return true } // 频率有数据的时候校验频率单位字段 const checkFrequencyUnit = (list: any) => { @@ -110,6 +112,7 @@ */ const addRow = (list: ICheckItem[], title: string) => { if (!checkFrequencyUnit(list)) { return false } + if (!checkArrayDataUnique()) { return false } if (checkList(list, `${title}表格`)) { if (list.length) { // 增加行时默认上一行数据 list.push({ @@ -311,6 +314,28 @@ loading.close() }) } +// 校验三个表格中不能同时出现核查项目和核查点两个属性同时相同的两条数据 +function checkArrayDataUnique() { + const tempBestList = bestList.value.map((item: any, index: number) => { item.tempTitle = '最佳点'; item.tempIndex = index; return item }) + const tempWorstList = worstList.value.map((item: any, index: number) => { item.tempTitle = '最差点'; item.tempIndex = index; return item }) + const tempModelList = modelList.value.map((item: any, index: number) => { item.tempTitle = '典型点'; item.tempIndex = index; return item }) + const list = tempBestList.concat(tempWorstList, tempModelList) + 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[j].checkPoint) { + if (list[i].tempTitle === list[j].tempTitle) { + ElMessage.warning(`${list[i].tempTitle}第${list[i].tempIndex + 1}行第${list[j].tempIndex + 1}行的 核查项目和核查点不能完全一样`) + } + else { + ElMessage.warning(`${list[i].tempTitle}第${list[i].tempIndex + 1}行和${list[j].tempTitle}第${list[j].tempIndex + 1}行的 核查项目和核查点不能完全一样`) + } + return false + } + } + } + return true +} // ------------------------------------------钩子-------------------------------------------------- onMounted(() => { form.value.equipmentNo = $route.query.equipmentNo as string // 统一编号 diff --git a/src/commonMethods/useArrayDataUnique.ts b/src/commonMethods/useArrayDataUnique.ts index 41b3ccc..f6ae9d6 100644 --- a/src/commonMethods/useArrayDataUnique.ts +++ b/src/commonMethods/useArrayDataUnique.ts @@ -1,4 +1,4 @@ -// import { ElMessage } from 'element-plus' +import { ElMessage } from 'element-plus' /** * 检查数组中不能存在属性数组中同时一样的两条数据 @@ -6,5 +6,34 @@ * @param property 属性数组 */ export function useArrayDataUnique(list: any, property: string[]) { - console.log('--', list, property) + 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}行的两个属性不能完全一样`) + } + } + } } + +// 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/first/config.vue b/src/views/equipement/standard/book/components/config/first/config.vue index b37d416..00cc993 100644 --- a/src/views/equipement/standard/book/components/config/first/config.vue +++ b/src/views/equipement/standard/book/components/config/first/config.vue @@ -60,7 +60,9 @@ ]) // 校验表格(点击保存的时候、增加行用) const checkList = (list: any, title: string) => { - return useCheckList(list, columns.value, title) + if (!checkArrayDataUnique()) { return false } + if (!useCheckList(list, columns.value, title)) { return false } + return true } // 频率有数据的时候校验频率单位字段 const checkFrequencyUnit = (list: any) => { @@ -110,6 +112,7 @@ */ const addRow = (list: ICheckItem[], title: string) => { if (!checkFrequencyUnit(list)) { return false } + if (!checkArrayDataUnique()) { return false } if (checkList(list, `${title}表格`)) { if (list.length) { // 增加行时默认上一行数据 list.push({ @@ -311,6 +314,28 @@ loading.close() }) } +// 校验三个表格中不能同时出现核查项目和核查点两个属性同时相同的两条数据 +function checkArrayDataUnique() { + const tempBestList = bestList.value.map((item: any, index: number) => { item.tempTitle = '最佳点'; item.tempIndex = index; return item }) + const tempWorstList = worstList.value.map((item: any, index: number) => { item.tempTitle = '最差点'; item.tempIndex = index; return item }) + const tempModelList = modelList.value.map((item: any, index: number) => { item.tempTitle = '典型点'; item.tempIndex = index; return item }) + const list = tempBestList.concat(tempWorstList, tempModelList) + 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[j].checkPoint) { + if (list[i].tempTitle === list[j].tempTitle) { + ElMessage.warning(`${list[i].tempTitle}第${list[i].tempIndex + 1}行第${list[j].tempIndex + 1}行的 核查项目和核查点不能完全一样`) + } + else { + ElMessage.warning(`${list[i].tempTitle}第${list[i].tempIndex + 1}行和${list[j].tempTitle}第${list[j].tempIndex + 1}行的 核查项目和核查点不能完全一样`) + } + return false + } + } + } + return true +} // ------------------------------------------钩子-------------------------------------------------- onMounted(() => { form.value.equipmentNo = $route.query.equipmentNo as string // 统一编号 diff --git a/src/views/equipement/standard/book/components/config/third/config.vue b/src/views/equipement/standard/book/components/config/third/config.vue index 5b4e2f5..ed89ae5 100644 --- a/src/views/equipement/standard/book/components/config/third/config.vue +++ b/src/views/equipement/standard/book/components/config/third/config.vue @@ -81,23 +81,23 @@ * @param title 操作的表格 */ const addRow = (list: IList[], title: string) => { - if (checkList(list, `${title}表格`)) { - // 增加行时默认上一行数据 - list.push({ - id: '', - checkPoint: list.length ? list[list.length - 1].checkPoint : '', // 核查点(直接存字典value) - checkType: list.length ? list[list.length - 1].checkType : ['重复性', '稳定性'], // 核查类型 - cycleNumber: list.length ? list[list.length - 1].cycleNumber : 6, // 循环次数 - equipmentId: list.length ? list[list.length - 1].equipmentId : infoId.value, // 配套设备id - itemCategoryId: list.length ? list[list.length - 1].itemCategoryId : form.value.itemCategoryId, // 核查项分类id(能够确定是哪个标准装置) - params: list.length ? list[list.length - 1].params : title, // 核查项目(直接存字典value) - remark: list.length ? list[list.length - 1].remark : '', // 核查项备注(每个数据存储的核查项备注相同,前端取列表中一个即可) - resolution: list.length ? list[list.length - 1].resolution : 0.0001, // 分辨力 - testType: list.length ? list[list.length - 1].testType : title, // 核查点类型(直接存字典value) - unit: list.length ? list[list.length - 1].unit : '', // 单位(直接存字典value) - urel: list.length ? list[list.length - 1].urel : 0, // 测量标准相对扩展不确定度urel - }) - } + if (!checkArrayDataUnique()) { return false } + if (!checkList(list, `${title}表格`)) { return false } + // 增加行时默认上一行数据 + list.push({ + id: '', + checkPoint: list.length ? list[list.length - 1].checkPoint : '', // 核查点(直接存字典value) + checkType: list.length ? list[list.length - 1].checkType : ['重复性', '稳定性'], // 核查类型 + cycleNumber: list.length ? list[list.length - 1].cycleNumber : 6, // 循环次数 + equipmentId: list.length ? list[list.length - 1].equipmentId : infoId.value, // 配套设备id + itemCategoryId: list.length ? list[list.length - 1].itemCategoryId : form.value.itemCategoryId, // 核查项分类id(能够确定是哪个标准装置) + params: list.length ? list[list.length - 1].params : title, // 核查项目(直接存字典value) + remark: list.length ? list[list.length - 1].remark : '', // 核查项备注(每个数据存储的核查项备注相同,前端取列表中一个即可) + resolution: list.length ? list[list.length - 1].resolution : 0.0001, // 分辨力 + testType: list.length ? list[list.length - 1].testType : title, // 核查点类型(直接存字典value) + unit: list.length ? list[list.length - 1].unit : '', // 单位(直接存字典value) + urel: list.length ? list[list.length - 1].urel : 0, // 测量标准相对扩展不确定度urel + }) } /** * 删除行公共方法 @@ -149,6 +149,7 @@ if (!listResistance.value.length) { ElMessage.warning('电阻测量表格不能为空'); return false } if (!checkList(listVoltage.value, '直流电压表格')) { return false } if (!checkList(listResistance.value, '电阻测量表格')) { return false } + if (!checkArrayDataUnique()) { return false } const voltage = listVoltage.value.map((item) => { return { ...item, @@ -209,6 +210,28 @@ loading.close() }) } + +// 校验三个表格中不能同时出现核查项目和核查点两个属性同时相同的两条数据 +function checkArrayDataUnique() { + const tempVoltageList = listVoltage.value.map((item: any, index: number) => { item.tempTitle = '直流电压'; item.tempIndex = index; return item }) + const tempResistanceList = listResistance.value.map((item: any, index: number) => { item.tempTitle = '电阻测量'; item.tempIndex = index; return item }) + const list = tempVoltageList.concat(tempResistanceList) + 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[j].checkPoint) { + if (list[i].tempTitle === list[j].tempTitle) { + ElMessage.warning(`${list[i].tempTitle}第${list[i].tempIndex + 1}行第${list[j].tempIndex + 1}行的 核查项目和核查点不能完全一样`) + } + else { + ElMessage.warning(`${list[i].tempTitle}第${list[i].tempIndex + 1}行和${list[j].tempTitle}第${list[j].tempIndex + 1}行的 核查项目和核查点不能完全一样`) + } + return false + } + } + } + return true +} // ------------------------------------------钩子-------------------------------------------------- onMounted(() => { diff --git a/src/commonMethods/useArrayDataUnique.ts b/src/commonMethods/useArrayDataUnique.ts index 41b3ccc..f6ae9d6 100644 --- a/src/commonMethods/useArrayDataUnique.ts +++ b/src/commonMethods/useArrayDataUnique.ts @@ -1,4 +1,4 @@ -// import { ElMessage } from 'element-plus' +import { ElMessage } from 'element-plus' /** * 检查数组中不能存在属性数组中同时一样的两条数据 @@ -6,5 +6,34 @@ * @param property 属性数组 */ export function useArrayDataUnique(list: any, property: string[]) { - console.log('--', list, property) + 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}行的两个属性不能完全一样`) + } + } + } } + +// 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/first/config.vue b/src/views/equipement/standard/book/components/config/first/config.vue index b37d416..00cc993 100644 --- a/src/views/equipement/standard/book/components/config/first/config.vue +++ b/src/views/equipement/standard/book/components/config/first/config.vue @@ -60,7 +60,9 @@ ]) // 校验表格(点击保存的时候、增加行用) const checkList = (list: any, title: string) => { - return useCheckList(list, columns.value, title) + if (!checkArrayDataUnique()) { return false } + if (!useCheckList(list, columns.value, title)) { return false } + return true } // 频率有数据的时候校验频率单位字段 const checkFrequencyUnit = (list: any) => { @@ -110,6 +112,7 @@ */ const addRow = (list: ICheckItem[], title: string) => { if (!checkFrequencyUnit(list)) { return false } + if (!checkArrayDataUnique()) { return false } if (checkList(list, `${title}表格`)) { if (list.length) { // 增加行时默认上一行数据 list.push({ @@ -311,6 +314,28 @@ loading.close() }) } +// 校验三个表格中不能同时出现核查项目和核查点两个属性同时相同的两条数据 +function checkArrayDataUnique() { + const tempBestList = bestList.value.map((item: any, index: number) => { item.tempTitle = '最佳点'; item.tempIndex = index; return item }) + const tempWorstList = worstList.value.map((item: any, index: number) => { item.tempTitle = '最差点'; item.tempIndex = index; return item }) + const tempModelList = modelList.value.map((item: any, index: number) => { item.tempTitle = '典型点'; item.tempIndex = index; return item }) + const list = tempBestList.concat(tempWorstList, tempModelList) + 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[j].checkPoint) { + if (list[i].tempTitle === list[j].tempTitle) { + ElMessage.warning(`${list[i].tempTitle}第${list[i].tempIndex + 1}行第${list[j].tempIndex + 1}行的 核查项目和核查点不能完全一样`) + } + else { + ElMessage.warning(`${list[i].tempTitle}第${list[i].tempIndex + 1}行和${list[j].tempTitle}第${list[j].tempIndex + 1}行的 核查项目和核查点不能完全一样`) + } + return false + } + } + } + return true +} // ------------------------------------------钩子-------------------------------------------------- onMounted(() => { form.value.equipmentNo = $route.query.equipmentNo as string // 统一编号 diff --git a/src/views/equipement/standard/book/components/config/third/config.vue b/src/views/equipement/standard/book/components/config/third/config.vue index 5b4e2f5..ed89ae5 100644 --- a/src/views/equipement/standard/book/components/config/third/config.vue +++ b/src/views/equipement/standard/book/components/config/third/config.vue @@ -81,23 +81,23 @@ * @param title 操作的表格 */ const addRow = (list: IList[], title: string) => { - if (checkList(list, `${title}表格`)) { - // 增加行时默认上一行数据 - list.push({ - id: '', - checkPoint: list.length ? list[list.length - 1].checkPoint : '', // 核查点(直接存字典value) - checkType: list.length ? list[list.length - 1].checkType : ['重复性', '稳定性'], // 核查类型 - cycleNumber: list.length ? list[list.length - 1].cycleNumber : 6, // 循环次数 - equipmentId: list.length ? list[list.length - 1].equipmentId : infoId.value, // 配套设备id - itemCategoryId: list.length ? list[list.length - 1].itemCategoryId : form.value.itemCategoryId, // 核查项分类id(能够确定是哪个标准装置) - params: list.length ? list[list.length - 1].params : title, // 核查项目(直接存字典value) - remark: list.length ? list[list.length - 1].remark : '', // 核查项备注(每个数据存储的核查项备注相同,前端取列表中一个即可) - resolution: list.length ? list[list.length - 1].resolution : 0.0001, // 分辨力 - testType: list.length ? list[list.length - 1].testType : title, // 核查点类型(直接存字典value) - unit: list.length ? list[list.length - 1].unit : '', // 单位(直接存字典value) - urel: list.length ? list[list.length - 1].urel : 0, // 测量标准相对扩展不确定度urel - }) - } + if (!checkArrayDataUnique()) { return false } + if (!checkList(list, `${title}表格`)) { return false } + // 增加行时默认上一行数据 + list.push({ + id: '', + checkPoint: list.length ? list[list.length - 1].checkPoint : '', // 核查点(直接存字典value) + checkType: list.length ? list[list.length - 1].checkType : ['重复性', '稳定性'], // 核查类型 + cycleNumber: list.length ? list[list.length - 1].cycleNumber : 6, // 循环次数 + equipmentId: list.length ? list[list.length - 1].equipmentId : infoId.value, // 配套设备id + itemCategoryId: list.length ? list[list.length - 1].itemCategoryId : form.value.itemCategoryId, // 核查项分类id(能够确定是哪个标准装置) + params: list.length ? list[list.length - 1].params : title, // 核查项目(直接存字典value) + remark: list.length ? list[list.length - 1].remark : '', // 核查项备注(每个数据存储的核查项备注相同,前端取列表中一个即可) + resolution: list.length ? list[list.length - 1].resolution : 0.0001, // 分辨力 + testType: list.length ? list[list.length - 1].testType : title, // 核查点类型(直接存字典value) + unit: list.length ? list[list.length - 1].unit : '', // 单位(直接存字典value) + urel: list.length ? list[list.length - 1].urel : 0, // 测量标准相对扩展不确定度urel + }) } /** * 删除行公共方法 @@ -149,6 +149,7 @@ if (!listResistance.value.length) { ElMessage.warning('电阻测量表格不能为空'); return false } if (!checkList(listVoltage.value, '直流电压表格')) { return false } if (!checkList(listResistance.value, '电阻测量表格')) { return false } + if (!checkArrayDataUnique()) { return false } const voltage = listVoltage.value.map((item) => { return { ...item, @@ -209,6 +210,28 @@ loading.close() }) } + +// 校验三个表格中不能同时出现核查项目和核查点两个属性同时相同的两条数据 +function checkArrayDataUnique() { + const tempVoltageList = listVoltage.value.map((item: any, index: number) => { item.tempTitle = '直流电压'; item.tempIndex = index; return item }) + const tempResistanceList = listResistance.value.map((item: any, index: number) => { item.tempTitle = '电阻测量'; item.tempIndex = index; return item }) + const list = tempVoltageList.concat(tempResistanceList) + 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[j].checkPoint) { + if (list[i].tempTitle === list[j].tempTitle) { + ElMessage.warning(`${list[i].tempTitle}第${list[i].tempIndex + 1}行第${list[j].tempIndex + 1}行的 核查项目和核查点不能完全一样`) + } + else { + ElMessage.warning(`${list[i].tempTitle}第${list[i].tempIndex + 1}行和${list[j].tempTitle}第${list[j].tempIndex + 1}行的 核查项目和核查点不能完全一样`) + } + return false + } + } + } + return true +} // ------------------------------------------钩子-------------------------------------------------- onMounted(() => { diff --git a/src/views/equipement/standard/checkData/components/first/checkDataCom.vue b/src/views/equipement/standard/checkData/components/first/checkDataCom.vue index 2ee13a8..93fd24e 100644 --- a/src/views/equipement/standard/checkData/components/first/checkDataCom.vue +++ b/src/views/equipement/standard/checkData/components/first/checkDataCom.vue @@ -23,11 +23,8 @@ type: String, }, }) -const user = useUserStore() // 用户信息 -const $router = useRouter() // 关闭页面使用 const $route = useRoute() // 路由参数 const infoId = ref('') -const ruleFormRef = ref() // 表单ref const form = ref({ bestQualified: '合格', // 稳定性考核是否合格_最佳点 worstQualified: '合格', // 稳定性考核是否合格_最差点 @@ -54,8 +51,8 @@ ]) const current = ref('best') // 选择的tab 默认基本信息 -const repeatabilityTableLoading = ref(false) // 重复性报表各loading -const stabilityTableLoading = ref(false) // 稳定性报表各loading +const repeatabilityTableLoading = ref(false) // 重复性表格loading +const stabilityTableLoading = ref(false) // 稳定性表格loading const repeatabilityColumns = ref([ // 重复性表头 { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' }, { text: '核查点', value: 'checkPoint', align: 'center', required: true, type: 'text' }, @@ -197,7 +194,7 @@ { text: 'Urel', value: 'urel', align: 'center', type: 'text' }, { text: '相对重复性是否小于相对扩展不确定度Urel', value: 'lessThan', align: 'center', type: 'text' }, // { text: '稳定性考核是否合格', value: 'flit', align: 'center' }, -]) // 稳定性表头最佳点 +]) // 稳定性表头最佳点--查询历史日期 const stabilityColumnsWorstCheckDate = ref([ { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' }, { text: '核查点', value: 'checkPoint', align: 'center', required: true, type: 'text' }, @@ -226,7 +223,7 @@ { text: 'Urel', value: 'urel', align: 'center', type: 'text' }, { text: '相对重复性是否小于相对扩展不确定度Urel', value: 'lessThan', align: 'center', type: 'text' }, // { text: '稳定性考核是否合格', value: 'flit', align: 'center' }, -]) // 最差点稳定性 +]) // 最差点稳定性--查询历史日期 const stabilityColumnsModelCheckDate = ref([ { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' }, { text: '核查点', value: 'checkPoint', align: 'center', required: true, type: 'text' }, @@ -255,7 +252,7 @@ { text: 'Urel', value: 'urel', align: 'center', type: 'text' }, { text: '相对重复性是否小于相对扩展不确定度Urel', value: 'lessThan', align: 'center', type: 'text' }, // { text: '稳定性考核是否合格', value: 'flit', align: 'center' }, -]) // 典型点稳定性 +]) // 典型点稳定性--查询历史日期 const bestListCheckDate = ref([]) // 最佳点重复性查询数据 const bestListStabilityCheckDate = ref([]) // 最佳点稳定性查询数据 const worstListCheckDate = ref([]) // 最差点重复性查询数据 @@ -343,7 +340,7 @@ checkPoint: e.checkPoint, // 核查点 unit: e.unit, // 单位 checkType: '稳定性', - testType: e.testType, + testType: e.testType, // 核查点类型 urel: e.urel, } }) @@ -640,8 +637,6 @@ // 获取详情 function fetchInfo(id = '') { - console.log('ididididid', id) - const loading = ElLoading.service({ lock: true, background: 'rgba(255, 255, 255, 0.8)', @@ -820,7 +815,7 @@ ElMessage.warning('请计算典型点稳定性') return false } - const dateNum = 0 // 稳定性表格有几个日期 + // const dateNum = 0 // 稳定性表格有几个日期 // 统计有几个日期 // stabilityColumns.value[5].children?.forEach((item) => { diff --git a/src/commonMethods/useArrayDataUnique.ts b/src/commonMethods/useArrayDataUnique.ts index 41b3ccc..f6ae9d6 100644 --- a/src/commonMethods/useArrayDataUnique.ts +++ b/src/commonMethods/useArrayDataUnique.ts @@ -1,4 +1,4 @@ -// import { ElMessage } from 'element-plus' +import { ElMessage } from 'element-plus' /** * 检查数组中不能存在属性数组中同时一样的两条数据 @@ -6,5 +6,34 @@ * @param property 属性数组 */ export function useArrayDataUnique(list: any, property: string[]) { - console.log('--', list, property) + 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}行的两个属性不能完全一样`) + } + } + } } + +// 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/first/config.vue b/src/views/equipement/standard/book/components/config/first/config.vue index b37d416..00cc993 100644 --- a/src/views/equipement/standard/book/components/config/first/config.vue +++ b/src/views/equipement/standard/book/components/config/first/config.vue @@ -60,7 +60,9 @@ ]) // 校验表格(点击保存的时候、增加行用) const checkList = (list: any, title: string) => { - return useCheckList(list, columns.value, title) + if (!checkArrayDataUnique()) { return false } + if (!useCheckList(list, columns.value, title)) { return false } + return true } // 频率有数据的时候校验频率单位字段 const checkFrequencyUnit = (list: any) => { @@ -110,6 +112,7 @@ */ const addRow = (list: ICheckItem[], title: string) => { if (!checkFrequencyUnit(list)) { return false } + if (!checkArrayDataUnique()) { return false } if (checkList(list, `${title}表格`)) { if (list.length) { // 增加行时默认上一行数据 list.push({ @@ -311,6 +314,28 @@ loading.close() }) } +// 校验三个表格中不能同时出现核查项目和核查点两个属性同时相同的两条数据 +function checkArrayDataUnique() { + const tempBestList = bestList.value.map((item: any, index: number) => { item.tempTitle = '最佳点'; item.tempIndex = index; return item }) + const tempWorstList = worstList.value.map((item: any, index: number) => { item.tempTitle = '最差点'; item.tempIndex = index; return item }) + const tempModelList = modelList.value.map((item: any, index: number) => { item.tempTitle = '典型点'; item.tempIndex = index; return item }) + const list = tempBestList.concat(tempWorstList, tempModelList) + 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[j].checkPoint) { + if (list[i].tempTitle === list[j].tempTitle) { + ElMessage.warning(`${list[i].tempTitle}第${list[i].tempIndex + 1}行第${list[j].tempIndex + 1}行的 核查项目和核查点不能完全一样`) + } + else { + ElMessage.warning(`${list[i].tempTitle}第${list[i].tempIndex + 1}行和${list[j].tempTitle}第${list[j].tempIndex + 1}行的 核查项目和核查点不能完全一样`) + } + return false + } + } + } + return true +} // ------------------------------------------钩子-------------------------------------------------- onMounted(() => { form.value.equipmentNo = $route.query.equipmentNo as string // 统一编号 diff --git a/src/views/equipement/standard/book/components/config/third/config.vue b/src/views/equipement/standard/book/components/config/third/config.vue index 5b4e2f5..ed89ae5 100644 --- a/src/views/equipement/standard/book/components/config/third/config.vue +++ b/src/views/equipement/standard/book/components/config/third/config.vue @@ -81,23 +81,23 @@ * @param title 操作的表格 */ const addRow = (list: IList[], title: string) => { - if (checkList(list, `${title}表格`)) { - // 增加行时默认上一行数据 - list.push({ - id: '', - checkPoint: list.length ? list[list.length - 1].checkPoint : '', // 核查点(直接存字典value) - checkType: list.length ? list[list.length - 1].checkType : ['重复性', '稳定性'], // 核查类型 - cycleNumber: list.length ? list[list.length - 1].cycleNumber : 6, // 循环次数 - equipmentId: list.length ? list[list.length - 1].equipmentId : infoId.value, // 配套设备id - itemCategoryId: list.length ? list[list.length - 1].itemCategoryId : form.value.itemCategoryId, // 核查项分类id(能够确定是哪个标准装置) - params: list.length ? list[list.length - 1].params : title, // 核查项目(直接存字典value) - remark: list.length ? list[list.length - 1].remark : '', // 核查项备注(每个数据存储的核查项备注相同,前端取列表中一个即可) - resolution: list.length ? list[list.length - 1].resolution : 0.0001, // 分辨力 - testType: list.length ? list[list.length - 1].testType : title, // 核查点类型(直接存字典value) - unit: list.length ? list[list.length - 1].unit : '', // 单位(直接存字典value) - urel: list.length ? list[list.length - 1].urel : 0, // 测量标准相对扩展不确定度urel - }) - } + if (!checkArrayDataUnique()) { return false } + if (!checkList(list, `${title}表格`)) { return false } + // 增加行时默认上一行数据 + list.push({ + id: '', + checkPoint: list.length ? list[list.length - 1].checkPoint : '', // 核查点(直接存字典value) + checkType: list.length ? list[list.length - 1].checkType : ['重复性', '稳定性'], // 核查类型 + cycleNumber: list.length ? list[list.length - 1].cycleNumber : 6, // 循环次数 + equipmentId: list.length ? list[list.length - 1].equipmentId : infoId.value, // 配套设备id + itemCategoryId: list.length ? list[list.length - 1].itemCategoryId : form.value.itemCategoryId, // 核查项分类id(能够确定是哪个标准装置) + params: list.length ? list[list.length - 1].params : title, // 核查项目(直接存字典value) + remark: list.length ? list[list.length - 1].remark : '', // 核查项备注(每个数据存储的核查项备注相同,前端取列表中一个即可) + resolution: list.length ? list[list.length - 1].resolution : 0.0001, // 分辨力 + testType: list.length ? list[list.length - 1].testType : title, // 核查点类型(直接存字典value) + unit: list.length ? list[list.length - 1].unit : '', // 单位(直接存字典value) + urel: list.length ? list[list.length - 1].urel : 0, // 测量标准相对扩展不确定度urel + }) } /** * 删除行公共方法 @@ -149,6 +149,7 @@ if (!listResistance.value.length) { ElMessage.warning('电阻测量表格不能为空'); return false } if (!checkList(listVoltage.value, '直流电压表格')) { return false } if (!checkList(listResistance.value, '电阻测量表格')) { return false } + if (!checkArrayDataUnique()) { return false } const voltage = listVoltage.value.map((item) => { return { ...item, @@ -209,6 +210,28 @@ loading.close() }) } + +// 校验三个表格中不能同时出现核查项目和核查点两个属性同时相同的两条数据 +function checkArrayDataUnique() { + const tempVoltageList = listVoltage.value.map((item: any, index: number) => { item.tempTitle = '直流电压'; item.tempIndex = index; return item }) + const tempResistanceList = listResistance.value.map((item: any, index: number) => { item.tempTitle = '电阻测量'; item.tempIndex = index; return item }) + const list = tempVoltageList.concat(tempResistanceList) + 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[j].checkPoint) { + if (list[i].tempTitle === list[j].tempTitle) { + ElMessage.warning(`${list[i].tempTitle}第${list[i].tempIndex + 1}行第${list[j].tempIndex + 1}行的 核查项目和核查点不能完全一样`) + } + else { + ElMessage.warning(`${list[i].tempTitle}第${list[i].tempIndex + 1}行和${list[j].tempTitle}第${list[j].tempIndex + 1}行的 核查项目和核查点不能完全一样`) + } + return false + } + } + } + return true +} // ------------------------------------------钩子-------------------------------------------------- onMounted(() => { diff --git a/src/views/equipement/standard/checkData/components/first/checkDataCom.vue b/src/views/equipement/standard/checkData/components/first/checkDataCom.vue index 2ee13a8..93fd24e 100644 --- a/src/views/equipement/standard/checkData/components/first/checkDataCom.vue +++ b/src/views/equipement/standard/checkData/components/first/checkDataCom.vue @@ -23,11 +23,8 @@ type: String, }, }) -const user = useUserStore() // 用户信息 -const $router = useRouter() // 关闭页面使用 const $route = useRoute() // 路由参数 const infoId = ref('') -const ruleFormRef = ref() // 表单ref const form = ref({ bestQualified: '合格', // 稳定性考核是否合格_最佳点 worstQualified: '合格', // 稳定性考核是否合格_最差点 @@ -54,8 +51,8 @@ ]) const current = ref('best') // 选择的tab 默认基本信息 -const repeatabilityTableLoading = ref(false) // 重复性报表各loading -const stabilityTableLoading = ref(false) // 稳定性报表各loading +const repeatabilityTableLoading = ref(false) // 重复性表格loading +const stabilityTableLoading = ref(false) // 稳定性表格loading const repeatabilityColumns = ref([ // 重复性表头 { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' }, { text: '核查点', value: 'checkPoint', align: 'center', required: true, type: 'text' }, @@ -197,7 +194,7 @@ { text: 'Urel', value: 'urel', align: 'center', type: 'text' }, { text: '相对重复性是否小于相对扩展不确定度Urel', value: 'lessThan', align: 'center', type: 'text' }, // { text: '稳定性考核是否合格', value: 'flit', align: 'center' }, -]) // 稳定性表头最佳点 +]) // 稳定性表头最佳点--查询历史日期 const stabilityColumnsWorstCheckDate = ref([ { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' }, { text: '核查点', value: 'checkPoint', align: 'center', required: true, type: 'text' }, @@ -226,7 +223,7 @@ { text: 'Urel', value: 'urel', align: 'center', type: 'text' }, { text: '相对重复性是否小于相对扩展不确定度Urel', value: 'lessThan', align: 'center', type: 'text' }, // { text: '稳定性考核是否合格', value: 'flit', align: 'center' }, -]) // 最差点稳定性 +]) // 最差点稳定性--查询历史日期 const stabilityColumnsModelCheckDate = ref([ { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' }, { text: '核查点', value: 'checkPoint', align: 'center', required: true, type: 'text' }, @@ -255,7 +252,7 @@ { text: 'Urel', value: 'urel', align: 'center', type: 'text' }, { text: '相对重复性是否小于相对扩展不确定度Urel', value: 'lessThan', align: 'center', type: 'text' }, // { text: '稳定性考核是否合格', value: 'flit', align: 'center' }, -]) // 典型点稳定性 +]) // 典型点稳定性--查询历史日期 const bestListCheckDate = ref([]) // 最佳点重复性查询数据 const bestListStabilityCheckDate = ref([]) // 最佳点稳定性查询数据 const worstListCheckDate = ref([]) // 最差点重复性查询数据 @@ -343,7 +340,7 @@ checkPoint: e.checkPoint, // 核查点 unit: e.unit, // 单位 checkType: '稳定性', - testType: e.testType, + testType: e.testType, // 核查点类型 urel: e.urel, } }) @@ -640,8 +637,6 @@ // 获取详情 function fetchInfo(id = '') { - console.log('ididididid', id) - const loading = ElLoading.service({ lock: true, background: 'rgba(255, 255, 255, 0.8)', @@ -820,7 +815,7 @@ ElMessage.warning('请计算典型点稳定性') return false } - const dateNum = 0 // 稳定性表格有几个日期 + // const dateNum = 0 // 稳定性表格有几个日期 // 统计有几个日期 // stabilityColumns.value[5].children?.forEach((item) => { diff --git a/src/views/equipement/standard/checkData/components/third/checkDataCom.vue b/src/views/equipement/standard/checkData/components/third/checkDataCom.vue index 20b8e9e..6725602 100644 --- a/src/views/equipement/standard/checkData/components/third/checkDataCom.vue +++ b/src/views/equipement/standard/checkData/components/third/checkDataCom.vue @@ -3,47 +3,45 @@ import { ref } from 'vue' import { ElLoading, ElMessage } from 'element-plus' import saveCheckRecord from '../../dialog/saveCheckRecord.vue' +import { clearDateValue, handleDetailTableTableHead, handleSaveDateParams, solveHistoryIndicationTableData } from '../useStabilityCaculate' import type { IList } from './third-interface' import type { TableColumn } from '@/components/NormalTable/table_interface' import useUserStore from '@/store/modules/user' import type { dictType } from '@/global' import { getDictByCode } from '@/api/system/dict' import multiTable from '@/components/MultiHeaderTable/index.vue' +import { addCheckData, calculateHandle, getHistoryIndication, getInfo, updateCheckData } from '@/api/equipment/standard/checkData' import { getCheckItemDetail, getJobInstructionList } from '@/api/equipment/standard/book' -import { addCheckData, calculateHandle, getInfo, updateCheckData } from '@/api/equipment/standard/checkData' -const user = useUserStore() // 用户信息 -const $router = useRouter() // 关闭页面使用 -const $route = useRoute() // 路由参数 -const pageType = ref('add') // 页面类型: add, edit, detail -const infoId = ref('') -const ruleFormRef = ref() // 表单ref -const form = ref({ - conclusion: '', // 结论 - remark: '/', // 备注 +const props = defineProps({ + selectStandardId: { + type: String, + }, + pageType: { // 页面类型 + type: String, + }, + checkDate: { // 核查日期 + type: String, + }, }) -const belongStandardEquipment = ref('1') +const $route = useRoute() // 路由参数 +const infoId = ref('') +const form = ref({ + voltageQualified: '合格', // 稳定性考核是否合格_直流电压 + resistanceQualified: '合格', // 稳定性考核是否合格_电阻测量 +}) +const belongStandardEquipment = ref('3') const itemCategoryId = ref('') const itemCategoryName = ref('') +const equipmentId = ref('') // 设备id +const dateArrStability = ref([]) // 稳定性日期数组 +const currentDate = ref('') // 要查询历史稳定性的日期 // ----------------------------------路由参数------------------------------------------------ if ($route.params && $route.params.type) { - pageType.value = $route.params.type as string - console.log(pageType.value) - if ($route.params.id) { infoId.value = $route.params.id as string } } -// ------------------------------------------字典---------------------------------------------- -const conclusionList = ref([]) // 结论 - -function getDict() { - // 结论 - getDictByCode('conclusion').then((response) => { - conclusionList.value = response.data - }) -} -// getDict() // ----------------------------------------核查数据---------------------------------------------- const radioMenus = ref([ // 标签内容 @@ -51,16 +49,17 @@ { name: '电阻测量', value: 'resistance' }, ]) const current = ref('voltage') // 选择的tab 默认基本信息 + const repeatabilityColumns = ref([ // 重复性表头 - { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' }, + { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text', width: '90' }, { text: '核查点', value: 'checkPoint', align: 'center', required: true, type: 'text' }, { text: '单位', value: 'unit', align: 'center', required: true, type: 'text' }, { text: '示值', value: 'indicatingValue', align: 'center', - required: true, - width: '160', + required: false, + width: '180', children: [ { text: '1', value: 'testValueOne', align: 'center', required: true, type: 'inputNumber' }, { text: '2', value: 'testValueTwo', align: 'center', required: true, type: 'inputNumber' }, @@ -74,23 +73,23 @@ { text: '标准偏差S(X)', value: 'standardDeviation', align: 'center', required: true, type: 'text' }, { text: '相对重复性', value: 'relativeRepeatability', align: 'center', type: 'text' }, ]) -const stabilityColumns = ref([ // 稳定性表头 - { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' }, +const stabilityColumnsVoltage = ref([ // 稳定性表头直流电压 + { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text', width: '90' }, { text: '核查点', value: 'checkPoint', align: 'center', required: true, type: 'text' }, { text: '单位', value: 'unit', align: 'center', required: true, type: 'text' }, { text: '示值', value: 'indicatingValue', align: 'center', - required: true, - width: '110', + required: false, + width: '180', children: [ - { text: '2022-12-12', value: '2022-12-12', align: 'center', required: true, type: 'text' }, - { text: '2022-12-13', value: '2022-12-13', align: 'center', required: true, type: 'text' }, - { text: '2022-12-14', value: '2022-12-14', align: 'center', required: true, type: 'text' }, - { text: '2022-12-15', value: '2022-12-15', align: 'center', required: true, type: 'text' }, - { text: '2022-12-16', value: '2022-12-16', align: 'center', required: true, type: 'text' }, - { text: '2022-12-17', value: '2022-12-17', align: 'center', required: true, type: 'text' }, + { text: '-', value: 'testValueOne', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueTwo', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueThree', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueFour', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueFive', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueSix', align: 'center', required: false, type: 'text', customHeader: true }, ], }, { text: '算数平均值', value: 'averageValue', align: 'center', required: true, type: 'text' }, @@ -99,33 +98,112 @@ { text: 'Urel', value: 'urel', align: 'center', type: 'text' }, { text: '相对重复性是否小于相对扩展不确定度Urel', value: 'lessThan', align: 'center', type: 'text' }, ]) -const repeatabilityTableLoading = ref(false) // 重复性报表各loading -const stabilityTableLoading = ref(false) // 稳定性报表各loading -const voltageList = ref([]) // 直流电压重复性 -const voltageListStability = ref([]) // 直流电压稳定性 -const resistanceList = ref([]) // 电阻测量重复性 -const resistanceListStability = ref([]) // 电阻测量稳定性 +const stabilityColumnsResistance = ref([ // 稳定性表头电阻测量 + { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text', width: '90' }, + { text: '核查点', value: 'checkPoint', align: 'center', required: true, type: 'text' }, + { text: '单位', value: 'unit', align: 'center', required: true, type: 'text' }, + { + text: '示值', + value: 'indicatingValue', + align: 'center', + required: false, + width: '180', + children: [ + { text: '-', value: 'testValueOne', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueTwo', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueThree', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueFour', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueFive', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueSix', align: 'center', required: false, type: 'text', customHeader: true }, + ], + }, + { text: '算数平均值', value: 'averageValue', align: 'center', required: true, type: 'text' }, + { text: '标准偏差S(X)', value: 'standardDeviation', align: 'center', required: true, type: 'text' }, + { text: '相对重复性', value: 'relativeRepeatability', align: 'center', type: 'text' }, + { text: 'Urel', value: 'urel', align: 'center', type: 'text' }, + { text: '相对重复性是否小于相对扩展不确定度Urel', value: 'lessThan', align: 'center', type: 'text' }, +]) +const stabilityColumnsVoltageCheckDate = ref([ // 查询历史日期--稳定性表头直流电压 + { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text', width: '90' }, + { text: '核查点', value: 'checkPoint', align: 'center', required: true, type: 'text' }, + { text: '单位', value: 'unit', align: 'center', required: true, type: 'text' }, + { + text: '示值', + value: 'indicatingValue', + align: 'center', + required: false, + width: '180', + children: [ + { text: '-', value: 'testValueOne', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueTwo', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueThree', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueFour', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueFive', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueSix', align: 'center', required: false, type: 'text', customHeader: true }, + ], + }, + { text: '算数平均值', value: 'averageValue', align: 'center', required: true, type: 'text' }, + { text: '标准偏差S(X)', value: 'standardDeviation', align: 'center', required: true, type: 'text' }, + { text: '相对重复性', value: 'relativeRepeatability', align: 'center', type: 'text' }, + { text: 'Urel', value: 'urel', align: 'center', type: 'text' }, + { text: '相对重复性是否小于相对扩展不确定度Urel', value: 'lessThan', align: 'center', type: 'text' }, +]) +const stabilityColumnsResistanceCheckDate = ref([ // 查询历史日期--稳定性表头电阻测量 + { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text', width: '90' }, + { text: '核查点', value: 'checkPoint', align: 'center', required: true, type: 'text' }, + { text: '单位', value: 'unit', align: 'center', required: true, type: 'text' }, + { + text: '示值', + value: 'indicatingValue', + align: 'center', + required: false, + width: '180', + children: [ + { text: '-', value: 'testValueOne', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueTwo', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueThree', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueFour', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueFive', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueSix', align: 'center', required: false, type: 'text', customHeader: true }, + ], + }, + { text: '算数平均值', value: 'averageValue', align: 'center', required: true, type: 'text' }, + { text: '标准偏差S(X)', value: 'standardDeviation', align: 'center', required: true, type: 'text' }, + { text: '相对重复性', value: 'relativeRepeatability', align: 'center', type: 'text' }, + { text: 'Urel', value: 'urel', align: 'center', type: 'text' }, + { text: '相对重复性是否小于相对扩展不确定度Urel', value: 'lessThan', align: 'center', type: 'text' }, +]) +const repeatabilityTableLoading = ref(false) // 重复性表格loading +const stabilityTableLoading = ref(false) // 稳定性表格loading +const voltageList = ref([]) // 直流电压重复性 +const voltageListStability = ref([]) // 直流电压稳定性 +const resistanceList = ref([]) // 电阻测量重复性 +const resistanceListStability = ref([]) // 电阻测量稳定性 +const voltageListCheckDate = ref([]) // 直流电压重复性--查询历史日期 +const voltageListStabilityCheckDate = ref([]) // 直流电压稳定性--查询历史日期 +const resistanceListCheckDate = ref([]) // 电阻测量重复性--查询历史日期 +const resistanceListStabilityCheckDate = ref([]) // 电阻测量稳定性--查询历史日期 // 获取配置详情 -function fetchCheckItemDetail(equipmentId: string, belongStandardEquipmentParam: string, itemCategoryIdParam: string, itemCategoryNameParam: string) { +function fetchCheckItemDetail(equipmentIdParam: string, belongStandardEquipmentParam: string, itemCategoryIdParam: string, itemCategoryNameParam: string) { belongStandardEquipment.value = belongStandardEquipmentParam // 检校标准装置 itemCategoryId.value = itemCategoryIdParam // 核查分类id itemCategoryName.value = itemCategoryNameParam // 核查分类名称 + equipmentId.value = equipmentIdParam // 设备id const loading = ElLoading.service({ lock: true, background: 'rgba(255, 255, 255, 0.8)', }) const params = { - equipmentId, // 设备id + equipmentId: equipmentIdParam, // 设备id belongStandardEquipment: belongStandardEquipment.value, // 检校标准装置code - // itemCategoryId: itemCategoryId.value, // 核查项分类id - // itemCategoryName: itemCategoryName.value, // 核查项分类名称 - itemCategoryId: '1729312496614121474', // 核查项分类id - itemCategoryName: '多功能电气安全校准器核查项', // 核查项分类名称 + itemCategoryId: itemCategoryId.value, // 核查项分类id + itemCategoryName: itemCategoryName.value, // 核查项分类名称 } getCheckItemDetail(params).then((res) => { loading.close() handleData(res.data.checkItemDataElectricalSafetyList) + fetchHistoryIndication() // 获取稳定性 }) } @@ -165,6 +243,23 @@ urel: e.urel, // UREL } }) + // 直流电压稳定性 + voltageListStability.value = voltageList.value.map((e) => { + return { + editable: props.pageType !== 'detail', + dataId: e.id, // 核查数据管理基础信息表id + id: '', // id,更新/删除使用参数 + params: e.params, // 核查项目 + checkPoint: e.checkPoint, // 核查点 + unit: e.unit, // 单位 + checkType: '稳定性', + urel: e.urel, + // averageValue: '', // 核查读数平均值(算数平均值) + // relativeRepeatability: '', // 相对重复性 + // standardDeviation: '', // Sn(x)(标准偏差) + // lessThan: '', // 是否小于相对扩展不确定度Urel(0/1) + } + }) // 电阻测量 resistanceList.value = list.filter((item: { params: string }) => item.params === '电阻测量') @@ -200,6 +295,24 @@ urel: e.urel, // UREL } }) + + // 电阻测量稳定性 + resistanceListStability.value = resistanceList.value.map((e) => { + return { + editable: props.pageType !== 'detail', + dataId: e.id, // 核查数据管理基础信息表id + id: '', // id,更新/删除使用参数 + params: e.params, // 核查项目 + checkPoint: e.checkPoint, // 核查点 + unit: e.unit, // 单位 + checkType: '稳定性', + urel: e.urel, + // averageValue: '', // 核查读数平均值(算数平均值) + // relativeRepeatability: '', // 相对重复性 + // standardDeviation: '', // Sn(x)(标准偏差) + // lessThan: '', // 是否小于相对扩展不确定度Urel(0/1) + } + }) } // 点击生成结果处理 @@ -223,17 +336,22 @@ return false } } - let checkDataElectricalSafetyList // 要传的重复或者稳定性参数 + let checkDataElectricalSafetyListParams: any // 要传的重复或者稳定性参数 if (current.value === 'voltage') { // 直流电压 - checkDataElectricalSafetyList = type === 'repeatability' ? voltageList.value : voltageListStability.value + checkDataElectricalSafetyListParams = type === 'repeatability' ? voltageList.value : voltageListStability.value } else if (current.value === 'resistance') { // 电阻测量 - checkDataElectricalSafetyList = type === 'repeatability' ? resistanceList.value : resistanceListStability.value + checkDataElectricalSafetyListParams = type === 'repeatability' ? resistanceList.value : resistanceListStability.value } const params = { belongStandardEquipment: belongStandardEquipment.value, // 检校标准装置 - checkDataElectricalSafetyList, + checkDataElectricalSafetyList: checkDataElectricalSafetyListParams.map((item: { lessThan: string }) => { + return { + ...item, + lessThan: item.lessThan === '是' ? '1' : item.lessThan === '否' ? '0' : '', // 是否小于相对扩展不确定度Urel(0/1) + } + }), itemCategoryId: itemCategoryId.value, // 核查项分类id itemCategoryName: itemCategoryName.value, // 核查项分类id } @@ -244,17 +362,24 @@ const result = res.data.map((item: any) => { return { ...item, - editable: pageType.value !== 'detail', + editable: props.pageType !== 'detail', } }) if (type === 'repeatability') { // 重复性 voltageList.value = result - } - else { // 稳定性 - voltageListStability.value = result.map((item: { relativeRepeatability: string | number; urel: string | number }) => { + voltageListStability.value = voltageListStability.value.map((item, index: number) => { return { ...item, - lessThan: Number(item.relativeRepeatability) < Number(item.urel) ? '是' : '否', + testValueSix: voltageList.value[index].averageValue, // 核查读数6(本次重复性示值算术平均值) + testValueSixDate: props.checkDate, // 核查读数6日期(本次核查日期) + } + }) + } + else { // 稳定性 + voltageListStability.value = result.map((item: { lessThan: string | number }) => { + return { + ...item, + lessThan: `${item.lessThan}` === '1' ? '是' : '否', } }) } @@ -263,61 +388,309 @@ const result = res.data.map((item: any) => { return { ...item, - editable: pageType.value !== 'detail', + editable: props.pageType !== 'detail', } }) if (type === 'repeatability') { // 重复性 resistanceList.value = result - } - else { - resistanceListStability.value = result.map((item: { relativeRepeatability: string | number; urel: string | number }) => { + resistanceListStability.value = resistanceListStability.value.map((item, index: number) => { return { ...item, - lessThan: Number(item.relativeRepeatability) < Number(item.urel) ? '是' : '否', + testValueSix: resistanceList.value[index].averageValue, // 核查读数6(本次重复性示值算术平均值) + testValueSixDate: props.checkDate, // 核查读数6日期(本次核查日期) + } + }) + } + else { // 稳定性 + resistanceListStability.value = result.map((item: { lessThan: string | number }) => { + return { + ...item, + lessThan: `${item.lessThan}` === '1' ? '是' : '否', } }) } } repeatabilityTableLoading.value = false stabilityTableLoading.value = false + }).catch(() => { + repeatabilityTableLoading.value = false + stabilityTableLoading.value = false }) } // ------------------------------------------------------------------------------------------ +// 处理详情数据 +const solveGetDetailData = (responseList: any) => { + const voltageList = responseList.filter((item: { params: string; checkType: string }) => item.params === '直流电压' && item.checkType === '重复性').map((item: any) => { + return { + ...item, + editable: props.pageType !== 'detail', + } + }) + const resistanceList = responseList.filter((item: { params: string ; checkType: string }) => item.params === '电阻测量' && item.checkType === '重复性').map((item: any) => { + return { + ...item, + editable: props.pageType !== 'detail', + } + }) + const voltageListStability = responseList.filter((item: { params: string ; checkType: string }) => item.params === '直流电压' && item.checkType === '稳定性').map((item: any) => { + return { + ...item, + lessThan: `${item.lessThan}` === '1' ? '是' : `${item.lessThan}` === '0' ? '否' : item.lessThan, + } + }) + const resistanceListStability = responseList.filter((item: { params: string; checkType: string }) => item.params === '电阻测量' && item.checkType === '稳定性').map((item: any) => { + return { + ...item, + lessThan: `${item.lessThan}` === '1' ? '是' : `${item.lessThan}` === '0' ? '否' : item.lessThan, + } + }) + + return { + tempVoltageList: voltageList, + tempResistanceList: resistanceList, + tempVoltageListStability: voltageListStability, + tempResistanceListStability: resistanceListStability, + } +} // 获取详情 -function fetchInfo() { +function fetchInfo(id = '') { const loading = ElLoading.service({ lock: true, background: 'rgba(255, 255, 255, 0.8)', }) - getInfo({ id: infoId.value }).then((res) => { - // form.value = { ...res.data } - // list.value = res.data.checkDataPistonGaugeList.map((item: any) => { - // return { - // ...item, - // editable: pageType.value !== 'detail', - // } - // }) + getInfo({ id: id || infoId.value }).then((res) => { + form.value = { ...res.data } + equipmentId.value = res.data.equipmentId + const { tempVoltageList, tempResistanceList, tempVoltageListStability, tempResistanceListStability } = solveGetDetailData(res.data.checkDataElectricalSafetyList) + if (id !== '') { // 查询的日期获得的数据 + voltageListCheckDate.value = tempVoltageList// 直流电压重复性查询数据 + voltageListStabilityCheckDate.value = tempVoltageListStability// 直流电压稳定性查询数据 + resistanceListCheckDate.value = tempResistanceList// 电阻测量重复性查询数据 + resistanceListStabilityCheckDate.value = tempResistanceListStability // 电阻测量稳定性查询数据 + } + else { + voltageList.value = tempVoltageList + resistanceList.value = tempResistanceList + voltageListStability.value = tempVoltageListStability + resistanceListStability.value = tempResistanceListStability + } + + nextTick(() => { + if (id !== '') { // 稳定性表头---查询历史的稳定性日期数据 + stabilityColumnsVoltageCheckDate.value[3].children = [ + { text: '-', value: 'testValueOne', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueTwo', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueThree', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueFour', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueFive', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueSix', align: 'center', required: false, type: 'text', customHeader: true }, + ] + stabilityColumnsResistanceCheckDate.value[3].children = [ + { text: '-', value: 'testValueOne', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueTwo', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueThree', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueFour', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueFive', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueSix', align: 'center', required: false, type: 'text', customHeader: true }, + ] + fetchHistoryIndication(currentDate.value) // 获取稳定性 + } + else { // 正常核查数据 + stabilityColumnsVoltage.value = handleDetailTableTableHead(stabilityColumnsVoltage.value, voltageListStability.value, 3) + stabilityColumnsResistance.value = handleDetailTableTableHead(stabilityColumnsResistance.value, resistanceListStability.value, 3) + } + }) + form.value.voltageQualified = `${res.data.checkDataElectricalSafetyList[0].qualified}` === '1' ? '合格' : '不合格' + form.value.resistanceQualified = `${res.data.checkDataElectricalSafetyList[0].qualified}` === '1' ? '合格' : '不合格' + if (props.pageType === 'edit') { + fetchHistoryIndication() // 重新拉取稳定性日期 + } loading.close() }) } +/** + * 获取稳定性示值 + * @param date 查询日期 + */ +function fetchHistoryIndication(date = '') { + const params = { + belongStandardEquipment: belongStandardEquipment.value, // 检校标准装置(字典code) + checkDate: date || props.checkDate!, // 核查日期 + checkParam: '', // 核查参数((直流稳压电源-直接电流(间接测量)) + conclusion: '合格', // 结论 + equipmentId: equipmentId.value, // 被核查设备id + params: current.value === 'voltage' ? '直流电压' : '电阻测量', // 核查项目 + stabilityExamine: '1', // 是否用于稳定性考核(1/0) + standardEquipmentId: props.selectStandardId!, // 被核查标准装置id + } + if (props.selectStandardId && equipmentId.value) { + stabilityTableLoading.value = true + getHistoryIndication(params).then((res) => { + if (date === '') { // 正常核查数据 + const num = props.pageType === 'edit' ? 5 : 4 + // 直流电压 + voltageListStability.value = voltageListStability.value.map((item) => { + clearDateValue(item) + const { itemData, columnsData } = solveHistoryIndicationTableData(res.data, item, stabilityColumnsVoltage.value, num, 3) + stabilityColumnsVoltage.value = columnsData + return item = itemData + }) + voltageListStability.value = handleSaveDateParams(stabilityColumnsVoltage.value, voltageListStability.value, 3) + // 电阻测量 + resistanceListStability.value = resistanceListStability.value.map((item) => { + clearDateValue(item) + const { itemData, columnsData } = solveHistoryIndicationTableData(res.data, item, stabilityColumnsResistance.value, num, 3) + stabilityColumnsResistance.value = columnsData + return item = itemData + }) + resistanceListStability.value = handleSaveDateParams(stabilityColumnsResistance.value, resistanceListStability.value, 3) + } + else { + // 直流电压 + voltageListStabilityCheckDate.value = voltageListStabilityCheckDate.value.map((item) => { + clearDateValue(item) + const { itemData, columnsData } = solveHistoryIndicationTableData(res.data, item, stabilityColumnsVoltageCheckDate.value, 5, 3) + stabilityColumnsVoltageCheckDate.value = columnsData + return item = itemData + }) + voltageListStabilityCheckDate.value = handleSaveDateParams(stabilityColumnsVoltageCheckDate.value, voltageListStabilityCheckDate.value, 3) + // 电阻测量 + resistanceListStabilityCheckDate.value = resistanceListStabilityCheckDate.value.map((item) => { + clearDateValue(item) + const { itemData, columnsData } = solveHistoryIndicationTableData(res.data, item, stabilityColumnsResistanceCheckDate.value, 5, 3) + stabilityColumnsResistanceCheckDate.value = columnsData + return item = itemData + }) + resistanceListStabilityCheckDate.value = handleSaveDateParams(stabilityColumnsResistanceCheckDate.value, resistanceListStabilityCheckDate.value, 3) + } + + stabilityTableLoading.value = false + }).catch(() => { stabilityTableLoading.value = false }) + } +} + +// 保存之前的校验 +function checkList() { + if (current.value === 'voltage' && `${voltageList.value[0].averageValue}` === '') { // 直流电压 + ElMessage.warning('请计算最佳点重复性') + return false + } + if (current.value === 'resistance' && `${resistanceList.value[0].averageValue}` === '') { // 电阻测量 + ElMessage.warning('请计算最差点重复性') + return false + } + if (current.value === 'voltage' && `${voltageListStability.value[0].lessThan}` === '') { // 直流电压 + ElMessage.warning('请计算最佳点稳定性') + return false + } + if (current.value === 'resistance' && `${resistanceListStability.value[0].lessThan}` === '') { // 电阻测量 + ElMessage.warning('请计算最差点稳定性') + return false + } + return true +} + +// =======================点击表头日期查询历史稳定性数据=================== +// 点击表头 +const handleClickHeader = (val: any, checkDateDetailId: string) => { + dateArrStability.value = ['核查数据', val.label] + fetchInfo(checkDateDetailId) // 获取此次历史日期的详情 +} + +// 日期变化 +const handleChangeRadio = (date: string) => { + currentDate.value = date +} + // -------------------------------------钩子----------------------------------------------------- +// 统计日期 +const dateCount = (columns: TableColumn[]) => { + let dateNum = 0 // 稳定性表格有几个日期 + + // 统计有几个日期 + columns[3].children?.forEach((item) => { + if (item.text !== '-' && item.text !== '') { + dateNum += 1 + } + }) + return dateNum +} + +// 监听稳定性表格--判断稳定性考核是否合格 +watch([() => voltageListStability.value, () => resistanceListStability.value], (newValue: any) => { + console.log('监听稳定性表格') + + if (newValue[0] && newValue[0].length && newValue[0].averageValue) { // 直流电压 + const result = newValue[0].every((item: { lessThan: string }) => { + return item.lessThan === '是' + }) + const dateNum = dateCount(stabilityColumnsVoltage.value) + form.value.voltageQualified = dateNum < 4 ? '合格' : result ? '合格' : '不合格' + } + + if (newValue[1] && newValue[1].length && newValue[0].averageValue) { // 电阻测量 + const result = newValue[1].every((item: { lessThan: string }) => { + return item.lessThan === '是' + }) + const dateNum = dateCount(stabilityColumnsResistance.value) + form.value.resistanceQualified = dateNum < 4 ? '合格' : result ? '合格' : '不合格' + } +}, { deep: true, immediate: true }) + +/** + * 初始化表头 + * @param soveLastColumnDate 是否处理最后一列 + */ +function initColumns() { + stabilityColumnsVoltage.value[3].children = [ + { text: '-', value: 'testValueOne', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueTwo', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueThree', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueFour', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueFive', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueSix', align: 'center', required: false, type: 'text', customHeader: true }, + ] + stabilityColumnsResistance.value[3].children = [ + { text: '-', value: 'testValueOne', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueTwo', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueThree', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueFour', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueFive', align: 'center', required: false, type: 'text', customHeader: true }, + { text: '-', value: 'testValueSix', align: 'center', required: false, type: 'text', customHeader: true }, + ] + const index = stabilityColumnsVoltage.value.findIndex(item => item.text === '示值') + if (index !== -1) { + stabilityColumnsVoltage.value[index].children![5].text = props.checkDate! // 最后一列的表头日期 + } + const indexWorst = stabilityColumnsResistance.value.findIndex(item => item.text === '示值') + if (index !== -1) { + stabilityColumnsResistance.value[indexWorst].children![5].text = props.checkDate! // 最后一列的表头日期 + } +} + +// 监听核查日期变化 +watch(() => props.checkDate, (newValue) => { + initColumns() + nextTick(() => { + fetchHistoryIndication() // 重新拉取稳定性日期 + }) +}, { immediate: true }) onMounted(async () => { - if (pageType.value !== 'add') { - belongStandardEquipment.value = $route.query.belongStandardEquipment as string // 检校标准装置 - itemCategoryId.value = $route.query.itemCategoryId as string // 核查项分类id - itemCategoryName.value = $route.query.itemCategoryName as string // 核查项分类名称 + belongStandardEquipment.value = $route.query.belongStandardEquipment as string // 检校标准装置 + itemCategoryId.value = $route.query.itemCategoryId as string // 核查项分类id + itemCategoryName.value = $route.query.itemCategoryName as string // 核查项分类名称 + if (props.pageType !== 'add') { fetchInfo() } }) - -defineExpose({ fetchCheckItemDetail, form }) +defineExpose({ checkList, fetchCheckItemDetail, form, voltageList, resistanceList, voltageListStability, resistanceListStability })