引入store存放检测设备的相关信息
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
export interface DataCheck {
|
||||
export namespace CheckData {
|
||||
export interface DataCheck {
|
||||
testScriptName: string,
|
||||
errorSysName: string,
|
||||
dataRule: string,
|
||||
deviceName: string,
|
||||
monitorIdx: string,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 用于定义 查看(设备)通道检测结果 类型
|
||||
*/
|
||||
export interface CheckResult {
|
||||
export interface CheckResult {
|
||||
chnNum: string,
|
||||
standardValue: number,
|
||||
L1: number,
|
||||
@@ -20,35 +21,40 @@ export interface CheckResult {
|
||||
L3_errValue: number,
|
||||
maxErrVaule: number,
|
||||
result: string,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 用于定义 具体通道的原始数据类型
|
||||
*/
|
||||
export interface RawDataItem {
|
||||
export interface RawDataItem {
|
||||
updateTime: string,
|
||||
L1: number,
|
||||
L2: number,
|
||||
L3: number
|
||||
}
|
||||
}
|
||||
|
||||
export interface Device {
|
||||
deviceID: string; //装置序号ID
|
||||
deviceName: string; //设备名称
|
||||
chnNum: number; //设备通道数
|
||||
}
|
||||
|
||||
// 用来描述检测脚本类型
|
||||
export interface ScriptItem {
|
||||
// 用来描述检测脚本类型
|
||||
export interface ScriptItem {
|
||||
id: string,
|
||||
scriptItemName: string,
|
||||
children?: ScriptItem[]
|
||||
}
|
||||
}
|
||||
|
||||
// 用来描述 通道检测结果
|
||||
export enum ChnCheckResultEnum {
|
||||
// 用来描述 通道检测结果
|
||||
export enum ChnCheckResultEnum {
|
||||
UNKNOWN = -1,
|
||||
FAIL = 0,
|
||||
SUCCESS = 1,
|
||||
}
|
||||
}
|
||||
|
||||
//用来描述 某个脚本测试项对所有通道的检测结果
|
||||
export interface ScriptChnItem {
|
||||
//用来描述 某个脚本测试项对所有通道的检测结果
|
||||
export interface ScriptChnItem {
|
||||
scriptID: string
|
||||
scriptItemName: string
|
||||
|
||||
@@ -58,39 +64,41 @@ export interface ScriptChnItem {
|
||||
deviceName: string,
|
||||
chnResult: ChnCheckResultEnum[] //通道检测结果
|
||||
}>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 用于描述 (设备)通道检测结果展示的按钮类型
|
||||
*/
|
||||
export interface ButtonResult {
|
||||
export interface ButtonResult {
|
||||
resultType: 'info' | 'success' | 'danger',
|
||||
resultValue: '-' | '√' | '×'
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* 用于描述 脚本检测结果展示的按钮类型
|
||||
*/
|
||||
export interface ScriptChnViewItem {
|
||||
export interface ScriptChnViewItem {
|
||||
scriptID: string,
|
||||
scriptItemName: string //脚本项名称
|
||||
|
||||
// 设备
|
||||
devices:Array<{
|
||||
devices: Array<{
|
||||
deviceID: string,
|
||||
deviceName: string,
|
||||
chnResult: ButtonResult[],
|
||||
}>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* 定义检测日志类型
|
||||
*/
|
||||
export interface LogItem {
|
||||
export interface LogItem {
|
||||
type: 'info' | 'error'
|
||||
log: string
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -17,3 +17,5 @@ export const USER_STORE_KEY = "cn-user";
|
||||
// pinia中dict store的key
|
||||
export const DICT_STORE_KEY = "cn-dictData";
|
||||
|
||||
export const CHECK_STORE_KEY = "cn-check";
|
||||
|
||||
|
||||
24
frontend/src/stores/modules/check.ts
Normal file
24
frontend/src/stores/modules/check.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import {defineStore} from "pinia";
|
||||
import {CHECK_STORE_KEY} from "@/stores/constant";
|
||||
import type {CheckData} from "@/api/check/interface";
|
||||
|
||||
|
||||
export const useCheckStore = defineStore("check", {
|
||||
id: CHECK_STORE_KEY,
|
||||
|
||||
state: () => ({
|
||||
devices: Array<CheckData.Device>()
|
||||
}),
|
||||
|
||||
getters: {},
|
||||
|
||||
actions: {
|
||||
addDevices(device: CheckData.Device[]) {
|
||||
this.devices.push(...device);
|
||||
},
|
||||
|
||||
clearDevices() {
|
||||
this.devices = [];
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -255,8 +255,11 @@ import { onMounted, reactive, ref, watch } from "vue";
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import ChannelsTest from './channelsTest.vue'
|
||||
import { useModeStore } from '@/stores/modules/mode'; // 引入模式 store
|
||||
import {useCheckStore} from '@/stores/modules/check'
|
||||
|
||||
const dictStore = useDictStore()
|
||||
const checkStore = useCheckStore()
|
||||
|
||||
let devNum = 0;//当前选取的被检设备数量
|
||||
let devChannelsNum = 0;//当前选择的被检设备通道总数
|
||||
let devTestedNum = 0;//当前选择的已完成检测的被检设备数量
|
||||
@@ -555,6 +558,16 @@ const handleSelectionChange = (selection: any[]) => {
|
||||
{
|
||||
testType= "reTest";
|
||||
}
|
||||
let devices: Check.Device[] = selection.map((item: any) => {
|
||||
return {
|
||||
deviceId: item.id,
|
||||
deviceName: item.name,
|
||||
deviceType: item.devType,
|
||||
chnNum: item.devChns,
|
||||
}
|
||||
});
|
||||
checkStore.clearDevices()
|
||||
checkStore.addDevices(devices)
|
||||
}
|
||||
|
||||
//查询
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
<el-button type="success" v-if="activeIndex >= TEST_TOTAL" :icon="Check" disabled>检测完成</el-button>
|
||||
|
||||
|
||||
<el-button type="text" :icon="InfoFilled" @click="showTestLog">检测项进度</el-button>
|
||||
<el-button
|
||||
type="warning"
|
||||
v-if="isPause && activeIndex < TEST_TOTAL"
|
||||
@@ -25,6 +23,7 @@
|
||||
@click="handlePauseOrContinue"
|
||||
>继续检测
|
||||
</el-button>
|
||||
<el-button type="text" :icon="InfoFilled" @click="showTestLog">检测项进度</el-button>
|
||||
<!-- <el-button
|
||||
type="warning"
|
||||
v-if="activeIndex >= TEST_TOTAL"
|
||||
@@ -46,9 +45,9 @@
|
||||
</el-table-column>
|
||||
|
||||
<template v-if="chnSum<=MAX_CHN_SUM">
|
||||
<el-table-column v-for="(item,index1) in monitorList" :key="item.deviceID" :label="item.deviceName"
|
||||
<el-table-column v-for="(item,index1) in deviceList" :key="item.deviceID" :label="item.deviceName"
|
||||
:min-width="110" align="center">
|
||||
<el-table-column v-for="(chnItem,index2) in item.chnNum" :key="item.deviceID+chnItem"
|
||||
<el-table-column v-for="(chnItem,index2) in item.chnNum" :key="`${item.deviceID}${chnItem}`"
|
||||
:label="'通道'+chnItem" align="center">
|
||||
<template #default="{row}">
|
||||
<el-tooltip
|
||||
@@ -69,7 +68,7 @@
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<el-table-column v-for="(item,index) in monitorList" :key="item.deviceID" :label="item.deviceName"
|
||||
<el-table-column v-for="(item,index) in deviceList" :key="item.deviceID" :label="item.deviceName"
|
||||
:min-width="110" align="center">
|
||||
<template #default="{row}">
|
||||
<el-tooltip :content="row.devices[index].chnResult[0].resultType==='info' ? '暂无数据' : '点击查看详情'"
|
||||
@@ -108,19 +107,15 @@
|
||||
<dataCheckSingleChannelSingleTestPopup ref="dataCheckSingleChannelSingleTestPopupRef"/>
|
||||
</template>
|
||||
<script lang="tsx" setup name="test">
|
||||
import {Check, Refresh, VideoPause} from '@element-plus/icons-vue'
|
||||
import {Check, Refresh, VideoPause,InfoFilled} from '@element-plus/icons-vue'
|
||||
import resultPopup from './resultPopup.vue'
|
||||
import dataCheckSingleChannelSingleTestPopup from './dataCheckSingleChannelSingleTestPopup.vue'
|
||||
import {reactive, ref} from "vue";
|
||||
import {dialogBig} from "@/utils/elementBind";
|
||||
import {
|
||||
ButtonResult,
|
||||
ChnCheckResultEnum,
|
||||
LogItem,
|
||||
ScriptChnItem,
|
||||
ScriptChnViewItem,
|
||||
ScriptItem
|
||||
} from "@/api/check/interface"
|
||||
import {CheckData} from "@/api/check/interface"
|
||||
import {useCheckStore} from "@/stores/modules/check";
|
||||
|
||||
const checkStore = useCheckStore()
|
||||
|
||||
const drawer = ref(false)
|
||||
const showTestLog = () =>{
|
||||
@@ -128,7 +123,6 @@ const showTestLog = () =>{
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 总测试项数
|
||||
const TEST_TOTAL = 12
|
||||
// 最大通道数
|
||||
@@ -149,46 +143,45 @@ const dataCheckSingleChannelSingleTestPopupRef = ref();
|
||||
// const currentRow = ref(null); // 用于存储当前选中的行
|
||||
|
||||
|
||||
|
||||
const monitorList = reactive([
|
||||
{
|
||||
deviceID: '1',
|
||||
deviceName: '240001',
|
||||
chnNum: 1,
|
||||
monitorIdx: 1,
|
||||
label: '240001',
|
||||
prop: 'Result1',
|
||||
},
|
||||
{
|
||||
deviceID: '2',
|
||||
deviceName: '240002',
|
||||
chnNum: 1,
|
||||
monitorIdx: 2,
|
||||
label: '240002',
|
||||
prop: 'Result2',
|
||||
},
|
||||
{
|
||||
deviceID: '3',
|
||||
deviceName: '240003',
|
||||
chnNum: 2,
|
||||
monitorIdx: 1,
|
||||
label: '240003',
|
||||
prop: 'Result3',
|
||||
},
|
||||
{
|
||||
deviceID: '4',
|
||||
deviceName: '240004',
|
||||
chnNum: 4,
|
||||
monitorIdx: 2,
|
||||
label: '240004',
|
||||
prop: 'Result4',
|
||||
}
|
||||
const deviceList = reactive<CheckData.Device[]>([
|
||||
// {
|
||||
// deviceID: '1',
|
||||
// deviceName: '240001',
|
||||
// chnNum: 1,
|
||||
// monitorIdx: 1,
|
||||
// label: '240001',
|
||||
// prop: 'Result1',
|
||||
// },
|
||||
// {
|
||||
// deviceID: '2',
|
||||
// deviceName: '240002',
|
||||
// chnNum: 1,
|
||||
// monitorIdx: 2,
|
||||
// label: '240002',
|
||||
// prop: 'Result2',
|
||||
// },
|
||||
// {
|
||||
// deviceID: '3',
|
||||
// deviceName: '240003',
|
||||
// chnNum: 2,
|
||||
// monitorIdx: 1,
|
||||
// label: '240003',
|
||||
// prop: 'Result3',
|
||||
// },
|
||||
// {
|
||||
// deviceID: '4',
|
||||
// deviceName: '240004',
|
||||
// chnNum: 4,
|
||||
// monitorIdx: 2,
|
||||
// label: '240004',
|
||||
// prop: 'Result4',
|
||||
// }
|
||||
])
|
||||
|
||||
// 总通道数
|
||||
const chnSum = computed(() => {
|
||||
let sum = 0
|
||||
monitorList.forEach((item) => {
|
||||
deviceList.forEach((item) => {
|
||||
sum += item.chnNum
|
||||
})
|
||||
return sum
|
||||
@@ -196,11 +189,12 @@ const chnSum = computed(() => {
|
||||
|
||||
onBeforeMount(() => {
|
||||
initScriptData()
|
||||
initDeviceList()
|
||||
initCheckResult()
|
||||
})
|
||||
|
||||
// 检测脚本数据
|
||||
const scriptData = reactive<ScriptItem[]>([])
|
||||
const scriptData = reactive<CheckData.ScriptItem[]>([])
|
||||
// 初始化检测脚本数据
|
||||
const initScriptData = () => {
|
||||
Object.assign(scriptData, [
|
||||
@@ -393,26 +387,35 @@ const initScriptData = () => {
|
||||
// },
|
||||
// ])
|
||||
}
|
||||
|
||||
// 初始化设备列表
|
||||
const initDeviceList = () => {
|
||||
checkStore.devices.forEach(item => {
|
||||
deviceList.push({
|
||||
deviceID: item.deviceID,
|
||||
deviceName: item.deviceName,
|
||||
chnNum: item.chnNum,
|
||||
})
|
||||
})
|
||||
}
|
||||
// 真正的检测结果(详细到通道)
|
||||
const checkResult = reactive<ScriptChnItem[]>([])
|
||||
const checkResult = reactive<CheckData.ScriptChnItem[]>([])
|
||||
// 初始化检测结果 (详细到通道)
|
||||
const initCheckResult = () => {
|
||||
scriptData.forEach(item => {
|
||||
// 处理当前节点的数据
|
||||
let temp: ScriptChnItem = {
|
||||
let temp: CheckData.ScriptChnItem = {
|
||||
scriptID: item.id,
|
||||
scriptItemName: item.scriptItemName,
|
||||
devices: []
|
||||
}
|
||||
for (let i = 0; i < monitorList?.length; i++) {
|
||||
let tempChnResult: ChnCheckResultEnum[] = []
|
||||
for (let j = 0; j < monitorList[i].chnNum; j++) {
|
||||
tempChnResult.push(ChnCheckResultEnum.UNKNOWN)
|
||||
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: monitorList[i].deviceID,
|
||||
deviceName: monitorList[i].deviceName,
|
||||
deviceID: deviceList[i].deviceID,
|
||||
deviceName: deviceList[i].deviceName,
|
||||
chnResult: tempChnResult
|
||||
})
|
||||
}
|
||||
@@ -420,7 +423,7 @@ const initCheckResult = () => {
|
||||
})
|
||||
}
|
||||
// 更新检测结果(详细到通道)
|
||||
const updateCheckResult = (data: ScriptChnItem) => {
|
||||
const updateCheckResult = (data: CheckData.ScriptChnItem) => {
|
||||
const {scriptID} = {...data}
|
||||
|
||||
checkResult.forEach(item => {
|
||||
@@ -435,34 +438,34 @@ const updateCheckResult = (data: ScriptChnItem) => {
|
||||
// 用来展示的检测结果
|
||||
const checkResultView = computed(() => {
|
||||
|
||||
let result: ScriptChnViewItem[] = checkResult.map(item => {
|
||||
let temp: ScriptChnViewItem = {
|
||||
let result: CheckData.ScriptChnViewItem[] = checkResult.map(item => {
|
||||
let temp: CheckData.ScriptChnViewItem = {
|
||||
scriptID: item.scriptID,
|
||||
scriptItemName: item.scriptItemName,
|
||||
devices: []
|
||||
}
|
||||
|
||||
item.devices.forEach(device => {
|
||||
let tempChnBtnResult: ButtonResult[] = []
|
||||
let tempChnBtnResult: CheckData.ButtonResult[] = []
|
||||
|
||||
if (chnSum.value <= MAX_CHN_SUM) {
|
||||
for (let j = 0; j < device.chnResult.length; j++) {
|
||||
if (device.chnResult[j] == ChnCheckResultEnum.UNKNOWN) {
|
||||
if (device.chnResult[j] == CheckData.ChnCheckResultEnum.UNKNOWN) {
|
||||
tempChnBtnResult.push({resultType: 'info', resultValue: '-'})
|
||||
} else if (device.chnResult[j] == ChnCheckResultEnum.FAIL) {
|
||||
} else if (device.chnResult[j] == CheckData.ChnCheckResultEnum.FAIL) {
|
||||
tempChnBtnResult.push({resultType: 'danger', resultValue: '×'})
|
||||
} else {
|
||||
tempChnBtnResult.push({resultType: 'success', resultValue: '√'})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let tempChnResult: ChnCheckResultEnum = device.chnResult[0]
|
||||
if (device.chnResult.some(item => item == ChnCheckResultEnum.FAIL)) {
|
||||
tempChnResult = ChnCheckResultEnum.FAIL
|
||||
let tempChnResult: CheckData.ChnCheckResultEnum = device.chnResult[0]
|
||||
if (device.chnResult.some(item => item == CheckData.ChnCheckResultEnum.FAIL)) {
|
||||
tempChnResult = CheckData.ChnCheckResultEnum.FAIL
|
||||
}
|
||||
if (tempChnResult == ChnCheckResultEnum.UNKNOWN) {
|
||||
if (tempChnResult == CheckData.ChnCheckResultEnum.UNKNOWN) {
|
||||
tempChnBtnResult.push({resultType: 'info', resultValue: '-'})
|
||||
} else if (tempChnResult == ChnCheckResultEnum.FAIL) {
|
||||
} else if (tempChnResult == CheckData.ChnCheckResultEnum.FAIL) {
|
||||
tempChnBtnResult.push({resultType: 'danger', resultValue: '×'})
|
||||
} else {
|
||||
tempChnBtnResult.push({resultType: 'success', resultValue: '√'})
|
||||
@@ -529,7 +532,7 @@ function getTimeDifference(timeDifference: number): string {
|
||||
}
|
||||
|
||||
// 用来存放检测日志
|
||||
const testLogList = ref<LogItem[]>([{type: 'info', log: '暂无数据,等待检测开始'}])
|
||||
const testLogList = ref<CheckData.LogItem[]>([{type: 'info', log: '暂无数据,等待检测开始'}])
|
||||
|
||||
// 更新日志
|
||||
const updateLog = () => {
|
||||
@@ -797,17 +800,17 @@ const updateCheckResultView = (scriptID: string) => {
|
||||
const simulateCheck = (scriptID: string) => {
|
||||
let devices = []
|
||||
|
||||
devices = monitorList.map(item => {
|
||||
devices = deviceList.map(item => {
|
||||
|
||||
let tempChnResult: ChnCheckResultEnum[] = []
|
||||
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
|
||||
for (let i = 0; i < item.chnNum; i++) {
|
||||
tempChnResult.push(ChnCheckResultEnum.SUCCESS)
|
||||
tempChnResult.push(CheckData.ChnCheckResultEnum.SUCCESS)
|
||||
}
|
||||
|
||||
let randomNum = getRandomInt(item.chnNum * 2)
|
||||
if (activeIndex.value >= 4 && activeIndex.value <= 6) {
|
||||
if (randomNum <= item.chnNum) {
|
||||
tempChnResult[randomNum] = ChnCheckResultEnum.FAIL
|
||||
tempChnResult[randomNum] = CheckData.ChnCheckResultEnum.FAIL
|
||||
|
||||
errorCheckItem.push(scriptID)
|
||||
}
|
||||
@@ -820,7 +823,7 @@ const simulateCheck = (scriptID: string) => {
|
||||
}
|
||||
})
|
||||
|
||||
let tempScriptChnItem: ScriptChnItem = {
|
||||
let tempScriptChnItem: CheckData.ScriptChnItem = {
|
||||
scriptID,
|
||||
devices,
|
||||
}
|
||||
@@ -839,7 +842,7 @@ const handleReCheck = () => {
|
||||
};
|
||||
|
||||
// 用来保存定时器
|
||||
const timer = ref("");
|
||||
const timer:any = ref("");
|
||||
|
||||
// 处理暂停、继续按钮点击事件
|
||||
const handlePauseOrContinue = () => {
|
||||
|
||||
Reference in New Issue
Block a user