Newer
Older
xc-business-system / src / views / equipement / standard / checkData / components / fifth / checkDataCom.vue
<!-- 核查数据管理详情--核查项---第5套:二等铂电阻温度计标准装置  -->
<script lang="ts" setup name="checkDataDetail">
import { ref, watch } from 'vue'
import { ElLoading, ElMessage } from 'element-plus'
import saveCheckRecord from '../../dialog/saveCheckRecord.vue'
import type { IList } from './fifth-interface'
import type { TableColumn } from '@/components/NormalTable/table_interface'
import useUserStore from '@/store/modules/user'
import type { dictType } from '@/global'
import { getDictByCode } from '@/api/system/dict'
import multiTable from '@/components/MultiHeaderTable/index.vue'
// import { getCheckItemDetail, getJobInstructionList } from '@/api/equipment/standard/book'
// import { addCheckData, calculateHandle, getInfo, updateCheckData } from '@/api/equipment/standard/checkData'
const user = useUserStore() // 用户信息
const $router = useRouter() // 关闭页面使用
const $route = useRoute() // 路由参数
const pageType = ref('add') // 页面类型: add, edit, detail
const infoId = ref('')
const ruleFormRef = ref() // 表单ref
const form = ref({
  conclusion: '', // 结论
  // remark: '/', // 备注
  // flit: '', // 稳定性考核是否合格
  isCheckTemperature: true, // 是否进行温度核查
  isCheckRTP: true, // 是否进行RTP核查
})

const belongStandardEquipment = ref('9')
const itemCategoryId = ref('') // 核查项分类id
const itemCategoryName = ref('') // 核查项分类名称

// ----------------------------------路由参数------------------------------------------------
if ($route.params && $route.params.type) {
  pageType.value = $route.params.type as string
  console.log(pageType.value)

  if ($route.params.id) {
    infoId.value = $route.params.id as string
  }
}
// ------------------------------------------字典----------------------------------------------
const conclusionList = ref<dictType[]>([]) // 结论

function getDict() {
  // 结论
  getDictByCode('conclusion').then((response) => {
    conclusionList.value = response.data
  })
}
// getDict()

// ----------------------------------------核查数据----------------------------------------------
const radioMenus = ref([ // 标签内容
  { name: '温度值', value: 'temperature' },
  { name: 'RTP', value: 'RTP' },
  { name: '绝缘电阻表校准', value: 'insulation-resistance' },
])
const current = ref('temperature') // 选择的tab 默认基本信息
const repeatabilityColumns = ref<TableColumn[]>([]) // 重复性表头
const stabilityColumns = ref<TableColumn[]>([]) // 稳定性表头
const columns_repeatability_temperature = ref<TableColumn[]>([ // 重复性表头--温度值
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '温度点', value: 'checkPoint', align: 'center', required: true, type: 'text' },
  { text: '单位', value: 'checkPoint', align: 'center', required: true, type: 'text' },
  {
    text: '1',
    value: 'indicatingValue',
    align: 'center',
    required: true,
    width: '160',
    children: [
      { text: '核查标准示值', value: '1', align: 'center', required: true, type: 'inputNumber' },
      { text: '测量标准示值', value: '2', align: 'center', required: true, type: 'inputNumber' },
      { text: '差值', value: '3', align: 'center', required: true, type: 'inputNumber' },
    ],
  },
  {
    text: '2',
    value: 'indicatingValue',
    align: 'center',
    required: true,
    width: '160',
    children: [
      { text: '核查标准示值', value: '1', align: 'center', required: true, type: 'inputNumber' },
      { text: '测量标准示值', value: '2', align: 'center', required: true, type: 'inputNumber' },
      { text: '差值', value: '3', align: 'center', required: true, type: 'inputNumber' },
    ],
  },
  {
    text: '3',
    value: 'indicatingValue',
    align: 'center',
    required: true,
    width: '160',
    children: [
      { text: '核查标准示值', value: '1', align: 'center', required: true, type: 'inputNumber' },
      { text: '测量标准示值', value: '2', align: 'center', required: true, type: 'inputNumber' },
      { text: '差值', value: '3', align: 'center', required: true, type: 'inputNumber' },
    ],
  },
  {
    text: '4',
    value: 'indicatingValue',
    align: 'center',
    required: true,
    width: '160',
    children: [
      { text: '核查标准示值', value: '1', align: 'center', required: true, type: 'inputNumber' },
      { text: '测量标准示值', value: '2', align: 'center', required: true, type: 'inputNumber' },
      { text: '差值', value: '3', align: 'center', required: true, type: 'inputNumber' },
    ],
  },
  {
    text: '5',
    value: 'indicatingValue',
    align: 'center',
    required: true,
    width: '160',
    children: [
      { text: '核查标准示值', value: '1', align: 'center', required: true, type: 'inputNumber' },
      { text: '测量标准示值', value: '2', align: 'center', required: true, type: 'inputNumber' },
      { text: '差值', value: '3', align: 'center', required: true, type: 'inputNumber' },
    ],
  },
  {
    text: '6',
    value: 'indicatingValue',
    align: 'center',
    required: true,
    width: '160',
    children: [
      { text: '核查标准示值', value: '1', align: 'center', required: true, type: 'inputNumber' },
      { text: '测量标准示值', value: '2', align: 'center', required: true, type: 'inputNumber' },
      { text: '差值', value: '3', align: 'center', required: true, type: 'inputNumber' },
    ],
  },
  { text: '差值平均值', value: 'averageValue', align: 'center', required: true, type: 'text' },
  { text: 'Sn', value: 'averageValue', align: 'center', required: true, type: 'text' },
])
const columns_repeatability_RTP = ref<TableColumn[]>([ // 重复性表头--RTP
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '水三相点', value: 'checkPoint', align: 'center', required: true, type: 'text' },
  { text: '功率', value: 'checkPoint', align: 'center', required: true, type: 'text' },
  {
    text: '被校示值(Ω)',
    value: 'indicatingValue',
    align: 'center',
    required: true,
    width: '160',
    children: [
      { text: '1', value: '1', align: 'center', required: true, type: 'inputNumber' },
      { text: '2', value: '2', align: 'center', required: true, type: 'inputNumber' },
      { text: '3', value: '3', align: 'center', required: true, type: 'inputNumber' },
      { text: '4', value: '4', align: 'center', required: true, type: 'inputNumber' },
      { text: '5', value: '5', align: 'center', required: true, type: 'inputNumber' },
      { text: '6', value: '6', align: 'center', required: true, type: 'inputNumber' },
    ],
  },
  { text: '平均值', value: 'averageValue', align: 'center', required: true, type: 'text' },
])
const columns_insulation_resistance = ref<TableColumn[]>([ // 绝缘电阻表校准表头
  { text: '核查项目', value: 'params', align: 'center', required: true },
  { text: '单位', value: 'checkPoint', align: 'center', required: true },
  { text: '确认点', value: 'checkPoint', align: 'center', required: true },
  { text: '测量值', value: 'checkPoint', align: 'center', required: true },
  { text: '示值误差', value: 'checkPoint', align: 'center', required: true },
  { text: '最大允许误差', value: 'averageValue', align: 'center', required: true },
])

// 稳定性表头--温度值
const columns_stability_temperature = ref<TableColumn[]>([
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '温度点', value: 'checkPoint', align: 'center', required: true, type: 'text' },
  { text: '单位', value: 'checkPoint', align: 'center', required: true, type: 'text' },
  {
    text: '测量差值',
    value: 'indicatingValue',
    align: 'center',
    required: true,
    width: '110',
    children: [
      { text: '2022-12-12', value: '2022-12-12', align: 'center', required: true, type: 'text' },
      { text: '2022-12-13', value: '2022-12-13', align: 'center', required: true, type: 'text' },
      { text: '2022-12-14', value: '2022-12-14', align: 'center', required: true, type: 'text' },
      { text: '2022-12-15', value: '2022-12-15', align: 'center', required: true, type: 'text' },
      { text: '2022-12-16', value: '2022-12-16', align: 'center', required: true, type: 'text' },
      { text: '2022-12-17', value: '2022-12-17', align: 'center', required: true, type: 'text' },
    ],
  },
  { text: '平均值', value: 'averageValue', align: 'center', required: true, type: 'text' },
  { text: 'Sm', value: 'standardDeviation', align: 'center', required: true, type: 'text' },
  { text: '扩展不确定度U', value: 'relativeRepeatability', align: 'center', type: 'text' },
  { text: '是否Sm≤U', value: 'lessThan', align: 'center', type: 'text' },
])

// 稳定性表头--RTP
const columns_stability_RTP = ref<TableColumn[]>([
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '水三相点', value: 'checkPoint', align: 'center', required: true, type: 'text' },
  { text: '单位', value: 'checkPoint', align: 'center', required: true, type: 'text' },
  {
    text: '被校示值平均值(Ω)',
    value: 'indicatingValue',
    align: 'center',
    required: true,
    width: '110',
    children: [
      { text: '2022-12-12', value: '2022-12-12', align: 'center', required: true, type: 'text' },
      { text: '2022-12-13', value: '2022-12-13', align: 'center', required: true, type: 'text' },
      { text: '2022-12-14', value: '2022-12-14', align: 'center', required: true, type: 'text' },
      { text: '2022-12-15', value: '2022-12-15', align: 'center', required: true, type: 'text' },
      { text: '2022-12-16', value: '2022-12-16', align: 'center', required: true, type: 'text' },
      { text: '2022-12-17', value: '2022-12-17', align: 'center', required: true, type: 'text' },
    ],
  },
  { text: '测量极差值', value: 'averageValue', align: 'center', required: true, type: 'text' },
  { text: '允许值', value: 'standardDeviation', align: 'center', required: true, type: 'text' },
  { text: '结论', value: 'lessThan', align: 'center', type: 'text' },
])

const listRepeatability = ref<any[]>([]) // 重复性数据
const listStability = ref<any[]>([]) // 稳定性数据
const temperatureListRepeatability = ref<any[]>([]) // 温度值重复性
const temperatureListStability = ref<any[]>([]) // 温度值稳定性
const RTPListRepeatability = ref<any[]>([]) // RTP重复性
const RTPListStability = ref<any[]>([]) // RTP稳定性
const listinsulationResistance = ref<any[]>([]) // 绝缘电阻表校准

// 获取配置详情
function fetchCheckItemDetail(equipmentId: string, belongStandardEquipmentParam: string, itemCategoryIdParam: string, itemCategoryNameParam: string) {
  belongStandardEquipment.value = belongStandardEquipmentParam // 检校标准装置
  itemCategoryId.value = itemCategoryIdParam // 核查分类id
  itemCategoryName.value = itemCategoryNameParam // 核查分类名称
  const loading = ElLoading.service({
    lock: true,
    background: 'rgba(255, 255, 255, 0.8)',
  })
  const params = {
    equipmentId, // 设备id
    belongStandardEquipment: belongStandardEquipment.value, // 检校标准装置code
    itemCategoryId: itemCategoryId.value, // 核查项分类id
    itemCategoryName: itemCategoryName.value, // 核查项分类名称
  }
  // getCheckItemDetail(params).then((res) => {
  //   loading.close()
  //   handleData(res.data.checkItemDataCalibratorList)
  // })
}

// 点击生成结果处理
const calculate = () => {
  //
}
// ------------------------------------------------------------------------------------------

// 获取详情
function fetchInfo() {
  // const loading = ElLoading.service({
  //   lock: true,
  //   background: 'rgba(255, 255, 255, 0.8)',
  // })
  // getInfo({ id: infoId.value }).then((res) => {
  //   form.value = { ...res.data }
  //   list.value = res.data.checkDataPistonGaugeList.map((item: any) => {
  //     return {
  //       ...item,
  //       editable: pageType.value !== 'detail',
  //     }
  //   })
  //   loading.close()
  // })
}

// -------------------------------------钩子-----------------------------------------------------
watch(() => current.value, (newValue) => {
  switch (newValue) {
    case 'temperature': // 温度值
      repeatabilityColumns.value = columns_repeatability_temperature.value // 重复性表头
      stabilityColumns.value = columns_stability_temperature.value // 稳定性表头
      listRepeatability.value = temperatureListRepeatability.value // 重复性数据
      listStability.value = temperatureListStability.value // 稳定性数据
      break
    case 'RTP': // 功率
      repeatabilityColumns.value = columns_repeatability_RTP.value // 重复性表头
      stabilityColumns.value = columns_stability_RTP.value // 稳定性表头
      listRepeatability.value = RTPListRepeatability.value // 重复性数据
      listStability.value = RTPListStability.value // 稳定性数据
      break
    default:
      break
  }
}, { immediate: true })

onMounted(async () => {
  if (pageType.value !== 'add') {
    // fetchInfo()
  }
})

defineExpose({ fetchCheckItemDetail, form })
</script>

<template>
  <!-- 核查数据 -->
  <detail-block title="核查数据">
    <div style="display: flex;justify-content: space-between;">
      <el-radio-group v-model="current" style="margin-bottom: 20px;">
        <el-radio-button v-for="item in radioMenus" :key="item.value" :label="item.value">
          {{ item.name }}
        </el-radio-button>
      </el-radio-group>
    </div>
    <div style="padding: 0 10px;">
      <el-checkbox v-if="current === 'temperature'" v-model="form.isCheckTemperature" :disabled="pageType === 'detail'">
        是否进行此项核查
      </el-checkbox>
      <el-checkbox v-if="current === 'RTP'" v-model="form.isCheckRTP" :disabled="pageType === 'detail'">
        是否进行此项核查
      </el-checkbox>
    </div>
    <div v-if="current === 'temperature' || current === 'RTP'" style="display: flex;justify-content: space-between;align-items: center;">
      <h5>核查类型--重复性</h5>
      <el-button v-if="pageType !== 'detail'" type="primary" @click="calculate">
        计算结果
      </el-button>
    </div>
    <multi-table
      v-if="current === 'temperature' || current === 'RTP'"
      :table-data="listRepeatability"
      :table-header="repeatabilityColumns"
      :merge-rows="[]"
      :need-index="true"
    />

    <div v-if="current === 'temperature' || current === 'RTP'" style="display: flex;justify-content: space-between;align-items: center;">
      <h5>核查类型--稳定性</h5>
      <el-button v-if="pageType !== 'detail'" type="primary" @click="calculate">
        计算结果
      </el-button>
      <el-button v-if="pageType !== 'detail' && current === 'RTP'" type="primary" @click="calculate">
        生成图表
      </el-button>
    </div>

    <multi-table
      v-if="current === 'temperature' || current === 'RTP'"
      :table-data="listStability"
      :table-header="stabilityColumns"
      :merge-rows="[]"
      :need-index="true"
    />

    <div v-if="current === 'insulation-resistance'" style="display: flex;justify-content: flex-end;align-items: center;padding-bottom: 10px;">
      <el-button v-if="pageType !== 'detail'" type="primary" @click="calculate">
        计算结果
      </el-button>
    </div>
    <!-- 绝缘电阻表校准 -->
    <el-table
      v-if="current === 'insulation-resistance'"
      ref="tableRef"
      :data="listinsulationResistance"
      border
      style="width: 100%;"
    >
      <el-table-column align="center" label="序号" width="80" type="index" />
      <el-table-column
        v-for="item in columns_insulation_resistance"
        :key="item.value"
        :prop="item.value"
        :label="item.text"
        :width="item.width"
        align="center"
      />
    </el-table>
    <!-- 结论 -->
    <el-form
      style="margin-top: 20px;"
      :model="form"
      label-width="160"
      label-position="right"
    >
      <el-row :gutter="24">
        <el-col :span="12">
          <el-form-item label="结论:" prop="conclusion">
            <el-input v-model="form.conclusion" class="full-width-input" disabled :placeholder="pageType === 'detail' ? ' ' : '稳定性考核是否合格'" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </detail-block>

  <!-- 保存核查记录  -->
  <save-check-record ref="saveCheckRecordRef" />
</template>

<style lang="scss" scoped>
.link {
  text-decoration: underline;
  color: #3d7eff;
  cursor: pointer;
}

.file-area {
  display: flex;
  align-items: center;
  font-size: 14px;
  color: #60627f;
  margin-bottom: 10px;
  margin-left: 40px;
  white-space: nowrap;

  .tech-file {
    display: flex;
    align-items: center;
    margin-left: 20px;

    .file-text {
      margin-right: 10px;
    }
  }
}
</style>