<!-- 核查数据管理详情--核查项---第8套:E2等砝码标准装置 -->
<script lang="ts" setup name="checkDataDetail">
import { ref, watch } from 'vue'
import { ElLoading, ElMessage } from 'element-plus'
import saveCheckRecord from '../../dialog/saveCheckRecord.vue'
import { clearDateValue, handleDetailTableTableHead, handleSaveDateParams, solveHistoryIndicationTableData, solveListStability } from '../useStabilityCaculate'
import type { TableColumn } from '@/components/NormalTable/table_interface'
import multiTable from '@/components/MultiHeaderTable/index.vue'
import { getCheckItemDetail } from '@/api/equipment/standard/book'
import { useCheckList } from '@/commonMethods/useCheckList'
import { useGroup } from '@/commonMethods/useGroup'
import { getDictByCode } from '@/api/system/dict'
import type { dictType } from '@/global'
import { calculateHandle, getHistoryIndication, getInfo } from '@/api/equipment/standard/checkData'
const props = defineProps({
selectStandardId: { // 选择的标准装置id
type: String,
},
pageType: { // 页面类型
type: String,
},
checkDate: { // 核查日期
type: String,
},
})
const emits = defineEmits(['isConfigCheck'])
const $route = useRoute() // 路由参数
const infoId = ref('')
const form = ref({
conclusion: '', // 结论
remark: '/', // 备注
})
const belongStandardEquipment = ref('8')
const itemCategoryId = ref('') // 核查项分类id
const itemCategoryName = ref('') // 核查项分类名称
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 checkUnitList = [ // 单位select数组
{
text: 'ug',
value: 'ug',
},
{
text: 'mg',
value: 'mg',
},
{
text: 'g',
value: 'g',
},
{
text: 'kg',
value: 'kg',
},
{
text: 't',
value: 't',
},
]
// ----------------------------------------核查数据----------------------------------------------
const columns_repeatability = ref<TableColumn[]>([ // 重复性表头
{ text: '示值设备名称', value: 'valueEquipmentName', align: 'center', required: false, type: 'text' },
{ text: '核查点', value: 'checkPoint', align: 'center', required: false, type: 'text' },
{ text: '单位', value: 'unit', align: 'center', required: true, type: 'select', options: checkUnitList, width: '120' },
{
text: '第1次',
value: 'one',
align: 'center',
required: false,
width: '180',
children: [
{ value: 'aOneValueOne', text: 'A1(Ir1i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'bOneValueOne', text: 'B1(It1i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'bTwoValueOne', text: 'B2(It2i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'aTwoValueOne', text: 'A2(Ir2i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'averageValueOne', text: '平均值△Ii', align: 'center', required: false, width: '180', type: 'text' },
],
},
{
text: '第2次',
value: 'two',
align: 'center',
required: false,
width: '180',
children: [
{ value: 'aOneValueTwo', text: 'A1(Ir1i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'bOneValueTwo', text: 'B1(It1i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'bTwoValueTwo', text: 'B2(It2i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'aTwoValueTwo', text: 'A2(Ir2i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'averageValueTwo', text: '平均值△Ii', align: 'center', required: false, width: '180', type: 'text' },
],
},
{
text: '第3次',
value: 'three',
align: 'center',
required: false,
width: '180',
children: [
{ value: 'aOneValueThree', text: 'A1(Ir1i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'bOneValueThree', text: 'B1(It1i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'bTwoValueThree', text: 'B2(It2i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'aTwoValueThree', text: 'A2(Ir2i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'averageValueThree', text: '平均值△Ii', align: 'center', required: false, width: '180', type: 'text' },
],
},
{
text: '第4次',
value: 'four',
align: 'center',
required: false,
width: '180',
children: [
{ value: 'aOneValueFour', text: 'A1(Ir1i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'bOneValueFour', text: 'B1(It1i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'bTwoValueFour', text: 'B2(It2i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'aTwoValueFour', text: 'A2(Ir2i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'averageValueFour', text: '平均值△Ii', align: 'center', required: false, width: '180', type: 'text' },
],
},
{
text: '第5次',
value: 'five',
align: 'center',
required: false,
width: '180',
children: [
{ value: 'aOneValueFive', text: 'A1(Ir1i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'bOneValueFive', text: 'B1(It1i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'bTwoValueFive', text: 'B2(It2i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'aTwoValueFive', text: 'A2(Ir2i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'averageValueFive', text: '平均值△Ii', align: 'center', required: false, width: '180', type: 'text' },
],
},
{
text: '第6次',
value: 'six',
align: 'center',
required: false,
width: '180',
children: [
{ value: 'aOneValueSix', text: 'A1(Ir1i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'bOneValueSix', text: 'B1(It1i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'bTwoValueSix', text: 'B2(It2i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'aTwoValueSix', text: 'A2(Ir2i)', align: 'center', required: true, width: '180', type: 'inputNumber' },
{ value: 'averageValueSix', text: '平均值△Ii', align: 'center', required: false, width: '180', type: 'text' },
],
},
{ text: '平均值△Ij', value: 'averageValue', align: 'center', required: false, type: 'text' },
{ text: '重复性Sn', value: 'repeatability', align: 'center', required: false, type: 'text' },
])
const columns_stability = ref<TableColumn[]>([ // 稳定性表头
{ text: '核查点', value: 'checkPoint', align: 'center', required: false, type: 'text' },
{ text: '单位', value: 'unit', align: 'center', required: false, type: 'text' },
{
text: '测量数据△Ij及处理结果',
value: 'mesaureValue',
align: 'center',
required: false,
width: '180',
children: [
{ width: '180', text: '-', value: 'averageValueOne', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueTwo', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueThree', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueFour', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueFive', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueSix', align: 'center', required: false, type: 'text', customHeader: true },
],
},
{ text: '平均值', value: 'averageValue', align: 'center', required: false, type: 'text' },
{ text: '重复性Sm', value: 'repeatability', align: 'center', required: false, type: 'text' },
{ text: 'U(k=2)', value: 'urel', align: 'center', required: false, type: 'text' },
{ text: '是否Sm≤U', value: 'lessThan', align: 'center', required: false, type: 'text' },
])
// 查询历史日期---稳定性表头
const columns_stability_checkDate = ref<TableColumn[]>([
{ text: '核查点', value: 'checkPoint', align: 'center', required: true, type: 'text' },
{ text: '单位', value: 'unit', align: 'center', required: true, type: 'text' },
{
text: '测量数据△Ij及处理结果',
value: 'mesaureValue',
align: 'center',
required: false,
width: '180',
children: [
{ width: '180', text: '-', value: 'averageValueOne', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueTwo', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueThree', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueFour', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueFive', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueSix', align: 'center', required: false, type: 'text', customHeader: true },
],
},
{ text: '平均值', value: 'averageValue', align: 'center', required: true, type: 'text' },
{ text: '重复性Sm', value: 'repeatability', align: 'center', required: true, type: 'text' },
{ text: 'U(k=2)', value: 'urel', align: 'center', required: true, type: 'text' },
{ text: '是否Sm≤U', value: 'lessThan', align: 'center', required: true, type: 'text' },
])
const listRepeatability = ref<any[]>([]) // 重复性
const listStability = ref<any[]>([]) // 稳定性
const listRepeatabilityCheckDate = ref<any[]>([]) // 重复性--查询历史日期
const listStabilityCheckDate = ref<any[]>([]) // 稳定性--查询历史日期
const repeatabilityTableLoading = ref(false) // 重复性表格loading
const stabilityTableLoading = ref(false) // 稳定性表格loading
// 获取配置详情
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: equipmentIdParam, // 设备id
belongStandardEquipment: belongStandardEquipment.value, // 检校标准装置code
itemCategoryId: itemCategoryId.value, // 核查项分类id
itemCategoryName: itemCategoryName.value, // 核查项分类名称
}
getCheckItemDetail(params).then((res) => {
loading.close()
if (!res.data) {
emits('isConfigCheck', false)
}
else {
handleData(res.data.checkItemDataETwoList)
fetchHistoryIndication() // 获取稳定性
}
})
}
// 初始化数据(查询配置检定项)
function handleData(list: any, type = 'edit') {
listRepeatability.value = list.map((e: any) => {
return {
editable: type === 'edit',
id: '', // id,更新/删除使用参数
checkType: '重复性',
dataId: e.id, // 核查数据管理基础信息表id
params: e.params, // 核查项目
checkPoint: e.checkPoint,
unit: e.checkPoint === '20kg' ? 'g' : 'mg', // 单位(直接存字典value)
urel: e.urel, // 扩展不确定度U
valueEquipmentName: e.valueEquipmentName, // 设备名称
// 第一次
aOneValueOne: undefined, // a
bOneValueOne: undefined, // b
aTwoValueOne: undefined,
bTwoValueOne: undefined,
// 第二次
aOneValueTwo: undefined,
aTwoValueTwo: undefined,
bOneValueTwo: undefined,
bTwoValueTwo: undefined,
// 第三次
aOneValueThree: undefined,
aTwoValueThree: undefined,
bOneValueThree: undefined,
bTwoValueThree: undefined,
// 第四次
aOneValueFour: undefined,
bOneValueFour: undefined,
bTwoValueFour: undefined,
aTwoValueFour: undefined,
// 第五次
aOneValueFive: undefined,
aTwoValueFive: undefined,
bTwoValueFive: undefined,
bOneValueFive: undefined,
// 第6次
aOneValueSix: undefined,
aTwoValueSix: undefined,
bOneValueSix: undefined,
bTwoValueSix: undefined,
averageValueOne: '', // 第1次平均值(重复性)/测量数据1(稳定性)
averageValueTwo: '', // 第2次平均值(重复性)/测量数据2(稳定性)
averageValueThree: '', // 第3次平均值(重复性)/测量数据3(稳定性)
averageValueFour: '', // 第4次平均值(重复性)/测量数据4(稳定性)
averageValueFive: '', // 第5次平均值(重复性)/测量数据5(稳定性)
averageValueSix: '', // 第6次平均值(重复性)/测量数据6(稳定性)
averageValue: '', // 差值平均值
repeatability: '', // Sn
conclusion: '', // 结论(设备性能正常/设备性能异常)
}
})
listStability.value = listRepeatability.value.map((e) => {
return {
editable: props.pageType !== 'detail',
dataId: e.id, // 核查数据管理基础信息表id
id: '', // id,更新/删除使用参数
checkPoint: e.checkPoint,
unit: e.unit, // 单位
checkType: '稳定性',
urel: e.urel, // 扩展不确定度U
}
})
listRepeatability.value = useGroup(listRepeatability.value, 'valueEquipmentName') // 数据根据示值设备名称分组
}
// 点击计算结果
/**
* type
* @param type 类型 repeatability重复性、stability稳定性
*/
const createResult = (type: 'repeatability' | 'stability') => {
// 重复性校验
if (type === 'repeatability') {
if (!useCheckList(listRepeatability.value, columns_repeatability.value, '重复性')) { return false }
}
// 稳定性校验
if (type === 'stability' && `${listRepeatability.value[0].averageValue}` === '') {
ElMessage.warning('请先计算重复性')
return false
}
const checkDataETwoListParams = type === 'repeatability' ? listRepeatability.value : listStability.value
const params = {
belongStandardEquipment: belongStandardEquipment.value, // 检校标准装置
checkDataETwoList: checkDataETwoListParams.map((item: { lessThan: string; illustration: string }) => {
return {
...item,
conclusion: '',
lessThan: '',
// lessThan: item.lessThan === '是' ? '1' : item.lessThan === '否' ? '0' : '', // 是否Sm≤U
}
}),
itemCategoryId: itemCategoryId.value, // 核查项分类id
itemCategoryName: itemCategoryName.value, // 核查项分类id
}
repeatabilityTableLoading.value = type === 'repeatability' // 重复性表loading
stabilityTableLoading.value = type === 'stability' // 稳定性表loading
calculateHandle(params).then((res) => {
const result = res.data.map((item: any) => {
return {
...item,
editable: props.pageType !== 'detail',
// 第一次
aOneValueOne: Number(item.aOneValueOne), // a
bOneValueOne: Number(item.bOneValueOne), // b
aTwoValueOne: Number(item.aTwoValueOne),
bTwoValueOne: Number(item.bTwoValueOne),
// 第二次
aOneValueTwo: Number(item.aOneValueTwo),
aTwoValueTwo: Number(item.aTwoValueTwo),
bOneValueTwo: Number(item.bOneValueTwo),
bTwoValueTwo: Number(item.bTwoValueTwo),
// 第三次
aOneValueThree: Number(item.aOneValueThree),
aTwoValueThree: Number(item.aTwoValueThree),
bOneValueThree: Number(item.bOneValueThree),
bTwoValueThree: Number(item.bTwoValueThree),
// 第四次
aOneValueFour: Number(item.aOneValueFour),
bOneValueFour: Number(item.bOneValueFour),
bTwoValueFour: Number(item.bTwoValueFour),
aTwoValueFour: Number(item.aTwoValueFour),
// 第五次
aOneValueFive: Number(item.aOneValueFive),
aTwoValueFive: Number(item.aTwoValueFive),
bTwoValueFive: Number(item.bTwoValueFive),
bOneValueFive: Number(item.bOneValueFive),
// 第6次
aOneValueSix: Number(item.aOneValueSix),
aTwoValueSix: Number(item.aTwoValueSix),
bOneValueSix: Number(item.bOneValueSix),
bTwoValueSix: Number(item.bTwoValueSix),
}
})
if (type === 'repeatability') { // 重复性
listRepeatability.value = result
console.log(listRepeatability.value)
// 填充稳定性最后一列的日期和数值
listStability.value = listStability.value.map((item, index: number) => {
return {
...item,
averageValueSix: listRepeatability.value[index].averageValue, // 测量数据
testValueSixDate: props.checkDate, // 核查读数6日期(本次核查日期)
}
})
}
else { // 稳定性
listStability.value = result.map((item: { lessThan: string | number }) => {
return {
...item,
lessThan: `${item.lessThan}` === '1' ? '是' : '否',
}
})
// 计算结论
const tempResult = listStability.value.every((item: { lessThan: string }) => {
return item.lessThan === '是'
})
const dateNum = dateCount(columns_stability.value)
form.value.conclusion = dateNum < 4 ? '设备性能正常' : tempResult ? '设备性能正常' : '设备性能异常'
}
repeatabilityTableLoading.value = false
stabilityTableLoading.value = false
}).catch(() => {
repeatabilityTableLoading.value = false
stabilityTableLoading.value = false
})
}
// ------------------------------------------------------------------------------------------
// 处理详情数据
const solveGetDetailData = (responseList: any) => {
const listRepeatability = responseList.filter((item: { params: string; checkType: string }) => item.checkType === '重复性').map((item: any) => {
return {
...item,
editable: props.pageType !== 'detail',
}
})
const listStability = responseList.filter((item: { params: string ; checkType: string }) => item.checkType === '稳定性').map((item: any) => {
return {
...item,
lessThan: `${item.lessThan}` === '1' ? '是' : (`${item.lessThan}` === '0' || `${item.lessThan}` === '') ? '否' : item.lessThan,
}
})
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.checkDataETwoList)
if (id !== '') { // 查询的日期获得的数据
listRepeatabilityCheckDate.value = tempListRepeatability// 重复性查询数据
listStabilityCheckDate.value = tempListStability// 稳定性查询数据
}
else {
listRepeatability.value = tempListRepeatability// 重复性查询数据
// listStability.value = tempListStability // 稳定性查询数据
listStability.value = solveListStability(tempListStability) // 稳定性查询数据
}
nextTick(() => {
if (id !== '') { // 稳定性表头---查询历史的稳定性日期数据
columns_stability.value[2].children = [
{ width: '180', text: '-', value: 'averageValueOne', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueTwo', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueThree', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueFour', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueFive', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueSix', align: 'center', required: false, type: 'text', customHeader: true },
]
fetchHistoryIndication(currentDate.value) // 获取稳定性
}
else { // 正常核查数据处理表头
columns_stability.value = handleDetailTableTableHead(columns_stability.value, listStability.value, 2)
}
})
if (props.pageType === 'edit' || props.pageType === 'detail') {
fetchHistoryIndication() // 重新拉取稳定性日期
}
// ====================计算结论=====================
// if (listStability.value.every(item => `${item.lessThan}` === '是')) {
// form.value.conclusion = '设备性能正常'
// }
// else {
// form.value.conclusion = '设备性能异常'
// }
// 计算结论
nextTick(() => {
const tempResult = listStability.value.every((item: { lessThan: string }) => {
return item.lessThan === '是'
})
const dateNum = dateCount(columns_stability.value)
form.value.conclusion = dateNum < 4 ? '设备性能正常' : tempResult ? '设备性能正常' : '设备性能异常'
})
// form.value.conclusion = listStability.value.length ? listStability.value[0].conclusion! : ''// 结论
loading.close()
})
}
/**
* 获取稳定性示值
* @param date 查询日期
*/
function fetchHistoryIndication(date = '') {
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) {
stabilityTableLoading.value = true
getHistoryIndication(params).then((res) => {
if (date === '') { // 正常核查数据
// initColumns()
// listStability.value = solveListStability(listStability.value)
// console.log('==--=-=', listStability.value);
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, '8')
columns_stability.value = columnsData
return item = itemData
})
listStability.value = handleSaveDateParams(columns_stability.value, listStability.value, 2)
}
else {
initColumnsCheckDate()
listStabilityCheckDate.value = listStabilityCheckDate.value.map((item) => {
clearDateValue(item)
const { itemData, columnsData } = solveHistoryIndicationTableData(res.data.data, item, columns_stability_checkDate.value, 5, 2, '8')
columns_stability_checkDate.value = columnsData
return item = itemData
})
listStabilityCheckDate.value = handleSaveDateParams(columns_stability_checkDate.value, listStabilityCheckDate.value, 2)
}
stabilityTableLoading.value = false
}).catch(() => { stabilityTableLoading.value = false })
}
}
/**
* 保存之前的校验
* 重复性和稳定性必须要计算才能保存
* 因为如果不计算稳定性
*/
function checkList() {
// 新建核查数据的时候,在保存之前要先校验一下本次核查日期有没有数据,没有不允许保存
if (`${listRepeatability.value[0].averageValue}` === '') { //
ElMessage.warning('请计算重复性')
return false
}
// 保存之前处理参数
// 稳定性
listStability.value = listStability.value.map((item) => {
return {
...item,
conclusion: form.value.conclusion, // 结论
}
})
return true
}
// 点击表头日期查询历史稳定性数据
const handleClickHeader = (val: any, checkDateDetailId: string) => {
dateArrStability.value = ['核查数据', val.label]
fetchInfo(checkDateDetailId) // 获取此次历史日期的详情
}
// 日期变化
const handleChangeRadio = (date: string) => {
currentDate.value = date
}
// -------------------------------------钩子-----------------------------------------------------
// 统计日期
function dateCount(columns: TableColumn[]) {
let dateNum = 0 // 稳定性表格有几个日期
// 统计有几个日期
columns[2].children!.forEach((item) => {
if (item.text !== '-' && item.text !== '') {
dateNum += 1
}
})
return dateNum
}
watch(() => props.pageType, (newValue) => {
if (newValue === 'detail') {
listRepeatability.value = listRepeatability.value.map((item) => { item.editable = false; return item })
}
})
/**
* 初始化表头
* @param soveLastColumnDate 是否处理最后一列
*/
function initColumns() {
columns_stability.value[2].children = [
{ width: '180', text: '-', value: 'averageValueOne', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueTwo', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueThree', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueFour', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueFive', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueSix', align: 'center', required: false, type: 'text', customHeader: true },
]
const index = columns_stability.value.findIndex(item => item.text === '测量数据△Ij及处理结果')
if (index !== -1) {
columns_stability.value[index].children![5].text = props.checkDate! // 最后一列的表头日期
}
}
/**
* 初始化CheckDate表头
*/
function initColumnsCheckDate() {
columns_stability_checkDate.value[2].children = [
{ width: '180', text: '-', value: 'averageValueOne', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueTwo', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueThree', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueFour', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueFive', align: 'center', required: false, type: 'text', customHeader: true },
{ width: '180', text: '-', value: 'averageValueSix', align: 'center', required: false, type: 'text', customHeader: true },
]
}
// 监听核查日期变化
watch(() => props.checkDate, (newValue) => {
initColumns()
nextTick(() => {
fetchHistoryIndication() // 重新拉取稳定性日期
})
}, { immediate: true })
// 重复性单位选中值变化--修改稳定性表格中的单位
const selectChange = (value: string, row: any) => {
const checkPoint = row.checkPoint // 核查点
const index = listStability.value.findIndex(item => item.checkPoint === checkPoint)
if (index !== -1) {
listStability.value[index].unit = value
}
}
onMounted(async () => {
belongStandardEquipment.value = $route.query.belongStandardEquipment as string // 检校标准装置
itemCategoryId.value = $route.query.itemCategoryId as string // 核查项分类id
itemCategoryName.value = $route.query.itemCategoryName as string // 核查项分类名称
console.log('itemCategoryId', itemCategoryId.value)
console.log('itemCategoryName', itemCategoryName.value)
if (props.pageType !== 'add') {
fetchInfo()
}
})
defineExpose({
fetchCheckItemDetail,
form,
checkList,
listRepeatability,
listStability,
})
</script>
<template>
<!-- 核查数据 -->
<detail-block :title="dateArrStability.length > 1 ? ' ' : '核查数据'" :title-menus="dateArrStability" @handle-change-radio="handleChangeRadio">
<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-show="currentDate === '核查数据' || currentDate === ''"
v-loading="repeatabilityTableLoading"
:table-data="listRepeatability"
:table-header="columns_repeatability"
:merge-rows="['valueEquipmentName']"
:need-index="true"
max-height="300"
@selectChange="selectChange"
/>
<!-- 历史日期重复性数据 -->
<multi-table
v-show="currentDate !== '核查数据' && currentDate !== ''"
v-loading="repeatabilityTableLoading"
:table-data="listRepeatabilityCheckDate"
:table-header="columns_repeatability"
:merge-rows="['valueEquipmentName']"
: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-show="currentDate === '核查数据' || currentDate === ''"
v-loading="stabilityTableLoading"
:table-data="listStability"
:table-header="columns_stability"
:merge-rows="[]"
:need-index="true"
max-height="500"
@handle-click-header="handleClickHeader"
/>
<multi-table
v-show="currentDate !== '核查数据' && currentDate !== ''"
v-loading="stabilityTableLoading"
:table-data="listStabilityCheckDate"
:table-header="columns_stability_checkDate"
:merge-rows="[]"
:need-index="true"
max-height="500"
@handle-click-header="handleClickHeader"
/>
<!-- 结论 -->
<el-form
style="margin-top: 20px;"
:model="form"
label-width="180"
label-position="right"
>
<el-row :gutter="24">
<el-col :span="12">
<el-form-item label="结论:">
<el-input v-model="form.conclusion" class="full-width-input" disabled placeholder="结论" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :span="16">
<el-form-item label="备注:" prop="remark">
<el-input
v-model="form.remark"
autosize
type="textarea"
:disabled="pageType === 'detail'"
/>
</el-form-item>
</el-col>
</el-row>
</el-form>
</detail-block>
<!-- 保存核查记录 -->
<save-check-record ref="saveCheckRecordRef" />
</template>