<!-- 第2套:直流稳压电源标准装置 --> <script lang="ts" setup name="TemplateDetailSecond"> import { ElMessage } from 'element-plus' import type { IList } from './templateDetail-interface' import templateTable from './templateTable.vue' 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' import type { TableColumn } from '@/components/NormalTable/table_interface' import { differenceArray, setSelectList } from '@/utils/Array' 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 form1 = ref({ voltageRepresentationValueErrorType: '1', // 电压表示值误差类型:1数字式、2指针式 ammeterDirectType: '1', // 电流表示值误差(直接测量)类型:1数字式、2指针式 ammeterIndirectType: '1', // 电流表示值误差(间接测量)类型:1数字式、2指针式 // technicalIndexSymbol: '≤', // 通用规则 appearanceFunctionCheck: 1, // 外观及功能性检查 voltageRegulation: 1, // 电源电压调整率 loadRegulation: 1, // 负载调整率 voltageRepresentError: 1, // 电压表示值误差 currentRepresentErrorDirect: 1, // 电流表示值误差(直接测量) currentRepresentErrorIndirect: 1, // 电流表示值误差(间接测量) rippleVoltage: 1, // 纹波电压 voltageOutputStability: 1, // 输出电压短期稳定性 }) watch(() => props.form, (newVal) => { form1.value = { ...newVal, voltageRepresentationValueErrorType: form1.value.voltageRepresentationValueErrorType, ammeterDirectType: form1.value.ammeterDirectType, ammeterIndirectType: form1.value.ammeterIndirectType, } // form1.value.voltageRepresentationValueErrorType = '1' // form1.value.ammeterDirectType = '1' // form1.value.ammeterIndirectType = '1' }) // 取消列表把列表置空 const pageEditFlag = ref(false) const tableLoading = ref(false) const list1 = ref<IList[]>([]) const lineVoltageRegulationList = ref<IList[]>([]) // 电源电压调整率 const loadRegulationList = ref<IList[]>([]) // 负载调整率 const voltageRepresentationValueErrorList = ref<IList[]>([]) // 电压表示值误差 const ammeterDirectList = ref<IList[]>([]) // 电流表示值误差(直接测量) const ammeterIndirectList = ref<IList[]>([]) // 电流表示值误差(间接测量) const rippleVoltageList = ref<IList[]>([]) // 纹波电压 const outputVoltageStabilityList = ref<IList[]>([]) // 输出电压短期稳定性 // 表格数据对应 list 字典 const listDict = ref<{ [key: string]: any }>() // 监听所有表格数据 watch(() => [lineVoltageRegulationList.value, loadRegulationList.value, voltageRepresentationValueErrorList.value, ammeterDirectList.value, ammeterIndirectList.value, rippleVoltageList.value, outputVoltageStabilityList.value], () => { listDict.value = { '1-电源电压调整率': lineVoltageRegulationList.value, // 1 '2-负载调整率': loadRegulationList.value, // 2 '3-电压示值误差': voltageRepresentationValueErrorList.value, // 3 '4-电流示值误差(直接测量)': ammeterDirectList.value, // 4 '5-电流示值误差(间接测量)': ammeterIndirectList.value, // 5 '6-纹波电压': rippleVoltageList.value, // 6 '7-输出电压短期稳定性': outputVoltageStabilityList.value, // 7 } list1.value = [] for (const i in listDict.value) { list1.value = [...list1.value, ...listDict.value[i]] } }, { deep: true, }) // watch(() => form.value.technicalIndexSymbol, (newVal) => { // if (newVal) { // for (const i in listDict.value) { // listDict.value[i] = listDict.value[i].map((item: any) => ({ ...item, technicalIndexSymbol: newVal })) // } // } // }) // 清空所有数据 function clearAllList() { list1.value = [] lineVoltageRegulationList.value = [] // 电源电压调整率 loadRegulationList.value = [] // 负载调整率 voltageRepresentationValueErrorList.value = [] // 电压表示值误差 ammeterDirectList.value = [] // 电流表示值误差(直接测量) ammeterIndirectList.value = [] // 电流表示值误差(间接测量) rippleVoltageList.value = [] // 纹波电压 outputVoltageStabilityList.value = [] // 输出电压短期稳定性 for (const i in listDict.value) { listDict.value[i] = [] } } // 页面 pageType 发生变化清空所有数据 watch(() => props.pageType, () => { clearAllList() setLoadSituation('', [], '') }) const lineVoltageRegulationCheckoutList = ref<IList[]>([]) // 电源电压调整率多选 const loadRegulationCheckoutList = ref<IList[]>([]) // 负载调整率多选 const voltageRepresentationValueErrorCheckoutList = ref<IList[]>([]) // 电压表示值误差多选 const ammeterDirectCheckoutList = ref<IList[]>([]) // 电流表示值误差(直接测量)多选 const ammeterIndirectCheckoutList = ref<IList[]>([]) // 电流表示值误差(间接测量)多选 const rippleVoltageCheckoutList = ref<IList[]>([]) // 纹波电压多选 const outputVoltageStabilityCheckoutList = ref<IList[]>([]) // 输出电压短期稳定性多选 // ----------------------------------------表头------------------------------------------------ const columns_line_voltage_regulation = ref<TableColumn[]>([ // 电源电压调整率 { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' }, { text: '输出通道', value: 'outputChannel', align: 'center', required: true, type: 'select-dict', code: 'standardOutputChannel' }, { text: '单位', value: 'unit', align: 'center', required: true, type: 'select' }, { text: '调压器输出值', value: 'voltageRegulatorOutputValue', align: 'center', required: true, type: 'select' }, { text: '被检电源技术指标', value: 'technicalIndex', align: 'center', required: true, type: 'number' }, ]) const columns_load_regulation = ref<TableColumn[]>([ // 负载调整率 { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' }, { text: '输出通道', value: 'outputChannel', align: 'center', required: true, type: 'select' }, { text: '单位', value: 'unit', align: 'center', required: true, type: 'select' }, { text: '负载情况', value: 'loadSituation', align: 'center', required: true, type: 'select' }, { text: '被检电源技术指标', value: 'technicalIndex', align: 'center', required: true, type: 'number' }, ]) // 电压表示值误差(数字式)、电流表示值误差(直接测量)--(数字式) const columns_voltage_representation_value_error_number = ref<any[]>([ { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' }, { text: '输出通道', value: 'outputChannel', align: 'center', required: true, type: 'select-dict', code: 'standardOutputChannel' }, { text: '单位', value: 'unit', align: 'center', required: true, type: 'select' }, { text: '被检表示值', value: 'measureIndicationValue', align: 'center', required: true, type: 'number' }, { text: '误差参数a', value: 'errorParamA', align: 'center', required: true, type: 'number' }, { text: '误差参数b', value: 'errorParamB', align: 'center', required: true, type: 'number' }, { text: '最大允许误差', value: 'maximumError', align: 'center', required: true, type: 'select', bind: 'value', width: '300' }, { text: '分辨力', value: 'resolution', align: 'center', required: true, type: 'number', reg: (resolution: string | number) => { return Number(resolution) <= 1 } }, ]) // 电压表示值误差(数字式) const columns_voltage_representation = ref(columns_voltage_representation_value_error_number.value) // 电流表示值误差(直接测量) const columns_ammeter_direct = ref(columns_voltage_representation_value_error_number.value) // 电压表示值误差(指针式)、电流表示值误差(直接测量)--(指针式) const columns_voltage_representation_value_error_pointer = ref<any[]>([ { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' }, { text: '输出通道', value: 'outputChannel', align: 'center', required: true, type: 'select-dict', code: 'standardOutputChannel' }, { text: '单位', value: 'unit', align: 'center', required: true, type: 'select' }, { text: '被检表示值', value: 'measureIndicationValue', align: 'center', required: true, type: 'number' }, { text: '准确度a', value: 'accuracyA', align: 'center', required: true, type: 'number' }, { text: '指针式仪表满量程值', value: 'fullScaleValue', align: 'center', required: true, type: 'number' }, { text: '最大允许误差', value: 'maximumError', align: 'center', required: true, type: 'select', bind: 'value', width: '300' }, ]) // 电流表示值误差(间接测量)--数字式 const columns_ammeter_indirect_number = ref<any[]>([ { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' }, { text: '输出通道', value: 'outputChannel', align: 'center', required: true, type: 'select-dict', code: 'standardOutputChannel' }, { text: '单位', value: 'unit', align: 'center', required: true, type: 'select' }, { text: '被检表示值', value: 'measureIndicationValue', align: 'center', required: true, type: 'number' }, { text: '标准电阻值', value: 'standardResistanceValue', align: 'center', required: true, type: 'number' }, { text: '标准电阻值单位', value: 'standardResistanceValueUnit', align: 'center', required: true, type: 'select' }, { text: '误差参数a', value: 'errorParamA', align: 'center', required: true, type: 'number' }, { text: '误差参数b', value: 'errorParamB', align: 'center', required: true, type: 'number' }, { text: '最大允许误差', value: 'maximumError', align: 'center', required: true, type: 'select', bind: 'value', width: '300' }, { text: '分辨力', value: 'resolution', align: 'center', required: true, type: 'number' }, ]) // 电流表示值误差(间接测量) const columns_ammeter_indirect = ref(columns_ammeter_indirect_number.value) // 电流表示值误差(间接测量)--指针式 const columns_ammeter_indirect_pointer = ref<any[]>([ { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' }, { text: '输出通道', value: 'outputChannel', align: 'center', required: true, type: 'select-dict', code: 'standardOutputChannel' }, { text: '单位', value: 'unit', align: 'center', required: true, type: 'select' }, { text: '被检表示值', value: 'measureIndicationValue', align: 'center', required: true, type: 'number' }, { text: '标准电阻值', value: 'standardResistanceValue', align: 'center', required: true, type: 'number' }, { text: '标准电阻值单位', value: 'standardResistanceValueUnit', align: 'center', required: true, type: 'select' }, { text: '准确度a', value: 'accuracyA', align: 'center', required: true, type: 'number' }, { text: '指针式仪表满量程值', value: 'fullScaleValue', align: 'center', required: true, type: 'number' }, { text: '最大允许误差', value: 'maximumError', align: 'center', required: true, type: 'select', bind: 'value', width: '300' }, ]) // 纹波电压 const columns_ripple_voltage = ref<TableColumn[]>([ { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' }, { text: '输出通道', value: 'outputChannel', align: 'center', required: true, type: 'select-dict', code: 'standardOutputChannel' }, { text: '单位', value: 'unit', align: 'center', required: true, type: 'select' }, { text: '被检电源技术指标', value: 'technicalIndex', align: 'center', required: true, type: 'number' }, ]) // 输出电压短期稳定性 const columns_output_voltage_stability = ref<TableColumn[]>([ { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' }, { text: '输出通道', value: 'outputChannel', align: 'center', required: true, type: 'select-dict', code: 'standardOutputChannel' }, { text: '单位', value: 'unit', align: 'center', required: true, type: 'select' }, { text: '仪器技术指标', value: 'technicalIndex', align: 'center', required: true, type: 'number' }, ]) // --------------------------------表格操作--------------------------------------------------- // 多选 const handleSelectionChange = (e: any, type: string) => { switch (type) { case '电源电压调整率': // 电源电压调整率 lineVoltageRegulationCheckoutList.value = e break case '负载调整率': // 负载调整率 loadRegulationCheckoutList.value = e break case '电压示值误差': // 电压表示值误差 voltageRepresentationValueErrorCheckoutList.value = e break case '电流示值误差(直接测量)': // 电流表示值误差(直接测量) ammeterDirectCheckoutList.value = e break case '电流示值误差(间接测量)': // 电流表示值误差(间接测量) ammeterIndirectCheckoutList.value = e break case '纹波电压': // 纹波电压 rippleVoltageCheckoutList.value = e break case '输出电压短期稳定性': // 输出电压短期稳定性 outputVoltageStabilityCheckoutList.value = e break } } // 表格对应 columns字典 1数字式、2指针式 const columnsDict = ref<{ [key: string]: any }>( { '1-电源电压调整率': columns_line_voltage_regulation.value, // 1 '2-负载调整率': columns_load_regulation.value, // 2 '3-电压示值误差': columns_voltage_representation.value, // 3 '4-电流示值误差(直接测量)': columns_ammeter_direct.value, // 4 '5-电流示值误差(间接测量)': columns_ammeter_indirect.value, // 5 '6-纹波电压': columns_ripple_voltage.value, // 6 '7-输出电压短期稳定性': columns_output_voltage_stability.value, // 7 }, ) // 表格对应的 选择状态 let chekedDict = {} as { [key: string]: any } watch(() => form1.value, () => { chekedDict = { '1-电源电压调整率': form1.value.voltageRegulation, // 1 '2-负载调整率': form1.value.loadRegulation, // 2 '3-电压示值误差': form1.value.voltageRepresentError, // 3 '4-电流示值误差(直接测量)': form1.value.currentRepresentErrorDirect, // 4 '5-电流示值误差(间接测量)': form1.value.currentRepresentErrorIndirect, // 5 '6-纹波电压': form1.value.rippleVoltage, // 6 '7-输出电压短期稳定性': form1.value.voltageOutputStability, } }, { deep: true, }) /** * 增加行公共方法 * @param list 要操作的数组 * @param title 操作的表格 */ const addRow = (list: IList[], title: string, index: string) => { if (checkList(list, columnsDict.value[`${index}-${title}`], `${title}表格`)) { let data = {} as any switch (title) { case '电源电压调整率': // 电源电压调整率 data = { params: '电源电压调整率', dataType: '1', technicalIndexSymbol: '≤', // 技术指标前符号 technicalIndex: '', // 技术指标 outputChannel: '', // 输出通道 unit: '', // 单位 voltageRegulatorOutputValue: '', // 调压器输出值 editable: true, } as any // lineVoltageRegulationList.value.length ? lineVoltageRegulationList.value.push(lineVoltageRegulationList.value[lineVoltageRegulationList.value.length - 1]) : lineVoltageRegulationList.value.push(data) for (let i = 1; i < 4; i++) { lineVoltageRegulationList.value.push({ ...data, voltageRegulatorOutputValue: i === 1 ? '198' : i === 2 ? '220' : '242', id: `custom-${new Date().getTime()}` }) } break case '负载调整率': // 负载调整率 data = { params: '负载调整率', dataType: '2', technicalIndexSymbol: '≤', // 技术指标前符号 technicalIndex: '', // 技术指标 outputChannel: '', // 输出通道 unit: '', // 单位 editable: true, } for (let i = 1; i < 3; i++) { loadRegulationList.value.push({ ...data, loadSituation: i === 1 ? '满载' : '空载', id: `custom-${new Date().getTime()}` }) } break case '电压示值误差': // 电压表示值误差 // 1数字式、2指针式 if (voltageRepresentationValueErrorList.value.length) { voltageRepresentationValueErrorList.value.push(JSON.parse(JSON.stringify({ ...voltageRepresentationValueErrorList.value[voltageRepresentationValueErrorList.value.length - 1], id: `custom-${new Date().getTime()}` }))) break } data = { params: '电压示值误差', dataType: '3', outputChannel: '', // 输出通道 technicalIndexSymbol: '±', // 技术指标前符号 unit: '', // 单位 measureIndicationValue: '', // 被检表示值 resolution: '0.0001', // 分辨力 editable: true, } if (form1.value.voltageRepresentationValueErrorType === '1') { // 数字式 voltageRepresentationValueErrorList.value.push({ ...data, dataTypeType: '1', errorParamA: '', // 误差参数a errorParamB: '', // 误差参数b maximumError: '', id: `custom-${new Date().getTime()}`, }) } else { // 指针式 voltageRepresentationValueErrorList.value.push({ ...data, dataTypeType: '2', accuracyA: '', // 准确度a fullScaleValue: '', // 指针式仪表满量程值 maximumError: '1', // 最大允许误差 id: `custom-${new Date().getTime()}`, }) } break case '电流示值误差(直接测量)': // 电流表示值误差(直接测量) if (ammeterDirectList.value.length) { ammeterDirectList.value.push(JSON.parse(JSON.stringify({ ...ammeterDirectList.value[ammeterDirectList.value.length - 1], id: `custom-${new Date().getTime()}` }))) break } data = { params: '电流示值误差(直接测量)', dataType: '4', outputChannel: '', // 输出通道 technicalIndexSymbol: '±', // 技术指标前符号 unit: '', // 单位 measureIndicationValue: '', // 被检表示值 maximumError: '', // 最大允许误差 resolution: '0.0001', // 分辨力 editable: true, } // 1数字式、2指针式 if (form1.value.ammeterDirectType === '1') { // 数字式 ammeterDirectList.value.push({ ...data, dataTypeType: '1', errorParamA: '', // 误差参数a errorParamB: '', // 误差参数b id: `custom-${new Date().getTime()}`, }) } else { // 指针式 ammeterDirectList.value.push({ ...data, dataTypeType: '2', accuracyA: '', // 准确度a fullScaleValue: '', // 指针式仪表满量程值 maximumError: '1', // 最大允许误差 id: `custom-${new Date().getTime()}`, }) } break case '电流示值误差(间接测量)': // 电流表示值误差(间接测量) if (ammeterIndirectList.value.length) { ammeterIndirectList.value.push(JSON.parse(JSON.stringify({ ...ammeterIndirectList.value[ammeterIndirectList.value.length - 1], id: `custom-${new Date().getTime()}` }))) break } data = { params: '电流示值误差(间接测量)', dataType: '5', outputChannel: '', // 输出通道 technicalIndexSymbol: '±', // 技术指标前符号 standardResistanceValue: '', // 标准电阻值 standardResistanceValueUnit: '', // 标准电阻值单位 editable: true, unit: '', // 单位 measureIndicationValue: '', // 被检表示值 maximumError: '', // 最大允许误差 } // 1数字式、2指针式 if (form1.value.ammeterIndirectType === '1') { // 数字式 ammeterIndirectList.value.push({ ...data, dataTypeType: '1', errorParamA: '', // 误差参数a errorParamB: '', // 误差参数b maximumError: '', // 最大允许误差 resolution: '0.0001', // 分辨力 id: `custom-${new Date().getTime()}`, }) } else { // 指针式 ammeterIndirectList.value.push({ ...data, dataTypeType: '2', accuracyA: '', // 准确度a fullScaleValue: '', // 指针式仪表满量程值 maximumError: '1', // 最大允许误差 id: `custom-${new Date().getTime()}`, }) } break case '纹波电压': // 纹波电压 if (rippleVoltageList.value.length) { rippleVoltageList.value.push(JSON.parse(JSON.stringify({ ...rippleVoltageList.value[rippleVoltageList.value.length - 1], id: `custom-${new Date().getTime()}` }))) break } data = { params: '纹波电压', dataType: '6', technicalIndexSymbol: '≤', // 技术指标前符号 technicalIndex: 0, // 技术指标 outputChannel: '', // 输出通道 unit: '', // 单位 editable: true, id: `custom-${new Date().getTime()}`, } rippleVoltageList.value.push(data) break case '输出电压短期稳定性': // 输出电压短期稳定性 data = { params: '输出电压短期稳定性', dataType: '7', technicalIndexSymbol: '≤', // 技术指标前符号 technicalIndex: '', // 技术指标 outputChannel: '', // 输出通道 unit: '', // 单位 editable: true, id: `custom-${new Date().getTime()}`, } outputVoltageStabilityList.value.length ? outputVoltageStabilityList.value.push(JSON.parse(JSON.stringify({ ...outputVoltageStabilityList.value[outputVoltageStabilityList.value.length - 1], id: `custom-${new Date().getTime()}` }))) : outputVoltageStabilityList.value.push(data) break } } } /** * 删除行公共方法 * @param checkoutList 选中的数组 * @param list 操作的数组 */ const delRow = (checkoutList: IList[], list: IList[], title: string) => { if (!checkoutList.length) { ElMessage.warning('请选中要删除的行') } else { let data = [] as any[] data = differenceArray(list, checkoutList) switch (title) { case '电源电压调整率': // 电源电压调整率 // lineVoltageRegulationList.value = data lineVoltageRegulationList.value = lineVoltageRegulationList.value.filter((item: any) => { const needDelte = [...new Set(checkoutList.map(item => item.outputChannel))] return !needDelte.includes(item.outputChannel) }) break case '负载调整率': // 负载调整率 loadRegulationList.value = loadRegulationList.value.filter((item: any) => { const needDelte = [...new Set(checkoutList.map(item => item.outputChannel))] return !needDelte.includes(item.outputChannel) }) break case '电压示值误差': // 电压表示值误差 voltageRepresentationValueErrorList.value = data break case '电流示值误差(直接测量)': // 电流表示值误差(直接测量) ammeterDirectList.value = data break case '电流示值误差(间接测量)': // 电流表示值误差(间接测量) ammeterIndirectList.value = data break case '纹波电压': // 纹波电压 rippleVoltageList.value = data break case '输出电压短期稳定性': // 输出电压短期稳定性 outputVoltageStabilityList.value = data break } } } // ---------------------------------------------校验--------------------------------------------------- // 校验表格(点击保存的时候用、生成标准器示值) function checkList(list: any[], columns: any[], title: string) { return useCheckList(list, columns, title) } // 校验所有表格 function checkAllList() { let result = true for (const i in columnsDict.value) { if (!Number(chekedDict[i])) { result = true } else { const requireLength = !!((chekedDict[i] === '1' || chekedDict[i] === 1) && chekedDict[i]) if (!useCheckList(listDict.value[i], columnsDict.value[i], i.substring(2), '', '', '', requireLength)) { result = false break } } } return result } // ----------------------------------------------------------------------------------------------------- // 设置默认值 const setType = (list: Ilist[]) => { // 设置默认 通用规则 // if (list?.length) { // form.value.technicalIndexSymbol = list[0].technicalIndexSymbol // } // else { // form.value.technicalIndexSymbol = '≤' // } // 设置 类型 1数字式、2指针式 pageEditFlag.value = false for (let i = 3; i < 6; i++) { const data = list.filter(item => item.dataType === i.toString()) const dataLength = data.length // if (dataLength) { switch (i) { case 3: // 电压表示值误差 form1.value.voltageRepresentationValueErrorType = dataLength ? data[0].dataTypeType : '1' break case 4: // 电流表示值误差(直接测量) form1.value.ammeterDirectType = dataLength ? data[0].dataTypeType : '1' break case 5: // 电流表示值误差(间接测量) form1.value.ammeterIndirectType = dataLength ? data[0].dataTypeType : '1' break } // } } setTimeout(() => { pageEditFlag.value = true }, 500) } // 监听 父组件传来的数据 watch(() => props.list, (newVal) => { if (newVal) { clearAllList() setType(newVal) newVal.forEach((item: IList) => { switch (item.dataType) { case '1': // 电源电压调整率 lineVoltageRegulationList.value.push({ ...item, params: '电源电压调整率' }) break case '2': // 负载调整率 loadRegulationList.value.push({ ...item, params: '负载调整率' }) break case '3': // 电压表示值误差 voltageRepresentationValueErrorList.value.push({ ...item, params: '电压示值误差' }) form1.value.voltageRepresentationValueErrorType = item.dataTypeType as string break case '4': // 电流表示值误差(直接测量) ammeterDirectList.value.push({ ...item, params: '电流示值误差(直接测量)' }) form1.value.ammeterDirectType = item.dataTypeType as string break case '5': // 电流表示值误差(间接测量) ammeterIndirectList.value.push({ ...item, params: '电流示值误差(间接测量)' }) form1.value.ammeterIndirectType = item.dataTypeType as string break case '6': // 纹波电压 rippleVoltageList.value.push({ ...item, params: '纹波电压' }) break case '7': // 输出电压短期稳定性 outputVoltageStabilityList.value.push({ ...item, params: '输出电压短期稳定性' }) break } }) } }) // 电压表示值误差、监听电流表示值误差(直接测量) watch(() => form1.value.voltageRepresentationValueErrorType, (newValue) => { if (newValue === '2') { columns_voltage_representation.value = columns_voltage_representation_value_error_pointer.value } else { columns_voltage_representation.value = columns_voltage_representation_value_error_number.value } columnsDict.value['3-电压示值误差'] = columns_voltage_representation.value if (!pageEditFlag.value) { return } voltageRepresentationValueErrorList.value = [] }) watch(() => form1.value.ammeterDirectType, (newValue) => { if (newValue === '2') { columns_ammeter_direct.value = columns_voltage_representation_value_error_pointer.value } else { columns_ammeter_direct.value = columns_voltage_representation_value_error_number.value } columnsDict.value['4-电流示值误差(直接测量)'] = columns_ammeter_direct.value if (!pageEditFlag.value) { return } ammeterDirectList.value = [] }) // 监听电流表示值误差(间接测量) watch(() => form1.value.ammeterIndirectType, (newValue) => { if (newValue === '2') { // 指针式 columns_ammeter_indirect.value = columns_ammeter_indirect_pointer.value } else { // 数字式 columns_ammeter_indirect.value = columns_ammeter_indirect_number.value } columnsDict.value['5-电流示值误差(间接测量)'] = columns_ammeter_indirect.value if (!pageEditFlag.value) { return } ammeterIndirectList.value = [] }) // 监听 输出通道 修改下拉框内容 const changeLoadSituationaSymbol = (value: any, index: number, text: string, type: string, list: IList[], item: string) => { if (type === 'change' && item === '电源电压调整率' && text === '被检电源技术指标') { if (Number(index) % 3 === 0) { lineVoltageRegulationList.value[index + 1].technicalIndexSymbol = value lineVoltageRegulationList.value[index + 2].technicalIndexSymbol = value } } if (type === 'change' && item === '负载调整率' && text === '被检电源技术指标') { if (Number(index) % 2 === 0) { loadRegulationList.value[index + 1].technicalIndexSymbol = value } } } const changeLoadSituationa = (value: any, index: number, text: string, type: string, list: IList[], item: string) => { if (type === 'change' && item === '电源电压调整率' && text === '被检电源技术指标') { if (Number(index) % 3 === 0) { lineVoltageRegulationList.value[index + 1].technicalIndex = value lineVoltageRegulationList.value[index + 2].technicalIndex = value } } if (type === 'change' && item === '负载调整率' && text === '被检电源技术指标') { if (Number(index) % 2 === 0) { loadRegulationList.value[index + 1].technicalIndex = value } } if (text !== '输出通道') { return } if (type === 'change' && item === '负载调整率') { // 1.判断奇偶修改对应的 输出通道 if (Number(index) % 2 === 0) { loadRegulationList.value[index + 1].outputChannel = value } else { loadRegulationList.value[index - 1].outputChannel = value } } if (type === 'change' && item === '电源电压调整率') { if (Number(index) % 3 === 0) { lineVoltageRegulationList.value[index + 1].outputChannel = value lineVoltageRegulationList.value[index + 2].outputChannel = value } else if (Number(index) % 3 === 1) { lineVoltageRegulationList.value[index - 1].outputChannel = value lineVoltageRegulationList.value[index + 1].outputChannel = value } else if (Number(index) % 3 === 2) { lineVoltageRegulationList.value[index - 1].outputChannel = value lineVoltageRegulationList.value[index - 2].outputChannel = value } } // 2.限制下拉框内容 setLoadSituation(typeof value === 'string' ? value : list[index].outputChannel as string, list, item) } // 表格下拉框等内容是否禁用 const disabled = ({ scope, column }, fun) => { if (scope.row.params === '电源电压调整率' && column.text === '被检电源技术指标' && (scope.$index % 3 !== 0)) { fun(true) return } if (scope.row.params === '负载调整率' && column.text === '被检电源技术指标' && (scope.$index % 2 !== 0)) { fun(true) return } // 禁用的话 调用fun函数并传递参数 if (column.text === '负载情况') { fun(true) return } if (column.text === '调压器输出值') { fun(true) return } // 指针式 禁用最大允许误差 if (scope.row.dataTypeType === '2' && column.text === '最大允许误差') { fun(true) return } fun(props.pageType === 'detail') } // 禁用某一个选项 // const disabledItem = ({ scope, column, citem }, fun) => { // if (scope.row.dataTypeType === '1' && column.text === '最大允许误差' && citem.value === '1') { // return true // } // return false // } // ---------------------------------------------获取字典--------------------------------------------------- const TechnicalIndexSymbolList = ref<{ value: string;name: string;id: string }[]>([]) // 技术指标前符号 const OutputChannelList = ref<{ value: string;name: string;id: string }[]>([]) // 输出通道 const unitList = ref<{ value: string;name: string;id: string }[]>([]) // 单位 const unitList1 = ref<{ value: string;name: string;id: string }[]>([]) // 单位 (直接测量/间接测量) const RegulatorOutputValue = ref<{ value: string;name: string;id: string }[]>([]) // 调压器输出值 const loadSituationList = ref<{ value: string;name: string;id: string }[]>([ { name: '空载', value: '1', id: '1', }, { name: '满载', value: '2', id: '2', }, ]) // 负载情况 const OutputChannelAllList = ref<{ value: string;name: string;id: string }[]>([]) // 所有输出通道 const standardMaximumError = ref<{ value: string;name: string;id: string }[]>([]) // 最大允许误差公式 const standardResistance = ref<{ value: string;name: string;id: string }[]>([]) // 标准电阻值单位 const typeList = [{ value: '1', name: '数字式', }, { value: '2', name: '指针式', }] // 每个table对应的下拉框内容 字典 const tableDict = ref<{ [key: string]: { value: string;name: string;id: string }[] }>({}) // 修改输出通道 function setLoadSituation(current: string, list: IList[], title: string) { if (props.pageType === 'detail' || title !== '负载调整率') { tableDict.value['输出通道'] = OutputChannelAllList.value } else { tableDict.value['输出通道'] = setSelectList(OutputChannelAllList.value, list, current, 'outputChannel', 'name') } } const fecthDict = async () => { // 技术指标前符号 const res1 = await getDictByCode('standardTechnicalIndexSymbol') TechnicalIndexSymbolList.value = res1.data // 输出通道 const res2 = await getDictByCode('standardOutputChannel') OutputChannelList.value = res2.data OutputChannelAllList.value = JSON.parse(JSON.stringify(res2.data)) // 单位 const res3 = await getDictByCode('unitElectricalSignalV') unitList.value = res3.data // 调压器输出值 const res4 = await getDictByCode('voltageRegulatorOutputValue') RegulatorOutputValue.value = res4.data // 最大允许误差公式 const res5 = await getDictByCode('secondStandardMaximumError') standardMaximumError.value = res5.data if (standardMaximumError.value.length) { standardMaximumError.value[0].disabled = true } // 单位 (直接测量/间接测量) const res6 = await getDictByCode('unitElectricalSignalA') unitList1.value = res6.data // 标准电阻值单位 const res7 = await getDictByCode('standardResistance') standardResistance.value = res7.data // table字典 tableDict.value = { 输出通道: OutputChannelList.value, 单位: unitList.value, 调压器输出值: RegulatorOutputValue.value, 负载情况: loadSituationList.value, 最大允许误差: standardMaximumError.value, 标准电阻值单位: standardResistance.value, } } // 自定义下拉框内容 const customSelect = (data: any, fun: any) => { if (data.column.text === '单位') { fun(unitList1.value) } else { fun(tableDict.value[data.text]) } } // 生成最终list const getList = () => { let result = [] as any[] for (const i in chekedDict) { if ((chekedDict[i] === '1' || chekedDict[i] === 1) && chekedDict[i]) { result = [...result, ...listDict.value[i]] } } return result } fecthDict() // 清空配置方法 const clearConfig = () => { list1.value = [] lineVoltageRegulationList.value = [] loadRegulationList.value = [] voltageRepresentationValueErrorList.value = [] ammeterDirectList.value = [] ammeterIndirectList.value = [] rippleVoltageList.value = [] outputVoltageStabilityList.value = [] } defineExpose({ list1, checkAllList, form1, getList, clearConfig }) </script> <template> <div style="padding: 0 10px;display: flex;justify-content: space-between;"> <el-checkbox v-model="form1.appearanceFunctionCheck" :checked="true" :true-label="1" :false-label="0" :disabled="pageType === 'detail'"> 外观及功能性检查 </el-checkbox> </div> <!-- 电源电压调整率 --> <template-table :show="Boolean(form1.voltageRegulation)" :data="lineVoltageRegulationList" :columns="columns_line_voltage_regulation" :page-type="pageType" title="电源电压调整率" index="1" :show-btn="pageType !== 'detail'" :select-all-list="tableDict" @disabled="disabled" @selection-change="(e) => handleSelectionChange(e, '电源电压调整率')" @add-row="addRow" @del-row="delRow" @change-load-situationa="changeLoadSituationa" > <template #custom-check> <el-checkbox v-model="form1.voltageRegulation" :checked="true" :true-label="1" :false-label="0" :disabled="pageType === 'detail'"> 电源电压调整率 </el-checkbox> </template> <!-- 技术指标 --> <template #pre-content="{ scope, column, index }"> <div v-if="column.text === '被检电源技术指标'" style="line-height: 30px;margin-right: 10px;"> <el-select v-model="scope.technicalIndexSymbol" placeholder="请选择" :disabled="pageType === 'detail' || (index % 3 !== 0)" class="full-width-input" style="margin-right: 10px;width: 50px;" @change="(value) => changeLoadSituationaSymbol(value, index, '被检电源技术指标', 'change', [], '电源电压调整率')" > <el-option v-for="item of TechnicalIndexSymbolList" :key="item.value" :label="item.name" :value="item.value" /> </el-select> </div> </template> <!-- 符号 --> <template #next-content="{ column }"> <div v-if="column.text === '被检电源技术指标'" style="line-height: 30px;margin-left: 10px;"> % </div> </template> </template-table> <!-- 负载调整率 --> <template-table :show="Boolean(form1.loadRegulation)" :data="loadRegulationList" :columns="columns_load_regulation" :page-type="pageType" title="负载调整率" index="2" :show-btn="pageType !== 'detail'" :select-all-list="tableDict" @disabled="disabled" @selection-change="(e) => handleSelectionChange(e, '负载调整率')" @add-row="addRow" @del-row="delRow" @change-load-situationa="changeLoadSituationa" > <template #custom-check> <el-checkbox v-model="form1.loadRegulation" :checked="true" :true-label="1" :false-label="0" :disabled="pageType === 'detail'"> 负载调整率 </el-checkbox> </template> <!-- 技术指标 --> <template #pre-content="{ scope, column, index }"> <!-- <div v-if="column.text === '被检电源技术指标'" style="line-height: 30px;margin-right: 10px;"> {{ scope.technicalIndexSymbol }} </div> --> <div v-if="column.text === '被检电源技术指标'" style="line-height: 30px;margin-right: 10px;"> <!-- {{ scope.technicalIndexSymbol }} --> <el-select v-model="scope.technicalIndexSymbol" placeholder="请选择" :disabled="pageType === 'detail' || (index % 2 !== 0)" class="full-width-input" style="margin-right: 10px;width: 50px;" @change="(value) => changeLoadSituationaSymbol(value, index, '被检电源技术指标', 'change', [], '负载调整率')" > <el-option v-for="item of TechnicalIndexSymbolList" :key="item.value" :label="item.name" :value="item.value" /> </el-select> </div> </template> <!-- 符号 --> <template #next-content="{ column }"> <div v-if="column.text === '被检电源技术指标'" style="line-height: 30px;margin-left: 10px;"> % </div> </template> </template-table> <!-- 电压表示值误差 --> <template-table :show="Boolean(form1.voltageRepresentError)" :data="voltageRepresentationValueErrorList" :columns="columns_voltage_representation" :page-type="pageType" title="电压示值误差" index="3" :show-btn="pageType !== 'detail'" :select-all-list="tableDict" @disabled="disabled" @selection-change="(e) => handleSelectionChange(e, '电压示值误差')" @add-row="addRow" @del-row="delRow" @change-load-situationa="changeLoadSituationa" > <template #custom-check> <el-checkbox v-model="form1.voltageRepresentError" :checked="true" :true-label="1" :false-label="0" :disabled="pageType === 'detail'"> 电压示值误差 </el-checkbox> </template> <template #custom-right> <!-- 选择类型:1数字式、2指针式 --> <el-select v-model="form1.voltageRepresentationValueErrorType" placeholder="请选择" :disabled="pageType === 'detail'" style="margin-right: 10px;width: 120px !important;" > <el-option v-for="item of typeList" :key="item.value" :label="item.name" :value="item.value" /> </el-select> </template> <!-- 技术指标 --> <template #pre-content="{ scope, column }"> <div v-if="column.text === '被检电源技术指标'" style="line-height: 30px;margin-right: 10px;"> {{ scope.technicalIndexSymbol }} </div> </template> <!-- 符号 --> <template #next-content="{ column }"> <div v-if="column.text === '被检电源技术指标'" style="line-height: 30px;margin-left: 10px;"> % </div> </template> </template-table> <!-- 电流表示值误差(直接测量) --> <template-table :show="Boolean(form1.currentRepresentErrorDirect)" :data="ammeterDirectList" :columns="columns_ammeter_direct" :page-type="pageType" title="电流示值误差(直接测量)" index="4" :show-btn="pageType !== 'detail'" :custom-select="true" :select-all-list="tableDict" @custom-select="customSelect" @disabled="disabled" @selection-change="(e) => handleSelectionChange(e, '电流示值误差(直接测量)')" @add-row="addRow" @del-row="delRow" @change-load-situationa="changeLoadSituationa" > <template #custom-check> <el-checkbox v-model="form1.currentRepresentErrorDirect" :checked="true" :true-label="1" :false-label="0" :disabled="pageType === 'detail'"> 电流示值误差(直接测量) </el-checkbox> </template> <template #custom-right> <!-- 选择类型:1数字式、2指针式 --> <el-select v-model="form1.ammeterDirectType" placeholder="请选择" :disabled="pageType === 'detail'" style="margin-right: 10px;width: 120px !important;" > <el-option v-for="item of typeList" :key="item.value" :label="item.name" :value="item.value" /> </el-select> </template> </template-table> <!-- 电流表示值误差(间接测量) --> <template-table :show="Boolean(form1.currentRepresentErrorIndirect)" :data="ammeterIndirectList" :columns="columns_ammeter_indirect" :page-type="pageType" title="电流示值误差(间接测量)" index="5" :show-btn="pageType !== 'detail'" :custom-select="true" :select-all-list="tableDict" @disabled="disabled" @custom-select="customSelect" @selection-change="(e) => handleSelectionChange(e, '电流示值误差(间接测量)')" @add-row="addRow" @del-row="delRow" @change-load-situationa="changeLoadSituationa" > <template #custom-check> <el-checkbox v-model="form1.currentRepresentErrorIndirect" :checked="true" :true-label="1" :false-label="0" :disabled="pageType === 'detail'"> 电流示值误差(间接测量) </el-checkbox> </template> <template #custom-right> <!-- 选择类型:1数字式、2指针式 --> <el-select v-model="form1.ammeterIndirectType" placeholder="请选择" :disabled="pageType === 'detail'" style="margin-right: 10px;width: 120px !important;" > <el-option v-for="item of typeList" :key="item.value" :label="item.name" :value="item.value" /> </el-select> </template> </template-table> <!-- 纹波电压 --> <template-table :show="Boolean(form1.rippleVoltage)" :data="rippleVoltageList" :columns="columns_ripple_voltage" :page-type="pageType" title="纹波电压" index="6" :show-btn="pageType !== 'detail'" :select-all-list="tableDict" @disabled="disabled" @selection-change="(e) => handleSelectionChange(e, '纹波电压')" @add-row="addRow" @del-row="delRow" @change-load-situationa="changeLoadSituationa" > <template #custom-check> <el-checkbox v-model="form1.rippleVoltage" :checked="true" :true-label="1" :false-label="0" :disabled="pageType === 'detail'"> 纹波电压 </el-checkbox> </template> <!-- 技术指标 --> <template #pre-content="{ scope, column }"> <!-- <div v-if="column.text === '被检电源技术指标'" style="line-height: 30px;margin-right: 10px;"> {{ scope.technicalIndexSymbol }} </div> --> <div v-if="column.text === '被检电源技术指标'" style="line-height: 30px;margin-right: 10px;"> <!-- {{ scope.technicalIndexSymbol }} --> <el-select v-model="scope.technicalIndexSymbol" placeholder="请选择" :disabled="pageType === 'detail'" class="full-width-input" style="margin-right: 10px;width: 50px;" > <el-option v-for="item of TechnicalIndexSymbolList" :key="item.value" :label="item.name" :value="item.value" /> </el-select> </div> </template> </template-table> <!-- 输出电压短期稳定性 --> <template-table :show="Boolean(form1.voltageOutputStability)" :data="outputVoltageStabilityList" :columns="columns_output_voltage_stability" :page-type="pageType" title="输出电压短期稳定性" index="7" :show-btn="pageType !== 'detail'" :select-all-list="tableDict" @disabled="disabled" @selection-change="(e) => handleSelectionChange(e, '输出电压短期稳定性')" @add-row="addRow" @del-row="delRow" @change-load-situationa="changeLoadSituationa" > <template #custom-check> <el-checkbox v-model="form1.voltageOutputStability" :checked="true" :true-label="1" :false-label="0" :disabled="pageType === 'detail'"> 输出电压短期稳定性 </el-checkbox> </template> <!-- 技术指标 --> <template #pre-content="{ scope, column }"> <!-- <div v-if="column.text === '被检电源技术指标'" style="line-height: 30px;margin-right: 10px;"> {{ scope.technicalIndexSymbol }} </div> --> <div v-if="column.text === '仪器技术指标'" style="line-height: 30px;margin-right: 10px;"> <!-- {{ scope.technicalIndexSymbol }} --> <el-select v-model="scope.technicalIndexSymbol" placeholder="请选择" :disabled="pageType === 'detail'" class="full-width-input" style="margin-right: 10px;width: 50px;" > <el-option v-for="item of TechnicalIndexSymbolList" :key="item.value" :label="item.name" :value="item.value" /> </el-select> </div> </template> <!-- 符号 --> <template #next-content="{ column }"> <div v-if="column.text === '仪器技术指标'" style="line-height: 30px;margin-left: 10px;"> % </div> </template> </template-table> </template>