误差体系修改

This commit is contained in:
caozehui
2025-04-22 14:21:24 +08:00
parent 9ed47ac5bc
commit 3891e5459a
3 changed files with 220 additions and 191 deletions

View File

@@ -33,7 +33,9 @@ export namespace ErrorSystem {
endFlag?:number;//是否包含结束值 endFlag?:number;//是否包含结束值
conditionType?:string;//判断条件值类型(包括值类型,绝对值、相对值) conditionType?:string;//判断条件值类型(包括值类型,绝对值、相对值)
maxErrorValue:number;//误差最大值 maxErrorValue:number;//误差最大值
errorValueType:string;//误差值类型(包括值类型绝对值、相对值1、相对值2 errorValueType:any;//误差值类型(0标称值、1标准值、2值类型
valueType:number;//值类型1绝对值、2相对值
errorUnit:string;//误差单位
} }
//查看详细误差体系 //查看详细误差体系

View File

@@ -1,169 +1,161 @@
<template> <template>
<div class="dialog-footer"> <div class="dialog-footer">
<el-button :icon='CirclePlus' type="primary" @click="openAddDialog">新增</el-button> <el-button :icon='CirclePlus' type="primary" @click="openAddDialog">新增</el-button>
<el-button :icon='Delete' type="danger" plain :disabled='!multipleSelection.length' @click="deleteSelectedRows">删除</el-button> <el-button :icon='Delete' type="danger" plain :disabled='!multipleSelection.length' @click="deleteSelectedRows">删除</el-button>
</div> </div>
<div class="table-container"> <div class="table-container">
<el-table :data="tableData" <el-table :data="tableData"
:header-cell-style="{ textAlign: 'center',backgroundColor: 'var(--el-color-primary)',color: '#fff' } " :header-cell-style="{ textAlign: 'center',backgroundColor: 'var(--el-color-primary)',color: '#fff' } "
:cell-style="{ textAlign: 'center' }" :cell-style="{ textAlign: 'center' }"
style="width: 100%" style="width: 100%"
:style="{ height: '400px',maxHeight: '400px',overflow:'hidden'}" :style="{ height: '400px',maxHeight: '400px',overflow:'hidden'}"
@selection-change="handleSelectionChange"> @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" /> <el-table-column type="selection" width="55"/>
<el-table-column prop="sort" label="序号" width="60" /> <el-table-column prop="sort" label="序号" width="60"/>
<el-table-column prop="type" label="误差类型" min-width="180"> <el-table-column prop="type" label="误差类型" min-width="180">
<template #default="{ row }"> <template #default="{ row }">
<el-cascader style="min-width: 180px;" <el-cascader style="min-width: 180px;"
:options="errorOptions" :options="errorOptions"
v-model="row.errorType" v-model="row.errorType"
:props="{ checkStrictly: false, emitPath: false }" :props="{ checkStrictly: false, emitPath: false }"
placeholder="请选择误差类型" placeholder="请选择误差类型"
@change="handleErrorTypeChange($event, row)"/> @change="handleErrorTypeChange($event, row)"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="type" label="脚本类型" min-width="230"> <el-table-column prop="type" label="脚本类型" min-width="230">
<template #default="{ row }"> <template #default="{ row }">
<el-cascader style="min-width: 230px;" <el-cascader style="min-width: 230px;"
:options="scriptOptions" :options="scriptOptions"
v-model="row.scriptType" v-model="row.scriptType"
:props="{ checkStrictly: false, emitPath: false }" :props="{ checkStrictly: false, emitPath: false }"
placeholder="请选择脚本类型" placeholder="请选择脚本类型"
/> @change="handleScriptTypeChange(row)"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="起止范围" > <el-table-column label="起止范围">
<el-table-column label="起始" width="150"> <el-table-column label="起始" width="150">
<template #default="{ row }"> <template #default="{ row }">
<el-row type="flex" :gutter="24"> <el-row type="flex" :gutter="24">
<el-col :span="12"> <el-col :span="12">
<el-select v-model="row.startFlag" placeholder="选择起始值" style="width: 70px;" @change="(value) => handleStartFlagChange(row, value)"> <el-select v-model="row.startFlag" placeholder="选择起始值" style="width: 70px;" @change="(value) => handleStartFlagChange(row, value)">
<el-option label="无" :value="2"></el-option> <el-option label="无" :value="2"></el-option>
<el-option label=">=" :value="1"></el-option> <el-option label=">=" :value="1"></el-option>
<el-option label=">" :value="0"></el-option> <el-option label=">" :value="0"></el-option>
</el-select> </el-select>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-input v-model= "row.startValue" style="width: 60px;" :disabled="isStartValueDisabled[row.sort]" <el-input v-model="row.startValue" style="width: 60px;" :disabled="isStartValueDisabled[row.sort]"
/> />
</el-col> </el-col>
</el-row> </el-row>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="结束" width="150"> <el-table-column label="结束" width="150">
<template #default="{ row }"> <template #default="{ row }">
<el-row type="flex" :gutter="24" > <el-row type="flex" :gutter="24">
<el-col :span="12"> <el-col :span="12">
<el-select v-model="row.endFlag" placeholder="选择结束值" style="width: 70px;" @change="(value) => handleEndFlagChange(row, value)"> <el-select v-model="row.endFlag" placeholder="选择结束值" style="width: 70px;" @change="(value) => handleEndFlagChange(row, value)">
<el-option label="无" :value="2"></el-option> <el-option label="无" :value="2"></el-option>
<el-option label="<=" :value="1"></el-option> <el-option label="<=" :value="1"></el-option>
<el-option label="<" :value="0"></el-option> <el-option label="<" :value="0"></el-option>
</el-select> </el-select>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-input v-model= "row.endValue" style="width: 60px;" :disabled="isEndValueDisabled[row.sort]"/> <el-input v-model="row.endValue" style="width: 60px;" :disabled="isEndValueDisabled[row.sort]"/>
</el-col> </el-col>
</el-row> </el-row>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="单位" width="130"> <el-table-column label="单位" width="130">
<template #default="{ row }"> <template #default="{ row }">
<el-select v-model="row.conditionType" placeholder="选择单位"> <el-select v-model="row.conditionType" placeholder="选择单位">
<el-option <el-option
v-for="item in dictStore.getDictData('Condition_Type')" v-for="item in conditionTypes"
:key="item.id" :key="item.id"
:label="item.name" :label="item.name"
:value="Number(item.value)" :value="Number(item.value)"
/> />
</el-select> </el-select>
</template> </template>
</el-table-column> </el-table-column>
</el-table-column> </el-table-column>
<el-table-column label="最大误差"> <el-table-column label="最大误差">
<el-table-column prop="maxErrorValue" label="最大误差值" width="100"> <el-table-column prop="maxErrorValue" label="最大误差值" width="100">
<template #default="{ row }"> <template #default="{ row }">
<el-input v-model= "row.maxErrorValue" style="width: 70px;"/> <el-input v-model="row.maxErrorValue" style="width: 70px;"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="误差类型" width="180"> <el-table-column label="误差类型" width="170">
<template #default="{ row }"> <template #default="{ row }">
<el-select v-model="row.errorValueType" placeholder="选择误差类型"> <el-cascader :options="errorValueTypeOptions"
<el-option v-model="row.errorValueType"
v-for="item in dictStore.getDictData('Error_Value_Type')" @change="handleErrorValueTypeChange(row)"/>
:key="item.id" </template>
:label="item.name" </el-table-column>
:value="Number(item.value)" <el-table-column label="误差单位" width="100" prop="errorUnit">
/> <template #default="{ row }">
</el-select> <span>{{ row.errorUnit }}</span>
</template> </template>
</el-table-column> </el-table-column>
</el-table-column> </el-table-column>
<el-table-column label="操作" min-width="150"> <el-table-column label="操作" min-width="150">
<template #default="{ row }"> <template #default="{ row }">
<el-button type="primary" link :icon='CopyDocument' @click="copyRow(row)">复制</el-button> <el-button type="primary" link :icon='CopyDocument' @click="copyRow(row)">复制</el-button>
<el-button type='primary' link :icon='Delete' @click="deleteRow(row)">删除</el-button> <el-button type='primary' link :icon='Delete' @click="deleteRow(row)">删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { type ErrorSystem } from '@/api/device/interface/error'; import {type ErrorSystem} from '@/api/device/interface/error';
import { useDictStore, } from '@/stores/modules/dict' import {useDictStore,} from '@/stores/modules/dict'
import {CirclePlus, Delete, EditPen,CopyDocument} from '@element-plus/icons-vue' import {CirclePlus, CopyDocument, Delete} from '@element-plus/icons-vue'
import { type CascaderOption, type FormItemRule } from 'element-plus'; import {type CascaderOption} from 'element-plus';
import { el } from 'element-plus/es/locale'; import {defineEmits, type PropType, reactive, ref, watch} from 'vue';
import { type PropType, type Ref, ref, watch } from 'vue';
import { defineEmits } from 'vue';
const emit = defineEmits(['updateTableData']);
const multipleSelection = ref<number[]>([])
const dictStore = useDictStore()
const isStartValueDisabled = ref<{ [key: number]: boolean }>({});
const isEndValueDisabled = ref<{ [key: number]: boolean }>({});
const props = defineProps({
errorOptions: {
type: Array as PropType<CascaderOption[]>,
required: true
},
scriptOptions: { const emit = defineEmits(['updateTableData']);
type: Array as PropType<CascaderOption[]>, const multipleSelection = ref<number[]>([])
required: true const dictStore = useDictStore()
}, const isStartValueDisabled = ref<{ [key: number]: boolean }>({});
const isEndValueDisabled = ref<{ [key: number]: boolean }>({});
const props = defineProps({
errorOptions: {
type: Array as PropType<CascaderOption[]>,
required: true
},
tableData: { scriptOptions: {
type: Array as PropType<CascaderOption[]>,
required: true
},
tableData: {
type: Array as PropType<ErrorSystem.ErrorSystemDetail[]>, type: Array as PropType<ErrorSystem.ErrorSystemDetail[]>,
default: () => [] default: () => []
} }
}); });
const errorValueTypeOptions = reactive<{ value: number, label: string, children: { value: number, label: string }[] }[]>([])
const conditionTypes = dictStore.getDictData('Condition_Type')
const errorValueTypes = dictStore.getDictData('Error_Value_Type')
const valueTypes = dictStore.getDictData('Script_Value_Type')
// 定义一个 Map 来存储误差和脚本系统信息
const errSysAndScriptMap = new Map<string, string>([
['Freq_Deviation_Freq','FREQ'],//频率偏差/频率---频率
['Vol_Deviation_Vol','VRMS'],//电压偏差/电压---电压/相电压有效值
['MSQI_V','V_UNBAN'],//三相不平衡/电压---电压/三相电压负序不平衡度
['MSQI_CUR','I_UNBAN'],//三相不平衡/电流---电流/三相电流负序不平衡度
['Voltage Fluctuation_Voltage Amplitude',''],//电压波动/电压幅值---
['Voltage Fluctuation_Duration',''],//电压波动/持续时间---
['Short Time Flicker Item','PST'],//闪变/短时间闪变---闪变/短时间闪变
['Harmonic_Voltage','V2-50'],//谐波/电压---谐波/谐波电压含有率
['Harmonic_Current','I2-50'],//谐波/电流---谐波/谐波电流幅值
['Harmonic_Angle','VA2-50'],//谐波/相角---谐波/谐波电压相角
['Harmonic_Angle','IA2-50'],//谐波/相角---谐波/谐波电流相角
['Harmonic_Power','P2-50'],//谐波/功率---谐波/谐波有功功率
['Interharmonic_Voltage','SV_1-49'],//间谐波/电压---谐波/间谐波电压含有率
['Interharmonic_Current','SI_1-49'],//间谐波/电流---谐波/间谐波电流幅值
['High Frequency Harmonic_Voltage',''],//高频次谐波/电压
['High Frequency Harmonic_Current',''],//高频次谐波/电流
['Power Item','P'],//功率/功率---功率
['Current Item','IRMS'],//电流/电流---电流/电流有效值
['Dip & Swell & Short duration interruption_Voltage','MAG'],//暂态/电压幅值/电压---暂态/电压幅值
['Dip & Swell & Short duration interruption_Duration','DUR'],//暂态/持续时间/时间---暂态/持续时间
]);
const handleErrorTypeChange = (value: any, row: any) =>{ onBeforeMount(() => {
valueTypes.forEach(item1 => {
let children = []
for (let i = 0; i < errorValueTypes.length; i++) {
if (item1.value === '2' && errorValueTypes[i].value === '2') {
continue
}
children.push({label: errorValueTypes[i].name, value: Number(errorValueTypes[i].value)})
}
errorValueTypeOptions.push({label: item1.name, value: Number(item1.value), children: children})
})
})
const handleErrorTypeChange = (value: any, row: any) => {
// const matchedRow = findRowById(row.errorType, props.errorOptions);//选中误差id找对应结构中的含chilren的code // const matchedRow = findRowById(row.errorType, props.errorOptions);//选中误差id找对应结构中的含chilren的code
// console.log('matchedRow.code',matchedRow.code) // console.log('matchedRow.code',matchedRow.code)
@@ -182,6 +174,31 @@ const handleErrorTypeChange = (value: any, row: any) =>{
// } // }
} }
const handleScriptTypeChange = (row: any) => {
handleErrorValueTypeChange(row)
}
const handleErrorValueTypeChange = (row: any) => {
let scriptType = findRowById(row.scriptType, props.scriptOptions)
if (scriptType) {
const errorValueType = row.errorValueType
let level1 = errorValueType[0]
switch (level1) {
case 1: // 绝对值
row.valueType = 1
row.errorUnit = scriptType.remark
break;
case 2: // 相对值
row.valueType = 2
row.errorUnit = "%"
break;
default:
break;
}
}
}
// 假设 props.errorOptions 是一个数组,每个元素可能包含 children 属性 // 假设 props.errorOptions 是一个数组,每个元素可能包含 children 属性
const findRowById = (id: string, options: any[]): any | null => { const findRowById = (id: string, options: any[]): any | null => {
@@ -236,7 +253,7 @@ watch(() => props.tableData, async (newTableData) => {
props.tableData.forEach(row => { props.tableData.forEach(row => {
isEndValueDisabled.value[row.sort] = row.endFlag === 2; isEndValueDisabled.value[row.sort] = row.endFlag === 2;
}); });
}, { immediate: true }); }, {immediate: true});
// 处理 startFlag 变化的方法 // 处理 startFlag 变化的方法
@@ -259,41 +276,43 @@ const handleEndFlagChange = (row: ErrorSystem.ErrorSystemDetail, value: number)
} }
}; };
//选中 //选中
const handleSelectionChange = (selection: ErrorSystem.ErrorSystemDetail[]) => { const handleSelectionChange = (selection: ErrorSystem.ErrorSystemDetail[]) => {
multipleSelection.value = selection.map(row => row.sort); // 更新选中的行 multipleSelection.value = selection.map(row => row.sort); // 更新选中的行
}; };
//新增 //新增
const openAddDialog = () => { const openAddDialog = () => {
// 获取字典数据 // 获取字典数据
const conditionTypes = dictStore.getDictData('Condition_Type');
const errorValueTypes = dictStore.getDictData('Error_Value_Type');
const newRow = { const newRow = {
sort: props.tableData.length + 1, sort: props.tableData.length + 1,
id: '', id: '',
startFlag:2, startFlag: 2,
endFlag:2, endFlag: 2,
conditionType: conditionTypes.length > 0 ? Number(conditionTypes[3].value) : 0, // 设置默认值为第一个选项的值 conditionType: conditionTypes.length > 0 ? Number(conditionTypes[0].value) : 0, // 设置默认值为第一个选项的值
errorValueType:errorValueTypes.length > 0 ? Number(errorValueTypes[0].value) : 0, // 设置默认值为第一个选项的值 valueType: valueTypes.length > 0 ? Number(valueTypes[0].value) : 1,
errorSysId: "", errorValueType: [errorValueTypeOptions[0].value, errorValueTypeOptions[0].children[0].value],
errorType: "", errorSysId: "",
scriptType: "", errorType: "",
maxErrorValue: 0 scriptType: "",
maxErrorValue: 0
}; };
emit('updateTableData', [...props.tableData, newRow]); emit('updateTableData', [...props.tableData, newRow]);
}; };
const copyRow = (row: ErrorSystem.ErrorSystemDetail) => { const copyRow = (row: ErrorSystem.ErrorSystemDetail) => {
// 深拷贝行数据 // 深拷贝行数据
const newRow = { ...row }; const newRow = {...row};
const maxNextId = Math.max(...props.tableData.map(item => item.sort), 0); const maxNextId = Math.max(...props.tableData.map(item => item.sort), 0);
newRow.sort = maxNextId + 1; newRow.sort = maxNextId + 1;
emit('updateTableData', [...props.tableData, newRow]); emit('updateTableData', [...props.tableData, newRow]);
}; };
//删除行 //删除行
const deleteRow = (row:ErrorSystem.ErrorSystemDetail) => { const deleteRow = (row: ErrorSystem.ErrorSystemDetail) => {
const index = props.tableData.indexOf(row); const index = props.tableData.indexOf(row);
if (index !== -1) { if (index !== -1) {
const newTableData = [...props.tableData]; const newTableData = [...props.tableData];
@@ -303,8 +322,8 @@ const deleteRow = (row:ErrorSystem.ErrorSystemDetail) => {
}; };
//批量删除选中行 //批量删除选中行
const deleteSelectedRows = () => { const deleteSelectedRows = () => {
const newTableData = props.tableData.filter(row => !multipleSelection.value.includes(row.sort)); const newTableData = props.tableData.filter(row => !multipleSelection.value.includes(row.sort));
multipleSelection.value = []; // 清空已选择的行 multipleSelection.value = []; // 清空已选择的行
emit('updateTableData', newTableData); emit('updateTableData', newTableData);
}; };
@@ -313,15 +332,16 @@ const deleteSelectedRows = () => {
<style scoped> <style scoped>
.dialog-footer { .dialog-footer {
display: flex; display: flex;
justify-content: flex-start; justify-content: flex-start;
margin-bottom: 10px; /* 调整这里的值以增加或减少间距 */ margin-bottom: 10px; /* 调整这里的值以增加或减少间距 */
margin-top: 10px; margin-top: 10px;
} }
.el-table th, .el-table td { .el-table th, .el-table td {
text-align: center; /* 所有单元格文字居中 */ text-align: center; /* 所有单元格文字居中 */
} }
.table-container { .table-container {
max-height: 400px; /* 根据需要调整高度 */ max-height: 400px; /* 根据需要调整高度 */
overflow-y: auto; /* 允许垂直滚动 */ overflow-y: auto; /* 允许垂直滚动 */

View File

@@ -1,8 +1,8 @@
<template> <template>
<el-dialog :title="dialogTitle" v-model='dialogVisible' @close="close" v-bind="dialogBig" width="1500px"> <el-dialog :title="dialogTitle" v-model='dialogVisible' @close="close" v-bind="dialogBig" width="1660px">
<el-tabs type="border-card"> <el-tabs type="border-card">
<el-tab-pane label="基础信息"> <el-tab-pane label="基础信息">
<div > <div>
<el-form :model="formContent" ref='dialogFormRef' :rules='rules' label-width="auto" class="form-four"> <el-form :model="formContent" ref='dialogFormRef' :rules='rules' label-width="auto" class="form-four">
<el-form-item label="标准号" prop="standardName" > <el-form-item label="标准号" prop="standardName" >
<el-input v-model='formContent.standardName' placeholder="请填写标准号"/> <el-input v-model='formContent.standardName' placeholder="请填写标准号"/>
@@ -137,6 +137,9 @@ const handleTableDataUpdate = (newTableData: ErrorSystem.ErrorSystemDetail[]) =>
} }
formContent.value.pqErrSysDtlsList = tableData.value formContent.value.pqErrSysDtlsList = tableData.value
formContent.value.pqErrSysDtlsList.forEach((item) => {
item.errorValueType=item.errorValueType[1]
})
if (formContent.value.id) { if (formContent.value.id) {
await updatePqErrSys(formContent.value); await updatePqErrSys(formContent.value);
ElMessage.success({ message: `${dialogTitle.value}成功!` }) ElMessage.success({ message: `${dialogTitle.value}成功!` })
@@ -212,7 +215,8 @@ const loadSecondLevelOptions = async () => {
value: item.id, value: item.id,
label: item.name, label: item.name,
code: item.code, code: item.code,
children: item.children ? convertToOptions(item.children) : undefined children: item.children ? convertToOptions(item.children) : undefined,
remark: item.remark
})); }));
}; };
@@ -230,6 +234,9 @@ const open = async (sign: string, data: ErrorSystem.ErrorSystemList) => {
if (result && result.data) { if (result && result.data) {
formContent.value = result.data as ErrorSystem.ErrorSystemList; formContent.value = result.data as ErrorSystem.ErrorSystemList;
tableData.value = formContent.value.pqErrSysDtlsList || []; tableData.value = formContent.value.pqErrSysDtlsList || [];
tableData.value.forEach((item) => {
item.errorValueType=[item.valueType,item.errorValueType]
})
} else { } else {
resetFormContent(); resetFormContent();
} }