Newer
Older
xc-business-system / src / views / equipement / standard / checkData / components / second / checkDataCom.vue
<!-- 核查数据管理详情--核查项---第2套:直流稳压电源 -->
<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 './second-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: '', // 稳定性考核是否合格
})
const belongStandardEquipment = ref('2')
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: 'voltage' },
  { name: '电源效应和负载效应', value: 'effect' },
  { name: '直接电流(直接测量)', value: 'electricity-direct' },
  { name: '直接电流(间接测量)', value: 'electricity-indirect' },
  { name: '纹波电压', value: 'ripple-voltage' },
])
const current = ref('voltage') // 选择的tab 默认基本信息
const repeatabilityColumns = ref<TableColumn[]>([]) // 重复性表头
const stabilityColumns = ref<TableColumn[]>([]) // 稳定性表头
const columns_repeatability_voltage = ref<TableColumn[]>([ // 重复性表头(直流电压、电源效应和负载效应,直接电流(直接测量))
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '核查点', value: 'checkPoint', align: 'center', required: true, type: 'text' },
  { text: '单位', value: 'unit', 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' },
  { text: '标准偏差S(X)', value: 'standardDeviation', align: 'center', required: true, type: 'text' },
  { text: '相对标准偏差', value: 'relativeRepeatability', align: 'center', type: 'text' },
])
// 直接电流(间接测量) 重复性表头
const columns_repeatability_electricity_indirect = 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: 'unit', 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' },
  { text: '标准偏差S(X)', value: 'standardDeviation', align: 'center', required: true, type: 'text' },
  { text: '相对标准偏差', value: 'relativeRepeatability', align: 'center', type: 'text' },
])

// 纹波电压 重复性表头
const columns_repeatability_ripple_voltage = ref<TableColumn[]>([
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '核查点', value: 'checkPoint', align: 'center', required: true, type: 'text' },
  { text: '单位', value: 'unit', 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: '7', value: '7', align: 'center', required: true, type: 'inputNumber' },
      { text: '8', value: '8', align: 'center', required: true, type: 'inputNumber' },
      { text: '9', value: '9', align: 'center', required: true, type: 'inputNumber' },
      { text: '10', value: '10', align: 'center', required: true, type: 'inputNumber' },
    ],
  },
  { text: '算数平均值', value: 'averageValue', align: 'center', required: true, type: 'text' },
  { text: '标准偏差S(X)', value: 'standardDeviation', align: 'center', required: true, type: 'text' },
  { text: '相对标准偏差', value: 'relativeRepeatability', align: 'center', type: 'text' },
])
// 稳定性表头,直流电压、电源效应和负载效应
const columns_stability_voltage = ref<TableColumn[]>([
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '核查点', value: 'checkPoint', align: 'center', required: true, type: 'text' },
  { text: '单位', value: 'unit', 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: '标准偏差S(X)', value: 'standardDeviation', align: 'center', required: true, type: 'text' },
  { text: '相对标准偏差', value: 'relativeRepeatability', align: 'center', type: 'text' },
  { text: '相对扩展不确定度Urel', value: 'urel', align: 'center', type: 'text' },
  { text: '相对标准偏差是否小于相对扩展不确定度Urel', value: 'lessThan', align: 'center', type: 'text' },
])

// 稳定性表头,直接电流(直接测量)、直接电流(间接测量)
const columns_stability_electricity_direct = ref<TableColumn[]>([
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '核查点', value: 'checkPoint', align: 'center', required: true, type: 'text' },
  { text: '单位', value: 'unit', 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: '标准偏差S(X)', value: 'standardDeviation', align: 'center', required: true, type: 'text' },
  { text: '相对重复性', value: 'relativeRepeatability', align: 'center', type: 'text' },
  { text: '相对扩展不确定度Urel', value: 'urel', align: 'center', type: 'text' },
  { text: '相对重复性是否小于相对扩展不确定度Urel', value: 'lessThan', align: 'center', type: 'text' },
])
// 稳定性表头,纹波电压
const columns_stability_ripple_voltage = ref<TableColumn[]>([
  { text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
  { text: '核查点', value: 'checkPoint', align: 'center', required: true, type: 'text' },
  { text: '单位', value: 'unit', align: 'center', required: true, type: 'text' },
  { text: '频率', value: 'unit', 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: '标准偏差S(X)', value: 'standardDeviation', align: 'center', required: true, type: 'text' },
  { text: '相对扩展不确定度Urel', value: 'urel', align: 'center', type: 'text' },
  { text: '标准偏差是否小于相对扩展不确定度Urel', value: 'lessThan', align: 'center', type: 'text' },
])

const listRepeatability = ref<any[]>([]) // 重复性数据
const listStability = ref<any[]>([]) // 稳定性数据

const voltageListRepeatability = ref<any[]>([]) // 直流电压重复性
const voltageListStability = ref<any[]>([]) // 直流电压稳定性
const effectListRepeatability = ref<any[]>([]) // 电源效应和负载效应重复性
const effectListStability = ref<any[]>([]) // 电源效应和负载效应稳定性
const electricityDirectListRepeatability = ref<any[]>([]) // 直接电流(直接测量)重复性
const electricityDirectListStability = ref<any[]>([]) // 直接电流(直接测量)稳定性
const electricityIndirectListRepeatability = ref<any[]>([]) // 直接电流(间接测量)重复性
const electricityIndirectListStability = ref<any[]>([]) // 直接电流(间接测量)稳定性
const rippleVoltageListRepeatability = ref<any[]>([]) // 纹波电压重复性
const rippleVoltageListStability = 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 createResult = () => {
  //
}
// ------------------------------------------------------------------------------------------

// 获取详情
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 'voltage': // 直流电压
      repeatabilityColumns.value = columns_repeatability_voltage.value // 重复性表头
      stabilityColumns.value = columns_stability_voltage.value // 稳定性表头
      listRepeatability.value = voltageListRepeatability.value // 重复性数据
      listStability.value = voltageListRepeatability.value // 稳定性数据
      break
    case 'effect': // 电源效应和负载效应
      repeatabilityColumns.value = columns_repeatability_voltage.value // 重复性表头
      stabilityColumns.value = columns_stability_voltage.value // 稳定性表头
      listRepeatability.value = effectListRepeatability.value // 重复性数据
      listStability.value = effectListStability.value // 稳定性数据
      break
    case 'electricity-direct': // 直接电流(直接测量)
      repeatabilityColumns.value = columns_repeatability_voltage.value // 重复性表头
      stabilityColumns.value = columns_stability_electricity_direct.value // 稳定性表头
      listRepeatability.value = electricityDirectListRepeatability.value // 重复性数据
      listStability.value = electricityDirectListStability.value // 稳定性数据
      break
    case 'electricity-indirect': // 直接电流(间接测量)
      repeatabilityColumns.value = columns_repeatability_electricity_indirect.value // 重复性表头
      stabilityColumns.value = columns_stability_electricity_direct.value // 稳定性表头
      listRepeatability.value = electricityIndirectListRepeatability.value // 重复性数据
      listStability.value = electricityIndirectListStability.value // 稳定性数据
      break
    case 'ripple-voltage': // 纹波电压
      repeatabilityColumns.value = columns_repeatability_ripple_voltage.value // 重复性表头
      stabilityColumns.value = columns_stability_ripple_voltage.value // 稳定性表头
      listRepeatability.value = rippleVoltageListRepeatability.value // 重复性数据
      listStability.value = rippleVoltageListStability.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="display: flex;justify-content: space-between;align-items: center;">
      <h5>核查类型--重复性</h5>
      <el-button v-if="pageType !== 'detail'" type="primary" @click="createResult">
        生成结果处理
      </el-button>
    </div>
    <multi-table
      :table-data="listRepeatability"
      :table-header="repeatabilityColumns"
      :merge-rows="[]"
      :need-index="true"
    />

    <div style="display: flex;justify-content: space-between;align-items: center;">
      <h5>核查类型--稳定性</h5>
      <el-button v-if="pageType !== 'detail'" type="primary" @click="createResult">
        生成结果处理
      </el-button>
    </div>

    <multi-table
      :table-data="listStability"
      :table-header="stabilityColumns"
      :merge-rows="[]"
      :need-index="true"
    />
    <!-- 稳定性考核是否合格 -->
    <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="flit">
            <el-input v-model="form.flit" 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>