<!-- 第三套:多功能电气安全校准器标准装置 --> <script lang="ts" setup name="TemplateDetailThird"> import { ElMessage } from 'element-plus' import type { IList } from './templateDetail-interface' import { getUid } from '@/utils/getUid' 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 listTopCheckout = ref<IList[]>([]) // 表格数据(上面表格)多选 const listBottomCheckout = ref<IList[]>([]) // 表格数据(下面表格)多选 const showListTop = ref(true) // 上面表格是否显示 const showListBottom = ref(true) // 下面表格是否显示 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, width: '100' }, { 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 handleSelectionChange = (e: any, type: 'top' | 'bottom') => { if (type === 'top') { // 上面表格多选 listTopCheckout.value = e } else { // 下面表格多选 listBottomCheckout.value = e } } /** * 增加行 * @param dataType 1上面表格 2下面表格 */ const addRow = (dataType: string) => { if (dataType === '1') { // 开路电压 if (props.itemCategoryName === '电子式绝缘电阻表(数字式)') { if (!useCheckList(listTop.value, columns_top_voltage_insulation_megger.value, '开路电压')) { return false } listTop.value.push({ id: '', params: '开路电压', // 检定项目 nominalValue: listTop.value.length ? listTop.value[listTop.value.length - 1].nominalValue : '', // 标称值 dataType, // 检定项数据类型(一个检定项中区分两个表格)(字典code),同对应的检定项类型 minimumAllowFactorA: listTop.value.length ? listTop.value[listTop.value.length - 1].minimumAllowFactorA : '', // 最小允许值相关系数a maximumAllowFactorB: listTop.value.length ? listTop.value[listTop.value.length - 1].maximumAllowFactorB : '', // 最大允许值相关系数b minimumAllowValue: listTop.value.length ? listTop.value[listTop.value.length - 1].minimumAllowValue : '', // 最小允许值 maximumAllowValue: listTop.value.length ? listTop.value[listTop.value.length - 1].maximumAllowValue : '', // 最大允许值 itemId: props.itemId, // 检定项id }) } } else { // 示值误差 if (props.itemCategoryName === '电子式绝缘电阻表(数字式)') { if (!useCheckList(listBottom.value, columns_bottom_Electronic_insulation_resistance_meter_number.value, '示值误差')) { return false } listTop.value.push({ id: '', params: '示值误差', // 检定项目 nominalValue: listTop.value.length ? listTop.value[listTop.value.length - 1].nominalValue : '', // 标称值 dataType, // 检定项数据类型(一个检定项中区分两个表格)(字典code),同对应的检定项类型 minimumAllowFactorA: listTop.value.length ? listTop.value[listTop.value.length - 1].minimumAllowFactorA : '', // 最小允许值相关系数a maximumAllowFactorB: listTop.value.length ? listTop.value[listTop.value.length - 1].maximumAllowFactorB : '', // 最大允许值相关系数b minimumAllowValue: listTop.value.length ? listTop.value[listTop.value.length - 1].minimumAllowValue : '', // 最小允许值 maximumAllowValue: listTop.value.length ? listTop.value[listTop.value.length - 1].maximumAllowValue : '', // 最大允许值 itemId: props.itemId, // 检定项id }) } } } // 删除行 const deleteRow = (type: 'top' | 'bottom') => { if (type === 'top' && !listTopCheckout.value.length) { ElMessage.warning('请选中要删除的行') } if (type === 'bottom' && !listBottomCheckout.value.length) { ElMessage.warning('请选中要删除的行') } else { if (type === 'top') { listTop.value = listTop.value.filter((item: any) => { return !listTopCheckout.value.includes(item) }) } else { listBottom.value = listBottom.value.filter((item: any) => { return !listBottomCheckout.value.includes(item) }) } } } // ---------------------------------------------校验--------------------------------------------------- // 校验表格(点击保存的时候用、生成标准器示值) function 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="showListTop" :checked="true" :disabled="pageType === 'detail'"> 开路电压 </el-checkbox> <el-checkbox v-if="props.itemCategoryName === '数字式接地电阻表' || props.itemCategoryName === '模拟式接地电阻表'" v-model="showListTop" :checked="true" :disabled="pageType === 'detail'"> 示值误差 </el-checkbox> </div> <!-- 上面表格 --> <detail-block v-if="showListTop" title=" " style="margin-top: 0;"> <template v-if="props.pageType !== 'detail'" #btns> <el-button type="primary" @click="addRow('1')"> 增加行 </el-button> <el-button type="info" @click="deleteRow('top')"> 删除行 </el-button> <el-button type="primary"> 计算结果 </el-button> </template> <el-table ref="tableRef" v-loading="tableLoading" :data="listTop" border style="width: 100%;" @selection-change="(e) => handleSelectionChange(e, 'top')" > <el-table-column v-if="pageType !== 'detail'" type="selection" width="38" /> <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> <template #default="scope"> <!-- 标称值、最小允许值相关系数a、最大允许值相关系数b --> <el-input-number v-if="props.pageType !== 'detail' && (item.value === 'nominalValue' || item.value === 'minimumAllowFactorA' || item.value === 'maximumAllowFactorB')" v-model="scope.row[item.value]" :placeholder="pageType === 'detail' ? '' : `${item.text}`" :disabled="pageType === 'detail'" class="full-width-input" /> </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="showListBottom" :checked="true" :disabled="pageType === 'detail'"> 示值误差 </el-checkbox> <el-checkbox v-if="props.itemCategoryName === '数字式接地电阻表' || props.itemCategoryName === '模拟式接地电阻表'" v-model="showListBottom" :checked="true" :disabled="pageType === 'detail'"> 辅助接地电阻试验 </el-checkbox> </div> <!-- 下面表格 --> <detail-block v-if="showListBottom" title=" " style="margin-top: 0;"> <template v-if="props.pageType !== 'detail'" #btns> <el-button v-if="props.itemCategoryName === '电子式绝缘电阻表(数字式)' || props.itemCategoryName === '电子式绝缘电阻表(指针式)' || props.itemCategoryName === '兆欧表(指针式)'" type="primary" @click="addRow('2')"> 增加行 </el-button> <el-button v-if="props.itemCategoryName === '电子式绝缘电阻表(数字式)' || props.itemCategoryName === '电子式绝缘电阻表(指针式)' || props.itemCategoryName === '兆欧表(指针式)'" type="info" @click="deleteRow('bottom')"> 删除行 </el-button> <el-button v-if="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%;" @selection-change="(e) => handleSelectionChange(e, 'bottom')" > <el-table-column v-if="pageType !== 'detail'" type="selection" width="38" /> <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>