Newer
Older
xc-business-system / src / views / business / taskMeasure / measureData / components / fourth / templateDetail.vue
dutingting on 7 Mar 2024 69 KB 示波器配置检定项50%
<!-- 第4套:0.02级活塞式压力计 -->
<!-- 检定数据管理详情模板 -->
<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 selectStandard from '../../dialog/selectStandardDialog.vue'
import TemplateFormAndTable from '../templateFormAndTable.vue'
import { useSolveFormData } from '../useSolveFormData'
import { useZeroDriftResult } from '../../useCaculate'
import type { IDetailMeasureList } from './fourth-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, getSlopeB } from '@/api/business/measure/item'
import { useCheckList } from '@/commonMethods/useCheckList'
import multiTable from '@/components/MultiHeaderTable/index.vue'
import { calc } from '@/utils/useCalc'

const props = defineProps({
  infoId: String, // id
  dataNo: String, // 检定数据编号
})
const emits = defineEmits(['giveInfoId'])
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/0)
  appearanceRemark: '', // 外观备注说明
  pointerDeflectionStability: '', // 指针偏转平稳性
  pointerDeflectionStabilityRemark: '', // 指针偏转平稳性备注说明
  tightness: '', // 密封性
  tightnessRemark: '', // 密封性备注说明
  zeroDriftResult: '', // 零位飘移结果(合格/不合格,直接存文字)
  insulationResistance: '', //	绝缘电阻
  insulationResistanceRemark: '', //	绝缘电阻备注说明-0.02活塞式压力计
  workLineEquation: '1', // 工作直线方程

  cycleNumber: 0, // 循环次数
  maxIndicatingError: '', // 最大误差(示值误差最大值)
  indicatingError: '', // 示值误差允许值(示值误差)
  maxReturnError: '', // 最大回差(回程误差最大值)
  returnError: '', // 回差(允许回差)

  tempData: '', // 无用,计算输出时去掉

  outcome: '', // 结果(合格、不合格)
  remark: '', // 备注
  otherOutcome: '', // 结果(检定数据中有2个表格情况下的第2个表中的合格/不合格)(前端判断)
  otherRemark: '', // 备注(检定数据中有2个表格情况下的第2个表中的备注)

  interceptA: '', // 截距a
  slopeB: '', // 斜率b
  sensitivityB: '', // 灵敏度b
  repeatabilityR: '', // 重复性ξR
  hysteresisH: '', // 迟滞ξH
  linearL: '', // 线性ξL
  basicErrorA: '', // 基本误差A
  periodicStabilitySB: '', // 周期稳定性Sb

  lastCycleSensitivity: '', // 上一周期灵敏度b0
  supplyVoltage: '', // 供电电压
})
const measureItemConfigPistonGauge = ref() as any // 输入配置
const tableLoadingTop = ref(false)
const tableLoadingBottom = ref(false)
const pressureSensorTableLoading = ref(false) // 压力传感器loading
const inputList = ref([]) as any
const eqptEquipmentId = ref('') // 受检设备id(压力传感器获取上一周期灵敏度b0使用)
// -------------------------------------------路由参数------------------------------------------
const pageType = ref('add') // 页面类型: add, edit, detail
const infoId = ref('') // 列表id
if ($route.params && $route.params.type) {
  pageType.value = $route.params.type as string

  if ($route.params.id) {
    infoId.value = $route.params.id as string
  }
}

// --------------------------------------------字典--------------------------------------
const workingLinearEquationList = ref<dictType[]>([])// 工作直线方程
async function getDict() {
  // 工作直线方程
  getDictByCode('workingLinearEquation').then((response) => {
    workingLinearEquationList.value = response.data
  })
}
getDict()
// ------------------------------------------标签----------------------------------------------------------
const radioMenus = ref([ // 标签内容
  { name: '检定数据', value: 'measure-data' },
  { name: '历史修改记录', value: 'change-record' },
])
const current = ref('measure-data') // 选择的tab 默认基本信息

// ---------------------------------------检定项数据表格----------------------------------------------------
const list = ref<IDetailMeasureList[]>([]) // 表格数据
const resultList = ref<IDetailMeasureList[]>([]) // 结果表格数据
const listElectricContact = ref<IDetailMeasureList[]>([]) // 电接点一般压力表表格数据
const resultListElectricContact = ref<IDetailMeasureList[]>([]) // 电接点一般压力表第二结果表格数据

const measureColumns = ref([]) as any // 表头数据
const columns_generalPurposegauge = ref([ // 一般压力表、精密压力表、电接点一般压力表
  { text: '标准器示值', value: 'indicatingValue', align: 'center', required: true, type: 'text' },
  {
    text: '轻敲前被检设备示值',
    value: 'beforeFrictionStroke',
    align: 'center',
    required: true,
    children: [
      { text: '正行程', width: '180', value: 'beforeFrictionForwardStroke', align: 'center', required: true, type: 'inputNumber' },
      { text: '反行程', width: '180', value: 'beforeFrictionReverseStroke', align: 'center', required: true, type: 'inputNumber' },
    ],
  },
  {
    text: '轻敲后被检设备示值',
    value: 'afterFrictionStroke',
    align: 'center',
    required: true,
    children: [
      { text: '正行程', width: '180', value: 'afterFrictionForwardStroke', align: 'center', required: true, type: 'inputNumber' },
      { text: '反行程', width: '180', value: 'afterFrictionReverseStroke', align: 'center', required: true, type: 'inputNumber' },
    ],
  },
  {
    text: '轻敲前后变动量',
    value: 'variationStroke',
    align: 'center',
    required: true,
    children: [
      { text: '正行程', width: '180', value: 'variationForwardStroke', align: 'center', required: true, type: 'text' },
      { text: '反行程', width: '180', value: 'variationReverseStroke', align: 'center', required: true, type: 'text' },
    ],
  },
])
// 生成结果表头--一般压力表
const result_columns_generalPurposegauge = ref([
  { text: '项目', value: 'item', align: 'center', required: true },
  { text: '示值误差允许值', value: 'indicatingError', align: 'center', required: true },
  { text: '示值误差最大值', value: 'maxIndicatingError', align: 'center', required: true },
  { text: '轻敲位移允许值', value: 'frictionError', align: 'center', required: true },
  { text: '轻敲位移最大值', value: 'maxFrictionError', align: 'center', required: true },
  { text: '回程误差允许值', value: 'returnError', align: 'center', required: true },
  { text: '回程误差最大值', value: 'maxReturnError', align: 'center', required: true },
])
// 精密压力表
const result_columns_precisionPressuregauge = ref([
  { text: '示值误差允许值', value: 'indicatingError', align: 'center', required: true },
  { text: '示值误差最大值', value: 'maxIndicatingError', align: 'center', required: true },
  { text: '轻敲位移允许值', value: 'frictionError', align: 'center', required: true },
  { text: '轻敲位移最大值', value: 'maxFrictionError', align: 'center', required: true },
  { text: '回程误差允许值', value: 'returnError', align: 'center', required: true },
  { text: '回程误差最大值', value: 'maxReturnError', align: 'center', required: true },
])
const columns_digitalMultimeterTable = ref([ // 压力变送器
  { text: '标准器示值', value: 'indicatingValue', align: 'center', required: true, type: 'text' },
  { text: '理论输出值', value: 'theoreticalOutputValue', align: 'center', required: true, type: 'text' },
  {
    text: '第一次',
    value: 'firstStroke',
    align: 'center',
    required: true,
    width: '180',
    children: [
      { text: '正行程', value: 'firstForwardStroke', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '反行程', value: 'firstReverseStroke', align: 'center', required: true, width: '180', type: 'inputNumber' },
    ],
  },
  {
    text: '第二次',
    value: 'secondStroke',
    align: 'center',
    required: true,
    width: '180',
    children: [
      { text: '正行程', value: 'secondForwardStroke', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '反行程', value: 'secondReverseStroke', align: 'center', required: true, width: '180', type: 'inputNumber' },
    ],
  },
  {
    text: '第三次',
    value: 'thirdStroke',
    align: 'center',
    required: true,
    width: '180',
    children: [
      { text: '正行程', value: 'thirdForwardStroke', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '反行程', value: 'thirdReverseStroke', align: 'center', required: true, width: '180', type: 'inputNumber' },
    ],
  },
  { text: '示值误差', value: 'indicatingError', align: 'center', required: false, type: 'text' },
  { text: '回程误差', value: 'returnError', align: 'center', required: false, type: 'text' },
])
const result_columns_digitalMultimeterTable = ref([ // 压力变送器结果表格
  { text: '最大误差', value: 'maxIndicatingError', align: 'center', required: true, type: 'text' },
  { text: '示值误差允许值', value: 'indicatingError', align: 'center', required: true, type: 'text' },
  { text: '最大回差', value: 'maxReturnError', align: 'center', required: true, type: 'text' },
  { text: '回差(允许回差)', value: 'returnError', align: 'center', required: true, type: 'text' },
])
const columns_pressureSensor = ref([ // 压力传感器
  { text: '标准器示值', value: 'indicatingValue', align: 'center', required: true, type: 'text' },
  { text: '理论输出值', value: 'theoreticalOutputValue', align: 'center', required: true, type: 'text' },
  {
    text: '第一次',
    value: 'firstStroke',
    align: 'center',
    required: true,
    width: '180',
    children: [
      { text: '正行程', value: 'firstForwardStroke', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '反行程', value: 'firstReverseStroke', align: 'center', required: true, type: 'inputNumber' },
    ],
  },
  {
    text: '第二次',
    value: 'secondStroke',
    align: 'center',
    required: true,
    width: '180',
    children: [
      { text: '正行程', value: 'secondForwardStroke', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '反行程', value: 'secondReverseStroke', align: 'center', required: true, width: '180', type: 'inputNumber' },
    ],
  },
  {
    text: '第三次',
    value: 'thirdStroke',
    align: 'center',
    required: true,
    width: '180',
    children: [
      { text: '正行程', value: 'thirdForwardStroke', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '反行程', value: 'thirdReverseStroke', align: 'center', required: true, width: '180', type: 'inputNumber' },
    ],
  },
  { text: '正行程平均值', value: 'averageForwardStroke', align: 'center', required: true, type: 'text' },
  { text: '反行程平均值', value: 'averageReverseStroke', align: 'center', required: true, type: 'text' },
  { text: '平均值', value: 'averageValue', align: 'center', required: true, type: 'text' },
  { text: '回差平均值ΔyHi', value: 'averageReturnError', align: 'center', required: true, type: 'text' },
])
// 电接点一般压力表设定点偏差及切换差表格
const columns_electricContact = ref([
  { text: '标准器示值', value: 'indicatingValue', align: 'center', required: true, width: '120' },
  { text: '正行程切换值', width: '180', value: 'forwardStrokeSwitchValue', align: 'center', required: true },
  { text: '反行程切换值', width: '180', value: 'reverseStrokeSwitchValue', align: 'center', required: true },
  { text: '设定点偏差', value: 'pointDeviation', align: 'center', required: false, width: '120' },
  { text: '切换差', value: 'differentGap', align: 'center', required: false, width: '120' },
])

// 电接点一般压力表设定点偏差及切换差表格--结果表格
const result_columns_electricContact = ref([
  { text: '最大设定点偏差绝对值', value: 'maxPointDeviation', align: 'center', required: true, width: '120' },
  { text: '允许设定点偏差绝对值', value: 'allowPointDeviation', align: 'center', required: true, width: '120' },
  { text: '最大切换差', value: 'maxDifferentGap', align: 'center', required: true, width: '120' },
  { text: '允许切换差', value: 'allowDifferentGap', align: 'center', required: true, width: '120' },
])
const columns_digitalPressureGauge = ref([ // 数字压力计
  { text: '标准器示值', value: 'indicatingValue', align: 'center', required: true, type: 'text' },
  {
    text: '第一次',
    value: 'firstStroke',
    align: 'center',
    required: true,
    width: '180',
    children: [
      { text: '正行程', value: 'firstForwardStroke', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '反行程', value: 'firstReverseStroke', align: 'center', required: true, width: '180', type: 'inputNumber' },
    ],
  },
  {
    text: '第二次',
    value: 'secondStroke',
    align: 'center',
    required: true,
    width: '180',
    children: [
      { text: '正行程', value: 'secondForwardStroke', align: 'center', required: true, width: '180', type: 'inputNumber' },
      { text: '反行程', value: 'secondReverseStroke', align: 'center', required: true, width: '180', type: 'inputNumber' },
    ],
  },
  { text: '示值误差', value: 'indicatingError', align: 'center', required: true, type: 'text' },
  { text: '正行程平均值', value: 'averageForwardStroke', align: 'center', required: true, type: 'text' },
  { text: '反行程平均值', value: 'averageReverseStroke', align: 'center', required: true, type: 'text' },
  { text: '回程误差', value: 'returnError', align: 'center', required: true, type: 'text' },
])

const columns_zeroDriftResult = ref([ // 零位飘逸表头
  { text: 'min', value: 'min', align: 'center', required: true },
  { text: '0', value: 'zeroDriftOne', align: 'center', required: true },
  { text: '15', value: 'zeroDriftTwo', align: 'center', required: true },
  { text: '30', value: 'zeroDriftThree', align: 'center', required: true },
  { text: '45', value: 'zeroDriftFour', align: 'center', required: true },
  { text: '60', value: 'zeroDriftFive', align: 'center', required: true },
])
const zeroDriftResultList = ref([]) as any // 数字压力计零位漂移表格
// 数字压力计结果表格
const result_columns_digitalPressureGauge = ref([
  { text: '示值误差允许值', value: 'indicatingError', align: 'center', required: true, type: 'text' },
  { text: '示值误差最大值', value: 'maxIndicatingError', align: 'center', required: true, type: 'text' },
  { text: '回程误差允许值', value: 'returnError', align: 'center', required: true, type: 'text' },
  { text: '回程误差最大值', value: 'maxReturnError', align: 'center', required: true, type: 'text' },
])
// -------------------------------------------获取详情信息--------------------------------------------------
// 获取页面详情信息
const fetchInfo = async () => {
  const loading = ElLoading.service({
    lock: true,
    background: 'rgba(255, 255, 255, 0.8)',
  })
  const res = await getInfo({
    id: infoId.value,
    belongStandardEquipment: itemFormData.value.belongStandardEquipment,
    // 我的任务跳转过来如果已经配置过检定项了,到编辑页面,且用一下三个字段替代传id请求详情
    itemId: $route.query.itemId, // 检定项id
    orderId: $route.query.orderId, // 任务单id
    sampleId: $route.query.sampleId, // 被检设备id
  })
  // 有关于检定项的数据
  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.appearanceRemark = res.data.appearanceRemark // 外观备注说明
  itemFormData.value.pointerDeflectionStability = `${res.data.pointerDeflectionStability}` // 指针偏转平稳性
  itemFormData.value.pointerDeflectionStabilityRemark = res.data.pointerDeflectionStabilityRemark // 指针偏转平稳性备注说明
  itemFormData.value.tightness = `${res.data.tightness}` // 密封性
  itemFormData.value.tightnessRemark = res.data.tightnessRemark // 密封性备注说明
  itemFormData.value.zeroDriftResult = res.data.zeroDriftResult // 零位飘移结果(合格/不合格,直接存文字)
  itemFormData.value.insulationResistance = `${res.data.insulationResistance}`//	绝缘电阻
  itemFormData.value.insulationResistanceRemark = res.data.insulationResistanceRemark //	绝缘电阻备注说明-0.02活塞式压力计
  itemFormData.value.remark = res.data.remark // 备注
  // =======================================表单公共组件数据处理=======================================================
  useSolveFormData(res, templateFormAndTableRef.value)
  // ==================================检定数据========================================================================

  const responseList = res.data.measureDataPistonGaugeList.map((item: IDetailMeasureList) => {
    return {
      ...item,
      editable: pageType.value !== 'detail',
    }
  }) // 检定数据
  if (itemFormData.value.itemCategoryName === '电接点一般压力表') {
    list.value = responseList.filter((item: { dataCategory: string; dataType: string }) => item.dataType !== '2')
    listElectricContact.value = responseList.filter((item: { dataCategory: string; dataType: string }) => item.dataType === '2')
  }
  else {
    list.value = responseList
    if (itemFormData.value.itemCategoryName === '数字压力计') {
      zeroDriftResultList.value.push({
        min: '示值',
        zeroDriftFive: responseList[0].zeroDriftFive,
        zeroDriftFour: responseList[0].zeroDriftFour,
        zeroDriftOne: responseList[0].zeroDriftOne,
        zeroDriftThree: responseList[0].zeroDriftThree,
        zeroDriftTwo: responseList[0].zeroDriftTwo,
      })
    }
  }
  infoId.value = res.data.id
  emits('giveInfoId', infoId.value)
  loading.close()
}
// 初始化输入数据
const initInputData = (data: any) => {
  if (itemFormData.value.itemCategoryName === '一般压力表' || itemFormData.value.itemCategoryName === '精密压力表') {
    list.value = data.map((item: IDetailMeasureList) => {
      return {
        id: '',
        afterFrictionForwardStroke: item.indicatingValue, //	轻敲后被检设备示值-正行程
        afterFrictionReverseStroke: item.indicatingValue, //	轻敲后被检设备示值-反行程
        beforeFrictionForwardStroke: item.indicatingValue, //	轻敲前被检设备示值-正行程
        beforeFrictionReverseStroke: item.indicatingValue, //	轻敲前被检设备示值-反行程
        indicatingValue: item.indicatingValue,	// 标准器示值
        variationForwardStroke: 0,		//	轻敲前后变动量-正行程 公式:轻敲后(正行程)-轻敲前(正行程)所以初始的时候为0
        variationReverseStroke: 0,		//	轻敲前后变动量-反行程 公式:轻敲后(反行程)-轻敲前(反行程)
        editable: pageType.value !== 'detail',
        indicatingError: item.indicatingError,	// 示值误差
        returnError: item.returnError,	// 回程误差、回程误差允许值
        frictionError: item.frictionError, // 轻敲位移允许值
      }
    }) // 检定项表格
  }
  else if (itemFormData.value.itemCategoryName === '电接点一般压力表') {
    list.value = data.map((item: IDetailMeasureList) => {
      return {
        id: '',
        afterFrictionForwardStroke: item.indicatingValue, //	轻敲后被检设备示值-正行程
        afterFrictionReverseStroke: item.indicatingValue, //	轻敲后被检设备示值-反行程
        beforeFrictionForwardStroke: item.indicatingValue, //	轻敲前被检设备示值-正行程
        beforeFrictionReverseStroke: item.indicatingValue, //	轻敲前被检设备示值-反行程
        indicatingValue: item.indicatingValue,	// 标准器示值
        variationForwardStroke: 0,		//	轻敲前后变动量-正行程 公式:轻敲后(正行程)-轻敲前(正行程)所以初始的时候为0
        variationReverseStroke: 0,		//	轻敲前后变动量-反行程 公式:轻敲后(反行程)-轻敲前(反行程)
        editable: pageType.value !== 'detail',
        indicatingError: item.indicatingError,	// 示值误差
        returnError: item.returnError,	// 回程误差、回程误差允许值
        frictionError: item.frictionError, // 轻敲位移允许值
        forwardStrokeSwitchValue: 0, // 正行程切换值
        reverseStrokeSwitchValue: 0, // 反行程切换值
      }
    }) // 检定项表格
    listElectricContact.value = list.value
  }
  else if (itemFormData.value.itemCategoryName === '压力变送器' || itemFormData.value.itemCategoryName === '压力传感器') {
    list.value = data.map((item: IDetailMeasureList) => {
      return {
        id: '',
        indicatingValue: item.indicatingValue,	// 标准器示值
        theoreticalOutputValue: item.theoreticalOutputValue,	// 理论输出值
        firstForwardStroke: '', //	第一次正行程
        firstReverseStroke: '', //	第一次反行程
        secondForwardStroke: '',	// 第二次正行程
        secondReverseStroke: '',	// 第二次反行程
        thirdForwardStroke: '',		// 第三次正行程
        thirdReverseStroke: '',		//	第三次反行程
        indicatingError: '',	// 示值误差
        returnError: '',	// 回程误差
        editable: pageType.value !== 'detail',
      }
    }) // 检定项表格
  }
  else if (itemFormData.value.itemCategoryName === '数字压力计') {
    zeroDriftResultList.value = [{
      min: data.length ? data[0].indicatingValue : '',	// 标准器示值
      zeroDriftOne: '',	// 0
      zeroDriftTwo: '',	// 15
      zeroDriftThree: '',	// 30
      zeroDriftFour: '',	// 45
      zeroDriftFive: '',	// 60
    }]
    list.value = data.map((item: IDetailMeasureList) => {
      return {
        id: '',
        indicatingValue: item.indicatingValue,	// 标准器示值
        firstForwardStroke: '', //	第一次正行程
        firstReverseStroke: '', //	第一次反行程
        secondForwardStroke: '',	// 第二次正行程
        secondReverseStroke: '',	// 第二次反行程
        thirdForwardStroke: '',		// 第三次正行程
        thirdReverseStroke: '',		//	第三次反行程
        maxIndicatingError: '',	// 示值误差最大值
        averageForwardStroke: '',	// 正行程平均值
        averageReverseStroke: '',	// 反行程平均值
        maxReturnError: '',	// 回程误差最大值
        editable: pageType.value !== 'detail',
      }
    }) // 检定项表格
  }
}

/**
 * 新增的时候获取检定项输入数据(获取检定项分类详情)
 * @param itemId  检定项id
 * @param itemCategoryName 检定项分类名字
 * @param belongStandardEquipment 检校标准装置字典
 */
const fetchItemInfo = async (itemId: string, itemCategoryName: string, belongStandardEquipment = '', solveList = '') => {
  const params = {
    id: itemId,
    itemCategoryName, // 检定项分类名字
    belongStandardEquipment, // 检校标准装置字典code
  }
  const res = await getItemInfo(params)
  measureItemConfigPistonGauge.value = res.data.measureItemConfigPistonGauge // 输入配置
  itemFormData.value.pointerDeflectionStability = res.data.measureItemConfigPistonGauge.pointerDeflectionStability ? '1' : '' // 指针偏转平稳性
  itemFormData.value.tightness = res.data.measureItemConfigPistonGauge.tightness ? '1' : '' // 密封性
  itemFormData.value.insulationResistance = res.data.measureItemConfigPistonGauge.insulationResistance ? '1' : '' // 绝缘电阻
  itemFormData.value.insulationResistance = res.data.measureItemConfigPistonGauge.insulationResistance ? '1' : '' // 绝缘电阻
  itemFormData.value.appearance = res.data.measureItemConfigPistonGauge.appearance ? '1' : '' // 外观及功能检查 1有外观,2没有外观
  itemFormData.value.supplyVoltage = res.data.measureItemConfigPistonGauge.supplyVoltage // 供电电压
  if (solveList !== 'notNeedList') {
    initInputData(res.data.measureItemDataPistonGaugeList)
  }
  // 处理压力变送器的理论输出值单位
  if (itemFormData.value.itemCategoryName === '压力变送器' && res.data.measureItemDataPistonGaugeList.length) {
    measureItemConfigPistonGauge.value.theoreticalOutputValueUnit = res.data.measureItemDataPistonGaugeList[0].theoreticalOutputValueUnit
  }
  inputList.value = res.data.measureItemDataPistonGaugeList.map((item: { is90Upper: number; indicatingValue: string }) => {
    return {
      ...item,
      // 是否是量程上线90%以上:标准器示值 >(量程上限 - 量程下限)* 90%
      // 是否是量程上线90%以下:标准器示值 <(量程上限 - 量程下限)* 90%
      is90Upper: calc(Number(calc(measureItemConfigPistonGauge.value.rangeUpper, measureItemConfigPistonGauge.value.rangeLower, '-')), 0.9, '*') < Number(item.indicatingValue),
    }
  }) // 记录配置项
  itemFormData.value.cycleNumber = res.data.measureItemConfigPistonGauge.cycleNumber // 循环次数
}

// ----------------------------------------点击保存时校验---------------------------------------
// 校验
const checkout = () => {
  if (`${itemFormData.value.appearance}` === '0' && !itemFormData.value.appearanceRemark) { // 不合格需要验证外观说明
    ElMessage.warning('外观备注说明不能为空')
  }

  // 保存时不做空校验
  // if (!list.value.length) {
  //   ElMessage.warning('示值误差、回程误差、轻敲位移不能为空')
  //   return false
  // }
  // if (!resultList.value) {
  //   ElMessage.warning('结果不能为空,请点击生成结果处理')
  //   return false
  // }
  // if (itemFormData.value.itemCategoryName === '电接点一般压力表') {
  //   if (!listElectricContact.value.length) {
  //     ElMessage.warning('设定点偏差及切换差不能为空')
  //     return false
  //   }
  //   if (!resultListElectricContact.value) {
  //     ElMessage.warning('设定点偏差及切换差 结果 不能为空,请点击生成结果处理')
  //     return false
  //   }
  // }
  if (itemFormData.value.itemCategoryName === '数字压力计') {
    if (!useCheckList(zeroDriftResultList.value, columns_zeroDriftResult.value, '零位漂移')) {
      return false
    }
  }
  return true
}
// -----------------------------------------生成结果处理----------------------------------------
// 处理结果表格--一般压力表、电接点一般压力表
const solveResultData = () => {
  if (!resultList.value.length) { return resultList.value }
  const rangeUpperList = resultList.value.filter((item: IDetailMeasureList) => item.item === '量程上限90%以上')
  const rangeLowerList = resultList.value.filter((item: IDetailMeasureList) => item.item === '量程上限90%以下')
  const inputUpperList = inputList.value.filter((item: { is90Upper: boolean }) => item.is90Upper === true)
  const inputLowerList = inputList.value.filter((item: { is90Upper: boolean }) => item.is90Upper === false)
  if (rangeUpperList.length && inputUpperList.length) { // 量程上线90%以上
    console.log('量程上限90%以上', inputUpperList)
    resultList.value = resultList.value.map((item: IDetailMeasureList) => {
      if (item.item === '量程上限90%以上') {
        item.indicatingError = inputUpperList[0].indicatingError	// 示值误差
        item.returnError = inputUpperList[0].returnError	// 回程误差、回程误差允许值
        item.frictionError = inputUpperList[0].frictionError // 轻敲位移允许值
      }
      return item
    }) // 检定数据
  }

  if (rangeLowerList.length && inputLowerList.length) { // 量程上线90%以下
    console.log('量程上限90%以下', inputLowerList)
    resultList.value = resultList.value.map((item: IDetailMeasureList) => {
      if (item.item === '量程上限90%以下') {
        item.indicatingError = inputLowerList[0].indicatingError	// 示值误差
        item.returnError = inputLowerList[0].returnError	// 回程误差、回程误差允许值
        item.frictionError = inputLowerList[0].frictionError // 轻敲位移允许值
      }
      return item
    }) // 检定数据
  }
}

/**
 * 点击生成结果处理
 * @param type bottomTable下面表格的计算结果
 * dataCategoryParam 检定数据类别(1检定数据,2计算结果表数据(对应取注释带(结果表)的数据))
 */
const createResult = (type = '') => {
  if (type !== 'bottomTable' && !list.value.length) {
    ElMessage.warning('没有 示值误差、回程误差、轻敲位移 检定项数据,无法生成结果')
    return false
  }
  // ======================在这里要校验上面表格不能的字段不能为空===========
  // ===================================================================
  // ==================================================================
  // if (!useCheckList(list.value, measureColumns.value, '检定数据')) {
  //   return false
  // }
  // 校验数字压力计零位漂移
  if (itemFormData.value.itemCategoryName === '数字压力计') {
    if (!useCheckList(zeroDriftResultList.value, columns_zeroDriftResult.value, '零位漂移')) {
      return false
    }
    else {
    // 计算零位漂移结果:零位漂移合格判断依据:min0为示值基础值,min15、30、45、60的示值与mn0进行差值对比,差值小于等于最大允许误差绝对值(回程误差允许值:为最大允许误差绝对值(不带±))的1/2为合格
      itemFormData.value.zeroDriftResult = useZeroDriftResult(zeroDriftResultList.value[0].zeroDriftOne, zeroDriftResultList.value[0].zeroDriftTwo, zeroDriftResultList.value[0].zeroDriftThree, zeroDriftResultList.value[0].zeroDriftFour, zeroDriftResultList.value[0].zeroDriftFive, inputList.value[0].returnError)
    }
  }
  if (type === 'bottomTable') {
    if (!listElectricContact.value.length) {
      ElMessage.warning('没有 设定点偏差及切换差 检定项数据,无法生成结果')
      return false
    }
    if (!useCheckList(listElectricContact.value, columns_electricContact.value, '设定点偏差及切换差')) {
      return false
    }
  }
  // ===========================loading处理===========================================
  tableLoadingTop.value = itemFormData.value.itemCategoryName !== '电接点一般压力表'
  if (itemFormData.value.itemCategoryName === '压力传感器' || itemFormData.value.itemCategoryName === '压力变送器' || itemFormData.value.itemCategoryName === '数字压力计') {
    pressureSensorTableLoading.value = true
  }
  // 电接点一般压力表区分上下结果表格loading
  else if (itemFormData.value.itemCategoryName === '电接点一般压力表') {
    if (type === 'bottomTable') { // 下面表格的计算
      tableLoadingBottom.value = true
    }
    else { // 上面表格计算
      tableLoadingTop.value = true
    }
  }
  // =================================================================================
  let tempMeasureDataPistonGaugeList = list.value.map((item, index) => {
    return {
      ...item,
      workLineEquation: itemFormData.value.workLineEquation, // 工作直线方程(压力传感器)
      dataType: '1', // 电接点一般压力表计算上面表格字段
    }
  }) as any
  if (type === 'bottomTable') {
    tempMeasureDataPistonGaugeList = listElectricContact.value.map((item) => {
      return {
        ...item,
        dataType: '2', // 电接点一般压力表计算下面表格字段
      }
    })
  }
  const params = {
    belongStandardEquipment: itemFormData.value.belongStandardEquipment, // 检校标准装置
    itemCategoryName: itemFormData.value.itemCategoryName, // 检定项分类名称
    measureDataPistonGaugeList: tempMeasureDataPistonGaugeList,
    measureItemConfigPistonGauge: measureItemConfigPistonGauge.value, // 输入配置
  }

  calculateHandle(params).then((res) => {
    if (res.data && res.data.length) {
      if (itemFormData.value.itemCategoryName === '一般压力表' || itemFormData.value.itemCategoryName === '精密压力表' || itemFormData.value.itemCategoryName === '电接点一般压力表') {
        if (type !== 'bottomTable') { // 电接点一般压力表的第二表格计算不去处理第一表格的数据
          const responseList = res.data.filter((item: { dataCategory: string }) => item.dataCategory === '2')
          resultList.value = responseList
        }
        if (itemFormData.value.itemCategoryName === '一般压力表') {
          // 处理量程上限90%以上、量程上限90%以上以下的数据
          solveResultData()
        }
        else if (itemFormData.value.itemCategoryName === '精密压力表') {
          resultList.value = resultList.value.map((item: IDetailMeasureList) => {
            item.indicatingError = inputList.value[0].indicatingError	// 示值误差
            item.returnError = inputList.value[0].returnError	// 回程误差、回程误差允许值
            item.frictionError = inputList.value[0].frictionError // 轻敲位移允许值
            return item
          }) // 检定数据
        }
        else if (itemFormData.value.itemCategoryName === '电接点一般压力表') {
          if (type === 'bottomTable') { // 下面表格计算
            listElectricContact.value = res.data.filter((item: { dataCategory: string }) => item.dataCategory !== '2')
            listElectricContact.value = listElectricContact.value.map((item) => {
              return {
                ...item,
                editable: pageType.value !== 'detail',
              }
            })
            resultListElectricContact.value = res.data.filter((item: { dataCategory: string }) => item.dataCategory === '2')
            // 找到输入配置量程90以下数据
            const inputLowerList = inputList.value.filter((item: { is90Upper: boolean }) => item.is90Upper === false)
            resultListElectricContact.value = resultListElectricContact.value.map((item: IDetailMeasureList) => {
              if (inputLowerList.length) {
                item.allowPointDeviation = inputLowerList[0].indicatingError 	// 允许设定点偏差绝对值--允许设定点偏差绝对值
                item.indicatingError = inputLowerList[0].indicatingError 	// 允许设定点偏差绝对值--允许设定点偏差绝对值
                item.returnError = inputLowerList[0].returnError	// 允许切换差--量程上限90%以下回程误差允许值
                item.allowDifferentGap = inputLowerList[0].returnError	// 允许切换差--量程上限90%以下回程误差允许值
              }
              return item
            }) // 检定数据
            // =====================电接点一般压力第二结果判断===========
            const result = resultListElectricContact.value.every((item: any) => {
              return Number(item.maxPointDeviation) <= Number(item.allowPointDeviation)
                && Number(item.maxDifferentGap) <= Number(item.allowDifferentGap)
            })
            itemFormData.value.otherOutcome = result ? '合格' : '不合格' // 第二结果
          }
          else { // 上面表格计算
            console.log('9999999', resultList.value)
            // 处理量程上限90%以上、量程上限90%以上以下的数据
            solveResultData()
          }
        }

        // ==================第一结果判断====================
        // 判断结果:示值误差最大值、轻敲位移最大值、回程误差最大值均在允许值内,则合格,否则不合格。
        const result = resultList.value.every((item) => {
          return Number(item.maxIndicatingError) <= Number(item.indicatingError!.slice(1))
                && Number(item.maxFrictionError) <= Number(item.frictionError)
                && Number(item.maxReturnError) <= Number(item.returnError)
        })
        itemFormData.value.outcome = result ? '合格' : '不合格'
      }
      else if (itemFormData.value.itemCategoryName === '压力变送器') {
        list.value = res.data.filter((item: { dataCategory: string }) => item.dataCategory !== '2')
        list.value = list.value.map((item) => {
          return {
            ...item,
            editable: pageType.value !== 'detail',
          }
        })
        const responseList = res.data.filter((item: { dataCategory: string }) => item.dataCategory === '2')
        resultList.value = responseList
        resultList.value = resultList.value.map((item: IDetailMeasureList) => {
          item.indicatingError = inputList.value[0].indicatingError	// 示值误差
          item.returnError = inputList.value[0].returnError	// 回程误差、回程误差允许值
          return item
        }) // 检定数据
        // 判断结果:示值误差最大值、回程误差最大值均在允许值内,则合格,否则不合格。
        const result = resultList.value.every((item) => {
          return Number(item.maxIndicatingError) <= Number(item.indicatingError!.slice(1))
                && Number(item.maxReturnError) <= Number(item.returnError)
        })
        itemFormData.value.outcome = result ? '合格' : '不合格'
      }
      else if (itemFormData.value.itemCategoryName === '压力传感器') {
        const responseList = res.data.filter((item: { dataCategory: string }) => `${item.dataCategory}` !== '2')
        list.value = responseList.map((item: { editable: boolean }) => {
          return {
            ...item,
            editable: pageType.value !== 'detail',
          }
        })
        const resFormData = res.data.filter((item: { dataCategory: string }) => `${item.dataCategory}` === '2')
        if (resFormData.length) {
          itemFormData.value.interceptA = resFormData[0].interceptA // 截距a
          itemFormData.value.slopeB = resFormData[0].slopeB // 斜率b
          itemFormData.value.sensitivityB = resFormData[0].sensitivityB // 灵敏度b
          itemFormData.value.repeatabilityR = resFormData[0].repeatabilityR // 重复性ξR
          itemFormData.value.hysteresisH = resFormData[0].hysteresisH // 迟滞ξH
          itemFormData.value.linearL = resFormData[0].linearL // 线性ξL
          itemFormData.value.basicErrorA = resFormData[0].basicErrorA // 基本误差A
          itemFormData.value.periodicStabilitySB = resFormData[0].periodicStabilitySB // 周期稳定性Sb
        }
      }
      else if (itemFormData.value.itemCategoryName === '数字压力计') {
        const responseList = res.data.filter((item: { dataCategory: string }) => `${item.dataCategory}` !== '2')
        list.value = responseList.map((item: { editable: boolean }) => {
          return {
            ...item,
            editable: pageType.value !== 'detail',
          }
        })
        const responseResultList = res.data.filter((item: { dataCategory: string }) => `${item.dataCategory}` === '2')
        resultList.value = responseResultList.map((item: IDetailMeasureList) => {
          item.indicatingError = inputList.value[0].indicatingError	// 示值误差
          item.returnError = inputList.value[0].returnError	// 回程误差、回程误差允许值
          return item
        }) // 检定数据
        // 判断结果:示值误差最大值、回程误差最大值均在允许值内,则合格,否则不合格。
        const result = resultList.value.every((item) => {
          return Number(item.maxIndicatingError) <= Number(item.indicatingError!.slice(1))
                && Number(item.maxReturnError) <= Number(item.returnError)
        })
        itemFormData.value.outcome = result ? '合格' : '不合格'
      }
    }
    else {
      list.value = res.data
    }
    tableLoadingTop.value = false
    pressureSensorTableLoading.value = false
    tableLoadingBottom.value = false
  }).catch(() => {
    tableLoadingTop.value = false
    pressureSensorTableLoading.value = false
    tableLoadingBottom.value = false
  })
}

// -------------------------------------------处理表格函数---------------------------------------
// el-input-number组件值变化
const handleInputNumberChange = ({ row }: any) => {
  if (itemFormData.value.itemCategoryName === '一般压力表' || itemFormData.value.itemCategoryName === '精密压力表' || itemFormData.value.itemCategoryName === '电接点一般压力表') {
    row.variationForwardStroke = calc(row.afterFrictionForwardStroke, row.beforeFrictionForwardStroke, '-')		//	轻敲前后变动量-正行程 公式:轻敲后(正行程)-轻敲前(正行程)所以初始的时候为0
    row.variationReverseStroke = calc(row.afterFrictionReverseStroke, row.beforeFrictionReverseStroke, '-')		//	轻敲前后变动量-正行程 公式:轻敲后(正行程)-轻敲前(正行程)所以初始的时候为0
  }
}

// 压力变送器复制
const copy = () => {
  console.log('点击复制')
  list.value = list.value.map((item: IDetailMeasureList) => {
    return {
      ...item,
      indicatingValue: item.indicatingValue,	// 标准器示值
      theoreticalOutputValue: item.theoreticalOutputValue,	// 理论输出值
      firstForwardStroke: item.firstForwardStroke, //	第一次正行程
      firstReverseStroke: item.firstReverseStroke, //	第一次反行程
      secondForwardStroke: item.firstForwardStroke,	// 第二次正行程
      secondReverseStroke: item.firstReverseStroke,	// 第二次反行程
      thirdForwardStroke: item.firstForwardStroke,		// 第三次正行程
      thirdReverseStroke: item.firstReverseStroke,		//	第三次反行程
      indicatingError: '',	// 示值误差
      returnError: '',	// 回程误差
      editable: pageType.value !== 'detail',
    }
  }) // 检定项表格
}

// -------------------------------------压力传感器--------------------------------------------------
// 获取上一周期灵敏度
const fetchSlopeB = () => {
  getSlopeB({ eqptEquipmentId: eqptEquipmentId.value }).then((res) => {
    itemFormData.value.lastCycleSensitivity = res.data || '/' // 上一周期灵敏度b0
  })
}

// ------------------------------------------钩子----------------------------------------------
watch(() => itemFormData.value.itemCategoryName, (newValue) => {
  console.log(newValue, 'itemCategoryName.value')

  if (newValue) {
    switch (newValue) {
      case '一般压力表':
        measureColumns.value = columns_generalPurposegauge.value
        break
      case '精密压力表':
        measureColumns.value = columns_generalPurposegauge.value
        break
      case '电接点一般压力表':
        measureColumns.value = columns_generalPurposegauge.value
        break
      case '压力变送器':
        if (itemFormData.value.cycleNumber === 1) {
          measureColumns.value = columns_digitalMultimeterTable.value.filter((item, index) => index !== 3 && index !== 4)
        }
        else if (itemFormData.value.cycleNumber === 2) {
          measureColumns.value = columns_digitalMultimeterTable.value.filter((item, index) => index !== 4)
        }
        else {
          measureColumns.value = columns_digitalMultimeterTable.value
        }
        break
      case '压力传感器':
        if (itemFormData.value.cycleNumber === 1) {
          measureColumns.value = columns_pressureSensor.value.filter((item, index) => index !== 3 && index !== 4)
        }
        else if (itemFormData.value.cycleNumber === 2) {
          measureColumns.value = columns_pressureSensor.value.filter((item, index) => index !== 4)
        }
        else {
          measureColumns.value = columns_pressureSensor.value
        }
        break
      case '数字压力计':
        measureColumns.value = columns_digitalPressureGauge.value
        break
      default:
        break
    }
  }
}, { immediate: true, deep: true })

watch(() => props.infoId, (newValue) => {
  if (newValue) {
    infoId.value = newValue
    if (pageType.value === 'detail' && itemFormData.value.belongStandardEquipment) {
      fetchInfo()
    }
  }
}, { immediate: true })

onMounted(() => {
  eqptEquipmentId.value = $route.query.sampleId as string // 受检设备id
  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 (pageType.value === '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, 'notNeedList')
    fetchInfo().then(() => {
      createResult()
      if (itemFormData.value.itemCategoryName === '电接点一般压力表') {
        createResult('bottomTable')
      }
    }) // 获取页面详情信息
  }
  // 获取上一周期灵敏度b0
  if (itemFormData.value.itemCategoryName === '压力传感器') {
    fetchSlopeB()
  }
})
// 监听页面类型
watch(() => pageType.value, (newValue) => {
  console.log('页面类型', newValue)
  list.value = list.value.map((item) => {
    return {
      ...item,
      editable: newValue !== 'detail',
    }
  })
})

defineExpose({
  measureItemConfigPistonGauge,
  checkout,
  zeroDriftResultList,
  itemFormData,
  list,
  resultList,
  listElectricContact,
  resultListElectricContact,
  templateFormAndTableRef,
  pageType,
})
</script>

<template>
  <template-form-and-table ref="templateFormAndTableRef" :page-type="pageType" />
  <!-- 标签 -->
  <detail-block :title="pageType !== 'detail' ? '检定数据' : ''" :class="pageType === 'detail' ? 'setBottom' : ''">
    <el-radio-group v-if="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="120"
      label-position="right"
      style="margin-top: 20px;"
    >
      <el-row>
        <!-- 外观  -->
        <el-col :span="8">
          <el-form-item label="外观:" prop="appearance">
            <el-radio-group v-model="itemFormData.appearance" :disabled="pageType === 'detail'">
              <el-radio label="1">
                合格
              </el-radio>
              <el-radio label="0">
                不合格
              </el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col v-if="`${itemFormData.appearance}` === '0'" :span="12">
          <el-form-item label="备注说明:" prop="appearanceRemark">
            <el-input
              v-model="itemFormData.appearanceRemark"
              class="full-width-input"
              :placeholder="pageType === 'detail' ? ' ' : '外观备注说明'"
              autosize
              type="textarea"
              :disabled="pageType === 'detail'"
            />
          </el-form-item>
        </el-col>
        <!-- 指针偏转平稳性 -->
        <el-col v-if="itemFormData.pointerDeflectionStability" :span="8">
          <el-form-item label="指针偏转平稳性:" prop="pointerDeflectionStability">
            <el-radio-group v-model="itemFormData.pointerDeflectionStability" :disabled="pageType === 'detail'">
              <el-radio label="1">
                合格
              </el-radio>
              <el-radio label="0">
                不合格
              </el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col v-if="`${itemFormData.pointerDeflectionStability}` === '0'" :span="12">
          <el-form-item label="备注说明:" prop="pointerDeflectionStabilityRemark">
            <el-input
              v-model="itemFormData.pointerDeflectionStabilityRemark"
              class="full-width-input"
              :placeholder="pageType === 'detail' ? ' ' : '指针偏转平稳性备注说明'"
              autosize
              type="textarea"
              :disabled="pageType === 'detail'"
            />
          </el-form-item>
        </el-col>
        <!-- 密封性  -->
        <el-col v-if="itemFormData.tightness" :span="8">
          <el-form-item label="密封性:" prop="tightness">
            <el-radio-group v-model="itemFormData.tightness" :disabled="pageType === 'detail'">
              <el-radio label="1">
                合格
              </el-radio>
              <el-radio label="0">
                不合格
              </el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col v-if="`${itemFormData.tightness}` === '0'" :span="12">
          <el-form-item label="备注说明:" prop="tightnessRemark">
            <el-input
              v-model="itemFormData.tightnessRemark"
              class="full-width-input"
              :placeholder="pageType === 'detail' ? ' ' : '密封性备注说明'"
              autosize
              type="textarea"
              :disabled="pageType === 'detail'"
            />
          </el-form-item>
        </el-col>
        <!-- 绝缘电阻 -->
        <el-col v-if="itemFormData.insulationResistance" :span="8">
          <el-form-item label="绝缘电阻:" prop="insulationResistance">
            <el-radio-group v-model="itemFormData.insulationResistance" :disabled="pageType === 'detail'">
              <el-radio label="1">
                合格
              </el-radio>
              <el-radio label="0">
                不合格
              </el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col v-if="`${itemFormData.insulationResistance}` === '0'" :span="12">
          <el-form-item label="备注说明:" prop="insulationResistanceRemark">
            <el-input
              v-model="itemFormData.insulationResistanceRemark"
              class="full-width-input"
              :placeholder="pageType === 'detail' ? ' ' : '绝缘电阻备注说明'"
              autosize
              type="textarea"
              :disabled="pageType === 'detail'"
            />
          </el-form-item>
        </el-col>
      </el-row>

      <!-- =================数字压力计零位飘逸============================================= -->
      <div v-if="current === 'measure-data' && itemFormData.itemCategoryName === '数字压力计'" style="width: 100%;display: flex;align-items: center;">
        <div style="font-size: 14px;color: #606266;padding: 0 20px 20px 0;font-weight: 600;">
          零位漂移:
        </div>
        <el-form
          v-if="current === 'measure-data' && itemFormData.itemCategoryName === '数字压力计'"
          ref="formRef"
          :model="itemFormData"
          label-width="120"
          label-position="right"
          style="width: 520px;"
        >
          <el-row :gutter="24">
            <el-col :span="12">
              <el-form-item label="零位漂移结果:" prop="zeroDriftResult">
                <el-input
                  v-model="itemFormData.zeroDriftResult"
                  class="full-width-input"
                  disabled
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <el-table
        v-show="current === 'measure-data' && itemFormData.itemCategoryName === '数字压力计'"
        ref="tableRef"
        :data="zeroDriftResultList"
        border
        style="margin-bottom: 20px;"
      >
        <el-table-column align="center" label="序号" width="80" type="index" />
        <el-table-column
          v-for="item in columns_zeroDriftResult"
          :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 v-if="pageType !== 'detail'" #default="scope">
            <!-- 示值  -->
            <el-input
              v-if="item.value === 'zeroDriftOne' || item.value === 'zeroDriftTwo' || item.value === 'zeroDriftThree' || item.value === 'zeroDriftFour' || item.value === 'zeroDriftFive'"
              v-model="scope.row[item.value]"
              :placeholder="`${item.text}`"
              class="input"
            />
          </template>
        </el-table-column>
      </el-table>
    </el-form>

    <div v-if="current === 'measure-data'" style="display: flex;justify-content: space-between;">
      <div v-if="itemFormData.itemCategoryName === '一般压力表' || itemFormData.itemCategoryName === '精密压力表' || itemFormData.itemCategoryName === '电接点一般压力表'" style="white-space: nowrap; font-size: 14px;color: #606266;padding: 0 20px 20px 0;font-weight: 600;">
        示值误差、回程误差、轻敲位移:
      </div>
      <div v-if="itemFormData.itemCategoryName === '压力传感器'" style="white-space: nowrap; font-size: 14px;color: #606266;padding: 0 20px 20px 0;font-weight: 600;">
        检定数据:
      </div>
      <div v-if="itemFormData.itemCategoryName === '数字压力计'" style="white-space: nowrap; font-size: 14px;color: #606266;padding: 0 20px 20px 0;font-weight: 600;">
        示值误差:
      </div>
      <div v-if="itemFormData.itemCategoryName === '压力变送器'" style="font-size: 14px;color: #606266;padding: 0 20px;white-space: nowrap;">
        <!-- 理论输出值的单位 -->
        单位: {{ measureItemConfigPistonGauge ? measureItemConfigPistonGauge.theoreticalOutputValueUnit : '' }}
      </div>
      <div v-if="itemFormData.itemCategoryName !== '压力变送器'" style="white-space: nowrap; font-size: 14px;color: #606266;padding: 0 20px;">
        <!-- 根据输入单位自动配置:量程的单位 -->
        单位: {{ measureItemConfigPistonGauge ? measureItemConfigPistonGauge.rangeUnit : '' }}
      </div>
      <div style="width: 100%;display: flex;justify-content: flex-end;margin-bottom: 10px;">
        <el-button v-if="pageType !== 'detail' && (itemFormData.itemCategoryName === '压力变送器' || itemFormData.itemCategoryName === '压力传感器')" type="primary" @click="copy">
          复制
        </el-button>
        <el-button v-if="pageType !== 'detail'" type="primary" @click="createResult('')">
          生成结果处理
        </el-button>
      </div>
    </div>
    <el-form
      v-if="current === 'measure-data' && itemFormData.itemCategoryName === '压力传感器'"
      ref="formRef"
      :model="itemFormData"
      label-width="120"
      label-position="right"
    >
      <el-row :gutter="24">
        <el-col :span="12">
          <el-form-item label="工作直线方程:" prop="workLineEquation">
            <el-select
              v-model="itemFormData.workLineEquation"
              filterable
              placeholder="请选择工作直线方程"
              :disabled="pageType === 'detail'"
              class="full-width-input"
            >
              <el-option v-for="item of workingLinearEquationList" :key="item.id" :label="item.name" :value="item.value" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <!-- 有多级表头的表格(一般压力表、精密压力表、压力传感器、电接点一般压力表、数字压力计) -->
    <multi-table
      v-if="current === 'measure-data' && (itemFormData.itemCategoryName === '一般压力表' || itemFormData.itemCategoryName === '精密压力表' || itemFormData.itemCategoryName === '压力变送器' || itemFormData.itemCategoryName === '压力传感器' || itemFormData.itemCategoryName === '电接点一般压力表' || itemFormData.itemCategoryName === '数字压力计')"
      v-loading="pressureSensorTableLoading"
      :table-data="list"
      :table-header="measureColumns"
      :merge-rows="[]"
      :need-index="true"
      @handle-input-number-change="handleInputNumberChange"
    />

    <!-- ==================================结果======================================================= -->
    <!-- 一般压力表结果表格、电接点一般压力表 -->
    <el-table
      v-if="current === 'measure-data' && (itemFormData.itemCategoryName === '一般压力表' || itemFormData.itemCategoryName === '电接点一般压力表')"
      ref="tableRef"
      v-loading="tableLoadingTop"
      :data="resultList"
      border
      style="width: 100%;margin-top: 20px;"
    >
      <el-table-column align="center" label="序号" width="80" type="index" />
      <el-table-column
        v-for="item in result_columns_generalPurposegauge"
        :key="item.value"
        :prop="item.value"
        :label="item.text"
        align="center"
      />
    </el-table>
    <!-- 精密压力表结果表格 -->
    <el-table
      v-if="current === 'measure-data' && (itemFormData.itemCategoryName === '精密压力表')"
      ref="tableRef"
      v-loading="tableLoadingTop"
      :data="resultList"
      border
      style="width: 100%;margin-top: 20px;"
    >
      <el-table-column align="center" label="序号" width="80" type="index" />
      <el-table-column
        v-for="item in result_columns_precisionPressuregauge"
        :key="item.value"
        :prop="item.value"
        :label="item.text"
        align="center"
      />
    </el-table>

    <!-- 压力变送器结果表格 -->
    <el-table
      v-if="current === 'measure-data' && itemFormData.itemCategoryName === '压力变送器'"
      ref="tableRef"
      v-loading="tableLoadingTop"
      :data="resultList"
      border
      style="width: 100%;margin-top: 20px;"
    >
      <el-table-column align="center" label="序号" width="80" type="index" />
      <el-table-column
        v-for="item in result_columns_digitalMultimeterTable"
        :key="item.value"
        :prop="item.value"
        :label="item.text"
        align="center"
      />
    </el-table>

    <!-- 数字压力计结果表格 -->
    <el-table
      v-if="current === 'measure-data' && itemFormData.itemCategoryName === '数字压力计'"
      ref="tableRef"
      v-loading="tableLoadingTop"
      :data="resultList"
      border
      style="width: 100%;margin-top: 20px;"
    >
      <el-table-column align="center" label="序号" width="80" type="index" />
      <el-table-column
        v-for="item in result_columns_digitalPressureGauge"
        :key="item.value"
        :prop="item.value"
        :label="item.text"
        align="center"
      />
    </el-table>

    <!-- 结果、备注:第一结果 -->
    <el-form
      v-if="current === 'measure-data' && itemFormData.itemCategoryName !== '压力传感器'"
      ref="formRef"
      :model="itemFormData"
      label-width="120"
      label-position="right"
      style="margin-top: 20px;"
    >
      <el-row :gutter="24">
        <el-col :span="12">
          <el-form-item label="结果:" prop="outcome">
            <el-input
              v-model="itemFormData.outcome"
              class="full-width-input"
              autosize
              :placeholder="pageType === 'detail' ? ' ' : '请判断结果'"
              type="textarea"
              disabled
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="输出备注:" prop="remark">
            <el-input
              v-model="itemFormData.remark"
              class="full-width-input"
              :placeholder="pageType === 'detail' ? ' ' : '请填写输出备注'"
              autosize
              type="textarea"
              :disabled="pageType === 'detail'"
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <!-- ========================================第二结果======================================== -->
    <div v-if="current === 'measure-data' && itemFormData.itemCategoryName === '压力传感器'" style="margin-top: 20px;font-size: 14px;color: #606266;padding: 0 20px 20px 0;font-weight: 600;">
      数据处理:
    </div>
    <!-- 压力传感器第二结果 -->
    <el-form
      v-if="current === 'measure-data' && itemFormData.itemCategoryName === '压力传感器'"
      ref="formRef"
      :model="itemFormData"
      label-width="120"
      label-position="right"
      style="margin-top: 20px;"
    >
      <el-row :gutter="24">
        <el-col :span="6">
          <el-form-item label="截距a:">
            <el-input
              v-model="itemFormData.interceptA"
              class="full-width-input"
              autosize
              type="textarea"
              disabled
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="斜率b:">
            <el-input
              v-model="itemFormData.slopeB"
              class="full-width-input"
              autosize
              type="textarea"
              disabled
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="灵敏度b:">
            <el-input
              v-model="itemFormData.sensitivityB"
              class="full-width-input"
              autosize
              type="textarea"
              disabled
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="供电电压:">
            <el-input
              v-model="itemFormData.supplyVoltage"
              class="full-width-input"
              autosize
              type="textarea"
              disabled
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="重复性ξR:">
            <el-input
              v-model="itemFormData.repeatabilityR"
              class="full-width-input"
              autosize
              type="textarea"
              disabled
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="迟滞ξH:">
            <el-input
              v-model="itemFormData.hysteresisH"
              class="full-width-input"
              autosize
              type="textarea"
              disabled
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="线性ξL:">
            <el-input
              v-model="itemFormData.linearL"
              class="full-width-input"
              autosize
              type="textarea"
              disabled
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="基本误差A:">
            <el-input
              v-model="itemFormData.basicErrorA"
              class="full-width-input"
              autosize
              type="textarea"
              disabled
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="上一周期灵敏度b0:">
            <el-input
              v-model="itemFormData.lastCycleSensitivity"
              class="full-width-input"
              autosize
              type="textarea"
              disabled
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="周期稳定性Sb:">
            <el-input
              v-model="itemFormData.periodicStabilitySB"
              class="full-width-input"
              autosize
              type="textarea"
              disabled
            />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="结果:" prop="otherOutcome">
            <el-input
              v-if="itemFormData.itemCategoryName !== '压力传感器'"
              v-model="itemFormData.otherOutcome"
              class="full-width-input"
              autosize
              type="textarea"
              disabled
            />
            <el-select
              v-if="itemFormData.itemCategoryName === '压力传感器'"
              v-model="itemFormData.otherOutcome"
              filterable
              placeholder="请选择结果"
              :disabled="pageType === 'detail'"
              class="full-width-input"
            >
              <el-option v-for="item of ['合格', '不合格']" :key="item" :label="item" :value="item" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="输出备注:" prop="otherRemark">
            <el-input
              v-model="itemFormData.otherRemark"
              class="full-width-input"
              :placeholder="pageType === 'detail' ? ' ' : '请填写输出备注'"
              autosize
              type="textarea"
              :disabled="pageType === 'detail'"
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <!-- ========================================电接点一般压力第二结果表格======================= -->
    <!-- 电接点一般压力表第二结果 -->
    <div v-if="current === 'measure-data' && itemFormData.itemCategoryName === '电接点一般压力表'" style="width: 100%;margin-top: 36px;display: flex;justify-content: space-between;align-items: center;">
      <div style="font-size: 14px;color: #606266;padding: 0 20px 0 0;font-weight: 600;">
        设定点偏差及切换差:
      </div>
      <el-button v-if="pageType !== 'detail'" type="primary" @click="createResult('bottomTable')">
        生成结果处理
      </el-button>
    </div>
    <!-- 电接点一般压力表 设定点偏差及切换差表格 -->
    <el-table
      v-if="current === 'measure-data' && itemFormData.itemCategoryName === '电接点一般压力表'"
      ref="tableRef"
      v-loading="tableLoadingBottom"
      :data="listElectricContact"
      border
      style="width: 100%;margin-top: 20px;"
    >
      <el-table-column align="center" label="序号" width="80" type="index" />
      <el-table-column
        v-for="item in columns_electricContact"
        :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">
          <!-- 正行程切换值、反行程切换值 -->
          <el-input-number
            v-if="pageType !== 'detail' && (item.value === 'forwardStrokeSwitchValue' || item.value === 'reverseStrokeSwitchValue')"
            v-model="scope.row[item.value]"
            :placeholder="pageType === 'detail' ? '' : '请输入'"
            :disabled="pageType === 'detail'"
            size="small"
          />
        </template>
      </el-table-column>
    </el-table>
    <el-table
      v-if="current === 'measure-data' && itemFormData.itemCategoryName === '电接点一般压力表'"
      ref="tableRef"
      v-loading="tableLoadingBottom"
      :data="resultListElectricContact"
      border
      style="width: 100%;margin-top: 20px;"
    >
      <el-table-column align="center" label="序号" width="80" type="index" />
      <el-table-column
        v-for="item in result_columns_electricContact"
        :key="item.value"
        :prop="item.value"
        :label="item.text"
        align="center"
      />
    </el-table>
    <el-form
      v-if="current === 'measure-data' && itemFormData.itemCategoryName === '电接点一般压力表'"
      ref="formRef"
      :model="itemFormData"
      label-width="120"
      label-position="right"
      style="margin-top: 20px;"
    >
      <el-row :gutter="24">
        <el-col :span="12">
          <el-form-item label="结果:" prop="otherOutcome">
            <el-input
              v-model="itemFormData.otherOutcome"
              class="full-width-input"
              autosize
              type="textarea"
              disabled
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="输出备注:" prop="otherRemark">
            <el-input
              v-model="itemFormData.otherRemark"
              class="full-width-input"
              :placeholder="pageType === 'detail' ? ' ' : '请填写输出备注'"
              autosize
              type="textarea"
              :disabled="pageType === 'detail'"
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <!-- =============================================================================================== -->
    <!-- 历史修改记录 -->
    <change-record v-show="pageType === 'detail' && current === 'change-record'" :info-id="infoId" />
  </detail-block>
</template>

<style lang="scss" scoped>
.setBottom {
  padding-bottom: 20px;
}
</style>