误差体系禁用

This commit is contained in:
sjl
2024-12-24 20:22:36 +08:00
parent f17f5c9925
commit f0edeaee85
8 changed files with 368 additions and 62 deletions

View File

@@ -22,13 +22,13 @@ export namespace ErrorSystem {
// 查看详细误差体系
export interface ErrorSystemDetail {
nextId: number;
sort: number;
id:string;//误差体系子表ID
errorSysId:string;//所属误差体系ID
type: string;//检测脚本类型,树形字典表(没有树形表则需要拆分字段)
startValue?:number;//误差判断起始值(误差范围)
startValue?:number | null;//误差判断起始值(误差范围)
startFlag?:number;//是否包含起始值
endValue?:number;//;误差判断结束值(误差范围)
endValue?:number | null;//;误差判断结束值(误差范围)
endFlag?:number;//是否包含结束值
conditionType?:string;//判断条件值类型(包括值类型,绝对值、相对值)
maxErrorValue:number;//误差最大值

View File

@@ -754,6 +754,38 @@ const handleTest = async (val:string) => {
)
return
}
const checkDevVolt = channelsSelection.value.map(item => item.devVolt);
const isDevVoltConsistent = new Set(checkDevVolt).size === 1;
if (!isDevVoltConsistent) {
ElMessageBox.confirm(
'所勾选设备额定电压不一致,请重新选择',
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
)
return
}
const checkDevCurr = channelsSelection.value.map(item => item.devCurr);
const isDevCurrConsistent = new Set(checkDevCurr).size === 1;
if (!isDevCurrConsistent) {
ElMessageBox.confirm(
'所勾选设备额定电流不一致,请重新选择',
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
)
return
}
if(val==='手动检测'||val==='自动检测'||val==='不合格项复检'||val==='全部复检' )
{
if(devNum > 6)

View File

@@ -148,7 +148,7 @@ const detectionOptions = ref([
const open = (selection: Device.ResPqDev[],title: string,time:boolean) => {
const checkStates = selection.map(item => item.checkState);
const checkStates = selection.map(item => item.checkState);
const allCheckStatesEqual = new Set(checkStates).size <= 1;
if (!allCheckStatesEqual) {

View File

@@ -11,7 +11,7 @@
:style="{ height: '250px',maxHeight: '400px',overflow:'hidden'}"
@selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column prop="nextId" label="序号" width="60" />
<el-table-column prop="sort" label="序号" width="60" />
<el-table-column prop="type" label="电能质量检测指标类型" min-width="340">
<template #default="{ row }">
<el-cascader style="min-width: 350px;"
@@ -26,14 +26,14 @@
<template #default="{ row }">
<el-row type="flex" :gutter="24">
<el-col :span="12">
<el-select v-model="row.startFlag" placeholder="选择起始值" style="width: 70px;">
<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="1"></el-option>
<el-option label=">" :value="0"></el-option>
</el-select>
</el-col>
<el-col :span="12">
<el-input v-model= "row.startValue" style="width: 60px;"
<el-input v-model= "row.startValue" style="width: 60px;" :disabled="isStartValueDisabled[row.sort]"
/>
</el-col>
</el-row>
@@ -43,14 +43,14 @@
<template #default="{ row }">
<el-row type="flex" :gutter="24" >
<el-col :span="12">
<el-select v-model="row.endFlag" placeholder="选择结束值" style="width: 70px;">
<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="1"></el-option>
<el-option label="<" :value="0"></el-option>
</el-select>
</el-col>
<el-col :span="12">
<el-input v-model= "row.endValue" style="width: 60px;"/>
<el-input v-model= "row.endValue" style="width: 60px;" :disabled="isEndValueDisabled[row.sort]"/>
</el-col>
</el-row>
</template>
@@ -107,6 +107,8 @@
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({
options: {
type: Array as PropType<CascaderOption[]>,
@@ -119,43 +121,78 @@
}
});
// 监听 props.tableData 的变化,确保每次数据变化时都重新设置 nextId
// 监听 props.tableData 的变化,确保每次数据变化时都重新设置 sort
watch(() => props.tableData, async (newTableData) => {
for (let i = 0; i < newTableData.length; i++) {
newTableData[i].nextId = i + 1;
newTableData[i].sort = i + 1;
if (newTableData[i].startFlag === 2) {
newTableData[i].startValue = null; // 设置 startValue 为 null
}
if (newTableData[i].endFlag === 2) {
newTableData[i].endValue = null; // 设置 endValue 为 null
}
}
// 重新设置 isStartValueDisabled 和 isEndValueDisabled,并清空输入框
props.tableData.forEach(row => {
isStartValueDisabled.value[row.sort] = row.startFlag === 2;
});
props.tableData.forEach(row => {
isEndValueDisabled.value[row.sort] = row.endFlag === 2;
});
}, { immediate: true });
// 处理 startFlag 变化的方法
const handleStartFlagChange = (row: ErrorSystem.ErrorSystemDetail, value: number) => {
if (value === 2) {
row.startValue = null; // 清空输入框
isStartValueDisabled.value[row.sort] = true; // 禁用输入框
} else {
isStartValueDisabled.value[row.sort] = false; // 启用输入框
}
};
// 处理 endFlag 变化的方法
const handleEndFlagChange = (row: ErrorSystem.ErrorSystemDetail, value: number) => {
if (value === 2) {
row.endValue = null; // 清空输入框
isEndValueDisabled.value[row.sort] = true; // 禁用输入框
} else {
isEndValueDisabled.value[row.sort] = false; // 启用输入框
}
};
//选中
const handleSelectionChange = (selection: ErrorSystem.ErrorSystemDetail[]) => {
multipleSelection.value = selection.map(row => row.nextId); // 更新选中的行
multipleSelection.value = selection.map(row => row.sort); // 更新选中的行
};
//新增
const openAddDialog = () => {
// 获取字典数据
const conditionTypes = dictStore.getDictData('Condition_Type');
const errorValueTypes = dictStore.getDictData('Error_Value_Type');
const newRow = {
nextId: props.tableData.length + 1,
id: '',
startFlag:2,
endFlag:2,
conditionType: conditionTypes.length > 0 ? Number(conditionTypes[3].value) : 0, // 设置默认值为第一个选项的值
errorValueType:errorValueTypes.length > 0 ? Number(errorValueTypes[0].value) : 0, // 设置默认值为第一个选项的值
errorSysId: "",
type: "",
maxErrorValue: 0
const newRow = {
sort: props.tableData.length + 1,
id: '',
startFlag:2,
endFlag:2,
conditionType: conditionTypes.length > 0 ? Number(conditionTypes[3].value) : 0, // 设置默认值为第一个选项的值
errorValueType:errorValueTypes.length > 0 ? Number(errorValueTypes[0].value) : 0, // 设置默认值为第一个选项的值
errorSysId: "",
type: "",
maxErrorValue: 0
};
emit('updateTableData', [...props.tableData, newRow]);
};
const copyRow = (row: ErrorSystem.ErrorSystemDetail) => {
// 深拷贝行数据
const newRow = { ...row };
const maxNextId = Math.max(...props.tableData.map(item => item.nextId), 0);
newRow.nextId = maxNextId + 1;
const maxNextId = Math.max(...props.tableData.map(item => item.sort), 0);
newRow.sort = maxNextId + 1;
emit('updateTableData', [...props.tableData, newRow]);
};
//删除行
@@ -169,7 +206,7 @@ const deleteRow = (row:ErrorSystem.ErrorSystemDetail) => {
};
//批量删除选中行
const deleteSelectedRows = () => {
const newTableData = props.tableData.filter(row => !multipleSelection.value.includes(row.nextId));
const newTableData = props.tableData.filter(row => !multipleSelection.value.includes(row.sort));
multipleSelection.value = []; // 清空已选择的行
emit('updateTableData', newTableData);
};

View File

@@ -180,13 +180,13 @@ const handleTableDataUpdate = (newTableData: ErrorSystem.ErrorSystemDetail[]) =>
};
// 转换函数
const convertToOptions = (dictTree: Dict.ResDictTree[]): CascaderOption[] => {
return dictTree.map(item => ({
value: item.id,
label: item.name,
children: item.children ? convertToOptions(item.children) : undefined
}));
};
const convertToOptions = (dictTree: Dict.ResDictTree[]): CascaderOption[] => {
return dictTree.map(item => ({
value: item.id,
label: item.name,
children: item.children ? convertToOptions(item.children) : undefined
}));
};
// 打开弹窗,可能是新增,也可能是编辑
const open = async (sign: string, data: ErrorSystem.ErrorSystemList) => {

View File

@@ -0,0 +1,181 @@
<template>
<div class="data-check-content">
<div class="content-tree" >
<el-tree
:default-expanded-keys="['0', '0-1', '0-2', '0-3', '1']"
node-key="id"
:data="data"
:props="defaultProps"
@node-click="handleNodeClick" />
</div>
<div class="content-right-Tabs" style="height: 500px;">
<el-tabs type="border-card" style="height: 100%;">
<el-tab-pane
v-for="tab in tabs"
:key="tab.name"
:label="tab.label"
:name="tab.name">
<!-- 频率tab -->
<el-tabs type="border-card" style="height: 430px;">
<el-tab-pane
v-for="subTab in tab.subTabs"
:key="subTab.name"
:label="subTab.label"
:name="subTab.name">
<!-- 子标签页内容 -->
</el-tab-pane>
</el-tabs>
</el-tab-pane>
</el-tabs>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { data } from "@/api/plan/autoTest.json";
const tabs = ref([
{
label: '频率',
name: 'resultTab',
subTabs: [
{ label: '额度工作条件下的检测', name: 'quotaConditionTab' },
{ label: '电压对频率测量的影响', name: 'voltageFrequencyImpactTab' },
{ label: '谐波对频率测量的影响', name: 'harmonicFrequencyImpactTab' }
]
},
{
label: '电压',
name: 'resultTab1',
subTabs: [
{ label: '额度工作条件下的检测', name: 'quotaConditionTab1' },
{ label: '电压对频率测量的影响', name: 'voltageFrequencyImpactTab1' },
{ label: '谐波对频率测量的影响', name: 'harmonicFrequencyImpactTab1' }
]
},
{
label: '电流',
name: 'resultTab2',
subTabs: [
{ label: '额度工作条件下的检测', name: 'quotaConditionTab2' },
{ label: '电压对频率测量的影响', name: 'voltageFrequencyImpactTab2' },
{ label: '谐波对频率测量的影响', name: 'harmonicFrequencyImpactTab2' }
]
},
{
label: '电压不平衡度',
name: 'resultTab3',
subTabs: [
{ label: '额度工作条件下的检测', name: 'quotaConditionTab3' },
{ label: '电压对频率测量的影响', name: 'voltageFrequencyImpactTab3' },
{ label: '谐波对频率测量的影响', name: 'harmonicFrequencyImpactTab3' }
]
},
{
label: '电流不平衡度',
name: 'resultTab4',
subTabs: [
{ label: '额度工作条件下的检测', name: 'quotaConditionTab4' },
{ label: '电压对频率测量的影响', name: 'voltageFrequencyImpactTab4' },
{ label: '谐波对频率测量的影响', name: 'harmonicFrequencyImpactTab4' }
]
},
{
label: '谐波电压',
name: 'resultTab5',
subTabs: [
{ label: '额度工作条件下的检测', name: 'quotaConditionTab5' },
{ label: '电压对频率测量的影响', name: 'voltageFrequencyImpactTab5' },
{ label: '谐波对频率测量的影响', name: 'harmonicFrequencyImpactTab5' }
]
},
{
label: '谐波电流',
name: 'resultTab6',
subTabs: [
{ label: '额度工作条件下的检测', name: 'quotaConditionTab6' },
{ label: '电压对频率测量的影响', name: 'voltageFrequencyImpactTab6' },
{ label: '谐波对频率测量的影响', name: 'harmonicFrequencyImpactTab6' }
]
},
{
label: '间谐波电压',
name: 'resultTab7',
subTabs: [
{ label: '额度工作条件下的检测', name: 'quotaConditionTab7' },
{ label: '电压对频率测量的影响', name: 'voltageFrequencyImpactTab7' },
{ label: '谐波对频率测量的影响', name: 'harmonicFrequencyImpactTab7' }
]
},
{
label: '间谐波电流',
name: 'resultTab8',
subTabs: [
{ label: '额度工作条件下的检测', name: 'quotaConditionTab8' },
{ label: '电压对频率测量的影响', name: 'voltageFrequencyImpactTab8' },
{ label: '谐波对频率测量的影响', name: 'harmonicFrequencyImpactTab8' }
]
},
{
label: '电压暂升暂降',
name: 'resultTab9',
subTabs: [
{ label: '额度工作条件下的检测', name: 'quotaConditionTab9' },
{ label: '电压对频率测量的影响', name: 'voltageFrequencyImpactTab9' },
{ label: '谐波对频率测量的影响', name: 'harmonicFrequencyImpactTab9' }
]
},
{
label: '闪变',
name: 'resultTab10',
subTabs: [
{ label: '额度工作条件下的检测', name: 'quotaConditionTab10' },
{ label: '电压对频率测量的影响', name: 'voltageFrequencyImpactTab10' },
{ label: '谐波对频率测量的影响', name: 'harmonicFrequencyImpactTab10' }
]
}
]);
const defaultProps = {
children: "children",
label: "name",
pid: "pid",
};
const handleNodeClick = (data: any) => {
console.log(data);
};
</script>
<style scoped>
.data-check-content {
display: flex;
gap: 20px;
}
.content-tree {
width: 300px;
height: 500px;
border: 1px solid #dcdfe6;
border-radius: 4px;
margin-right: 10px;
overflow: auto; /* 同时启用垂直和水平滚动 */
overflow-x: auto; /* 确保水平滚动条生效 */
}
/* 确保 el-tree 内容可以超出容器宽度 */
.el-tree {
width: fit-content; /* 根据内容自适应宽度 */
}
.content-right-Tabs {
flex: 1; /* 根据需要调整宽度比例 */
}
</style>

View File

@@ -1,45 +1,93 @@
<template>
<el-dialog title="请确认检测脚本值类型" v-model='dialogVisible' @close="close" v-bind="dialogSmall">
<div>
<el-form :model="formContent" ref='dialogFormRef'>
<el-form-item label="检测脚本值类型" >
<el-select clearable placeholder="请选择类型检测脚本值类型" >
<el-option label="相对值" :value="0"></el-option>
<el-option label="绝对值" :value="1"></el-option>
</el-select>
</el-form-item>
</el-form>
<el-dialog :title="dialogTitle"
v-model='dialogVisible'
@close="close"
v-bind="dialogBig"
width="1400px">
<div class="dialog-content" >
<el-form :model='formContent' label-width="auto" class="form-three ">
<el-form-item label="脚本名称" prop='name'>
<el-input v-model='formContent.name' />
</el-form-item>
<el-form-item label="参照标准名称" prop='standardName'>
<el-input v-model='formContent.standardName' />
</el-form-item>
<el-form-item label="标准推行年份" prop='standardTime'>
<el-date-picker
v-model="formContent.standardTime"
type="year"
placeholder="请选择标准推行年份"
/>
</el-form-item>
<el-form-item label='值类型' prop='valueType' >
<el-select v-model="formContent.valueType" filterable clearable placeholder="请选择值类型">
<el-option
v-for="item in dictStore.getDictData('Script_Value_Type')"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-form>
</div>
<TestScriptDetail />
<template #footer>
<div >
<el-button @click='close()'> </el-button>
<el-button type="primary" @click='save()'>保存</el-button>
</div>
<template #footer>
<div >
<el-button @click='close()'> </el-button>
<el-button type="primary" @click='save()'>新增</el-button>
</div>
</template>
</el-dialog>
</template>
</el-dialog>
</template>
<script setup lang='ts'>
import { dialogSmall } from '@/utils/elementBind'
import { ElMessage, type FormItemRule } from 'element-plus'
import { computed, reactive, type Ref, ref } from 'vue'
import { CirclePlus, Delete, EditPen } from '@element-plus/icons-vue'
import { dialogBig } from '@/utils/elementBind'
import { computed, ref } from 'vue'
import { useDictStore } from '@/stores/modules/dict'
import TestScriptDetail from '@/views/machine/testScript/components/testScriptDetail.vue';
import { type TestScript } from '@/api/device/interface/testScript';
const modeId = ref()
// 定义弹出组件元信息
const dialogFormRef = ref()
const dictStore = useDictStore()
function useMetaInfo() {
const dialogVisible = ref(false)
const formContent = ref()
return { dialogVisible, formContent }
const titleType = ref('add')
const formContent = ref<TestScript.ResTestScript>({
name: '',
type: '',
valueType:'',
pattern: modeId.value,
standardName: '',
standardTime: '',
state:1,
})
return { dialogVisible, titleType,formContent }
}
const { dialogVisible, formContent } = useMetaInfo()
const { dialogVisible, titleType,formContent } = useMetaInfo()
let dialogTitle = computed(() => {
return titleType.value === 'add' ? '新增检测脚本' : '编辑检测脚本'
})
// 清空formContent
const resetFormContent = () => {
formContent.value = {
name: '',
type: '',
valueType:'',
pattern: modeId.value,
standardName: '',
standardTime: '',
state:1,
}
}
@@ -60,7 +108,9 @@ const dialogFormRef = ref()
// 打开弹窗,可能是新增,也可能是编辑
const open = (currentMode: string) => {
const open = (sign: string,row: any,currentMode: string) => {
titleType.value = sign
modeId.value = dictStore.getDictData('Pattern').find(item => item.name === currentMode)?.id;
// 重置表单
dialogFormRef.value?.resetFields()
dialogVisible.value = true
@@ -72,4 +122,10 @@ const props = defineProps<{
refreshTable: (() => Promise<void>) | undefined;
}>()
</script>
</script>
<style scoped>
/* .dialog-content {
padding: 10px;
} */
</style>

View File

@@ -112,9 +112,9 @@ const columns = reactive<ColumnProps<TestScript.ResTestScript>[]>([
// 打开 drawer(新增、编辑)
const openDialog = (titleType: string, row: Partial<TestScript.ResTestScript> = {}) => {
if(modeStore.currentMode == '比对式'){
//comparisonPopup.value?.open(titleType, row)
comparisonPopup.value?.open(titleType, row,modeStore.currentMode,)
}else{
//testScriptPopup.value?.open(titleType, row)
testScriptPopup.value?.open(titleType, row,modeStore.currentMode)
}