<!-- 核查数据管理详情--核查项 --> <script lang="ts" setup name="checkDataDetail"> import { ref } from 'vue' import { ElLoading, ElMessage } from 'element-plus' import saveCheckRecord from '../../dialog/saveCheckRecord.vue' import type { TableColumn } from '@/components/NormalTable/table_interface' import useUserStore from '@/store/modules/user' import multiTable from '@/components/MultiHeaderTable/index.vue' 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({ bestQualified: '', // 稳定性考核是否合格_最佳点 worstQualified: '', // 稳定性考核是否合格_最差点 modelQualified: '', // 稳定性考核是否合格_典型点 }) const belongStandardEquipment = ref('1') const itemCategoryId = ref('') const itemCategoryName = 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 radioMenus = ref([ // 标签内容 { name: '最佳点', value: 'best' }, { name: '最差点', value: 'worst' }, { name: '典型点', value: 'model' }, ]) const current = ref('best') // 选择的tab 默认基本信息 const repeatabilityTableLoading = ref(false) // 重复性报表各loading const stabilityTableLoading = ref(false) // 稳定性报表各loading const repeatabilityColumns = ref<TableColumn[]>([ // 重复性表头 { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' }, { text: '核查点', value: 'checkPoint', align: 'center', required: true, type: 'text' }, { text: '单位', value: 'unit', align: 'center', required: true, type: 'text' }, { text: '频率', value: 'frequency', align: 'center', type: 'text' }, { text: '单位', value: 'frequencyUnit', align: 'center', type: 'text' }, { text: '示值', value: 'indicatingValue', align: 'center', required: true, width: '160', children: [ { text: '1', value: 'testValueOne', align: 'center', required: true, type: 'inputNumber' }, { text: '2', value: 'testValueTwo', align: 'center', required: true, type: 'inputNumber' }, { text: '3', value: 'testValueThree', align: 'center', required: true, type: 'inputNumber' }, { text: '4', value: 'testValueFour', align: 'center', required: true, type: 'inputNumber' }, { text: '5', value: 'testValueFive', align: 'center', required: true, type: 'inputNumber' }, { text: '6', value: 'testValueSix', align: 'center', required: true, type: 'inputNumber' }, ], }, { 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' }, ]) const stabilityColumns = ref<TableColumn[]>([ // 稳定性表头 { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' }, { text: '核查点', value: 'checkPoint', align: 'center', required: true, type: 'text' }, { text: '单位', value: 'unit', align: 'center', required: true, type: 'text' }, { text: '频率', value: 'frequency', align: 'center', type: 'text' }, { text: '单位', value: 'frequencyUnit', align: 'center', type: 'text' }, { text: '示值', value: 'indicatingValue', align: 'center', required: true, width: '160', children: [ { text: '2022-12-12', value: 'testValueOne', align: 'center', required: true, type: 'inputNumber' }, { text: '2022-12-13', value: 'testValueTwo', align: 'center', required: true, type: 'inputNumber' }, { text: '2022-12-14', value: 'testValueThree', align: 'center', required: true, type: 'inputNumber' }, { text: '2022-12-15', value: 'testValueFour', align: 'center', required: true, type: 'inputNumber' }, { text: '2022-12-16', value: 'testValueFive', align: 'center', required: true, type: 'inputNumber' }, { text: '2022-12-17', value: 'testValueSix', align: 'center', required: true, type: 'inputNumber' }, ], }, { 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: '历次核查Sn(x)', value: 'previousCheck', align: 'center' }, { text: 'Urel', value: 'urel', align: 'center', type: 'text' }, { text: '相对重复性是否小于相对扩展不确定度Urel', value: 'lessThan', align: 'center', type: 'text' }, // { text: '稳定性考核是否合格', value: 'flit', align: 'center' }, ]) const bestList = ref<any[]>([]) // 最佳点重复性 const bestListStability = ref<any[]>([]) // 最佳点稳定性 const worstList = ref<any[]>([]) // 最差点重复性 const worstListStability = ref<any[]>([]) // 最差点稳定性 const modelList = ref<any[]>([]) // 典型点重复性 const modelListStability = ref<any[]>([]) // 典型点稳定性 // 获取配置详情 function fetchCheckItemDetail(equipmentId: string, belongStandardEquipmentParam: string, itemCategoryIdParam: string, itemCategoryNameParam: string) { belongStandardEquipment.value = belongStandardEquipmentParam // 检校标准装置 itemCategoryId.value = itemCategoryIdParam // 核查分类id itemCategoryName.value = itemCategoryNameParam // 核查分类名称 const loading = ElLoading.service({ lock: true, background: 'rgba(255, 255, 255, 0.8)', }) const params = { equipmentId, // 设备id belongStandardEquipment: belongStandardEquipment.value, // 检校标准装置code itemCategoryId: itemCategoryId.value, // 核查项分类id itemCategoryName: itemCategoryName.value, // 核查项分类名称 } getCheckItemDetail(params).then((res) => { loading.close() handleData(res.data.checkItemDataCalibratorList) }) } // 处理数据 function handleData(list: any, type = 'edit') { // 最佳点 bestList.value = list.filter((item: { testType: string }) => item.testType === '最佳点') // 最佳点重复性 bestList.value = bestList.value.map((e: any) => { return { ...e, frequency: !e.frequency ? '/' : e.frequency, // 频率 frequencyUnit: !e.frequencyUnit ? '/' : e.frequencyUnit, // 频率单位 editable: type === 'edit', averageValue: '', // 核查读数平均值(算数平均值) dataId: e.id, // 核查数据管理基础信息表id id: '', // id,更新/删除使用参数 lessThan: '', // 是否小于相对扩展不确定度Urel(0/1) previousCheck: '', // 历次核查Sn(x)(历次核查的标准偏差)(只稳定性有该值) qualified: '', // 稳定性考核是否合格 relativeRepeatability: '', // Sn(x)/核查读数平均值(相对重复性) standardDeviation: '', // Sn(x)(标准偏差) testType: e.testType, // 核查点类型(直接存字典value) testValueFive: '1', // 核查读数5(示值) testValueFiveDate: '', // 核查读数5日期(稳定性) testValueFour: '1', // 核查读数4(示值) testValueFourDate: '', // 核查读数4日期(稳定性) testValueOne: '1', // 核查读数1(示值) testValueOneDate: '', // 核查读数1日期(稳定性) testValueSix: '1', // 核查读数6(本次示值) testValueSixDate: '', // 核查读数6日期(稳定性) testValueThree: '1', // 核查读数3(示值) testValueThreeDate: '', // 核查读数3日期(稳定性) testValueTwo: '1', // 核查读数2(示值) testValueTwoDate: '', // 核查读数2日期(稳定性) unit: e.unit, // 单位(直接存字典value) urel: e.urel, // UREL } }) // =================这里之后会给接口查询稳定性、暂时先做假数据=================== // // 最佳点稳定性 // bestListStability.value = bestList.value.map((e: any) => { // return { // ...e, // frequency: !e.frequency ? '/' : e.frequency, // 频率 // frequencyUnit: !e.frequencyUnit ? '/' : e.frequencyUnit, // 频率单位 // editable: type !== 'detail', // averageValue: '', // 核查读数平均值(算数平均值) // dataId: e.id, // 核查数据管理基础信息表id // id: '', // id,更新/删除使用参数 // lessThan: '', // 是否小于相对扩展不确定度Urel(0/1) // previousCheck: '', // 历次核查Sn(x)(历次核查的标准偏差)(只稳定性有该值) // qualified: '', // 稳定性考核是否合格 // relativeRepeatability: '', // Sn(x)/核查读数平均值(相对重复性) // standardDeviation: '', // Sn(x)(标准偏差) // testType: e.testType, // 核查点类型(直接存字典value) // testValueFive: '1', // 核查读数5(示值) // testValueFiveDate: '', // 核查读数5日期(稳定性) // testValueFour: '1', // 核查读数4(示值) // testValueFourDate: '', // 核查读数4日期(稳定性) // testValueOne: '1', // 核查读数1(示值) // testValueOneDate: '', // 核查读数1日期(稳定性) // testValueSix: '1', // 核查读数6(本次示值) // testValueSixDate: '', // 核查读数6日期(稳定性) // testValueThree: '1', // 核查读数3(示值) // testValueThreeDate: '', // 核查读数3日期(稳定性) // testValueTwo: '1', // 核查读数2(示值) // testValueTwoDate: '', // 核查读数2日期(稳定性) // unit: e.unit, // 单位(直接存字典value) // urel: e.urel, // UREL // } // }) // 最差点 worstList.value = list.filter((item: { testType: string }) => item.testType === '最差点') // 最差点重复性 worstList.value = worstList.value.map((e: any) => { return { ...e, frequency: !e.frequency ? '/' : e.frequency, // 频率 frequencyUnit: !e.frequencyUnit ? '/' : e.frequencyUnit, // 频率单位 editable: type === 'edit', averageValue: '', // 核查读数平均值(算数平均值) dataId: e.id, // 核查数据管理基础信息表id id: '', // id,更新/删除使用参数 lessThan: '', // 是否小于相对扩展不确定度Urel(0/1) previousCheck: '', // 历次核查Sn(x)(历次核查的标准偏差)(只稳定性有该值) qualified: '', // 稳定性考核是否合格 relativeRepeatability: '', // Sn(x)/核查读数平均值(相对重复性) standardDeviation: '', // Sn(x)(标准偏差) testType: e.testType, // 核查点类型(直接存字典value) testValueFive: '1', // 核查读数5(示值) testValueFiveDate: '', // 核查读数5日期(稳定性) testValueFour: '1', // 核查读数4(示值) testValueFourDate: '', // 核查读数4日期(稳定性) testValueOne: '1', // 核查读数1(示值) testValueOneDate: '', // 核查读数1日期(稳定性) testValueSix: '1', // 核查读数6(本次示值) testValueSixDate: '', // 核查读数6日期(稳定性) testValueThree: '1', // 核查读数3(示值) testValueThreeDate: '', // 核查读数3日期(稳定性) testValueTwo: '1', // 核查读数2(示值) testValueTwoDate: '', // 核查读数2日期(稳定性) unit: e.unit, // 单位(直接存字典value) urel: e.urel, // UREL } }) // // 最差点稳定性 // worstListStability.value = worstList.value.map((e: any) => { // return { // ...e, // frequency: !e.frequency ? '/' : e.frequency, // 频率 // frequencyUnit: !e.frequencyUnit ? '/' : e.frequencyUnit, // 频率单位 // editable: true, // } // }) // 典型点 modelList.value = list.filter((item: { testType: string }) => item.testType === '典型点') // 典型点重复性 modelList.value = modelList.value.map((e: any) => { return { ...e, frequency: !e.frequency ? '/' : e.frequency, // 频率 frequencyUnit: !e.frequencyUnit ? '/' : e.frequencyUnit, // 频率单位 editable: type === 'edit', averageValue: '', // 核查读数平均值(算数平均值) dataId: e.id, // 核查数据管理基础信息表id id: '', // id,更新/删除使用参数 lessThan: '', // 是否小于相对扩展不确定度Urel(0/1) previousCheck: '', // 历次核查Sn(x)(历次核查的标准偏差)(只稳定性有该值) qualified: '', // 稳定性考核是否合格 relativeRepeatability: '', // Sn(x)/核查读数平均值(相对重复性) standardDeviation: '', // Sn(x)(标准偏差) testType: e.testType, // 核查点类型(直接存字典value) testValueFive: '1', // 核查读数5(示值) testValueFiveDate: '', // 核查读数5日期(稳定性) testValueFour: '1', // 核查读数4(示值) testValueFourDate: '', // 核查读数4日期(稳定性) testValueOne: '1', // 核查读数1(示值) testValueOneDate: '', // 核查读数1日期(稳定性) testValueSix: '1', // 核查读数6(本次示值) testValueSixDate: '', // 核查读数6日期(稳定性) testValueThree: '1', // 核查读数3(示值) testValueThreeDate: '', // 核查读数3日期(稳定性) testValueTwo: '1', // 核查读数2(示值) testValueTwoDate: '', // 核查读数2日期(稳定性) unit: e.unit, // 单位(直接存字典value) urel: e.urel, // UREL } }) // // 典型点稳定性 // modelListStability.value = modelList.value.map((e: any) => { // return { // ...e, // frequency: !e.frequency ? '/' : e.frequency, // 频率 // frequencyUnit: !e.frequencyUnit ? '/' : e.frequencyUnit, // 频率单位 // editable: true, // } // }) } // 点击生成结果处理 const createResult = (type: 'repeatability' | 'stability') => { if (current.value === 'best' && !bestList.value.length) { // 最佳点 ElMessage.warning('最佳点未配置重复性,请检查') return false } if (current.value === 'worst' && !worstList.value.length) { // 最佳点 ElMessage.warning('最差点未配置重复性,请检查') return false } if (current.value === 'model' && !modelList.value.length) { // 最佳点 ElMessage.warning('典型点未配置重复性,请检查') return false } if (type === 'stability') { if (current.value === 'best' && `${bestList.value[0].averageValue}` === '') { // 最佳点 ElMessage.warning('请先计算最佳点重复性') return false } if (current.value === 'worst' && `${worstList.value[0].averageValue}` === '') { // 最差点 ElMessage.warning('请先计算最差点重复性') return false } if (current.value === 'model' && `${modelList.value[0].averageValue}` === '') { // 典型点 ElMessage.warning('请先计算典型点重复性') return false } } let checkDataCalibratorListParam // 要传的重复或者稳定性参数 if (current.value === 'best') { // 最佳点 checkDataCalibratorListParam = type === 'repeatability' ? bestList.value : bestListStability.value } else if (current.value === 'worst') { // 最差点 checkDataCalibratorListParam = type === 'repeatability' ? worstList.value : worstListStability.value } else { // 典型点 checkDataCalibratorListParam = type === 'repeatability' ? modelList.value : modelListStability.value } const params = { belongStandardEquipment: belongStandardEquipment.value, // 检校标准装置 checkDataCalibratorList: checkDataCalibratorListParam, itemCategoryId: itemCategoryId.value, // 核查项分类id itemCategoryName: itemCategoryName.value, // 核查项分类id } repeatabilityTableLoading.value = type === 'repeatability' // 重复性表loading stabilityTableLoading.value = type === 'stability' // 稳定性表loading calculateHandle(params).then((res) => { if (current.value === 'best') { // 最佳点 const result = res.data.map((item: any) => { return { ...item, editable: pageType.value !== 'detail', } }) if (type === 'repeatability') { // 重复性 bestList.value = result } else { // 稳定性 bestListStability.value = result.map((item: { relativeRepeatability: string | number; urel: string | number }) => { return { ...item, lessThan: Number(item.relativeRepeatability) < Number(item.urel) ? '是' : '否', } }) } } else if (current.value === 'worst') { // 最差点 const result = res.data.map((item: any) => { return { ...item, editable: pageType.value !== 'detail', } }) if (type === 'repeatability') { // 重复性 worstList.value = result } else { worstListStability.value = result.map((item: { relativeRepeatability: string | number; urel: string | number }) => { return { ...item, lessThan: Number(item.relativeRepeatability) < Number(item.urel) ? '是' : '否', } }) } } else { // 典型点 const result = res.data.map((item: any) => { return { ...item, editable: pageType.value !== 'detail', } }) if (type === 'repeatability') { // 重复性 modelList.value = result } else { // 稳定性 modelListStability.value = result.map((item: { relativeRepeatability: string | number; urel: string | number }) => { return { ...item, lessThan: Number(item.relativeRepeatability) < Number(item.urel) ? '是' : '否', } }) } } repeatabilityTableLoading.value = false stabilityTableLoading.value = false }) } // ------------------------------------------------------------------------------------------ // 获取详情 function fetchInfo() { const loading = ElLoading.service({ lock: true, background: 'rgba(255, 255, 255, 0.8)', }) getInfo({ id: infoId.value }).then((res) => { form.value = { ...res.data } // ======================暂时如此处理======================= // handleData(res.data.checkDataCalibratorList, 'detail') bestList.value = res.data.checkDataCalibratorList loading.close() }) } // -------------------------------------钩子----------------------------------------------------- // 监听最佳点稳定性表格--判断稳定性考核是否合格 watch([() => bestListStability.value, () => worstListStability.value, () => modelListStability.value], (newValue: any) => { if (newValue[0] && newValue[0].length && newValue[0].averageValue) { // 最佳点 const result = newValue[0].every((item: { lessThan: string }) => { return item.lessThan === '是' }) form.value.bestQualified = result ? '合格' : '不合格' } if (newValue[1] && newValue[1].length && newValue[0].averageValue) { // 最差点 const result = newValue[1].every((item: { lessThan: string }) => { return item.lessThan === '是' }) console.log('result', result) form.value.worstQualified = result ? '合格' : '不合格' } if (newValue[2] && newValue[2].length && newValue[0].averageValue) { // 典型点 const result = newValue[2].every((item: { lessThan: string }) => { return item.lessThan === '是' }) form.value.modelQualified = result ? '合格' : '不合格' } }) onMounted(async () => { if (pageType.value !== 'add') { fetchInfo() } }) defineExpose({ fetchCheckItemDetail, form, bestList, bestListStability, worstList, worstListStability, modelList, modelListStability }) </script> <template> <!-- 核查数据 --> <detail-block title="核查数据"> <div style="display: flex;justify-content: space-between;"> <el-radio-group v-model="current" style="margin-bottom: 20px;"> <el-radio-button v-for="item in radioMenus" :key="item.value" :label="item.value"> {{ item.name }} </el-radio-button> </el-radio-group> </div> <div style="display: flex;justify-content: space-between;align-items: center;"> <h5>核查类型--重复性</h5> <el-button v-if="pageType !== 'detail'" type="primary" @click="createResult('repeatability')"> 生成结果处理 </el-button> </div> <multi-table v-loading="repeatabilityTableLoading" :table-data="current === 'best' ? bestList : current === 'worst' ? worstList : modelList" :table-header="repeatabilityColumns" :merge-rows="[]" :need-index="true" max-height="300" /> <div style="display: flex;justify-content: space-between;align-items: center;"> <h5>核查类型--稳定性</h5> <el-button v-if="pageType !== 'detail'" type="primary" @click="createResult('stability')"> 生成结果处理 </el-button> </div> <multi-table v-loading="stabilityTableLoading" :table-data="current === 'best' ? bestListStability : current === 'worst' ? worstListStability : modelListStability" :table-header="stabilityColumns" :merge-rows="[]" :need-index="true" max-height="500" /> <!-- 稳定性考核是否合格 --> <el-form style="margin-top: 20px;" :model="form" label-width="160" label-position="right" > <el-row :gutter="24"> <el-col :span="12"> <el-form-item v-if="current === 'best'" label="稳定性考核是否合格(最佳点):"> <el-input v-model="form.bestQualified" class="full-width-input" disabled placeholder="稳定性考核是否合格" /> </el-form-item> <el-form-item v-if="current === 'worst'" label="稳定性考核是否合格(最差点):"> <el-input v-model="form.worstQualified" class="full-width-input" disabled placeholder="稳定性考核是否合格" /> </el-form-item> <el-form-item v-if="current === 'model'" label="稳定性考核是否合格(典型点):"> <el-input v-model="form.modelQualified" class="full-width-input" disabled placeholder="稳定性考核是否合格" /> </el-form-item> </el-col> </el-row> </el-form> </detail-block> <!-- 保存核查记录 --> <save-check-record ref="saveCheckRecordRef" /> </template> <style lang="scss" scoped> .link { text-decoration: underline; color: #3d7eff; cursor: pointer; } .file-area { display: flex; align-items: center; font-size: 14px; color: #60627f; margin-bottom: 10px; margin-left: 40px; white-space: nowrap; .tech-file { display: flex; align-items: center; margin-left: 20px; .file-text { margin-right: 10px; } } } </style>