Newer
Older
xc-business-system / src / views / business / taskMeasure / measureData / components / fourth / templateDetail.vue
dutingting on 16 Nov 2023 44 KB 检定数据管理联调
<!-- 第一套:多功能校准源标准装置 -->
<!-- 检定数据管理详情模板 -->
<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 type { IDetailMeasureList } from './fourth-interface'
import { useSolveFormData } from './useSolveFormData'
import useUserStore from '@/store/modules/user'
import type { dictType } from '@/global'
import { getDictByCode } from '@/api/system/dict'
import type { TableColumn } from '@/components/NormalTable/table_interface'
import { calculateHandle, getInfo } from '@/api/business/taskMeasure/measureData'
import { getInfo as getItemInfo } from '@/api/business/measure/item'
import { useCheckList } from '@/commonMethods/useCheckList'
import multiTable from '@/components/MultiHeaderTable/index.vue'
import { calc } from '@/utils/useCalc'

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活塞式压力计
  remark: '', // 备注

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

  tempData: '', // 无用,计算输出时去掉
})
// -------------------------------------------路由参数------------------------------------------
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 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: '正行程', value: 'beforeFrictionForwardStroke', align: 'center', required: true, type: 'inputNumber' },
      { text: '反行程', value: 'beforeFrictionReverseStroke', align: 'center', required: true, type: 'inputNumber' },
    ],
  },
  {
    text: '轻敲后被检设备示值',
    value: 'afterFrictionStroke',
    align: 'center',
    required: true,
    children: [
      { text: '正行程', value: 'afterFrictionForwardStroke', align: 'center', required: true, type: 'inputNumber' },
      { text: '反行程', value: 'afterFrictionReverseStroke', align: 'center', required: true, type: 'inputNumber' },
    ],
  },
  {
    text: '轻敲前后变动量',
    value: 'variationStroke',
    align: 'center',
    required: true,
    children: [
      { text: '正行程', value: 'variationForwardStroke', align: 'center', required: true, type: 'text' },
      { text: '反行程', value: 'variationReverseStroke', align: 'center', required: true, type: 'text' },
    ],
  },
])
// 生成结果表头--一般压力表、精密压力表
const result_columns_generalPurposegauge = ref([
  { text: '项目', value: 'params', align: 'center', required: true },
  { text: '示值误差允许值', value: 'params', align: 'center', required: true },
  { text: '示值误差最大值', value: 'params', align: 'center', required: true },
  { text: '轻敲位移允许值', value: 'params', align: 'center', required: true },
  { text: '轻敲位移最大值', value: 'params', align: 'center', required: true },
  { text: '回程误差允许值', value: 'params', align: 'center', required: true },
  { text: '回程误差最大值', value: 'params', 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, 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, type: 'inputNumber' },
      { text: '反行程', value: 'secondReverseStroke', align: 'center', required: true, type: 'inputNumber' },
    ],
  },
  {
    text: '第三次',
    value: 'thirdStroke',
    align: 'center',
    required: true,
    width: '180',
    children: [
      { text: '正行程', value: 'thirdForwardStroke', align: 'center', required: true, type: 'inputNumber' },
      { text: '反行程', value: 'thirdReverseStroke', align: 'center', required: true, type: 'inputNumber' },
    ],
  },
  { text: '示值误差', value: 'indicatingError', 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, 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, type: 'inputNumber' },
      { text: '反行程', value: 'secondReverseStroke', align: 'center', required: true, type: 'inputNumber' },
    ],
  },
  {
    text: '第三次',
    value: 'thirdStroke',
    align: 'center',
    required: true,
    width: '180',
    children: [
      { text: '正行程', value: 'thirdForwardStroke', align: 'center', required: true, type: 'inputNumber' },
      { text: '反行程', value: 'thirdReverseStroke', align: 'center', required: true, 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: '正行程切换值', value: 'forwardStrokeSwitchValue', align: 'center', required: true, width: '120' },
  { text: '反行程切换值', value: 'reverseStrokeSwitchValue', align: 'center', required: true, width: '120' },
  { text: '设定点偏差', value: 'pointDeviation', align: 'center', required: true, width: '120' },
  { text: '切换差', value: 'differentGap', 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, 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, type: 'inputNumber' },
      { text: '反行程', value: 'secondReverseStroke', align: 'center', required: true, type: 'inputNumber' },
    ],
  },
  { text: '示值误差最大值', value: 'maxIndicatingError', 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: 'maxReturnError', align: 'center', required: true, type: 'text' },
])
// 零位飘逸表头
const columns_zeroDriftResult = ref([ // 数字压力计
  { text: 'min', value: 'min', align: 'center', required: true },
  { text: '0', value: '0', align: 'center', required: true },
  { text: '15', value: '15', align: 'center', required: true },
  { text: '30', value: '30', align: 'center', required: true },
  { text: '45', value: '45', align: 'center', required: true },
  { text: '60', value: '60', align: 'center', required: true },
])
const zeroDriftResultList = ref([]) as any // 数字压力计零位漂移表格

// -------------------------------------------获取详情信息--------------------------------------------------
// 获取页面详情信息
const fetchInfo = () => {
  const loading = ElLoading.service({
    lock: true,
    background: 'rgba(255, 255, 255, 0.8)',
  })
  getInfo({
    id: infoId.value,
    belongStandardEquipment: itemFormData.value.belongStandardEquipment,
    // 我的任务跳转过来如果已经配置过检定项了,到编辑页面,且用一下三个字段替代传id请求详情
    itemId: $route.query.itemId, // 检定项id
    orderId: $route.query.orderId, // 任务单id
    sampleId: $route.query.sampleId, // 被检设备id
  }).then((res) => {
    // 有关于检定项的数据
    itemFormData.value.itemId = res.data.itemId // 检定项id
    itemFormData.value.itemCategoryName = res.data.itemCategoryName // 设备检定项分类名称
    itemFormData.value.itemCategoryId = res.data.itemCategoryId ? res.data.itemCategoryId : itemFormData.value.itemCategoryId // 设备检定项分类名称id
    itemFormData.value.appearance = `${res.data.appearance}` // 外观(1/0)
    itemFormData.value.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)
    // ==================================检定数据========================================================================

    list.value = res.data.measureDataPistonGaugeList.map((item: IDetailMeasureList) => {
      return {
        ...item,
        editable: pageType.value !== 'detail',
      }
    }) // 检定数据

    infoId.value = res.data.id
    emits('giveInfoId', infoId.value)
    loading.close()
  })
}

// 初始化输入数据
const initInputData = (data: any) => {
  if (itemFormData.value.itemCategoryName === '一般压力表' || 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',
        // averageForwardStroke: '', //	正行程平均值
        // averageReturnError: '', //	回程误差平均值
        // averageReverseStroke: '', //	反行程平均值
        // averageValue: '', //	平均值
        // dataId: '', //	检定数据管理基础信息表id(新增不用传)
        // dataType: '', //	检定数据类型(电接点一般压力表一个检定数据中区分两个表格)(字典code)
        // differentGap: '', //	切换差(电接点一般压力表)
        // firstForwardStroke: '', //	第一次正行程
        // firstReverseStroke: '', //	第一次反行程
        // forwardStrokeSwitchValue: '', // 正行程切换值(电接点一般压力表)
        // indicatingError: '',	// 示值误差
        // maxIndicatingError: '',	// 示值误差最大值
        // maxReturnError: '',	// 回程误差最大值
        // maximumErrorAbsolute: '',	// 最大允许误差绝对值
        // pointDeviation: '',	// 设定点偏差(电接点一般压力表)
        // returnError: '',	// 回程误差
        // reverseStrokeSwitchValue: '',	// 反行程切换值(电接点一般压力表)
        // secondForwardStroke: '',	// 第二次正行程
        // secondReverseStroke: '',	// 第二次反行程
        // theoreticalOutputValue: 0,	// 理论输出值
        // thirdForwardStroke: '',		// 第三次正行程
        // thirdReverseStroke: '',		//	第三次反行程
      }
    }) // 检定项表格
  }
  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 : '',	// 标准器示值
      0: '',	// 标准器示值
      15: '',	// 标准器示值
      30: '',	// 标准器示值
      45: '',	// 标准器示值
      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 = (itemId: string, itemCategoryName: string, belongStandardEquipment = '') => {
  const params = {
    id: itemId,
    itemCategoryName, // 检定项分类名字
    belongStandardEquipment, // 检校标准装置字典code
  }
  getItemInfo(params).then((res) => {
    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没有外观
    initInputData(res.data.measureItemDataPistonGaugeList)

    itemFormData.value.cycleNumber = res.data.measureItemConfigPistonGauge.cycleNumber // 循环次数
  })
}

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

  if (itemFormData.value.itemCategoryName === '一般压力表') {
    if (!list.value.length) {
      ElMessage.warning('示值误差、回程误差、轻敲位移不能为空')
      return false
    }
    if (!resultList.value) {
      ElMessage.warning('结果不能为空,请点击生成结果处理')
      return false
    }
  }
  return true
}
// -----------------------------------------生成结果处理----------------------------------------
// 点击生成结果处理
const createResult = () => {
  ElMessage.info('敬请期待')
  return false
  // if (!list.value.length) {
  //   ElMessage.warning('没有检定项数据,无法生成结果')
  //   return false
  // }
  // if (!useCheckList(list.value, measureColumns.value, '检定数据')) {
  //   return false
  // }
  // const params = {
  //   belongStandardEquipment: itemFormData.value.belongStandardEquipment, // 检校标准装置
  //   itemCategoryName: itemFormData.value.itemCategoryName, // 检定项分类名称
  //   measureDataCalibratorList: list.value,
  // }
  // calculateHandle(params).then((res) => {
  //   if (res.data && res.data.length) {
  //     resultList.value = res.data.map((item: IDetailMeasureList) => {
  //       return {
  //         ...item,
  //       }
  //     }) // 检定数据
  //   }
  //   else {
  //     list.value = res.data
  //   }
  // })
}

// -------------------------------------------处理表格函数---------------------------------------
// el-input-number组件值变化
const handleInputNumberChange = ({ row }: any) => {
  if (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',
    }
  }) // 检定项表格
}

// ------------------------------------------钩子----------------------------------------------
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
  }
}, { immediate: true })

onMounted(() => {
  if (pageType.value === 'add') { // 从我的任务跳转过来(新增)
    itemFormData.value.itemId = $route.query.itemId 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// 标准装置名称
    // 查输入值(查检定项管理的详情)
    fetchItemInfo($route.query.itemId! as string, $route.query.itemCategoryName! as string, $route.query.belongStandardEquipment as string)
  }
  else {
    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// 标准装置名称
    fetchInfo()
  }
})

defineExpose({ checkout, itemFormData, list, 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 #default="scope">
            <!-- 示值  -->
            <el-input
              v-if="item.value === '0' || item.value === '15' || item.value === '30' || item.value === '45' || item.value === '60'"
              v-model="scope.row[item.value]"
              :placeholder="`${item.text}`"
              class="input"
            />
          </template>
        </el-table-column>
      </el-table>
      <!-- ============================================================================== -->
      <div style="display: flex;justify-content: space-between;">
        <div v-if="itemFormData.itemCategoryName === '一般压力表' || itemFormData.itemCategoryName === '精密压力表' || itemFormData.itemCategoryName === '电接点一般压力表'" style="font-size: 14px;color: #606266;padding: 0 20px 20px 0;font-weight: 600;">
          示值误差、回程误差、轻敲位移:
        </div>
        <!-- <div style="font-size: 14px;color: #606266;padding: 0 20px 20px 0;font-weight: 600;">
          单位:
        </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>
    <!-- 有多级表头的表格(一般压力表、精密压力表、压力传感器、电接点一般压力表、数字压力计) -->
    <multi-table
      v-if="current === 'measure-data' && (itemFormData.itemCategoryName === '一般压力表' || itemFormData.itemCategoryName === '精密压力表' || itemFormData.itemCategoryName === '压力变送器' || itemFormData.itemCategoryName === '压力传感器' || itemFormData.itemCategoryName === '电接点一般压力表' || itemFormData.itemCategoryName === '数字压力计')"
      :table-data="list"
      :table-header="measureColumns"
      :merge-rows="[]"
      :need-index="true"
      @handle-input-number-change="handleInputNumberChange"
    />

    <!-- ==================================结果======================================================= -->
    <!-- 一般压力表和精密压力表结果表格 -->
    <el-table
      v-if="current === 'measure-data' && resultList.length && (itemFormData.itemCategoryName === '一般压力表' || itemFormData.itemCategoryName === '精密压力表' || itemFormData.itemCategoryName === '电接点一般压力表')"
      ref="tableRef"
      :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>
    <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 20px 0;font-weight: 600;">
        数据处理:
      </div>
      <el-button v-if="pageType !== 'detail'" type="primary" @click="createResult">
        生成结果处理
      </el-button>
    </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="12">
          <el-form-item label="工作直线方程:" prop="remark">
            <el-select
              v-model="itemFormData.remark"
              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-row :gutter="24">
        <el-col :span="6">
          <el-form-item label="截距:" prop="1">
            <el-input
              v-model="itemFormData.tempData"
              class="full-width-input"
              autosize
              type="textarea"
              disabled
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="斜率:" prop="2">
            <el-input
              v-model="itemFormData.tempData"
              class="full-width-input"
              autosize
              type="textarea"
              disabled
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="灵敏度:" prop="3">
            <el-input
              v-model="itemFormData.tempData"
              class="full-width-input"
              autosize
              type="textarea"
              disabled
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="供电电压:" prop="4">
            <el-input
              v-model="itemFormData.tempData"
              class="full-width-input"
              autosize
              type="textarea"
              disabled
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="重复性ξR:" prop="5">
            <el-input
              v-model="itemFormData.tempData"
              class="full-width-input"
              autosize
              type="textarea"
              disabled
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="迟滞ξH:" prop="tempData">
            <el-input
              v-model="itemFormData.tempData"
              class="full-width-input"
              autosize
              type="textarea"
              disabled
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="线性ξL:" prop="tempData">
            <el-input
              v-model="itemFormData.tempData"
              class="full-width-input"
              autosize
              type="textarea"
              disabled
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="基本误差A:" prop="tempData">
            <el-input
              v-model="itemFormData.tempData"
              class="full-width-input"
              autosize
              type="textarea"
              disabled
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="上一周期灵敏度b0:" prop="tempData">
            <el-input
              v-model="itemFormData.tempData"
              class="full-width-input"
              autosize
              type="textarea"
              disabled
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="周期稳定性Sb:" prop="tempData">
            <el-input
              v-model="itemFormData.tempData"
              class="full-width-input"
              autosize
              type="textarea"
              disabled
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="结果:" prop="zeroDriftResult">
            <el-input
              v-model="itemFormData.zeroDriftResult"
              class="full-width-input"
              autosize
              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
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <el-form
      v-if="current === 'measure-data' && false"
      ref="formRef"
      :model="itemFormData"
      label-width="120"
      label-position="right"
      style="margin-top: 20px;"
    >
      <el-row>
        <el-col v-if="itemFormData.maxIndicatingError" :span="12">
          <el-form-item label="最大误差(示值误差最大值):" prop="maxIndicatingError">
            <el-input
              v-model="itemFormData.maxIndicatingError"
              class="full-width-input"
              autosize
              type="textarea"
              :disabled="pageType === 'detail'"
            />
          </el-form-item>
        </el-col>
        <el-col v-if="itemFormData.indicatingError" :span="12">
          <el-form-item label="示值误差允许值(示值误差):" prop="indicatingError">
            <el-input
              v-model="itemFormData.indicatingError"
              class="full-width-input"
              autosize
              type="textarea"
              :disabled="pageType === 'detail'"
            />
          </el-form-item>
        </el-col>
        <el-col v-if="itemFormData.maxReturnError" :span="12">
          <el-form-item label="最大回差(回程误差最大值):" prop="maxReturnError">
            <el-input
              v-model="itemFormData.maxReturnError"
              class="full-width-input"
              autosize
              type="textarea"
              :disabled="pageType === 'detail'"
            />
          </el-form-item>
        </el-col>
        <el-col v-if="itemFormData.returnError" :span="12">
          <el-form-item label="回差(允许回差):" prop="returnError">
            <el-input
              v-model="itemFormData.returnError"
              class="full-width-input"
              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">
        生成结果处理
      </el-button>
    </div>
    <el-table
      v-if="current === 'measure-data' && itemFormData.itemCategoryName === '电接点一般压力表'"
      ref="tableRef"
      :data="list"
      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"
      />
    </el-table>

    <!-- 历史修改记录 -->
    <change-record v-show="pageType === 'detail' && current === 'change-record'" :info-id="infoId" />
  </detail-block>
</template>

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

<style lang="scss">
.el-radio__label {
  display: block !important;
}
</style>