30 Commits

Author SHA1 Message Date
caozehui
5abaa743c0 修改常量 2026-06-11 10:35:11 +08:00
caozehui
52a8095334 移除文件 2026-06-11 09:57:01 +08:00
caozehui
654c997607 移除文件 2026-06-11 09:43:59 +08:00
caozehui
b31efb9ede 闪变编辑框微调 2026-06-11 09:28:26 +08:00
caozehui
195b58d798 比对检测计划默认值 2026-06-09 19:22:54 +08:00
caozehui
0423de2683 新增小工具页面、SNTP对时功能集成到小工具页面 2026-06-08 08:46:29 +08:00
caozehui
27b593ba01 微调 2026-06-02 11:21:55 +08:00
caozehui
8c7b164166 微调 2026-06-02 09:25:17 +08:00
caozehui
bdc45b8890 微调 2026-06-01 18:37:31 +08:00
caozehui
2705bedc71 微调 2026-06-01 14:12:47 +08:00
caozehui
ae970d048c 微调 2026-06-01 11:34:39 +08:00
caozehui
29f57c80ef 数据库调整 2026-06-01 11:25:37 +08:00
caozehui
80072bf7e0 资源管理前后端 2026-06-01 11:20:11 +08:00
caozehui
8d377dfed7 微调 2026-06-01 11:09:32 +08:00
caozehui
633b6ffd29 自动播放视频 2026-06-01 11:07:47 +08:00
caozehui
cf3141198b 微调 2026-06-01 09:26:01 +08:00
caozehui
c05d329614 补充观看教学视频路由跳转功能,检测页面微调 2026-05-29 10:39:12 +08:00
caozehui
ee08263e4a 检测计划统计弹窗下拉框内容调整 2026-05-29 09:58:24 +08:00
19ea08d5e0 feat(detection): 添加检测锁机制防止多用户同时操作
- 新增 detectionLock store 管理检测锁状态
- 实现检测锁相关的弹窗提示功能
- 添加 DETECTION_BUSY 错误码处理多人竞争逻辑
- 在 websocket 中集成检测锁超时处理
- 修改程序源控制接口以同步锁状态
- 更新项目标题和图标配置
- 添加 docs 目录到忽略列表
2026-05-28 20:44:53 +08:00
caozehui
f9809197e8 微调 2026-05-28 16:33:07 +08:00
caozehui
0090a922c6 资源管理页面微调 2026-05-28 14:37:40 +08:00
caozehui
0b26de20b9 资源管理 2026-05-28 13:26:35 +08:00
caozehui
1202f64bfc 检测计划统计功能 2026-05-28 08:44:15 +08:00
caozehui
ce1738daf0 微调 2026-05-27 11:20:12 +08:00
caozehui
a41d824ca3 归档 2026-05-26 15:45:08 +08:00
caozehui
ac5a8450e8 微调 2026-05-26 14:23:59 +08:00
caozehui
01e817a5d6 微调 2026-05-26 13:45:23 +08:00
caozehui
01bf07fc42 检测计划统计功能 2026-05-26 09:22:38 +08:00
caozehui
633e914c9a Revert "下拉多选报告模版"
This reverts commit 37e69e7bda.
2026-05-25 18:38:46 +08:00
caozehui
37e69e7bda 下拉多选报告模版 2026-05-25 14:25:57 +08:00
89 changed files with 2499 additions and 2341 deletions

1
.gitignore vendored
View File

@@ -9,3 +9,4 @@ public/electron/
pnpm-lock.yaml
CLAUDE.md
/public/dist/
/docs/

View File

@@ -33,9 +33,9 @@ mybatis-plus:
#驼峰命名
map-underscore-to-camel-case: true
#配置sql日志输出
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#关闭日志输出
# log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
global-config:
db-config:
#指定主键生成策略
@@ -55,30 +55,32 @@ webSocket:
#源参数下发,暂态数据默认值
Dip:
#暂态前时间s
fPreTime: 2f
# 暂态前时间s
# fPreTime: 2f
#写入时间s
fRampIn: 0.001f
#写出时间s
fRampOut: 0.001f
#暂态后时间s
fAfterTime: 3f
# 暂态后时间s
# fAfterTime: 3f
Flicker:
waveFluType: CPM
waveType: SQU
fDutyCycle: 50f
#Flicker:
# waveFluType: CPM
# waveType: SQU
# fDutyCycle: 50f
log:
homeDir: {{APP_DATA_PATH}}\logs
commonLevel: info
#log:
# homeDir: D:\logs
# commonLevel: info
report:
template: {{APP_DATA_PATH}}\template
reportDir: {{APP_DATA_PATH}}\report
# template: D:\template
# reportDir: D:\report
dateFormat: yyyy年MM月dd日
data:
homeDir: {{APP_DATA_PATH}}\data
#data:
# homeDir: D:\data
#resource:
# videoDir: ${data.homeDir}\resources\videos
qr:
cloud: http://pqmcc.com:18082/api/file
dev:

View File

@@ -1 +1 @@
95428
116212

Binary file not shown.

Binary file not shown.

View File

@@ -14,3 +14,5 @@
.\binlog.000036
.\binlog.000037
.\binlog.000038
.\binlog.000039
.\binlog.000040

View File

@@ -16,12 +16,13 @@ VITE_PWA=false
# 开发环境接口地址
VITE_API_URL=/api
VITE_COMPANY_WEBSITE=http://www.shining-electric.com/
# 开发环境跨域代理,支持配置多个
VITE_PROXY=[["/api","http://127.0.0.1:18093/"]]
VITE_PROXY=[["/api","http://127.0.0.1:18092/"]]
#VITE_PROXY=[["/api","http://192.168.1.124:18092/"]]
#VITE_PROXY=[["/api","http://192.168.2.125:18092/"]]
# VITE_PROXY=[["/api","http://192.168.1.138:8080/"]]张文
VITE_IS_SHOW_RAW_DATA=true
# 开启激活验证
VITE_ACTIVATE_OPEN=false

View File

@@ -23,6 +23,8 @@ VITE_PWA=true
# 线上环境接口地址
#VITE_API_URL="/api" # 打包时用
VITE_API_URL="http://127.0.0.1:18093/"
VITE_API_URL="http://127.0.0.1:18092/"
VITE_COMPANY_WEBSITE=http://www.shining-electric.com/
VITE_IS_SHOW_RAW_DATA=true
# 开启激活验证
VITE_ACTIVATE_OPEN=false
VITE_ACTIVATE_OPEN=false

View File

@@ -4,7 +4,8 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1.0, minimum-scale=1.0" />
<title></title>
<link rel="icon" type="image/x-icon" href="/favicon.ico">
<title>NPQS-9100</title>
<!-- 优化vue渲染未完成之前先加一个css动画 -->
<style>
#loadingPage {

BIN
frontend/public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@@ -0,0 +1,15 @@
import http from '@/api'
import type { DetectionLockHolder } from '@/stores/modules/detectionLock'
/**
* 查询当前检测锁持有状态
* - data 为 null → 锁空闲
* - data 非 null → 锁被某账号持有
*
* 本接口只读,不抢锁、不会返回 DETECTION_BUSY
*/
export const getCurrentLock = () => {
return http.get<DetectionLockHolder | null>('/detection/lock/current', undefined, {
loading: false
})
}

View File

@@ -1,6 +1,7 @@
import type { controlSource } from '@/api/device/interface/controlSource'
import http from '@/api'
import { useDetectionLockStore } from '@/stores/modules/detectionLock'
/**
* @name 程控源管理模块
@@ -17,8 +18,11 @@ export const startSimulateTest = (params: controlSource.ResControl) => {
}
//停止
export const closeSimulateTest = (params: controlSource.ResControl) => {
return http.post(`/prepare/closeSimulateTest`,params,{loading:false})
export const closeSimulateTest = async (params: controlSource.ResControl) => {
const result = await http.post(`/prepare/closeSimulateTest`,params,{loading:false})
// 主动终止 → 释放本地持锁标记
useDetectionLockStore().clearHolder()
return result
}

View File

@@ -1,269 +0,0 @@
const data = [
{
id: 'device1',
deviceName:"模拟装置1",
deviceType:"PQS882B4电能质量监测装置",
deviceChannels:"4",
planName: "沧州220kV留古等4座变电站电能质量检测",
deviceUn: "57.74",
deviceIn: "5",
deviceCompany: "南京灿能电力自动化股份有限公司",
deviceModel: "模拟式",
},
{
id: 'device2',
deviceName:"模拟装置2",
deviceType:"PQS882A电能质量监测装置",
deviceChannels:"1",
planName: "邯郸220kV团城站等4座站电能质量检测",
deviceUn: "57.74",
deviceIn: "5",
deviceCompany: "南京灿能电力自动化股份有限公司",
deviceModel: "模拟式",
},
{
id: 'device3',
deviceName:"模拟装置3",
deviceType:"PQS882A电能质量监测装置",
deviceChannels:"1",
planName: "衡水冀州光伏电站配套出口工程",
deviceUn: "57.74",
deviceIn: "1",
deviceCompany: "南京灿能电力自动化股份有限公司",
deviceModel: "模拟式",
},
{
id: 'device4',
deviceName:"模拟装置4",
deviceType:"PMC-680M-22-22-00-115ANBC电能质量监测装置",
deviceChannels:"4",
planName: "深圳市中电软件有限公司委托送检",
deviceUn: "57.74",
deviceIn: "5",
deviceCompany: "深圳中电电力技术股份有限公司",
deviceModel: "模拟式",
},
]
const plan_devicedata = [
{
id: '1', //装置序号ID
name: '240001', //设备名称
dev_Type: 'PQS-882B4',//设备类型
dev_Chns: 4, //设备通道数
check_Result: '未检', //检测结果
report_State: '未生成', //报告状态
document_State: '未归档', //归档状态
check_State:'未检',//检测状态
reCheck_Num: 0, //复检次数
},
{
id: '2', //装置序号ID
name: '240002', //设备名称
dev_Type: 'PQS-882B4',//设备类型
dev_Chns: 4, //设备通道数
check_Result: '未检', //检测结果
report_State: '未生成', //报告状态
document_State: '未归档', //归档状态
check_State:'未检',//检测状态
reCheck_Num: 0, //复检次数
},
{
id: '3', //装置序号ID
name: '240003', //设备名称
dev_Type: 'PQS-882B4',//设备类型
dev_Chns: 4, //设备通道数
check_Result: '未检', //检测结果
report_State: '未生成', //报告状态
document_State: '未归档', //归档状态
check_State:'未检',//检测状态
reCheck_Num: 0, //复检次数
},
{
id: '4', //装置序号ID
name: '240004', //设备名称
dev_Type: 'PQS-882B4',//设备类型
dev_Chns: 4, //设备通道数
check_Result: '未检', //检测结果
report_State: '未生成', //报告状态
document_State: '未归档', //归档状态
check_State:'未检',//检测状态
reCheck_Num: 0, //复检次数
},
{
id: '5', //装置序号ID
name: '240005', //设备名称
dev_Type: 'PQS-882A',//设备类型
dev_Chns: 1, //设备通道数
check_Result: '不符合', //检测结果
report_State: '未生成', //报告状态
document_State: '未归档', //归档状态
check_State:'检测完成',//检测状态
reCheck_Num: 1, //复检次数
},
{
id: '6', //装置序号ID
name: '240006', //设备名称
dev_Type: 'PQS-882B4',//设备类型
dev_Chns: 4, //设备通道数
check_Result: '不符合', //检测结果
report_State: '未生成', //报告状态
document_State: '未归档', //归档状态
check_State:'检测完成',//检测状态
reCheck_Num: 1, //复检次数
},
{
id: '7', //装置序号ID
name: '240007', //设备名称
dev_Type: 'PQS-882A',//设备类型
dev_Chns: 1, //设备通道数
check_Result: '符合', //检测结果
report_State: '未生成', //报告状态
document_State: '未归档', //归档状态
check_State:'检测完成',//检测状态
reCheck_Num: 1, //复检次数
},
{
id: '8', //装置序号ID
name: '240008', //设备名称
dev_Type: 'PQS-882B4',//设备类型
dev_Chns: 4, //设备通道数
check_Result: '符合', //检测结果
report_State: '未生成', //报告状态
document_State: '未归档', //归档状态
check_State:'检测完成',//检测状态
reCheck_Num: 1, //复检次数
},
{
id: '9', //装置序号ID
name: '240009', //设备名称
dev_Type: 'PQS-882B4',//设备类型
dev_Chns: 4, //设备通道数
check_Result: '不符合', //检测结果
report_State: '已生成', //报告状态
document_State: '未归档', //归档状态
check_State:'检测完成',//检测状态
reCheck_Num: 1, //复检次数
},
{
id: '10', //装置序号ID
name: '240010', //设备名称
dev_Type: 'PQS-882A',//设备类型
dev_Chns: 1, //设备通道数
check_Result: '符合', //检测结果
report_State: '已生成', //报告状态
document_State: '未归档', //归档状态
check_State:'检测完成',//检测状态
reCheck_Num: 2, //复检次数
},
{
id: '11', //装置序号ID
name: '240011', //设备名称
dev_Type: 'PQS-882A',//设备类型
dev_Chns: 1, //设备通道数
check_Result: '符合', //检测结果
report_State: '已生成', //报告状态
document_State: '已归档', //归档状态
check_State:'检测完成',//检测状态
reCheck_Num: 1, //复检次数
},
{
id: '12', //装置序号ID
name: '240012', //设备名称
dev_Type: 'PQS-882B4',//设备类型
dev_Chns: 4, //设备通道数
check_Result: '符合', //检测结果
report_State: '已生成', //报告状态
document_State: '已归档', //归档状态
check_State:'检测完成',//检测状态
reCheck_Num: 2, //复检次数
},
{
id: '13', //装置序号ID
name: '240013', //设备名称
dev_Type: 'PQS-882A',//设备类型
dev_Chns: 1, //设备通道数
check_Result: '未检', //检测结果
report_State: '未生成', //报告状态
document_State: '未归档', //归档状态
check_State:'未检',//检测状态
reCheck_Num: 0, //复检次数
},
{
id: '14', //装置序号ID
name: '240014', //设备名称
dev_Type: 'PQS-882A',//设备类型
dev_Chns: 1, //设备通道数
check_Result: '未检', //检测结果
report_State: '未生成', //报告状态
document_State: '未归档', //归档状态
check_State:'未检',//检测状态
reCheck_Num: 0, //复检次数
},
{
id: '15', //装置序号ID
name: '240015', //设备名称
dev_Type: 'PQS-882A',//设备类型
dev_Chns: 1, //设备通道数
check_Result: '未检', //检测结果
report_State: '未生成', //报告状态
document_State: '未归档', //归档状态
check_State:'未检',//检测状态
reCheck_Num: 0, //复检次数
},
{
id: '16', //装置序号ID
name: '240016', //设备名称
dev_Type: 'PQS-882A',//设备类型
dev_Chns: 1, //设备通道数
check_Result: '未检', //检测结果
report_State: '未生成', //报告状态
document_State: '未归档', //归档状态
check_State:'未检',//检测状态
reCheck_Num: 0, //复检次数
},
{
id: '17', //装置序号ID
name: '240017', //设备名称
dev_Type: 'PQS-882A',//设备类型
dev_Chns: 1, //设备通道数
check_Result: '未检', //检测结果
report_State: '未生成', //报告状态
document_State: '未归档', //归档状态
check_State:'未检',//检测状态
reCheck_Num: 0, //复检次数
},
{
id: '18', //装置序号ID
name: '240018', //设备名称
dev_Type: 'PQS-882A',//设备类型
dev_Chns: 1, //设备通道数
check_Result: '未检', //检测结果
report_State: '未生成', //报告状态
document_State: '未归档', //归档状态
check_State:'未检',//检测状态
reCheck_Num: 0, //复检次数
},
{
id: '19', //装置序号ID
name: '240019', //设备名称
dev_Type: 'PQS-882A',//设备类型
dev_Chns: 1, //设备通道数
check_Result: '未检', //检测结果
report_State: '未生成', //报告状态
document_State: '未归档', //归档状态
check_State:'未检',//检测状态
reCheck_Num: 0, //复检次数
},
{
id: '20', //装置序号ID
name: '240020', //设备名称
dev_Type: 'PQS-882A',//设备类型
dev_Chns: 1, //设备通道数
check_Result: '未检', //检测结果
report_State: '未生成', //报告状态
document_State: '未归档', //归档状态
check_State:'未检',//检测状态
reCheck_Num: 0, //复检次数
},
]
export default {data,plan_devicedata}

View File

@@ -2,43 +2,44 @@ import type { ReqPage, ResPage } from '@/api/interface'
// 检测源模块
export namespace TestSource {
/**
* 检测脚本表格分页查询参数
*/
export interface ReqTestSourceParams extends ReqPage{
id: string; // 装置序号id 必填
name: string;
pattern: string;
}
/**
* 检测源表格分页查询参数
*/
export interface ReqTestSourceParams extends ReqPage {
id: string
name: string
pattern: string
}
// 检测源接口
export interface ResTestSource {
id: string; //检测源ID
name?: string; //检测源名称(检测源类型 + 设备类型 + 数字自动生成)
pattern: string;//检测源模式(字典表Code字段数字、模拟、比对)
type: string; //检测源类型(字典表Code字段标准源、高精度设备)
devType: string;//检测源设备类型(字典表Code字段)
parameter?: string;//源参数JSON字符串
state:number;//
createBy?: string;
createTime?: string;
updateBy?: string;
updateTime?: string;
id: string
name?: string
pattern: string
type: string
devType: string
maxVoltage?: number
maxCurrent?: number
parameter?: string
state: number
createBy?: string
createTime?: string
updateBy?: string
updateTime?: string
}
/* 检测脚本查询分页返回的对象;
*/
export interface ResTestSourcePage extends ResPage<ResTestSource> {
}
export interface ParameterType{
id:string;
type:string;
desc:string;
value:string|null;
sort:number;
pId:string;
children?:ParameterType[];
/*
* 检测源查询分页返回的对象
*/
export interface ResTestSourcePage extends ResPage<ResTestSource> {}
export interface ParameterType {
id: string
type: string
desc: string
value: string | null
sort: number
pId: string
children?: ParameterType[]
}
}
}

View File

@@ -12,6 +12,12 @@ import { type ResultData } from '@/api/interface'
import { ResultEnum } from '@/enums/httpEnum'
import { checkStatus } from './helper/checkStatus'
import { useUserStore } from '@/stores/modules/user'
import { useDetectionLockStore, type DetectionLockHolder } from '@/stores/modules/detectionLock'
import {
showForceReleasedDialog,
showLockBusyDialog,
showLockNotStartedToast
} from '@/utils/detectionLockDialog'
import router from '@/routers'
import { refreshToken } from '@/api/user/login'
import { EventSourcePolyfill } from 'event-source-polyfill'
@@ -107,6 +113,32 @@ class RequestHttp {
}
return Promise.reject(data)
}
// 单用户检测互斥:命中 DETECTION_BUSY 时根据 data 和本地持锁状态分发到 4 种文案
if (data.code === ResultEnum.DETECTION_BUSY) {
const lockStore = useDetectionLockStore()
const holder = (data.data ?? null) as DetectionLockHolder | null
const currentUserId = userStore.userInfo?.id
const localDetecting = lockStore.iAmHolder
if (!localDetecting && holder) {
// S1:他人持锁
showLockBusyDialog(holder)
} else if (!localDetecting && !holder) {
// S2:未开始检测就调中间接口
showLockNotStartedToast()
} else if (localDetecting && holder && holder.holderUserId !== currentUserId) {
// S4-a:被强释 + 别人接手
showForceReleasedDialog(holder)
lockStore.clearHolder()
} else if (localDetecting && !holder) {
// S4-b:被强释,无人接手
showForceReleasedDialog(null)
lockStore.clearHolder()
}
// 阻断默认错误提示,不再走下面的 ElMessage.error
return Promise.reject(data)
}
// 全局错误信息拦截(防止下载文件的时候返回数据流,没有 code 直接报错)
if (data.code && data.code !== ResultEnum.SUCCESS) {
if (data.message.includes('&')) {

View File

@@ -69,5 +69,37 @@ export namespace Plan {
maxTime: number;
}
export interface PlanStatisticsItem {
itemId: string;
itemName: string;
unqualifiedCount: number;
}
export interface PlanStatisticsOption {
id: string;
name: string;
}
export interface PlanStatistics {
planId: string;
planName: string;
totalCheckCount: number;
checkedDeviceCount: number;
uncheckedDeviceCount: number;
firstQualifiedDeviceCount: number;
secondQualifiedDeviceCount: number;
thirdOrMoreQualifiedDeviceCount: number;
qualifiedDeviceCount: number;
unqualifiedDeviceCount: number;
unqualifiedItemCount: number;
firstPassRate: number;
secondPassRate: number;
thirdOrMorePassRate: number;
unqualifiedRate: number;
itemDistributions: PlanStatisticsItem[];
manufacturerOptions: PlanStatisticsOption[];
devTypeOptions: PlanStatisticsOption[];
}
}
}

View File

@@ -94,6 +94,10 @@ export const staticsAnalyse = (params: { id: string[] }) => {
return http.download('/adPlan/analyse', params)
}
export const getPlanStatistics = (params: { planId: string; manufacturer?: string; devType?: string }) => {
return http.post<Plan.PlanStatistics>(`/adPlan/statistics`, params)
}
//根据计划id分页查询被检设
export const getDevListByPlanId = (params: any) => {
return http.post(`/adPlan/listDevByPlanId`, params)
@@ -159,4 +163,4 @@ export const importAndMergePlanCheckData = (params: Plan.ResPlan) => {
return http.upload(`/adPlan/importAndMergePlanCheckData`, params, {
timeout: 60000 * 20
})
}
}

View File

@@ -0,0 +1,18 @@
import http from '@/api'
import type { ResourceManage } from '@/api/resourceManage/interface'
export const getResourceManageList = (params: ResourceManage.ReqResourceManageParams) => {
return http.post<ResourceManage.ResResourceManagePage>('/resourceManage/list', params)
}
export const addResourceManage = (params: FormData) => {
return http.upload('/resourceManage/add', params)
}
export const updateResourceManage = (params: ResourceManage.ReqUpdateResourceManage) => {
return http.post('/resourceManage/update', params)
}
export const getResourceManagePlayUrl = (id: string) => {
return http.get<ResourceManage.PlayVO>(`/resourceManage/play?id=${id}`)
}

View File

@@ -0,0 +1,34 @@
import type { ReqPage, ResPage } from '@/api/interface'
export namespace ResourceManage {
export interface ReqResourceManageParams extends ReqPage {
name?: string
fileName?: string
}
export interface ResResourceManage {
id: string
name: string
fileName: string
fileSize: number
relativePath: string
remark: string
state: number
createBy?: string | null
createTime?: string | null
updateBy?: string | null
updateTime?: string | null
}
export interface ResResourceManagePage extends ResPage<ResResourceManage> {}
export interface ReqUpdateResourceManage {
id: string
name: string
remark: string
}
export interface PlayVO {
url: string
}
}

View File

@@ -1,8 +1,12 @@
import http from '@/api'
import { useDetectionLockStore } from '@/stores/modules/detectionLock'
export const startPreTest = (params) => {
return http.post(`/prepare/startPreTest`, params, {loading: false})
export const startPreTest = async (params) => {
const result = await http.post(`/prepare/startPreTest`, params, {loading: false})
// 抢锁成功 → 标记本地为持锁者
useDetectionLockStore().setAsHolder()
return result
}
export const closePreTest = (params) => {
@@ -37,8 +41,11 @@ export const resumeTest = (params) => {
* 比对式通道配对
* @param params
*/
export const contrastTest = (params: any) => {
return http.post(`/prepare/startContrastTest`,params)
export const contrastTest = async (params: any) => {
const result = await http.post(`/prepare/startContrastTest`, params)
// 抢锁成功 → 标记本地为持锁者
useDetectionLockStore().setAsHolder()
return result
}
export const exportAlignData= () => {

View File

@@ -0,0 +1,19 @@
import http from '@/api'
export interface SntpTimeMessage {
type: string
deviceIp?: string
computerTime?: string
deviceTime?: string
computerTimestampMs?: number
deviceTimestampMs?: number
errorMs?: number
}
export const startSntpService = () => {
return http.post('/sntp/start', {})
}
export const stopSntpService = () => {
return http.post('/sntp/stop', {})
}

View File

@@ -6,6 +6,7 @@ export enum ResultEnum {
ERROR = 500,
ACCESSTOKEN_EXPIRED = "A0024",
OVERDUE = "A0025",
DETECTION_BUSY = "A020042",
TIMEOUT = 30000,
TYPE = "success"
}

View File

@@ -20,10 +20,11 @@
</template>
</el-dropdown>
<p style="margin: 0">
<a href="http://www.shining-electric.com/" target="_blank">2024 © 南京灿能电力自动化股份有限公司</a>
<a :href="companyWebsite" target="_blank" rel="noopener noreferrer">2024 © 南京灿能电力自动化股份有限公司</a>
</p>
</div>
</template>
<script lang="ts" setup>
import { computed } from 'vue'
import { useAuthStore } from '@/stores/modules/auth'
@@ -42,6 +43,8 @@ const title = computed(() => {
})
const activateInfo = authStore.activateInfo
const isActivateOpen = import.meta.env.VITE_ACTIVATE_OPEN
const companyWebsite = import.meta.env.VITE_COMPANY_WEBSITE
const modeList = [
{
name: '模拟式模块',
@@ -62,13 +65,14 @@ const modeList = [
activated: isActivateOpen === 'true' ? activateInfo.contrast.permanently === 1 : true
}
]
const handelOpen = async (item: string, key: string) => {
if (isActivateOpen === 'true' && activateInfo[key].permanently !== 1) {
ElMessage.warning(`${item}模块未激活`)
return
}
await authStore.setShowMenu()
modeStore.setCurrentMode(item) // 将模式code存入 store
modeStore.setCurrentMode(item) // 将模式 code 存入 store
// 强制刷新页面
await tabsStore.closeMultipleTab()
await initDynamicRouter()
@@ -80,11 +84,12 @@ const handelOpen = async (item: string, key: string) => {
// 如果已在目标页面,手动触发组件更新
window.location.reload() // 或者采用其他方式刷新数据
}
}
</script>
<style scoped lang="scss">
@use './index.scss';
.footer {
position: relative;
background-color: var(--el-color-primary);
@@ -101,30 +106,37 @@ const handelOpen = async (item: string, key: string) => {
height: 100%;
width: auto;
font-size: 14px;
.change_mode_down {
display: block;
}
.change_mode_up {
display: none;
}
}
.change_mode:hover {
.change_mode_down {
display: none;
}
.change_mode_up {
display: block;
}
}
.el-dropdown {
z-index: 1001;
}
p {
position: absolute;
width: 100%;
height: 100%;
text-align: right;
line-height: 40px;
a {
color: #fff;
margin-right: 25px; // 增加右边距

View File

@@ -19,3 +19,6 @@ export const DICT_STORE_KEY = "cn-dictData";
export const CHECK_STORE_KEY = "cn-check";
// pinia中detectionLock store的key
export const DETECTION_LOCK_STORE_KEY = "cn-detectionLock";

View File

@@ -7,75 +7,60 @@ import { useModeStore } from '@/stores/modules/mode'
import { getLicense } from '@/api/activate'
import type { Activate } from '@/api/activate/interface'
const CONTRAST_MODE_NAME = '比对式'
export const useAuthStore = defineStore(AUTH_STORE_KEY, {
state: (): AuthState => ({
// 按钮权限列表
authButtonList: {},
// 菜单权限列表
authMenuList: [],
// 当前页面的 router name用来做按钮权限筛选
routeName: '',
//登录不显示菜单栏和导航栏,点击进入测试的时候显示
showMenuFlag: JSON.parse(localStorage.getItem('showMenuFlag') as string),
activateInfo: {} as Activate.ActivationCodePlaintext
}),
getters: {
// 按钮权限列表
authButtonListGet: state => state.authButtonList,
// 菜单权限列表 ==> 这里的菜单没有经过任何处理
authMenuListGet: state => state.authMenuList,
// 菜单权限列表 ==> 左侧菜单栏渲染,需要剔除 isHide == true
showMenuListGet: state => getShowMenuList(state.authMenuList),
// 菜单权限列表 ==> 扁平化之后的一维数组菜单,主要用来添加动态路由
flatMenuListGet: state => getFlatMenuList(state.authMenuList),
// 递归处理后的所有面包屑导航列表
breadcrumbListGet: state => getAllBreadcrumbList(state.authMenuList),
//是否显示菜单和导航栏
showMenuFlagGet: state => state.showMenuFlag,
// 获取激活信息
activateInfoGet: state => state.activateInfo
},
actions: {
// Get AuthButtonList
async getAuthButtonList() {
const { data } = await getAuthButtonListApi()
this.authButtonList = data
},
// Get AuthMenuList
async getAuthMenuList() {
const modeStore = useModeStore()
const { data: menuData } = await getAuthMenuListApi()
// 根据不同模式过滤菜单
const filteredMenu =
modeStore.currentMode === '比对式'
? filterMenuByExcludedNames(menuData, ['testSource', 'testScript', 'controlSource'])
: filterMenuByExcludedNames(menuData, ['standardDevice'])
this.authMenuList = filteredMenu
const isContrastMode = modeStore.currentMode === CONTRAST_MODE_NAME
const filteredMenu = isContrastMode
? filterMenuByExcludedNames(menuData, ['testSource', 'testScript', 'controlSource'])
: filterMenuByExcludedNames(menuData, ['standardDevice'])
this.authMenuList = filterMenuByExcludedNames(filteredMenu, ['sntp'])
},
// Set RouteName
async setRouteName(name: string) {
this.routeName = name
},
//重置权限
async resetAuthStore() {
this.showMenuFlag = false
localStorage.removeItem('showMenuFlag')
},
//修改判断菜单栏/导航栏显示条件
async setShowMenu() {
this.showMenuFlag = true
localStorage.setItem('showMenuFlag', 'true')
},
//更改模式
changeModel() {
this.showMenuFlag = false
localStorage.removeItem('showMenuFlag')
},
async setActivateInfo() {
const license_result = await getLicense()
const licenseData = license_result.data as Activate.ActivationCodePlaintext
const licenseResult = await getLicense()
const licenseData = licenseResult.data as Activate.ActivationCodePlaintext
if (!licenseData.simulate) {
licenseData.simulate = {
permanently: 0
@@ -91,24 +76,18 @@ export const useAuthStore = defineStore(AUTH_STORE_KEY, {
permanently: 0
}
}
this.activateInfo = licenseData
}
}
})
/**
* 通用菜单过滤函数
* @param menuList 菜单列表
* @param excludedNames 需要排除的菜单名称数组
* @returns 过滤后的菜单列表
*/
function filterMenuByExcludedNames(menuList: any[], excludedNames: string[]): any[] {
function filterMenuByExcludedNames(menuList: Menu.MenuOptions[], excludedNames: string[]): Menu.MenuOptions[] {
return menuList.filter(menu => {
// 如果当前项有 children递归处理子项
if (menu.children && menu.children.length > 0) {
menu.children = filterMenuByExcludedNames(menu.children, excludedNames)
}
// 过滤掉在排除列表中的菜单项
return !excludedNames.includes(menu.name)
})
}

View File

@@ -0,0 +1,33 @@
import { defineStore } from 'pinia'
import { DETECTION_LOCK_STORE_KEY } from '@/stores/constant'
export interface DetectionLockHolder {
holderUserId: string
holderUserName: string
acquireTime: string
expireAt: string
}
export const useDetectionLockStore = defineStore(DETECTION_LOCK_STORE_KEY, {
state: () => ({
iAmHolder: false,
holder: null as DetectionLockHolder | null
}),
actions: {
setAsHolder(holder?: Partial<DetectionLockHolder> | null) {
this.iAmHolder = true
if (holder) {
this.holder = {
holderUserId: holder.holderUserId ?? '',
holderUserName: holder.holderUserName ?? '',
acquireTime: holder.acquireTime ?? '',
expireAt: holder.expireAt ?? ''
}
}
},
clearHolder() {
this.iAmHolder = false
this.holder = null
}
}
})

View File

@@ -27,7 +27,10 @@ declare interface ViteEnv {
VITE_PWA: boolean;
VITE_PUBLIC_PATH: string;
VITE_API_URL: string;
VITE_COMPANY_WEBSITE: string;
VITE_PROXY: [string, string][];
VITE_IS_SHOW_RAW_DATA:boolean;
VITE_ACTIVATE_OPEN:boolean;
}
interface ImportMetaEnv extends ViteEnv {

View File

@@ -0,0 +1,85 @@
import { ElMessage, ElMessageBox } from 'element-plus'
import router from '@/routers'
import type { DetectionLockHolder } from '@/stores/modules/detectionLock'
import mittBus, { STOP_DETECTION_TIMER_EVENT } from '@/utils/mittBus'
import { requestResourceManageAutoplayFirst } from '@/utils/resourceManageAutoplay'
const stopDetectionTimer = () => {
mittBus.emit(STOP_DETECTION_TIMER_EVENT)
}
const goResourceManage = async () => {
requestResourceManageAutoplayFirst()
if (router.hasRoute('resourceManage')) {
await router.push({ name: 'resourceManage' })
return
}
await router.push('/resourceManage')
}
/**
* S1: 他人正在做检测, 自己抢锁被挡
*/
export const showLockBusyDialog = (holder: DetectionLockHolder) => {
stopDetectionTimer()
ElMessageBox.confirm(`${holder.holderUserName}」正在做检测,请稍后。`, '检测进行中', {
confirmButtonText: '观看检测视频教学',
cancelButtonText: '我知道了',
type: 'warning',
distinguishCancelAndClose: true,
customClass: 'detection-lock-busy-dialog'
})
.then(() => {
return goResourceManage()
})
.catch(() => {
// 用户点了"我知道了"或关闭,什么都不做
})
}
/**
* S2: 未开始检测就调中间接口
*/
export const showLockNotStartedToast = () => {
ElMessage.warning('请先点击"开始检测"按钮启动本轮检测')
}
/**
* S3: 自己暂停超 10 分钟, 被 WS 推 STOP_TIMEOUT 强制结束
*/
export const showPauseTimeoutDialog = () => {
stopDetectionTimer()
ElMessageBox.alert('暂停超过 10 分钟未恢复,系统已自动结束本次检测。\n\n如需继续,请重新发起检测。', '本次检测已结束', {
confirmButtonText: '我知道了',
type: 'warning'
}).catch(() => {})
}
/**
* S4: 被管理员强制释放
* - holder 为 null: 强释后无人接手
* - holder 非 null: 强释后被别人立刻抢占
*/
export const showForceReleasedDialog = (holder: DetectionLockHolder | null) => {
stopDetectionTimer()
if (holder) {
ElMessageBox.confirm(`当前「${holder.holderUserName}」正在做检测,您无法继续检测,请稍后。`, '检测已被中止', {
confirmButtonText: '观看检测视频教学',
cancelButtonText: '我知道了',
type: 'warning',
distinguishCancelAndClose: true
})
.then(() => {
return goResourceManage()
})
.catch(() => {})
} else {
ElMessageBox.alert('您的检测已被管理员强制结束。\n如需继续,请重新发起检测。', '检测已被中止', {
confirmButtonText: '我知道了',
type: 'warning'
}).catch(() => {})
}
}

View File

@@ -1,4 +1,11 @@
import mitt from "mitt";
const mittBus = mitt();
export const STOP_DETECTION_TIMER_EVENT = "stopDetectionTimer";
type MittBusEvents = {
openThemeDrawer: undefined;
[STOP_DETECTION_TIMER_EVENT]: undefined;
};
const mittBus = mitt<MittBusEvents>();
export default mittBus;

View File

@@ -0,0 +1,13 @@
let shouldAutoplayFirstVideo = false
export const requestResourceManageAutoplayFirst = () => {
shouldAutoplayFirstVideo = true
}
export const hasPendingResourceManageAutoplayFirst = () => shouldAutoplayFirstVideo
export const consumeResourceManageAutoplayFirst = () => {
if (!shouldAutoplayFirstVideo) return false
shouldAutoplayFirstVideo = false
return true
}

View File

@@ -9,6 +9,8 @@
import { ElMessage } from "element-plus";
import { jwtUtil } from "./jwtUtil";
import { useDetectionLockStore } from "@/stores/modules/detectionLock";
import { showPauseTimeoutDialog } from "@/utils/detectionLockDialog";
// ============================================================================
// 类型定义 (Types & Interfaces)
@@ -190,8 +192,7 @@ export default class SocketService {
* WebSocket连接配置
*/
private config: SocketConfig = {
url: 'ws://127.0.0.1:7778/hello',
//url: 'ws://192.168.1.124:7777/hello',
url: `ws://127.0.0.1:7778/hello`,
heartbeatInterval: 9000, // 9秒心跳间隔
reconnectDelay: 5000, // 5秒重连延迟
maxReconnectAttempts: 5, // 最多重连5次
@@ -546,6 +547,18 @@ export default class SocketService {
// 检查是否为JSON格式
if (typeof event.data === 'string' && (event.data.startsWith('{') || event.data.startsWith('['))) {
const message: WebSocketMessage = JSON.parse(event.data);
// 全局拦截:暂停 10 分钟超时,后端推 STOP_TIMEOUT 表示锁已被释放
// 不管页面是否注册了对应回调,都要做"清本地持锁标记 + 弹窗告知"
if (message?.operateCode === 'STOP_TIMEOUT') {
try {
useDetectionLockStore().clearHolder();
showPauseTimeoutDialog();
} catch (e) {
console.error('STOP_TIMEOUT 全局处理失败:', e);
}
}
if (message?.type && this.callBackMapping[message.type]) {
this.callBackMapping[message.type](message);
} else {

View File

@@ -18,7 +18,7 @@
<template #operation='scope'>
<el-button v-auth.role="'edit'" type='primary' link :icon='EditPen' @click="openDrawer('edit', scope.row)" :disabled="scope.row.code == 'root'">编辑</el-button>
<el-button v-auth.role="'delete'" type='primary' link :icon='Delete' @click='deleteAccount(scope.row)' :disabled="scope.row.code == 'root'">删除</el-button>
<el-button v-auth.role="'SetPermissions'" type='primary' link :icon='Share' @click="openDrawer('设置权限', scope.row)" :disabled="scope.row.code == 'root'">设置权限</el-button>
<el-button v-auth.role="'SetPermissions'" type='primary' link :icon='Share' @click="openDrawer('设置权限', scope.row)" >设置权限</el-button>
</template>
</ProTable>

View File

@@ -122,7 +122,8 @@
<script lang="tsx" setup name="test">
import {InfoFilled, Loading} from '@element-plus/icons-vue'
import CompareDataCheckSingleChannelSingleTestPopup from './compareDataCheckSingleChannelSingleTestPopup.vue'
import {computed, ComputedRef, nextTick, onBeforeMount, onMounted, reactive, ref, toRef, watch} from 'vue'
import {computed, nextTick, onBeforeMount, onBeforeUnmount, onMounted, reactive, ref, toRef, watch} from 'vue'
import type { ComputedRef } from 'vue'
import {dialogBig} from '@/utils/elementBind'
import {CheckData} from '@/api/check/interface'
import {useCheckStore} from '@/stores/modules/check'
@@ -132,6 +133,7 @@ import {getAutoGenerate, getCanCoefficient, startCoefficient} from '@/api/user/l
import { generateDevReport } from '@/api/plan/plan'
import {useModeStore} from '@/stores/modules/mode' // 引入模式 store
import {useDictStore} from '@/stores/modules/dict'
import mittBus, { STOP_DETECTION_TIMER_EVENT } from '@/utils/mittBus'
const checkStore = useCheckStore()
const modeStore = useModeStore()
const dictStore = useDictStore()
@@ -740,6 +742,10 @@ const stopTimeCount = (type: number) => {
}
}
const handleStopDetectionTimer = () => {
stopTimeCount(1)
}
// 将秒数转换为 HH:MM:SS 格式
const secondToTime = (second: number) => {
let h: string | number = Math.floor(second / 3600) // 小时
@@ -898,6 +904,7 @@ const initializeParameters = async () => {
//
onMounted(() => {
mittBus.on(STOP_DETECTION_TIMER_EVENT, handleStopDetectionTimer)
if (!checkStore.selectTestItems.preTest) {
// 判断是否预检测
@@ -905,6 +912,10 @@ onMounted(() => {
}
})
onBeforeUnmount(() => {
mittBus.off(STOP_DETECTION_TIMER_EVENT, handleStopDetectionTimer)
})
defineExpose({
initializeParameters,
handlePause,

View File

@@ -148,6 +148,7 @@ import { useCheckStore } from '@/stores/modules/check'
import { contrastTest, pauseTest, resumeTest, startPreTest } from '@/api/socket/socket'
import { useUserStore } from '@/stores/modules/user'
import { JwtUtil } from '@/utils/jwtUtil'
import mittBus, { STOP_DETECTION_TIMER_EVENT } from '@/utils/mittBus'
const userStore = useUserStore()
const checkStore = useCheckStore()
@@ -165,6 +166,14 @@ const preTestStatus = ref('waiting') //预检测执行状态
const TestStatus = ref('waiting') //正式检测执行状态
const webMsgSend = ref() //webSocket推送的数据
const hideInitializingButton = () => {
if (TestStatus.value === 'test_init') {
TestStatus.value = 'waiting'
}
}
mittBus.on(STOP_DETECTION_TIMER_EVENT, hideInitializingButton)
const dialogTitle = ref('')
const showComponent = ref(true)
const preTestRef = ref<InstanceType<typeof ComparePreTest> | null>(null)
@@ -187,6 +196,7 @@ onMounted(() => {
})
onUnmounted(() => {
mittBus.off(STOP_DETECTION_TIMER_EVENT, hideInitializingButton)
window.removeEventListener('resize', handleResize)
})

View File

@@ -206,6 +206,23 @@ function handleWarningError(stepRef: any, logRef: any, message: string) {
watch(webMsgSend, function (newValue, oldValue) {
if (testStatus.value !== 'waiting') {
switch (newValue.requestId) {
case 'overloadTest':
if (newValue.code === 1) {
handleFatalError(step1, step1InitLog, '电压过载!')
}
if (newValue.code === 2) {
handleFatalError(step1, step1InitLog, '电流过载!')
}
if (newValue.code === 3) {
handleFatalError(step1, step1InitLog, '电压和电流过载!')
}
if (newValue.code === 4) {
step1InitLog.value.push({
type: 'info',
log: '过载测试成功!',
})
}
break;
case 'yjc_ytxjy':
switch (newValue.operateCode) {
case 'INIT_GATHER':

View File

@@ -91,7 +91,7 @@
type="primary"
icon="Clock"
@click="handleTest('手动检测')"
v-if="form.activeTabs === 0 && modeStore.currentMode == '模拟式'"
v-if="form.activeTabs === 0 && modeStore.currentMode != '比对式'"
>
手动检测
</el-button>
@@ -483,7 +483,7 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
sortable: true,
isShow: checkStateShow,
render: scope => {
return scope.row.checkState === 0 ? '未检' : scope.row.checkState === 1 ? '检测中' : '检测完成'
return scope.row.checkState === 0 ? '未检' : scope.row.checkState === 1 ? '检测中' : scope.row.checkState === 2 ? '检测完成':'归档'
}
},
{
@@ -494,10 +494,12 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
render: scope => {
if (scope.row.checkResult === 0) {
return <el-tag type="danger">不符合</el-tag>
} else if (scope.row.checkResult === 0) {
return '不符合'
} else if (scope.row.checkResult === 1) {
return '符合'
} else if (scope.row.checkResult === 2) {
return '未检'
}else if(scope.row.checkResult === 2) {
return '未检'
}
return ''
}
@@ -539,7 +541,6 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
{ prop: 'operation', label: '操作', fixed: 'right', minWidth :200,isShow: operationShow }
])
let testType = 'test' // 检测类型:'test'-检测 'reTest'-复检
let qualifiedCount = 0 //合格数量
//比对单个报告生成
@@ -575,8 +576,6 @@ const handleSelectionChange = (selection: any[]) => {
} else {
testType = 'reTest'
}
qualifiedCount=selection.filter(item => item.checkResult == 1).length
let devices: CheckData.Device[] = selection.map((item: any) => {
return {
deviceId: item.id,
@@ -599,6 +598,19 @@ const handleSelectionChange = (selection: any[]) => {
}
}
const isUncheckedDevice = (device: Device.ResPqDev) => Number(device.checkState) === 0 || Number(device.checkResult) === 2
const hasCheckedSelectedDevice = () => channelsSelection.value.some(device => !isUncheckedDevice(device))
const hasUncheckedSelectedDevice = () => channelsSelection.value.some(device => isUncheckedDevice(device))
const hasCheckedUnqualifiedSelectedDevice = () =>
channelsSelection.value.some(device => !isUncheckedDevice(device) && Number(device.checkResult) === 0)
const shouldShowRecheckModeDialog = () => hasCheckedSelectedDevice()
const canUseUnqualifiedItemRecheck = () => hasCheckedUnqualifiedSelectedDevice() && !hasUncheckedSelectedDevice()
//查询
const handleSearch = () => {
proTable.value?.getTableList()
@@ -923,12 +935,12 @@ const handleTest = async (val: string) => {
dialogTitle.value = val
if (val === '手动检测') {
checkStore.setShowDetailType(2)
if (testType === 'reTest') {
if (shouldShowRecheckModeDialog()) {
ElMessageBox.confirm('请选择复检检测方式', '设备复检', {
distinguishCancelAndClose: true,
confirmButtonText: '不合格项复检',
cancelButtonText: '全部复检',
showConfirmButton:qualifiedCount<=0,
showConfirmButton: canUseUnqualifiedItemRecheck(),
type: 'warning'
})
.then(() => {
@@ -963,11 +975,12 @@ const handleTest = async (val: string) => {
checkStore.setCheckType(1)
checkStore.initSelectTestItems()
// 一键检测
if (testType === 'reTest' && modeStore.currentMode != '比对式') {
if (shouldShowRecheckModeDialog() && modeStore.currentMode != '比对式') {
ElMessageBox.confirm('请选择复检检测方式', '设备复检', {
distinguishCancelAndClose: true,
confirmButtonText: '不合格项复检',
cancelButtonText: '全部复检',
showConfirmButton: canUseUnqualifiedItemRecheck(),
type: 'warning'
})
.then(() => {
@@ -1087,7 +1100,7 @@ const openDrawer = async (title: string, row: any) => {
if (title === '检测数据查询') {
checkStore.setShowDetailType(0)
if (modeStore.currentMode == '模拟式') {
if (modeStore.currentMode == '模拟式'||modeStore.currentMode == '数字式') {
dataCheckPopupRef.value?.open(row.id, '-1', null)
} else if (modeStore.currentMode == '比对式') {
dataCheckSingleChannelSingleTestPopupRef.value?.open(row, null, row.id, 2)
@@ -1095,7 +1108,7 @@ const openDrawer = async (title: string, row: any) => {
}
if (title === '误差体系更换') {
checkStore.setShowDetailType(1)
if (modeStore.currentMode == '模拟式') {
if (modeStore.currentMode == '模拟式'||modeStore.currentMode == '数字式') {
dataCheckPopupRef.value?.open(row.id, '-1', null)
} else if (modeStore.currentMode == '比对式') {
dataCheckSingleChannelSingleTestPopupRef.value?.open(row, null, row.id, 2)

View File

@@ -105,7 +105,7 @@ import { InfoFilled, Loading } from '@element-plus/icons-vue'
// 单通道单测试项详情弹窗组件
import dataCheckSingleChannelSingleTestPopup from './dataCheckSingleChannelSingleTestPopup.vue'
// Vue 3 Composition API
import { computed, reactive, ref, toRef, watch } from 'vue'
import { computed, onBeforeUnmount, onMounted, reactive, ref, toRef, watch } from 'vue'
// 对话框大小绑定工具
import { dialogBig } from '@/utils/elementBind'
// 检测数据类型定义
@@ -120,6 +120,7 @@ import { getAutoGenerate } from '@/api/user/login'
import { generateDevReport } from '@/api/plan/plan'
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
import { useDictStore } from '@/stores/modules/dict'
import mittBus, { STOP_DETECTION_TIMER_EVENT } from '@/utils/mittBus'
// 获取检测状态管理实例
const checkStore = useCheckStore()
@@ -1176,6 +1177,10 @@ const stopTimeCount = () => {
}
}
const handleStopDetectionTimer = () => {
stopTimeCount()
}
// 恢复计时(用于暂停后继续)
const resumeTimeCount = () => {
@@ -1199,8 +1204,14 @@ const secondToTime = (second: number) => {
return h + ':' + m + ':' + s
}
onMounted(() => {
mittBus.on(STOP_DETECTION_TIMER_EVENT, handleStopDetectionTimer)
})
// 组件卸载前清理定时器和响应式引用
onBeforeUnmount(() => {
mittBus.off(STOP_DETECTION_TIMER_EVENT, handleStopDetectionTimer)
// 清理定时器
if (timer) {
clearInterval(timer)

View File

@@ -172,6 +172,7 @@ import { useCheckStore } from '@/stores/modules/check'
import { pauseTest, resumeTest, startPreTest } from '@/api/socket/socket'
import { useUserStore } from '@/stores/modules/user'
import { JwtUtil } from '@/utils/jwtUtil'
import mittBus, { STOP_DETECTION_TIMER_EVENT } from '@/utils/mittBus'
// ====================== 状态管理 ======================
const userStore = useUserStore()
@@ -200,6 +201,14 @@ const channelsTestStatus = ref('waiting') // 通道系数校准执行状态
const TestStatus = ref('waiting') // 正式检测执行状态
const webMsgSend = ref() // webSocket推送的数据用于组件间通信
const hideInitializingButton = () => {
if (TestStatus.value === 'test_init') {
TestStatus.value = 'waiting'
}
}
mittBus.on(STOP_DETECTION_TIMER_EVENT, hideInitializingButton)
// ====================== WebSocket 相关 ======================
const dataSocket = reactive<{
socketServe: typeof socketClient.Instance | null
@@ -705,6 +714,7 @@ const handleClose = () => {
* 确保路由切换或组件销毁时正确关闭WebSocket连接
*/
onBeforeUnmount(() => {
mittBus.off(STOP_DETECTION_TIMER_EVENT, hideInitializingButton)
closeWebSocket() // 组件销毁前关闭WebSocket连接
})
@@ -767,4 +777,4 @@ defineExpose({ open }) // 只暴露open方法供父组件调用
transform: rotate(360deg);
}
}
</style>
</style>

View File

@@ -29,7 +29,7 @@
@node-click="handleNodeClick"
>
<template #default="{ node, data }">
<span class="custom-tree-node" style="display: flex; align-items: center;">
<span class="custom-tree-node">
<!-- 父节点图标 -->
<Platform
v-if="!data.pid"
@@ -39,56 +39,59 @@
}"
/>
<!-- 节点名称 -->
<span>{{ node.label }}</span>
<!-- 子节点右侧图标 + tooltip -->
<el-tooltip
v-if="
node.label != '未检' &&
node.label != '检测中' &&
node.label != '检测完成' &&
hasChildrenInPlanTable(node.data)
"
placement="top"
:manual="true"
content="子计划信息"
>
<List
@click.stop="childDetail(node.data)"
style="
width: 16px;
height: 16px;
margin-left: 8px;
cursor: pointer;
color: var(--el-color-primary);
"
<span class="node-label">{{ node.label }}</span>
<span class="node-actions">
<PieChart
v-if="!isCompareMode && isCompletedPlanNode(node.data)"
class="node-action-icon"
@click.stop="openStatistics(node.data)"
style="margin-right: 8px"
/>
</el-tooltip>
<!-- 子节点右侧图标 + tooltip -->
<el-tooltip
v-if="
node.label != '未检' &&
node.label != '检测中' &&
node.label != '检测完成' &&
hasChildrenInPlanTable(node.data)
"
placement="top"
:manual="true"
content="子计划信息"
>
<List class="node-action-icon" @click.stop="childDetail(node.data)" />
</el-tooltip>
</span>
</span>
</template>
</el-tree>
</div>
</div>
<SourceOpen ref="openSourceView" :width="width" :height="height + 175"></SourceOpen>
<PlanStatisticsPopup ref="planStatisticsPopupRef" />
</template>
<script lang="ts" setup>
import { type Plan } from '@/api/plan/interface'
import { List, Menu, Platform } from '@element-plus/icons-vue'
import { nextTick, onMounted, ref, watch } from 'vue'
import { List, Menu, PieChart, Platform } from '@element-plus/icons-vue'
import { computed, nextTick, onMounted, ref, watch } from 'vue'
import { useRouter } from 'vue-router'
import { useCheckStore } from '@/stores/modules/check'
import { ElTooltip } from 'element-plus'
import SourceOpen from '@/views/plan/planList/components/childrenPlan.vue'
import PlanStatisticsPopup from '@/views/plan/planList/components/planStatisticsPopup.vue'
import { getPlanList } from '@/api/plan/plan.ts'
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
import { useDictStore } from '@/stores/modules/dict'
const openSourceView = ref()
const planStatisticsPopupRef = ref<InstanceType<typeof PlanStatisticsPopup> | null>(null)
const router = useRouter()
const checkStore = useCheckStore()
const filterText = ref('')
const treeRef = ref()
const data: any = ref([])
const modeStore = useModeStore()
const isCompareMode = computed(() => modeStore.currentMode === '比对式')
const dictStore = useDictStore()
const defaultProps = {
@@ -211,6 +214,14 @@ const childDetail = (data: Plan.ResPlan) => {
}
}
const isCompletedPlanNode = (data: Partial<Plan.ResPlan>) => {
return [1, 2].includes(Number(data.testState))
}
const openStatistics = (data: Partial<Plan.ResPlan>) => {
planStatisticsPopupRef.value?.open(data)
}
function buildTree(flatList: any[]): any[] {
const map = new Map()
const tree: any[] = []
@@ -293,6 +304,40 @@ defineExpose({ getTreeData, clickTableToTree })
margin-top: 12px;
}
:deep(.el-tree-node__content) {
padding-right: 6px;
}
.custom-tree-node {
display: flex;
align-items: center;
width: 100%;
min-width: 0;
}
.node-label {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.node-actions {
flex: none;
display: inline-flex;
align-items: center;
gap: 8px;
margin-left: 8px;
}
.node-action-icon {
width: 16px;
height: 16px;
cursor: pointer;
color: var(--el-color-primary);
}
//.filter-tree span {
// font-size: 16px;
// display:block;

View File

@@ -464,9 +464,11 @@ const getPieData = async (id: string) => {
planName.value = '所选计划:'
}
pieRef1.value.init()
pieRef2.value.init()
pieRef3.value.init()
if (pieRef1.value && pieRef2.value && pieRef3.value) {
pieRef1.value.init()
pieRef2.value.init()
pieRef3.value.init()
}
}
/**
* 初始化树组件数据

View File

@@ -0,0 +1,10 @@
export interface FlickerData {
flickerValue: string | null
fchagFre: string
fchagValue: string
waveType: string
waveFluType: string
fdutyCycle: number
}
export function normalizeFlickerData(flickerData: Partial<FlickerData> | null | undefined): FlickerData

View File

@@ -0,0 +1,27 @@
const DEFAULT_WAVE_TYPE = 'CPM'
const DEFAULT_WAVE_FLU_TYPE = 'SQU'
const DEFAULT_DUTY_CYCLE = 50
export function normalizeFlickerData(flickerData) {
const normalized = {
flickerValue: flickerData?.flickerValue ?? null,
fchagFre: flickerData?.fchagFre ?? '',
fchagValue: flickerData?.fchagValue ?? '',
waveType: flickerData?.waveType ?? DEFAULT_WAVE_TYPE,
waveFluType: flickerData?.waveFluType ?? DEFAULT_WAVE_FLU_TYPE,
fdutyCycle: flickerData?.fdutyCycle ?? DEFAULT_DUTY_CYCLE
}
const isBackendEmptyState =
normalized.flickerValue == null &&
normalized.fchagFre === '1' &&
normalized.fchagValue === '2.724'
if (isBackendEmptyState) {
normalized.fchagFre = ''
normalized.fchagValue = ''
}
return normalized
}

View File

@@ -228,7 +228,7 @@ const unit = [
},
{
label: '功率',
unit: 'W'
unit: props.valueCode == 'Absolute' ? 'W' : '%Un*In'
},
{
label: '电压偏差',

View File

@@ -80,7 +80,8 @@
</template>
<script setup lang="ts">
import { onMounted, ref, computed } from 'vue'
import { computed, watch } from 'vue'
import { normalizeFlickerData } from './flickerData.js'
const props = defineProps({
childForm: {
type: [Array, Object] as any,
@@ -359,16 +360,21 @@ const changeWaveType = e => {
}
const form: any = computed({
get() {
if (props.childForm[0].flickerData.flickerValue == null) {
props.childForm[0].flickerData.fchagValue = ''
props.childForm[0].flickerData.fchagFre = ''
}
return props.childForm
},
set(value) {}
})
onMounted(() => {})
watch(
() => props.childForm[0],
channel => {
if (!channel) {
return
}
channel.flickerData = normalizeFlickerData(channel.flickerData)
},
{ immediate: true }
)
</script>
<style scoped>

View File

@@ -10,7 +10,7 @@
class="form-three"
>
<el-form-item label="设备类型" prop="devType">
<el-select v-model="formContent.devType" placeholder="请选择源型">
<el-select v-model="formContent.devType" placeholder="请选择源设备类型">
<el-option
v-for="item in dictStore.getDictData(dictTypeCode)"
:key="item.id"
@@ -29,6 +29,24 @@
/>
</el-select>
</el-form-item>
<el-form-item label="最大电压" prop="maxVoltage">
<el-input-number
v-model="formContent.maxVoltage"
:min="0"
:precision="2"
:step="0.1"
style="width: 100%"
/>
</el-form-item>
<el-form-item label="最大电流" prop="maxCurrent">
<el-input-number
v-model="formContent.maxCurrent"
:min="0"
:precision="2"
:step="0.1"
style="width: 100%"
/>
</el-form-item>
</el-form>
</div>
@@ -40,7 +58,7 @@
/>
<template #footer>
<div>
<el-button :disabled="tableIsDisable" @click="close()"> </el-button>
<el-button :disabled="tableIsDisable" @click="close()">取消</el-button>
<el-button :disabled="tableIsDisable" type="primary" @click="save()">保存</el-button>
</div>
</template>
@@ -49,12 +67,12 @@
<script lang="ts" setup name="ErrorSystemDialog">
import { ElMessage, type FormItemRule } from 'element-plus'
import { computed, Ref, ref } from 'vue'
import { computed, ref, type Ref } from 'vue'
import { dialogBig } from '@/utils/elementBind'
import { addTestSource, getTestSourceById, updateTestSource } from '@/api/device/testSource/index'
import { useDictStore } from '@/stores/modules/dict'
import { type TestSource } from '@/api/device/interface/testSource'
// 定义弹出组件元信息
import { useDictStore } from '@/stores/modules/dict'
const dialogFormRef = ref()
const dictStore = useDictStore()
const mode = ref()
@@ -71,13 +89,15 @@ function useMetaInfo() {
parameter: '',
type: '',
devType: '',
maxVoltage: undefined,
maxCurrent: undefined,
state: 1
})
return { dialogVisible, titleType, formContent }
}
const { dialogVisible, titleType, formContent } = useMetaInfo()
// 清空formContent
const resetFormContent = () => {
formContent.value = {
id: '',
@@ -85,11 +105,13 @@ const resetFormContent = () => {
parameter: '',
type: '',
devType: '',
maxVoltage: undefined,
maxCurrent: undefined,
state: 1
}
}
let dialogTitle = computed(() => {
const dialogTitle = computed(() => {
switch (titleType.value) {
case 'add':
tableIsDisable.value = false
@@ -101,45 +123,52 @@ let dialogTitle = computed(() => {
tableIsDisable.value = true
return '查看检测源'
default:
return '' // 默认情况,可选
return ''
}
})
let dictTypeCode = computed(() => {
const dictTypeCode = computed(() => {
return 'S_Dev_Type_' + dictStore.getDictData('Pattern').find(item => item.id === modeId.value)?.code
})
// 定义规则
const validateNonNegative = (label: string) => {
return (_rule: FormItemRule, value: number | undefined, callback: (error?: Error) => void) => {
if (value != null && value < 0) {
callback(new Error(`${label} cannot be negative`))
return
}
callback()
}
}
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
name: [{ required: true, message: '检测源名称必填', trigger: 'blur' }],
name: [{ required: true, message: '检测源名称必填', trigger: 'blur' }],
devType: [{ required: true, message: '请选择一项设备类型', trigger: 'change' }],
type: [{ required: true, message: '请选择一项检测源类型', trigger: 'change ' }]
type: [{ required: true, message: '请选择一项检测源类型', trigger: 'change' }],
maxVoltage: [{ validator: validateNonNegative('最大电压'), trigger: 'change' }],
maxCurrent: [{ validator: validateNonNegative('最大电流'), trigger: 'change' }]
})
// 关闭弹窗
const close = () => {
dialogVisible.value = false
// 清空dialogForm中的值
resetFormContent()
// 重置表单
dialogFormRef.value?.resetFields()
parameterTable.value?.clearData()
}
// 保存数据
const save = () => {
try {
dialogFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
if (formContent.value.id) {
await updateTestSource(formContent.value)
ElMessage.success({ message: `${dialogTitle.value}成功` })
ElMessage.success({ message: `${dialogTitle.value}成功` })
} else {
await addTestSource(formContent.value)
ElMessage.success({ message: `${dialogTitle.value}成功` })
ElMessage.success({ message: `${dialogTitle.value}成功` })
}
close()
// 刷新表格
await props.refreshTable!()
await props.refreshTable?.()
}
})
} catch (err) {
@@ -147,7 +176,6 @@ const save = () => {
}
}
// 打开弹窗,可能是新增,也可能是编辑
const open = async (sign: string, data: TestSource.ResTestSource, currentMode: string) => {
titleType.value = sign
dialogVisible.value = true
@@ -155,13 +183,25 @@ const open = async (sign: string, data: TestSource.ResTestSource, currentMode: s
modeId.value = dictStore.getDictData('Pattern').find(item => item.name === currentMode)?.id
if (data.id) {
const result = await getTestSourceById(data)
if (result && result.data) {
formContent.value = result.data as TestSource.ResTestSource
const sourceData = (result?.data ?? {}) as Partial<TestSource.ResTestSource>
formContent.value = {
id: sourceData.id ?? data.id,
pattern: sourceData.pattern ?? modeId.value,
parameter: sourceData.parameter ?? '',
type: sourceData.type ?? '',
devType: sourceData.devType ?? '',
maxVoltage: sourceData.maxVoltage ?? undefined,
maxCurrent: sourceData.maxCurrent ?? undefined,
state: sourceData.state ?? 1,
name: sourceData.name,
createBy: sourceData.createBy,
createTime: sourceData.createTime,
updateBy: sourceData.updateBy,
updateTime: sourceData.updateTime
}
} else {
resetFormContent()
}
// 重置表单
dialogFormRef.value?.resetFields()
}
@@ -169,7 +209,6 @@ const changeParameter = (parameterArr: any) => {
formContent.value.parameter = JSON.stringify(parameterArr)
}
// 对外映射
defineExpose({ open })
const props = defineProps<{
refreshTable: (() => Promise<void>) | undefined

View File

@@ -1,115 +1,123 @@
<template>
<div class='table-box'>
<ProTable
ref='proTable'
:columns='columns'
:request-api="getTableList"
>
<!-- :data='testSourceData' 如果要显示静态数据就切换该配置-->
<!-- 表格 header 按钮 -->
<template #tableHeader='scope'>
<el-button v-auth.testSource="'add'" type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
<el-button v-auth.testSource="'delete'" type='danger' :icon='Delete'
plain :disabled='!scope.isSelected' @click='batchDelete(scope.selectedListIds)'>
删除
</el-button>
</template>
<!-- 表格操作 -->
<template #operation='scope'>
<el-button v-auth.testSource="'view'" type='primary' link :icon='View' @click="openDialog('view', scope.row)">查看</el-button>
<el-button v-auth.testSource="'edit'" type='primary' link :icon='EditPen' @click="openDialog('edit', scope.row)">编辑</el-button>
<el-button v-auth.testSource="'delete'" type='primary' link :icon='Delete' @click='handleDelete(scope.row)'>删除</el-button>
</template>
</ProTable>
<div class="table-box">
<ProTable ref="proTable" :columns="columns" :request-api="getTableList">
<template #tableHeader="scope">
<el-button v-auth.testSource="'add'" type="primary" :icon="CirclePlus" @click="openDialog('add')">
新增
</el-button>
<el-button
v-auth.testSource="'delete'"
type="danger"
:icon="Delete"
plain
:disabled="!scope.isSelected"
@click="batchDelete(scope.selectedListIds)"
>
删除
</el-button>
</template>
<template #operation="scope">
<el-button v-auth.testSource="'view'" type="primary" link :icon="View" @click="openDialog('view', scope.row)">
查看
</el-button>
<el-button v-auth.testSource="'edit'" type="primary" link :icon="EditPen" @click="openDialog('edit', scope.row)">
编辑
</el-button>
<el-button
v-auth.testSource="'delete'"
type="primary"
link
:icon="Delete"
@click="handleDelete(scope.row)"
>
删除
</el-button>
</template>
</ProTable>
</div>
<TestSourcePopup :refresh-table='proTable?.getTableList' ref='testSourcePopup' />
<TestSourcePopup :refresh-table="proTable?.getTableList" ref="testSourcePopup" />
</template>
</template>
<script setup lang='tsx' name='useRole'>
import { type TestSource } from '@/api/device/interface/testSource'
import { useHandleData } from '@/hooks/useHandleData'
import { useDownload } from '@/hooks/useDownload'
import { useAuthButtons } from '@/hooks/useAuthButtons'
import ProTable from '@/components/ProTable/index.vue'
import ImportExcel from '@/components/ImportExcel/index.vue'
import type{ ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
import { CirclePlus, Delete, EditPen, Share, Download, Upload, View, Refresh } from '@element-plus/icons-vue'
import { useDictStore } from '@/stores/modules/dict'
import TestSourcePopup from './components/testSourcePopup.vue'
import {
getTestSourceList,deleteTestSource,
} from '@/api/device/testSource/index'
import { reactive, ref } from 'vue'
import { useModeStore } from '@/stores/modules/mode'; // 引入模式 store
defineOptions({
name: 'testSource'
})
const testSourcePopup = ref()
const dictStore = useDictStore()
const modeStore = useModeStore();
// ProTable 实例
const proTable = ref<ProTableInstance>()
const getTableList = (params: any) => {
<script setup lang="tsx" name="useRole">
import { type TestSource } from '@/api/device/interface/testSource'
import { useHandleData } from '@/hooks/useHandleData'
import ProTable from '@/components/ProTable/index.vue'
import type { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
import { CirclePlus, Delete, EditPen, View } from '@element-plus/icons-vue'
import { useDictStore } from '@/stores/modules/dict'
import TestSourcePopup from './components/testSourcePopup.vue'
import { getTestSourceList, deleteTestSource } from '@/api/device/testSource/index'
import { reactive, ref } from 'vue'
import { useModeStore } from '@/stores/modules/mode'
let newParams = JSON.parse(JSON.stringify(params))
const patternId = dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id//获取数据字典中对应的id
newParams.pattern = patternId
return getTestSourceList(newParams)
defineOptions({
name: 'testSource'
})
const testSourcePopup = ref()
const dictStore = useDictStore()
const modeStore = useModeStore()
const proTable = ref<ProTableInstance>()
const getTableList = (params: any) => {
const newParams = JSON.parse(JSON.stringify(params))
const patternId = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id
newParams.pattern = patternId
return getTestSourceList(newParams)
}
// 表格配置项
const columns = reactive<ColumnProps<TestSource.ResTestSource>[]>([
{ type: 'selection', fixed: 'left', width: 70 ,
},
const columns = reactive<ColumnProps<TestSource.ResTestSource>[]>([
{ type: 'selection', fixed: 'left', width: 70 },
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
{
prop: 'name',
label: '名称',
search: { el: 'input' },
minWidth: 300,
prop: 'name',
label: '名称',
search: { el: 'input' },
minWidth: 300
},
{
prop: 'devType',
label: '设备类型',
enum: dictStore.getDictData('S_Dev_Type_'+dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.code),
fieldNames: { label: 'name', value: 'id' },
search: { el: 'select' },
minWidth: 250,
prop: 'devType',
label: '设备类型',
enum: dictStore.getDictData(
'S_Dev_Type_' + dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.code
),
fieldNames: { label: 'name', value: 'id' },
search: { el: 'select' },
minWidth: 250
},
{
prop: 'type',
label: '检测源类型',
enum: dictStore.getDictData('Pq_Source_Type'),
fieldNames: { label: 'name', value: 'id' },
search: { el: 'select' },
minWidth: 150,
prop: 'type',
label: '检测源类型',
enum: dictStore.getDictData('Pq_Source_Type'),
fieldNames: { label: 'name', value: 'id' },
search: { el: 'select' },
minWidth: 150
},
{ prop: 'operation', label: '操作', fixed: 'right', width: 250 },
])
{
prop: 'maxVoltage',
label: '最大电压(V)',
minWidth: 140
},
{
prop: 'maxCurrent',
label: '最大电流(A)',
minWidth: 140
},
{ prop: 'operation', label: '操作', fixed: 'right', width: 250 }
])
// 打开 drawer(新增、编辑)
const openDialog = (titleType: string, row: Partial<TestSource.ResTestSource> = {}) => {
testSourcePopup.value?.open(titleType, row,modeStore.currentMode)
testSourcePopup.value?.open(titleType, row, modeStore.currentMode)
}
// 批量删除设备
const batchDelete = async (id: string[]) => {
await useHandleData(deleteTestSource, id, '删除所选检测源')
proTable.value?.clearSelection()
proTable.value?.getTableList()
await useHandleData(deleteTestSource, id, '删除所选检测源')
proTable.value?.clearSelection()
proTable.value?.getTableList()
}
// 删除设备
const handleDelete = async (params: TestSource.ResTestSource) => {
await useHandleData(deleteTestSource, [params.id], `删除【${params.name}】检测源`)
proTable.value?.getTableList()
await useHandleData(deleteTestSource, [params.id], `删除【${params.name}】检测源`)
proTable.value?.getTableList()
}
</script>
</script>

View File

@@ -1,276 +0,0 @@
<template>
<el-dialog
title="数据查询"
v-model='dialogVisible'
v-bind="dialogBig"
draggable
>
<div class='table-box'>
<el-tabs type="border-card">
<el-tab-pane label="检测结果">
<!-- 列表数据 -->
<div class="container_table1">
<ProTable
ref='proTable1'
:columns='columns1'
:data="testResultDatas"
:toolButton="false"
>
</ProTable>
</div>
</el-tab-pane>
<el-tab-pane label="原始数据">
<!-- 列表数据 -->
<div class="container_table2">
<ProTable
ref='proTable2'
:columns='columns2'
:data="testDatas"
:toolButton="false"
>
</ProTable>
</div>
</el-tab-pane>
</el-tabs>
</div>
</el-dialog>
</template>
<script setup lang='tsx' name='useRole'>
import { Role } from '@/api/role/interface'
import { useHandleData } from '@/hooks/useHandleData'
import { useDownload } from '@/hooks/useDownload'
import { useAuthButtons } from '@/hooks/useAuthButtons'
import ProTable from '@/components/ProTable/index.vue'
import rolePopup from './components/rolePopup.vue'
import permissionUnit from './components/permissionUnit.vue'
import ImportExcel from '@/components/ImportExcel/index.vue'
import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
import {dialogBig,dialogMiddle,dialogSmall} from '@/utils/elementBind'
import { CirclePlus, Delete, EditPen, Share, Download, Upload, View, Refresh } from '@element-plus/icons-vue'
import { useDictStore } from '@/stores/modules/dict'
import {
getRoleList,
deleteRole,
} from '@/api/user/role/index'
import { deleteUser } from '@/api/user/user'
const dialogVisible = ref(false)
const open = () => {
dialogVisible.value = true
}
defineExpose({ open })
// ProTable 实例
const proTable1 = ref<ProTableInstance>()
const proTable2 = ref<ProTableInstance>()
// dataCallback 是对于返回的表格数据做处理,如果你后台返回的数据不是 list && total 这些字段,可以在这里进行处理成这些字段
// 或者直接去 hooks/useTable.ts 文件中把字段改为你后端对应的就行
const dataCallback = (data: any) => {
return {
records: data.list,
total: data.total,
current: data.pageNum,
size: data.pageSize,
}
}
// 如果你想在请求之前对当前请求参数做一些操作可以自定义如下函数params 为当前所有的请求参数(包括分页),最后返回请求列表接口
// 默认不做操作就直接在 ProTable 组件上绑定 :requestApi="getUserList"
const getTableList = (params: any) => {
let newParams = JSON.parse(JSON.stringify(params))
newParams.createTime && (newParams.startTime = newParams.createTime[0])
newParams.createTime && (newParams.endTime = newParams.createTime[1])
delete newParams.createTime
return getRoleList(newParams)
}
// 页面按钮权限(按钮权限既可以使用 hooks也可以直接使用 v-auth 指令指令适合直接绑定在按钮上hooks 适合根据按钮权限显示不同的内容)
const { BUTTONS } = useAuthButtons()
interface TestResultData {
standardData: number,//标准值
testedData: number,//被检值
errorData: number,//误差值
errorValue: number,//误差允许值
testResult: string,//检测结果(合格、不合格、无法比较)
}
interface TestData {
dataTime: string,//数据时间(合格、不合格、无法比较)
standardData: number,//标准值
testedData: number,//被检值
}
//检测结果数组
const testResultDatas = [
{
standardData: 57.74,//标准值
testedData: 57.73,//被检值
errorData: 0.01,//误差值
errorValue: 0.05774,//误差允许值
testResult: "合格",//检测结果(合格、不合格、无法比较)
}
];
//原始数据数组
const testDatas = [
{
dataTime: "2024-11-11 14:05:00",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:03",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:06",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:09",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:12",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:15",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:18",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:21",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:24",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:27",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:30",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:33",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:36",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:39",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:42",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:45",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:48",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:51",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:54",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:57",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
];
// 表格配置项
const columns1 = reactive<ColumnProps<TestResultData>[]>([
{ type: 'selection', fixed: 'left', width: 70 },
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
{
prop: 'standardData',
label: '标准值',
minWidth: 150,
},
{
prop: 'testedData',
label: '被检值',
minWidth: 150,
},
{
prop: 'errorData',
label: '误差值',
minWidth: 150,
},
{
prop: 'errorValue',
label: '误差允许值',
minWidth: 150,
},
{
prop: 'testResult',
label: '检测结果',
minWidth: 150,
},
])
// 表格配置项
const columns2 = reactive<ColumnProps<TestData>[]>([
{ type: 'selection', fixed: 'left', width: 70 },
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
{
prop: 'dataTime',
label: '数据时间',
minWidth: 200,
},
{
prop: 'standardData',
label: '标准值',
minWidth: 150,
},
{
prop: 'testedData',
label: '被检值',
minWidth: 150,
},
])
</script>

View File

@@ -1,526 +0,0 @@
<template>
<div class="table_info">
<ProTable
ref="proTable"
:columns="columns"
:request-api="getTableList"
:init-param="initParam"
:data-callback="dataCallback"
@drag-sort="sortTable"
:height="tableHeight"
:stripe="true"
>
<!-- 表格 header 按钮 -->
<template #tableHeader="scope">
<el-form :model="form" label-width="80px" :inline="true">
<el-form-item label="检测状态" v-if="form.activeTabs != 5">
<el-select v-model="form.checkStatus">
<el-option
v-for="(item, index) in checkStatusList"
:label="item.label"
:value="item.value"
:key="index"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="报告状态" v-if="form.activeTabs != 5">
<el-select v-model="form.checkReportStatus">
<el-option
v-for="(item, index) in checkReportStatusList"
:label="item.label"
:value="item.value"
:key="index"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="检测结果" v-if="form.activeTabs != 5">
<el-select v-model="form.checkResult">
<el-option
v-for="(item, index) in checkResultList"
:label="item.label"
:value="item.value"
:key="index"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="绑定状态" v-if="form.activeTabs == 5">
<el-select v-model="form.deviceBindStatus">
<el-option
v-for="(item, index) in deviceBindStatusList"
:label="item.label"
:value="item.value"
:key="index"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="设备类型" v-if="form.activeTabs == 5">
<el-select v-model="form.deviceType">
<el-option
v-for="(item, index) in deviceTypeList"
:label="item.label"
:value="item.value"
:key="index"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="制造厂商" v-if="form.activeTabs == 5">
<el-select v-model="form.manufacturer">
<el-option
v-for="(item, index) in manufacturerList"
:label="item.label"
:value="item.value"
:key="index"
></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" :icon="Search" @click="handleSearch">查询</el-button>
<el-button type="primary" @click="handleTest" v-if="form.activeTabs === 0">
启动自动检测
</el-button>
<el-button type="primary" @click="handleTest" v-if="form.activeTabs === 1">
启动手动检测
</el-button>
<el-button type="primary" v-if="form.activeTabs === 2">报告生成</el-button>
<el-button type="primary" v-if="form.activeTabs === 5">设备导入</el-button>
</el-form-item>
</el-form>
</template>
<!-- 表格操作 -->
<!-- <template #operation="scope">
<el-button
dictType="primary"
link
:icon="View"
@click="openDrawer('查看', scope.row)"
>查看</el-button
>
<el-button
dictType="primary"
link
:icon="EditPen"
@click="openDrawer('编辑', scope.row)"
>导出</el-button
>
<el-button
dictType="primary"
link
:icon="Delete"
@click="deleteAccount(scope.row)"
>删除</el-button
>
</template> -->
</ProTable>
</div>
</template>
<script setup lang="tsx" name="useProTable">
import { onMounted, reactive, ref } from 'vue'
import { useRouter } from 'vue-router'
import { User } from '@/api/interface'
import { useHandleData } from '@/hooks/useHandleData'
import { ElMessage } from 'element-plus'
import ProTable from '@/components/ProTable/index.vue'
import { Search } from '@element-plus/icons-vue'
import { getPlanList } from '@/api/plan/planList'
const router = useRouter()
const value1 = ref('')
const value2 = ref('')
const tableHeight = ref(0)
tableHeight.value = window.innerHeight - 630
//下拉框数据
//检测状态数据
const checkStatusList = [
{
label: '未检',
value: 0
},
{
label: '检测中',
value: 1
},
{
label: '检测完成',
value: 2
},
{
label: '归档',
value: 3
}
]
//检测报告状态数据
const checkReportStatusList = [
{
label: '未生成报告',
value: 0
},
{
label: '已生成报告',
value: 1
}
]
//检测结果数组
const checkResultList = [
{
label: '/',
value: null
},
{
label: '不合格',
value: 0
},
{
label: '合格',
value: 1
}
]
//绑定状态数组
const deviceBindStatusList = [
{
label: '未绑定',
value: 0
},
{
label: '已绑定',
value: 1
}
]
//设备类型数组
const deviceTypeList = [
{
label: 'PQS882A',
value: 0
},
{
label: 'PQS882B4',
value: 1
},
{
label: 'PQS882B5',
value: 2
},
{
label: 'PQS882B6',
value: 3
},
{
label: 'PQS882B7',
value: 4
},
{
label: 'PQS882B8',
value: 5
}
]
//制造厂商数组
const manufacturerList = [
{
label: '南京灿能电力',
value: 0
},
{
label: '南瑞继保',
value: 1
},
{
label: '中电',
value: 2
}
]
//查询条件
const form: any = ref({
activeTabs: 0, //功能选择
checkStatus: 0, //检测状态
checkReportStatus: 0, //检测报告状态
checkResult: 0, //检测结果
deviceBindStatus: 0, //绑定状态
deviceType: 0, //设备类型
manufacturer: 0 //制造厂商
})
const searchForm = ref({
intervalType: 0,
time: ['2024-08-20', '2024-08-27'],
searchBeginTime: '',
searchEndTime: '',
checkStatus: 0,
checkReportStatus: 0,
checkResult: 0
})
// ProTable 实例
const proTable = ref<ProTableInstance>()
// 如果表格需要初始化请求参数,直接定义传给 ProTable (之后每次请求都会自动带上该参数,此参数更改之后也会一直带上,改变此参数会自动刷新表格数据)
const initParam = reactive({ type: 1, pageNum: 1, pageSize: 10 })
// dataCallback 是对于返回的表格数据做处理,如果你后台返回的数据不是 list && total 这些字段,可以在这里进行处理成这些字段
// 或者直接去 hooks/useTable.ts 文件中把字段改为你后端对应的就行
const tableList = ref([])
const dataCallback = (data: any) => {
return {
list: data || data.data || data.list,
total: data.length || data.total //total
}
}
// 如果你想在请求之前对当前请求参数做一些操作可以自定义如下函数params 为当前所有的请求参数(包括分页),最后返回请求列表接口
// 默认不做操作就直接在 ProTable 组件上绑定 :requestApi="getUserList"
const getTableList = (params: any) => {
let newParams = JSON.parse(JSON.stringify(params))
newParams.createTime && (newParams.startTime = newParams.createTime[0])
newParams.createTime && (newParams.endTime = newParams.createTime[1])
delete newParams.createTime
return getPlanList(newParams)
}
// 表格配置项
const columns = reactive<ColumnProps<User.ResUserList>[]>([
{ type: 'selection', fixed: 'left', width: 70 },
{
prop: 'checkMode',
label: '设备序列号',
width: 140,
render: scope => {
return scope.row.checkMode == 0
? '设备1'
: scope.row.checkMode == 1
? '设备2'
: scope.row.checkMode == 2
? '设备3'
: scope.row.checkMode
}
},
{
prop: 'checkMode',
label: '设备类型',
width: 140,
render: scope => {
return scope.row.checkMode == 0
? 'PQS991'
: scope.row.checkMode == 1
? 'PQS882'
: scope.row.checkMode == 2
? 'PQS6666'
: scope.row.checkMode
}
},
{
prop: 'checkFrom',
label: '制造厂商',
width: 140,
render: scope => {
return scope.row.checkFrom == 0
? '南京灿能'
: scope.row.checkFrom == 1
? '南瑞继保'
: scope.row.checkFrom == 2
? '/'
: scope.row.checkFrom
}
},
{
prop: 'numberFromName',
label: 'MAC/IP',
render: scope => {
return scope.row.numberFromName == 0
? '192.168.0.1'
: scope.row.numberFromName == 1
? '192.168.0.2'
: scope.row.numberFromName == 2
? '192.168.0.3'
: scope.row.numberFromName
}
}
// {
// prop: "checkExe",
// label: "检测脚本",
// render: (scope) => {
// return scope.row.checkExe == 0
// ? "国网入网检测脚本(单影响量-模拟式)"
// : scope.row.checkExe == 1
// ? "国网入网检测脚本"
// : scope.row.checkExe == 2
// ? "/"
// : scope.row.checkExe;
// },
// },
// {
// prop: "wctx",
// label: "误差体系",
// render: (scope) => {
// return scope.row.wctx == 0
// ? "Q/GDW 1650.2- 2016"
// : scope.row.wctx == 1
// ? "Q/GDW 10650.2 - 2021"
// : scope.row.wctx == 2
// ? "/"
// : scope.row.wctx;
// },
// },
// {
// prop: "checkStatus",
// label: "检测状态",
// width: 120,
// render: (scope) => {
// return scope.row.checkStatus == 1
// ? "未检"
// : scope.row.checkStatus == 2
// ? "检测中"
// : scope.row.checkStatus == 3
// ? "检测完成"
// : scope.row.checkStatus;
// },
// },
// {
// prop: "checkReport",
// label: "检测报告",
// width: 120,
// render: (scope) => {
// return scope.row.checkReport == 1
// ? "未生成"
// : scope.row.checkReport == 2
// ? "部分生成"
// : scope.row.checkReport == 3
// ? "全部生成"
// : scope.row.checkReport;
// },
// },
// {
// prop: "checkResult",
// label: "检测结果",
// width: 120,
// render: (scope) => {
// return scope.row.checkReport == 1
// ? "/"
// : scope.row.checkReport == 2
// ? "符合"
// : scope.row.checkReport == 3
// ? "不符合"
// : scope.row.checkReport;
// },
// },
// {
// prop: "parentNode",
// label: "父节点",
// width: 90,
// render: (scope) => {
// return scope.row.checkReport == 0
// ? "/"
// : scope.row.checkReport == 1
// ? "检测计划1"
// : scope.row.checkReport == 2
// ? "检测计划2"
// : scope.row.checkReport == 3
// ? "检测计划3"
// : scope.row.checkReport;
// },
// },
// { prop: "operation", label: "操作", fixed: "right", width: 250 },
])
// 跳转详情页
const toDetail = () => {
router.push(`/proTable/useProTable/detail/${Math.random().toFixed(3)}?params=detail-page`)
}
//重置查询条件
const resetSearchForm = () => {
searchForm.value = {
intervalType: 0,
time: ['2024-08-20', '2024-08-27'],
searchBeginTime: '',
searchEndTime: '',
checkStatus: 0,
checkReportStatus: 0,
checkResult: 0
}
}
//查询
const handleSearch = () => {
proTable.value?.getTableList()
}
//重置
const handleRefresh = () => {
proTable.value?.getTableList()
}
// 表格拖拽排序
const sortTable = ({ newIndex, oldIndex }: { newIndex?: number; oldIndex?: number }) => {
ElMessage.success('修改列表排序成功')
}
// 删除用户信息
const deleteAccount = async (params: User.ResUserList) => {
await useHandleData(deleteUser, { id: [params.id] }, `删除【${params.username}`)
proTable.value?.getTableList()
}
// 批量删除用户信息
const batchDelete = async (id: string[]) => {
await useHandleData(deleteUser, { id }, '删除所选用户信息')
proTable.value?.clearSelection()
proTable.value?.getTableList()
}
// 重置用户密码
const resetPass = async (params: User.ResUserList) => {
await useHandleData(resetUserPassWord, { id: params.id }, `重置【${params.username}】用户密码`)
proTable.value?.getTableList()
}
// 切换用户状态
const changeStatus = async (row: User.ResUserList) => {
await useHandleData(
changeUserStatus,
{ id: row.id, status: row.status == 1 ? 0 : 1 },
`切换【${row.username}】用户状态`
)
proTable.value?.getTableList()
}
//顶部功能切换时修改activeTabs
const changeActiveTabs = (val: number) => {
form.value.activeTabs = val
}
//启动自动检测/手动检测
const handleTest = () => {
//自动检测
if (form.value.activeTabs === 0) {
ElMessage.success('自动检测')
router.push({
path: '/plan/autoTest'
})
} else {
ElMessage.warning('手动检测')
}
}
onMounted(() => {
})
defineExpose({ changeActiveTabs })
</script>
<style lang="scss" scoped>
/* 当屏幕宽度小于或等于1300像素时 */
@media screen and (max-width: 1300px) {
.el-select {
width: 130px !important;
}
}
@media screen and (min-width: 1300px) {
.el-select {
width: 150px !important;
}
}
.el-form {
width: 100%;
display: flex;
flex-wrap: wrap;
.el-form-item {
display: flex;
align-items: center;
justify-content: space-between;
.el-button {
margin: 0 !important;
margin-right: 10px !important;
}
}
}
</style>

View File

@@ -1,149 +0,0 @@
<template>
<div class="plan_tree">
<!-- <div class="search_view">
<el-input
placeholder="请输入计划名称"
v-model="searchForm.planName"
></el-input>
</div> -->
<div class="tree_container">
<el-tree
:data="data"
ref="treeRef"
:filter-node-method="filterNode"
:props="defaultProps"
node-key="id"
default-expand-all
:default-checked-keys="defaultChecked"
@node-click="handleNodeClick"
@check-change="changeSelect"
>
<!-- scriptIdx -->
<template #default="{ node, data }">
<span
class="custom-tree-node"
style="display: flex; align-items: center"
>
<CircleCheck v-if="data.isChildNode && data.scriptIdx < currentIndex" style="width:18px;height: 18px;margin-right:8px;color:#91cc75;"/>
<svg-icon v-if="data.isChildNode && data.scriptIdx === currentIndex" name="loading" spin ></svg-icon>
<span>{{ node.label }}</span>
</span>
</template>
</el-tree>
</div>
</div>
</template>
<script lang="ts" setup>
import { ref, onMounted, defineExpose, watch } from "vue";
import { Menu, Platform, CircleCheck,Loading } from "@element-plus/icons-vue";
const emit = defineEmits(["jump"]);
const data: any = ref([]);
const defaultProps = {
children: "children",
label: "name",
pid: "pid",
};
const searchForm = ref({
planName: "",
});
const defaultChecked: any = ref([]);
const treeList: any = ref([]);
const getTreeData = (val: any) => {
defaultChecked.value = [];
data.value = val;
if(data.value[0].children[0].hasOwnProperty("children"))
{
defaultChecked.value.push(data.value[0].children[0].children[0].id);
}
else
{
defaultChecked.value.push(data.value[0].children[0].id);
}
treeRef.value.setCurrentKey(defaultChecked.value);
};
const getCurrentIndex = (val: number) => {
currentIndex.value = val;
};
const filterText = ref("");
const treeRef = ref();
const currentIndex = ref(0);
// const timer = setInterval(() => {
// currentIndex.value++;
// if (currentIndex.value > 14)
// currentIndex.value = 0;
// console.log(currentIndex.value);
// }, 2000);
watch(
() => searchForm.value.planName,
(val) => {
treeRef.value!.filter(val);
},
{
deep: true,
}
);
const changeSelect=()=>{
//console.log(treeRef.value.getCheckedKeys());
}
const handleNodeClick = (data) => {
};
const filterNode = (value: string, data) => {
if (!value) return true;
return data.name.includes(value);
};
// 点击详情
const detail = (e: any) => {
emit("jump", e);
};
onMounted(() => {
});
defineExpose({ getTreeData,getCurrentIndex });
</script>
<style lang="scss" scoped>
.plan_tree {
// width: 200px;
height: 100%;
display: flex;
flex-direction: column;
padding: 5px;
// height: calc(100% - 70px);
background-color: #fff;
box-sizing: border-box;
.search_view {
width: 100%;
height: auto;
display: flex;
justify-content: space-between;
padding: 0 5px;
box-sizing: border-box;
align-items: center;
.el-input {
margin-top: 6px;
}
}
.el-input {
width: 100%;
// margin: 0 10px 10px 0;
}
.tree_container {
flex: 1;
height: 100%;
overflow-y: auto;
.el-tree {
height: 100%;
}
}
}
</style>

View File

@@ -1,701 +0,0 @@
<template>
<!-- 自动检测页面 -->
<div class="test">
<!-- 顶部筛选条件&返回按钮 -->
<!-- {{ printText }} -->
<div class="test_top">
<!-- style="pointer-events: none" -->
<svg-icon name="wind" spin></svg-icon>
<el-checkbox
v-for="(item, index) in detectionOptions"
v-model="item.selected"
:key="index"
:label="item.name"
></el-checkbox>
<el-button type="primary" @click="handlePreTest">预检测</el-button>
<el-button type="primary" @click="handleAutoTest">正式检测</el-button>
<el-button type="primary" @click="handleBackDeviceList">返回首页</el-button>
<!-- <el-select v-model="currentErrSysID" placeholder="请选择误差体系" autocomplete="off">
<el-option
v-for="plan in testErrSystDataList"
:key="plan.id"
:label="plan.label"
:value="plan.id">
</el-option>
</el-select>
<el-button type="primary" @click="handlePreTest">重新计算</el-button> -->
</div>
<div class="test_bot">
<div class="test_left">
<AutoTestTree ref="treeRef"></AutoTestTree>
</div>
<div class="test_right">
<el-descriptions
style="width: 100%; border-radius: 6px; margin-bottom: 10px; background-color: #fff; padding: 10px"
:column="3"
border
>
<template #extra>
<el-progress style="width: 80%" :percentage="percentage" :color="customColors" />
<div class="test_button">
<el-button type="primary" v-if="!isPause" :icon="VideoPause" @click="handlePauseTest">
暂停检测
</el-button>
<el-button type="warning" v-if="isPause" :icon="Refresh" @click="handlePauseTest">
继续检测
</el-button>
<el-button type="danger" :icon="Close" @click="handleFinishTest">停止检测</el-button>
<!-- <el-button
type="danger"
v-if="!isPause"
:icon="Close"
@click="handlePauseTest"
>暂停检测</el-button
>
<el-button
type="warning"
v-if="isPause"
:icon="Refresh"
@click="handlePauseTest"
>继续检测</el-button
>
<el-button type="primary" :icon="Check" @click="handleFinishTest"
>完成检测</el-button
> -->
</div>
</template>
<!-- <el-descriptions-item width="0px" label="上送数据总数">
{{ num }}
</el-descriptions-item>
<el-descriptions-item width="0px" label="已上送数据数">
{{ num1 }}
</el-descriptions-item>
<el-descriptions-item width="0px" label="待上送数据数">
{{ num2 }}
</el-descriptions-item> -->
</el-descriptions>
<!-- 右侧列表 -->
<div class="right_table">
<!-- 模拟列表样式 -->
<!-- 表头设备 -->
<div class="table_left" v-if="false">
<p>测试项目</p>
<div v-for="(item, index) in deviceTestList" :key="index">
{{ item.name }}
</div>
</div>
<div class="table_right">
<div class="right_device_title">
<p v-for="(item, index) in deviceData" :key="index">
{{ item.name }}
</p>
</div>
<div class="right_device_status">
<div v-if="beforeTest">
<span class="empty__div">暂无数据</span>
</div>
<div
class="status_info"
v-if="!beforeTest"
v-for="(item, index) in deviceTestList"
:key="index"
>
<!-- <p v-for="(vv, vvs) in item.children" :key="vvs">
{{ vv.status }}
</p> -->
<el-button
v-for="(vv, vvs) in item.children"
:key="vvs"
:type="vv.type"
text
@click="handleClick(item, index, vvs)"
>
{{ vv.label }}
</el-button>
</div>
</div>
</div>
</div>
<!-- 右侧状态加载 -->
<div class="right_status" v-if="beforeTest">
<span class="empty__div">暂无数据</span>
</div>
<div class="right_status" ref="statusRef" v-if="!beforeTest">
<!-- ,fontSize:index%5===0?'16px':'14px' -->
<p
v-for="(item, index) in statusList"
:key="index"
:style="{ color: index % 5 === 0 ? '#F56C6C' : 'var(--el-text-color-regular)' }"
>
输入{{ item.remark }} -{{ item.status == 0 ? '输出完毕' : '输入中,请稍后!' }}
<br />
<span v-if="index == statusList.length - 1">...</span>
</p>
</div>
</div>
</div>
</div>
<ShowDataPopup ref="showDataPopup" />
</template>
<script lang="ts" setup>
import { nextTick, onMounted, ref } from 'vue'
import AutoTestTree from './components/autoTestTree.vue'
import { data } from '@/api/plan/autoTest.json'
import { ElMessage, ElMessageBox } from 'element-plus'
import ShowDataPopup from './components/ShowDataPopup.vue'
import { Close, Refresh, VideoPause } from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const currentErrSysID = ref('2')
const treeRef = ref<any>()
const PopupVisible = ref(false)
const showDataPopup = ref()
const beforeTest = ref(true)
const testModel = ref('')
//定义与预检测配置数组
const detectionOptions = ref([
{
id: 0,
name: '标准源通讯检测', //判断源通讯是否正常
selected: true
},
{
id: 1,
name: '设备通讯检测', //判断设备的IP、Port、识别码、秘钥是否正常
selected: true
},
{
id: 2,
name: '协议校验', //ICD报告触发测试
selected: true
},
{
id: 3,
name: '相序校验', //判断装置的接线是否正确
selected: true
},
{
id: 4,
name: '守时校验', //判断装置24小时内的守时误差是否小于1s
selected: true
},
{
id: 5,
name: '通道系数校准', //通过私有协议与装置进行通讯,校准三相电压电流的通道系数
selected: true
}
// {
// id: 6,
// name: "实时数据比对",
// },
// {
// id: 7,
// name: "录波数据比对",
// },
])
const leftDeviceData = ref<any>([
// {
// id: 0,
// name: "设备1-预检测",
// status: 0,
// },
// {
// id: 1,
// name: "设备2-预检测",
// status: 1,
// },
// {
// id: 2,
// name: "设备3-预检测",
// status: 1,
// },
// {
// id: 3,
// name: "设备4-预检测",
// status: 0,
// },
// {
// id: 4,
// name: "设备5-预检测",
// status: 1,
// },
// {
// id: 5,
// name: "设备6-预检测",
// status: 0,
// },
])
const initLeftDeviceData = () => {
leftDeviceData.value.map((item, index) => {
// handlePrintText(item.name, index);
})
}
const preTestData = [
{
id: 0,
name: '预检测项目',
children: [
{
scriptIdx: 1,
isChildNode: true,
pid: '0-2',
id: '0-2-2',
name: '标准源通讯检测'
},
{
scriptIdx: 2,
isChildNode: true,
pid: '0-3',
id: '0-3-1',
name: '设备通讯检测'
},
{
scriptIdx: 3,
isChildNode: true,
pid: '0-3',
id: '0-3-1',
name: '协议校验'
},
{
scriptIdx: 4,
isChildNode: true,
pid: '0-3',
id: '0-3-1',
name: '相序校验'
},
{
scriptIdx: 5,
isChildNode: true,
pid: '0-3',
id: '0-3-1',
name: '守时校验'
},
{
scriptIdx: 6,
isChildNode: true,
pid: '0-3',
id: '0-3-1',
name: '通道系数校准'
}
]
}
]
// 弹出数据查询页面
const handleClick = (item, index, vvs) => {
//const data = "检测脚本为:"+item.name+";被检设备为:"+item.children.value.devID+";被检通道序号为:"+ item.children.monitorIndex;
PopupVisible.value = true
showDataPopup.value.open()
}
let currentIndex = 0
let totalNum = 0
//启动预检测
const handlePreTest = () => {
ElMessage.success('启动预检测')
currentIndex = 0
percentage.value = 0
statusList.value = []
deviceTestList.value = []
statusId.value = 0
testModel.value = 'preTest'
beforeTest.value = false
getTreeData(preTestData)
totalNum = preTestData[0].children.length
interValTest()
// let count = 0;
// if (timer) {
// clearInterval(timer);
// count = 0;
// leftDeviceData.value = [];
// }
// if (count == 5) {
// count = 0;
// }
// else {
// timer = setInterval(async () => {
// count++;
// if (count > 15) return;
// await nextTick(() => {
// leftDeviceData.value.push({
// id: count,
// name: "设备" + count + "预检测",
// status: count % 2 == 0 ? 0 : 1,
// });
// });
// }, 2000);
// }
}
//进入检测流程
const handleAutoTest = () => {
ElMessage.success('启动正式检测')
currentIndex = 0
percentage.value = 0
statusList.value = []
deviceTestList.value = []
statusId.value = 0
testModel.value = 'Test'
beforeTest.value = false
getTreeData(data)
// totalNum = data.length;
totalNum = 10
interValTest()
}
//返回设备列表
const handleBackDeviceList = () => {
router.push({
path: '/home/index'
})
}
const getTreeData = val => {
treeRef.value && treeRef.value.getTreeData(val)
}
const tableList = ref([])
const percentage = ref(0)
const customColors = [
// { color: "red", percentage: 0 },
// { color: "red", percentage: 10 },
// { color: "red", percentage: 20 },
// { color: "red", percentage: 30 }, //红
// { color: "red", percentage: 40 },
// { color: "#e6a23c", percentage: 50 },
// { color: "#e6a23c", percentage: 60 },
// { color: "#e6a23c", percentage: 70 }, //黄
// { color: "#e6a23c", percentage: 80 }, //1989fa
// { color: "#e6a23c", percentage: 90 }, //1989fa
{ color: '#5cb87a', percentage: 100 } //绿
]
//加载进度条
const refreshProgress = () => {
if (percentage.value < 100) {
percentage.value = Math.trunc((currentIndex / totalNum) * 100)
} else {
clearInterval(timer.value)
clearInterval(statusTimer.value)
let strTemp = ''
if (testModel.value === 'preTest') strTemp = '预检测过程全部结束'
else if (testModel.value === 'Test') strTemp = '正式检测全部结束'
statusId.value++
statusList.value.push({
id: statusId.value,
remark: strTemp,
status: 0
})
if (testModel.value === 'preTest') ElMessage.success('预检测过程全部结束')
else if (testModel.value === 'Test')
//ElMessage.success("正式检测全部结束,你可以停留在此页面查看检测结果,或返回首页进行复检、报告生成和归档等操作")
ElMessageBox.confirm(
'检测全部结束,你可以停留在此页面查看检测结果,或返回首页进行复检、报告生成和归档等操作',
'检测完成',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'success'
}
).then()
// percentage.value = 0;
// statusList.value = [];
// deviceTestList.value = [];
// statusId.value = 0;
}
}
let timer: any = ref('')
const statusTimer: any = ref('')
//检测列表数据
const deviceTestList = ref<any>([])
//检测结果数据
const deviceList = ref<any>([])
//前一个页面带过来的设备数据
// const deviceData = ref<any>([]);
const deviceData = ref([
{
id: 0,
name: '设备1通道1',
status: Math.floor(Math.random() * 4),
type: 'info',
label: '/',
devID: 'dev1',
monitorIndex: 1
},
{
id: 1,
name: '设备1通道2',
status: Math.floor(Math.random() * 4),
type: 'success',
label: '√',
devID: 'dev1',
monitorIndex: 2
},
{
id: 2,
name: '设备2通道1',
status: Math.floor(Math.random() * 4),
type: 'danger',
label: '×',
devID: 'dev2',
monitorIndex: 1
},
{
id: 3,
name: '设备3通道1',
status: Math.floor(Math.random() * 4),
type: 'success',
label: '√',
devID: 'dev3',
monitorIndex: 1
}
])
const interValTest = () => {
timer.value = setInterval(() => {
deviceTestList.value.push({
id: 0,
name: `频率 ${statusId.value}Hz`,
children: deviceData.value
// status: Math.floor(Math.random() * 4),
})
currentIndex++
treeRef.value && treeRef.value.getCurrentIndex(currentIndex)
refreshProgress()
}, 2000)
statusTimer.value = setInterval(() => {
getStatusList()
statusList.value.map((item: any, index: any) => {
if (index == statusList.value.length - 1) {
item.status = 1
} else {
item.status = 0
}
})
}, 2000)
}
//暂停检测
const isPause = ref<boolean>(false)
const handlePauseTest = () => {
if (!isPause.value) {
clearInterval(timer.value)
clearInterval(statusTimer.value)
} else {
interValTest()
}
isPause.value = !isPause.value
}
//完成检测
const handleFinishTest = () => {
ElMessage.success('完成检测')
}
// 表格拖拽排序
const sortTable = ({ newIndex, oldIndex }: { newIndex?: number; oldIndex?: number }) => {
ElMessage.success('修改列表排序成功')
}
const statusList: any = ref([])
let statusId = ref(0)
const statusRef = ref()
const getStatusList = () => {
statusId.value++
statusList.value.push({
id: statusId.value,
remark: `频率 ${statusId.value}Hz`,
status: 0
})
// console.log(statusRef.value.offsetHeight);
nextTick(() => {
if (statusRef.value) statusRef.value.scrollTop = statusRef.value.scrollHeight
})
}
onMounted(() => {})
</script>
<style lang="scss" scoped>
.empty__div {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
color: var(--el-text-color-secondary);
font-size: var(--el-font-size-base);
}
.test {
width: 100%;
height: 100%;
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: space-between;
.test_top {
width: 100%;
height: 50px;
display: flex;
background-color: #fff;
justify-content: flex-start;
align-items: center;
border-radius: 4px;
padding: 0 10px;
box-sizing: border-box;
.el-button {
margin-top: 10px;
margin-bottom: 10px;
margin-left: 20px;
}
.el-select {
margin-top: 10px;
margin-bottom: 10px;
margin-left: 20px;
}
}
.test_bot {
flex: 1;
margin-top: 10px;
display: flex;
height: calc(100vh - 240px);
.test_left {
max-width: 300px;
min-width: 200px;
width: 15%;
height: 100%;
overflow: auto;
padding-bottom: 20px;
box-sizing: border-box;
background-color: #fff;
border-radius: 6px;
padding: 5px !important;
box-sizing: border-box;
}
.test_right {
flex: 1;
height: 100%;
margin-left: 10px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
.right_table {
flex: 1;
// width: 100%;
// height: calc(100vh - 330px);
height: 100%;
flex: 1 !important;
height: calc(100vh - 560px);
border-radius: 4px;
background-color: #fff;
width: 100% !important;
display: flex;
padding: 10px;
box-sizing: border-box;
.table_left {
width: 150px;
height: 100%;
overflow: auto;
p {
line-height: 40px;
margin: 0;
width: 100px;
}
}
.table_right {
flex: 1;
display: flex;
overflow: auto;
flex-direction: column;
.right_device_title {
width: 100%;
display: flex;
justify-content: center;
// overflow-x: auto !important;
p {
flex: 1;
// max-width: 150px;
text-align: center;
width: auto;
padding: 0 10px;
margin: 0;
line-height: 40px;
}
}
.right_device_status {
position: relative;
width: 100%;
flex: 1;
.status_info {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
.el-button {
flex: 1;
// max-width: 150px;
min-width: auto;
margin: 0;
padding: 0 10px;
text-align: left;
}
}
}
}
}
.right_status {
position: relative;
width: 100%;
height: 150px;
overflow: auto;
background-color: #fff;
border-radius: 4px;
margin-top: 10px;
padding: 10px 0 20px 10px;
box-sizing: border-box;
p {
height: 20px;
font-size: 14px;
margin: 0 !important;
}
:nth-last-child(1) {
margin-bottom: 40px;
}
}
}
}
}
:deep(.header-button-lf) {
clear: both !important;
}
:deep(.el-descriptions__extra) {
width: 100%;
display: flex;
justify-content: space-between;
.test_button {
width: auto;
display: flex;
align-items: center;
}
}
</style>

View File

@@ -1,137 +0,0 @@
<!--单列-->
<template>
<el-dialog class='table-box'
v-model='dialogVisible'
top='114px'
:style="{ height: height+'px', maxHeight: height+'px', overflow: 'hidden' }"
:title='title'
:width='width'
:modal='false'>
<div class='table-box' :style="{height:(height-64)+'px',maxHeight:(height-64)+'px',overflow:'hidden'}">
<ProTable
ref='proTable'
:columns='columns'
:data='deviceData'
type='selection'
@selection-change="handleSelectionChange"
>
<!-- 表格 header 按钮 -->
<template #tableHeader="scope">
<el-tooltip content="通过文件导入设备" placement="top">
<el-button type='primary' :icon='Download' tooltip >导入设备</el-button>
</el-tooltip>
<el-tooltip content="通过设备列表导入设备" placement="top">
<el-button type='primary' :icon='Download' tooltip @click="showDeviceSelectOpen">筛选设备</el-button>
</el-tooltip>
<el-tooltip content="把设备列表导出成文件" placement="top" :disabled='!scope.isSelected'>
<el-button type='primary' :icon='Download' :disabled='!scope.isSelected' tooltip >导出设备</el-button>
</el-tooltip>
<el-button type='danger' :icon='Delete' plain :disabled='!scope.isSelected'>
批量移除
</el-button>
</template>
<!-- <el-button type='primary' :icon='Download' >下载报告</el-button> -->
<!-- 表格操作 -->
<template #operation='scope'>
<!-- <el-button type='primary' link :icon='View' >查看</el-button> -->
<el-button type='primary' link :icon='Delete' >移除</el-button>
</template>
</ProTable>
</div>
<DeviceSelectOpen :width='width' :height='height' ref='openDeviceSelectView' />
</el-dialog>
</template>
<script setup lang='tsx'>
import { Delete, View ,Upload,Download} from '@element-plus/icons-vue'
import { reactive,ref } from 'vue'
import type { Device } from '@/api/device/interface/device.ts'
import ProTable from '@/components/ProTable/index.vue'
import { type ProTableInstance, type ColumnProps } from '@/components/ProTable/interface'
import deviceDataList from '@/api/device/device/deviceData.ts'
import DeviceSelectOpen from '@/views/plan/planList/components/devSelectPopup.vue'
import { useViewSize } from '@/hooks/useViewSize'
//const { popupBaseView, viewWidth, viewHeight } = useViewSize()
const deviceData = deviceDataList.plan_devicedata
const dialogVisible = ref(false)
const title = ref('')
const openDeviceSelectView = ref()
let multipleSelection = ref<string[]>([])
// 表格配置项
const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
{ type: 'selection', fixed: 'left', width: 70 },
{
prop: 'name',
label: '名称',
minWidth: 120,
},
{
prop: 'dev_Type',
label: '类型',
minWidth: 180,
},
{
prop: 'dev_Chns',
label: '通道数',
minWidth: 100,
},
{
prop: 'reCheck_Num',
label: '复检次数',
minWidth: 70,
},
{
prop: 'report_State',
label: '报告状态',
minWidth: 110,
},
{
prop: 'check_Result',
label: '检测结果',
minWidth: 110,
},
{
prop: 'check_State',
label: '检测状态',
minWidth: 110,
},
{
prop: 'document_State',
label: '归档状态',
minWidth: 110,
},
{ prop: 'operation', label: '操作', fixed: 'right', minWidth: 100 },
])
const open = (textTitle: string) => {
dialogVisible.value = true
title.value = textTitle
}
defineExpose({ open })
const props = defineProps({
width: {
type: Number,
default: 800,
},
height: {
type: Number,
default: 744,
},
})
const showDeviceSelectOpen = () => {
openDeviceSelectView.value.open('设备筛选列表')
}
// 处理选择变化
const handleSelectionChange = (selection:Device.ResPqDev[]) => {
multipleSelection.value = selection.map(row => row.id); // 更新选中的行
};
</script>
<style>
</style>

View File

@@ -895,7 +895,7 @@ const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan:
// 默认选择 cp95值 作为数据处理原则
const dataRuleDict = dictStore.getDictData('Data_Rule')
const rule = dataRuleDict.find(item => item.code === 'Cp95_Value')
const rule = dataRuleDict.find(item => item.code === 'Avg_value')
formContent.dataRule = rule ? rule.id : ''
} else {
[pqSource_Result, PqScript_Result, PqErrSys_Result, pqDevList_Result, pqReportName_Result] =
@@ -933,7 +933,7 @@ const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan:
const datasourceDicts = dictStore.getDictData('Datasource')
formContent.datasourceIds = datasourceDicts
.filter(item => ['real', 'wave_data'].includes(item.code))
.filter(item => ['real'].includes(item.code))
.map(item => item.code)
realTimeSetting.value = true
@@ -1212,10 +1212,12 @@ const loadTestItemsForErrorSys = async (errorSysId: string) => {
if (res.data && typeof res.data === 'object') {
// 将返回的键值对对象转换为下拉选项格式
Object.keys(res.data).forEach(key => {
if((res.data as Record<string, string>)[key]!='谐波有功功率') {
secondLevelOptions.push({
value: key,
label: (res.data as Record<string, string>)[key]
value: key,
label: (res.data as Record<string, string>)[key]
})
}
})
formContent.testItems = secondLevelOptions
.filter(option => option.label !== '闪变')

View File

@@ -0,0 +1,505 @@
<template>
<el-dialog
v-model="dialogVisible"
:title="`检测计划统计 - ${planName || '/'}`"
width="min(1280px, 92vw)"
class="plan-statistics-dialog"
destroy-on-close
draggable
@closed="handleClosed"
>
<div v-loading="loading" class="plan-statistics">
<el-empty v-if="loadFailed" description="统计数据加载失败" />
<template v-else>
<el-form class="filter-bar" :model="filters" inline label-width="72px">
<el-form-item label="设备厂家">
<el-select
v-model="filters.manufacturer"
filterable
placeholder="全部"
class="filter-select"
@change="reloadStatistics('manufacturer')"
>
<el-option label="全部" value="" />
<el-option
v-for="item in manufacturerOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="设备类型">
<el-select
v-model="filters.devType"
filterable
placeholder="全部"
class="filter-select"
@change="reloadStatistics('devType')"
>
<el-option label="全部" value="" />
<el-option
v-for="item in devTypeOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-form>
<div class="summary-grid">
<div v-for="item in summaryItems" :key="item.label" class="summary-item" :class="item.type">
<span class="summary-label">{{ item.label }}</span>
<strong class="summary-value">{{ item.value }}</strong>
</div>
</div>
<div v-if="isEmpty" class="empty-area">
<el-empty description="暂无统计数据" />
</div>
<template v-else>
<div class="chart-grid">
<div class="chart-panel">
<div class="panel-title">合格率</div>
<div ref="rateChartRef" class="chart"></div>
</div>
<div class="chart-panel">
<div class="panel-title">检测大项不合格分布</div>
<div ref="itemChartRef" class="chart"></div>
</div>
</div>
</template>
</template>
</div>
</el-dialog>
</template>
<script setup lang="ts">
import { computed, nextTick, onMounted, onUnmounted, reactive, ref } from 'vue'
import * as echarts from 'echarts'
import { ElMessage } from 'element-plus'
import { getPlanStatistics } from '@/api/plan/plan'
import type { Plan } from '@/api/plan/interface'
interface SelectOption {
id: string
name: string
}
type FilterField = 'manufacturer' | 'devType'
const emptyStatistics = (): Plan.PlanStatistics => ({
planId: '',
planName: '',
totalCheckCount: 0,
checkedDeviceCount: 0,
uncheckedDeviceCount: 0,
firstQualifiedDeviceCount: 0,
secondQualifiedDeviceCount: 0,
thirdOrMoreQualifiedDeviceCount: 0,
qualifiedDeviceCount: 0,
unqualifiedDeviceCount: 0,
unqualifiedItemCount: 0,
firstPassRate: 0,
secondPassRate: 0,
thirdOrMorePassRate: 0,
unqualifiedRate: 0,
itemDistributions: [],
manufacturerOptions: [],
devTypeOptions: []
})
const dialogVisible = ref(false)
const loading = ref(false)
const loadFailed = ref(false)
const planName = ref('')
const currentPlanId = ref('')
const rateChartRef = ref<HTMLDivElement>()
const itemChartRef = ref<HTMLDivElement>()
const statisticsData = reactive<Plan.PlanStatistics>(emptyStatistics())
const filters = reactive({
manufacturer: '',
devType: ''
})
const manufacturerOptions = ref<SelectOption[]>([])
const devTypeOptions = ref<SelectOption[]>([])
let rateChart: echarts.ECharts | null = null
let itemChart: echarts.ECharts | null = null
const isEmpty = computed(() => {
return (
!loading.value &&
statisticsData.totalCheckCount === 0 &&
statisticsData.checkedDeviceCount === 0 &&
statisticsData.itemDistributions.length === 0
)
})
const summaryItems = computed(() => [
{ label: '未检设备', value: statisticsData.uncheckedDeviceCount },
{ label: '已检设备', value: statisticsData.checkedDeviceCount },
{ label: '合格设备', value: statisticsData.qualifiedDeviceCount, type: 'is-qualified' },
{ label: '不合格设备', value: statisticsData.unqualifiedDeviceCount, type: 'is-unqualified' }
])
const resetData = () => {
Object.assign(statisticsData, emptyStatistics())
}
const formatRate = (value: number | string | null | undefined) => {
const numberValue = Number(value)
if (!Number.isFinite(numberValue)) return '0%'
return `${numberValue.toFixed(2)}%`
}
const normalizeRate = (value: number | string | null | undefined) => {
const numberValue = Number(value)
return Number.isFinite(numberValue) ? numberValue : 0
}
const open = async (row: Partial<Plan.ReqPlan>) => {
if (!row.id) {
ElMessage.error('计划信息缺失,无法统计')
return
}
resetData()
disposeCharts()
loadFailed.value = false
currentPlanId.value = row.id
filters.manufacturer = ''
filters.devType = ''
planName.value = row.name || ''
dialogVisible.value = true
await loadStatistics()
}
const reloadStatistics = async (changedField?: FilterField) => {
if (!dialogVisible.value || !currentPlanId.value) return
await loadStatistics(changedField)
}
const loadStatistics = async (changedField?: FilterField) => {
loading.value = true
try {
const { data } = await getPlanStatistics({
planId: currentPlanId.value,
manufacturer: filters.manufacturer || undefined,
devType: filters.devType || undefined
})
const nextManufacturerOptions = data?.manufacturerOptions || []
const nextDevTypeOptions = data?.devTypeOptions || []
Object.assign(statisticsData, {
...emptyStatistics(),
...data,
itemDistributions: data?.itemDistributions || [],
manufacturerOptions: nextManufacturerOptions,
devTypeOptions: nextDevTypeOptions
})
manufacturerOptions.value = nextManufacturerOptions
devTypeOptions.value = nextDevTypeOptions
if (clearInvalidFilters(changedField)) {
await loadStatistics()
return
}
await nextTick()
renderCharts()
} catch (error) {
loadFailed.value = true
ElMessage.error('统计数据加载失败')
} finally {
loading.value = false
}
}
const clearInvalidFilters = (changedField?: FilterField) => {
let cleared = false
if (
changedField !== 'manufacturer' &&
filters.manufacturer &&
!manufacturerOptions.value.some(item => item.id === filters.manufacturer)
) {
filters.manufacturer = ''
cleared = true
}
if (changedField !== 'devType' && filters.devType && !devTypeOptions.value.some(item => item.id === filters.devType)) {
filters.devType = ''
cleared = true
}
return cleared
}
const renderCharts = () => {
if (!dialogVisible.value || loadFailed.value || isEmpty.value) return
renderRateChart()
renderItemChart()
resizeCharts()
}
const renderRateChart = () => {
if (!rateChartRef.value) return
rateChart?.dispose()
rateChart = echarts.init(rateChartRef.value)
const rateData = [
{
name: '一次合格率',
value: normalizeRate(statisticsData.firstPassRate),
count: statisticsData.firstQualifiedDeviceCount
},
{
name: '二次合格率',
value: normalizeRate(statisticsData.secondPassRate),
count: statisticsData.secondQualifiedDeviceCount
},
{
name: '三次及以上合格率',
value: normalizeRate(statisticsData.thirdOrMorePassRate),
count: statisticsData.thirdOrMoreQualifiedDeviceCount
},
{
name: '不合格率',
value: normalizeRate(statisticsData.unqualifiedRate),
count: statisticsData.unqualifiedDeviceCount
}
]
rateChart.setOption({
tooltip: {
trigger: 'item',
formatter: (params: any) => {
return `${params.name}<br/>${formatRate(params.value)}<br/>设备数:${params.data?.count || 0}`
}
},
legend: { bottom: 0, left: 'center' },
color: ['#67c23a', '#409eff', '#e6a23c', '#f56c6c'],
series: [
{
name: '合格率',
type: 'pie',
radius: ['42%', '68%'],
center: ['50%', '43%'],
avoidLabelOverlap: true,
data: rateData,
label: {
formatter: ({ name, value }: any) => `${name}\n${formatRate(value)}`
}
}
]
})
}
const renderItemChart = () => {
if (!itemChartRef.value) return
itemChart?.dispose()
itemChart = echarts.init(itemChartRef.value)
const topItems = [...statisticsData.itemDistributions]
.sort((a, b) => (b.unqualifiedCount || 0) - (a.unqualifiedCount || 0))
.slice(0, 8)
itemChart.setOption({
tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } },
grid: { left: 48, right: 20, top: 36, bottom: 48 },
xAxis: {
type: 'category',
data: topItems.map(item => item.itemName || '/'),
axisLabel: { interval: 0, rotate: 28 }
},
yAxis: { type: 'value', minInterval: 1 },
series: [
{
name: '不合格次数',
type: 'bar',
barWidth: 30,
data: topItems.map(item => item.unqualifiedCount || 0),
itemStyle: { color: '#f56c6c' }
}
]
})
}
const disposeCharts = () => {
rateChart?.dispose()
itemChart?.dispose()
rateChart = null
itemChart = null
}
const resizeCharts = () => {
rateChart?.resize()
itemChart?.resize()
}
const handleClosed = () => {
disposeCharts()
resetData()
loadFailed.value = false
currentPlanId.value = ''
}
onMounted(() => {
window.addEventListener('resize', resizeCharts)
})
onUnmounted(() => {
window.removeEventListener('resize', resizeCharts)
disposeCharts()
})
defineExpose({ open })
</script>
<style scoped>
:deep(.plan-statistics-dialog) {
max-width: 92vw;
}
:deep(.plan-statistics-dialog .el-dialog__body) {
padding: 14px;
}
.plan-statistics {
min-height: 0;
}
.filter-bar {
display: flex;
flex-wrap: wrap;
gap: 10px;
margin-bottom: 12px;
}
.filter-select {
width: 220px;
}
.summary-grid {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 10px;
margin-bottom: 12px;
}
.summary-item {
min-height: 64px;
padding: 10px 12px;
border: 1px solid var(--el-border-color-light);
border-radius: 6px;
background: var(--el-fill-color-lighter);
box-sizing: border-box;
}
.summary-label {
display: block;
color: var(--el-text-color-secondary);
font-size: 13px;
line-height: 18px;
}
.summary-value {
display: block;
margin-top: 6px;
color: var(--el-text-color-primary);
font-size: 20px;
line-height: 28px;
}
.summary-item.is-qualified {
border-color: var(--el-color-success-light-5);
background: var(--el-color-success-light-9);
}
.summary-item.is-qualified .summary-value {
color: var(--el-color-success);
}
.summary-item.is-unqualified {
border-color: var(--el-color-danger-light-5);
background: var(--el-color-danger-light-9);
}
.summary-item.is-unqualified .summary-value {
color: var(--el-color-danger);
}
.chart-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 12px;
margin-bottom: 12px;
}
.chart-panel {
border: 1px solid var(--el-border-color-light);
border-radius: 6px;
padding: 10px;
}
.panel-title {
color: var(--el-text-color-primary);
font-size: 14px;
font-weight: 600;
line-height: 20px;
}
.chart {
width: 100%;
height: 250px;
}
.empty-area {
display: flex;
align-items: center;
justify-content: center;
min-height: 320px;
}
@media (max-width: 1200px) {
.summary-grid {
grid-template-columns: repeat(4, minmax(0, 1fr));
}
}
@media (max-width: 900px) {
.summary-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.chart-grid {
grid-template-columns: 1fr;
}
.chart {
height: 260px;
}
}
@media (max-width: 640px) {
:deep(.plan-statistics-dialog) {
width: 96vw;
max-width: 96vw;
}
:deep(.plan-statistics-dialog .el-dialog__body) {
max-height: calc(92vh - 110px);
overflow-y: auto;
padding: 12px;
}
.summary-grid {
gap: 8px;
}
.filter-select {
width: 100%;
}
.summary-item {
padding: 10px;
}
.summary-value {
font-size: 18px;
line-height: 24px;
}
}
</style>

View File

@@ -99,6 +99,16 @@
被检设备
</el-button>
<!-- <el-button type='primary' link :icon='List' @click='showDeviceOpen(scope.row)'>设备绑定</el-button> -->
<el-button
type="primary"
v-auth.plan="'analysis'"
link
icon="PieChart"
v-if="(scope.row.testState == '1' || scope.row.testState == '2') && modeStore.currentMode != '比对式'"
@click="openStatistics(scope.row)"
>
统计
</el-button>
<el-button
type="primary"
v-auth.plan="'analysis'"
@@ -136,6 +146,7 @@
<ImportExcel ref="planImportExcel" />
<ImportZip ref="planImportZip" @result="importResult" />
<PlanStatisticsPopup ref="planStatisticsPopupRef" />
<ChildrenPlan
:refresh-table="refreshTable"
@@ -163,6 +174,7 @@ import { computed, onMounted, reactive, ref, watch } from 'vue'
import type { Plan } from '@/api/plan/interface'
import PlanPopup from '@/views/plan/planList/components/planPopup.vue' // 导入子组件
import ChildrenPlan from '@/views/plan/planList/components/childrenPlan.vue'
import PlanStatisticsPopup from '@/views/plan/planList/components/planStatisticsPopup.vue'
import { useViewSize } from '@/hooks/useViewSize'
import { useDictStore } from '@/stores/modules/dict'
import { ElMessage, ElMessageBox } from 'element-plus'
@@ -187,6 +199,7 @@ const proTable = ref<ProTableInstance>()
const errorStandardPopup = ref()
const testSourcePopup = ref()
const planPopup = ref()
const planStatisticsPopupRef = ref<InstanceType<typeof PlanStatisticsPopup> | null>(null)
const modeStore = useModeStore()
const tableData = ref<any[]>([])
@@ -530,7 +543,7 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
isShow: modeStore.currentMode == '比对式'
},
{ prop: 'operation', label: '操作', fixed: 'right', minWidth: 250 }
{ prop: 'operation', label: '操作', fixed: 'right', minWidth: 320 }
])
function isVisible(row: Plan.ReqPlan) {
@@ -654,6 +667,10 @@ const statisticalAnalysis = async (row: Partial<Plan.ReqPlan> = {}) => {
useDownload(staticsAnalyse, '分析结果', [row.id], false, '.xlsx')
}
const openStatistics = (row: Partial<Plan.ReqPlan> = {}) => {
planStatisticsPopupRef.value?.open(row)
}
const importSubClick = () => {
const params = {
title: '导入检测计划',
@@ -671,4 +688,4 @@ const importResult = async (success: boolean | undefined) => {
}
</script>
<style scoped></style>
<style scoped></style>

View File

@@ -0,0 +1,182 @@
<template>
<el-dialog
v-model="dialogVisible"
:title="dialogTitle"
width="520px"
:destroy-on-close="true"
:close-on-click-modal="!submitting"
draggable
>
<el-form ref="formRef" :model="form" :rules="rules" label-width="90px">
<el-form-item label="资源名称" prop="name">
<el-input v-model="form.name" maxlength="250" placeholder="请输入资源名称" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" maxlength="250" placeholder="请输入备注" type="textarea" :rows="3" />
</el-form-item>
<el-form-item v-if="mode === 'add'" label="文件" prop="file">
<el-upload
ref="uploadRef"
action="#"
:auto-upload="false"
:limit="1"
accept=".mp4,video/mp4"
:file-list="fileList"
:on-change="handleFileChange"
:on-remove="handleFileRemove"
:on-exceed="handleExceed"
>
<el-button type="primary" :icon="Upload">选择文件</el-button>
<template #tip>
<div class="el-upload__tip">仅支持 MP4 文件最大 250MB</div>
</template>
</el-upload>
</el-form-item>
</el-form>
<template #footer>
<el-button :disabled="submitting" @click="dialogVisible = false">取消</el-button>
<el-button type="primary" :loading="submitting" @click="submit">确定</el-button>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { computed, reactive, ref } from 'vue'
import {
ElMessage,
genFileId,
type FormInstance,
type FormRules,
type UploadFile,
type UploadInstance,
type UploadProps,
type UploadRawFile
} from 'element-plus'
import { Upload } from '@element-plus/icons-vue'
import { addResourceManage, updateResourceManage } from '@/api/resourceManage'
import type { ResourceManage } from '@/api/resourceManage/interface'
const MAX_FILE_SIZE = 250 * 1024 * 1024
const props = defineProps<{
refreshTable?: () => void
}>()
const dialogVisible = ref(false)
const submitting = ref(false)
const mode = ref<'add' | 'edit'>('add')
const formRef = ref<FormInstance>()
const uploadRef = ref<UploadInstance>()
const fileList = ref<UploadFile[]>([])
const form = reactive<{
id: string
name: string
remark: string
file: File | null
}>({
id: '',
name: '',
remark: '',
file: null
})
const dialogTitle = computed(() => (mode.value === 'edit' ? '编辑资源' : '新增资源'))
const validateFile = (_rule: unknown, value: File | null, callback: (error?: Error) => void) => {
if (!value) {
callback(new Error('请选择 MP4 文件'))
return
}
callback()
}
const rules = reactive<FormRules>({
name: [{ required: true, message: '请输入资源名称', trigger: 'blur' }],
remark: [{ required: true, message: '请输入备注', trigger: 'blur' }],
file: [{ validator: validateFile, trigger: 'change' }]
})
const open = (type: 'add' | 'edit' = 'add', row?: ResourceManage.ResResourceManage) => {
mode.value = type
form.id = row?.id ?? ''
form.name = row?.name ?? ''
form.remark = row?.remark ?? ''
form.file = null
fileList.value = []
dialogVisible.value = true
formRef.value?.clearValidate()
}
const isValidMp4 = (file: File) => {
return file.name.toLowerCase().endsWith('.mp4') && (!file.type || file.type === 'video/mp4')
}
const handleFileChange: UploadProps['onChange'] = uploadFile => {
const raw = uploadFile.raw
if (!raw) return
if (!isValidMp4(raw)) {
ElMessage.error('仅支持上传 MP4 文件')
fileList.value = []
form.file = null
return
}
if (raw.size > MAX_FILE_SIZE) {
ElMessage.error('文件大小不能超过 250MB')
fileList.value = []
form.file = null
return
}
fileList.value = [uploadFile]
form.file = raw
formRef.value?.validateField('file')
}
const handleFileRemove = () => {
form.file = null
fileList.value = []
formRef.value?.validateField('file')
}
const handleExceed: UploadProps['onExceed'] = files => {
uploadRef.value?.clearFiles()
const file = files[0] as UploadRawFile
file.uid = genFileId()
uploadRef.value?.handleStart(file)
}
const submit = async () => {
if (!formRef.value) return
await formRef.value.validate()
const name = form.name.trim()
const remark = form.remark.trim()
submitting.value = true
try {
if (mode.value === 'edit') {
await updateResourceManage({
id: form.id,
name,
remark
})
} else {
if (!form.file) return
const formData = new FormData()
formData.append('name', name)
formData.append('remark', remark)
formData.append('file', form.file)
await addResourceManage(formData)
}
ElMessage.success(mode.value === 'edit' ? '编辑成功' : '新增成功')
dialogVisible.value = false
props.refreshTable?.()
} finally {
submitting.value = false
}
}
defineExpose({
open
})
</script>

View File

@@ -0,0 +1,42 @@
<template>
<el-dialog v-model="dialogVisible" title="播放视频" width="820px" :destroy-on-close="true" @closed="clearVideo">
<video ref="videoRef" class="resource-player" :src="videoUrl" controls autoplay />
</el-dialog>
</template>
<script setup lang="ts">
import { nextTick, ref } from 'vue'
const dialogVisible = ref(false)
const videoUrl = ref('')
const videoRef = ref<HTMLVideoElement>()
const open = async (url: string) => {
videoUrl.value = url
dialogVisible.value = true
await nextTick()
videoRef.value?.load()
}
const clearVideo = () => {
if (videoRef.value) {
videoRef.value.pause()
videoRef.value.removeAttribute('src')
videoRef.value.load()
}
videoUrl.value = ''
}
defineExpose({
open
})
</script>
<style scoped lang="scss">
.resource-player {
display: block;
width: 100%;
max-height: 68vh;
background: #000;
}
</style>

View File

@@ -0,0 +1,166 @@
<template>
<div class="table-box">
<ProTable ref="proTable" :columns="columns" :request-api="getTableList">
<template #tableHeader>
<el-button v-auth.resourceManage="'add'" type="primary" :icon="CirclePlus" @click="openAddDialog">
新增
</el-button>
</template>
<template #operation="scope">
<el-button
v-auth.resourceManage="'play'"
type="primary"
link
:icon="VideoPlay"
@click="handlePlay(scope.row)"
>
播放
</el-button>
<el-button
v-auth.resourceManage="'edit'"
type="primary"
link
:icon="EditPen"
@click="openEditDialog(scope.row)"
>
编辑
</el-button>
</template>
</ProTable>
</div>
<ResourceManagePopup ref="resourceManagePopup" :refresh-table="proTable?.getTableList" />
<ResourcePlayerDialog ref="resourcePlayerDialog" />
</template>
<script setup lang="tsx" name="resourceManage">
import { onActivated, reactive, ref } from 'vue'
import { CirclePlus, EditPen, VideoPlay } from '@element-plus/icons-vue'
import ProTable from '@/components/ProTable/index.vue'
import type { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
import type { ResourceManage } from '@/api/resourceManage/interface'
import { getResourceManageList, getResourceManagePlayUrl } from '@/api/resourceManage'
import {
consumeResourceManageAutoplayFirst,
hasPendingResourceManageAutoplayFirst
} from '@/utils/resourceManageAutoplay'
import ResourceManagePopup from './components/resourceManagePopup.vue'
import ResourcePlayerDialog from './components/resourcePlayerDialog.vue'
defineOptions({
name: 'resourceManage'
})
const proTable = ref<ProTableInstance>()
const resourceManagePopup = ref()
const resourcePlayerDialog = ref()
const tryAutoPlayFirstRecord = async (firstRecord?: ResourceManage.ResResourceManage) => {
if (!consumeResourceManageAutoplayFirst()) return
if (!firstRecord) return
await handlePlay(firstRecord)
}
const getTableList = async (params: ResourceManage.ReqResourceManageParams) => {
const response = await getResourceManageList(params)
const firstRecord = response.data.records?.[0]
await tryAutoPlayFirstRecord(firstRecord)
return response
}
const formatFileSize = (size?: number) => {
if (!size && size !== 0) return ''
if (size < 1024) return `${size} B`
const kb = size / 1024
if (kb < 1024) return `${kb.toFixed(2)} KB`
return `${(kb / 1024).toFixed(2)} MB`
}
const formatDateTime = (value?: string | null) => {
if (!value) return ''
const date = new Date(value)
if (Number.isNaN(date.getTime())) return value
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
const hours = String(date.getHours()).padStart(2, '0')
const minutes = String(date.getMinutes()).padStart(2, '0')
const seconds = String(date.getSeconds()).padStart(2, '0')
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
}
const normalizeStreamUrl = (url: string) => {
if (/^https?:\/\//i.test(url)) return url
const baseUrl = import.meta.env.VITE_API_URL as string
const normalizedBase = baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl
const normalizedUrl = url.startsWith('/') ? url : `/${url}`
return `${normalizedBase}${normalizedUrl}`
}
const columns = reactive<ColumnProps<ResourceManage.ResResourceManage>[]>([
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
{
prop: 'name',
label: '资源名称',
minWidth: 160,
search: { el: 'input' }
},
{
prop: 'fileName',
label: '文件名',
minWidth: 220,
search: { el: 'input' }
},
{
prop: 'fileSize',
label: '文件大小',
width: 120,
render: scope => formatFileSize(scope.row.fileSize)
},
{
prop: 'relativePath',
label: '路径',
width: 200,
showOverflowTooltip: true
},
{
prop: 'remark',
label: '备注',
minWidth: 180,
showOverflowTooltip: true
},
{
prop: 'createTime',
label: '上传时间',
width: 180,
render: scope => formatDateTime(scope.row.createTime)
},
{ prop: 'operation', label: '操作', fixed: 'right', width: 180 }
])
const openAddDialog = () => {
resourceManagePopup.value?.open('add')
}
const openEditDialog = (row: ResourceManage.ResResourceManage) => {
resourceManagePopup.value?.open('edit', row)
}
const handlePlay = async (row: ResourceManage.ResResourceManage) => {
const { data } = await getResourceManagePlayUrl(row.id)
resourcePlayerDialog.value?.open(normalizeStreamUrl(data.url))
}
onActivated(async () => {
if (!hasPendingResourceManageAutoplayFirst()) return
const currentFirstRecord = proTable.value?.tableData?.[0] as ResourceManage.ResResourceManage | undefined
if (currentFirstRecord) {
await tryAutoPlayFirstRecord(currentFirstRecord)
return
}
await proTable.value?.getTableList?.()
})
</script>

View File

@@ -0,0 +1,627 @@
<template>
<el-dialog
v-model="dialogVisible"
:title="dialogTitle"
width="1100px"
:close-on-click-modal="false"
:before-close="handleDialogClose"
destroy-on-close
@closed="handleDialogClosed"
>
<div class="sntp-tool">
<aside class="device-panel">
<div class="device-panel__header">
<span>{{ devicePanelTitle }}</span>
<span class="device-panel__count">{{ deviceItems.length }}</span>
</div>
<div v-if="deviceItems.length === 0" class="device-panel__empty">{{ emptyDeviceText }}</div>
<div v-else class="device-list">
<button
v-for="item in deviceItems"
:key="item.deviceIp"
type="button"
class="device-list__item"
:class="{ 'is-active': item.deviceIp === activeDeviceIp }"
@click="activeDeviceIp = item.deviceIp"
>
<span class="device-list__ip">{{ item.deviceIp }}</span>
<span class="device-list__time">{{ item.deviceTime }}</span>
</button>
</div>
</aside>
<section class="content-panel">
<el-row :gutter="16" class="time-list">
<el-col :xs="24" :md="12">
<div class="time-item">
<div class="time-label">{{ computerTimeLabel }}</div>
<div class="time-content">{{ activeDeviceState?.computerTime || '--' }}</div>
</div>
</el-col>
<el-col :xs="24" :md="12">
<div class="time-item">
<div class="time-label">{{ deviceTimeLabel }}</div>
<div class="time-content">{{ activeDeviceState?.deviceTime || '--' }}</div>
</div>
</el-col>
</el-row>
<div class="status-row">
<div class="status-chip">
<span class="status-chip__label">{{ activeDeviceLabel }}</span>
<span class="status-chip__value">{{ activeDeviceIp || '--' }}</span>
</div>
<div class="status-chip">
<span class="status-chip__label">{{ latestErrorLabel }}</span>
<span class="status-chip__value">{{ activeErrorMs }}</span>
</div>
</div>
<div class="action-row">
<el-button type="primary" :loading="starting" :disabled="running || stopping" @click="handleStart">
{{ startButtonText }}
</el-button>
<el-button type="danger" plain :loading="stopping" :disabled="!running || starting" @click="handleStop">
{{ stopButtonText }}
</el-button>
</div>
<div class="history-section">
<div class="history-header">
<span class="history-title">{{ historyTitle }}</span>
<el-button plain type="danger" :disabled="activeHistory.length === 0" @click="clearActiveHistory">
{{ clearButtonText }}
</el-button>
</div>
<div class="history-table">
<div class="history-table__head history-row">
<div class="col-order">{{ orderColumnLabel }}</div>
<div>{{ computerTimeLabel }}</div>
<div>{{ deviceTimeLabel }}</div>
<div>{{ errorColumnLabel }}</div>
</div>
<div v-if="activeHistory.length === 0" class="history-empty">
<span>{{ emptyHistoryText }}</span>
</div>
<div v-else class="history-table__body">
<div v-for="(item, index) in activeHistory" :key="item.id" class="history-row">
<div class="col-order">{{ index + 1 }}</div>
<div>{{ item.computerTime }}</div>
<div>{{ item.deviceTime }}</div>
<div>{{ formatErrorMs(item.errorMs) }}</div>
</div>
</div>
</div>
</div>
</section>
</div>
</el-dialog>
</template>
<script setup lang="ts" name="SntpToolDialog">
import { computed, ref } from 'vue'
import { ElMessage } from 'element-plus'
import socketClient from '@/utils/webSocketClient'
import type { SntpTimeMessage } from '@/api/system/sntp'
import { startSntpService, stopSntpService } from '@/api/system/sntp'
interface SntpHistoryItem {
id: string
computerTime: string
deviceTime: string
computerTimestampMs: number | null
deviceTimestampMs: number | null
errorMs: number | null
}
interface SntpDeviceState {
deviceIp: string
computerTime: string
deviceTime: string
errorMs: number | null
history: SntpHistoryItem[]
}
defineOptions({
name: 'SntpToolDialog'
})
const messageType = 'sntp_time_update'
const maxHistoryCount = 50
const dialogTitle = 'SNTP对时'
const devicePanelTitle = '设备列表'
const emptyDeviceText = '暂无设备数据'
const computerTimeLabel = '电脑时间'
const deviceTimeLabel = '装置返回时间'
const activeDeviceLabel = '当前设备'
const latestErrorLabel = '最新误差'
const startButtonText = '启动 SNTP 对时服务'
const stopButtonText = '停止 SNTP 对时服务'
const historyTitle = '历史记录'
const clearButtonText = '清空'
const orderColumnLabel = '序号'
const errorColumnLabel = '误差ms'
const emptyHistoryText = '暂无数据'
const dialogVisible = ref(false)
const running = ref(false)
const starting = ref(false)
const stopping = ref(false)
const activeDeviceIp = ref('')
const deviceStateMap = ref<Record<string, SntpDeviceState>>({})
const isClosing = ref(false)
const shouldStopAfterStart = ref(false)
const deviceItems = computed(() => Object.values(deviceStateMap.value))
const activeDeviceState = computed(() => {
if (!activeDeviceIp.value) {
return null
}
return deviceStateMap.value[activeDeviceIp.value] || null
})
const activeHistory = computed(() => activeDeviceState.value?.history || [])
const activeErrorMs = computed(() => formatErrorMs(activeDeviceState.value?.errorMs ?? null))
const formatErrorMs = (errorMs: number | null) => {
if (errorMs === null || Number.isNaN(errorMs)) {
return '--'
}
if (errorMs > 0) {
return `+${errorMs}`
}
return `${errorMs}`
}
const resetSession = () => {
running.value = false
starting.value = false
stopping.value = false
activeDeviceIp.value = ''
deviceStateMap.value = {}
isClosing.value = false
shouldStopAfterStart.value = false
}
const ensureSocketConnection = () => {
socketClient.Instance.connect()
socketClient.Instance.registerCallBack(messageType, (message: SntpTimeMessage) => {
handleTimeUpdate(message)
})
}
const unregisterSocket = () => {
socketClient.Instance.unRegisterCallBack(messageType)
}
const handleTimeUpdate = (message: SntpTimeMessage) => {
const deviceIp = message.deviceIp || 'unknown'
const current = deviceStateMap.value[deviceIp] || {
deviceIp,
computerTime: '--',
deviceTime: '--',
errorMs: null,
history: []
}
const nextHistoryItem: SntpHistoryItem = {
id: `${Date.now()}_${Math.random().toString(16).slice(2, 8)}`,
computerTime: message.computerTime || '--',
deviceTime: message.deviceTime || '--',
computerTimestampMs: typeof message.computerTimestampMs === 'number' ? message.computerTimestampMs : null,
deviceTimestampMs: typeof message.deviceTimestampMs === 'number' ? message.deviceTimestampMs : null,
errorMs: typeof message.errorMs === 'number' ? message.errorMs : null
}
deviceStateMap.value = {
...deviceStateMap.value,
[deviceIp]: {
deviceIp,
computerTime: nextHistoryItem.computerTime,
deviceTime: nextHistoryItem.deviceTime,
errorMs: nextHistoryItem.errorMs,
history: [nextHistoryItem, ...current.history].slice(0, maxHistoryCount)
}
}
if (!activeDeviceIp.value) {
activeDeviceIp.value = deviceIp
}
}
const clearActiveHistory = () => {
if (!activeDeviceIp.value) {
return
}
const current = deviceStateMap.value[activeDeviceIp.value]
if (!current) {
return
}
deviceStateMap.value = {
...deviceStateMap.value,
[activeDeviceIp.value]: {
...current,
history: []
}
}
}
const handleStart = async () => {
shouldStopAfterStart.value = false
starting.value = true
try {
await startSntpService()
running.value = true
if (isClosing.value || !dialogVisible.value || shouldStopAfterStart.value) {
await stopService(false)
}
} catch (error) {
ElMessage.error('启动 SNTP 对时服务失败')
} finally {
starting.value = false
}
}
const stopService = async (showError = true) => {
if (stopping.value) {
return
}
stopping.value = true
try {
await stopSntpService()
running.value = false
} catch (error) {
if (showError) {
ElMessage.error('停止 SNTP 对时服务失败')
}
throw error
} finally {
stopping.value = false
}
}
const handleStop = async () => {
await stopService()
}
const handleDialogClose = async (done: () => void) => {
if (isClosing.value) {
done()
return
}
isClosing.value = true
shouldStopAfterStart.value = true
try {
if (starting.value) {
return
}
if (running.value) {
await stopService(false)
}
} catch (error) {
ElMessage.error('停止 SNTP 对时服务失败')
} finally {
done()
}
}
const handleDialogClosed = () => {
unregisterSocket()
resetSession()
}
const open = () => {
resetSession()
ensureSocketConnection()
dialogVisible.value = true
}
defineExpose({ open })
</script>
<style scoped lang="scss">
:deep(.el-dialog) {
max-height: calc(100vh - 80px);
display: flex;
flex-direction: column;
}
:deep(.el-dialog__body) {
flex: 1;
min-height: 0;
overflow: hidden;
}
.sntp-tool {
display: grid;
grid-template-columns: 240px minmax(0, 1fr);
gap: 16px;
height: min(680px, calc(100vh - 160px));
min-height: 560px;
}
.device-panel,
.content-panel {
min-height: 0;
border: 1px solid #e5e7eb;
border-radius: 10px;
background: #ffffff;
}
.device-panel {
display: flex;
flex-direction: column;
overflow: hidden;
}
.device-panel__header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 14px 16px;
border-bottom: 1px solid #e5e7eb;
background: #fafafa;
color: #303133;
font-size: 14px;
font-weight: 600;
}
.device-panel__count {
min-width: 24px;
height: 24px;
border-radius: 999px;
background: #ecf5ff;
color: #409eff;
display: inline-flex;
align-items: center;
justify-content: center;
font-size: 12px;
}
.device-panel__empty {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
color: #909399;
font-size: 14px;
padding: 24px 16px;
}
.device-list {
flex: 1;
overflow: auto;
padding: 10px;
display: flex;
flex-direction: column;
gap: 10px;
}
.device-list__item {
border: 1px solid #e5e7eb;
border-radius: 8px;
background: #ffffff;
padding: 12px;
display: flex;
flex-direction: column;
gap: 6px;
text-align: left;
cursor: pointer;
transition: all 0.2s ease;
}
.device-list__item:hover,
.device-list__item.is-active {
border-color: #409eff;
box-shadow: 0 8px 24px rgba(64, 158, 255, 0.12);
}
.device-list__ip {
color: #303133;
font-size: 14px;
font-weight: 600;
word-break: break-all;
}
.device-list__time {
color: #909399;
font-size: 12px;
}
.content-panel {
display: flex;
flex-direction: column;
gap: 16px;
padding: 20px;
}
.time-list {
flex-shrink: 0;
}
.time-item {
min-height: 150px;
padding: 18px 20px;
border: 1px solid #e5e7eb;
border-radius: 8px;
background: #ffffff;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.time-label {
font-size: 14px;
color: #606266;
}
.time-content {
font-size: 24px;
line-height: 1.35;
color: #303133;
word-break: break-word;
}
.status-row {
display: flex;
gap: 12px;
flex-wrap: wrap;
}
.status-chip {
min-width: 220px;
border: 1px solid #e5e7eb;
border-radius: 8px;
padding: 12px 14px;
background: #fafafa;
display: flex;
flex-direction: column;
gap: 6px;
}
.status-chip__label {
font-size: 12px;
color: #909399;
}
.status-chip__value {
font-size: 14px;
color: #303133;
font-weight: 600;
word-break: break-all;
}
.action-row {
display: flex;
gap: 12px;
flex-shrink: 0;
}
.history-section {
flex: 1;
min-height: 0;
border: 1px solid #e5e7eb;
border-radius: 8px;
overflow: hidden;
display: flex;
flex-direction: column;
background: #ffffff;
}
.history-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 14px 16px;
border-bottom: 1px solid #e5e7eb;
background: #fafafa;
flex-shrink: 0;
}
.history-title {
font-size: 14px;
color: #303133;
font-weight: 500;
}
.history-empty {
flex: 1;
min-height: 0;
display: flex;
align-items: center;
justify-content: center;
color: #909399;
font-size: 14px;
}
.history-table {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
}
.history-table__head {
background: #fafafa;
flex-shrink: 0;
}
.history-table__body {
flex: 1;
min-height: 0;
max-height: 100%;
overflow: auto;
}
.history-row {
display: grid;
grid-template-columns: 88px minmax(0, 1fr) minmax(0, 1fr) 180px;
}
.history-row > div {
padding: 14px 16px;
border-bottom: 1px solid #f0f2f5;
color: #303133;
word-break: break-word;
}
.history-row > div + div {
border-left: 1px solid #f0f2f5;
}
.history-table__head > div {
font-size: 13px;
color: #606266;
font-weight: 500;
}
.history-table__body .history-row:last-child > div {
border-bottom: none;
}
.col-order {
text-align: center;
}
@media (max-width: 960px) {
:deep(.el-dialog) {
width: calc(100vw - 24px) !important;
max-height: calc(100vh - 24px);
margin: 12px auto;
}
.sntp-tool {
grid-template-columns: 1fr;
height: min(720px, calc(100vh - 120px));
}
.content-panel {
padding: 16px;
}
.action-row {
flex-direction: column;
}
.history-row {
grid-template-columns: 1fr;
}
.history-row > div + div {
border-left: none;
border-top: 1px solid #f0f2f5;
}
.col-order {
text-align: left;
}
}
</style>

View File

@@ -0,0 +1,16 @@
export interface ToolboxToolItem {
key: 'sntp'
title: string
description: string
icon: string
disabled?: boolean
}
export const toolboxTools: ToolboxToolItem[] = [
{
key: 'sntp',
title: 'SNTP对时',
description: '内置SNTP服务器可投入装置SNTP对时功能进行装置对时',
icon: 'Clock'
}
]

View File

@@ -0,0 +1,126 @@
<template>
<div class="toolbox-page">
<section class="toolbox-grid">
<button
v-for="tool in toolboxTools"
:key="tool.key"
type="button"
class="toolbox-card"
:disabled="tool.disabled"
@click="handleOpenTool(tool.key)"
>
<div class="toolbox-card__top">
<div class="toolbox-card__icon">
<el-icon>
<component :is="tool.icon" />
</el-icon>
</div>
</div>
<div class="toolbox-card__title">{{ tool.title }}</div>
<div class="toolbox-card__desc">{{ tool.description }}</div>
</button>
</section>
<SntpToolDialog ref="sntpToolDialogRef" />
</div>
</template>
<script setup lang="ts" name="toolbox">
import { ref } from 'vue'
import { toolboxTools } from './config/tools'
import SntpToolDialog from './components/SntpToolDialog.vue'
const sntpToolDialogRef = ref<InstanceType<typeof SntpToolDialog> | null>(null)
const handleOpenTool = (toolKey: string) => {
if (toolKey === 'sntp') {
sntpToolDialogRef.value?.open()
}
}
</script>
<style scoped lang="scss">
.toolbox-page {
min-height: 100%;
padding: 24px;
background:
radial-gradient(circle at top left, rgba(64, 158, 255, 0.16), transparent 28%),
linear-gradient(180deg, #f7fafc 0%, #eef3f8 100%);
}
.toolbox-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 320px));
gap: 20px;
}
.toolbox-card {
padding: 20px;
border: 1px solid rgba(15, 23, 42, 0.08);
border-radius: 18px;
background: rgba(255, 255, 255, 0.9);
box-shadow: 0 16px 30px rgba(15, 23, 42, 0.08);
display: flex;
flex-direction: column;
gap: 16px;
text-align: left;
cursor: pointer;
transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.toolbox-card:hover {
transform: translateY(-4px);
border-color: rgba(64, 158, 255, 0.28);
box-shadow: 0 24px 40px rgba(15, 23, 42, 0.12);
}
.toolbox-card__top {
display: flex;
align-items: center;
justify-content: space-between;
}
.toolbox-card__icon {
width: 48px;
height: 48px;
border-radius: 14px;
background: linear-gradient(135deg, #409eff 0%, #67c23a 100%);
display: inline-flex;
align-items: center;
justify-content: center;
color: #ffffff;
font-size: 22px;
}
.toolbox-card__tag {
border-radius: 999px;
background: #ecf5ff;
color: #409eff;
padding: 4px 10px;
font-size: 12px;
font-weight: 600;
}
.toolbox-card__title {
font-size: 20px;
line-height: 1.3;
color: #111827;
font-weight: 700;
}
.toolbox-card__desc {
font-size: 14px;
line-height: 1.7;
color: #4b5563;
}
@media (max-width: 768px) {
.toolbox-page {
padding: 16px;
}
.toolbox-grid {
grid-template-columns: 1fr;
}
}
</style>