<!-- 第5套:二等铂 --> <!-- 检定数据管理详情模板 --> <script lang="ts" setup name="MeasureDataTemplateDetail"> import { ref } from 'vue' import { ElLoading, ElMessage } from 'element-plus' import dayjs from 'dayjs' import changeRecord from '../changeRecord.vue' import TemplateFormAndTable from '../templateFormAndTable.vue' import { useSolveFormData } from '../useSolveFormData' import type { IDetailMeasureList } from './fifth-interface' import useUserStore from '@/store/modules/user' import type { dictType } from '@/global' import { getDictByCode } from '@/api/system/dict' import type { TableColumn } from '@/components/NormalTable/table_interface' import { calculateHandle, getInfo } from '@/api/business/taskMeasure/measureData' import { getInfo as getItemInfo } from '@/api/business/measure/item' import { useCheckList } from '@/commonMethods/useCheckList' import multiTable from '@/components/MultiHeaderTable/index.vue' import { calc } from '@/utils/useCalc' import { initTableRow } from '@/commonMethods/useMergeTableRow' const props = defineProps({ infoId: String, // id dataNo: String, // 检定数据编号 pageType: String, }) const emits = defineEmits(['giveInfoId', 'changePageType']) const user = useUserStore() // 用户信息 const $router = useRouter() // 关闭页面使用 const $route = useRoute() // 路由参数 const ruleFormRef = ref() // 表单ref const templateFormAndTableRef = ref() // 表单和被检设备、测量设备表格公共组件ref const itemFormData = ref({ // 有关于检定项的数据 itemId: '', // 检定项id itemCategoryName: '', // 设备检定项分类名称 itemCategoryId: '', // 设备检定项分类名称id belongStandardEquipment: '', // 标准装置code belongStandardEquipmentName: '', // 标准装置名称 appearance: '1', // 外观检查 isShowAppearance: false, // 外观检查输入数据--用来判断外观是否展示 isShowInsulationResistance: false, // 绝缘电阻输入数据--判断是否展示 insulationResistanceValue: '', // 绝缘电阻值 angleAdjustError: '1', // 角度调整误差(可调整角度仪表) isShowAngleAdjustErrort: false, // 角度调整误差(可调整角度仪表)输入数据--判断是否展示 resultConclusion: '', // 检验结论 remark: '', // 备注 rankLevel: '', // 级别(工业铂铜热电阻) }) const tableTop = ref(false) // 上面表格loading const tableBottom = ref(false) // 下面表格loading // -------------------------------------------路由参数------------------------------------------ const infoId = ref('') // 列表id if ($route.params && $route.params.type) { if ($route.params.id) { infoId.value = $route.params.id as string } } // --------------------------------------------字典-------------------------------------- const conclusionList = ref<dictType[]>([])// 结论 async function getDict() { // 结论 getDictByCode('bizUltimateness').then((response) => { conclusionList.value = response.data }) } getDict() // ------------------------------------------标签---------------------------------------------------------- const radioMenus = ref([ // 标签内容 { name: '检定数据', value: 'measure-data' }, { name: '历史修改记录', value: 'change-record' }, ]) const current = ref('measure-data') // 选择的tab 默认基本信息 // ---------------------------------------检定项数据表格---------------------------------------------------- // ==============================恒温槽=============================== const thermostaticBathWaveList = ref<IDetailMeasureList[]>([]) // 恒温槽-波动性测试表格数据 const thermostaticBathEvenList = ref<IDetailMeasureList[]>([]) // 恒温槽-均匀性测试表格数据 const columns_thermostatic_bath_wave = ref([ // 恒温槽--波动性测试 // 下/上限点:指标上限、指标下限 { text: '下/上限点', value: 'upperLowerPoint', 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: '1', value: 'oneValue', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4 }, { text: '2', value: 'twoValue', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4 }, { text: '3', value: 'threeValue', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4 }, { text: '4', value: 'fourValue', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4 }, { text: '5', value: 'fiveValue', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4 }, { text: '6', value: 'sixValue', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4 }, { text: '7', value: 'sevenValue', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4 }, { text: '8', value: 'eightValue', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4 }, { text: '9', value: 'nineValue', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4 }, { text: '10', value: 'tenValue', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4 }, { text: '11', value: 'elevenValue', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4 }, { text: '12', value: 'twelveValue', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4 }, { text: '13', value: 'thirteenValue', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4 }, { text: '14', value: 'fourteenValue', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4 }, { text: '15', value: 'fifteenValue', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4 }, ], }, { text: '最大值', value: 'maxValue', align: 'center', required: false, type: 'text' }, { text: '最小值', value: 'minValue', align: 'center', required: false, type: 'text' }, { text: '波动性', value: 'volatility', align: 'center', type: 'text' }, ]) const columns_thermostatic_bath_even = ref([ // 恒温槽--均匀性测试 { text: '下/上限点', value: 'upperLowerPoint', align: 'center', required: true, type: 'text' }, { text: '单位', value: 'unit', align: 'center', required: true, type: 'text' }, { text: '位置', value: 'location', align: 'center', required: true, type: 'text' }, { text: '示值', value: 'indicatingValue', align: 'center', required: false, width: '180', children: [ { text: 'ROA1', value: 'oneValue', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4 }, { text: 'RA1', value: 'twoValue', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4 }, { text: 'RA2', value: 'fourValue', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4 }, { text: 'ROA2', value: 'threeValue', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4 }, { text: 'ROA3', value: 'fiveValue', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4 }, { text: 'RA3', value: 'sixValue', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4 }, { text: 'RA4', value: 'eightValue', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4 }, { text: 'ROA4', value: 'sevenValue', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4 }, { text: 'ROA均值', value: 'nineValue', align: 'center', required: true, type: 'text', precision: 4 }, { text: 'RA均值', value: 'tenValue', align: 'center', required: true, type: 'text', precision: 4 }, ], }, { text: '上水平面温差', value: 'upperTemperatureDifferent', align: 'center', required: false, type: 'text' }, { text: '下水平面温差', value: 'lowerTemperatureDifferent', align: 'center', required: false, type: 'text' }, { text: '水平最大温差', value: 'maxHorizontalTemperatureDifferent', align: 'center', type: 'text' }, { text: '工作区域最大温差', value: 'maxWorkTemperatureDifferent', align: 'center', type: 'text' }, ]) // ===============================双金属温度计======================== const bimetalThermometerList = ref<IDetailMeasureList[]>([]) // 双金属温度计表格数据 const columns_bimetal_thermometer = ref([ // 双金属温度计表头 { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text', width: '90' }, { text: '校准点', value: 'calibratedPoint', align: 'center', required: true, type: 'text' }, { text: '标准器示值', value: 'beforeFrictionStroke', align: 'center', required: false, width: '180', children: [ { text: '正行程', value: 'indicatingValueForwardStroke', align: 'center', required: true, width: '180', type: 'inputNumber' }, { text: '反行程', value: 'indicatingValueReverseStroke', align: 'center', required: true, width: '180', type: 'inputNumber' }, ], }, { text: '被检示值', value: 'beforeFrictionStroke', align: 'center', width: '180', required: false, children: [ { text: '正行程', value: 'measureIndicationValueForwardStroke', align: 'center', required: true, width: '180', type: 'inputNumber' }, { text: '反行程', value: 'measureIndicationValueReverseStroke', align: 'center', required: true, width: '180', type: 'inputNumber' }, ], }, { text: '示值误差', value: 'beforeFrictionStroke', align: 'center', width: '180', required: false, children: [ { text: '正行程', value: 'indicatingErrorForwardStroke', align: 'center', required: true, type: 'text' }, { text: '反行程', value: 'indicatingErrorReverseStroke', align: 'center', required: true, type: 'text' }, ], }, { text: '最大允许误差', value: 'maximumError', align: 'center', required: true, type: 'text' }, { text: '扩展不确定度U', value: 'urel', align: 'center', required: true, type: 'text' }, ]) // ==============================工业铂铜热电阻======================= const resistanceFranchiseList = ref<IDetailMeasureList[]>([]) // 允差表格数据 const resistanceResultList = ref([]) as any // 结果处理表格数据 const columns_resistance_franchise = ref([ // 允差表头 { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' }, { text: '标称温度', value: 'nominalTemperature', align: 'center', required: true, type: 'text' }, { text: '1', value: 'beforeFrictionStroke', align: 'center', required: true, width: '180', children: [ { text: '标准器示值(℃)', value: 'oneValue', align: 'center', required: true, width: '180', type: 'inputNumber' }, { text: '被检示值(Ω)', value: 'twoValue', align: 'center', required: true, width: '180', type: 'inputNumber' }, ], }, { text: '2', value: 'beforeFrictionStroke', align: 'center', width: '180', required: true, children: [ { text: '标准器示值(℃)', value: 'threeValue', align: 'center', required: true, width: '180', type: 'inputNumber' }, { text: '被检示值(Ω)', value: 'fourValue', align: 'center', required: true, width: '180', type: 'inputNumber' }, ], }, { text: '3', value: 'beforeFrictionStroke', align: 'center', width: '180', required: true, children: [ { text: '标准器示值(℃)', value: 'fiveValue', align: 'center', required: true, width: '180', type: 'inputNumber' }, { text: '被检示值(Ω)', value: 'sixValue', align: 'center', required: true, width: '180', type: 'inputNumber' }, ], }, { text: '4', value: 'beforeFrictionStroke', align: 'center', width: '180', required: true, children: [ { text: '标准器示值(℃)', value: 'sevenValue', align: 'center', required: true, width: '180', type: 'inputNumber' }, { text: '被检示值(Ω)', value: 'eightValue', align: 'center', required: true, width: '180', type: 'inputNumber' }, ], }, { text: '5', value: 'beforeFrictionStroke', align: 'center', width: '180', required: true, children: [ { text: '标准器示值(℃)', value: 'nineValue', align: 'center', required: true, width: '180', type: 'inputNumber' }, { text: '被检示值(Ω)', value: 'tenValue', align: 'center', required: true, width: '180', type: 'inputNumber' }, ], }, { text: '6', value: 'beforeFrictionStroke', align: 'center', width: '180', required: true, children: [ { text: '标准器示值(℃)', value: 'elevenValue', align: 'center', required: true, width: '180', type: 'inputNumber' }, { text: '被检示值(Ω)', value: 'twelveValue', align: 'center', required: true, width: '180', type: 'inputNumber' }, ], }, { text: '均值', value: 'beforeFrictionStroke', align: 'center', width: '180', required: true, children: [ { text: '标准器示值(℃)', value: 'thirteenValue', align: 'center', required: true, type: 'text' }, { text: '被检示值(Ω)', value: 'fourteenValue', align: 'center', required: true, type: 'text' }, ], }, ]) // 结果处理表格 const columns_resistance_result = ref([ // 结果处理表头 { text: '项目', value: 'itemTitleFront', align: 'center', required: true }, { text: '允差下限', value: 'allowErrorLower', align: 'center', required: true }, { text: '允差上限', value: 'allowErrorUpper', align: 'center', required: true }, { text: '测量值', value: 'measureValue', align: 'center', required: false }, ]) // -------------------------------------------获取详情信息-------------------------------------------------- // 获取页面详情信息 const fetchInfo = () => { const loading = ElLoading.service({ lock: true, background: 'rgba(255, 255, 255, 0.8)', }) getInfo({ id: infoId.value, belongStandardEquipment: itemFormData.value.belongStandardEquipment, // 我的任务跳转过来如果已经配置过检定项了,到编辑页面,且用一下三个字段替代传id请求详情 itemId: $route.query.itemId, // 检定项id orderId: $route.query.orderId, // 任务单id sampleId: $route.query.sampleId, // 被检设备id }).then((res) => { // 有关于检定项的数据 itemFormData.value.itemId = res.data.itemId // 检定项id itemFormData.value.itemCategoryName = res.data.itemCategoryName // 设备检定项分类名称 itemFormData.value.itemCategoryId = res.data.itemCategoryId ? res.data.itemCategoryId : itemFormData.value.itemCategoryId // 设备检定项分类名称id itemFormData.value.appearance = `${res.data.appearance}` // 外观(1/0) itemFormData.value.isShowAppearance = `${res.data.appearance}` !== '' // 是否展示外观 itemFormData.value.isShowInsulationResistance = `${res.data.insulationResistanceValue}` !== '' // 绝缘电阻输入数据--判断是否展示 itemFormData.value.insulationResistanceValue = res.data.insulationResistanceValue // 绝缘电阻值 itemFormData.value.isShowAngleAdjustErrort = `${res.data.angleAdjustError}` !== '' // 是否展示角度调整误差(可调整角度仪表) itemFormData.value.angleAdjustError = `${res.data.angleAdjustError}` // 角度调整误差(可调整角度仪表) itemFormData.value.remark = res.data.remark // 备注 // =======================================表单公共组件数据处理======================================================= useSolveFormData(res, templateFormAndTableRef.value) // ==================================检定数据======================================================================== if (itemFormData.value.itemCategoryName === '恒温槽') { thermostaticBathWaveList.value = res.data.measureDataResistanceThermometerList.filter((item: { dataType: string }) => `${item.dataType}` === '1') thermostaticBathEvenList.value = res.data.measureDataResistanceThermometerList.filter((item: { dataType: string }) => `${item.dataType}` === '2') thermostaticBathWaveList.value = thermostaticBathWaveList.value.map((i: any) => { i.editable = props.pageType !== 'detail'; return i }) thermostaticBathEvenList.value = thermostaticBathEvenList.value.map((i: any) => { i.editable = props.pageType !== 'detail'; return i }) } if (itemFormData.value.itemCategoryName === '双金属温度计') { bimetalThermometerList.value = res.data.measureDataResistanceThermometerList.map((i: any) => { i.params = '示值误差'; i.editable = props.pageType !== 'detail'; return i }) itemFormData.value.resultConclusion = caculateConclusion() ? '设备性能正常' : '设备性能异常' } if (itemFormData.value.itemCategoryName === '工业铂铜热电阻') { resistanceFranchiseList.value = res.data.measureDataResistanceThermometerList.filter((item: { dataCategory: string }) => `${item.dataCategory}` !== '2') resistanceFranchiseList.value = resistanceFranchiseList.value.map((item) => { return { ...item, editable: props.pageType !== 'detail', params: '允差', } }) resistanceResultList.value = res.data.measureDataResistanceThermometerList.filter((item: { dataCategory: string }) => `${item.dataCategory}` === '2') itemFormData.value.resultConclusion = caculateConclusion() ? '合格' : '不合格' resistanceResultList.value = resistanceResultList.value.map((item: { item: string; rValue: string }, index: number) => { return { ...item, editable: props.pageType !== 'detail', itemTitleFront: item.item === '△α' ? '△α/10<sup>-6</sup>℃<sup>-1</sup>' : item.item, // 项目 // nominalValue: originResistanceResultList.value[index].nominalValue, // α标称值(字典value) // rValue: originResistanceResultList.value[index].rValue, // R值 // drDt: originResistanceResultList.value[index].drDt, // dR/dt // rTp: originResistanceResultList.value[index].rTp, // rtp // wS: originResistanceResultList.value[index].wS, // rtpwS // dwstDt: originResistanceResultList.value[index].dwstDt, // dWst/dt } }) itemFormData.value.rankLevel = resistanceResultList.value.length ? resistanceResultList.value[0].rankLevel : '' } infoId.value = res.data.id emits('giveInfoId', infoId.value) loading.close() }) } // 恒温槽均匀性初始化数据使用 const thermostaticBathEvenMap = { 1: 'A', 2: 'B', 3: 'C', 4: 'D', 5: 'E', 6: 'F', 7: 'G', 0: 'H', } as any // 初始化输入数据 const initInputData = (data: any) => { if (itemFormData.value.itemCategoryName === '恒温槽') { for (let i = 1; i <= 16; i++) { // 恒温槽波动性 thermostaticBathWaveList.value.push({ id: '', dataType: '1', // 用于区分两个表格 upperLowerPoint: i < 9 ? `${data[0].lowerIndex}` : `${data[0].upperIndex}`, // 指标上限和下限 unit: data[0].unit, // 单位 oneValue: 0, twoValue: 0, threeValue: 0, fourValue: 0, fiveValue: 0, sixValue: 0, sevenValue: 0, eightValue: 0, nineValue: 0, tenValue: 0, elevenValue: 0, twelveValue: 0, thirteenValue: 0, fourteenValue: 0, fifteenValue: 0, maxValue: '', // 最大值 minValue: '', // 最小值 volatility: '', // 波动性 editable: props.pageType !== 'detail', }) // 恒温槽均匀性 thermostaticBathEvenList.value.push({ id: '', dataType: '2', // 用于区分两个表格 upperLowerPoint: i < 9 ? `${data[0].lowerIndex}` : `${data[0].upperIndex}`, // 指标上限和下限 unit: data[0].unit, // 单位 location: thermostaticBathEvenMap[i % 8], // 位置 oneValue: 0, // ROA1 twoValue: 0, // RA1 threeValue: 0, // ROA2 fourValue: 0, // RA2 fiveValue: 0, // ROA3 sixValue: 0, // RA3 sevenValue: 0, // ROA4 eightValue: 0, // RA4 nineValue: 0, // ROA均值 tenValue: 0, // RA均值 upperTemperatureDifferent: '', // 上水平面温差 lowerTemperatureDifferent: '', // 下水平面温差 maxHorizontalTemperatureDifferent: '', // 水平最大温差 maxWorkTemperatureDifferent: '', // 工作区域最大温差 editable: props.pageType !== 'detail', }) } } else if (itemFormData.value.itemCategoryName === '双金属温度计') { bimetalThermometerList.value = data.map((item: IDetailMeasureList) => { return { id: '', params: '示值误差', // 检定项目 dataType: '1', // 用于区分两个表格 calibratedPoint: item.calibratedPoint! + item.unit, // 校准点+单位 indicatingValueForwardStroke: 0, // 标准器示值正行程 indicatingValueReverseStroke: 0, // 标准器示值反行程 measureIndicationValueForwardStroke: 0, // 被检示值正行程 measureIndicationValueReverseStroke: 0, // 被检示值反行程 indicatingErrorForwardStroke: 0, // 示值误差正行程 indicatingErrorReverseStroke: 0, // 示值误差反行程 maximumError: item.maximumError, // 最大允许误差 urel: item.urel, // 扩展不确定度U editable: props.pageType !== 'detail', } }) } else { // 工业铂铜热电阻 // 允差 resistanceFranchiseList.value = data.map((item: IDetailMeasureList) => { return { id: '', params: '允差', dataType: '1', // 用于区分两个表格 dataCategory: '1', nominalTemperature: item.nominalTemperature, // 标称温度 oneValue: undefined, // 1 标准器示值 twoValue: undefined, // 1 被检示值 threeValue: undefined, // 标准器示值2 fourValue: undefined, // 被检示值2 fiveValue: undefined, // 标准器示值3 sixValue: undefined, // 被检示值3 sevenValue: undefined, // 标准器示值4 eightValue: undefined, // 被检示值4 nineValue: undefined, // 标准器示值5 tenValue: undefined, // 被检示值5 elevenValue: undefined, // 标准器示值6 twelveValue: undefined, // 被检示值6 thirteenValue: undefined, // 标准器示值均值 fourteenValue: undefined, // 被检示值均值 editable: props.pageType !== 'detail', } }) // 结果表格 resistanceResultList.value = [ { id: '', dataId: '', dataCategory: '2', dataType: '1', item: 'R\'(0℃)/Ω', // 项目 itemTitleFront: 'R\'(0℃)/Ω', // 项目 allowErrorLower: data[0].allowErrorLower, // 允差下限 data[0] 是 0℃ allowErrorUpper: data[0].allowErrorUpper, // 允差上限 data[0] 是 0℃ measureValue: '', // 测量值 rankLevel: itemFormData.value.rankLevel, // 级别 nominalValue: data[0].nominalValue, // α标称值(字典value) rValue: data[0].rValue, // R值 drDt: data[0].drDt, // dR/dt rTp: data[0].rTp, // rtp wS: data[0].wS, // rtpwS dwstDt: data[0].dwstDt, // dWst/dt }, { id: '', dataId: '', dataCategory: '2', dataType: '1', item: 'R\'(100℃)/Ω', // 项目 itemTitleFront: 'R\'(100℃)/Ω', // 项目 allowErrorLower: data[1].allowErrorLower, // 允差下限 data[1] 是 100℃ allowErrorUpper: data[1].allowErrorUpper, // 允差上限 data[1] 是 100℃ measureValue: '', // 测量值 rankLevel: itemFormData.value.rankLevel, // 级别 nominalValue: data[0].nominalValue, // α标称值(字典value) rValue: data[1].rValue, // R值 drDt: data[1].drDt, // dR/dt rTp: data[1].rTp, // rtp wS: data[1].wS, // rtpwS dwstDt: data[1].dwstDt, // dWst/dt }, { id: '', dataId: '', dataCategory: '2', dataType: '1', item: 'α', // 项目 itemTitleFront: 'α', // 项目 allowErrorLower: '/', // 允差下限 allowErrorUpper: '/', // 允差上限 measureValue: '', // 测量值 rankLevel: itemFormData.value.rankLevel, // 级别 nominalValue: data[0].nominalValue, // α标称值(字典value) drDt: data[0].drDt, // dR/dt rTp: data[0].rTp, // rtp wS: data[0].wS, // rtpwS dwstDt: data[0].dwstDt, // dWst/dt }, { id: '', dataId: '', dataCategory: '2', dataType: '1', item: '△t(0℃)/℃', // 项目 itemTitleFront: '△t(0℃)/℃', // 项目 allowErrorLower: '/', // 允差下限 allowErrorUpper: '/', // 允差上限 measureValue: '', // 测量值 rankLevel: itemFormData.value.rankLevel, // 级别 nominalValue: data[0].nominalValue, // α标称值(字典value) drDt: data[0].drDt, // dR/dt rTp: data[0].rTp, // rtp wS: data[0].wS, // rtpwS dwstDt: data[0].dwstDt, // dWst/dt }, { id: '', dataId: '', dataCategory: '2', dataType: '1', item: '△t(100℃)/℃', // 项目 itemTitleFront: '△t(100℃)/℃', // 项目 allowErrorLower: '/', // 允差下限 allowErrorUpper: '/', // 允差上限 measureValue: '', // 测量值 rankLevel: itemFormData.value.rankLevel, // 级别 nominalValue: data[0].nominalValue, // α标称值(字典value) drDt: data[1].drDt, // dR/dt rTp: data[1].rTp, // rtp wS: data[1].wS, // rtpwS dwstDt: data[1].dwstDt, // dWst/dt }, { id: '', dataId: '', dataCategory: '2', dataType: '1', item: '△α', itemTitleFront: '△α/10<sup>-6</sup>℃<sup>-1</sup>', // 项目 allowErrorLower: data[1].allowErrorLower, // 允差下限 data[1] 是 100℃ allowErrorUpper: data[1].allowErrorUpper, // 允差上限 data[1] 是 100℃ measureValue: '', // 测量值 rankLevel: itemFormData.value.rankLevel, // 级别 nominalValue: data[0].nominalValue, // α标称值(字典value) drDt: data[0].drDt, // dR/dt rTp: data[0].rTp, // rtp wS: data[0].wS, // rtpwS dwstDt: data[0].dwstDt, // dWst/dt }, ] } } /** * 新增的时候获取检定项输入数据(获取检定项分类详情) * @param itemId 检定项id * @param itemCategoryName 检定项分类名字 * @param belongStandardEquipment 检校标准装置字典 */ const fetchItemInfo = async (itemId: string, itemCategoryName: string, belongStandardEquipment = '') => { const params = { id: itemId, itemCategoryName, // 检定项分类名字 belongStandardEquipment, // 检校标准装置字典code } const res = await getItemInfo(params) itemFormData.value.isShowAppearance = `${res.data.appearanceFunctionCheck}` === '1' // 外观(1/0) itemFormData.value.isShowInsulationResistance = `${res.data.insulateResistance}` === '1' // 绝缘电阻输入数据 itemFormData.value.isShowAngleAdjustErrort = `${res.data.angleAdjustError}` === '1' // 角度调整误差(可调整角度仪表) itemFormData.value.rankLevel = res.data.measureItemDataResistanceThermometerList[0].level // 级别 initInputData(res.data.measureItemDataResistanceThermometerList) } // ----------------------------------------点击保存时校验--------------------------------------- // 校验 const checkout = () => { if (itemFormData.value.itemCategoryName === '恒温槽') { if (!thermostaticBathWaveList.value.length) { ElMessage.warning('波动性测试不能为空') return false } if (!thermostaticBathEvenList.value.length) { ElMessage.warning('均匀性测试不能为空') return false } } else { if (itemFormData.value.itemCategoryName !== '恒温槽' && `${itemFormData.value.insulationResistanceValue}` === '') { ElMessage.warning('绝缘电阻不能为空') return false } if (itemFormData.value.itemCategoryName === '双金属温度计' && !bimetalThermometerList.value.length) { ElMessage.warning('示值误差不能为空') return false } if (itemFormData.value.itemCategoryName === '工业铂铜热电阻' && !resistanceFranchiseList.value.length) { ElMessage.warning('允差不能为空') return false } } return true } // -----------------------------------------生成结果处理---------------------------------------- // 计算双金属温度计、工业铂铜热电阻结论 function caculateConclusion() { if (itemFormData.value.itemCategoryName === '双金属温度计') { // (如果外观检查合格,示值误差均在最大允许误差内,补充设备性能正常;否则为设备性能异常) return bimetalThermometerList.value.every((item: IDetailMeasureList) => { const tempMaximumError = Number(`${item.maximumError}`.slice(1)) // 去掉正负号的最大允许误差 return Math.abs(Number(item.indicatingErrorForwardStroke)) < Math.abs(tempMaximumError) && Math.abs(Number(item.indicatingErrorReverseStroke)) < Math.abs(tempMaximumError) && `${itemFormData.value.appearance}` === '1' }) } if (itemFormData.value.itemCategoryName === '工业铂铜热电阻') { // 根据公式计算,如果外观检查合格、测量值在允差下限、允差上限内,则自动补充合格,否则为不合格 return resistanceResultList.value.every((item: IDetailMeasureList) => { if (item.allowErrorLower !== '/' && item.allowErrorUpper !== '/') { return Number(item.measureValue) > Number(item.allowErrorLower) && Number(item.measureValue) < Number(item.allowErrorUpper) && `${itemFormData.value.appearance}` === '1' } else { return true } }) } } /** * 点击生成结果处理 * @param type top上面表格 bottom下面表格 */ function createResult(type: 'top' | 'bottom') { let list = [] as IDetailMeasureList[] let columns = [] as any let title = '' // 提醒标题 if (itemFormData.value.itemCategoryName === '恒温槽') { list = type === 'top' ? thermostaticBathWaveList.value : thermostaticBathEvenList.value columns = type === 'top' ? columns_thermostatic_bath_wave.value : columns_thermostatic_bath_even.value title = type === 'top' ? '波动性测试' : '均匀性测试' } else if (itemFormData.value.itemCategoryName === '双金属温度计') { list = bimetalThermometerList.value columns = columns_bimetal_thermometer.value } else if (itemFormData.value.itemCategoryName === '工业铂铜热电阻') { list = type === 'top' ? resistanceFranchiseList.value : resistanceResultList.value title = type === 'top' ? '允差' : '结果处理' columns = type === 'top' ? columns_resistance_franchise.value : columns_resistance_result.value } if (!list.length) { ElMessage.warning('没有检定项数据,无法生成结果') return false } if (!useCheckList(list, columns, title)) { return false } tableTop.value = type === 'top' tableBottom.value = type === 'bottom' const params = { belongStandardEquipment: itemFormData.value.belongStandardEquipment, // 检校标准装置 itemCategoryName: itemFormData.value.itemCategoryName, // 检定项分类名称 measureDataResistanceThermometerList: list, } calculateHandle(params).then((res) => { if (res.data && res.data.length) { res.data.map((item: { editable: boolean }) => { item.editable = props.pageType !== 'detail'; return item }) if (type === 'top') { switch (itemFormData.value.itemCategoryName) { case '恒温槽': thermostaticBathWaveList.value = res.data break case '双金属温度计': bimetalThermometerList.value = res.data.map((item: { params: string }) => { item.params = '示值误差'; return item }) itemFormData.value.resultConclusion = caculateConclusion() ? '设备性能正常' : '设备性能异常' break case '工业铂铜热电阻': resistanceFranchiseList.value = res.data.map((item: { params: string }) => { item.params = '允差'; return item }) break default: break } } else { switch (itemFormData.value.itemCategoryName) { case '恒温槽': thermostaticBathEvenList.value = res.data break case '工业铂铜热电阻': resistanceResultList.value = res.data.map((item: { item: string }) => { return { ...item, itemTitleFront: item.item === '△α' ? '△α/10<sup>-6</sup>℃<sup>-1</sup>' : item.item, // 项目 } }) itemFormData.value.resultConclusion = caculateConclusion() ? '合格' : '不合格' break default: break } } } tableTop.value = false tableBottom.value = false // emits('changePageType', 'detail') }).catch(() => { tableTop.value = false; tableBottom.value = false }) } // ------------------------------------------钩子---------------------------------------------- watch(() => props.infoId, (newValue) => { if (newValue) { infoId.value = newValue } }, { immediate: true }) watch(() => props.pageType, (newValue) => { if (newValue) { if (itemFormData.value.itemCategoryName === '恒温槽') { thermostaticBathWaveList.value = thermostaticBathWaveList.value.map((i: any) => { i.editable = props.pageType !== 'detail'; return i }) thermostaticBathEvenList.value = thermostaticBathEvenList.value.map((i: any) => { i.editable = props.pageType !== 'detail'; return i }) } if (itemFormData.value.itemCategoryName === '双金属温度计') { bimetalThermometerList.value = bimetalThermometerList.value.map((i: any) => { i.params = '示值误差'; i.editable = props.pageType !== 'detail'; return i }) } if (itemFormData.value.itemCategoryName === '工业铂铜热电阻') { resistanceFranchiseList.value = resistanceFranchiseList.value.map((i: any) => { i.params = '允差'; i.editable = props.pageType !== 'detail'; return i }) resistanceResultList.value = resistanceResultList.value.map((i: any) => { i.editable = props.pageType !== 'detail'; return i }) } } }) watch(() => current.value, (val) => { console.log('监听双金属温度计', val) console.log(bimetalThermometerList.value) }, { immediate: true }) onMounted(() => { itemFormData.value.itemCategoryName = $route.query.itemCategoryName as string// 设备检定项分类名称 itemFormData.value.itemCategoryId = $route.query.itemCategoryId as string// 设备检定项分类名称id itemFormData.value.belongStandardEquipment = $route.query.belongStandardEquipment as string// 标准装置code itemFormData.value.belongStandardEquipmentName = $route.query.belongStandardEquipmentName as string// 标准装置名称 if (props.pageType === 'add') { // 从我的任务跳转过来(新增) itemFormData.value.itemId = $route.query.itemId as string// 检定项id // 查输入值(查检定项管理的详情) fetchItemInfo($route.query.itemId! as string, $route.query.itemCategoryName! as string, $route.query.belongStandardEquipment as string) } else { // 查输入值(查检定项管理的详情) // fetchItemInfo($route.query.itemId! as string, $route.query.itemCategoryName! as string, $route.query.belongStandardEquipment as string, false).then(() => { fetchInfo() // }) } }) defineExpose({ fetchInfo, checkout, itemFormData, templateFormAndTableRef, thermostaticBathWaveList, thermostaticBathEvenList, bimetalThermometerList, resistanceFranchiseList, resistanceResultList }) </script> <template> <div class="measure-data-template-detail"> <template-form-and-table ref="templateFormAndTableRef" :page-type="props.pageType" /> <!-- 标签 --> <detail-block :title="props.pageType !== 'detail' ? '检定数据' : ''" :class="props.pageType === 'detail' ? 'setBottom' : ''"> <el-radio-group v-if="props.pageType === 'detail'" v-model="current"> <el-radio-button v-for="item in radioMenus" :key="item.value" :label="item.value"> {{ item.name }} </el-radio-button> </el-radio-group> <el-form v-if="current === 'measure-data'" ref="formRef" :model="itemFormData" label-width="140" label-position="right" style="margin-top: 20px;" > <el-row> <!-- 外观 --> <el-col v-if="itemFormData.isShowAppearance" :span="8"> <el-form-item label="外观检查:" prop="appearance"> <el-select v-model="itemFormData.appearance" :disabled="props.pageType === 'detail'" class="full-width-input"> <el-option v-for="i in conclusionList" :key="i.value" :label="i.name" :value="i.value" /> </el-select> </el-form-item> </el-col> <el-col v-if="itemFormData.itemCategoryName !== '恒温槽' && itemFormData.isShowInsulationResistance" :span="8"> <el-form-item label="绝缘电阻(MΩ):" prop="insulationResistanceValue"> <el-input v-model="itemFormData.insulationResistanceValue" :disabled="props.pageType === 'detail'" :placeholder="props.pageType === 'detail' ? ' ' : '请输入绝缘电阻'" /> </el-form-item> </el-col> <el-col v-if="itemFormData.itemCategoryName === '双金属温度计' && itemFormData.isShowAngleAdjustErrort" :span="8"> <el-form-item label-width="250px" label="角度调整误差(可调整角度仪表):" prop="angleAdjustError"> <el-select v-model="itemFormData.angleAdjustError" :disabled="props.pageType === 'detail'" class="full-width-input"> <el-option v-for="i in [{ value: '1', name: '不可用' }]" :key="i.value" :label="i.name" :value="i.value" /> </el-select> </el-form-item> </el-col> </el-row> </el-form> <!-- 恒温槽 --> <detail-block v-if="current === 'measure-data' && itemFormData.itemCategoryName === '恒温槽'" title="波动性测试" style="margin-top: 0;padding: 0;"> <template v-if="props.pageType !== 'detail'" #btns> <el-button type="primary" @click="createResult('top')"> 计算结果 </el-button> </template> <multi-table v-loading="tableTop" :table-data="thermostaticBathWaveList" :table-header="columns_thermostatic_bath_wave" :need-index="true" max-height="400" :merge-rows="['upperLowerPoint', 'unit']" /> </detail-block> <detail-block v-if="current === 'measure-data' && itemFormData.itemCategoryName === '恒温槽'" title="均匀性测试" style="margin-top: 0;padding: 0;"> <template v-if="props.pageType !== 'detail'" #btns> <el-button type="primary" @click="createResult('bottom')"> 计算结果 </el-button> </template> <multi-table v-loading="tableBottom" :table-data="thermostaticBathEvenList" :table-header="columns_thermostatic_bath_even" :need-index="true" max-height="400" :merge-rows="['upperLowerPoint', 'unit']" /> </detail-block> <!-- 双金属温度计 --> <detail-block v-if="current === 'measure-data' && itemFormData.itemCategoryName === '双金属温度计'" title="示值误差" style="margin-top: 0;padding: 0;"> <template v-if="props.pageType !== 'detail'" #btns> <el-button type="primary" @click="createResult('top')"> 计算结果 </el-button> </template> <multi-table v-loading="tableTop" :table-data="bimetalThermometerList" :table-header="columns_bimetal_thermometer" :merge-rows="[]" :need-index="true" /> </detail-block> <!-- 工业铂铜热电阻 --> <detail-block v-if="current === 'measure-data' && itemFormData.itemCategoryName === '工业铂铜热电阻'" title="" style="margin-top: 0;padding: 0;"> <div style="width: 100%;margin-bottom: 16px;display: flex;justify-content: space-between;align-items: center;"> <div> <span style="font-size: 16px;padding-left: 10px;">允差</span> <span style="margin-left: 60px;">级别: {{ itemFormData.rankLevel }}</span> </div> <div> <el-button type="primary" @click="createResult('top')"> 计算结果 </el-button> </div> </div> <multi-table v-loading="tableTop" :table-data="resistanceFranchiseList" :table-header="columns_resistance_franchise" :merge-rows="[]" :need-index="true" /> </detail-block> <detail-block v-if="current === 'measure-data' && itemFormData.itemCategoryName === '工业铂铜热电阻'" title="结果处理" style="margin-top: 0;padding: 0;"> <template v-if="props.pageType !== 'detail'" #btns> <el-button type="primary" @click="createResult('bottom')"> 计算结果 </el-button> </template> <el-table ref="tableRef" v-loading="tableBottom" :data="resistanceResultList" border style="width: 100%;" > <el-table-column align="center" label="序号" width="80" type="index" /> <el-table-column v-for="item in columns_resistance_result" :key="item.value" :prop="item.value" :label="item.text" align="center" > <template #header> <span v-show="item.required" style="color: red;">*</span><span>{{ item.text }}</span> </template> <template #default="scope"> <div v-html="scope.row[item.value]" /> </template> </el-table-column> </el-table> </detail-block> <el-form v-if="current === 'measure-data'" ref="formRef" :model="itemFormData" label-width="140" label-position="right" style="margin-top: 20px;" > <el-row> <!-- 结论 --> <el-col v-if="itemFormData.itemCategoryName !== '恒温槽'" :span="12"> <el-form-item label="结论:" prop="resultConclusion"> <el-input v-model="itemFormData.resultConclusion" autosize type="textarea" disabled :placeholder="props.pageType === 'detail' ? ' ' : '结论'" /> </el-form-item> </el-col> <!-- 备注 --> <el-col :span="12"> <el-form-item label="备注:" prop="remark"> <el-input v-model="itemFormData.remark" autosize type="textarea" :disabled="props.pageType === 'detail'" :placeholder="props.pageType === 'detail' ? ' ' : '请输入备注'" /> </el-form-item> </el-col> </el-row> </el-form> <!-- 历史修改记录 --> <change-record v-if="props.pageType === 'detail' && current === 'change-record'" :info-id="infoId" /> </detail-block> </div> </template> <style lang="scss" scoped> .setBottom { padding-bottom: 20px; } </style> <style lang="scss"> .measure-data-template-detail { .el-radio__label { display: block !important; } } </style>