<!-- 核查数据管理详情--核查项---第15套:小功率标准装置 --> <script lang="ts" setup name="checkDataDetail"> import { ref, watch } from 'vue' import { ElLoading, ElMessage, rowContextKey } from 'element-plus' import saveCheckRecord from '../../dialog/saveCheckRecord.vue' import { clearDateValue, handleDetailTableTableHead, handleSaveDateParams, solveHistoryIndicationTableData } from '../useStabilityCaculate' import type { IList } from './fifteenth-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 { useCheckList } from '@/commonMethods/useCheckList' 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 { useGroup } from '@/commonMethods/useGroup' import { useRound } from '@/commonMethods/useRound' import { useScientificNotation } from '@/commonMethods/useScientificNotation' const props = defineProps({ selectStandardId: { // 选择的标准装置id type: String, }, pageType: { // 页面类型 type: String, }, checkDate: { // 核查日期 type: String, }, }) const emits = defineEmits(['isConfigCheck']) const user = useUserStore() // 用户信息 const $router = useRouter() // 关闭页面使用 const $route = useRoute() // 路由参数 const infoId = ref('') const belongStandardEquipment = ref('15') const itemCategoryId = ref('') // 核查项分类id const itemCategoryName = ref('') // 核查项分类名称 const form = ref({ qualified: '', // 稳定性考核是否合格 }) const equipmentId = ref('') // 设备id const dateArrStability = ref<string[]>([]) // 稳定性日期数组 const currentDate = ref('') // 要查询历史稳定性的日期 // ----------------------------------路由参数------------------------------------------------ if ($route.params && $route.params.type) { if ($route.params.id) { infoId.value = $route.params.id as string } } // ----------------------------------------核查数据---------------------------------------------- const radioMenus = ref([ // 标签内容 { name: '重复性', value: 'repeatability' }, { name: '稳定性', value: 'stability' }, ]) const current = ref('repeatability') // 选择的tab 默认基本信息 const columns_repeatability = ref<TableColumn[]>([ // 重复性表头 { text: '频率', value: 'frequency', align: 'center', required: true, type: 'text' }, { text: '频率点单位', value: 'frequencyUnit', align: 'center', required: true, type: 'text' }, { text: 'Kc/%', value: 'kc', align: 'center', required: true, type: 'text' }, { text: '第一次', value: '1', align: 'center', required: false, width: '180', children: [ { text: 'Pcu/mW', value: 'pcuValueOne', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4, reg: (pcuValueOne: any) => { return `${pcuValueOne}` !== '0' }, belongStandardEquipment: '15', message: '第一次' }, { text: '示数Pbu/mW', value: 'pbuValueOne', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 3, belongStandardEquipment: '15', message: '第一次' }, { text: '校准因子Ku/%', value: 'kuValueOne', align: 'center', required: false, type: 'text' }, ], }, { text: '第二次', value: '2', align: 'center', required: false, width: '180', children: [ { text: 'Pcu/mW', value: 'pcuValueTwo', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4, reg: (pcuValueTwo: any) => { return `${pcuValueTwo}` !== '0' }, belongStandardEquipment: '15', message: '第二次' }, { text: '示数Pbu/mW', value: 'pbuValueTwo', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 3, belongStandardEquipment: '15', message: '第二次' }, { text: '校准因子Ku/%', value: 'kuValueTwo', align: 'center', required: false, type: 'text' }, ], }, { text: '第三次', value: '3', align: 'center', required: false, width: '180', children: [ { text: 'Pcu/mW', value: 'pcuValueThree', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4, reg: (pcuValueThree: any) => { return `${pcuValueThree}` !== '0' }, belongStandardEquipment: '15', message: '第三次' }, { text: '示数Pbu/mW', value: 'pbuValueThree', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 3, belongStandardEquipment: '15', message: '第三次' }, { text: '校准因子Ku/%', value: 'kuValueThree', align: 'center', required: false, type: 'text' }, ], }, { text: '第四次', value: '4', align: 'center', required: false, width: '180', children: [ { text: 'Pcu/mW', value: 'pcuValueFour', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4, reg: (pcuValueFour: any) => { return `${pcuValueFour}` !== '0' }, belongStandardEquipment: '15', message: '第四次' }, { text: '示数Pbu/mW', value: 'pbuValueFour', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 3, belongStandardEquipment: '15', message: '第四次' }, { text: '校准因子Ku/%', value: 'kuValueFour', align: 'center', required: false, type: 'text' }, ], }, { text: '第五次', value: '5', align: 'center', required: false, width: '180', children: [ { text: 'Pcu/mW', value: 'pcuValueFive', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4, reg: (pcuValueFive: any) => { return `${pcuValueFive}` !== '0' }, belongStandardEquipment: '15', message: '第五次' }, { text: '示数Pbu/mW', value: 'pbuValueFive', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 3, belongStandardEquipment: '15', message: '第五次' }, { text: '校准因子Ku/%', value: 'kuValueFive', align: 'center', required: false, type: 'text' }, ], }, { text: '第六次', value: '6', align: 'center', required: false, width: '180', children: [ { text: 'Pcu/mW', value: 'pcuValueSix', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4, reg: (pcuValueSix: any) => { return `${pcuValueSix}` !== '0' }, belongStandardEquipment: '15', message: '第六次' }, { text: '示数Pbu/mW', value: 'pbuValueSix', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 3, belongStandardEquipment: '15', message: '第六次' }, { text: '校准因子Ku/%', value: 'kuValueSix', align: 'center', required: false, type: 'text' }, ], }, { text: '第七次', value: '7', align: 'center', required: false, width: '180', children: [ { text: 'Pcu/mW', value: 'pcuValueSeven', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4, reg: (pcuValueSeven: any) => { return `${pcuValueSeven}` !== '0' }, belongStandardEquipment: '15', message: '第七次' }, { text: '示数Pbu/mW', value: 'pbuValueSeven', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 3, belongStandardEquipment: '15', message: '第七次' }, { text: '校准因子Ku/%', value: 'kuValueSeven', align: 'center', required: false, type: 'text' }, ], }, { text: '第八次', value: '8', align: 'center', required: false, width: '180', children: [ { text: 'Pcu/mW', value: 'pcuValueEight', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4, reg: (pcuValueEight: any) => { return `${pcuValueEight}` !== '0' }, belongStandardEquipment: '15', message: '第八次' }, { text: '示数Pbu/mW', value: 'pbuValueEight', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 3, belongStandardEquipment: '15', message: '第八次' }, { text: '校准因子Ku/%', value: 'kuValueEight', align: 'center', required: false, type: 'text' }, ], }, { text: '第九次', value: '9', align: 'center', required: false, width: '180', children: [ { text: 'Pcu/mW', value: 'pcuValueNine', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4, reg: (pcuValueNine: any) => { return `${pcuValueNine}` !== '0' }, belongStandardEquipment: '15', message: '第九次' }, { text: '示数Pbu/mW', value: 'pbuValueNine', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 3, belongStandardEquipment: '15', message: '第九次' }, { text: '校准因子Ku/%', value: 'kuValueNine', align: 'center', required: false, type: 'text' }, ], }, { text: '第十次', value: '10', align: 'center', required: false, width: '160', children: [ { text: 'Pcu/mW', value: 'pcuValueTen', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 4, reg: (pcuValueTen: any) => { return `${pcuValueTen}` !== '0' }, belongStandardEquipment: '15', message: '第十次' }, { text: '示数Pbu/mW', value: 'pbuValueTen', align: 'center', required: true, width: '180', type: 'inputNumber', precision: 3, belongStandardEquipment: '15', message: '第十次' }, { text: '校准因子Ku/%', value: 'kuValueTen', align: 'center', required: false, type: 'text' }, ], }, { text: '平均值(校准因子Ku/%)', value: 'averageValue', align: 'center', required: false, type: 'text' }, { text: '重复性S(x)', value: 'standardDeviation', align: 'center', required: false, type: 'text' }, ]) const columns_stability = ref<TableColumn[]>([ // 稳定性表头 { text: '频率', value: 'frequency', align: 'center', required: true, type: 'text' }, { text: '频率点单位', value: 'frequencyUnit', align: 'center', required: true, type: 'text' }, { text: '校准因子Ku/%(平均值)', value: '-', align: 'center', required: false, width: '180', children: [ { width: '180', text: '-', value: 'kuValueOne', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueTwo', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueThree', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueFour', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueFive', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueSix', align: 'center', required: false, type: 'text', customHeader: true }, ], }, { text: '平均值', value: 'averageValue', align: 'center', required: false, type: 'text' }, { text: '稳定性', value: 'stability', align: 'center', required: false, type: 'text' }, { text: 'U(k=2)', value: 'urel', align: 'center', required: false, type: 'text' }, { text: '结论', value: 'lessThan', align: 'center', required: false, type: 'text' }, ]) const columns_stability_checkDate = ref<TableColumn[]>([ // 稳定性表头 { text: '频率', value: 'params', align: 'center', required: true, type: 'text' }, { text: '频率点单位', value: 'checkPointDefineFront', align: 'center', required: true, type: 'text' }, { text: '校准因子Ku/%(平均值)', value: '-', align: 'center', required: false, width: '180', children: [ { width: '180', text: '-', value: 'kuValueOne', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueTwo', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueThree', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueFour', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueFive', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueSix', align: 'center', required: false, type: 'text', customHeader: true }, ], }, { text: '平均值', value: 'averageValue', align: 'center', required: false, type: 'text' }, { text: '稳定性', value: 'stability', align: 'center', required: false, type: 'text' }, { text: 'U(k=2)', value: 'urel', align: 'center', required: false, type: 'text' }, { text: '结论', value: 'lessThan', align: 'center', required: false, type: 'text' }, ]) const listRepeatability = ref<IList[]>([]) // 重复性 const listRepeatabilityLoading = ref(false) // 重复性Loading const listRepeatabilityCheckDate = ref<IList[]>([]) // 重复性历史日期数据 const listStability = ref<IList[]>([]) // 稳定性 const listStabilityLoading = ref(false) // 稳定性Loading const listStabilityCheckDate = ref<IList[]>([]) // 稳定性历史日期数据 const originList = ref<IList[]>([]) // 重复性 // 获取配置详情 async function fetchCheckItemDetail(equipmentId: string, belongStandardEquipmentParam: string, itemCategoryIdParam: string, itemCategoryNameParam: string, solveData = true) { 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, // 核查项分类名称 } const res = await getCheckItemDetail(params) loading.close() if (!res.data) { emits('isConfigCheck', false) originList.value = [] listRepeatability.value = [] // 稳定性 listStability.value = [] } else { emits('isConfigCheck', true) originList.value = res.data.checkItemDataLowerPowerList if (solveData) { handleData(res.data.checkItemDataLowerPowerList) fetchHistoryIndication() // 重新拉取稳定性 } } } // 初始化数据(查询配置检定项) function handleData(list: any, type = 'edit') { listRepeatability.value = list // 重复性 listRepeatability.value = listRepeatability.value.map((e: any) => { return { editable: type === 'edit', dataId: e.id, // 核查数据管理基础信息表id id: '', // id,更新/删除使用参数 checkType: '重复性', dataType: '1', params: e.params, // 核查项目 frequency: e.frequency, // 频率 frequencyUnit: e.frequencyUnit, // 频率单位(直接存字典value) kc: e.kc, // kc averageValue: '', // 平均值 standardDeviation: '', // 重复性 urel: e.urel, // u(k=2) pbuValueOne: undefined, // Pbu1/mW pbuValueTwo: undefined, // Pbu2/mW pbuValueThree: undefined, // Pbu3/mW pbuValueFour: undefined, // Pbu4/mW pbuValueFive: undefined, // Pbu5/mW pbuValueSix: undefined, // Pbu6/mW pbuValueSeven: undefined, // Pbu7/mW pbuValueEight: undefined, // Pbu8/mW pbuValueNine: undefined, // Pbu9/mW pbuValueTen: undefined, // Pbu10/mW pcuValueOne: undefined, // Pcu1/mW pcuValueTwo: undefined, // Pcu2/mW pcuValueThree: undefined, // Pcu3/mW pcuValueFour: undefined, // Pcu4/mW pcuValueFive: undefined, // Pcu5/mW pcuValueSix: undefined, // Pcu6/mW pcuValueSeven: undefined, // Pcu7/mW pcuValueEight: undefined, // Pcu8/mW pcuValueNine: undefined, // Pcu9/mW pcuValueTen: undefined, // Pcu10/mW } }) as any // 稳定性 listStability.value = listRepeatability.value.map((e: any) => { return { editable: props.pageType !== 'detail', dataId: e.dataId, // 核查数据管理基础信息表id id: '', // id,更新/删除使用参数 params: e.params, // 核查项目 dataType: '1', kc: e.kc, // kc frequency: e.frequency, // 频率 frequencyUnit: e.frequencyUnit, // 频率单位(直接存字典value) unit: e.unit, // 单位(直接存字典value) checkType: '稳定性', urel: e.urel, // u(k=2) averageValue: '', // 平均值 stability: '', // 稳定性 lessThan: '', // 结论 } }) as any } // 点击计算结果 const createResult = () => { let checkDataLowPowerListParams = [] as any if (current.value === 'stability') { // 计算稳定性先校验重复性 if (!checkList()) { return false } checkDataLowPowerListParams = listStability.value listStabilityLoading.value = true // 频率-稳定性 } if (current.value === 'repeatability') { if (!useCheckList(listRepeatability.value, columns_repeatability.value, '重复性表格')) { return false } checkDataLowPowerListParams = listRepeatability.value listRepeatabilityLoading.value = true } const params = { belongStandardEquipment: belongStandardEquipment.value, // 检校标准装置 checkDataLowPowerList: checkDataLowPowerListParams.map((item: { lessThan: string }) => { return { ...item, lessThan: '', qualified: '', } }), itemCategoryId: itemCategoryId.value, // 核查项分类id itemCategoryName: itemCategoryName.value, // 核查项分类id } calculateHandle(params).then((res) => { const result = res.data.map((item: any) => { return { ...item, editable: props.pageType !== 'detail', standardDeviation: useScientificNotation(item.standardDeviation), stability: useScientificNotation(item.stability), } }) if (current.value === 'repeatability') { // 重复性 listRepeatability.value = result // 填充稳定性最后一列的日期和数值 listStability.value = listStability.value.map((item, index: number) => { return { ...item, kuValueSix: listRepeatability.value[index].averageValue, // 测量差值 testValueSixDate: props.checkDate, // 核查读数6日期(本次核查日期) } }) as any } else if (current.value === 'stability') { // 稳定性 const resultList = res.data.map((item: any) => { return { ...item, lessThan: (`${item.lessThan}` === '1' || `${item.lessThan}` === '') ? '合格' : '不合格', editable: props.pageType !== 'detail', } }) listStability.value = resultList // 计算稳定性考核是否合格 // if (resultList.every((item: { lessThan: string | number }) => item.lessThan === '合格')) { // form.value.qualified = '合格' // } // else { // form.value.qualified = '不合格' // } if (listStability.value && listStability.value.length) { form.value.qualified = `${listStability.value[0].qualified}` === '1' ? '合格' : '不合格' } } // 重复性Loading listRepeatabilityLoading.value = false // 稳定性loading listStabilityLoading.value = false // 频率-稳定性 }).catch(() => { // 重复性Loading listRepeatabilityLoading.value = false listStabilityLoading.value = false // 频率-稳定性 }) } // ------------------------------------------------------------------------------------------ // 处理详情数据 const solveGetDetailData = (responseList: any) => { const list = responseList.map((item: any) => { return { ...item, editable: props.pageType !== 'detail', lessThan: `${item.lessThan}` !== '' ? `${item.lessThan}` === '1' ? '合格' : '不合格' : item.lessThan, kuValueOne: item.checkType === '稳定性' ? item.kuValueOne : Number(item.kuValueOne), kuValueTwo: item.checkType === '稳定性' ? item.kuValueTwo : Number(item.kuValueTwo), kuValueThree: item.checkType === '稳定性' ? item.kuValueThree : Number(item.kuValueThree), kuValueFour: item.checkType === '稳定性' ? item.kuValueFour : Number(item.kuValueFour), kuValueFive: item.checkType === '稳定性' ? item.kuValueFive : Number(item.kuValueFive), kuValueSix: item.checkType === '稳定性' ? item.kuValueSix : Number(item.kuValueSix), kuValueSeven: item.checkType === '稳定性' ? item.kuValueSeven : Number(item.kuValueSeven), kuValueEight: item.checkType === '稳定性' ? item.kuValueEight : Number(item.kuValueEight), kuValueNine: item.checkType === '稳定性' ? item.kuValueNine : Number(item.kuValueNine), kuValueTen: item.checkType === '稳定性' ? item.kuValueTen : Number(item.kuValueTen), pbuValueOne: item.checkType === '稳定性' ? item.pbuValueOne : (item.checkType === '重复性' && `${item.pbuValueOne}` === '') ? undefined : useRound(Number(item.pbuValueOne), 4), // Pbu1/mW pbuValueTwo: item.checkType === '稳定性' ? item.pbuValueTwo : (item.checkType === '重复性' && `${item.pbuValueTwo}` === '') ? undefined : useRound(Number(item.pbuValueTwo), 4), // Pbu2/mW pbuValueThree: item.checkType === '稳定性' ? item.pbuValueThree : (item.checkType === '重复性' && `${item.pbuValueThree}` === '') ? undefined : useRound(Number(item.pbuValueThree), 4), // Pbu3/mW pbuValueFour: item.checkType === '稳定性' ? item.pbuValueFour : (item.checkType === '重复性' && `${item.pbuValueFour}` === '') ? undefined : useRound(Number(item.pbuValueFour), 4), // Pbu4/mW pbuValueFive: item.checkType === '稳定性' ? item.pbuValueFive : (item.checkType === '重复性' && `${item.pbuValueFive}` === '') ? undefined : useRound(Number(item.pbuValueFive), 4), // Pbu5/mW pbuValueSix: item.checkType === '稳定性' ? item.pbuValueSix : (item.checkType === '重复性' && `${item.pbuValueSix}` === '') ? undefined : useRound(Number(item.pbuValueSix), 4), // Pbu6/mW pbuValueSeven: item.checkType === '稳定性' ? item.pbuValueSeven : (item.checkType === '重复性' && `${item.pbuValueSeven}` === '') ? undefined : useRound(Number(item.pbuValueSeven), 4), // Pbu7/mW pbuValueEight: item.checkType === '稳定性' ? item.pbuValueEight : (item.checkType === '重复性' && `${item.pbuValueEight}` === '') ? undefined : useRound(Number(item.pbuValueEight), 4), // Pbu8/mW pbuValueNine: item.checkType === '稳定性' ? item.pbuValueNine : (item.checkType === '重复性' && `${item.pbuValueNine}` === '') ? undefined : useRound(Number(item.pbuValueNine), 4), // Pbu9/mW pbuValueTen: item.checkType === '稳定性' ? item.pbuValueTen : (item.checkType === '重复性' && `${item.pbuValueTen}` === '') ? undefined : useRound(Number(item.pbuValueTen), 4), // Pbu10/mW pcuValueOne: item.checkType === '稳定性' ? item.pcuValueOne : (item.checkType === '重复性' && `${item.pcuValueOne}` === '') ? undefined : useRound(Number(item.pcuValueOne), 3), // Pcu1/mW pcuValueTwo: item.checkType === '稳定性' ? item.pcuValueTwo : (item.checkType === '重复性' && `${item.pcuValueTwo}` === '') ? undefined : useRound(Number(item.pcuValueTwo), 3), // Pcu2/mW pcuValueThree: item.checkType === '稳定性' ? item.pcuValueThree : (item.checkType === '重复性' && `${item.pcuValueThree}` === '') ? undefined : useRound(Number(item.pcuValueThree), 3), // Pcu3/mW pcuValueFour: item.checkType === '稳定性' ? item.pcuValueFour : (item.checkType === '重复性' && `${item.pcuValueFour}` === '') ? undefined : useRound(Number(item.pcuValueFour), 3), // Pcu4/mW pcuValueFive: item.checkType === '稳定性' ? item.pcuValueFive : (item.checkType === '重复性' && `${item.pcuValueFive}` === '') ? undefined : useRound(Number(item.pcuValueFive), 3), // Pcu5/mW pcuValueSix: item.checkType === '稳定性' ? item.pcuValueSix : (item.checkType === '重复性' && `${item.pcuValueSix}` === '') ? undefined : useRound(Number(item.pcuValueSix), 3), // Pcu6/mW pcuValueSeven: item.checkType === '稳定性' ? item.pcuValueSeven : (item.checkType === '重复性' && `${item.pcuValueSeven}` === '') ? undefined : useRound(Number(item.pcuValueSeven), 3), // Pcu7/mW pcuValueEight: item.checkType === '稳定性' ? item.pcuValueEight : (item.checkType === '重复性' && `${item.pcuValueEight}` === '') ? undefined : useRound(Number(item.pcuValueEight), 3), // Pcu8/mW pcuValueNine: item.checkType === '稳定性' ? item.pcuValueNine : (item.checkType === '重复性' && `${item.pcuValueNine}` === '') ? undefined : useRound(Number(item.pcuValueNine), 3), // Pcu9/mW pcuValueTen: item.checkType === '稳定性' ? item.pcuValueTen : (item.checkType === '重复性' && `${item.pcuValueTen}` === '') ? undefined : useRound(Number(item.pcuValueTen), 3), // Pcu10/mW } }) const listRepeatability = list.filter((item: { params: string; checkType: string }) => item.checkType === '重复性').map((item: any, index: number) => { return { ...item, kc: originList.value && originList.value[index] && originList.value[index].kc ? originList.value[index].kc : '', } }) // 重复性 const listStability = list.filter((item: { params: string; checkType: string }) => item.checkType === '稳定性').map((item: any, index: number) => { return { ...item, kc: originList.value && originList.value[index] && originList.value[index].kc ? originList.value[index].kc : '', } }) // 稳定性 if (listStability && listStability.length && `${listStability[0].qualified}` !== '') { form.value.qualified = `${listStability[0].qualified}` === '1' ? '合格' : '不合格' } return { templistRepeatability: listRepeatability, templistStability: listStability, } } // 获取详情 function fetchInfo(id = '') { const loading = ElLoading.service({ lock: true, background: 'rgba(255, 255, 255, 0.8)', }) getInfo({ id: id || infoId.value }).then((res) => { form.value = { ...res.data } equipmentId.value = res.data.equipmentId const { templistRepeatability, templistStability, } = solveGetDetailData(res.data.checkDataLowPowerList) if (id !== '') { // 查询的日期获得的数据 listRepeatabilityCheckDate.value = templistRepeatability listStabilityCheckDate.value = templistStability } else { listRepeatability.value = templistRepeatability listStability.value = templistStability } nextTick(() => { if (id !== '') { // 稳定性表头---查询历史的稳定性日期数据 const tempColumn = [ { width: '180', text: '-', value: 'kuValueOne', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueTwo', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueThree', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueFour', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueFive', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueSix', align: 'center', required: false, type: 'text', customHeader: true }, ] as any columns_stability.value[2].children = [...tempColumn] fetchHistoryIndication(currentDate.value) // 获取稳定性 } else { // 正常核查数据处理表头 columns_stability.value = handleDetailTableTableHead(columns_stability.value, listStability.value, 2) } }) if (props.pageType === 'edit' || props.pageType === 'detail') { fetchHistoryIndication() // 重新拉取稳定性日期 } loading.close() }) } /** * 获取稳定性示值 * @param date 查询日期 */ function fetchHistoryIndication(date = '') { if (!equipmentId.value || !props.selectStandardId) { return false } const params = { belongStandardEquipment: belongStandardEquipment.value, // 检校标准装置(字典code) checkDate: date || props.checkDate!, // 核查日期 checkParam: '', // 核查参数((直流稳压电源-直接电流(间接测量)) conclusion: '合格', // 结论 equipmentId: equipmentId.value, // 被核查设备id params: '', // 核查项目 stabilityExamine: '1', // 是否用于稳定性考核(1/0) standardEquipmentId: props.selectStandardId!, // 被核查标准装置id } if (props.selectStandardId && equipmentId.value) { // 稳定性Loading listStabilityLoading.value = true } getHistoryIndication(params).then((res) => { if (date === '') { // 正常核查数据 const num = (props.pageType === 'edit' || props.pageType === 'detail') ? 5 : 4 listStability.value = listStability.value.map((item) => { const { itemData, columnsData } = solveHistoryIndicationTableData(res.data.data, item, columns_stability.value, num, 2, '15') columns_stability.value = columnsData return item = itemData }) listStability.value = handleSaveDateParams(columns_stability.value, listStability.value, 2) } else { initColumnsCheckDate() const num = 5 listStabilityCheckDate.value = listStabilityCheckDate.value.map((item) => { clearDateValue(item) const { itemData, columnsData } = solveHistoryIndicationTableData(res.data.data, item, columns_stability_checkDate.value, num, 2, '15') columns_stability_checkDate.value = columnsData return item = itemData }) listStabilityCheckDate.value = handleSaveDateParams(columns_stability_checkDate.value, listStabilityCheckDate.value, 2) } listStabilityLoading.value = false // 稳定性 }).catch(() => { listStabilityLoading.value = false // 稳定性 }) } /** * 保存之前的校验 */ function checkList() { // 新建核查数据的时候,在保存之前要先校验一下本次核查日期有没有数据,没有不允许保存 if (listRepeatability.value.length && `${listRepeatability.value[0].averageValue}` === '') { ElMessage.warning('请先计算重复性') return false } return true } // 保存之前处理数据 const solveDataBeforeSave = () => { // 数据处理 let tempList = [] as any tempList = tempList.concat( // 重复性 listRepeatability.value, // 重复性 listStability.value, // 稳定性 ) return tempList } // 点击表头日期查询历史稳定性数据 const handleClickHeader = (val: any, checkDateDetailId: string) => { dateArrStability.value = ['核查数据', val.label] fetchInfo(checkDateDetailId) // 获取此次历史日期的详情 } // 日期变化 const handleChangeRadio = (date: string) => { currentDate.value = date } // -------------------------------------钩子----------------------------------------------------- watch(() => props.pageType, (newValue) => { if (newValue === 'detail') { listRepeatability.value = listRepeatability.value.map((item) => { return { ...item, editable: false, pbuValueOne: useRound(Number(item.pbuValueOne), 4), // Pbu1/mW pbuValueTwo: useRound(Number(item.pbuValueTwo), 4), // Pbu2/mW pbuValueThree: useRound(Number(item.pbuValueThree), 4), // Pbu3/mW pbuValueFour: useRound(Number(item.pbuValueFour), 4), // Pbu4/mW pbuValueFive: useRound(Number(item.pbuValueFive), 4), // Pbu5/mW pbuValueSix: useRound(Number(item.pbuValueSix), 4), // Pbu6/mW pbuValueSeven: useRound(Number(item.pbuValueSeven), 4), // Pbu7/mW pbuValueEight: useRound(Number(item.pbuValueEight), 4), // Pbu8/mW pbuValueNine: useRound(Number(item.pbuValueNine), 4), // Pbu9/mW pbuValueTen: useRound(Number(item.pbuValueTen), 4), // Pbu10/mW pcuValueOne: useRound(Number(item.pcuValueOne), 3), // Pcu1/mW pcuValueTwo: useRound(Number(item.pcuValueTwo), 3), // Pcu2/mW pcuValueThree: useRound(Number(item.pcuValueThree), 3), // Pcu3/mW pcuValueFour: useRound(Number(item.pcuValueFour), 3), // Pcu4/mW pcuValueFive: useRound(Number(item.pcuValueFive), 3), // Pcu5/mW pcuValueSix: useRound(Number(item.pcuValueSix), 3), // Pcu6/mW pcuValueSeven: useRound(Number(item.pcuValueSeven), 3), // Pcu7/mW pcuValueEight: useRound(Number(item.pcuValueEight), 3), // Pcu8/mW pcuValueNine: useRound(Number(item.pcuValueNine), 3), // Pcu9/mW pcuValueTen: useRound(Number(item.pcuValueTen), 3), // Pcu10/mW } }) as any } }) /** * 初始化表头 * @param soveLastColumnDate 是否处理最后一列 */ function initColumns() { const tempColumn = [ { width: '180', text: '-', value: 'kuValueOne', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueTwo', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueThree', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueFour', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueFive', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueSix', align: 'center', required: false, type: 'text', customHeader: true }, ] as any columns_stability.value[2].children = [...tempColumn] columns_stability.value[2].children![5].text = props.checkDate! // 最后一列的表头日期 } /** * 初始化CheckDate表头 */ function initColumnsCheckDate() { const tempColumn = [ { width: '180', text: '-', value: 'kuValueOne', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueTwo', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueThree', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueFour', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueFive', align: 'center', required: false, type: 'text', customHeader: true }, { width: '180', text: '-', value: 'kuValueSix', align: 'center', required: false, type: 'text', customHeader: true }, ] as any columns_stability_checkDate.value[2].children = [...tempColumn] } // 监听核查日期变化 watch(() => props.checkDate, (newValue) => { initColumns() nextTick(() => { fetchHistoryIndication() // 重新拉取稳定性日期 }) }, { immediate: true }) onMounted(async () => { 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') { fetchCheckItemDetail($route.query.equipmentId as string, belongStandardEquipment.value, itemCategoryId.value, itemCategoryName.value, false).then(() => { fetchInfo() }) } }) defineExpose({ fetchCheckItemDetail, checkList, solveDataBeforeSave, form }) </script> <template> <!-- 核查数据 --> <detail-block :title="dateArrStability.length > 1 ? ' ' : '核查数据'" :title-menus="dateArrStability" @handle-change-radio="handleChangeRadio"> <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: flex-end;align-items: center;margin-bottom: 10px;"> <el-button v-if="pageType !== 'detail'" type="primary" @click="createResult"> 计算结果 </el-button> </div> <multi-table v-show="current === 'repeatability' && (currentDate === '核查数据' || currentDate === '')" v-loading="listRepeatabilityLoading" :table-data="listRepeatability" :table-header="columns_repeatability" :merge-rows="[]" :need-index="true" max-height="300" /> <!-- 历史日期重复性数据 --> <multi-table v-show="current === 'repeatability' && (currentDate !== '核查数据' && currentDate !== '')" v-loading="listRepeatabilityLoading" :table-data="listRepeatabilityCheckDate" :table-header="columns_repeatability" :merge-rows="[]" :need-index="true" max-height="300" /> <!-- 稳定性 --> <multi-table v-show="current === 'stability' && (currentDate === '核查数据' || currentDate === '')" v-loading="listStabilityLoading" :table-data="listStability" :table-header="columns_stability" :merge-rows="[]" :need-index="true" max-height="500" @handle-click-header="handleClickHeader" /> <!-- 历史日期稳定性数据 --> <multi-table v-show="current === 'stability' && (currentDate !== '核查数据' && currentDate !== '')" v-loading="listStabilityLoading" :table-data="listStabilityCheckDate" :table-header="columns_stability_checkDate" :merge-rows="[]" :need-index="true" max-height="500" @handle-click-header="handleClickHeader" /> <el-form v-if="current === 'stability'" style="margin-top: 20px;" :model="form" label-width="160" label-position="right" > <el-row :gutter="24"> <el-col :span="12"> <el-form-item label="稳定性考核是否合格:"> <el-input v-model="form.qualified" class="full-width-input" disabled :placeholder="pageType === 'detail' ? ' ' : '稳定性考核是否合格'" /> </el-form-item> </el-col> </el-row> </el-form> <!-- 保存核查记录 --> <save-check-record ref="saveCheckRecordRef" /> </detail-block> </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>