Newer
Older
xc-business-system / src / views / business / measure / item / components / third / templateDetail.vue
<!-- 第三套:多功能电气安全校准器标准装置 -->
<script lang="ts" setup name="TemplateDetailThird">
import type { IList } from './templateDetail-interface'
import type { dictType } from '@/global'
import { getDictByCode } from '@/api/system/dict'
import { calc } from '@/utils/useCalc'
import { useCheckList } from '@/commonMethods/useCheckList'
import { calculate, recalculate } from '@/api/business/measure/caculate'

const props = defineProps({
  pageType: {
    type: String,
    default: 'add',
  },
  itemCategoryName: {
    type: String,
    require: true,
  }, // 设备检定项分类名称
  belongStandardEquipment: { // 检校标准装置code
    type: String,
    require: true,
  },
  list: {
    type: Array as any,
  },
  form: { // 检定项表单
    type: Object as any,
  },
  itemId: { // 检定项id
    type: String,
    default: '',
  },
})
const listTop = ref<IList[]>([]) // 表格数据(上面表格)
const listBottom = ref<IList[]>([]) // 表格数据(下面表格)
const list = ref<IList[]>([]) // 表格数据
const tableLoading = ref(false)
// ----------------------------------------表头------------------------------------------------
const columns_top = ref([]) as any // 表头数据--上面表格
const columns_bottom = ref([]) as any // 表头数据--下面表格
const columns_top_voltage_insulation_megger = ref([ // 开路电压(电子式绝缘电阻表(数字式)、电子式绝缘电阻表(指针式)、兆欧式)上面表格
  { text: '检定项目', value: 'params', align: 'center', required: true },
  { text: '标称值(V)', value: 'nominalValue', align: 'center', required: true },
  { text: '最小允许值相关系数a', value: 'minimumAllowFactorA', align: 'center', required: true },
  { text: '最大允许值相关系数b', value: 'maximumAllowFactorB', align: 'center', required: true },
  { text: '最小允许值(V)', value: 'minimumAllowValue', align: 'center', required: false },
  { text: '最大允许值(V)', value: 'maximumAllowValue', align: 'center', required: false },
])

const columns_top_earth_resistanc_meter_number = ref([ // 示值误差(数字式接地电阻表)上面表格
  { text: '检定项目', value: 'params', align: 'center', required: true },
  { text: '量程', value: 'rangeRange', align: 'center', required: true },
  { text: '标准值', value: 'standardValue', align: 'center', required: true },
  { text: '单位', value: 'unit', align: 'center', required: true },
  { text: '分辨力', value: 'resolution', align: 'center', required: true },
  { text: '误差参数a', value: 'errorParamA', align: 'center', required: true },
  { text: '误差参数b', value: 'errorParamB', align: 'center', required: true },
  { text: '最大允许误差(Ω)', value: 'maximumError', align: 'center', required: true },
])
const columns_top_earth_resistanc_meter_simulation = ref([ // 示值误差(模拟式接地电阻表)上面表格
  { text: '检定项目', value: 'params', align: 'center', required: true },
  { text: '量程', value: 'rangeRange', align: 'center', required: true },
  { text: '被检表示值', value: 'measureIndicationValue', align: 'center', required: true },
  { text: '单位', value: 'unit', align: 'center', required: true },
  { text: '分辨力', value: 'resolution', align: 'center', required: true },
  { text: '准确度a', value: 'accuracyA', align: 'center', required: true },
  { text: '最大允许误差', value: 'maximumError', align: 'center', required: true },
])

const columns_bottom_Electronic_insulation_resistance_meter_number = ref([ // 电子式绝缘电阻表(数字式)--下面表格示值误差
  { text: '检定项目', value: 'params', align: 'center', required: true },
  { text: '端钮电压(V)', value: 'terminalVoltage', align: 'center', required: true },
  { text: '量程', value: 'rangeRange', align: 'center', required: true },
  { text: '标准值', value: 'nominalValue', align: 'center', required: true },
  { text: '单位', value: 'unit', align: 'center', required: true },
  { text: '分辨力', value: 'resolution', align: 'center', required: true },
  { text: '误差参数a', value: 'errorParamA', align: 'center', required: true },
  { text: '误差参数b', value: 'errorParamB', align: 'center', required: true },
  { text: '最大允许误差', value: 'maximumError', align: 'center', required: true },
])

const columns_bottom_Electronic_insulation_resistance_meter_pointer = ref([ // // 电子式绝缘电阻表(指针式)--下面表格示值误差
  { text: '检定项目', value: 'params', align: 'center', required: true },
  { text: '端钮电压(V)', value: 'terminalVoltage', align: 'center', required: true },
  { text: '被检表示值', value: 'measureIndicationValue', align: 'center', required: true },
  { text: '单位', value: 'unit', align: 'center', required: true },
  { text: '分辨力', value: 'resolution', align: 'center', required: true },
  { text: '准确度a', value: 'accuracyA', align: 'center', required: true },
  { text: '最大允许误差', value: 'maximumError', align: 'center', required: true },
])

const columns_bottom_megger = ref([ // 兆欧表--下面表格示值误差
  { text: '检定项目', value: 'params', align: 'center', required: true },
  { text: '被检表示值', value: 'measureIndicationValue', align: 'center', required: true },
  { text: '单位', value: 'unit', align: 'center', required: true },
  { text: '分辨力', value: 'resolution', align: 'center', required: true },
  { text: '准确度a', value: 'accuracyA', align: 'center', required: true },
  { text: '最大允许误差', value: 'maximumError', align: 'center', required: true },
])

const columns_bottom_earth_resistanc_meter = ref([ // 数字式接地电阻、模拟式接地电阻--下面表格(辅助接地电阻试验)
  { text: '检定项目', value: 'params', align: 'center', required: true },
  { text: '标准值', value: 'nominalValue', align: 'center', required: true },
  { text: '辅助地阻', value: 'auxiliaryGroundResistance', align: 'center', required: true },
  { text: '单位', value: 'unit', align: 'center', required: true },
  { text: '分辨力', value: 'resolution', align: 'center', required: true },
])

// ---------------------------------------------校验---------------------------------------------------
// 校验表格(点击保存的时候用、生成标准器示值)
const checkList = () => {
  // return useCheckList(list.value, columns.value, '检定项表格')
}
// ------------------------------------------------------------------------------------------------
// 点击计算结果--上方表格计算
const calculateDataTop = () => {

}
// 点击生成辅助接地电阻--下面表格计算
const calculateDataBottom = () => {

}
// -----------------------------------------------------------------------------------------------------

watch(() => props.itemCategoryName, (newValue) => {
  if (newValue) {
    switch (newValue) {
      case '电子式绝缘电阻表(数字式)':
        columns_top.value = columns_top_voltage_insulation_megger.value
        columns_bottom.value = columns_bottom_Electronic_insulation_resistance_meter_number.value
        break
      case '电子式绝缘电阻表(指针式)':
        columns_top.value = columns_top_voltage_insulation_megger.value
        columns_bottom.value = columns_bottom_Electronic_insulation_resistance_meter_pointer.value
        break
      case '兆欧表(指针式)':
        columns_top.value = columns_top_voltage_insulation_megger.value
        columns_bottom.value = columns_bottom_megger.value
        break
      case '数字式接地电阻表':
        columns_top.value = columns_top_earth_resistanc_meter_number.value
        columns_bottom.value = columns_bottom_earth_resistanc_meter.value
        break
      case '模拟式接地电阻表':
        columns_top.value = columns_top_earth_resistanc_meter_simulation.value
        columns_bottom.value = columns_bottom_earth_resistanc_meter.value
        break
    }
  }
}, { immediate: true })

watch(() => props.list, (newVal) => { // 检定项表格
  if (newVal) {
    list.value = [...newVal]
  }
})

defineExpose({ list })
</script>

<template>
  <div style="padding: 0 10px;">
    <el-checkbox v-model="form.appearance" :checked="true" :disabled="pageType === 'detail'">
      外观及功能性检查
    </el-checkbox>
  </div>
  <div style="padding: 0 10px;">
    <el-checkbox v-if="props.itemCategoryName === '电子式绝缘电阻表(数字式)' || props.itemCategoryName === '电子式绝缘电阻表(指针式)' || props.itemCategoryName === '兆欧表(指针式)'" v-model="form.appearance" :checked="true" :disabled="pageType === 'detail'">
      开路电压
    </el-checkbox>
    <el-checkbox v-if="props.itemCategoryName === '数字式接地电阻表' || props.itemCategoryName === '模拟式接地电阻表'" v-model="form.appearance" :checked="true" :disabled="pageType === 'detail'">
      示值误差
    </el-checkbox>
  </div>
  <!-- 上面表格 -->
  <detail-block title=" " style="margin-top: 0;">
    <template v-if="props.pageType !== 'detail'" #btns>
      <el-button type="primary">
        增加行
      </el-button>
      <el-button type="info">
        删除行
      </el-button>
      <el-button type="primary">
        计算结果
      </el-button>
    </template>
    <el-table
      ref="tableRef"
      v-loading="tableLoading"
      :data="listTop"
      border
      style="width: 100%;"
    >
      <el-table-column align="center" label="序号" width="80" type="index" />
      <el-table-column
        v-for="item in columns_top"
        :key="item.value"
        :prop="item.value"
        :label="item.text"
        :width="item.width"
        align="center"
      >
        <template #header>
          <span v-show="item.required" style="color: red;">*</span><span>{{ item.text }}</span>
        </template>
      </el-table-column>
    </el-table>
  </detail-block>

  <div style="padding: 0 10px;">
    <el-checkbox v-if="props.itemCategoryName === '电子式绝缘电阻表(数字式)' || props.itemCategoryName === '电子式绝缘电阻表(指针式)' || props.itemCategoryName === '兆欧表(指针式)'" v-model="form.appearance" :checked="true" :disabled="pageType === 'detail'">
      示值误差
    </el-checkbox>
    <el-checkbox v-if="props.itemCategoryName === '数字式接地电阻表' || props.itemCategoryName === '模拟式接地电阻表'" v-model="form.appearance" :checked="true" :disabled="pageType === 'detail'">
      辅助接地电阻试验
    </el-checkbox>
  </div>
  <!-- 下面表格  -->
  <detail-block title=" " style="margin-top: 0;">
    <template v-if="props.pageType !== 'detail'" #btns>
      <el-button v-if="props.itemCategoryName === '电子式绝缘电阻表(数字式)' || props.itemCategoryName === '电子式绝缘电阻表(指针式)' || props.itemCategoryName === '兆欧表(指针式)'" type="primary">
        增加行
      </el-button>
      <el-button v-if="props.itemCategoryName === '电子式绝缘电阻表(数字式)' || props.itemCategoryName === '电子式绝缘电阻表(指针式)' || props.itemCategoryName === '兆欧表(指针式)'" type="info">
        删除行
      </el-button>
      <el-button v-if="props.itemCategoryName === '电子式绝缘电阻表(数字式)' || props.itemCategoryName === '电子式绝缘电阻表(指针式)' || props.itemCategoryName === '兆欧表(指针式)'" type="primary">
        计算结果
      </el-button>
      <el-button v-if="props.itemCategoryName === '数字式接地电阻表' || props.itemCategoryName === '模拟式接地电阻表'" type="primary">
        生成辅助接地电阻
      </el-button>
    </template>
    <el-table
      ref="tableRef"
      v-loading="tableLoading"
      :data="listBottom"
      border
      style="width: 100%;"
    >
      <el-table-column align="center" label="序号" width="80" type="index" />
      <el-table-column
        v-for="item in columns_bottom"
        :key="item.value"
        :prop="item.value"
        :label="item.text"
        :width="item.width"
        align="center"
      >
        <template #header>
          <span v-show="item.required" style="color: red;">*</span><span>{{ item.text }}</span>
        </template>
      </el-table-column>
    </el-table>
  </detail-block>
</template>