This commit is contained in:
caozehui
2024-12-24 19:21:43 +08:00
parent 30c1f90513
commit 5cbdadecc4
6 changed files with 250 additions and 291 deletions

View File

@@ -1,5 +1,5 @@
import http from "@/api";
export const getCheckItemDetail = (params: { checkItemId: string, deviceId: string, chnNum: number }) => {
export const getCheckItemDetail = (params: { deviceId: string, chnNum: number, checkItemId?: string }) => {
return http.post<any>("/check/test/detail/", params, {loading: false});
}

View File

@@ -67,6 +67,7 @@ import DataCheckResultTable from './dataCheckResultTable.vue'
import DataCheckRawDataTable from './dataCheckRawDataTable.vue'
import {CheckData} from "@/api/check/interface";
import {data as treeData} from "@/api/plan/autoTest.json";
import {getCheckItemDetail} from "@/api/check/test";
const {appendToBody} = withDefaults(defineProps<{
appendToBody: boolean
@@ -279,10 +280,14 @@ const close = () => {
visible.value = false;
};
const open = (checkItemId: string, deviceId: string, chnNum?: number) => {
console.log(checkItemId, deviceId, chnNum);
const open = async (deviceId: string, chnNum: number, checkItemId?: string) => {
// 发起后端请求,查询详细信息
//const result = await getCheckItemDetail({checkItemId,deviceId, chnNum})
// 当checkItemId为空时默认显示全部测试项、全部不合格测试项
// 当checkItemId不为空时默认显示当前checkItemId的测试项、属于当前checkItemId的不合格测试项
checkItemId = checkItemId ?? ''
console.log(deviceId, chnNum, checkItemId);
//const result = await getCheckItemDetail({deviceId, chnNum, checkItemId})
// 数据处理
// checkResultTableData=[];
@@ -330,6 +335,7 @@ defineExpose({
padding: 10px 0;
border: 1px solid #ccc;
overflow: auto;
.content-tree {
min-width: 100%;
height: 100%;

View File

@@ -875,8 +875,7 @@ const openDrawer = (title: string, row: any) => {
if(title === '检测数据查询')
{
let device={}
dataCheckPopupRef.value?.open(device)
dataCheckPopupRef.value?.open(row.id,-1)
}
if (title === '误差体系更换')
{

View File

@@ -8,17 +8,17 @@
<el-button
type="primary"
v-if="testStatus=='process' && activeIndex < TEST_TOTAL"
v-if="testStatus=='process' && activeIndex < checkTotal"
:disabled="activeIndex===0"
:icon="VideoPause"
@click="emit('update:testStatus','paused')">停止检测
</el-button>
<el-button type="success" v-if="activeIndex >= TEST_TOTAL" :icon="Check" disabled>检测完成</el-button>
<el-button type="success" v-if="activeIndex >= checkTotal" :icon="Check" disabled>检测完成</el-button>
<el-button
type="warning"
v-if="testStatus=='paused' && activeIndex < TEST_TOTAL"
v-if="testStatus=='paused' && activeIndex < checkTotal"
:icon="Refresh"
@click="emit('update:testStatus','process')"
>继续检测
@@ -26,7 +26,7 @@
<el-button type="text" :icon="InfoFilled" @click="showTestLog">检测项进度</el-button>
<!-- <el-button
type="warning"
v-if="activeIndex >= TEST_TOTAL"
v-if="activeIndex >= checkTotal"
:icon="Refresh"
@click="handleReCheck"
>重新检测</el-button
@@ -90,15 +90,20 @@
</div>
</div>
<el-drawer v-model="drawer" title="检测项进度">
<div ref="scrollContainer">
<p v-for="(item, index) in testLogList"
:key="index"
:style="{color:item.type==='error'?'#F56C6C':'var(--el-text-color-regular)'}">
{{ item.log }}<br/>
</p>
</div>
</el-drawer>
<div class="drawer-container">
<el-drawer v-model="drawer" title="检测项进度">
<!-- <template #header>-->
<!-- <div style="background: #003078 !important; color: #fff !important; font-size: 18px;">检测项进度</div>-->
<!-- </template>-->
<div ref="scrollContainer">
<p v-for="(item, index) in testLogList"
:key="index"
:style="{color:item.type==='error'?'#F56C6C':'var(--el-text-color-regular)'}">
{{ item.log }}<br/>
</p>
</div>
</el-drawer>
</div>
<resultPopup
:visible="resultDialogVisible"
@@ -117,11 +122,12 @@ import {useCheckStore} from "@/stores/modules/check";
const checkStore = useCheckStore()
// 总测试项数
const TEST_TOTAL = 12 + 1
// 最大通道数
const MAX_CHN_SUM = 10
// 总测试项数
const checkTotal = ref(0)
const props = defineProps({
testStatus: {
type: String,
@@ -139,6 +145,8 @@ const emit = defineEmits(['update:testStatus', 'update:webMsgSend']);
const drawer = ref(false)
// 进度条颜色
const customColors = [{color: "#5cb87a", percentage: 100}]
// 检测脚本数据
const scriptData = reactive<CheckData.ScriptItem[]>([])
// 用来保存被检设备
const deviceList = reactive<CheckData.Device[]>([])
// 用来保存定时器
@@ -152,6 +160,8 @@ const startData = ref(new Date())
//测试项检测结束时间(或暂停时的时间)
const endData = ref(new Date())
const timeDifference = ref(0)
// 真正的检测结果(详细到通道)
const checkResult = reactive<CheckData.ScriptChnItem[]>([])
// 用来存放检测出现失败的测试项id。只要有一个通道检测不合格则该检测项的id会被加入该数组。
const errorCheckItem = reactive<string[]>([]);
// 用来存放检测日志
@@ -161,7 +171,9 @@ const testStatus = toRef(props, 'testStatus')
const webMsgSend = toRef(props, 'webMsgSend')
const resultDialogVisible = ref(false)
const dataCheckSingleChannelSingleTestPopupRef = ref()
const scrollContainer = ref<HTMLElement | null>(null);
const dataCheckSingleChannelSingleTestPopupRef = ref<InstanceType<typeof dataCheckSingleChannelSingleTestPopup>>()
// 总通道数
const chnSum = computed(() => {
@@ -172,265 +184,6 @@ const chnSum = computed(() => {
return sum
})
watch(testStatus, function (newValue, oldValue) {
if (newValue == 'start') {
emit('update:testStatus', 'process')
startTimer()
}
if (newValue == 'paused' && oldValue == 'process') {
handlePauseOrContinue()
}
if (newValue === 'process' && oldValue == 'paused') {
handlePauseOrContinue()
}
})
watch(webMsgSend, function (newValue, oldValue) {
if (activeIndex.value <= TEST_TOTAL) {
console.log('检测开始')
switch (newValue.requestId) {
case 'Test_Freq':
updateCheckResultView("Freq")
break;
case 'Test_VOL':
updateCheckResultView("VOL")
break;
case 'Test_Harm_V':
updateCheckResultView("Harm_V")
break;
case 'Test_Harm_I':
updateCheckResultView("Harm_I")
break;
case 'Test_Harm_P':
updateCheckResultView("Harm_P")
break;
case 'Test_InHarm_V':
updateCheckResultView("InHarm_V")
break;
case 'Test_InHarm_I':
updateCheckResultView("InHarm_I")
break;
case 'Test_Dip':
updateCheckResultView("Dip")
break;
case 'Test_CUR':
updateCheckResultView("CUR")
break;
case 'Test_MSQI_U':
updateCheckResultView("MSQI_U")
break;
case 'Test_MSQI_I':
updateCheckResultView("MSQI_I")
break;
case 'Test_Flicker':
updateCheckResultView("Flicker")
break;
case 'Test_Quit':
console.log('检测结束')
break;
}
updateLog()
activeIndex.value++;
if (percentage.value < 100) {
percentage.value = Math.trunc(activeIndex.value / TEST_TOTAL * 100);
} else {
percentage.value = 100;
clearInterval(timer.value)
timer.value = null;
emit('update:testStatus', 'success')
ElMessageBox.alert('检测全部结束,你可以停留在此页面查看检测结果,或返回首页进行复检、报告生成和归档等操作', '检测完成', {
// if you want to disable its autofocus
// autofocus: false,
confirmButtonText: '确定',
})
clear();
}
} else {
clearInterval(timer.value)
timer.value = null;
emit('update:testStatus', 'success')
scrollToBottom();
}
}, {deep: true})
onBeforeMount(() => {
initScriptData()
initDeviceList()
initCheckResult()
})
const showTestLog = () => {
drawer.value = true
}
// const currentRow = ref<{
// id: number;
// scriptItemName: string;
// name: string;
// address: string;
// hasChildren?: boolean;
// children?: User[]
// } | null>(null);
// const currentRow = ref(null); // 用于存储当前选中的行
// 检测脚本数据
const scriptData = reactive<CheckData.ScriptItem[]>([])
// 初始化检测脚本数据
const initScriptData = () => {
let map = new Map<string, string>()
map.set('Freq', '频率')
.set('VOL', '电压')
.set('Harm_V', '谐波电压')
.set('Harm_I', '谐波电流')
.set('Harm_P', '谐波有功功率')
.set('InHarm_V', '间谐波电压')
.set('InHarm_I', '间谐波电流')
.set('Dip', '暂态')
.set('CUR', '电流')
.set('MSQI_U', '电压不平衡度')
.set('MSQI_I', '电流不平衡度')
.set('Flicker', '短时闪变')
let response: CheckData.ScriptItem[] = [
{id: '1', code: 'Freq', scriptItemName: '频率准确度检测'},
{id: '2', code: 'VOL', scriptItemName: '电压准确度检测'},
{id: '3', code: 'Harm_V', scriptItemName: '谐波电压准确度检测'},
{id: '4', code: 'Harm_I', scriptItemName: '谐波电流准确度检测'},
{id: '5', code: 'Harm_P', scriptItemName: '谐波有功功率准确度检测'},
{id: '6', code: 'InHarm_V', scriptItemName: '间谐波电压准确度检测'},
{id: '7', code: 'InHarm_I', scriptItemName: '间谐波电流准确度检测'},
{id: '8', code: 'Dip', scriptItemName: '暂态准确度检测'},
{id: '9', code: 'CUR', scriptItemName: '电流准确度检测'},
{id: '10', code: 'MSQI_U', scriptItemName: '三相电压不平衡度检测'},
{id: '11', code: 'MSQI_I', scriptItemName: '三相电流不平衡度检测'},
{id: '12', code: 'Flicker', scriptItemName: '闪变准确度检测'}
]
// Object.assign(scriptData, [
// {
// id: '1',
// code: 'Freq',
// scriptItemName: '频率'
// },
// {
// id: '2',
// code: 'VOL',
// scriptItemName: '电压'
// },
// {
// id: '3',
// code: 'Harm_V',
// scriptItemName: '谐波电压'
// },
// {
// id: '4',
// code: 'Harm_I',
// scriptItemName: '谐波电流'
// },
// {
// id: '5',
// code: 'Harm_P',
// scriptItemName: '谐波有功功率'
// },
// {
// id: '6',
// code: 'InHarm_V',
// scriptItemName: '间谐波电压'
// },
// {
// id: '7',
// code: 'InHarm_I',
// scriptItemName: '间谐波电流'
// },
// {
// id: '8',
// code: 'Dip',
// scriptItemName: '暂态'
// },
// {
// id: '9',
// code: 'CUR',
// scriptItemName: '电流'
// },
// {
// id: '10',
// code: 'MSQI_U',
// scriptItemName: '电压不平衡度'
// },
// {
// id: '11',
// code: 'MSQI_I',
// scriptItemName: '电流不平衡度'
// },
// {
// id: '12',
// code: 'Flicker',
// scriptItemName: '短时闪变'
// },
// ])
let temp = response.map(item => {
return {
...item,
scriptItemName: map.get(item.code) || item.scriptItemName
}
})
scriptData.push(...temp)
}
// 初始化设备列表
const initDeviceList = () => {
checkStore.devices.forEach(item => {
deviceList.push({
deviceId: item.deviceId,
deviceName: item.deviceName,
chnNum: item.chnNum,
})
})
}
// 真正的检测结果(详细到通道)
const checkResult = reactive<CheckData.ScriptChnItem[]>([])
// 初始化检测结果 (详细到通道)
const initCheckResult = () => {
scriptData.forEach(item => {
// 处理当前节点的数据
let temp: CheckData.ScriptChnItem = {
scriptId: item.id,
scriptItemName: item.scriptItemName,
devices: []
}
for (let i = 0; i < deviceList?.length; i++) {
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
for (let j = 0; j < deviceList[i].chnNum; j++) {
tempChnResult.push(CheckData.ChnCheckResultEnum.UNKNOWN)
}
temp.devices.push({
deviceId: deviceList[i].deviceId,
deviceName: deviceList[i].deviceName,
chnResult: tempChnResult
})
}
checkResult.push(temp)
})
}
// 更新检测结果(详细到通道)
const updateCheckResult = (data: CheckData.ScriptChnItem) => {
const {scriptId} = {...data}
checkResult.forEach(item => {
if (item.scriptId == scriptId) {
item.devices.forEach((device, index) => {
device.chnResult = [...data.devices[index].chnResult]
})
}
})
}
// 用来展示的检测结果
const checkResultView = computed(() => {
@@ -480,7 +233,188 @@ const checkResultView = computed(() => {
return result
})
const scrollContainer = ref<HTMLElement | null>(null); // 声明 scrollContainer
watch(testStatus, function (newValue, oldValue) {
if (newValue == 'start') {
emit('update:testStatus', 'process')
startTimer()
}
if (newValue == 'paused' && oldValue == 'process') {
handlePauseOrContinue()
}
if (newValue === 'process' && oldValue == 'paused') {
handlePauseOrContinue()
}
})
watch(webMsgSend, function (newValue, oldValue) {
if (activeIndex.value <= checkTotal.value) {
console.log('检测开始')
switch (newValue.requestId) {
case 'Test_Freq':
updateCheckResultView("Freq")
break;
case 'Test_VOL':
updateCheckResultView("VOL")
break;
case 'Test_Harm_V':
updateCheckResultView("Harm_V")
break;
case 'Test_Harm_I':
updateCheckResultView("Harm_I")
break;
case 'Test_Harm_P':
updateCheckResultView("Harm_P")
break;
case 'Test_InHarm_V':
updateCheckResultView("InHarm_V")
break;
case 'Test_InHarm_I':
updateCheckResultView("InHarm_I")
break;
case 'Test_Dip':
updateCheckResultView("Dip")
break;
case 'Test_CUR':
updateCheckResultView("CUR")
break;
case 'Test_MSQI_U':
updateCheckResultView("MSQI_U")
break;
case 'Test_MSQI_I':
updateCheckResultView("MSQI_I")
break;
case 'Test_Flicker':
updateCheckResultView("Flicker")
break;
case 'Test_Quit':
console.log('检测结束')
break;
}
updateLog()
activeIndex.value++;
if (percentage.value < 100) {
percentage.value = Math.trunc(activeIndex.value / checkTotal.value * 100);
} else {
percentage.value = 100;
clearInterval(timer.value)
timer.value = null;
emit('update:testStatus', 'success')
ElMessageBox.alert('检测全部结束,你可以停留在此页面查看检测结果,或返回首页进行复检、报告生成和归档等操作', '检测完成', {
// if you want to disable its autofocus
// autofocus: false,
confirmButtonText: '确定',
})
clear();
}
} else {
clearInterval(timer.value)
timer.value = null;
emit('update:testStatus', 'success')
scrollToBottom();
}
}, {deep: true})
onBeforeMount(() => {
initScriptData()
initDeviceList()
initCheckResult()
})
const showTestLog = () => {
drawer.value = true
}
// 初始化检测脚本数据
const initScriptData = () => {
let map = new Map<string, string>()
map.set('Freq', '频率')
.set('VOL', '电压')
.set('Harm_V', '谐波电压')
.set('Harm_I', '谐波电流')
.set('Harm_P', '谐波有功功率')
.set('InHarm_V', '间谐波电压')
.set('InHarm_I', '间谐波电流')
.set('Dip', '暂态')
.set('CUR', '电流')
.set('MSQI_U', '电压不平衡度')
.set('MSQI_I', '电流不平衡度')
.set('Flicker', '短时闪变')
let response: CheckData.ScriptItem[] = [
{id: '1', code: 'Freq', scriptItemName: '频率准确度检测'},
{id: '2', code: 'VOL', scriptItemName: '电压准确度检测'},
{id: '3', code: 'Harm_V', scriptItemName: '谐波电压准确度检测'},
{id: '4', code: 'Harm_I', scriptItemName: '谐波电流准确度检测'},
{id: '5', code: 'Harm_P', scriptItemName: '谐波有功功率准确度检测'},
{id: '6', code: 'InHarm_V', scriptItemName: '间谐波电压准确度检测'},
{id: '7', code: 'InHarm_I', scriptItemName: '间谐波电流准确度检测'},
{id: '8', code: 'Dip', scriptItemName: '暂态准确度检测'},
{id: '9', code: 'CUR', scriptItemName: '电流准确度检测'},
{id: '10', code: 'MSQI_U', scriptItemName: '三相电压不平衡度检测'},
{id: '11', code: 'MSQI_I', scriptItemName: '三相电流不平衡度检测'},
{id: '12', code: 'Flicker', scriptItemName: '闪变准确度检测'}
]
let temp = response.map(item => {
return {
...item,
scriptItemName: map.get(item.code) || item.scriptItemName
}
})
scriptData.push(...temp)
checkTotal.value = scriptData.length + 1
}
// 初始化设备列表
const initDeviceList = () => {
checkStore.devices.forEach(item => {
deviceList.push({
deviceId: item.deviceId,
deviceName: item.deviceName,
chnNum: item.chnNum,
})
})
}
// 初始化检测结果 (详细到通道)
const initCheckResult = () => {
scriptData.forEach(item => {
// 处理当前节点的数据
let temp: CheckData.ScriptChnItem = {
scriptId: item.id,
scriptItemName: item.scriptItemName,
devices: []
}
for (let i = 0; i < deviceList?.length; i++) {
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
for (let j = 0; j < deviceList[i].chnNum; j++) {
tempChnResult.push(CheckData.ChnCheckResultEnum.UNKNOWN)
}
temp.devices.push({
deviceId: deviceList[i].deviceId,
deviceName: deviceList[i].deviceName,
chnResult: tempChnResult
})
}
checkResult.push(temp)
})
}
// 更新检测结果(详细到通道)
const updateCheckResult = (data: CheckData.ScriptChnItem) => {
const {scriptId} = {...data}
checkResult.forEach(item => {
if (item.scriptId == scriptId) {
item.devices.forEach((device, index) => {
device.chnResult = [...data.devices[index].chnResult]
})
}
})
}
const scrollToBottom = () => {
if (scrollContainer.value) {
scrollContainer.value.scrollTop = scrollContainer.value.scrollHeight;
@@ -828,14 +762,16 @@ const handlePauseOrContinue = () => {
// 点击查看设备通道检测详情。参数1设备信息参数2通道号-1代表查看全部通道
const handleClick = (scriptId: string, deviceId: any, chnNum: number) => {
dataCheckSingleChannelSingleTestPopupRef.value?.open(scriptId, deviceId, chnNum);
dataCheckSingleChannelSingleTestPopupRef.value?.open(deviceId, chnNum, scriptId);
};
const startTimer = () => {
activeIndex.value++;
if (activeIndex.value === 0) {
activeIndex.value++;
}
//if (timer.value !== null) return; // 如果定时器已经启动,则不再重复启动
timer.value = setInterval(() => {
if (activeIndex.value <= TEST_TOTAL) {
if (activeIndex.value <= checkTotal.value) {
switch (activeIndex.value) {
case 1:
emit('update:webMsgSend', {
@@ -1022,6 +958,24 @@ function clear() {
font-size: 14px;
}
}
.drawer-container{
:deep(header.el-drawer__header){
color: #fff !important;
background-color: #003078 !important;
.el-drawer__close-btn svg:hover {
color: #ccc !important;
}
.el-drawer__title{
color: #fff !important;
}
}
}
//:deep(.el-drawer .el-drawer__title){
// background-color: #003078 !important;
//}
</style>
@@ -1035,4 +989,5 @@ function clear() {
padding: 5px 0 !important;
}
</style>

View File

@@ -399,9 +399,9 @@ const resizeObserver = new ResizeObserver(entries => {
chartsWidth.value = entry.contentRect.width;
//console.log('Charts Info Width:', chartsWidth.value);
pieRef1.value.reSize(chartsWidth.value * 0.95, 180, true);
pieRef2.value.reSize(chartsWidth.value * 0.95, 180, true);
pieRef3.value.reSize(chartsWidth.value * 0.95, 180, true);
pieRef1.value?.reSize(chartsWidth.value * 0.95, 180, true);
pieRef2.value?.reSize(chartsWidth.value * 0.95, 180, true);
pieRef3.value?.reSize(chartsWidth.value * 0.95, 180, true);
}
});

View File

@@ -33,8 +33,7 @@
</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="row.startFlag === 2"/>
</el-col>
</el-row>
</template>
@@ -50,7 +49,7 @@
</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="row.endFlag === 2"/>
</el-col>
</el-row>
</template>