This commit is contained in:
sjl
2024-12-23 14:05:53 +08:00
parent 5f0b36b3bb
commit fdf91965d9
6 changed files with 138 additions and 105 deletions

View File

@@ -146,7 +146,6 @@ const open = async (sign: string, data: Role.RoleBO, AllFunction: Function.ResFu
const allIds = getAllIds(AllFunction);
// 匹配 roleFunctions 中的 id 并设置 checkedKeys
const checkedKeys = allIds.filter(id => roleFunctions.some(roleFunc => roleFunc.id === id));
// 过滤出叶子节点
const leafCheckedKeys = filterLeafNodes(AllFunction, checkedKeys);

View File

@@ -42,7 +42,7 @@
<el-tabs type="border-card">
<div v-if="activeIndex > 0">
<el-tab-pane v-for="(device, index) in name.slice(0, activeIndex + 1)" :key="index" :label="device">
<el-tab-pane v-for="(device, index) in name.slice(0, activeIndex )" :key="index" :label="device">
<template #label>
<span class="custom-tabs-label">
<span>{{ device }}</span>
@@ -102,9 +102,10 @@
</template>
<script lang="tsx" setup name="channelsTest">
import { type Device } from '@/api/device/interface/device';
import { SuccessFilled, Failed } from '@element-plus/icons-vue'
import { SuccessFilled, Failed, Message, MessageBox } from '@element-plus/icons-vue'
import { type Ref, ref, toRef, watch } from 'vue'
import {dialogBig} from '@/utils/elementBind'
import { ElMessage, ElMessageBox } from 'element-plus';
const activeIndex = ref(0)
const activeTotalNum = ref(4)
const qualified = ref(0)
@@ -118,6 +119,28 @@ let intervalId: NodeJS.Timeout | null = null;
// 在 setup 函数中
const errorStates = ref(new Array(name.value.length).fill(false));
// 定义 TableDataItem 接口
interface TableDataItem {
id: string;
deviceName: string;
MonitorIdx: number;
UaData?: number | string;
UaChannel?: number | string;
UbData?: number | string;
UbChannel?: number | string;
UcData?: number | string;
UcChannel?: number | string;
IaData?: number | string;
IaChannel?: number | string;
IbData?: number | string;
IbChannel?: number | string;
IcData?: number | string;
IcChannel?: number | string;
Result?: string | string;
updateTime?: string;
}
// 更新错误状态的方法
const updateErrorState = (index: number, hasError: boolean) => {
errorStates.value[index] = hasError;
@@ -413,7 +436,7 @@ const tableData3 = ref<TableDataItem[]>([
IaData: 5,
IaChannel: '合格',
IbData: 5,
IbChannel: 1.0001,
IbChannel: '合格',
IcData: 5,
IcChannel: '合格',
Result: '合格',
@@ -439,10 +462,38 @@ const tableData3 = ref<TableDataItem[]>([
},
])
const tableDataMap = new Map<number, Ref<TableDataItem[]>>([
[0, tableData1],
[1, tableData2],
[2, tableData3],
[3, tableData1],
[4, tableData1],
[5, tableData1],
]);
const currentStepStatus = ref<'error' | 'finish' | 'wait' | 'success' | 'process'>('finish');
// 打开弹窗,可能是新增,也可能是编辑
const open = (selection: Device.ResPqDev[]) => {
const checkStates = selection.map(item => item.checkState);
const allCheckStatesEqual = new Set(checkStates).size <= 1;
if (!allCheckStatesEqual) {
ElMessageBox.confirm(
'所勾选设备检测状态不一致,请重新选择',
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
)
return
}
name.value = selection.map(item => item.name)
channel.value = selection.map(item => item.devChns)
dialogVisible.value = true;
@@ -460,35 +511,6 @@ const currentStepStatus = ref<'error' | 'finish' | 'wait' | 'success' | 'process
dialogVisible.value = false
}
// 定义 TableDataItem 接口
interface TableDataItem {
id: string;
deviceName: string;
MonitorIdx: number;
UaData?: number;
UaChannel?: number | string;
UbData?: number;
UbChannel?: number | string;
UcData?: number;
UcChannel?: number | string;
IaData?: number;
IaChannel?: number | string;
IbData?: number;
IbChannel?: number | string;
IcData?: number;
IcChannel?: number | string;
Result?: string;
updateTime?: string;
}
const tableDataMap = new Map<number, Ref<TableDataItem[]>>([
[0, tableData1],
[1, tableData2],
[2, tableData3],
]);
const getTableDataForChannel = (index: number): any[] => {
const data = tableDataMap.get(index);
return data ? data.value : [];
@@ -566,28 +588,26 @@ const handleSubmit = () => {
clearInterval(intervalId);
}
intervalId = setInterval(() => {
console.log('开始')
if (activeIndex.value < name.value.length) {
activeIndex.value++;
console.log('active index',activeIndex.value)
// 获取当前活动索引对应的 tableData
const currentDataRef = tableDataMap.get(activeIndex.value);
const currentDataRef = tableDataMap.get(activeIndex.value - 1);
if (currentDataRef) {
const currentData = currentDataRef.value;
// 检查当前数据中有无不合格字段
const hasError = checkForErrors(currentData);
if (hasError) {
}else{
qualified.value++;
}
updateErrorState(activeIndex.value, hasError);
updateErrorState(activeIndex.value - 1, hasError);
}
} else {
console.log('停')
clearInterval(intervalId!); // 停止定时器
}
}, 3000); // 每隔3秒显示下一个tab
}, 1000); // 每隔3秒显示下一个tab
// let timer = setInterval(() => {
// if (activeIndex.value < activeTotalNum.value) {

View File

@@ -781,19 +781,19 @@ const handleTest = async (val:string) => {
.then(() => {
ElMessage.success('不合格项复检');
dialogTitle.value = val;
testPopup.value?.open(dialogTitle.value,props.isTimeCheck)// 打开对话框
testPopup.value?.open(channelsSelection.value,dialogTitle.value,props.isTimeCheck)// 打开对话框
})
.catch((action: Action) => {
ElMessage.success('全部复检');
dialogTitle.value = val;
testPopup.value?.open(dialogTitle.value,props.isTimeCheck) // 打开对话框
testPopup.value?.open(channelsSelection.value,dialogTitle.value,props.isTimeCheck) // 打开对话框
})
}
else
{
ElMessage.success(val);
//ElMessage.success(val);
dialogTitle.value = val;
testPopup.value?.open(dialogTitle.value,props.isTimeCheck)
testPopup.value?.open(channelsSelection.value,dialogTitle.value,props.isTimeCheck)
}
return

View File

@@ -45,6 +45,7 @@
import preTest from './preTest.vue'
import timeTest from './timeTest.vue'
import channelsTest from './channelsTest.vue'
import { Device } from '@/api/device/interface/device';
//import SvgIcon from '@/components/SvgIcon.vue';
// import preTestIcon from '@/assets/icons/preTest.svg'
@@ -129,7 +130,23 @@ const detectionOptions = ref([
const isTimeCheck = ref(false)
// 打开弹窗,可能是新增,也可能是编辑
const open = (title: string,time:boolean) => {
const open = (selection: Device.ResPqDev[],title: string,time:boolean) => {
const checkStates = selection.map(item => item.checkState);
const allCheckStatesEqual = new Set(checkStates).size <= 1;
if (!allCheckStatesEqual) {
ElMessageBox.confirm(
'所勾选设备检测状态不一致,请重新选择',
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
)
return
}
dialogTitle.value = title;
dialogVisible.value = true;
isTimeCheck.value = time

View File

@@ -14,13 +14,7 @@
<el-table-column prop="nextId" label="序号" width="60" />
<el-table-column prop="type" label="电能质量检测指标类型" min-width="200">
<template #default="{ row }">
<el-cascader :options="options" v-model="row.type"/>
<!-- <el-select v-model="row.type" placeholder="选择指标类型" >
<el-option v-for="item in dictStore.getDictData('Pq_Test_Type')"
:key="item.id"
:label="item.name"
:value="item.id"/>
</el-select> -->
<el-cascader :options="options" v-model="row.type" :props="{ checkStrictly: false, emitPath: false }"/>
</template>
</el-table-column>
<el-table-column label="起止范围" >
@@ -64,7 +58,7 @@
v-for="item in dictStore.getDictData('Condition_Type')"
:key="item.id"
:label="item.name"
:value="item.id"
:value="Number(item.value)"
/>
</el-select>
</template>
@@ -83,7 +77,7 @@
v-for="item in dictStore.getDictData('Error_Value_Type')"
:key="item.id"
:label="item.name"
:value="item.id"
:value="Number(item.value)"
/>
</el-select>
</template>
@@ -104,61 +98,23 @@
import { useDictStore, } from '@/stores/modules/dict'
import {CirclePlus, Delete, EditPen,CopyDocument} from '@element-plus/icons-vue'
import { type CascaderOption, type FormItemRule } from 'element-plus';
import { onMounted, type PropType, Ref, ref, watch } from 'vue';
import { type PropType, type Ref, ref, watch } from 'vue';
import { defineEmits } from 'vue';
import ProTable from '@/components/ProTable/index.vue'
import {
getDictTreeList,
} from '@/api/system/dictionary/dictTree'
import { type Dict } from '@/api/system/dictionary/interface';
const emit = defineEmits(['updateTableData']);
const multipleSelection = ref<number[]>([])
const dictStore = useDictStore()
const props = defineProps({
options: {
type: Array as PropType<CascaderOption[]>,
required: true
},
tableData: {
type: Array as PropType<ErrorSystem.ErrorSystemDetail[]>,
default: () => []
}
});
const options: Ref<CascaderOption[]> = ref([]); // 修改这里
onMounted(async () => {
const dictCode = '误差体系指标项'; // 替换为实际需要的字典代码
const resDictTree: Dict.ResDictTree = {
name: dictCode,
id: '',
pid: '',
pids: '',
code: '',
sort: 0
};
const result = await getDictTreeList(resDictTree);
const allOptions = convertToOptions(result.data as Dict.ResDictTree[]);
// 提取第二层节点
const secondLevelOptions: any[] = [];
allOptions.forEach(option => {
if (option.children && option.children.length > 0) {
secondLevelOptions.push(...option.children);
}
});
// 将第二层节点赋值给 options.value
options.value = secondLevelOptions;
})
// 转换函数
const convertToOptions = (dictTree: Dict.ResDictTree[]): CascaderOption[] => {
return dictTree.map(item => ({
value: item.id,
label: item.name,
children: item.children ? convertToOptions(item.children) : undefined
}));
};
// 监听 props.tableData 的变化,确保每次数据变化时都重新设置 nextId
watch(() => props.tableData, async (newTableData) => {
for (let i = 0; i < newTableData.length; i++) {

View File

@@ -35,7 +35,7 @@
</el-tabs>
<ErrorSystemDetailTable :tableData="tableData" @updateTableData="handleTableDataUpdate" />
<ErrorSystemDetailTable :tableData="tableData" :options="options" @updateTableData="handleTableDataUpdate" />
<template #footer>
<div >
@@ -49,18 +49,21 @@
</template>
<script lang="ts" setup name="ErrorSystemDialog">
import{ElMessage, type FormInstance,type FormItemRule}from'element-plus'
import { defineProps, defineEmits, reactive,watch,ref, Ref, computed } from 'vue';
import{type CascaderOption, ElMessage, type FormInstance,type FormItemRule}from'element-plus'
import { defineProps, defineEmits, reactive,watch,ref, type Ref, computed } from 'vue';
import { dialogBig} from '@/utils/elementBind'
import { addPqErrSys,updatePqErrSys,getPqErrSysListById} from '@/api/device/error/index'
import {CirclePlus, Delete, EditPen,FolderOpened,CopyDocument} from '@element-plus/icons-vue'
import { useDictStore } from '@/stores/modules/dict'
import { type ErrorSystem } from '@/api/device/interface/error';
import ErrorSystemDetailTable from '@/views/machine/errorSystem/components/errorSystemDetailTable.vue';
import {getDictTreeList} from '@/api/system/dictionary/dictTree'
import { type Dict } from '@/api/system/dictionary/interface';
// 定义弹出组件元信息
const dialogFormRef = ref()
const dictStore = useDictStore()
const tableData = ref<ErrorSystem.ErrorSystemDetail[]>([]);
const options: Ref<CascaderOption[]> = ref([]); // 修改这里
const handleTableDataUpdate = (newTableData: ErrorSystem.ErrorSystemDetail[]) => {
tableData.value = newTableData;
@@ -149,12 +152,47 @@
console.error('验证过程中出现错误', err)
}
}
// 封装提取第二层节点的逻辑
const loadSecondLevelOptions = async () => {
const dictCode = '误差体系指标项'; // 替换为实际需要的字典代码
const resDictTree: Dict.ResDictTree = {
name: dictCode,
id: '',
pid: '',
pids: '',
code: '',
sort: 0
};
const result = await getDictTreeList(resDictTree);
const allOptions = convertToOptions(result.data as Dict.ResDictTree[]);
// 提取第二层节点
const secondLevelOptions: any[] = [];
allOptions.forEach(option => {
if (option.children && option.children.length > 0) {
secondLevelOptions.push(...option.children);
}
});
// 将第二层节点赋值给 options.value
options.value = secondLevelOptions;
};
// 转换函数
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) => {
titleType.value = sign
dialogVisible.value = true
// 确保每次打开弹窗时都重新加载数据
await loadSecondLevelOptions();
if (data.id) {
const result = await getPqErrSysListById(data);
if (result && result.data) {
@@ -167,6 +205,9 @@ const open = async (sign: string, data: ErrorSystem.ErrorSystemList) => {
}
// 重置表单
dialogFormRef.value?.resetFields()
dialogVisible.value = true
}