Compare commits
40 Commits
2025-10
...
29dfc193a6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
29dfc193a6 | ||
|
|
2c72045d3a | ||
|
|
b9dfe29ffd | ||
|
|
647afd9fc9 | ||
| 4c477ae22a | |||
|
|
5708afb816 | ||
|
|
cd33151920 | ||
|
|
0e0b753126 | ||
|
|
61ee760f52 | ||
|
|
03d1db3bb4 | ||
|
|
6334681dc5 | ||
|
|
211b727b47 | ||
|
|
389857ac7e | ||
|
|
dde3f11bbe | ||
|
|
ff90f51cf1 | ||
| f8be28077f | |||
|
|
7d95a869c1 | ||
|
|
d3fc977983 | ||
| 2322858bc4 | |||
| a7487c24bf | |||
| a6d1195f13 | |||
|
|
f0ce2e0ac8 | ||
| 1119d6a7a8 | |||
| 28808dd39e | |||
|
|
38ac583fb7 | ||
|
|
64c05b629c | ||
| e9bf7e9e0e | |||
| 92a3076638 | |||
|
|
f987e1c625 | ||
|
|
4a309feac5 | ||
|
|
be95e792a8 | ||
|
|
308965751a | ||
|
|
6e8851f415 | ||
|
|
d99064c82e | ||
|
|
9ff9e7b923 | ||
|
|
ff5c435b6e | ||
|
|
5106149483 | ||
|
|
d5d04bd1ef | ||
|
|
bd5692fa23 | ||
|
|
f6b4979e7c |
28
.claude/settings.local.json
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"permissions": {
|
||||||
|
"allow": [
|
||||||
|
"Bash(dir:*)",
|
||||||
|
"Bash(\"build/extraResources/jre/bin/java.exe\" -version)",
|
||||||
|
"Bash(npm run build-frontend:*)",
|
||||||
|
"Bash(taskkill:*)",
|
||||||
|
"Bash(iconv:*)",
|
||||||
|
"Bash(powershell:*)",
|
||||||
|
"Bash(del:*)",
|
||||||
|
"Bash(git -C \"c:\\code\\gitea\\NPQS-9100\\pqs-9100_client\" log -1 --oneline)",
|
||||||
|
"Bash(npm run icon:*)",
|
||||||
|
"Bash(node:*)",
|
||||||
|
"Bash(xxd:*)",
|
||||||
|
"Bash(awk:*)",
|
||||||
|
"Bash(md5sum:*)",
|
||||||
|
"Bash(if exist \"out\" rd /s /q \"out\")",
|
||||||
|
"Bash(findstr:*)",
|
||||||
|
"Read(//c/code/gitea/NPQS-9100/pqs-9100_tool_client/cmd/**)",
|
||||||
|
"Bash(copy:*)",
|
||||||
|
"Bash(npm run build-w:*)",
|
||||||
|
"Read(//c/code/gitea/NPQS-9100/pqs-9100_tool_client/**)",
|
||||||
|
"Bash(npm install:*)"
|
||||||
|
],
|
||||||
|
"deny": [],
|
||||||
|
"ask": []
|
||||||
|
}
|
||||||
|
}
|
||||||
18
build/NPQS9100.bat
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
@echo off
|
||||||
|
chcp 65001 >nul
|
||||||
|
|
||||||
|
REM 获取当前批处理文件所在目录
|
||||||
|
cd /d "%~dp0"
|
||||||
|
|
||||||
|
REM 检查是否有管理员权限
|
||||||
|
net session >nul 2>&1
|
||||||
|
if %errorlevel% == 0 (
|
||||||
|
REM 已有管理员权限,直接启动
|
||||||
|
start "" "NPQS9100.exe"
|
||||||
|
exit
|
||||||
|
) else (
|
||||||
|
REM 没有管理员权限,使用 PowerShell 以管理员身份启动(隐藏窗口)
|
||||||
|
powershell -WindowStyle Hidden -Command "Start-Process '%~dp0NPQS9100.exe' -Verb RunAs"
|
||||||
|
exit
|
||||||
|
)
|
||||||
|
|
||||||
46
build/README-升级回滚.txt
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
========================================
|
||||||
|
NPQS-9100 升级与回滚说明
|
||||||
|
========================================
|
||||||
|
|
||||||
|
一、升级步骤(超简单!)
|
||||||
|
----------------------------------------
|
||||||
|
1. 双击 upgrade.bat(首次会自动创建 upgrade 文件夹)
|
||||||
|
2. 将升级文件放入 upgrade/ 目录:
|
||||||
|
- app.asar (前端升级包 - 文件)
|
||||||
|
- app.asar.unpacked\ (前端升级包 - 文件夹)
|
||||||
|
- entrance.jar (后端升级包)
|
||||||
|
3. 再次双击 upgrade.bat 开始升级
|
||||||
|
4. 等待完成后重启应用
|
||||||
|
|
||||||
|
二、回滚步骤
|
||||||
|
----------------------------------------
|
||||||
|
如果升级后出现问题:
|
||||||
|
1. 双击 rollback.bat
|
||||||
|
2. 选择是否回滚数据库(谨慎!)
|
||||||
|
3. 等待完成后重启应用
|
||||||
|
|
||||||
|
三、重要提示
|
||||||
|
----------------------------------------
|
||||||
|
✓ 升级前会自动备份到 backup/ 目录
|
||||||
|
✓ 数据库会自动备份到 mysql/data_backup/
|
||||||
|
✓ 升级日志保存在 logs/upgrade.log
|
||||||
|
✓ 多次升级时,backup/ 保存最后一次升级前的版本
|
||||||
|
|
||||||
|
四、紧急情况
|
||||||
|
----------------------------------------
|
||||||
|
如果脚本无法运行,请手动操作:
|
||||||
|
|
||||||
|
【恢复前端】
|
||||||
|
copy /Y backup\app.asar resources\app.asar
|
||||||
|
xcopy backup\app.asar.unpacked resources\app.asar.unpacked\ /E /I /Y
|
||||||
|
|
||||||
|
【恢复后端】
|
||||||
|
copy /Y backup\entrance.jar resources\extraResources\java\entrance.jar
|
||||||
|
|
||||||
|
【恢复数据库】(慎用!)
|
||||||
|
xcopy mysql\data_backup mysql\data\ /E /I /Y
|
||||||
|
|
||||||
|
========================================
|
||||||
|
详细文档请参考:doc/绿色包升级指南.md
|
||||||
|
========================================
|
||||||
|
|
||||||
29
build/app.manifest
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||||
|
<assemblyIdentity
|
||||||
|
version="1.0.0.0"
|
||||||
|
processorArchitecture="*"
|
||||||
|
name="NPQS9100"
|
||||||
|
type="win32"
|
||||||
|
/>
|
||||||
|
<description>NPQS-9100自动检测平台</description>
|
||||||
|
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||||
|
<security>
|
||||||
|
<requestedPrivileges>
|
||||||
|
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
|
||||||
|
</requestedPrivileges>
|
||||||
|
</security>
|
||||||
|
</trustInfo>
|
||||||
|
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||||
|
<application>
|
||||||
|
<!-- Windows 10 and Windows 11 -->
|
||||||
|
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
||||||
|
<!-- Windows 8.1 -->
|
||||||
|
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
|
||||||
|
<!-- Windows 8 -->
|
||||||
|
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
|
||||||
|
<!-- Windows 7 -->
|
||||||
|
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
|
||||||
|
</application>
|
||||||
|
</compatibility>
|
||||||
|
</assembly>
|
||||||
59
build/build.bat
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
@echo off
|
||||||
|
chcp 65001 >nul
|
||||||
|
echo ========================================
|
||||||
|
echo 清理并重新打包
|
||||||
|
echo ========================================
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo [1/4] 删除 out 目录...
|
||||||
|
cd /d "%~dp0.."
|
||||||
|
if exist out (
|
||||||
|
rmdir /s /q out 2>nul
|
||||||
|
if exist out (
|
||||||
|
echo 删除失败,请手动删除 out 目录
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
) else (
|
||||||
|
echo out 目录已删除
|
||||||
|
)
|
||||||
|
) else (
|
||||||
|
echo out 目录不存在
|
||||||
|
)
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo [2/4] 构建前端代码...
|
||||||
|
call npm run build-frontend
|
||||||
|
if %errorlevel% neq 0 (
|
||||||
|
echo 前端构建失败
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
echo 前端代码构建完成
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo [3/4] 构建 electron 代码...
|
||||||
|
call npm run build-electron
|
||||||
|
if %errorlevel% neq 0 (
|
||||||
|
echo electron 构建失败
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
echo electron 代码构建完成
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo [4/4] 打包 Windows 版本(包含代码加密)...
|
||||||
|
call npm run build-w
|
||||||
|
if %errorlevel% neq 0 (
|
||||||
|
echo 打包失败
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo ========================================
|
||||||
|
echo 打包完成!
|
||||||
|
echo 输出目录: out\win-unpacked\
|
||||||
|
echo ========================================
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
|
|
||||||
@@ -9,40 +9,6 @@ echo [1/5] 结束所有相关进程...
|
|||||||
echo 正在停止 NPQS9100...
|
echo 正在停止 NPQS9100...
|
||||||
taskkill /F /IM NPQS9100.exe 2>nul
|
taskkill /F /IM NPQS9100.exe 2>nul
|
||||||
|
|
||||||
echo 正在停止 MySQL...
|
|
||||||
taskkill /F /IM mysqld.exe 2>nul
|
|
||||||
timeout /t 2 /nobreak >nul
|
|
||||||
|
|
||||||
REM 验证 MySQL 是否真的停止了
|
|
||||||
tasklist | find /I "mysqld.exe" >nul 2>&1
|
|
||||||
if %errorlevel% equ 0 (
|
|
||||||
echo ! MySQL 进程还在运行,再次尝试...
|
|
||||||
taskkill /F /IM mysqld.exe 2>nul
|
|
||||||
timeout /t 2 /nobreak >nul
|
|
||||||
|
|
||||||
REM 再次验证
|
|
||||||
tasklist | find /I "mysqld.exe" >nul 2>&1
|
|
||||||
if %errorlevel% equ 0 (
|
|
||||||
echo ! MySQL 进程仍在运行,使用强制方法...
|
|
||||||
REM 找出所有 mysqld.exe 的 PID 并逐个杀死
|
|
||||||
for /f "tokens=2" %%a in ('tasklist ^| find /I "mysqld.exe"') do (
|
|
||||||
echo 强制结束 PID: %%a
|
|
||||||
taskkill /F /PID %%a 2>nul
|
|
||||||
)
|
|
||||||
timeout /t 2 /nobreak >nul
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
REM 最终验证
|
|
||||||
tasklist | find /I "mysqld.exe" >nul 2>&1
|
|
||||||
if %errorlevel% equ 0 (
|
|
||||||
echo ✗ 警告:MySQL 进程可能仍在运行
|
|
||||||
echo 请手动运行 build\extraResources\mysql\kill-running-port.bat
|
|
||||||
pause
|
|
||||||
) else (
|
|
||||||
echo ✓ MySQL 已完全停止
|
|
||||||
)
|
|
||||||
|
|
||||||
echo 正在停止 Java...
|
echo 正在停止 Java...
|
||||||
taskkill /F /IM java.exe 2>nul
|
taskkill /F /IM java.exe 2>nul
|
||||||
taskkill /F /IM javaw.exe 2>nul
|
taskkill /F /IM javaw.exe 2>nul
|
||||||
@@ -101,4 +67,3 @@ echo 输出目录: out\win-unpacked\
|
|||||||
echo ========================================
|
echo ========================================
|
||||||
echo.
|
echo.
|
||||||
pause
|
pause
|
||||||
|
|
||||||
|
|||||||
69
build/diagnose-startup.bat
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
@echo off
|
||||||
|
chcp 65001 >nul
|
||||||
|
echo ========================================
|
||||||
|
echo NPQS9100 启动诊断工具
|
||||||
|
echo ========================================
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo [1] 检查运行中的进程...
|
||||||
|
echo.
|
||||||
|
echo NPQS9100 进程:
|
||||||
|
tasklist | findstr /i "NPQS9100.exe"
|
||||||
|
if %errorlevel% neq 0 echo 未找到
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo MySQL 进程:
|
||||||
|
tasklist | findstr /i "mysqld.exe"
|
||||||
|
if %errorlevel% neq 0 echo 未找到
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo Java 进程:
|
||||||
|
tasklist | findstr /i "java.exe"
|
||||||
|
if %errorlevel% neq 0 echo 未找到
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo [2] 检查端口占用...
|
||||||
|
echo.
|
||||||
|
echo 3306 端口:
|
||||||
|
netstat -ano | findstr ":3306" | findstr "LISTENING"
|
||||||
|
if %errorlevel% neq 0 echo 未占用
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo 18092 端口:
|
||||||
|
netstat -ano | findstr ":18092" | findstr "LISTENING"
|
||||||
|
if %errorlevel% neq 0 echo 未占用
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo 7777 端口:
|
||||||
|
netstat -ano | findstr ":7777" | findstr "LISTENING"
|
||||||
|
if %errorlevel% neq 0 echo 未占用
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo [3] 查看最新日志...
|
||||||
|
echo.
|
||||||
|
set LOGDIR=%APPDATA%\NQPS9100\logs
|
||||||
|
echo 日志目录: %LOGDIR%
|
||||||
|
if exist "%LOGDIR%" (
|
||||||
|
echo.
|
||||||
|
echo 最新日志文件:
|
||||||
|
dir /b /o-d "%LOGDIR%\*.log" 2>nul
|
||||||
|
echo.
|
||||||
|
) else (
|
||||||
|
echo 日志目录不存在
|
||||||
|
)
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo [4] 检查 MySQL 服务...
|
||||||
|
sc query mysql9100 >nul 2>&1
|
||||||
|
if %errorlevel% equ 0 (
|
||||||
|
echo MySQL 服务存在
|
||||||
|
sc query mysql9100 | findstr "STATE"
|
||||||
|
) else (
|
||||||
|
echo MySQL 服务不存在
|
||||||
|
)
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo ========================================
|
||||||
|
echo 诊断完成
|
||||||
|
echo ========================================
|
||||||
|
pause
|
||||||
10
build/extraResources/java/.gitignore
vendored
@@ -1,10 +0,0 @@
|
|||||||
# 自动生成的配置文件
|
|
||||||
application.yml
|
|
||||||
|
|
||||||
# 运行时端口记录
|
|
||||||
.running-port
|
|
||||||
|
|
||||||
# 日志文件
|
|
||||||
logs/
|
|
||||||
*.log
|
|
||||||
|
|
||||||
@@ -1,71 +1,20 @@
|
|||||||
==========================================
|
==========================================
|
||||||
NPQS9100 Java 后端服务说明
|
NPQS9100 Java 后端服务
|
||||||
==========================================
|
==========================================
|
||||||
|
|
||||||
一、目录结构
|
目录说明
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
entrance.jar - Spring Boot 应用程序
|
entrance.jar - Spring Boot 应用程序
|
||||||
application.yml - 应用配置文件(自动生成)
|
application.yml - 应用配置文件(自动生成)
|
||||||
application.yml.template - 配置模板
|
application.yml.template - 配置模板
|
||||||
kill-java-port.bat - 智能清理Java端口占用(紧急用)
|
|
||||||
.running-port - 运行时端口记录(自动生成,勿删除)
|
|
||||||
|
|
||||||
|
|
||||||
二、自动管理
|
服务管理
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
正常情况下,Java 后端服务由主应用自动管理:
|
Java 后端服务由主应用自动管理:
|
||||||
- 应用启动时自动启动 Java 服务
|
- 应用启动时自动启动
|
||||||
- 应用关闭时自动停止 Java 服务
|
- 应用关闭时自动停止
|
||||||
- 无需手动操作
|
- 默认端口:18092(如被占用会自动切换)
|
||||||
|
|
||||||
|
|
||||||
三、端口智能管理
|
|
||||||
----------------------------------------
|
|
||||||
- Java 服务默认使用端口:18092
|
|
||||||
- 如果 18092 被占用,自动尝试:18093, 18094, ...
|
|
||||||
- 启动成功后会记录实际端口到 .running-port 文件
|
|
||||||
- kill-java-port.bat 会自动识别正确的端口进行清理
|
|
||||||
|
|
||||||
|
|
||||||
四、手动清理工具
|
|
||||||
----------------------------------------
|
|
||||||
如果应用异常退出,Java 进程可能残留,导致:
|
|
||||||
- 端口被占用,无法再次启动
|
|
||||||
- 可以运行 kill-java-port.bat 清理残留进程
|
|
||||||
|
|
||||||
使用方法:
|
|
||||||
1. 双击运行:kill-java-port.bat
|
|
||||||
2. 脚本会自动识别实际使用的端口
|
|
||||||
3. 清理完成后即可重新启动应用
|
|
||||||
|
|
||||||
|
|
||||||
五、安全说明
|
|
||||||
----------------------------------------
|
|
||||||
⚠️ 进程停止安全性:
|
|
||||||
- 应用自动停止时,只会停止应用自己启动的 Java 进程
|
|
||||||
- 通过进程引用精确停止,不会影响其他 Java 应用
|
|
||||||
- kill-java-port.bat 只清理占用特定端口的进程
|
|
||||||
- 完全不会影响您电脑上的其他 Java 程序
|
|
||||||
|
|
||||||
⭐ 端口冲突处理:
|
|
||||||
- 如果您的电脑上有其他应用占用了 18092 端口
|
|
||||||
- 本应用会自动切换到其他端口(18093, 18094...)
|
|
||||||
- kill-java-port.bat 会自动识别实际端口,精确清理
|
|
||||||
|
|
||||||
|
|
||||||
六、常见问题
|
|
||||||
----------------------------------------
|
|
||||||
Q: Java 服务无法启动?
|
|
||||||
A: 运行 kill-java-port.bat 清理残留进程
|
|
||||||
|
|
||||||
Q: 端口被占用怎么办?
|
|
||||||
A: 应用会自动切换端口,无需手动处理
|
|
||||||
|
|
||||||
Q: 如何查看 Java 日志?
|
|
||||||
A: 启动应用后,日志窗口会实时显示 Java 输出
|
|
||||||
|
|
||||||
Q: 配置文件在哪里?
|
|
||||||
A: application.yml 由应用自动生成,请勿手动修改
|
|
||||||
|
|
||||||
|
|
||||||
==========================================
|
==========================================
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
server:
|
server:
|
||||||
port: 18092
|
port: 18093
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: entrance
|
name: entrance
|
||||||
@@ -51,7 +51,7 @@ socket:
|
|||||||
port: 61000
|
port: 61000
|
||||||
|
|
||||||
webSocket:
|
webSocket:
|
||||||
port: 7777
|
port: 7778
|
||||||
|
|
||||||
#源参数下发,暂态数据默认值
|
#源参数下发,暂态数据默认值
|
||||||
Dip:
|
Dip:
|
||||||
|
|||||||
@@ -1,115 +0,0 @@
|
|||||||
@echo off
|
|
||||||
chcp 65001 >nul
|
|
||||||
color 0E
|
|
||||||
title 清理NPQS9100 Java端口占用
|
|
||||||
cls
|
|
||||||
echo ==========================================
|
|
||||||
echo 清理 NPQS9100 Java 端口占用
|
|
||||||
echo ==========================================
|
|
||||||
echo.
|
|
||||||
|
|
||||||
REM 获取Java目录(脚本所在目录)
|
|
||||||
set JAVA_HOME=%~dp0
|
|
||||||
cd /d "%JAVA_HOME%"
|
|
||||||
|
|
||||||
REM 读取实际运行的端口
|
|
||||||
set PORT_FILE=.running-port
|
|
||||||
set JAVA_PORT=
|
|
||||||
|
|
||||||
if exist "%PORT_FILE%" (
|
|
||||||
set /p JAVA_PORT=<"%PORT_FILE%"
|
|
||||||
echo [√] 检测到运行记录:端口 %JAVA_PORT%
|
|
||||||
echo.
|
|
||||||
) else (
|
|
||||||
echo [!] 未找到运行记录文件,使用默认端口 18092
|
|
||||||
echo.
|
|
||||||
set JAVA_PORT=18092
|
|
||||||
)
|
|
||||||
|
|
||||||
echo [1] 检查端口 %JAVA_PORT% 占用情况...
|
|
||||||
echo.
|
|
||||||
|
|
||||||
REM 查找占用该端口的连接
|
|
||||||
netstat -ano | findstr ":%JAVA_PORT%" > "%TEMP%\java_port.txt"
|
|
||||||
|
|
||||||
if %errorlevel% equ 0 (
|
|
||||||
echo 发现以下端口 %JAVA_PORT% 连接:
|
|
||||||
echo ----------------------------------------
|
|
||||||
type "%TEMP%\java_port.txt"
|
|
||||||
echo ----------------------------------------
|
|
||||||
echo.
|
|
||||||
|
|
||||||
echo [2] 提取进程ID并结束进程...
|
|
||||||
echo.
|
|
||||||
|
|
||||||
REM 提取所有LISTENING状态的PID
|
|
||||||
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":%JAVA_PORT%" ^| findstr "LISTENING"') do (
|
|
||||||
if not "%%a"=="0" (
|
|
||||||
echo 正在结束进程 PID: %%a
|
|
||||||
taskkill /F /PID %%a 2>nul
|
|
||||||
if errorlevel 1 (
|
|
||||||
echo [失败] 无法结束进程 %%a
|
|
||||||
) else (
|
|
||||||
echo [成功] 已结束进程 %%a
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
REM 如果还有其他状态的连接,也尝试结束
|
|
||||||
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":%JAVA_PORT%" ^| findstr /V "LISTENING"') do (
|
|
||||||
if not "%%a"=="0" (
|
|
||||||
echo 正在结束进程 PID: %%a
|
|
||||||
taskkill /F /PID %%a 2>nul
|
|
||||||
if errorlevel 1 (
|
|
||||||
echo [已结束或无权限] 进程 %%a
|
|
||||||
) else (
|
|
||||||
echo [成功] 已结束进程 %%a
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo [3] 清理完成
|
|
||||||
|
|
||||||
REM 等待2秒让进程完全释放
|
|
||||||
timeout /t 2 /nobreak >nul
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo [4] 再次检查端口 %JAVA_PORT%...
|
|
||||||
netstat -ano | findstr ":%JAVA_PORT%"
|
|
||||||
if errorlevel 1 (
|
|
||||||
echo [√] 端口 %JAVA_PORT% 已完全释放
|
|
||||||
|
|
||||||
REM 删除端口记录文件
|
|
||||||
if exist "%PORT_FILE%" (
|
|
||||||
del "%PORT_FILE%"
|
|
||||||
echo [√] 已清理端口记录文件
|
|
||||||
)
|
|
||||||
) else (
|
|
||||||
echo [!] 仍有连接存在(可能是TIME_WAIT状态,会自动释放)
|
|
||||||
)
|
|
||||||
|
|
||||||
) else (
|
|
||||||
echo [√] 没有发现占用端口 %JAVA_PORT% 的进程
|
|
||||||
|
|
||||||
REM 删除端口记录文件
|
|
||||||
if exist "%PORT_FILE%" (
|
|
||||||
del "%PORT_FILE%"
|
|
||||||
echo [√] 已清理端口记录文件
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
REM 清理临时文件
|
|
||||||
if exist "%TEMP%\java_port.txt" del "%TEMP%\java_port.txt"
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo ==========================================
|
|
||||||
echo 清理完成
|
|
||||||
echo ==========================================
|
|
||||||
echo.
|
|
||||||
echo 说明:
|
|
||||||
echo - 此脚本只清理 NPQS9100 应用使用的 Java 端口
|
|
||||||
echo - 不会影响您电脑上的其他 Java 应用
|
|
||||||
echo.
|
|
||||||
pause
|
|
||||||
|
|
||||||
@@ -1,85 +1,33 @@
|
|||||||
==========================================
|
==========================================
|
||||||
NPQS9100 MySQL 免安装版使用说明
|
NPQS9100 MySQL 数据库
|
||||||
==========================================
|
==========================================
|
||||||
|
|
||||||
一、快速开始
|
目录说明
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
1. 启动 MySQL:
|
bin/ - MySQL 可执行文件
|
||||||
双击运行: startup.bat
|
data/ - 数据库数据目录
|
||||||
(注意:不要关闭窗口,关闭会停止MySQL)
|
share/ - 共享资源文件
|
||||||
|
my.ini - MySQL 配置文件
|
||||||
2. 首次使用,如需重置密码和权限:
|
|
||||||
双击运行: reset-root-password.bat
|
|
||||||
|
|
||||||
3. 停止 MySQL:
|
|
||||||
双击运行: stop.bat
|
|
||||||
|
|
||||||
|
|
||||||
二、连接信息
|
服务管理
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
主机: 127.0.0.1 (或 localhost)
|
MySQL 服务由主应用自动管理:
|
||||||
|
- 应用启动时自动启动
|
||||||
|
- 应用关闭时自动停止
|
||||||
|
- 默认端口:3306(如被占用会自动切换)
|
||||||
|
|
||||||
|
|
||||||
|
连接信息
|
||||||
|
----------------------------------------
|
||||||
|
主机: 127.0.0.1
|
||||||
端口: 3306
|
端口: 3306
|
||||||
用户: root
|
用户: root
|
||||||
密码: njcnpqs
|
密码: njcnpqs
|
||||||
字符集: utf8mb4
|
字符集: utf8mb4
|
||||||
|
|
||||||
|
|
||||||
三、脚本说明
|
|
||||||
----------------------------------------
|
|
||||||
startup.bat - 启动 MySQL 服务
|
|
||||||
stop.bat - 正常停止 MySQL 服务
|
|
||||||
reset-root-password.bat - 重置root密码和权限(解决1130错误)
|
|
||||||
kill-running-port.bat - 智能清理应用实际使用的端口(自动识别3306/3307/...)
|
|
||||||
my.ini - MySQL 配置文件
|
|
||||||
.running-port - 运行时端口记录(自动生成,勿删除)
|
|
||||||
|
|
||||||
bin/ - MySQL 可执行文件
|
|
||||||
data/ - 数据库数据目录
|
|
||||||
share/ - 共享资源
|
|
||||||
|
|
||||||
⚠️ 安全说明:
|
|
||||||
- 应用自动停止MySQL时,只会停止应用自己启动的MySQL进程
|
|
||||||
- 不会影响您电脑上安装的其他MySQL服务
|
|
||||||
- kill-running-port.bat 会读取 .running-port 文件,精确清理实际使用的端口
|
|
||||||
- 如果3306被占用,应用会自动使用3307,kill-running-port.bat 会智能识别
|
|
||||||
|
|
||||||
⚙️ 停止机制:
|
|
||||||
- 应用关闭时会自动使用 mysqladmin shutdown 优雅停止MySQL
|
|
||||||
- 如果优雅停止失败,会自动尝试强制停止
|
|
||||||
- 整个停止过程最多12秒,确保MySQL完全关闭
|
|
||||||
|
|
||||||
⭐ 端口智能管理:
|
|
||||||
- 应用启动时自动检测可用端口(3306 → 3307 → 3308...)
|
|
||||||
- 启动成功后会记录实际端口到 .running-port 文件
|
|
||||||
- 使用 kill-running-port.bat 可自动清理正确的端口
|
|
||||||
|
|
||||||
|
|
||||||
四、注意事项
|
|
||||||
----------------------------------------
|
|
||||||
1. 启动后不要关闭命令行窗口,关闭窗口会停止 MySQL
|
|
||||||
2. 正常停止请使用 stop.bat
|
|
||||||
3. 如果出现 1130 或密码错误,运行 reset-root-password.bat
|
|
||||||
4. 如果端口被占用无法启动,运行 kill-3306.bat
|
|
||||||
5. 默认密码是 njcnpqs,不要随意修改
|
|
||||||
|
|
||||||
|
|
||||||
五、常见问题
|
|
||||||
----------------------------------------
|
|
||||||
Q: 连接提示 1130 错误或密码错误?
|
|
||||||
A: 运行 reset-root-password.bat 重置权限
|
|
||||||
|
|
||||||
Q: 启动失败或端口被占用?
|
|
||||||
A: 运行 kill-running-port.bat 清理端口(自动识别正确端口)
|
|
||||||
|
|
||||||
Q: 如何重置密码?
|
|
||||||
A: 运行 reset-root-password.bat(密码会重置为 njcnpqs)
|
|
||||||
|
|
||||||
Q: 数据在哪里?
|
|
||||||
A: 所有数据库数据在 data/ 目录下
|
|
||||||
|
|
||||||
|
|
||||||
==========================================
|
==========================================
|
||||||
南京灿能电气自动化有限公司
|
南京灿能电气自动化有限公司
|
||||||
2025
|
2025
|
||||||
==========================================
|
==========================================
|
||||||
|
|
||||||
|
|||||||
34
build/extraResources/mysql/init_pwd.bat
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
@echo off
|
||||||
|
chcp 65001 >nul
|
||||||
|
cd /d %~dp0
|
||||||
|
|
||||||
|
taskkill /F /IM mysqld.exe 2>nul
|
||||||
|
timeout /t 2 /nobreak >nul
|
||||||
|
|
||||||
|
rmdir /s /q data 2>nul
|
||||||
|
mkdir data
|
||||||
|
|
||||||
|
echo 初始化数据库...
|
||||||
|
bin\mysqld.exe --defaults-file=my.ini --initialize-insecure --console
|
||||||
|
|
||||||
|
echo 启动 MySQL...
|
||||||
|
start /B bin\mysqld.exe --defaults-file=my.ini
|
||||||
|
timeout /t 8 /nobreak >nul
|
||||||
|
|
||||||
|
echo 设置密码...
|
||||||
|
bin\mysql.exe -h 127.0.0.1 -P 3306 -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'njcnpqs'; CREATE USER IF NOT EXISTS 'root'@'127.0.0.1' IDENTIFIED BY 'njcnpqs'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' WITH GRANT OPTION; FLUSH PRIVILEGES;"
|
||||||
|
|
||||||
|
if %errorlevel% NEQ 0 (
|
||||||
|
echo 第一次失败,重试...
|
||||||
|
timeout /t 3 /nobreak >nul
|
||||||
|
bin\mysql.exe -h localhost -P 3306 -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'njcnpqs'; CREATE USER IF NOT EXISTS 'root'@'127.0.0.1' IDENTIFIED BY 'njcnpqs'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' WITH GRANT OPTION; FLUSH PRIVILEGES;"
|
||||||
|
)
|
||||||
|
|
||||||
|
taskkill /F /IM mysqld.exe 2>nul
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ==========================================
|
||||||
|
echo 完成!密码: njcnpqs
|
||||||
|
echo ==========================================
|
||||||
|
pause
|
||||||
|
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
@echo off
|
|
||||||
chcp 65001 >nul
|
|
||||||
color 0C
|
|
||||||
title 清理NPQS9100 MySQL端口占用
|
|
||||||
cls
|
|
||||||
echo ==========================================
|
|
||||||
echo 清理 NPQS9100 MySQL 端口占用
|
|
||||||
echo ==========================================
|
|
||||||
echo.
|
|
||||||
|
|
||||||
REM 获取MySQL目录(脚本所在目录)
|
|
||||||
set MYSQL_HOME=%~dp0
|
|
||||||
cd /d "%MYSQL_HOME%"
|
|
||||||
|
|
||||||
REM 读取实际运行的端口
|
|
||||||
set PORT_FILE=.running-port
|
|
||||||
set MYSQL_PORT=
|
|
||||||
|
|
||||||
if exist "%PORT_FILE%" (
|
|
||||||
set /p MYSQL_PORT=<"%PORT_FILE%"
|
|
||||||
echo [√] 检测到运行记录:端口 %MYSQL_PORT%
|
|
||||||
echo.
|
|
||||||
) else (
|
|
||||||
echo [!] 未找到运行记录文件,使用默认端口 3306
|
|
||||||
echo.
|
|
||||||
set MYSQL_PORT=3306
|
|
||||||
)
|
|
||||||
|
|
||||||
echo [1] 检查端口 %MYSQL_PORT% 占用情况...
|
|
||||||
echo.
|
|
||||||
|
|
||||||
REM 查找占用该端口的连接
|
|
||||||
netstat -ano | findstr ":%MYSQL_PORT%" > "%TEMP%\mysql_port.txt"
|
|
||||||
|
|
||||||
if %errorlevel% equ 0 (
|
|
||||||
echo 发现以下端口 %MYSQL_PORT% 连接:
|
|
||||||
echo ----------------------------------------
|
|
||||||
type "%TEMP%\mysql_port.txt"
|
|
||||||
echo ----------------------------------------
|
|
||||||
echo.
|
|
||||||
|
|
||||||
echo [2] 提取进程ID并结束进程...
|
|
||||||
echo.
|
|
||||||
|
|
||||||
REM 提取所有LISTENING状态的PID
|
|
||||||
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":%MYSQL_PORT%" ^| findstr "LISTENING"') do (
|
|
||||||
if not "%%a"=="0" (
|
|
||||||
echo 正在结束进程 PID: %%a
|
|
||||||
taskkill /F /PID %%a 2>nul
|
|
||||||
if errorlevel 1 (
|
|
||||||
echo [失败] 无法结束进程 %%a
|
|
||||||
) else (
|
|
||||||
echo [成功] 已结束进程 %%a
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
REM 如果还有其他状态的连接,也尝试结束
|
|
||||||
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":%MYSQL_PORT%" ^| findstr /V "LISTENING"') do (
|
|
||||||
if not "%%a"=="0" (
|
|
||||||
echo 正在结束进程 PID: %%a
|
|
||||||
taskkill /F /PID %%a 2>nul
|
|
||||||
if errorlevel 1 (
|
|
||||||
echo [已结束或无权限] 进程 %%a
|
|
||||||
) else (
|
|
||||||
echo [成功] 已结束进程 %%a
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo [3] 清理完成
|
|
||||||
|
|
||||||
REM 等待2秒让进程完全释放
|
|
||||||
timeout /t 2 /nobreak >nul
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo [4] 再次检查端口 %MYSQL_PORT%...
|
|
||||||
netstat -ano | findstr ":%MYSQL_PORT%"
|
|
||||||
if errorlevel 1 (
|
|
||||||
echo [√] 端口 %MYSQL_PORT% 已完全释放
|
|
||||||
|
|
||||||
REM 删除端口记录文件
|
|
||||||
if exist "%PORT_FILE%" (
|
|
||||||
del "%PORT_FILE%"
|
|
||||||
echo [√] 已清理端口记录文件
|
|
||||||
)
|
|
||||||
) else (
|
|
||||||
echo [!] 仍有连接存在(可能是TIME_WAIT状态,会自动释放)
|
|
||||||
)
|
|
||||||
|
|
||||||
) else (
|
|
||||||
echo [√] 没有发现占用端口 %MYSQL_PORT% 的进程
|
|
||||||
|
|
||||||
REM 删除端口记录文件
|
|
||||||
if exist "%PORT_FILE%" (
|
|
||||||
del "%PORT_FILE%"
|
|
||||||
echo [√] 已清理端口记录文件
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
REM 清理临时文件
|
|
||||||
if exist "%TEMP%\mysql_port.txt" del "%TEMP%\mysql_port.txt"
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo ==========================================
|
|
||||||
echo 清理完成
|
|
||||||
echo ==========================================
|
|
||||||
echo.
|
|
||||||
echo 说明:
|
|
||||||
echo - 此脚本只清理 NPQS9100 应用使用的 MySQL 端口
|
|
||||||
echo - 不会影响您电脑上的其他 MySQL 服务
|
|
||||||
echo.
|
|
||||||
pause
|
|
||||||
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
ALTER USER IF EXISTS 'root'@'localhost' IDENTIFIED BY 'njcnpqs';
|
|
||||||
CREATE USER IF NOT EXISTS 'root'@'127.0.0.1' IDENTIFIED BY 'njcnpqs';
|
|
||||||
GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' WITH GRANT OPTION;
|
|
||||||
CREATE USER IF NOT EXISTS 'root'@'%' IDENTIFIED BY 'njcnpqs';
|
|
||||||
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
|
|
||||||
FLUSH PRIVILEGES;
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
@echo off
|
|
||||||
chcp 65001 >nul
|
|
||||||
color 0B
|
|
||||||
title Reset MySQL Root Password
|
|
||||||
cls
|
|
||||||
echo ==========================================
|
|
||||||
echo Reset MySQL Root Password
|
|
||||||
echo ==========================================
|
|
||||||
echo.
|
|
||||||
echo This script will reset root password and grant 127.0.0.1 access
|
|
||||||
echo.
|
|
||||||
echo IMPORTANT: Close any running MySQL windows first!
|
|
||||||
echo.
|
|
||||||
pause
|
|
||||||
|
|
||||||
set MYSQL_HOME=%cd%
|
|
||||||
set password=njcnpqs
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo [1] Stopping MySQL...
|
|
||||||
taskkill /F /IM mysqld.exe >nul 2>&1
|
|
||||||
timeout /t 2 >nul
|
|
||||||
echo Done.
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo [2] Creating init file...
|
|
||||||
(
|
|
||||||
echo ALTER USER IF EXISTS 'root'@'localhost' IDENTIFIED BY '%password%';
|
|
||||||
echo CREATE USER IF NOT EXISTS 'root'@'127.0.0.1' IDENTIFIED BY '%password%';
|
|
||||||
echo GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' WITH GRANT OPTION;
|
|
||||||
echo CREATE USER IF NOT EXISTS 'root'@'%%' IDENTIFIED BY '%password%';
|
|
||||||
echo GRANT ALL PRIVILEGES ON *.* TO 'root'@'%%' WITH GRANT OPTION;
|
|
||||||
echo FLUSH PRIVILEGES;
|
|
||||||
) > "%MYSQL_HOME%\reset-init.sql"
|
|
||||||
echo Done.
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo [3] Starting MySQL with init-file...
|
|
||||||
echo This will take about 30 seconds...
|
|
||||||
echo.
|
|
||||||
|
|
||||||
cd /d "%MYSQL_HOME%"
|
|
||||||
"%MYSQL_HOME%\bin\mysqld.exe" --defaults-file="%MYSQL_HOME%\my.ini" --init-file="%MYSQL_HOME%\reset-init.sql" --console
|
|
||||||
|
|
||||||
REM The above command runs in foreground and will exit when you press Ctrl+C
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo MySQL has stopped.
|
|
||||||
echo.
|
|
||||||
if exist "%MYSQL_HOME%\reset-init.sql" del "%MYSQL_HOME%\reset-init.sql"
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo ==========================================
|
|
||||||
echo Password reset completed!
|
|
||||||
echo ==========================================
|
|
||||||
echo.
|
|
||||||
echo Connection info:
|
|
||||||
echo Host: 127.0.0.1
|
|
||||||
echo Port: 3306
|
|
||||||
echo User: root
|
|
||||||
echo Password: %password%
|
|
||||||
echo.
|
|
||||||
echo Now you can run startup.bat to start MySQL normally
|
|
||||||
echo.
|
|
||||||
pause
|
|
||||||
|
|
||||||
BIN
build/extraResources/templates/比对检测报告/V1.0.0/base-template.docx
Normal file
BIN
build/extraResources/templates/比对检测报告/V1.0.0/data-template.docx
Normal file
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 930 B |
|
Before Width: | Height: | Size: 87 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 254 KiB |
|
Before Width: | Height: | Size: 7.1 KiB |
BIN
build/icons/favicon.ico
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
build/icons/icon-reference.ico
Normal file
|
After Width: | Height: | Size: 256 KiB |
|
Before Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 87 KiB |
|
Before Width: | Height: | Size: 26 KiB |
143
build/rollback.bat
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
@echo off
|
||||||
|
chcp 65001 >nul
|
||||||
|
echo ========================================
|
||||||
|
echo NPQS9100 回滚工具
|
||||||
|
echo ========================================
|
||||||
|
echo.
|
||||||
|
echo 【重要提示】
|
||||||
|
echo 本工具用于回滚上次升级的内容
|
||||||
|
echo 回滚后将恢复到升级前的状态
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo [1/5] 停止 NPQS9100 进程...
|
||||||
|
taskkill /F /IM NPQS9100.exe 2>nul
|
||||||
|
if %errorlevel% equ 0 (
|
||||||
|
echo NPQS9100 已停止
|
||||||
|
timeout /t 2 /nobreak >nul
|
||||||
|
) else (
|
||||||
|
echo NPQS9100 未运行
|
||||||
|
)
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo [2/5] 检查备份文件...
|
||||||
|
set hasBackup=0
|
||||||
|
|
||||||
|
if exist backup\app.asar (
|
||||||
|
echo 发现前端备份(app.asar)
|
||||||
|
set hasBackup=1
|
||||||
|
)
|
||||||
|
|
||||||
|
if exist backup\app.asar.unpacked (
|
||||||
|
echo 发现前端备份(app.asar.unpacked)
|
||||||
|
set hasBackup=1
|
||||||
|
)
|
||||||
|
|
||||||
|
if exist backup\entrance.jar (
|
||||||
|
echo 发现后端备份
|
||||||
|
set hasBackup=1
|
||||||
|
)
|
||||||
|
|
||||||
|
if exist mysql\data_backup (
|
||||||
|
echo 发现数据库备份
|
||||||
|
set hasBackup=1
|
||||||
|
)
|
||||||
|
|
||||||
|
if %hasBackup%==0 (
|
||||||
|
echo 未发现任何备份文件!
|
||||||
|
echo 无法执行回滚操作
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo [3/5] 回滚前端...
|
||||||
|
set frontendRollback=0
|
||||||
|
|
||||||
|
REM 回滚 app.asar
|
||||||
|
if exist backup\app.asar (
|
||||||
|
echo 正在恢复 app.asar...
|
||||||
|
copy /Y backup\app.asar resources\app.asar >nul 2>&1
|
||||||
|
if %errorlevel% equ 0 (
|
||||||
|
echo app.asar 已回滚
|
||||||
|
set frontendRollback=1
|
||||||
|
) else (
|
||||||
|
echo app.asar 回滚失败
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
REM 回滚 app.asar.unpacked
|
||||||
|
if exist backup\app.asar.unpacked (
|
||||||
|
echo 正在恢复 app.asar.unpacked...
|
||||||
|
if exist resources\app.asar.unpacked (
|
||||||
|
rmdir /s /q resources\app.asar.unpacked 2>nul
|
||||||
|
)
|
||||||
|
xcopy backup\app.asar.unpacked resources\app.asar.unpacked\ /E /I /Y /Q >nul 2>&1
|
||||||
|
if %errorlevel% equ 0 (
|
||||||
|
echo app.asar.unpacked 已回滚
|
||||||
|
set frontendRollback=1
|
||||||
|
) else (
|
||||||
|
echo app.asar.unpacked 回滚失败
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if %frontendRollback%==0 (
|
||||||
|
echo 无前端备份,跳过
|
||||||
|
)
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo [4/5] 回滚后端...
|
||||||
|
if exist backup\entrance.jar (
|
||||||
|
echo 正在恢复 JAR 文件...
|
||||||
|
copy /Y backup\entrance.jar resources\extraResources\java\entrance.jar >nul 2>&1
|
||||||
|
if %errorlevel% equ 0 (
|
||||||
|
echo 后端已回滚
|
||||||
|
) else (
|
||||||
|
echo 后端回滚失败
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
) else (
|
||||||
|
echo 无后端备份,跳过
|
||||||
|
)
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo [5/5] 回滚数据库...
|
||||||
|
if exist mysql\data_backup (
|
||||||
|
echo 是否回滚数据库?(数据库回滚会丢失升级后的数据!)
|
||||||
|
echo [Y] 是 [N] 否
|
||||||
|
choice /C YN /N /M "请选择:"
|
||||||
|
if errorlevel 2 (
|
||||||
|
echo 已跳过数据库回滚
|
||||||
|
) else (
|
||||||
|
echo 正在回滚数据库...
|
||||||
|
if exist mysql\data (
|
||||||
|
rmdir /s /q mysql\data 2>nul
|
||||||
|
)
|
||||||
|
xcopy mysql\data_backup mysql\data\ /E /I /Y /Q >nul 2>&1
|
||||||
|
if %errorlevel% equ 0 (
|
||||||
|
echo 数据库已回滚
|
||||||
|
) else (
|
||||||
|
echo 数据库回滚失败
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) else (
|
||||||
|
echo 无数据库备份,跳过
|
||||||
|
)
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo ========================================
|
||||||
|
echo 回滚完成!
|
||||||
|
echo ========================================
|
||||||
|
echo.
|
||||||
|
echo 您现在可以启动 NPQS9100 了
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
|
|
||||||
227
build/upgrade.bat
Normal file
@@ -0,0 +1,227 @@
|
|||||||
|
@echo off
|
||||||
|
chcp 65001 >nul
|
||||||
|
echo ========================================
|
||||||
|
echo NPQS9100 升级工具
|
||||||
|
echo ========================================
|
||||||
|
echo.
|
||||||
|
|
||||||
|
REM 检查并创建 upgrade 目录
|
||||||
|
if not exist upgrade (
|
||||||
|
mkdir upgrade
|
||||||
|
echo 【首次使用】已自动创建 upgrade 目录
|
||||||
|
echo.
|
||||||
|
echo 请将升级文件放入 upgrade 目录:
|
||||||
|
echo - app.asar (前端升级包 - 文件)
|
||||||
|
echo - app.asar.unpacked\ (前端升级包 - 文件夹)
|
||||||
|
echo - entrance.jar (后端升级包)
|
||||||
|
echo.
|
||||||
|
echo 放置完成后,重新运行本脚本即可升级
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
|
exit /b 0
|
||||||
|
)
|
||||||
|
|
||||||
|
REM 检查是否有升级文件
|
||||||
|
set hasUpgrade=0
|
||||||
|
if exist upgrade\app.asar set hasUpgrade=1
|
||||||
|
if exist upgrade\app.asar.unpacked set hasUpgrade=1
|
||||||
|
if exist upgrade\entrance.jar set hasUpgrade=1
|
||||||
|
|
||||||
|
if %hasUpgrade%==0 (
|
||||||
|
echo 【提示】upgrade 目录为空!
|
||||||
|
echo.
|
||||||
|
echo 请将升级文件放入 upgrade 目录:
|
||||||
|
echo - app.asar (前端升级包 - 文件)
|
||||||
|
echo - app.asar.unpacked\ (前端升级包 - 文件夹)
|
||||||
|
echo - entrance.jar (后端升级包)
|
||||||
|
echo.
|
||||||
|
echo 放置完成后,重新运行本脚本即可升级
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
|
exit /b 0
|
||||||
|
)
|
||||||
|
|
||||||
|
echo 【检测到升级文件】
|
||||||
|
if exist upgrade\app.asar echo - 前端升级(asar文件): upgrade\app.asar
|
||||||
|
if exist upgrade\app.asar.unpacked echo - 前端升级(unpacked文件夹): upgrade\app.asar.unpacked\
|
||||||
|
if exist upgrade\entrance.jar echo - 后端升级: upgrade\entrance.jar
|
||||||
|
echo.
|
||||||
|
echo 【重要提示】
|
||||||
|
echo 1. 升级前会自动备份当前版本
|
||||||
|
echo 2. 如升级失败可运行 rollback.bat 回滚
|
||||||
|
echo 3. 数据库会自动备份到 mysql\data_backup\
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo [1/6] 停止 NPQS9100 进程...
|
||||||
|
taskkill /F /IM NPQS9100.exe 2>nul
|
||||||
|
if %errorlevel% equ 0 (
|
||||||
|
echo NPQS9100 已停止
|
||||||
|
timeout /t 2 /nobreak >nul
|
||||||
|
) else (
|
||||||
|
echo NPQS9100 未运行
|
||||||
|
)
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo [2/6] 备份当前版本(用于回滚)...
|
||||||
|
if not exist backup mkdir backup
|
||||||
|
|
||||||
|
REM 备份前端(app.asar 和 app.asar.unpacked)
|
||||||
|
if exist resources\app.asar (
|
||||||
|
echo 正在备份前端 app.asar...
|
||||||
|
if not exist backup mkdir backup
|
||||||
|
copy /Y resources\app.asar backup\app.asar >nul 2>&1
|
||||||
|
if %errorlevel% equ 0 (
|
||||||
|
echo app.asar 备份完成
|
||||||
|
) else (
|
||||||
|
echo app.asar 备份失败
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if exist resources\app.asar.unpacked (
|
||||||
|
echo 正在备份前端 app.asar.unpacked...
|
||||||
|
if exist backup\app.asar.unpacked (
|
||||||
|
rmdir /s /q backup\app.asar.unpacked 2>nul
|
||||||
|
)
|
||||||
|
xcopy resources\app.asar.unpacked backup\app.asar.unpacked\ /E /I /Y /Q >nul 2>&1
|
||||||
|
if %errorlevel% equ 0 (
|
||||||
|
echo app.asar.unpacked 备份完成
|
||||||
|
) else (
|
||||||
|
echo app.asar.unpacked 备份失败
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
REM 备份后端
|
||||||
|
if exist resources\extraResources\java\entrance.jar (
|
||||||
|
echo 正在备份后端...
|
||||||
|
copy /Y resources\extraResources\java\entrance.jar backup\entrance.jar >nul 2>&1
|
||||||
|
if %errorlevel% equ 0 (
|
||||||
|
echo 后端备份完成
|
||||||
|
) else (
|
||||||
|
echo 后端备份失败
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
REM 备份数据库
|
||||||
|
if exist mysql\data (
|
||||||
|
echo 正在备份数据库...
|
||||||
|
if exist mysql\data_backup (
|
||||||
|
rmdir /s /q mysql\data_backup 2>nul
|
||||||
|
)
|
||||||
|
xcopy mysql\data mysql\data_backup\ /E /I /Y /Q >nul 2>&1
|
||||||
|
if %errorlevel% equ 0 (
|
||||||
|
echo 数据库备份完成
|
||||||
|
) else (
|
||||||
|
echo 数据库备份失败,请手动备份后继续
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo [3/6] 记录版本信息...
|
||||||
|
if not exist backup\version.txt (
|
||||||
|
echo 备份时间: %date% %time% > backup\version.txt
|
||||||
|
echo 升级前版本备份 >> backup\version.txt
|
||||||
|
) else (
|
||||||
|
echo 上次备份时间: %date% %time% >> backup\version.txt
|
||||||
|
)
|
||||||
|
echo 版本信息已记录
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo [4/6] 升级前端...
|
||||||
|
set frontendUpgraded=0
|
||||||
|
|
||||||
|
REM 升级 app.asar
|
||||||
|
if exist upgrade\app.asar (
|
||||||
|
echo 正在替换 app.asar...
|
||||||
|
copy /Y upgrade\app.asar resources\app.asar >nul 2>&1
|
||||||
|
if %errorlevel% equ 0 (
|
||||||
|
echo app.asar 升级完成
|
||||||
|
set frontendUpgraded=1
|
||||||
|
) else (
|
||||||
|
echo app.asar 升级失败,正在回滚...
|
||||||
|
if exist backup\app.asar (
|
||||||
|
copy /Y backup\app.asar resources\app.asar >nul 2>&1
|
||||||
|
echo 已回滚到升级前版本
|
||||||
|
)
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
REM 升级 app.asar.unpacked
|
||||||
|
if exist upgrade\app.asar.unpacked (
|
||||||
|
echo 正在替换 app.asar.unpacked...
|
||||||
|
if exist resources\app.asar.unpacked (
|
||||||
|
rmdir /s /q resources\app.asar.unpacked 2>nul
|
||||||
|
)
|
||||||
|
xcopy upgrade\app.asar.unpacked resources\app.asar.unpacked\ /E /I /Y /Q >nul 2>&1
|
||||||
|
if %errorlevel% equ 0 (
|
||||||
|
echo app.asar.unpacked 升级完成
|
||||||
|
set frontendUpgraded=1
|
||||||
|
) else (
|
||||||
|
echo app.asar.unpacked 升级失败,正在回滚...
|
||||||
|
if exist backup\app.asar.unpacked (
|
||||||
|
rmdir /s /q resources\app.asar.unpacked 2>nul
|
||||||
|
xcopy backup\app.asar.unpacked resources\app.asar.unpacked\ /E /I /Y /Q >nul 2>&1
|
||||||
|
echo 已回滚到升级前版本
|
||||||
|
)
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if %frontendUpgraded%==0 (
|
||||||
|
echo 无前端升级包,跳过
|
||||||
|
)
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo [5/6] 升级后端...
|
||||||
|
if exist upgrade\entrance.jar (
|
||||||
|
echo 正在替换 JAR 文件...
|
||||||
|
copy /Y upgrade\entrance.jar resources\extraResources\java\entrance.jar >nul 2>&1
|
||||||
|
if %errorlevel% equ 0 (
|
||||||
|
echo 后端升级完成
|
||||||
|
) else (
|
||||||
|
echo 后端升级失败,正在回滚...
|
||||||
|
if exist backup\entrance.jar (
|
||||||
|
copy /Y backup\entrance.jar resources\extraResources\java\entrance.jar >nul 2>&1
|
||||||
|
echo 已回滚到升级前版本
|
||||||
|
)
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
) else (
|
||||||
|
echo 无后端升级包,跳过
|
||||||
|
)
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo [6/6] 记录升级日志...
|
||||||
|
if not exist logs mkdir logs
|
||||||
|
echo ========================================== >> logs\upgrade.log
|
||||||
|
echo 升级时间: %date% %time% >> logs\upgrade.log
|
||||||
|
if exist upgrade\dist (
|
||||||
|
echo 升级内容: 前端 >> logs\upgrade.log
|
||||||
|
)
|
||||||
|
if exist upgrade\entrance.jar (
|
||||||
|
echo 升级内容: 后端 >> logs\upgrade.log
|
||||||
|
)
|
||||||
|
echo ========================================== >> logs\upgrade.log
|
||||||
|
echo 升级日志已记录
|
||||||
|
echo.
|
||||||
|
|
||||||
|
echo ========================================
|
||||||
|
echo 升级完成!
|
||||||
|
echo ========================================
|
||||||
|
echo.
|
||||||
|
echo 【提示】
|
||||||
|
echo 1. 如需回滚,请运行 rollback.bat
|
||||||
|
echo 2. 升级文件已使用,可删除 upgrade 目录
|
||||||
|
echo.
|
||||||
|
echo 您现在可以启动 NPQS9100 应用。
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
|
|
||||||
|
|
||||||
20
build/upgrade/README.txt
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# 升级包放置目录
|
||||||
|
|
||||||
|
## 使用方法
|
||||||
|
|
||||||
|
1. 将升级文件放入此目录:
|
||||||
|
- app.asar (前端升级包 - 文件)
|
||||||
|
- app.asar.unpacked/ (前端升级包 - 文件夹)
|
||||||
|
- entrance.jar (后端升级包)
|
||||||
|
|
||||||
|
2. 双击运行根目录的 upgrade.bat 脚本
|
||||||
|
|
||||||
|
3. 升级完成后重启应用
|
||||||
|
|
||||||
|
## 注意事项
|
||||||
|
|
||||||
|
- 可以只放前端或只放后端,支持单独升级
|
||||||
|
- 升级前会自动备份到 backup/ 目录
|
||||||
|
- 如果升级失败,运行 rollback.bat 可回滚
|
||||||
|
|
||||||
|
详细说明请参考:README-升级回滚.txt
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
"directories": {
|
"directories": {
|
||||||
"output": "out"
|
"output": "out"
|
||||||
},
|
},
|
||||||
|
"npmRebuild": false,
|
||||||
"asar": true,
|
"asar": true,
|
||||||
"asarUnpack": [
|
"asarUnpack": [
|
||||||
"public/images/**/*"
|
"public/images/**/*"
|
||||||
@@ -22,13 +23,13 @@
|
|||||||
],
|
],
|
||||||
"extraResources": [
|
"extraResources": [
|
||||||
{
|
{
|
||||||
"from": "build/extraResources/dll",
|
"from": "build/extraResources/java",
|
||||||
"to": "extraResources/dll",
|
"to": "extraResources/java",
|
||||||
"filter": ["**/*"]
|
"filter": ["**/*"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"from": "build/extraResources/java",
|
"from": "build/extraResources/templates",
|
||||||
"to": "extraResources/java",
|
"to": "extraResources/templates",
|
||||||
"filter": ["**/*"]
|
"filter": ["**/*"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -51,9 +52,30 @@
|
|||||||
"from": "build/extraResources/jre",
|
"from": "build/extraResources/jre",
|
||||||
"to": "jre",
|
"to": "jre",
|
||||||
"filter": ["**/*"]
|
"filter": ["**/*"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": "build/upgrade",
|
||||||
|
"to": "upgrade",
|
||||||
|
"filter": ["**/*"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": "build/upgrade.bat",
|
||||||
|
"to": "upgrade.bat"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": "build/rollback.bat",
|
||||||
|
"to": "rollback.bat"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": "build/README-升级回滚.txt",
|
||||||
|
"to": "README-升级回滚.txt"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"win": {
|
"win": {
|
||||||
|
"icon": "build/icons/icon.ico",
|
||||||
|
"requestedExecutionLevel": "requireAdministrator",
|
||||||
|
"signAndEditExecutable": false,
|
||||||
|
"verifyUpdateCodeSignature": false,
|
||||||
"artifactName": "${productName}-${os}-${version}-${arch}.${ext}",
|
"artifactName": "${productName}-${os}-${version}-${arch}.${ext}",
|
||||||
"target": [
|
"target": [
|
||||||
{
|
{
|
||||||
@@ -62,5 +84,16 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"nsis": {
|
||||||
|
"oneClick": false,
|
||||||
|
"allowElevation": true,
|
||||||
|
"allowToChangeInstallationDirectory": true,
|
||||||
|
"installerIcon": "build/icons/icon.ico",
|
||||||
|
"uninstallerIcon": "build/icons/icon.ico",
|
||||||
|
"installerHeaderIcon": "build/icons/icon.ico",
|
||||||
|
"createDesktopShortcut": true,
|
||||||
|
"createStartMenuShortcut": true,
|
||||||
|
"shortcutName": "NPQS9100"
|
||||||
|
},
|
||||||
"compression": "store"
|
"compression": "store"
|
||||||
}
|
}
|
||||||
|
|||||||
874
doc/NPQS-9100绿色包完整指南.md
Normal file
@@ -0,0 +1,874 @@
|
|||||||
|
# NPQS-9100 绿色包完整指南
|
||||||
|
|
||||||
|
本指南包含绿色包的打包、使用、升级和维护的完整说明。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📋 目录
|
||||||
|
|
||||||
|
- [一、产品说明](#一产品说明)
|
||||||
|
- [七、用户关心的文件](#七用户关心的文件重要)⭐
|
||||||
|
- [二、打包指南](#二打包指南)
|
||||||
|
- [三、启动流程](#三启动流程)
|
||||||
|
- [四、升级指南](#四升级指南)
|
||||||
|
- [五、测试清单](#五测试清单)
|
||||||
|
- [六、常见问题](#六常见问题)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 一、产品说明
|
||||||
|
|
||||||
|
### 📦 产品特性
|
||||||
|
|
||||||
|
绿色包是一个**免安装便携版**,包含:
|
||||||
|
- ✅ 应用本体(Electron + Vue 3)
|
||||||
|
- ✅ MySQL 数据库(免安装版,支持动态端口)
|
||||||
|
- ✅ Java 运行环境(JRE 8)
|
||||||
|
- ✅ Spring Boot 后端服务(entrance.jar)
|
||||||
|
- ✅ 智能启动流程(端口检测、Loading界面)
|
||||||
|
- ✅ **一键升级回滚机制** ⭐
|
||||||
|
|
||||||
|
**用户体验**:解压即用,双击启动,无需任何配置
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 🎯 核心功能
|
||||||
|
|
||||||
|
#### **1. 智能端口检测**
|
||||||
|
- MySQL 端口:从 3306 开始自动检测(最多 100 个)
|
||||||
|
- Java 端口:从 18092 开始自动检测(最多 100 个)
|
||||||
|
- 自动更新配置文件
|
||||||
|
|
||||||
|
#### **2. 盘符自动识别**
|
||||||
|
- 应用在 C 盘 → 数据目录:`C:\NPQS9100_Data\`
|
||||||
|
- 应用在 D 盘 → 数据目录:`D:\NPQS9100_Data\`
|
||||||
|
- 自动创建所有必要的子目录
|
||||||
|
|
||||||
|
#### **3. Loading 界面**
|
||||||
|
- 紫色渐变背景
|
||||||
|
- 流畅的进度条动画(0% → 100%)
|
||||||
|
- 实时状态文字更新
|
||||||
|
- 显示检测到的端口号和数据目录路径
|
||||||
|
|
||||||
|
#### **4. 热更新机制** ⭐
|
||||||
|
- 前端可独立升级
|
||||||
|
- 后端可独立升级
|
||||||
|
- 自动备份,支持一键回滚
|
||||||
|
- 数据库数据完全保留
|
||||||
|
|
||||||
|
#### **5. 简化配置管理**
|
||||||
|
- 基于环境变量的配置方案
|
||||||
|
- 需要修改配置时重新打包前端(upgrade.bat 升级)
|
||||||
|
- 保证稳定性和可靠性
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 📁 目录结构
|
||||||
|
|
||||||
|
```
|
||||||
|
win-unpacked/ # 绿色版目录(约 650-800 MB)
|
||||||
|
├── NPQS9100.exe # 主程序(双击运行)⭐
|
||||||
|
├── NPQS9100-启动器.bat # 管理员启动器(备用)
|
||||||
|
├── upgrade.bat # 升级工具 ⭐
|
||||||
|
├── rollback.bat # 回滚工具 ⭐
|
||||||
|
├── uninstall-mysql-service.bat # MySQL 服务卸载工具
|
||||||
|
├── 使用说明.txt # 使用手册
|
||||||
|
├── README-升级回滚.txt # 升级说明
|
||||||
|
├── upgrade/ # 升级包目录(首次使用自动创建)
|
||||||
|
├── backup/ # 自动备份目录
|
||||||
|
│ ├── dist/ # 前端备份
|
||||||
|
│ ├── entrance.jar # 后端备份
|
||||||
|
│ └── version.txt # 版本记录
|
||||||
|
├── resources/
|
||||||
|
│ ├── app.asar # Electron 主代码(加密)
|
||||||
|
│ ├── app.asar.unpacked/
|
||||||
|
│ │ └── public/
|
||||||
|
│ │ └── dist/ # 前端代码 ⭐ 可替换
|
||||||
|
│ └── extraResources/
|
||||||
|
│ ├── dll/
|
||||||
|
│ └── java/
|
||||||
|
│ ├── entrance.jar # 后端 JAR ⭐ 可替换
|
||||||
|
│ ├── application.yml.template
|
||||||
|
│ └── application.yml # 运行时生成
|
||||||
|
├── scripts/ # 启动管理脚本(⚠️ 不要修改)
|
||||||
|
│ ├── config-generator.js
|
||||||
|
│ ├── java-runner.js
|
||||||
|
│ ├── mysql-service-manager.js
|
||||||
|
│ ├── port-checker.js
|
||||||
|
│ └── startup-manager.js
|
||||||
|
├── mysql/ # MySQL 数据库
|
||||||
|
│ ├── bin/
|
||||||
|
│ ├── data/ # 数据库数据 ⚠️ 不要动
|
||||||
|
│ ├── data_backup/ # 自动备份
|
||||||
|
│ ├── my.ini # 运行时生成
|
||||||
|
│ └── README.txt
|
||||||
|
├── jre/ # Java 运行环境(⚠️ 不要修改)
|
||||||
|
│ ├── bin/
|
||||||
|
│ └── lib/
|
||||||
|
└── logs/ # 应用日志
|
||||||
|
├── startup-YYYYMMDD.log
|
||||||
|
└── upgrade.log
|
||||||
|
|
||||||
|
用户数据目录(首次运行自动创建):
|
||||||
|
X:\NPQS9100_Data\ (X 是应用所在盘符)
|
||||||
|
├── logs/ # Spring Boot 日志
|
||||||
|
├── template/ # 报告模板
|
||||||
|
├── report/ # 生成的报告
|
||||||
|
└── data/ # 应用数据
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 七、用户关心的文件(重要!)⭐
|
||||||
|
|
||||||
|
### 📌 可以使用的工具
|
||||||
|
|
||||||
|
| 文件 | 功能 | 使用场景 |
|
||||||
|
|------|------|---------|
|
||||||
|
| **NPQS9100.exe** | 主程序 | 日常启动 |
|
||||||
|
| **NPQS9100-启动器.bat** | 管理员启动器 | 首次运行或权限问题时 |
|
||||||
|
| **upgrade.bat** | 升级工具 | 收到升级包时使用 |
|
||||||
|
| **rollback.bat** | 回滚工具 | 升级后出问题时使用 |
|
||||||
|
| **uninstall-mysql-service.bat** | MySQL 服务卸载 | 完全卸载应用时使用 |
|
||||||
|
| **使用说明.txt** | 使用手册 | 遇到问题时参考 |
|
||||||
|
| **README-升级回滚.txt** | 升级说明 | 升级前阅读 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ⚠️ 不要修改的文件/目录
|
||||||
|
|
||||||
|
| 路径 | 说明 | 误修改后果 |
|
||||||
|
|------|------|----------|
|
||||||
|
| **resources/** | 应用核心代码 | 应用无法启动 |
|
||||||
|
| **scripts/** | 启动管理脚本 | 启动流程失败 |
|
||||||
|
| **jre/** | Java 运行环境 | Java 服务无法启动 |
|
||||||
|
| **mysql/bin/** | MySQL 可执行文件 | 数据库无法启动 |
|
||||||
|
| **mysql/my.ini** | MySQL 配置 | 运行时自动生成,手动修改会被覆盖 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 📂 需要保护的数据
|
||||||
|
|
||||||
|
| 路径 | 说明 | 备份建议 |
|
||||||
|
|------|------|---------|
|
||||||
|
| **mysql/data/** | 数据库数据 | ⚠️ 定期备份! |
|
||||||
|
| **backup/** | 升级备份 | 自动管理,无需手动操作 |
|
||||||
|
| **X:\NPQS9100_Data/** | 用户数据目录 | 包含日志、模板、报告 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 二、打包指南
|
||||||
|
|
||||||
|
### 🏗️ 打包步骤
|
||||||
|
|
||||||
|
#### **步骤 1:清理并打包**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd build
|
||||||
|
clean-and-build.bat
|
||||||
|
```
|
||||||
|
|
||||||
|
**打包过程**:
|
||||||
|
1. 停止 NPQS9100 进程
|
||||||
|
2. 删除 out 目录
|
||||||
|
3. 构建前端代码(Vue 3)
|
||||||
|
4. 编译 Electron 主进程代码
|
||||||
|
5. 复制 MySQL、JRE、Java 资源
|
||||||
|
6. 生成 win-unpacked 绿色版目录
|
||||||
|
|
||||||
|
**等待时间**:约 5-15 分钟
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
#### **步骤 2:测试运行**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd out\win-unpacked
|
||||||
|
NPQS9100.exe
|
||||||
|
```
|
||||||
|
|
||||||
|
**观察**:
|
||||||
|
- ✅ Loading 界面正常显示(不在任务栏显示)
|
||||||
|
- ✅ 启动进度正常更新(9个步骤)
|
||||||
|
- ✅ MySQL 自动启动
|
||||||
|
- ✅ Spring Boot 连接成功
|
||||||
|
- ✅ 顺利进入主界面
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
#### **步骤 3:压缩发布包**
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
cd out
|
||||||
|
Compress-Archive -Path win-unpacked -DestinationPath "NPQS9100-v1.0.0-绿色版.zip" -Force
|
||||||
|
```
|
||||||
|
|
||||||
|
**压缩后大小**:约 350-450 MB
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 三、启动流程
|
||||||
|
|
||||||
|
### 🔄 完整启动流程
|
||||||
|
|
||||||
|
```
|
||||||
|
用户解压 zip 并双击 NPQS9100.exe
|
||||||
|
↓
|
||||||
|
显示 Loading 界面(不在任务栏显示)
|
||||||
|
↓
|
||||||
|
[0%] 正在初始化应用...
|
||||||
|
↓
|
||||||
|
[15%] 检测 MySQL 端口 (3306 → 3307 → ...)
|
||||||
|
├─ 找到可用端口(如 3307)
|
||||||
|
↓
|
||||||
|
[30%] 启动 MySQL 数据库(端口 3307)
|
||||||
|
├─ 首次运行:自动初始化数据库
|
||||||
|
├─ 自动设置 root 密码:njcnpqs
|
||||||
|
├─ 自动授权 127.0.0.1 访问
|
||||||
|
↓
|
||||||
|
[45%] 等待 MySQL 就绪
|
||||||
|
├─ 监听端口是否打开
|
||||||
|
├─ 超时时间:30 秒
|
||||||
|
↓
|
||||||
|
[60%] 检测 Java 端口 (18092 → 18093 → ...)
|
||||||
|
├─ 找到可用端口(如 18093)
|
||||||
|
↓
|
||||||
|
[70%] 检测应用所在盘符并生成配置文件
|
||||||
|
├─ MySQL 连接:localhost:3307
|
||||||
|
├─ MySQL 密码:njcnpqs ⭐ 自动写入
|
||||||
|
├─ Java 端口:18093
|
||||||
|
├─ 数据路径:C:\NPQS9100_Data\
|
||||||
|
├─ 创建所有必要目录(logs、template、report、data)
|
||||||
|
↓
|
||||||
|
[80%] 启动 Spring Boot 后端
|
||||||
|
├─ 使用内置 JRE 8
|
||||||
|
├─ 加载生成的配置文件
|
||||||
|
├─ 连接 MySQL 数据库
|
||||||
|
↓
|
||||||
|
[90%] 等待 Spring Boot 就绪
|
||||||
|
├─ 监听 18093 端口
|
||||||
|
├─ 超时时间:60 秒
|
||||||
|
↓
|
||||||
|
[100%] 启动完成!
|
||||||
|
├─ 等待 1.5 秒显示完成状态
|
||||||
|
↓
|
||||||
|
销毁 Loading 窗口(使用 destroy() 确保完全释放)
|
||||||
|
↓
|
||||||
|
显示主应用界面(任务栏只显示1个图标)
|
||||||
|
```
|
||||||
|
|
||||||
|
**预计启动时间**:
|
||||||
|
- 首次运行:30-45 秒(需初始化 MySQL)
|
||||||
|
- 后续启动:15-25 秒
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 🚪 关闭流程
|
||||||
|
|
||||||
|
```
|
||||||
|
用户关闭应用(点击X或托盘退出)
|
||||||
|
↓
|
||||||
|
显示退出确认对话框
|
||||||
|
↓
|
||||||
|
用户确认退出
|
||||||
|
↓
|
||||||
|
停止 Spring Boot 进程(通过PID和端口精确清理)
|
||||||
|
↓
|
||||||
|
停止 MySQL 服务(如果是服务模式)
|
||||||
|
↓
|
||||||
|
清理资源
|
||||||
|
↓
|
||||||
|
应用退出
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 四、升级指南
|
||||||
|
|
||||||
|
### 🎯 升级流程概览
|
||||||
|
|
||||||
|
#### **升级流程**
|
||||||
|
```
|
||||||
|
1. 双击 upgrade.bat(首次自动创建 upgrade/ 目录)
|
||||||
|
2. 将升级包放入 upgrade/ 目录
|
||||||
|
3. 再次运行 upgrade.bat(自动备份 + 升级)
|
||||||
|
4. 重启应用测试
|
||||||
|
```
|
||||||
|
|
||||||
|
#### **回滚流程**
|
||||||
|
```
|
||||||
|
1. 双击 rollback.bat
|
||||||
|
2. 自动从 backup/ 恢复旧版本
|
||||||
|
3. 重启应用
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 🔧 升级操作步骤
|
||||||
|
|
||||||
|
#### **方法 1:使用升级脚本(推荐)⭐**
|
||||||
|
|
||||||
|
**第 1 步:准备升级包**
|
||||||
|
|
||||||
|
1. 双击 `upgrade.bat`
|
||||||
|
2. 脚本自动创建 `upgrade/` 文件夹并提示
|
||||||
|
3. 将升级文件放入 `upgrade/` 目录:
|
||||||
|
- `dist/` - 前端升级包(可选)
|
||||||
|
- `entrance.jar` - 后端升级包(可选)
|
||||||
|
4. 再次双击 `upgrade.bat` 开始升级
|
||||||
|
|
||||||
|
**第 2 步:自动升级**
|
||||||
|
|
||||||
|
脚本会自动:
|
||||||
|
- ✅ 停止 NPQS9100 进程
|
||||||
|
- ✅ **自动备份当前版本到 `backup/` 目录**
|
||||||
|
- ✅ 备份数据库到 `mysql/data_backup/`
|
||||||
|
- ✅ 替换前端文件(如果有)
|
||||||
|
- ✅ 替换后端 JAR(如果有)
|
||||||
|
- ✅ 记录升级日志到 `logs/upgrade.log`
|
||||||
|
|
||||||
|
**第 3 步:重启应用**
|
||||||
|
|
||||||
|
升级完成后,双击 `NPQS9100.exe` 启动应用。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
#### **方法 2:手动升级**
|
||||||
|
|
||||||
|
如果升级脚本失败,可以手动操作:
|
||||||
|
|
||||||
|
**升级前端**:
|
||||||
|
```batch
|
||||||
|
taskkill /F /IM NPQS9100.exe
|
||||||
|
rmdir /s /q resources\app.asar.unpacked\public\dist
|
||||||
|
xcopy upgrade\dist resources\app.asar.unpacked\public\dist\ /E /I /Y
|
||||||
|
```
|
||||||
|
|
||||||
|
**升级后端**:
|
||||||
|
```batch
|
||||||
|
taskkill /F /IM NPQS9100.exe
|
||||||
|
copy /Y upgrade\entrance.jar resources\extraResources\java\entrance.jar
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 🔄 回滚操作
|
||||||
|
|
||||||
|
#### **方法 1:使用回滚脚本(推荐)⭐**
|
||||||
|
|
||||||
|
如果升级后出现问题,直接双击 `rollback.bat`:
|
||||||
|
|
||||||
|
脚本会自动:
|
||||||
|
- ✅ 停止 NPQS9100
|
||||||
|
- ✅ 恢复前端(从 `backup/dist/`)
|
||||||
|
- ✅ 恢复后端(从 `backup/entrance.jar`)
|
||||||
|
- ✅ 询问是否恢复数据库(⚠️ 会丢失升级后的数据)
|
||||||
|
|
||||||
|
#### **方法 2:手动回滚**
|
||||||
|
|
||||||
|
```batch
|
||||||
|
# 恢复前端
|
||||||
|
rmdir /s /q resources\app.asar.unpacked\public\dist
|
||||||
|
xcopy backup\dist resources\app.asar.unpacked\public\dist\ /E /I /Y
|
||||||
|
|
||||||
|
# 恢复后端
|
||||||
|
copy /Y backup\entrance.jar resources\extraResources\java\entrance.jar
|
||||||
|
|
||||||
|
# 恢复数据库(⚠️ 谨慎!)
|
||||||
|
rmdir /s /q mysql\data
|
||||||
|
xcopy mysql\data_backup mysql\data\ /E /I /Y
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 📋 升级清单
|
||||||
|
|
||||||
|
| 升级类型 | 升级包来源 | 客户放置位置 | 最终替换位置 |
|
||||||
|
|---------|-----------|-------------|-------------|
|
||||||
|
| **前端** | `out/win-unpacked/resources/app.asar` + `app.asar.unpacked/` | `upgrade/app.asar` + `upgrade/app.asar.unpacked/` | `resources/app.asar` + `resources/app.asar.unpacked/` |
|
||||||
|
| **后端** | `out/win-unpacked/resources/extraResources/java/entrance.jar` | `upgrade/entrance.jar` | `resources/extraResources/java/entrance.jar` |
|
||||||
|
| **数据库** | ⚠️ **不升级,自动保留** | - | `mysql/data/` |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 🛠️ 开发者升级流程(完整版)
|
||||||
|
|
||||||
|
#### **前端升级完整流程**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# ============================================
|
||||||
|
# 开发侧操作
|
||||||
|
# ============================================
|
||||||
|
|
||||||
|
# 1️⃣ 修改前端代码
|
||||||
|
# 编辑 frontend/src/ 下的任何文件
|
||||||
|
|
||||||
|
# 2️⃣ 如需修改配置(可选)
|
||||||
|
# 编辑 frontend/.env
|
||||||
|
VITE_API_URL=http://192.168.1.100:18092 # 修改 API 地址
|
||||||
|
|
||||||
|
# 3️⃣ 构建前端
|
||||||
|
npm run build-frontend
|
||||||
|
|
||||||
|
# 4️⃣ 打包应用
|
||||||
|
npm run build-w
|
||||||
|
# 输出: out/win-unpacked/
|
||||||
|
|
||||||
|
# 5️⃣ 准备升级包
|
||||||
|
# 从 out/win-unpacked/resources/ 复制以下文件:
|
||||||
|
# - app.asar (文件)
|
||||||
|
# - app.asar.unpacked/ (整个文件夹)
|
||||||
|
#
|
||||||
|
# 压缩成: NPQS9100-前端-v1.0.1.zip
|
||||||
|
|
||||||
|
# 6️⃣ 发给客户
|
||||||
|
|
||||||
|
|
||||||
|
# ============================================
|
||||||
|
# 客户侧操作
|
||||||
|
# ============================================
|
||||||
|
|
||||||
|
# 1️⃣ 解压升级包
|
||||||
|
# 解压 NPQS9100-前端-v1.0.1.zip
|
||||||
|
# 得到:
|
||||||
|
# - app.asar
|
||||||
|
# - app.asar.unpacked/
|
||||||
|
|
||||||
|
# 2️⃣ 复制到升级目录
|
||||||
|
# 将两个文件都放到:win-unpacked/upgrade/
|
||||||
|
# - upgrade/app.asar
|
||||||
|
# - upgrade/app.asar.unpacked/
|
||||||
|
|
||||||
|
# 3️⃣ 运行升级脚本
|
||||||
|
# 双击: upgrade.bat
|
||||||
|
|
||||||
|
# 4️⃣ 重启应用
|
||||||
|
# 双击: NPQS9100.exe
|
||||||
|
```
|
||||||
|
|
||||||
|
#### **后端升级完整流程**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# ============================================
|
||||||
|
# 开发侧操作
|
||||||
|
# ============================================
|
||||||
|
|
||||||
|
# 1️⃣ 获取新的 JAR 文件
|
||||||
|
# 从后端开发人员获取新版本的 entrance.jar
|
||||||
|
|
||||||
|
# 2️⃣ 替换 JAR 文件
|
||||||
|
# 将新的 entrance.jar 复制到:
|
||||||
|
# build/extraResources/java/entrance.jar
|
||||||
|
|
||||||
|
# 3️⃣ 打包升级包
|
||||||
|
# 直接压缩 entrance.jar 文件
|
||||||
|
# 重命名为: NPQS9100-后端-v1.0.1.zip
|
||||||
|
|
||||||
|
# 4️⃣ 发给客户
|
||||||
|
# 发送 NPQS9100-后端-v1.0.1.zip
|
||||||
|
|
||||||
|
|
||||||
|
# ============================================
|
||||||
|
# 客户侧操作
|
||||||
|
# ============================================
|
||||||
|
|
||||||
|
# 1️⃣ 解压升级包
|
||||||
|
# 解压 NPQS9100-后端-v1.0.1.zip
|
||||||
|
# 得到 entrance.jar 文件
|
||||||
|
|
||||||
|
# 2️⃣ 复制到升级目录
|
||||||
|
# 将 entrance.jar 复制到:
|
||||||
|
# win-unpacked/upgrade/entrance.jar
|
||||||
|
|
||||||
|
# 3️⃣ 运行升级脚本
|
||||||
|
# 双击: upgrade.bat
|
||||||
|
|
||||||
|
# 4️⃣ 重启应用
|
||||||
|
# 双击: NPQS9100.exe
|
||||||
|
```
|
||||||
|
|
||||||
|
#### **前后端同时升级**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 开发侧:准备升级包
|
||||||
|
NPQS9100-升级-v1.1.0.zip
|
||||||
|
├── app.asar # 前端升级包(文件)
|
||||||
|
├── app.asar.unpacked/ # 前端升级包(文件夹)
|
||||||
|
└── entrance.jar # 后端升级包
|
||||||
|
|
||||||
|
# 客户侧:复制到
|
||||||
|
win-unpacked/upgrade/
|
||||||
|
├── app.asar
|
||||||
|
├── app.asar.unpacked/
|
||||||
|
└── entrance.jar
|
||||||
|
|
||||||
|
# 运行 upgrade.bat 即可一次性升级前后端
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 五、测试清单
|
||||||
|
|
||||||
|
### ✅ 打包验证
|
||||||
|
|
||||||
|
- [ ] `out/win-unpacked` 目录存在
|
||||||
|
- [ ] 目录大小约 650-800 MB
|
||||||
|
- [ ] NPQS9100.exe 存在
|
||||||
|
- [ ] NPQS9100-启动器.bat 存在
|
||||||
|
- [ ] upgrade.bat 存在
|
||||||
|
- [ ] rollback.bat 存在
|
||||||
|
- [ ] uninstall-mysql-service.bat 存在
|
||||||
|
- [ ] 使用说明.txt 存在
|
||||||
|
- [ ] README-升级回滚.txt 存在
|
||||||
|
- [ ] mysql/ 目录完整
|
||||||
|
- [ ] jre/ 目录完整
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ✅ 基础功能测试
|
||||||
|
|
||||||
|
- [ ] 双击 NPQS9100.exe 能正常启动
|
||||||
|
- [ ] Loading 界面正常显示
|
||||||
|
- [ ] **Loading 窗口不在任务栏显示** ⭐
|
||||||
|
- [ ] 进度条流畅更新(0% → 100%)
|
||||||
|
- [ ] 状态文字正确显示
|
||||||
|
- [ ] 主界面正常显示
|
||||||
|
- [ ] **任务栏只有1个窗口预览** ⭐
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ✅ 端口检测测试
|
||||||
|
|
||||||
|
- [ ] 手动占用 3306,应用自动使用 3307
|
||||||
|
- [ ] 手动占用 18092,应用自动使用 18093
|
||||||
|
- [ ] Loading 界面显示检测到的端口号
|
||||||
|
- [ ] 日志中显示正确的端口信息
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ✅ MySQL 测试
|
||||||
|
|
||||||
|
- [ ] MySQL 自动启动成功
|
||||||
|
- [ ] **首次运行自动初始化数据库** ⭐
|
||||||
|
- [ ] 可以用 Navicat 连接(密码:njcnpqs)
|
||||||
|
- [ ] 可以从 127.0.0.1 连接(不报 1130 错误)⭐
|
||||||
|
- [ ] 数据库操作正常
|
||||||
|
- [ ] 关闭应用后 MySQL 自动停止
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ✅ Spring Boot 测试
|
||||||
|
|
||||||
|
- [ ] 后端服务自动启动
|
||||||
|
- [ ] **能连接到 MySQL(不报密码错误)** ⭐
|
||||||
|
- [ ] 日志无错误:"HikariPool-1 - Start completed"
|
||||||
|
- [ ] API 接口正常响应
|
||||||
|
- [ ] 关闭应用后 Java 进程停止
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ✅ 配置生成测试
|
||||||
|
|
||||||
|
- [ ] application.yml 自动生成
|
||||||
|
- [ ] **MySQL 密码正确写入(njcnpqs)** ⭐
|
||||||
|
- [ ] MySQL 端口正确
|
||||||
|
- [ ] Java 端口正确
|
||||||
|
- [ ] 数据路径正确(对应盘符)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ✅ 数据目录测试
|
||||||
|
|
||||||
|
- [ ] 数据目录在正确的盘符下创建
|
||||||
|
- [ ] 所有子目录都自动创建
|
||||||
|
- [ ] 配置文件路径正确
|
||||||
|
- [ ] 日志文件正常写入
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ✅ 便携性测试
|
||||||
|
|
||||||
|
- [ ] 可以解压到任意目录运行
|
||||||
|
- [ ] 可以移动到其他目录运行
|
||||||
|
- [ ] 可以在不同电脑上运行
|
||||||
|
- [ ] 可以在不同盘符上运行(C/D/E...)
|
||||||
|
- [ ] 删除目录即可完全卸载
|
||||||
|
- [ ] **压缩成 zip 后用户可正常解压使用** ⭐
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ✅ 升级回滚测试
|
||||||
|
|
||||||
|
- [ ] upgrade.bat 首次运行自动创建 upgrade/ 目录
|
||||||
|
- [ ] upgrade.bat 检测到升级文件后正常升级
|
||||||
|
- [ ] 升级前自动备份到 backup/ 目录
|
||||||
|
- [ ] 升级后应用正常运行
|
||||||
|
- [ ] 升级后数据库数据保留
|
||||||
|
- [ ] rollback.bat 能正确回滚前端
|
||||||
|
- [ ] rollback.bat 能正确回滚后端
|
||||||
|
- [ ] 回滚后应用恢复正常
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ✅ 性能测试
|
||||||
|
|
||||||
|
- [ ] 首次启动 < 45 秒
|
||||||
|
- [ ] 后续启动 < 30 秒
|
||||||
|
- [ ] Loading 界面流畅无卡顿
|
||||||
|
- [ ] 内存占用合理(< 1GB)
|
||||||
|
- [ ] CPU 占用正常
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### ✅ 错误处理测试
|
||||||
|
|
||||||
|
- [ ] 端口全部占用时显示友好错误
|
||||||
|
- [ ] MySQL 启动失败时显示错误信息
|
||||||
|
- [ ] Spring Boot 启动失败时不崩溃
|
||||||
|
- [ ] 升级失败时自动回滚
|
||||||
|
- [ ] 托盘图标显示正常
|
||||||
|
- [ ] 退出确认对话框正常工作
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 六、常见问题
|
||||||
|
|
||||||
|
### Q1: Loading 界面一直卡在某个步骤?
|
||||||
|
|
||||||
|
**A**: 查看日志定位问题:
|
||||||
|
```
|
||||||
|
C:\Users\[用户名]\AppData\Roaming\NQPS9100\logs\
|
||||||
|
├── 9100-YYYYMMDD.log # 应用日志
|
||||||
|
├── 9100-core-YYYYMMDD.log # 核心日志
|
||||||
|
└── 9100-error-YYYYMMDD.log # 错误日志
|
||||||
|
```
|
||||||
|
|
||||||
|
常见原因:
|
||||||
|
- MySQL 启动失败 → 检查端口是否可用
|
||||||
|
- Java 启动失败 → 检查 JRE 是否完整
|
||||||
|
- 配置生成失败 → 检查磁盘权限
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q2: 显示"无法找到可用端口"错误?
|
||||||
|
|
||||||
|
**A**:
|
||||||
|
- 检查是否有大量端口被占用
|
||||||
|
- 尝试关闭其他占用端口的程序
|
||||||
|
- 或修改起始端口(见开发者指南)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q3: MySQL 连接失败或提示 1130 错误?
|
||||||
|
|
||||||
|
**A**:
|
||||||
|
- 确认 MySQL 已启动(任务管理器查看 mysqld.exe)
|
||||||
|
- 确认端口正确(看 Loading 界面显示的端口)
|
||||||
|
- 确认密码正确(njcnpqs,已自动配置)
|
||||||
|
- 检查是否有杀毒软件拦截
|
||||||
|
- 如有问题,重启应用即可(MySQL 会自动重新配置)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q4: 后端 API 无法访问?
|
||||||
|
|
||||||
|
**A**:
|
||||||
|
- 确认 Spring Boot 已启动
|
||||||
|
- 确认端口正确(看 Loading 界面)
|
||||||
|
- 检查防火墙设置
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q5: 打包后体积太大?
|
||||||
|
|
||||||
|
**A**: 预期体积:
|
||||||
|
- **解压后**:650-800 MB
|
||||||
|
- **压缩后 (zip)**:350-450 MB
|
||||||
|
|
||||||
|
主要组成:
|
||||||
|
- 应用本体:~150 MB
|
||||||
|
- MySQL 8.0:~400 MB
|
||||||
|
- JRE 8:~100 MB
|
||||||
|
|
||||||
|
优化建议:
|
||||||
|
- 考虑使用 7z 格式(压缩率更高)
|
||||||
|
- 可以精简 MySQL 的不必要组件
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q6: 任务栏显示2个窗口预览?
|
||||||
|
|
||||||
|
**A**: 已修复!现在 Loading 窗口使用 `skipTaskbar: true`,不会在任务栏显示。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q7: 升级后前端显示旧版本?
|
||||||
|
|
||||||
|
**A**: 清除浏览器缓存,或强制刷新(Ctrl + F5)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q8: 升级后数据丢失?
|
||||||
|
|
||||||
|
**A**: 检查 `mysql/data/` 目录是否完整,如有备份,从 `mysql/data_backup/` 恢复
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q9: 升级脚本报错?
|
||||||
|
|
||||||
|
**A**:
|
||||||
|
1. 检查 `upgrade` 文件夹路径是否正确
|
||||||
|
2. 手动执行升级步骤
|
||||||
|
3. 查看 `logs/upgrade.log` 日志
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q10: 回滚后还是有问题?
|
||||||
|
|
||||||
|
**A**:
|
||||||
|
1. 检查 `backup/` 目录是否有备份文件
|
||||||
|
2. 查看 `backup/version.txt` 确认备份版本
|
||||||
|
3. 手动执行回滚步骤(参考本文档)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q11: 多次升级后,backup 目录的内容是什么版本?
|
||||||
|
|
||||||
|
**A**: `backup/` 目录保存的是**最后一次升级前**的版本(每次升级都会覆盖)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q12: 点击 X 关闭后,Java 进程还在运行?
|
||||||
|
|
||||||
|
**A**: 已修复!现在使用精确的进程清理机制:
|
||||||
|
- 通过 PID 清理(如果有进程引用)
|
||||||
|
- 通过端口号清理(精确定位)
|
||||||
|
- **不会误杀 IDEA 等其他 Java 进程** ⭐
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q13: 如何修改 API 或 WebSocket 地址?
|
||||||
|
|
||||||
|
**A**:
|
||||||
|
1. 修改 `frontend/.env` 文件中的 `VITE_API_URL`
|
||||||
|
2. 重新构建前端:`npm run build-frontend`
|
||||||
|
3. 将 `public/dist/` 打包为升级包
|
||||||
|
4. 使用 `upgrade.bat` 升级
|
||||||
|
|
||||||
|
**示例**:
|
||||||
|
```env
|
||||||
|
# frontend/.env
|
||||||
|
VITE_API_URL=http://192.168.1.100:18092
|
||||||
|
```
|
||||||
|
|
||||||
|
**注意**:
|
||||||
|
- 配置修改需要重新打包前端
|
||||||
|
- 使用升级机制保证数据安全
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Q14: MySQL 服务如何卸载?
|
||||||
|
|
||||||
|
**A**:
|
||||||
|
**方法 1:使用卸载脚本(推荐)**
|
||||||
|
```batch
|
||||||
|
双击: uninstall-mysql-service.bat
|
||||||
|
```
|
||||||
|
|
||||||
|
**方法 2:手动卸载**
|
||||||
|
```batch
|
||||||
|
# 停止服务
|
||||||
|
net stop mysql9100
|
||||||
|
|
||||||
|
# 删除服务
|
||||||
|
sc delete mysql9100
|
||||||
|
```
|
||||||
|
|
||||||
|
**注意**:
|
||||||
|
- 卸载服务不会删除数据库数据
|
||||||
|
- 数据保存在 `mysql/data/` 目录
|
||||||
|
- 下次启动应用会重新安装服务
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📚 相关文档
|
||||||
|
|
||||||
|
**用户文档**(随应用发布):
|
||||||
|
- `使用说明.txt` - 用户使用手册
|
||||||
|
- `README-升级回滚.txt` - 简明升级说明
|
||||||
|
|
||||||
|
**开发者文档**(doc/ 目录):
|
||||||
|
- `doc/NPQS-9100绿色包完整指南.md` - 本文档(完整指南)
|
||||||
|
- `doc/打包前检查清单.md` - 逐项检查
|
||||||
|
- `doc/管理员权限说明.md` - 权限问题处理
|
||||||
|
- `doc/MySQL服务化方案说明.md` - MySQL 服务管理
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📊 技术架构
|
||||||
|
|
||||||
|
### 核心模块
|
||||||
|
|
||||||
|
- `scripts/port-checker.js` - 端口检测工具
|
||||||
|
- `scripts/startup-manager.js` - 启动状态管理
|
||||||
|
- `scripts/config-generator.js` - 配置文件生成
|
||||||
|
- `scripts/mysql-service-manager.js` - MySQL 服务管理器
|
||||||
|
- `scripts/java-runner.js` - Java 运行器
|
||||||
|
- `scripts/log-window-manager.js` - 日志窗口管理
|
||||||
|
- `electron/preload/lifecycle.js` - 生命周期管理
|
||||||
|
- `public/html/loading.html` - Loading 界面
|
||||||
|
|
||||||
|
### 启动流程架构
|
||||||
|
|
||||||
|
```
|
||||||
|
lifecycle.js (入口)
|
||||||
|
↓ 创建
|
||||||
|
StartupManager (显示 Loading)
|
||||||
|
↓ 调用
|
||||||
|
PortChecker (检测端口)
|
||||||
|
↓ 调用
|
||||||
|
MySQLServiceManager (管理 MySQL 服务)
|
||||||
|
↓ 调用
|
||||||
|
ConfigGenerator (生成配置)
|
||||||
|
↓ 调用
|
||||||
|
JavaRunner (启动 Spring Boot)
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🎉 最新改进
|
||||||
|
|
||||||
|
### 用户体验提升
|
||||||
|
- ✅ **任务栏只显示1个图标** - Loading 窗口不在任务栏显示
|
||||||
|
- ✅ **纯绿色版** - 只生成 win-unpacked 目录,压缩成 zip 即可发布
|
||||||
|
- ✅ **一键解压即用** - 用户解压后双击即可运行
|
||||||
|
- ✅ **热更新机制** - 前后端可独立升级,支持一键回滚
|
||||||
|
|
||||||
|
### 技术改进
|
||||||
|
- ✅ **MySQL 密码自动配置** - 配置生成器自动写入密码
|
||||||
|
- ✅ **权限自动授权** - 支持 localhost 和 127.0.0.1 访问
|
||||||
|
- ✅ **MySQL 服务化** - 使用 Windows 服务管理,开机自启
|
||||||
|
- ✅ **窗口管理优化** - 使用 destroy() 确保窗口完全释放
|
||||||
|
- ✅ **精确进程清理** - 不会误杀其他 Java 进程
|
||||||
|
- ✅ **自动备份机制** - 升级前自动备份,支持回滚
|
||||||
|
- ✅ **热更新机制** - 前后端独立升级,无需重装
|
||||||
|
|
||||||
|
### 文档完善
|
||||||
|
- ✅ **使用说明.txt** - 为用户提供详细的使用指南
|
||||||
|
- ✅ **README-升级回滚.txt** - 简明升级操作说明
|
||||||
|
- ✅ **完整指南** - 打包、启动、升级三合一文档
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📞 技术支持
|
||||||
|
|
||||||
|
如遇问题,请联系技术支持并提供:
|
||||||
|
- 应用版本号
|
||||||
|
- 错误日志(`logs/` 目录)
|
||||||
|
- 操作步骤截图
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*文档更新时间: 2025-10-23*
|
||||||
|
*南京灿能电力自动化股份有限公司*
|
||||||
|
|
||||||
@@ -1,133 +0,0 @@
|
|||||||
## 便携式 JRE/JDK8 集成指南
|
|
||||||
|
|
||||||
本指南介绍如何将 JRE 8 以“便携式”(解压即用、无需安装)的方式随应用打包,并在 Electron 主进程中通过绝对路径调用,从而避免要求用户在系统中安装 JDK/JRE。
|
|
||||||
|
|
||||||
### 为什么选择便携式 JRE
|
|
||||||
- 无需管理员权限与系统环境变量配置,用户无感知。
|
|
||||||
- 不污染系统环境(不写入 JAVA_HOME/PATH)。
|
|
||||||
- 跨平台一致,可精简体积、可控版本。
|
|
||||||
|
|
||||||
### 适用场景
|
|
||||||
- 运行 Java 程序或 JAR 包(仅需运行时)。
|
|
||||||
- 不需要 javac/jcmd/jmap 等开发/诊断工具(若需要,请改为随包便携式 JDK)。
|
|
||||||
|
|
||||||
### 推荐的 JRE 8 发行版(可再分发)
|
|
||||||
- Azul Zulu 8 JRE(可选 ZuluFX 含 JavaFX):[下载页面](https://www.azul.com/downloads/?version=java-8-lts&package=jre)
|
|
||||||
- BellSoft Liberica 8 JRE(Standard/Full,Full 含 JavaFX):[下载页面](https://bell-sw.com/pages/downloads/#/java-8-lts)
|
|
||||||
- Eclipse Temurin 8 JRE(Adoptium):[下载页面](https://adoptium.net/temurin/releases/?version=8)
|
|
||||||
|
|
||||||
选择要点:
|
|
||||||
- 需要 AWT/Swing/字体/打印 → 选择非 headless 包。
|
|
||||||
- 需要 JavaFX → 选择 Liberica Full 或 ZuluFX。
|
|
||||||
- 仅命令行/服务端 → 任意 JRE 8(headless 也可)。
|
|
||||||
|
|
||||||
### 目录放置约定
|
|
||||||
将解压后的 JRE 放入项目的 `build/extraResources/jre`,保证内部存在 `bin/java(.exe)`:
|
|
||||||
|
|
||||||
```
|
|
||||||
build/
|
|
||||||
extraResources/
|
|
||||||
jre/
|
|
||||||
bin/
|
|
||||||
java(.exe)
|
|
||||||
lib/
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
构建后在生产环境可通过 `process.resourcesPath` 访问:
|
|
||||||
`<app>/resources/extraResources/jre/bin/java(.exe)`。
|
|
||||||
|
|
||||||
### 主进程调用示例
|
|
||||||
在 `electron/preload/lifecycle.js` 或你的业务模块中封装 Java 运行工具(开发/生产两种路径):
|
|
||||||
|
|
||||||
```js
|
|
||||||
const path = require('path');
|
|
||||||
const { spawn } = require('child_process');
|
|
||||||
|
|
||||||
function getExtraResourcesDir() {
|
|
||||||
// 开发态:使用项目目录;生产态:使用 asar/resources 目录
|
|
||||||
const isDev = !!process.env.EE_DEV || process.env.NODE_ENV === 'development';
|
|
||||||
return isDev
|
|
||||||
? path.join(process.cwd(), 'build', 'extraResources')
|
|
||||||
: path.join(process.resourcesPath, 'extraResources');
|
|
||||||
}
|
|
||||||
|
|
||||||
function getJavaBinPath() {
|
|
||||||
const extraDir = getExtraResourcesDir();
|
|
||||||
const javaBinName = process.platform === 'win32' ? 'java.exe' : 'java';
|
|
||||||
return path.join(extraDir, 'jre', 'bin', javaBinName);
|
|
||||||
}
|
|
||||||
|
|
||||||
function runJavaJar(jarAbsPath, args = [], options = {}) {
|
|
||||||
const javaPath = getJavaBinPath();
|
|
||||||
const child = spawn(javaPath, ['-jar', jarAbsPath, ...args], {
|
|
||||||
stdio: 'inherit',
|
|
||||||
...options,
|
|
||||||
});
|
|
||||||
return child;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function ensureJavaVersion(logger) {
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
const child = spawn(getJavaBinPath(), ['-version']);
|
|
||||||
let out = '';
|
|
||||||
let err = '';
|
|
||||||
child.stdout && child.stdout.on('data', (d) => (out += d.toString()))
|
|
||||||
child.stderr && child.stderr.on('data', (d) => (err += d.toString()))
|
|
||||||
child.on('close', () => {
|
|
||||||
const text = (out + '\n' + err).trim();
|
|
||||||
logger && logger.info('[java] version check:', text);
|
|
||||||
resolve(text.includes('1.8.0'));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { getJavaBinPath, runJavaJar, ensureJavaVersion };
|
|
||||||
```
|
|
||||||
|
|
||||||
在生命周期中调用(示例):
|
|
||||||
|
|
||||||
```js
|
|
||||||
const { logger } = require('ee-core/log');
|
|
||||||
const path = require('path');
|
|
||||||
const { runJavaJar, ensureJavaVersion } = require('./java-runner');
|
|
||||||
|
|
||||||
class Lifecycle {
|
|
||||||
async ready() {
|
|
||||||
const ok = await ensureJavaVersion(logger);
|
|
||||||
if (!ok) {
|
|
||||||
logger.error('[java] 未检测到 JRE 8,请检查 extraResources/jre 是否存在');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async windowReady() {
|
|
||||||
const jarPath = path.join(process.resourcesPath || process.cwd(), 'extraResources', 'tools', 'your-app.jar');
|
|
||||||
// 示例:延后在某业务时机再启动 Java 进程
|
|
||||||
// const proc = runJavaJar(jarPath, ['--arg1', 'value']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
注意:示例中的 `java-runner` 为上文工具函数文件,实际请按你的项目结构放置。
|
|
||||||
|
|
||||||
### 验证清单
|
|
||||||
- 运行 `jre/bin/java -version` 输出包含 `1.8.0_xxx`。
|
|
||||||
- 若涉及 GUI/字体/打印,验证 AWT/Swing 中文渲染与打印。
|
|
||||||
- 若需 JavaFX,验证 JavaFX Demo 启动。
|
|
||||||
- 若涉及 TLS/HTTPS,验证 SSL 通信正常。
|
|
||||||
|
|
||||||
### 许可与合规
|
|
||||||
- Azul Zulu、Eclipse Temurin(Adoptium)、BellSoft Liberica 的 JRE/JDK 8 发行包均可免费再分发(GPLv2+CE 或厂商许可证)。
|
|
||||||
- 建议在应用的“关于/许可证”中附上所选发行版的许可证链接与致谢。
|
|
||||||
|
|
||||||
### 常见问题
|
|
||||||
1) 是否“阉割”?
|
|
||||||
— 上述 JRE 8 发行版均为标准运行时,通过兼容性测试;JRE 不包含开发者工具属于正常区别,不是删减。
|
|
||||||
|
|
||||||
2) 何时需要 JDK 而不是 JRE?
|
|
||||||
— 需要 `javac` 编译或 `jcmd/jmap` 等诊断工具,或你的 Java 组件依赖 `tools.jar` 时。
|
|
||||||
|
|
||||||
3) 体积如何优化?
|
|
||||||
— 选择 headless(若无 GUI 需求)、去除无用语言/字体包;或改用 JDK 9+ 使用 jlink(不适用于 8)。
|
|
||||||
|
|
||||||
|
|
||||||
436
doc/打包方案对比.md
@@ -1,436 +0,0 @@
|
|||||||
# 应用打包方案对比与实现
|
|
||||||
|
|
||||||
本文档详细说明 ElectronEgg 应用的两种打包方案:纯绿色版方案 和 双版本方案。
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 方案对比
|
|
||||||
|
|
||||||
| 特性 | 方案一:纯绿色版 | 方案二:双版本打包 |
|
|
||||||
|------|-----------------|-------------------|
|
|
||||||
| **打包产物** | 单个便携版 exe | 安装版 exe + 便携版 exe |
|
|
||||||
| **安装过程** | 无需安装 | 安装版需安装,便携版无需 |
|
|
||||||
| **桌面快捷方式** | 应用内自动创建 | 安装版自动创建,便携版手动或自动 |
|
|
||||||
| **开始菜单** | 无 | 安装版有 |
|
|
||||||
| **卸载程序** | 无(直接删除) | 安装版有 |
|
|
||||||
| **适用场景** | 临时使用、U盘携带 | 正式部署、企业分发 |
|
|
||||||
| **用户体验** | 灵活、轻量 | 专业、完整 |
|
|
||||||
| **打包时间** | 快 | 较慢(打包两次) |
|
|
||||||
| **分发复杂度** | 简单(单文件) | 中等(两个文件) |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 方案一:纯绿色版 + 自动创建快捷方式
|
|
||||||
|
|
||||||
### 特点
|
|
||||||
- ✅ 单个 exe 文件,双击即用
|
|
||||||
- ✅ 首次启动时询问是否创建桌面快捷方式
|
|
||||||
- ✅ 无需安装,无需卸载
|
|
||||||
- ✅ 适合快速分发和临时使用
|
|
||||||
|
|
||||||
### 实现步骤
|
|
||||||
|
|
||||||
#### 1. 修改打包配置
|
|
||||||
|
|
||||||
**文件**:[cmd/builder.json](../cmd/builder.json)
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"productName": "南京灿能工具",
|
|
||||||
"appId": "com.canneng.tool",
|
|
||||||
"copyright": "© 2025 hongawen",
|
|
||||||
"directories": {
|
|
||||||
"output": "out"
|
|
||||||
},
|
|
||||||
"asar": true,
|
|
||||||
"files": [
|
|
||||||
"**/*",
|
|
||||||
"!cmd/",
|
|
||||||
"!data/",
|
|
||||||
"!electron/",
|
|
||||||
"!frontend/",
|
|
||||||
"!logs/",
|
|
||||||
"!out/",
|
|
||||||
"!go/",
|
|
||||||
"!python/"
|
|
||||||
],
|
|
||||||
"extraResources": {
|
|
||||||
"from": "build/extraResources/",
|
|
||||||
"to": "extraResources"
|
|
||||||
},
|
|
||||||
"publish": [
|
|
||||||
{
|
|
||||||
"provider": "generic",
|
|
||||||
"url": "https://your-update-server.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"win": {
|
|
||||||
"icon": "build/icons/icon.ico",
|
|
||||||
"artifactName": "${productName}-${os}-${version}-${arch}.${ext}",
|
|
||||||
"target": [
|
|
||||||
{
|
|
||||||
"target": "portable"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 2. 添加自动创建快捷方式功能
|
|
||||||
|
|
||||||
**文件**:[electron/preload/lifecycle.js](../electron/preload/lifecycle.js)
|
|
||||||
|
|
||||||
在 `windowReady()` 钩子中添加以下代码:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
const { logger } = require('ee-core/log');
|
|
||||||
const { getConfig } = require('ee-core/config');
|
|
||||||
const { getMainWindow } = require('ee-core/electron');
|
|
||||||
|
|
||||||
class Lifecycle {
|
|
||||||
|
|
||||||
async ready() {
|
|
||||||
logger.info('[lifecycle] ready');
|
|
||||||
}
|
|
||||||
|
|
||||||
async electronAppReady() {
|
|
||||||
logger.info('[lifecycle] electron-app-ready');
|
|
||||||
}
|
|
||||||
|
|
||||||
async windowReady() {
|
|
||||||
logger.info('[lifecycle] window-ready');
|
|
||||||
|
|
||||||
// 延迟加载,无白屏
|
|
||||||
const { windowsOption } = getConfig();
|
|
||||||
if (windowsOption.show == false) {
|
|
||||||
const win = getMainWindow();
|
|
||||||
win.once('ready-to-show', () => {
|
|
||||||
win.show();
|
|
||||||
win.focus();
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 绿色版自动创建桌面快捷方式
|
|
||||||
await this.createDesktopShortcut();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 为绿色版创建桌面快捷方式
|
|
||||||
*/
|
|
||||||
async createDesktopShortcut() {
|
|
||||||
const { app, dialog, shell } = require('electron');
|
|
||||||
const path = require('path');
|
|
||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
// 判断是否为便携版(绿色版)
|
|
||||||
// 安装版通常在 C:\Program Files 或 AppData\Local\Programs
|
|
||||||
const isPortable = process.platform === 'win32' &&
|
|
||||||
!process.execPath.includes('Program Files') &&
|
|
||||||
!process.execPath.includes('AppData\\Local\\Programs');
|
|
||||||
|
|
||||||
if (!isPortable) {
|
|
||||||
logger.info('[lifecycle] 非便携版,跳过快捷方式创建');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const desktopPath = app.getPath('desktop');
|
|
||||||
const shortcutPath = path.join(desktopPath, '南京灿能工具.lnk');
|
|
||||||
|
|
||||||
// 如果快捷方式已存在,跳过
|
|
||||||
if (fs.existsSync(shortcutPath)) {
|
|
||||||
logger.info('[lifecycle] 桌面快捷方式已存在');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 询问用户是否创建快捷方式
|
|
||||||
const result = await dialog.showMessageBox({
|
|
||||||
type: 'question',
|
|
||||||
buttons: ['创建', '跳过'],
|
|
||||||
defaultId: 0,
|
|
||||||
title: '创建桌面快捷方式',
|
|
||||||
message: '是否在桌面创建快捷方式?',
|
|
||||||
detail: '方便您下次快速启动应用'
|
|
||||||
});
|
|
||||||
|
|
||||||
if (result.response === 0) {
|
|
||||||
// Windows 下创建快捷方式
|
|
||||||
const success = shell.writeShortcutLink(shortcutPath, {
|
|
||||||
target: process.execPath,
|
|
||||||
cwd: path.dirname(process.execPath),
|
|
||||||
description: '南京灿能C端工具',
|
|
||||||
icon: process.execPath,
|
|
||||||
iconIndex: 0
|
|
||||||
});
|
|
||||||
|
|
||||||
if (success) {
|
|
||||||
logger.info('[lifecycle] 桌面快捷方式创建成功');
|
|
||||||
await dialog.showMessageBox({
|
|
||||||
type: 'info',
|
|
||||||
title: '成功',
|
|
||||||
message: '桌面快捷方式已创建',
|
|
||||||
buttons: ['确定']
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
logger.error('[lifecycle] 桌面快捷方式创建失败');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
logger.info('[lifecycle] 用户跳过创建快捷方式');
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
logger.error('[lifecycle] 创建快捷方式时出错:', error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeClose() {
|
|
||||||
logger.info('[lifecycle] before-close');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Lifecycle.toString = () => '[class Lifecycle]';
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
Lifecycle
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 3. 打包命令
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm run build # 完整构建
|
|
||||||
npm run build-w # 打包 Windows 便携版
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 4. 产物说明
|
|
||||||
|
|
||||||
打包完成后,在 `out/` 目录下会生成:
|
|
||||||
```
|
|
||||||
out/
|
|
||||||
└── 南京灿能工具-win-4.0.0-x64.exe (便携版,约 150-200MB)
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 方案二:双版本打包(安装版 + 便携版)
|
|
||||||
|
|
||||||
### 特点
|
|
||||||
- ✅ 提供两种版本供用户选择
|
|
||||||
- ✅ 安装版:专业、完整的安装体验
|
|
||||||
- ✅ 便携版:灵活、轻量,无需安装
|
|
||||||
- ✅ 适合正式产品发布
|
|
||||||
|
|
||||||
### 实现步骤
|
|
||||||
|
|
||||||
#### 1. 修改打包配置
|
|
||||||
|
|
||||||
**文件**:[cmd/builder.json](../cmd/builder.json)
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"productName": "南京灿能工具",
|
|
||||||
"appId": "com.canneng.tool",
|
|
||||||
"copyright": "© 2025 hongawen",
|
|
||||||
"directories": {
|
|
||||||
"output": "out"
|
|
||||||
},
|
|
||||||
"asar": true,
|
|
||||||
"files": [
|
|
||||||
"**/*",
|
|
||||||
"!cmd/",
|
|
||||||
"!data/",
|
|
||||||
"!electron/",
|
|
||||||
"!frontend/",
|
|
||||||
"!logs/",
|
|
||||||
"!out/",
|
|
||||||
"!go/",
|
|
||||||
"!python/"
|
|
||||||
],
|
|
||||||
"extraResources": {
|
|
||||||
"from": "build/extraResources/",
|
|
||||||
"to": "extraResources"
|
|
||||||
},
|
|
||||||
"nsis": {
|
|
||||||
"oneClick": false,
|
|
||||||
"allowElevation": true,
|
|
||||||
"allowToChangeInstallationDirectory": true,
|
|
||||||
"installerIcon": "build/icons/icon.ico",
|
|
||||||
"uninstallerIcon": "build/icons/icon.ico",
|
|
||||||
"installerHeaderIcon": "build/icons/icon.ico",
|
|
||||||
"createDesktopShortcut": true,
|
|
||||||
"createStartMenuShortcut": true,
|
|
||||||
"shortcutName": "南京灿能工具",
|
|
||||||
"artifactName": "${productName}-Setup-${version}.${ext}"
|
|
||||||
},
|
|
||||||
"portable": {
|
|
||||||
"artifactName": "${productName}-Portable-${version}.${ext}"
|
|
||||||
},
|
|
||||||
"publish": [
|
|
||||||
{
|
|
||||||
"provider": "generic",
|
|
||||||
"url": "https://your-update-server.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"win": {
|
|
||||||
"icon": "build/icons/icon.ico",
|
|
||||||
"target": [
|
|
||||||
{
|
|
||||||
"target": "nsis",
|
|
||||||
"arch": ["x64"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"target": "portable",
|
|
||||||
"arch": ["x64"]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 2. 便携版快捷方式功能(可选)
|
|
||||||
|
|
||||||
如果希望便携版也能自动创建快捷方式,使用**方案一**中的 `createDesktopShortcut()` 代码。
|
|
||||||
|
|
||||||
#### 3. 打包命令
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm run build # 完整构建
|
|
||||||
npm run build-w # 打包两个版本
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 4. 产物说明
|
|
||||||
|
|
||||||
打包完成后,在 `out/` 目录下会生成:
|
|
||||||
```
|
|
||||||
out/
|
|
||||||
├── 南京灿能工具-Setup-4.0.0.exe (安装版,约 150MB)
|
|
||||||
└── 南京灿能工具-Portable-4.0.0.exe (便携版,约 150-200MB)
|
|
||||||
```
|
|
||||||
|
|
||||||
#### 5. 版本差异说明
|
|
||||||
|
|
||||||
**安装版 (NSIS)**:
|
|
||||||
- 需要安装到系统(默认 C:\Program Files)
|
|
||||||
- 自动创建桌面快捷方式
|
|
||||||
- 自动创建开始菜单项
|
|
||||||
- 提供卸载程序
|
|
||||||
- 支持自动更新
|
|
||||||
- 适合企业部署、长期使用
|
|
||||||
|
|
||||||
**便携版 (Portable)**:
|
|
||||||
- 单个 exe 文件
|
|
||||||
- 双击直接运行(首次会自解压)
|
|
||||||
- 无需安装,无需卸载
|
|
||||||
- 可放在 U 盘随身携带
|
|
||||||
- 适合临时使用、测试环境
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 快捷方式创建原理(技术细节)
|
|
||||||
|
|
||||||
### Windows 快捷方式 (.lnk)
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
shell.writeShortcutLink(shortcutPath, {
|
|
||||||
target: process.execPath, // 目标程序路径
|
|
||||||
cwd: path.dirname(process.execPath), // 工作目录
|
|
||||||
description: '应用描述', // 快捷方式描述
|
|
||||||
icon: process.execPath, // 图标路径
|
|
||||||
iconIndex: 0, // 图标索引
|
|
||||||
args: '', // 启动参数(可选)
|
|
||||||
appUserModelId: 'com.app.id' // Windows 应用 ID(可选)
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
### 判断是否为便携版
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
const isPortable = process.platform === 'win32' &&
|
|
||||||
!process.execPath.includes('Program Files') &&
|
|
||||||
!process.execPath.includes('AppData\\Local\\Programs');
|
|
||||||
```
|
|
||||||
|
|
||||||
**原理**:
|
|
||||||
- 安装版通常安装在 `C:\Program Files\YourApp\`
|
|
||||||
- 或者 `C:\Users\用户名\AppData\Local\Programs\YourApp\`
|
|
||||||
- 便携版可以在任意位置运行
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 推荐配置
|
|
||||||
|
|
||||||
### 企业级应用(推荐方案二)
|
|
||||||
```
|
|
||||||
✅ 提供两个版本
|
|
||||||
✅ 主推安装版(专业形象)
|
|
||||||
✅ 提供便携版作为备选
|
|
||||||
```
|
|
||||||
|
|
||||||
### 轻量工具(推荐方案一)
|
|
||||||
```
|
|
||||||
✅ 只提供便携版
|
|
||||||
✅ 应用内自动创建快捷方式
|
|
||||||
✅ 简化分发流程
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 常见问题
|
|
||||||
|
|
||||||
### Q1: 便携版首次启动为什么慢?
|
|
||||||
**A**: 便携版是自解压程序,首次运行需要解压资源到临时目录(约 3-5 秒)。后续启动会快很多。
|
|
||||||
|
|
||||||
### Q2: 便携版数据存储在哪里?
|
|
||||||
**A**:
|
|
||||||
- 用户数据:`C:\Users\用户名\AppData\Roaming\你的appId\`
|
|
||||||
- 临时文件:`C:\Users\用户名\AppData\Local\Temp\`
|
|
||||||
|
|
||||||
### Q3: 如何让便携版也支持自动更新?
|
|
||||||
**A**: 需要配置 `electron-updater`,但便携版更新体验不如安装版。建议:
|
|
||||||
- 安装版:使用自动更新
|
|
||||||
- 便携版:提示用户下载新版本
|
|
||||||
|
|
||||||
### Q4: 可以同时运行两个版本吗?
|
|
||||||
**A**: 不建议。虽然技术上可行,但会导致数据冲突(共享同一个 userData 目录)。
|
|
||||||
|
|
||||||
### Q5: 如何自定义快捷方式图标?
|
|
||||||
**A**: 在 `build/icons/` 目录放置 `.ico` 文件,并在 `builder.json` 中配置:
|
|
||||||
```json
|
|
||||||
"win": {
|
|
||||||
"icon": "build/icons/custom-icon.ico"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 测试检查清单
|
|
||||||
|
|
||||||
打包完成后,请进行以下测试:
|
|
||||||
|
|
||||||
### 安装版测试
|
|
||||||
- [ ] 安装到默认路径成功
|
|
||||||
- [ ] 安装到自定义路径成功
|
|
||||||
- [ ] 桌面快捷方式正常
|
|
||||||
- [ ] 开始菜单项正常
|
|
||||||
- [ ] 应用启动正常
|
|
||||||
- [ ] 卸载程序正常
|
|
||||||
|
|
||||||
### 便携版测试
|
|
||||||
- [ ] 双击 exe 正常启动
|
|
||||||
- [ ] 首次启动自动创建快捷方式(如已实现)
|
|
||||||
- [ ] 桌面快捷方式可用
|
|
||||||
- [ ] 应用功能正常
|
|
||||||
- [ ] 关闭后再次启动正常
|
|
||||||
- [ ] 可移动到其他目录运行
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 参考资源
|
|
||||||
|
|
||||||
- electron-builder 官方文档: https://www.electron.build/
|
|
||||||
- NSIS 配置: https://www.electron.build/configuration/nsis
|
|
||||||
- Portable 配置: https://www.electron.build/configuration/portable
|
|
||||||
- Electron shell API: https://www.electronjs.org/docs/latest/api/shell
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
*文档创建时间: 2025-10-14*
|
|
||||||
*作者: hongawen*
|
|
||||||
65
doc/管理员权限说明.md
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
# 管理员权限说明
|
||||||
|
|
||||||
|
> ⚠️ **文档已过期** - 本文档描述的是旧版服务模式,自 2025-12-01 起已改用**进程模式(绿色包)**。
|
||||||
|
>
|
||||||
|
> 🎉 **新版本不再需要管理员权限!**
|
||||||
|
>
|
||||||
|
> 参考最新文档:`MySQL进程模式改造方案.md` 和 `NPQS-9100绿色包完整指南.md`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ~~🔐 为什么需要管理员权限?~~(已废弃)
|
||||||
|
|
||||||
|
~~NPQS9100 需要管理 MySQL Windows 服务,执行以下操作:~~
|
||||||
|
- ~~✅ 安装 MySQL 服务 (`mysql9100`)~~
|
||||||
|
- ~~✅ 启动/停止服务~~
|
||||||
|
- ~~✅ 删除服务(重新安装时)~~
|
||||||
|
|
||||||
|
~~这些操作都需要 **Windows 管理员权限**。~~
|
||||||
|
|
||||||
|
**现状**:已改用进程模式,直接启动 `mysqld.exe` 进程,无需注册 Windows 服务,**完全不需要管理员权限**。
|
||||||
|
|
||||||
|
## 🎉 新版启动方式(进程模式)
|
||||||
|
|
||||||
|
**当前版本启动非常简单**:
|
||||||
|
|
||||||
|
1. ✅ 双击 `NPQS9100.exe` 即可启动
|
||||||
|
2. ✅ 无需管理员权限
|
||||||
|
3. ✅ 无 UAC 弹窗
|
||||||
|
4. ✅ 解压即用,完全绿色
|
||||||
|
|
||||||
|
**MySQL 和 Spring Boot 会在应用启动时自动启动,退出时自动清理。**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ~~以下内容已废弃(保留作为历史参考)~~
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>点击展开查看旧版(服务模式)说明</summary>
|
||||||
|
|
||||||
|
### ~~两种启动方式(已废弃)~~
|
||||||
|
|
||||||
|
#### ~~方式 1:使用启动器(推荐)~~
|
||||||
|
|
||||||
|
~~打包后的目录中有一个 `NPQS9100-启动器.bat` 文件。~~
|
||||||
|
|
||||||
|
#### ~~方式 2:手动以管理员身份运行~~
|
||||||
|
|
||||||
|
~~右键点击 `NPQS9100.exe` 选择"以管理员身份运行"~~
|
||||||
|
|
||||||
|
### ~~常见问题(已废弃)~~
|
||||||
|
|
||||||
|
~~Q: MySQL 服务安装后还需要管理员权限吗?~~
|
||||||
|
A: **新版本不使用 Windows 服务,因此完全不需要管理员权限。**
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📝 版本历史
|
||||||
|
|
||||||
|
| 日期 | 版本 | 说明 |
|
||||||
|
|------|------|------|
|
||||||
|
| 2025-12-01 | v2.0 | 改用进程模式,无需管理员权限 ✅ |
|
||||||
|
| 2025-10-17 | v1.0 | 服务模式,需要管理员权限(已废弃)|
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ module.exports = () => {
|
|||||||
singleLock: true,
|
singleLock: true,
|
||||||
windowsOption: {
|
windowsOption: {
|
||||||
title: 'NPQS9100-自动检测平台',
|
title: 'NPQS9100-自动检测平台',
|
||||||
menuBarVisible: true, // 显示菜单栏,方便查看日志
|
menuBarVisible: false, // 隐藏菜单栏
|
||||||
width: 1920,
|
width: 1920,
|
||||||
height: 1000,
|
height: 1000,
|
||||||
minWidth: 1024,
|
minWidth: 1024,
|
||||||
|
|||||||
@@ -1,75 +0,0 @@
|
|||||||
const path = require('path');
|
|
||||||
|
|
||||||
// 动态获取 scripts 目录路径
|
|
||||||
function getScriptsPath(scriptName) {
|
|
||||||
// 开发环境
|
|
||||||
const devPath = path.join(__dirname, '../../scripts', scriptName);
|
|
||||||
// 生产环境(打包后)
|
|
||||||
const prodPath = path.join(process.resourcesPath, 'scripts', scriptName);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 先尝试开发环境路径
|
|
||||||
require.resolve(devPath);
|
|
||||||
return devPath;
|
|
||||||
} catch (e) {
|
|
||||||
// 如果开发环境路径不存在,使用生产环境路径
|
|
||||||
return prodPath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 延迟加载 MySQLManager
|
|
||||||
let MySQLManager = null;
|
|
||||||
function getMySQLManager() {
|
|
||||||
if (!MySQLManager) {
|
|
||||||
MySQLManager = require(getScriptsPath('start-mysql'));
|
|
||||||
}
|
|
||||||
return MySQLManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
class MySQLController {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 启动MySQL服务
|
|
||||||
*/
|
|
||||||
async start() {
|
|
||||||
try {
|
|
||||||
const MySQLManagerClass = getMySQLManager();
|
|
||||||
const mysqlManager = new MySQLManagerClass();
|
|
||||||
await mysqlManager.start();
|
|
||||||
return { success: true, message: 'MySQL started successfully' };
|
|
||||||
} catch (error) {
|
|
||||||
return { success: false, message: error.message };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 停止MySQL服务
|
|
||||||
*/
|
|
||||||
async stop() {
|
|
||||||
try {
|
|
||||||
const MySQLManagerClass = getMySQLManager();
|
|
||||||
const mysqlManager = new MySQLManagerClass();
|
|
||||||
await mysqlManager.stop();
|
|
||||||
return { success: true, message: 'MySQL stopped successfully' };
|
|
||||||
} catch (error) {
|
|
||||||
return { success: false, message: error.message };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取MySQL连接配置
|
|
||||||
*/
|
|
||||||
async getConnectionConfig() {
|
|
||||||
try {
|
|
||||||
const MySQLManagerClass = getMySQLManager();
|
|
||||||
const mysqlManager = new MySQLManagerClass();
|
|
||||||
const config = mysqlManager.getConnectionConfig();
|
|
||||||
return { success: true, data: config };
|
|
||||||
} catch (error) {
|
|
||||||
return { success: false, message: error.message };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MySQLController.toString = () => '[class MySQLController]';
|
|
||||||
module.exports = MySQLController;
|
|
||||||
205
electron/main.js
@@ -1,27 +1,132 @@
|
|||||||
const { ElectronEgg } = require('ee-core');
|
const { ElectronEgg } = require('ee-core');
|
||||||
const { app, Menu, ipcMain } = require('electron');
|
const { app, Menu, ipcMain, Tray, dialog, BrowserWindow } = require('electron');
|
||||||
|
const path = require('path');
|
||||||
const lifecycle = require('./preload/lifecycle');
|
const lifecycle = require('./preload/lifecycle');
|
||||||
const { preload } = require('./preload');
|
const { preload } = require('./preload');
|
||||||
|
|
||||||
// new app
|
// new app
|
||||||
const electronApp = new ElectronEgg();
|
const electronApp = new ElectronEgg();
|
||||||
|
|
||||||
|
// 全局变量
|
||||||
|
let tray = null;
|
||||||
|
let isQuitting = false;
|
||||||
|
|
||||||
|
// 创建系统托盘
|
||||||
|
function createTray() {
|
||||||
|
try {
|
||||||
|
// 开发环境和生产环境的图标路径
|
||||||
|
const isDev = !process.resourcesPath;
|
||||||
|
const iconPath = isDev
|
||||||
|
? path.join(__dirname, '..', 'public', 'images', 'tray.png')
|
||||||
|
: path.join(process.resourcesPath, 'app.asar.unpacked', 'public', 'images', 'tray.png');
|
||||||
|
|
||||||
|
console.log('[Tray] Icon path:', iconPath);
|
||||||
|
|
||||||
|
// 检查图标文件是否存在
|
||||||
|
const fs = require('fs');
|
||||||
|
if (!fs.existsSync(iconPath)) {
|
||||||
|
console.error('[Tray] Icon file not found:', iconPath);
|
||||||
|
// 如果找不到,尝试使用备用路径(主图标)
|
||||||
|
const fallbackIcon = isDev
|
||||||
|
? path.join(__dirname, '..', 'public', 'images', 'icon.png')
|
||||||
|
: path.join(process.resourcesPath, 'app.asar.unpacked', 'public', 'images', 'icon.png');
|
||||||
|
|
||||||
|
if (fs.existsSync(fallbackIcon)) {
|
||||||
|
console.log('[Tray] Using fallback icon:', fallbackIcon);
|
||||||
|
tray = new Tray(fallbackIcon);
|
||||||
|
} else {
|
||||||
|
console.error('[Tray] No icon available, tray not created');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tray = new Tray(iconPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
tray.setToolTip('NPQS-9100自动检测平台');
|
||||||
|
console.log('[Tray] Tray created successfully');
|
||||||
|
|
||||||
|
// 创建托盘菜单
|
||||||
|
const contextMenu = Menu.buildFromTemplate([
|
||||||
|
{
|
||||||
|
label: '显示主窗口',
|
||||||
|
click: () => {
|
||||||
|
const mainWindow = BrowserWindow.getAllWindows()[0];
|
||||||
|
if (mainWindow) {
|
||||||
|
if (mainWindow.isMinimized()) {
|
||||||
|
mainWindow.restore();
|
||||||
|
}
|
||||||
|
mainWindow.show();
|
||||||
|
mainWindow.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ type: 'separator' },
|
||||||
|
{
|
||||||
|
label: '退出',
|
||||||
|
click: async () => {
|
||||||
|
// 弹出确认对话框
|
||||||
|
const { response } = await dialog.showMessageBox({
|
||||||
|
type: 'question',
|
||||||
|
title: '退出确认',
|
||||||
|
message: '确定退出应用吗?',
|
||||||
|
buttons: ['取消', '确定退出'],
|
||||||
|
defaultId: 0,
|
||||||
|
cancelId: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response === 1) {
|
||||||
|
// 用户点击了"确定退出"
|
||||||
|
isQuitting = true;
|
||||||
|
|
||||||
|
// 获取主窗口
|
||||||
|
const mainWindow = BrowserWindow.getAllWindows()[0];
|
||||||
|
|
||||||
|
// 移除所有 close 监听器,避免阻止关闭
|
||||||
|
if (mainWindow) {
|
||||||
|
mainWindow.removeAllListeners('close');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行清理
|
||||||
|
await lifecycle.cleanup();
|
||||||
|
|
||||||
|
// 退出应用
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
tray.setContextMenu(contextMenu);
|
||||||
|
|
||||||
|
// 双击托盘图标显示窗口
|
||||||
|
tray.on('double-click', () => {
|
||||||
|
const mainWindow = BrowserWindow.getAllWindows()[0];
|
||||||
|
if (mainWindow) {
|
||||||
|
if (mainWindow.isMinimized()) {
|
||||||
|
mainWindow.restore();
|
||||||
|
}
|
||||||
|
mainWindow.show();
|
||||||
|
mainWindow.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('[Tray] Failed to create tray:', error);
|
||||||
|
tray = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 创建应用菜单
|
// 创建应用菜单
|
||||||
function createApplicationMenu() {
|
function createApplicationMenu() {
|
||||||
|
// 生产环境隐藏菜单栏
|
||||||
|
Menu.setApplicationMenu(null);
|
||||||
|
|
||||||
|
// 调试时可以使用下面的菜单(取消注释)
|
||||||
|
/*
|
||||||
const template = [
|
const template = [
|
||||||
{
|
{
|
||||||
label: '查看',
|
label: '查看',
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
|
||||||
label: '显示/隐藏服务日志',
|
|
||||||
accelerator: 'F12',
|
|
||||||
click: () => {
|
|
||||||
if (lifecycle.logWindowManager) {
|
|
||||||
lifecycle.logWindowManager.toggle();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ type: 'separator' },
|
|
||||||
{ role: 'reload', label: '刷新' },
|
{ role: 'reload', label: '刷新' },
|
||||||
{ role: 'forceReload', label: '强制刷新' },
|
{ role: 'forceReload', label: '强制刷新' },
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
@@ -47,9 +152,10 @@ function createApplicationMenu() {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const menu = Menu.buildFromTemplate(template);
|
const menu = Menu.buildFromTemplate(template);
|
||||||
Menu.setApplicationMenu(menu);
|
Menu.setApplicationMenu(menu);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注册 IPC 处理器
|
// 注册 IPC 处理器
|
||||||
@@ -71,14 +177,87 @@ ipcMain.handle('toggle-log-window', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 检查是否正在退出
|
||||||
|
ipcMain.handle('is-quitting', () => {
|
||||||
|
return isQuitting;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 处理单实例:当尝试启动第二个实例时,聚焦已有窗口
|
||||||
|
app.on('second-instance', (event, commandLine, workingDirectory) => {
|
||||||
|
console.log('[Main] Second instance detected, focusing main window...');
|
||||||
|
|
||||||
|
// 获取主窗口
|
||||||
|
const mainWindow = BrowserWindow.getAllWindows().find(win => {
|
||||||
|
return win.getTitle().includes('NPQS') || win.getTitle().includes('检测平台');
|
||||||
|
});
|
||||||
|
|
||||||
|
if (mainWindow) {
|
||||||
|
// 如果窗口最小化,恢复它
|
||||||
|
if (mainWindow.isMinimized()) {
|
||||||
|
mainWindow.restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果窗口隐藏,显示它
|
||||||
|
if (!mainWindow.isVisible()) {
|
||||||
|
mainWindow.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 聚焦窗口
|
||||||
|
mainWindow.focus();
|
||||||
|
|
||||||
|
console.log('[Main] Main window focused');
|
||||||
|
} else {
|
||||||
|
console.warn('[Main] Main window not found');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 监听应用退出前事件(确保清理托盘)
|
||||||
|
app.on('before-quit', () => {
|
||||||
|
console.log('[Main] App before-quit, destroying tray...');
|
||||||
|
|
||||||
|
// 销毁托盘图标
|
||||||
|
if (tray && !tray.isDestroyed()) {
|
||||||
|
tray.destroy();
|
||||||
|
tray = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 监听 will-quit 事件(强制退出时)
|
||||||
|
app.on('will-quit', () => {
|
||||||
|
console.log('[Main] App will-quit');
|
||||||
|
|
||||||
|
// 确保托盘被销毁
|
||||||
|
if (tray && !tray.isDestroyed()) {
|
||||||
|
tray.destroy();
|
||||||
|
tray = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// register lifecycle (绑定 this 上下文)
|
// register lifecycle (绑定 this 上下文)
|
||||||
electronApp.register("ready", lifecycle.ready.bind(lifecycle));
|
electronApp.register("ready", lifecycle.ready.bind(lifecycle));
|
||||||
electronApp.register("electron-app-ready", () => {
|
electronApp.register("electron-app-ready", () => {
|
||||||
lifecycle.electronAppReady.bind(lifecycle)();
|
lifecycle.electronAppReady.bind(lifecycle)();
|
||||||
createApplicationMenu();
|
createApplicationMenu();
|
||||||
|
createTray(); // 创建系统托盘
|
||||||
});
|
});
|
||||||
electronApp.register("window-ready", lifecycle.windowReady.bind(lifecycle));
|
electronApp.register("window-ready", lifecycle.windowReady.bind(lifecycle));
|
||||||
electronApp.register("before-close", lifecycle.beforeClose.bind(lifecycle));
|
electronApp.register("before-close", async () => {
|
||||||
|
// 如果不是真正退出,不执行清理
|
||||||
|
if (!isQuitting) {
|
||||||
|
console.log('[Main] Not quitting, skip cleanup');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('[Main] Quitting, execute cleanup');
|
||||||
|
|
||||||
|
// 销毁托盘图标
|
||||||
|
if (tray && !tray.isDestroyed()) {
|
||||||
|
tray.destroy();
|
||||||
|
tray = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
await lifecycle.beforeClose.bind(lifecycle)();
|
||||||
|
});
|
||||||
|
|
||||||
// register preload
|
// register preload
|
||||||
electronApp.register("preload", preload);
|
electronApp.register("preload", preload);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ const path = require('path');
|
|||||||
const { logger } = require('ee-core/log');
|
const { logger } = require('ee-core/log');
|
||||||
const { getConfig } = require('ee-core/config');
|
const { getConfig } = require('ee-core/config');
|
||||||
const { getMainWindow } = require('ee-core/electron');
|
const { getMainWindow } = require('ee-core/electron');
|
||||||
const ps = require('ee-core/ps');
|
const { getBaseDir } = require('ee-core/ps');
|
||||||
const { app } = require('electron');
|
const { app } = require('electron');
|
||||||
|
|
||||||
// 动态获取 scripts 目录路径
|
// 动态获取 scripts 目录路径
|
||||||
@@ -12,7 +12,8 @@ function getScriptsPath(scriptName) {
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
// 判断是否是打包后的环境
|
// 判断是否是打包后的环境
|
||||||
const isProd = process.resourcesPath && process.resourcesPath.includes('win-unpacked');
|
// 只要 process.resourcesPath 存在,就是打包后的环境(无论在哪个目录)
|
||||||
|
const isProd = !!process.resourcesPath;
|
||||||
|
|
||||||
if (isProd) {
|
if (isProd) {
|
||||||
// 生产环境(打包后):从 resources 目录
|
// 生产环境(打包后):从 resources 目录
|
||||||
@@ -44,11 +45,11 @@ function getScriptsPath(scriptName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 延迟加载 scripts
|
// 延迟加载 scripts
|
||||||
let MySQLManager, JavaRunner, ConfigGenerator, PortChecker, StartupManager, LogWindowManager;
|
let MySQLServiceManager, JavaRunner, ConfigGenerator, PortChecker, StartupManager, LogWindowManager;
|
||||||
|
|
||||||
function loadScripts() {
|
function loadScripts() {
|
||||||
if (!MySQLManager) {
|
if (!MySQLServiceManager) {
|
||||||
MySQLManager = require(getScriptsPath('start-mysql'));
|
MySQLServiceManager = require(getScriptsPath('mysql-service-manager'));
|
||||||
JavaRunner = require(getScriptsPath('java-runner'));
|
JavaRunner = require(getScriptsPath('java-runner'));
|
||||||
ConfigGenerator = require(getScriptsPath('config-generator'));
|
ConfigGenerator = require(getScriptsPath('config-generator'));
|
||||||
PortChecker = require(getScriptsPath('port-checker'));
|
PortChecker = require(getScriptsPath('port-checker'));
|
||||||
@@ -59,7 +60,7 @@ function loadScripts() {
|
|||||||
|
|
||||||
class Lifecycle {
|
class Lifecycle {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.mysqlManager = null;
|
this.mysqlServiceManager = null;
|
||||||
this.javaRunner = null;
|
this.javaRunner = null;
|
||||||
this.startupManager = null;
|
this.startupManager = null;
|
||||||
this.logWindowManager = null;
|
this.logWindowManager = null;
|
||||||
@@ -74,91 +75,90 @@ class Lifecycle {
|
|||||||
async ready() {
|
async ready() {
|
||||||
logger.info('[lifecycle] ready');
|
logger.info('[lifecycle] ready');
|
||||||
// 延迟加载 scripts
|
// 延迟加载 scripts
|
||||||
if (ps.isProd()) {
|
loadScripts();
|
||||||
loadScripts();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 完整的应用启动流程
|
* 完整的应用启动流程
|
||||||
*/
|
*/
|
||||||
async startApplication() {
|
async startApplication() {
|
||||||
|
this.logWindowManager.addLog('system', '▶ 步骤1: 开始启动流程...');
|
||||||
|
logger.info('[lifecycle] Starting application...');
|
||||||
|
|
||||||
|
this.logWindowManager.addLog('system', '▶ 步骤2: 加载配置信息...');
|
||||||
const config = getConfig();
|
const config = getConfig();
|
||||||
|
logger.info('[lifecycle] Config loaded:', JSON.stringify(config));
|
||||||
|
|
||||||
// 步骤1: 初始化
|
// 步骤1: 初始化
|
||||||
|
this.logWindowManager.addLog('system', '▶ 步骤3: 初始化启动管理器...');
|
||||||
this.startupManager.updateProgress('init');
|
this.startupManager.updateProgress('init');
|
||||||
await this.sleep(500);
|
await this.sleep(500);
|
||||||
|
|
||||||
// 步骤2: 检测 MySQL 端口
|
// 步骤2-4: 确保 MySQL 服务运行
|
||||||
this.startupManager.updateProgress('check-mysql-port');
|
this.logWindowManager.addLog('system', '▶ 步骤4: 检查 MySQL 配置...');
|
||||||
this.logWindowManager.addLog('system', '正在检测可用的 MySQL 端口(从3306开始)...');
|
logger.info('[lifecycle] MySQL config check - enable:', config.mysql?.enable, 'autoStart:', config.mysql?.autoStart);
|
||||||
|
|
||||||
this.mysqlPort = await PortChecker.findAvailablePort(3306, 100);
|
|
||||||
|
|
||||||
if (this.mysqlPort === -1) {
|
|
||||||
this.logWindowManager.addLog('error', 'MySQL 端口检测失败:3306-3405 全部被占用');
|
|
||||||
throw new Error('无法找到可用的 MySQL 端口(3306-3405 全部被占用)');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.mysqlPort !== 3306) {
|
|
||||||
this.logWindowManager.addLog('warn', `MySQL 默认端口 3306 已被占用,自动切换到端口: ${this.mysqlPort}`);
|
|
||||||
} else {
|
|
||||||
this.logWindowManager.addLog('success', `MySQL 将使用默认端口: ${this.mysqlPort}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info(`[lifecycle] MySQL will use port: ${this.mysqlPort}`);
|
|
||||||
this.startupManager.updateProgress('check-mysql-port', { mysqlPort: this.mysqlPort });
|
|
||||||
await this.sleep(500);
|
|
||||||
|
|
||||||
// 步骤3: 启动 MySQL
|
|
||||||
if (config.mysql && config.mysql.enable && config.mysql.autoStart) {
|
if (config.mysql && config.mysql.enable && config.mysql.autoStart) {
|
||||||
this.startupManager.updateProgress('start-mysql', { mysqlPort: this.mysqlPort });
|
this.startupManager.updateProgress('check-mysql-port');
|
||||||
this.logWindowManager.addLog('mysql', `正在启动 MySQL,端口: ${this.mysqlPort}`);
|
this.logWindowManager.addLog('system', '▶ 步骤5: 启动 MySQL 服务管理器...');
|
||||||
|
|
||||||
this.mysqlManager = new MySQLManager();
|
this.mysqlServiceManager = new MySQLServiceManager(this.logWindowManager);
|
||||||
|
this.logWindowManager.addLog('system', '正在检查 MySQL 服务状态...');
|
||||||
|
|
||||||
// 监听 MySQL 输出
|
try {
|
||||||
const actualPort = await this.mysqlManager.start(this.mysqlPort);
|
// 使用服务管理器确保MySQL服务运行
|
||||||
this.setupMySQLLogging(this.mysqlManager.process);
|
this.logWindowManager.addLog('system', '▶ 步骤6: 确保 MySQL 服务运行中...');
|
||||||
|
this.mysqlPort = await this.mysqlServiceManager.ensureServiceRunning(
|
||||||
logger.info(`[lifecycle] MySQL started on port: ${actualPort}`);
|
PortChecker.findAvailablePort.bind(PortChecker),
|
||||||
this.logWindowManager.addLog('success', `MySQL 已启动,端口: ${actualPort}`);
|
PortChecker.waitForPort.bind(PortChecker)
|
||||||
|
);
|
||||||
// 步骤4: 等待 MySQL 就绪
|
|
||||||
this.startupManager.updateProgress('wait-mysql', { mysqlPort: actualPort });
|
logger.info(`[lifecycle] MySQL service running on port: ${this.mysqlPort}`);
|
||||||
this.logWindowManager.addLog('mysql', '等待 MySQL 就绪...');
|
this.logWindowManager.addLog('success', `✓ MySQL 服务已就绪,端口: ${this.mysqlPort}`);
|
||||||
|
this.startupManager.updateProgress('wait-mysql', { mysqlPort: this.mysqlPort });
|
||||||
const mysqlReady = await PortChecker.waitForPort(actualPort, 30000);
|
await this.sleep(500);
|
||||||
|
} catch (error) {
|
||||||
if (!mysqlReady) {
|
logger.error('[lifecycle] MySQL error:', error);
|
||||||
this.logWindowManager.addLog('error', `MySQL 启动超时(端口 ${actualPort} 未响应)`);
|
this.logWindowManager.addLog('error', `MySQL 错误: ${error.message}`);
|
||||||
throw new Error(`MySQL 启动超时(端口 ${actualPort} 未响应)`);
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info('[lifecycle] MySQL is ready');
|
|
||||||
this.logWindowManager.addLog('success', 'MySQL 已就绪!');
|
|
||||||
await this.sleep(500);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 步骤5: 检测 Java 端口
|
// 步骤5: 检测 Java 端口
|
||||||
|
this.logWindowManager.addLog('system', '▶ 步骤7: 检测可用的 Java 端口(从18093开始)...');
|
||||||
this.startupManager.updateProgress('check-java-port', { mysqlPort: this.mysqlPort });
|
this.startupManager.updateProgress('check-java-port', { mysqlPort: this.mysqlPort });
|
||||||
this.logWindowManager.addLog('system', '正在检测可用的 Java 端口(从18092开始)...');
|
|
||||||
|
this.javaPort = await PortChecker.findAvailablePort(18093, 100);
|
||||||
this.javaPort = await PortChecker.findAvailablePort(18092, 100);
|
|
||||||
|
|
||||||
if (this.javaPort === -1) {
|
if (this.javaPort === -1) {
|
||||||
this.logWindowManager.addLog('error', 'Java 端口检测失败:18092-18191 全部被占用');
|
this.logWindowManager.addLog('error', 'Java 端口检测失败:18093-18192 全部被占用');
|
||||||
throw new Error('无法找到可用的后端服务端口(18092-18191 全部被占用)');
|
throw new Error('无法找到可用的后端服务端口(18093-18192 全部被占用)');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.javaPort !== 18092) {
|
// 步骤5.5: 检测 WebSocket 端口
|
||||||
this.logWindowManager.addLog('warn', `Java 默认端口 18092 已被占用,自动切换到端口: ${this.javaPort}`);
|
this.logWindowManager.addLog('system', '▶ 步骤8: 检测可用的 WebSocket 端口(从7778开始)...');
|
||||||
|
|
||||||
|
this.websocketPort = await PortChecker.findAvailablePort(7778, 100);
|
||||||
|
|
||||||
|
if (this.websocketPort === -1) {
|
||||||
|
this.logWindowManager.addLog('error', 'WebSocket 端口检测失败:7778-7877 全部被占用');
|
||||||
|
throw new Error('无法找到可用的 WebSocket 端口(7778-7877 全部被占用)');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.javaPort !== 18093) {
|
||||||
|
this.logWindowManager.addLog('warn', `⚠ Java 默认端口 18093 已被占用,自动切换到端口: ${this.javaPort}`);
|
||||||
} else {
|
} else {
|
||||||
this.logWindowManager.addLog('success', `Java 将使用默认端口: ${this.javaPort}`);
|
this.logWindowManager.addLog('success', `✓ Java 将使用默认端口: ${this.javaPort}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.websocketPort !== 7778) {
|
||||||
|
this.logWindowManager.addLog('warn', `⚠ WebSocket 默认端口 7778 已被占用,自动切换到端口: ${this.websocketPort}`);
|
||||||
|
} else {
|
||||||
|
this.logWindowManager.addLog('success', `✓ WebSocket 将使用默认端口: ${this.websocketPort}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`[lifecycle] Spring Boot will use port: ${this.javaPort}`);
|
logger.info(`[lifecycle] Spring Boot will use port: ${this.javaPort}`);
|
||||||
|
logger.info(`[lifecycle] WebSocket will use port: ${this.websocketPort}`);
|
||||||
this.startupManager.updateProgress('check-java-port', {
|
this.startupManager.updateProgress('check-java-port', {
|
||||||
mysqlPort: this.mysqlPort,
|
mysqlPort: this.mysqlPort,
|
||||||
javaPort: this.javaPort
|
javaPort: this.javaPort
|
||||||
@@ -166,28 +166,35 @@ class Lifecycle {
|
|||||||
await this.sleep(500);
|
await this.sleep(500);
|
||||||
|
|
||||||
// 步骤6: 生成配置文件
|
// 步骤6: 生成配置文件
|
||||||
|
this.logWindowManager.addLog('system', '▶ 步骤9: 生成 Spring Boot 配置文件...');
|
||||||
this.startupManager.updateProgress('generate-config', {
|
this.startupManager.updateProgress('generate-config', {
|
||||||
mysqlPort: this.mysqlPort,
|
mysqlPort: this.mysqlPort,
|
||||||
javaPort: this.javaPort
|
javaPort: this.javaPort,
|
||||||
|
websocketPort: this.websocketPort
|
||||||
});
|
});
|
||||||
|
|
||||||
const configGenerator = new ConfigGenerator();
|
const configGenerator = new ConfigGenerator();
|
||||||
const { configPath, dataPath } = await configGenerator.generateConfig({
|
const { configPath, dataPath } = await configGenerator.generateConfig({
|
||||||
mysqlPort: this.mysqlPort,
|
mysqlPort: this.mysqlPort,
|
||||||
javaPort: this.javaPort,
|
javaPort: this.javaPort,
|
||||||
|
websocketPort: this.websocketPort,
|
||||||
mysqlPassword: 'njcnpqs'
|
mysqlPassword: 'njcnpqs'
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.info(`[lifecycle] Configuration generated at: ${configPath}`);
|
logger.info(`[lifecycle] Configuration generated at: ${configPath}`);
|
||||||
logger.info(`[lifecycle] Data directory: ${dataPath}`);
|
logger.info(`[lifecycle] Data directory: ${dataPath}`);
|
||||||
|
this.logWindowManager.addLog('success', `✓ 配置文件已生成: ${configPath}`);
|
||||||
|
this.logWindowManager.addLog('system', ` 数据目录: ${dataPath}`);
|
||||||
this.startupManager.updateProgress('generate-config', {
|
this.startupManager.updateProgress('generate-config', {
|
||||||
mysqlPort: this.mysqlPort,
|
mysqlPort: this.mysqlPort,
|
||||||
javaPort: this.javaPort,
|
javaPort: this.javaPort,
|
||||||
|
websocketPort: this.websocketPort,
|
||||||
dataPath: dataPath
|
dataPath: dataPath
|
||||||
});
|
});
|
||||||
await this.sleep(500);
|
await this.sleep(500);
|
||||||
|
|
||||||
// 步骤7: 启动 Spring Boot
|
// 步骤7: 启动 Spring Boot
|
||||||
|
this.logWindowManager.addLog('system', '▶ 步骤10: 启动 Spring Boot 应用...');
|
||||||
this.startupManager.updateProgress('start-java', {
|
this.startupManager.updateProgress('start-java', {
|
||||||
mysqlPort: this.mysqlPort,
|
mysqlPort: this.mysqlPort,
|
||||||
javaPort: this.javaPort,
|
javaPort: this.javaPort,
|
||||||
@@ -197,6 +204,7 @@ class Lifecycle {
|
|||||||
await this.startSpringBoot(configPath);
|
await this.startSpringBoot(configPath);
|
||||||
|
|
||||||
// 步骤8: 等待 Spring Boot 就绪
|
// 步骤8: 等待 Spring Boot 就绪
|
||||||
|
this.logWindowManager.addLog('system', '▶ 步骤11: 等待 Spring Boot 就绪(最多60秒)...');
|
||||||
this.startupManager.updateProgress('wait-java', {
|
this.startupManager.updateProgress('wait-java', {
|
||||||
mysqlPort: this.mysqlPort,
|
mysqlPort: this.mysqlPort,
|
||||||
javaPort: this.javaPort,
|
javaPort: this.javaPort,
|
||||||
@@ -207,13 +215,16 @@ class Lifecycle {
|
|||||||
|
|
||||||
if (!javaReady) {
|
if (!javaReady) {
|
||||||
logger.warn(`[lifecycle] Spring Boot 启动超时,但继续启动应用`);
|
logger.warn(`[lifecycle] Spring Boot 启动超时,但继续启动应用`);
|
||||||
|
this.logWindowManager.addLog('warn', '⚠ Spring Boot 启动超时(60秒),但应用将继续启动');
|
||||||
} else {
|
} else {
|
||||||
logger.info('[lifecycle] Spring Boot is ready');
|
logger.info('[lifecycle] Spring Boot is ready');
|
||||||
|
this.logWindowManager.addLog('success', '✓ Spring Boot 启动成功!');
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.sleep(1000);
|
await this.sleep(1000);
|
||||||
|
|
||||||
// 步骤9: 完成
|
// 步骤9: 完成
|
||||||
|
this.logWindowManager.addLog('system', '▶ 步骤12: 启动完成,准备显示主窗口...');
|
||||||
this.startupManager.updateProgress('done', {
|
this.startupManager.updateProgress('done', {
|
||||||
mysqlPort: this.mysqlPort,
|
mysqlPort: this.mysqlPort,
|
||||||
javaPort: this.javaPort,
|
javaPort: this.javaPort,
|
||||||
@@ -225,6 +236,7 @@ class Lifecycle {
|
|||||||
this.logWindowManager.addLog('success', '✓ NPQS9100 启动完成!所有服务正常运行');
|
this.logWindowManager.addLog('success', '✓ NPQS9100 启动完成!所有服务正常运行');
|
||||||
this.logWindowManager.addLog('system', `✓ MySQL 端口: ${this.mysqlPort}`);
|
this.logWindowManager.addLog('system', `✓ MySQL 端口: ${this.mysqlPort}`);
|
||||||
this.logWindowManager.addLog('system', `✓ Java 端口: ${this.javaPort}`);
|
this.logWindowManager.addLog('system', `✓ Java 端口: ${this.javaPort}`);
|
||||||
|
this.logWindowManager.addLog('system', `✓ WebSocket 端口: ${this.websocketPort}`);
|
||||||
this.logWindowManager.addLog('system', `✓ 数据目录: ${dataPath}`);
|
this.logWindowManager.addLog('system', `✓ 数据目录: ${dataPath}`);
|
||||||
this.logWindowManager.addLog('system', '='.repeat(60));
|
this.logWindowManager.addLog('system', '='.repeat(60));
|
||||||
this.logWindowManager.addLog('system', '应用即将启动...');
|
this.logWindowManager.addLog('system', '应用即将启动...');
|
||||||
@@ -239,13 +251,41 @@ class Lifecycle {
|
|||||||
const win = getMainWindow();
|
const win = getMainWindow();
|
||||||
win.show();
|
win.show();
|
||||||
win.focus();
|
win.focus();
|
||||||
|
|
||||||
// 添加主窗口关闭事件监听
|
// 窗口关闭时,使用 Electron 原生对话框确认
|
||||||
win.on('close', async () => {
|
win.on('close', async (event) => {
|
||||||
logger.info('[lifecycle] Main window closing, cleaning up...');
|
if (global.isConfirmedExit) {
|
||||||
await this.cleanup();
|
logger.info('[lifecycle] Exit already confirmed, proceeding');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
logger.info('[lifecycle] Window close intercepted, showing exit confirm dialog');
|
||||||
|
|
||||||
|
const { dialog } = require('electron');
|
||||||
|
const { response } = await dialog.showMessageBox(win, {
|
||||||
|
type: 'question',
|
||||||
|
buttons: ['取消', '退出'],
|
||||||
|
defaultId: 1,
|
||||||
|
cancelId: 0,
|
||||||
|
title: '退出确认',
|
||||||
|
message: '确定要退出应用吗?',
|
||||||
|
noLink: true
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response === 1) {
|
||||||
|
logger.info('[lifecycle] User confirmed exit');
|
||||||
|
global.isConfirmedExit = true;
|
||||||
|
await this.cleanup();
|
||||||
|
if (win && !win.isDestroyed()) {
|
||||||
|
win.destroy();
|
||||||
|
}
|
||||||
|
app.quit();
|
||||||
|
} else {
|
||||||
|
logger.info('[lifecycle] User cancelled exit');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 立即刷新一次,确保显示最新内容
|
// 立即刷新一次,确保显示最新内容
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (win && !win.isDestroyed()) {
|
if (win && !win.isDestroyed()) {
|
||||||
@@ -323,10 +363,8 @@ class Lifecycle {
|
|||||||
this.logWindowManager.addLog('system', '正在停止 Spring Boot...');
|
this.logWindowManager.addLog('system', '正在停止 Spring Boot...');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置超时,3秒后强制继续
|
// 停止 Java 进程(内部已有完整的等待和清理逻辑)
|
||||||
const stopPromise = this.javaRunner.stopSpringBoot();
|
await this.javaRunner.stopSpringBoot();
|
||||||
const timeoutPromise = new Promise(resolve => setTimeout(resolve, 3000));
|
|
||||||
await Promise.race([stopPromise, timeoutPromise]);
|
|
||||||
|
|
||||||
logger.info('[lifecycle] Spring Boot stopped');
|
logger.info('[lifecycle] Spring Boot stopped');
|
||||||
if (this.logWindowManager && this.logWindowManager.logWindow && !this.logWindowManager.logWindow.isDestroyed()) {
|
if (this.logWindowManager && this.logWindowManager.logWindow && !this.logWindowManager.logWindow.isDestroyed()) {
|
||||||
@@ -337,37 +375,30 @@ class Lifecycle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 停止 MySQL
|
// 停止 MySQL 进程(进程模式)
|
||||||
const config = getConfig();
|
if (this.mysqlServiceManager) {
|
||||||
if (config.mysql && config.mysql.enable && config.mysql.autoStart) {
|
|
||||||
try {
|
try {
|
||||||
logger.info('[lifecycle] Stopping MySQL...');
|
logger.info('[lifecycle] Stopping MySQL process...');
|
||||||
if (this.logWindowManager && this.logWindowManager.logWindow && !this.logWindowManager.logWindow.isDestroyed()) {
|
if (this.logWindowManager && this.logWindowManager.logWindow && !this.logWindowManager.logWindow.isDestroyed()) {
|
||||||
this.logWindowManager.addLog('system', '正在停止 MySQL(最多等待10秒)...');
|
this.logWindowManager.addLog('system', '正在停止 MySQL...');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.mysqlManager) {
|
await this.mysqlServiceManager.stopMySQLProcess();
|
||||||
// MySQL 的 stop() 方法内部使用 mysqladmin shutdown(最多10秒)
|
|
||||||
// 设置12秒超时作为保险
|
logger.info('[lifecycle] MySQL process stopped');
|
||||||
const stopPromise = this.mysqlManager.stop();
|
|
||||||
const timeoutPromise = new Promise(resolve => setTimeout(resolve, 12000));
|
|
||||||
await Promise.race([stopPromise, timeoutPromise]);
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info('[lifecycle] MySQL stopped');
|
|
||||||
if (this.logWindowManager && this.logWindowManager.logWindow && !this.logWindowManager.logWindow.isDestroyed()) {
|
if (this.logWindowManager && this.logWindowManager.logWindow && !this.logWindowManager.logWindow.isDestroyed()) {
|
||||||
this.logWindowManager.addLog('success', 'MySQL 已停止');
|
this.logWindowManager.addLog('success', 'MySQL 已停止');
|
||||||
this.logWindowManager.addLog('system', '清理完成,应用即将退出');
|
|
||||||
this.logWindowManager.addLog('system', '='.repeat(60));
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('[lifecycle] Failed to stop MySQL:', error);
|
logger.error('[lifecycle] Failed to stop MySQL:', error);
|
||||||
if (this.logWindowManager && this.logWindowManager.logWindow && !this.logWindowManager.logWindow.isDestroyed()) {
|
|
||||||
this.logWindowManager.addLog('error', 'MySQL 停止失败: ' + error.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.logWindowManager && this.logWindowManager.logWindow && !this.logWindowManager.logWindow.isDestroyed()) {
|
||||||
|
this.logWindowManager.addLog('system', '清理完成,应用即将退出');
|
||||||
|
this.logWindowManager.addLog('system', '='.repeat(60));
|
||||||
|
}
|
||||||
|
|
||||||
// 等待500ms让用户看到清理日志
|
// 等待500ms让用户看到清理日志
|
||||||
await this.sleep(500);
|
await this.sleep(500);
|
||||||
|
|
||||||
@@ -384,35 +415,6 @@ class Lifecycle {
|
|||||||
logger.info('[lifecycle] Cleanup completed');
|
logger.info('[lifecycle] Cleanup completed');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置 MySQL 日志监听
|
|
||||||
*/
|
|
||||||
setupMySQLLogging(mysqlProcess) {
|
|
||||||
if (!mysqlProcess) return;
|
|
||||||
|
|
||||||
mysqlProcess.stdout.on('data', (data) => {
|
|
||||||
const output = data.toString().trim();
|
|
||||||
if (output) {
|
|
||||||
// 根据内容判断日志类型
|
|
||||||
if (output.includes('[ERROR]') || output.includes('ERROR')) {
|
|
||||||
this.logWindowManager.addLog('error', `[MySQL] ${output}`);
|
|
||||||
} else if (output.includes('[Warning]') || output.includes('WARNING')) {
|
|
||||||
this.logWindowManager.addLog('warn', `[MySQL] ${output}`);
|
|
||||||
} else if (output.includes('ready for connections')) {
|
|
||||||
this.logWindowManager.addLog('success', `[MySQL] ${output}`);
|
|
||||||
} else {
|
|
||||||
this.logWindowManager.addLog('mysql', `[MySQL] ${output}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
mysqlProcess.stderr.on('data', (data) => {
|
|
||||||
const output = data.toString().trim();
|
|
||||||
if (output) {
|
|
||||||
this.logWindowManager.addLog('warn', `[MySQL Error] ${output}`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动 Spring Boot 应用
|
* 启动 Spring Boot 应用
|
||||||
@@ -432,8 +434,17 @@ class Lifecycle {
|
|||||||
? path.join(__dirname, '..', 'build', 'extraResources', 'java', 'entrance.jar')
|
? path.join(__dirname, '..', 'build', 'extraResources', 'java', 'entrance.jar')
|
||||||
: path.join(process.resourcesPath, 'extraResources', 'java', 'entrance.jar');
|
: path.join(process.resourcesPath, 'extraResources', 'java', 'entrance.jar');
|
||||||
|
|
||||||
|
// 获取日志路径(与 config-generator.js 中的 dataPath 保持一致)
|
||||||
|
const isDev2 = !process.resourcesPath;
|
||||||
|
const baseDir = isDev2
|
||||||
|
? path.join(__dirname, '..', '..')
|
||||||
|
: path.dirname(process.resourcesPath);
|
||||||
|
const dataPath = path.join(baseDir, 'NPQS9100_Data');
|
||||||
|
const logPath = path.join(dataPath, 'logs');
|
||||||
|
|
||||||
const javaProcess = this.javaRunner.runSpringBoot(jarPath, configPath, {
|
const javaProcess = this.javaRunner.runSpringBoot(jarPath, configPath, {
|
||||||
javaPort: this.javaPort
|
javaPort: this.javaPort,
|
||||||
|
logPath: logPath // 传递日志路径
|
||||||
});
|
});
|
||||||
|
|
||||||
// 监听Java进程输出
|
// 监听Java进程输出
|
||||||
@@ -495,56 +506,56 @@ class Lifecycle {
|
|||||||
* main window have been loaded
|
* main window have been loaded
|
||||||
*/
|
*/
|
||||||
async windowReady() {
|
async windowReady() {
|
||||||
logger.info('[lifecycle] window-ready');
|
logger.info('[lifecycle] window-ready hook triggered');
|
||||||
if (ps.isProd()) {
|
|
||||||
// 创建日志窗口
|
|
||||||
this.logWindowManager = new LogWindowManager();
|
|
||||||
this.logWindowManager.createLogWindow();
|
|
||||||
this.logWindowManager.addLog('system', '='.repeat(60));
|
|
||||||
this.logWindowManager.addLog('system', 'NPQS9100 启动中...');
|
|
||||||
this.logWindowManager.addLog('system', '='.repeat(60));
|
|
||||||
|
|
||||||
// 创建 Loading 窗口
|
// 进程模式不需要管理员权限检查
|
||||||
this.startupManager = new StartupManager();
|
|
||||||
this.startupManager.createLoadingWindow();
|
|
||||||
|
|
||||||
// 开始启动流程
|
// 创建日志管理器(但不显示窗口,仅用于写日志文件)
|
||||||
try {
|
logger.info('[lifecycle] Creating log window manager...');
|
||||||
await this.startApplication();
|
this.logWindowManager = new LogWindowManager();
|
||||||
} catch (error) {
|
// this.logWindowManager.createLogWindow(); // ← 注释掉,不创建窗口
|
||||||
logger.error('[lifecycle] Failed to start application:', error);
|
this.logWindowManager.addLog('system', '='.repeat(80));
|
||||||
this.logWindowManager.addLog('error', `启动失败: ${error.message}`);
|
this.logWindowManager.addLog('system', 'NPQS9100 应用启动');
|
||||||
this.logWindowManager.addLog('system', '请检查日志窗口了解详细错误信息');
|
this.logWindowManager.addLog('system', '='.repeat(80));
|
||||||
this.startupManager.showError(error.message || '启动失败,请查看日志');
|
|
||||||
|
|
||||||
// 显示错误5秒后关闭Loading窗口,但不关闭日志窗口
|
// 创建 Loading 窗口
|
||||||
setTimeout(() => {
|
logger.info('[lifecycle] Creating startup manager and loading window...');
|
||||||
this.startupManager.closeLoadingWindow();
|
this.startupManager = new StartupManager();
|
||||||
|
this.startupManager.createLoadingWindow();
|
||||||
// 即使启动失败,也显示主窗口(但用户可能需要手动修复问题)
|
this.logWindowManager.addLog('system', '='.repeat(60));
|
||||||
const win = getMainWindow();
|
this.logWindowManager.addLog('system', 'NPQS9100 启动中...');
|
||||||
win.show();
|
this.logWindowManager.addLog('system', '='.repeat(60));
|
||||||
win.focus();
|
|
||||||
|
|
||||||
// 添加主窗口关闭事件监听
|
|
||||||
win.on('close', async () => {
|
|
||||||
logger.info('[lifecycle] Main window closing (after error), cleaning up...');
|
|
||||||
await this.cleanup();
|
|
||||||
});
|
|
||||||
|
|
||||||
this.logWindowManager.addLog('warn', '应用已启动,但部分服务可能未正常运行');
|
|
||||||
}, 5000);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const win = getMainWindow();
|
|
||||||
const {windowsOption} = getConfig();
|
|
||||||
if (windowsOption.show == false) {
|
|
||||||
win.once('ready-to-show', () => {
|
|
||||||
win.show();
|
|
||||||
win.focus();
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// 开始启动流程
|
||||||
|
logger.info('[lifecycle] Starting application flow...');
|
||||||
|
try {
|
||||||
|
await this.startApplication();
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('[lifecycle] Failed to start application:', error);
|
||||||
|
this.logWindowManager.addLog('error', `启动失败: ${error.message}`);
|
||||||
|
this.logWindowManager.addLog('system', '请检查日志窗口了解详细错误信息');
|
||||||
|
this.startupManager.showError(error.message || '启动失败,请查看日志');
|
||||||
|
|
||||||
|
// 显示错误5秒后关闭Loading窗口,但不关闭日志窗口
|
||||||
|
setTimeout(() => {
|
||||||
|
this.startupManager.closeLoadingWindow();
|
||||||
|
|
||||||
|
// 即使启动失败,也显示主窗口(但用户可能需要手动修复问题)
|
||||||
|
const win = getMainWindow();
|
||||||
|
win.show();
|
||||||
|
win.focus();
|
||||||
|
|
||||||
|
// 启动失败时,允许用户正常关闭窗口(不强制托盘)
|
||||||
|
// 因为可能托盘未创建,或用户想直接退出
|
||||||
|
win.on('close', async (event) => {
|
||||||
|
logger.info('[lifecycle] Window closing (after error), cleaning up...');
|
||||||
|
// 不阻止关闭,执行清理
|
||||||
|
await this.cleanup();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.logWindowManager.addLog('warn', '应用已启动,但部分服务可能未正常运行');
|
||||||
|
this.logWindowManager.addLog('system', '您可以点击 X 关闭应用');
|
||||||
|
}, 5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 主窗口初始化但不显示,等待启动流程完成后再显示
|
// 主窗口初始化但不显示,等待启动流程完成后再显示
|
||||||
@@ -556,10 +567,7 @@ class Lifecycle {
|
|||||||
*/
|
*/
|
||||||
async beforeClose() {
|
async beforeClose() {
|
||||||
logger.info('[lifecycle] before-close hook triggered');
|
logger.info('[lifecycle] before-close hook triggered');
|
||||||
if (ps.isProd()) {
|
await this.cleanup();
|
||||||
await this.cleanup();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Lifecycle.toString = () => '[class Lifecycle]';
|
Lifecycle.toString = () => '[class Lifecycle]';
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ VITE_API_URL=/api
|
|||||||
# 开发环境跨域代理,支持配置多个
|
# 开发环境跨域代理,支持配置多个
|
||||||
|
|
||||||
#VITE_PROXY=[["/api","http://127.0.0.1:18092/"]]
|
#VITE_PROXY=[["/api","http://127.0.0.1:18092/"]]
|
||||||
VITE_PROXY=[["/api","http://192.168.1.124:18092/"]]
|
#VITE_PROXY=[["/api","http://192.168.1.124:18092/"]]
|
||||||
#VITE_PROXY=[["/api","http://192.168.1.125:18092/"]]
|
VITE_PROXY=[["/api","http://192.168.2.124:18092/"]]
|
||||||
# VITE_PROXY=[["/api","http://192.168.1.138:8080/"]]张文
|
# VITE_PROXY=[["/api","http://192.168.1.138:8080/"]]张文
|
||||||
# 开启激活验证
|
# 开启激活验证
|
||||||
VITE_ACTIVATE_OPEN=false
|
VITE_ACTIVATE_OPEN=false
|
||||||
@@ -23,6 +23,6 @@ VITE_PWA=true
|
|||||||
|
|
||||||
# 线上环境接口地址
|
# 线上环境接口地址
|
||||||
#VITE_API_URL="/api" # 打包时用
|
#VITE_API_URL="/api" # 打包时用
|
||||||
VITE_API_URL="http://127.0.0.1:18092/"
|
VITE_API_URL="http://127.0.0.1:18093/"
|
||||||
# 开启激活验证
|
# 开启激活验证
|
||||||
VITE_ACTIVATE_OPEN=false
|
VITE_ACTIVATE_OPEN=true
|
||||||
@@ -23,6 +23,7 @@
|
|||||||
"dayjs": "^1.11.9",
|
"dayjs": "^1.11.9",
|
||||||
"driver.js": "^1.3.0",
|
"driver.js": "^1.3.0",
|
||||||
"echarts": "^5.4.3",
|
"echarts": "^5.4.3",
|
||||||
|
"echarts-gl": "^2.0.9",
|
||||||
"echarts-liquidfill": "^3.1.0",
|
"echarts-liquidfill": "^3.1.0",
|
||||||
"element-plus": "^2.7.8",
|
"element-plus": "^2.7.8",
|
||||||
"event-source-polyfill": "^1.0.31",
|
"event-source-polyfill": "^1.0.31",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<!--element-plus语言国际化,全局修改为中文-->
|
<!--element-plus语言国际化,全局修改为中文-->
|
||||||
|
<!-- 测试升级功能 - 2025-10-24 -->
|
||||||
<el-config-provider :locale="locale" :size="assemblySize" :button="buttonConfig">
|
<el-config-provider :locale="locale" :size="assemblySize" :button="buttonConfig">
|
||||||
<router-view />
|
<router-view />
|
||||||
</el-config-provider>
|
</el-config-provider>
|
||||||
@@ -31,14 +32,6 @@ onMounted(() => {
|
|||||||
const language = globalStore.language ?? getBrowserLang()
|
const language = globalStore.language ?? getBrowserLang()
|
||||||
i18n.locale.value = language
|
i18n.locale.value = language
|
||||||
globalStore.setGlobalState('language', language as LanguageType)
|
globalStore.setGlobalState('language', language as LanguageType)
|
||||||
// 移除 autofit,使用 CSS 自适应
|
|
||||||
// autofit.init({
|
|
||||||
// el: '#app',
|
|
||||||
// dw: 1440,
|
|
||||||
// dh: 900,
|
|
||||||
// resize: true,
|
|
||||||
// limit: 0.1
|
|
||||||
// })
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// element language
|
// element language
|
||||||
|
|||||||
@@ -82,8 +82,9 @@ export const reCalculate = (params: {
|
|||||||
errorSysId: string
|
errorSysId: string
|
||||||
deviceId: string
|
deviceId: string
|
||||||
code: string
|
code: string
|
||||||
patternId: string
|
patternId: string,
|
||||||
|
chnNum?: string,
|
||||||
|
dataRuleId: string
|
||||||
}) => {
|
}) => {
|
||||||
return http.post('/result/reCalculate', params, {loading: true})
|
return http.post('/result/reCalculate', params, {loading: true})
|
||||||
}
|
}
|
||||||
@@ -115,6 +116,7 @@ export const getContrastResult = (params: {
|
|||||||
waveNum: number | null
|
waveNum: number | null
|
||||||
isWave: boolean
|
isWave: boolean
|
||||||
patternId: string
|
patternId: string
|
||||||
|
code: string
|
||||||
}) => {
|
}) => {
|
||||||
return http.post('/result/getContrastResult', params, {loading: true})
|
return http.post('/result/getContrastResult', params, {loading: true})
|
||||||
}
|
}
|
||||||
@@ -129,7 +131,9 @@ export const changeErrorSystem = (params: {
|
|||||||
errorSysId: string
|
errorSysId: string
|
||||||
deviceId: string
|
deviceId: string
|
||||||
code: string
|
code: string
|
||||||
patternId: string
|
patternId: string,
|
||||||
|
chnNum?: string,
|
||||||
|
dataRuleId: string
|
||||||
}) => {
|
}) => {
|
||||||
return http.post('/result/changeErrorSystem', params, {loading: true})
|
return http.post('/result/changeErrorSystem', params, {loading: true})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ export const getICDAllList = (params: ICD.ResICD) => {
|
|||||||
|
|
||||||
//添加ICD
|
//添加ICD
|
||||||
export const addICD = (params: ICD.ResICD) => {
|
export const addICD = (params: ICD.ResICD) => {
|
||||||
return http.post(`/icd/add`, params)
|
return http.upload(`/icd/add`, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
//编辑ICD
|
//编辑ICD
|
||||||
export const updateICD = (params: ICD.ResICD) => {
|
export const updateICD = (params: ICD.ResICD) => {
|
||||||
return http.post(`/icd/update`, params)
|
return http.upload(`/icd/update`, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
//删除ICD
|
//删除ICD
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export namespace ICD {
|
|||||||
updateTime?: string| null; //更新时间
|
updateTime?: string| null; //更新时间
|
||||||
angle: number; // 是否支持电压相角、电流相角指标
|
angle: number; // 是否支持电压相角、电流相角指标
|
||||||
usePhaseIndex: number; // 角型接线时是否使用相别的指标来进行检测
|
usePhaseIndex: number; // 角型接线时是否使用相别的指标来进行检测
|
||||||
|
mappingFile: string | null;//映射文件
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export namespace Monitor {
|
|||||||
export interface ResPqMon {
|
export interface ResPqMon {
|
||||||
id: string; //监测点ID
|
id: string; //监测点ID
|
||||||
devId: string; //所属设备ID
|
devId: string; //所属设备ID
|
||||||
busbar: string;//所属母线
|
busbar: string;//母线名称
|
||||||
name: string; //监测点名称
|
name: string; //监测点名称
|
||||||
num: number; //线路号,监测点序号
|
num: number; //线路号,监测点序号
|
||||||
pt: string; //PT变比
|
pt: string; //PT变比
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export namespace TestScript {
|
|||||||
selectedValue?: string
|
selectedValue?: string
|
||||||
ratedCurr?: number
|
ratedCurr?: number
|
||||||
ratedVolt?: number
|
ratedVolt?: number
|
||||||
|
fluke?:number|boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ export interface CustomAxiosRequestConfig extends InternalAxiosRequestConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
// 默认地址请求地址,可在 .env.** 文件中修改
|
// 默认地址请求地址,可在 .env 开头文件中修改
|
||||||
baseURL: import.meta.env.VITE_API_URL as string,
|
baseURL: import.meta.env.VITE_API_URL as string,
|
||||||
// 设置超时时间
|
// 设置超时时间(60s)
|
||||||
timeout: ResultEnum.TIMEOUT as number,
|
timeout: 60000,
|
||||||
// 跨域时候允许携带凭证
|
// 跨域时候允许携带凭证
|
||||||
withCredentials: true,
|
withCredentials: true,
|
||||||
// post请求指定数据类型以及编码
|
// post请求指定数据类型以及编码
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ export interface ResultData<T = any> extends Result {
|
|||||||
* 分页请求参数
|
* 分页请求参数
|
||||||
*/
|
*/
|
||||||
export interface ReqPage {
|
export interface ReqPage {
|
||||||
pageNum: number;
|
pageNum?: number;
|
||||||
pageSize: number;
|
pageSize?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { type VersionRegister } from '@/api/system/versionRegister/interface'
|
|||||||
|
|
||||||
//获取有效数据配置
|
//获取有效数据配置
|
||||||
export const getRegRes = (params: { type: string }) => {
|
export const getRegRes = (params: { type: string }) => {
|
||||||
return http.get(`/sysRegRes/getRegResByType?id=${params.type}`)
|
return http.get(`/sysRegRes/getRegResByType?typeId=${params.type}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
//编辑有效数据配置
|
//编辑有效数据配置
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||||
// import echarts from './echarts'
|
// import echarts from './echarts'
|
||||||
import * as echarts from 'echarts' // 全引入
|
import * as echarts from 'echarts' // 全引入
|
||||||
|
// import 'echarts-gl'
|
||||||
|
// import 'echarts-liquidfill'
|
||||||
// import 'echarts/lib/component/dataZoom'
|
// import 'echarts/lib/component/dataZoom'
|
||||||
|
|
||||||
const color = [
|
const color = [
|
||||||
@@ -39,11 +41,13 @@ const resizeHandler = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
const initChart = () => {
|
const initChart = () => {
|
||||||
|
|
||||||
if (!props.isInterVal && !props.pieInterVal) {
|
if (!props.isInterVal && !props.pieInterVal) {
|
||||||
chart?.dispose()
|
chart?.dispose()
|
||||||
}
|
}
|
||||||
// chart?.dispose()
|
// chart?.dispose()
|
||||||
chart = echarts.init(chartRef.value as HTMLDivElement)
|
chart = echarts.init(chartRef.value as HTMLDivElement)
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
title: {
|
title: {
|
||||||
left: 'center',
|
left: 'center',
|
||||||
|
|||||||
@@ -72,7 +72,15 @@ const handelOpen = async (item: string, key: string) => {
|
|||||||
// 强制刷新页面
|
// 强制刷新页面
|
||||||
await tabsStore.closeMultipleTab()
|
await tabsStore.closeMultipleTab()
|
||||||
await initDynamicRouter()
|
await initDynamicRouter()
|
||||||
await router.push({ path: '/home/index' })
|
|
||||||
|
// 只有当目标路径与当前路径不同时才跳转
|
||||||
|
if (router.currentRoute.value.path !== '/home/index') {
|
||||||
|
await router.push({ path: '/home/index' })
|
||||||
|
} else {
|
||||||
|
// 如果已在目标页面,手动触发组件更新
|
||||||
|
window.location.reload() // 或者采用其他方式刷新数据
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
72
frontend/src/utils/echartMethod.ts
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
const dataProcessing = (arr: any[]) => {
|
||||||
|
return arr
|
||||||
|
.filter(item => typeof item === 'number' || (typeof item === 'string' && !isNaN(parseFloat(item))))
|
||||||
|
.map(item => (typeof item === 'number' ? item : parseFloat(item)))
|
||||||
|
}
|
||||||
|
|
||||||
|
const calculateValue = (o: number, value: number, num: number, isMin: boolean) => {
|
||||||
|
if (value === 0) {
|
||||||
|
return 0
|
||||||
|
} else if (value > 0 && Math.abs(value) < 1 && isMin == true) {
|
||||||
|
return 0
|
||||||
|
} else if (value > -1 && value < 0 && isMin == false) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
let base
|
||||||
|
if (Math.abs(o) >= 100) {
|
||||||
|
base = 100
|
||||||
|
} else if (Math.abs(o) >= 10) {
|
||||||
|
base = 10
|
||||||
|
} else if (Math.abs(o) >= 1) {
|
||||||
|
base = 1
|
||||||
|
} else {
|
||||||
|
const multiple = 1 / 0.1
|
||||||
|
|
||||||
|
base = Math.ceil(Math.abs(o) * multiple) / multiple
|
||||||
|
}
|
||||||
|
|
||||||
|
let calculatedValue
|
||||||
|
if (isMin) {
|
||||||
|
if (value < 0) {
|
||||||
|
calculatedValue = value + num * value
|
||||||
|
} else {
|
||||||
|
calculatedValue = value - num * value
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (value < 0) {
|
||||||
|
calculatedValue = value - num * value
|
||||||
|
} else {
|
||||||
|
calculatedValue = value + num * value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (base === 0.1) {
|
||||||
|
return parseFloat(calculatedValue.toFixed(1))
|
||||||
|
} else if (isMin) {
|
||||||
|
return Math.floor(calculatedValue / base) * base
|
||||||
|
} else {
|
||||||
|
return Math.ceil(calculatedValue / base) * base
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理y轴最大最小值
|
||||||
|
export const yMethod = (arr: any) => {
|
||||||
|
const num = 0.2
|
||||||
|
const numList = dataProcessing(arr)
|
||||||
|
let maxValue = 0
|
||||||
|
let minValue = 0
|
||||||
|
let max = 0
|
||||||
|
let min = 0
|
||||||
|
maxValue = Math.max(...numList)
|
||||||
|
minValue = Math.min(...numList)
|
||||||
|
const o = maxValue - minValue == 0 ? maxValue : maxValue - minValue
|
||||||
|
min = calculateValue(o, minValue, num, true)
|
||||||
|
|
||||||
|
max = calculateValue(o, maxValue, num, false)
|
||||||
|
|
||||||
|
return [min, max]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
* WebSocket客户端服务
|
* WebSocket客户端服务
|
||||||
* 提供WebSocket连接管理、心跳机制、消息处理等功能
|
* 提供WebSocket连接管理、心跳机制、消息处理等功能
|
||||||
* 集成JWT token解析,支持自动获取用户登录名
|
* 集成JWT token解析,支持自动获取用户登录名
|
||||||
*
|
*
|
||||||
* @author hongawen
|
* @author hongawen
|
||||||
* @version 2.0
|
* @version 2.0
|
||||||
*/
|
*/
|
||||||
@@ -66,7 +66,7 @@ namespace WebSocketMessageTypes {
|
|||||||
progress?: number;
|
progress?: number;
|
||||||
errorInfo?: string;
|
errorInfo?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系数校准相关消息
|
* 系数校准相关消息
|
||||||
*/
|
*/
|
||||||
@@ -77,7 +77,7 @@ namespace WebSocketMessageTypes {
|
|||||||
current?: string;
|
current?: string;
|
||||||
calibrationResult?: boolean;
|
calibrationResult?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 正式检测相关消息
|
* 正式检测相关消息
|
||||||
*/
|
*/
|
||||||
@@ -87,7 +87,7 @@ namespace WebSocketMessageTypes {
|
|||||||
testResult?: 'success' | 'failed' | 'processing';
|
testResult?: 'success' | 'failed' | 'processing';
|
||||||
testData?: any;
|
testData?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用响应消息
|
* 通用响应消息
|
||||||
*/
|
*/
|
||||||
@@ -102,14 +102,14 @@ namespace WebSocketMessageTypes {
|
|||||||
// 导出类型
|
// 导出类型
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
export type {
|
export type {
|
||||||
WebSocketMessage,
|
WebSocketMessage,
|
||||||
CallbackFunction,
|
CallbackFunction,
|
||||||
SocketConfig,
|
SocketConfig,
|
||||||
WebSocketMessageTypes
|
WebSocketMessageTypes
|
||||||
};
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
ConnectionStatus
|
ConnectionStatus
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ export default class SocketService {
|
|||||||
* 单例实例
|
* 单例实例
|
||||||
*/
|
*/
|
||||||
private static instance: SocketService | null = null;
|
private static instance: SocketService | null = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取单例实例
|
* 获取单例实例
|
||||||
* @returns SocketService实例
|
* @returns SocketService实例
|
||||||
@@ -150,48 +150,48 @@ export default class SocketService {
|
|||||||
* WebSocket连接实例
|
* WebSocket连接实例
|
||||||
*/
|
*/
|
||||||
private ws: WebSocket | null = null;
|
private ws: WebSocket | null = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息回调函数映射表
|
* 消息回调函数映射表
|
||||||
*/
|
*/
|
||||||
private callBackMapping: Record<string, CallbackFunction<any>> = {};
|
private callBackMapping: Record<string, CallbackFunction<any>> = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前连接状态
|
* 当前连接状态
|
||||||
*/
|
*/
|
||||||
private connectionStatus: ConnectionStatus = ConnectionStatus.DISCONNECTED;
|
private connectionStatus: ConnectionStatus = ConnectionStatus.DISCONNECTED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送消息重试计数器
|
* 发送消息重试计数器
|
||||||
*/
|
*/
|
||||||
private sendRetryCount: number = 0;
|
private sendRetryCount: number = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 连接重试计数器
|
* 连接重试计数器
|
||||||
*/
|
*/
|
||||||
private connectRetryCount: number = 0;
|
private connectRetryCount: number = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 心跳Worker实例
|
* 心跳Worker实例
|
||||||
*/
|
*/
|
||||||
private heartbeatWorker: Worker | null = null;
|
private heartbeatWorker: Worker | null = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Worker脚本的Blob URL
|
* Worker脚本的Blob URL
|
||||||
*/
|
*/
|
||||||
private workerBlobUrl: string | null = null;
|
private workerBlobUrl: string | null = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最后一次收到心跳响应的时间戳
|
* 最后一次收到心跳响应的时间戳
|
||||||
*/
|
*/
|
||||||
private lastResponseHeartTime: number = Date.now();
|
private lastResponseHeartTime: number = Date.now();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WebSocket连接配置
|
* WebSocket连接配置
|
||||||
*/
|
*/
|
||||||
private config: SocketConfig = {
|
private config: SocketConfig = {
|
||||||
//url: 'ws://127.0.0.1:7777/hello',
|
url: 'ws://127.0.0.1:7778/hello',
|
||||||
url: 'ws://192.168.1.124:7777/hello',
|
//url: 'ws://192.168.1.124:7777/hello',
|
||||||
heartbeatInterval: 9000, // 9秒心跳间隔
|
heartbeatInterval: 9000, // 9秒心跳间隔
|
||||||
reconnectDelay: 5000, // 5秒重连延迟
|
reconnectDelay: 5000, // 5秒重连延迟
|
||||||
maxReconnectAttempts: 5, // 最多重连5次
|
maxReconnectAttempts: 5, // 最多重连5次
|
||||||
@@ -246,18 +246,18 @@ export default class SocketService {
|
|||||||
public connect(): Promise<void> | void {
|
public connect(): Promise<void> | void {
|
||||||
// 检查浏览器支持
|
// 检查浏览器支持
|
||||||
if (!window.WebSocket) {
|
if (!window.WebSocket) {
|
||||||
// console.log('您的浏览器不支持WebSocket');
|
// console.log('您的浏览器不支持WebSocket');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 防止重复连接
|
// 防止重复连接
|
||||||
if (this.connectionStatus === ConnectionStatus.CONNECTING || this.connected) {
|
if (this.connectionStatus === ConnectionStatus.CONNECTING || this.connected) {
|
||||||
// console.warn('WebSocket已连接或正在连接中');
|
// console.warn('WebSocket已连接或正在连接中');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.connectionStatus = ConnectionStatus.CONNECTING;
|
this.connectionStatus = ConnectionStatus.CONNECTING;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.ws = new WebSocket(this.buildWebSocketUrl());
|
this.ws = new WebSocket(this.buildWebSocketUrl());
|
||||||
this.setupEventHandlersLegacy();
|
this.setupEventHandlersLegacy();
|
||||||
@@ -289,7 +289,7 @@ export default class SocketService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.connectionStatus = ConnectionStatus.CONNECTING;
|
this.connectionStatus = ConnectionStatus.CONNECTING;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.ws = new WebSocket(this.buildWebSocketUrl());
|
this.ws = new WebSocket(this.buildWebSocketUrl());
|
||||||
this.setupEventHandlers(resolve, reject);
|
this.setupEventHandlers(resolve, reject);
|
||||||
@@ -311,7 +311,7 @@ export default class SocketService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.callBackMapping[messageType] = callback;
|
this.callBackMapping[messageType] = callback;
|
||||||
// console.log(`注册消息处理器: ${messageType}`);
|
// console.log(`注册消息处理器: ${messageType}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -349,11 +349,11 @@ export default class SocketService {
|
|||||||
try {
|
try {
|
||||||
// 重置重试计数
|
// 重置重试计数
|
||||||
this.sendRetryCount = 0;
|
this.sendRetryCount = 0;
|
||||||
|
|
||||||
// 尝试发送JSON数据,失败则发送原始数据
|
// 尝试发送JSON数据,失败则发送原始数据
|
||||||
const message = typeof data === 'string' ? data : JSON.stringify(data);
|
const message = typeof data === 'string' ? data : JSON.stringify(data);
|
||||||
this.ws.send(message);
|
this.ws.send(message);
|
||||||
|
|
||||||
//console.log('发送消息:', message);
|
//console.log('发送消息:', message);
|
||||||
resolve();
|
resolve();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -368,21 +368,21 @@ export default class SocketService {
|
|||||||
*/
|
*/
|
||||||
public closeWs(): void {
|
public closeWs(): void {
|
||||||
//console.log('正在关闭WebSocket连接...');
|
//console.log('正在关闭WebSocket连接...');
|
||||||
|
|
||||||
// 清理心跳
|
// 清理心跳
|
||||||
this.clearHeartbeat();
|
this.clearHeartbeat();
|
||||||
|
|
||||||
// 关闭连接
|
// 关闭连接
|
||||||
if (this.ws) {
|
if (this.ws) {
|
||||||
this.ws.close(1000, '主动关闭连接');
|
this.ws.close(1000, '主动关闭连接');
|
||||||
this.ws = null;
|
this.ws = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新状态
|
// 更新状态
|
||||||
this.connectionStatus = ConnectionStatus.DISCONNECTED;
|
this.connectionStatus = ConnectionStatus.DISCONNECTED;
|
||||||
this.connectRetryCount = 0;
|
this.connectRetryCount = 0;
|
||||||
this.sendRetryCount = 0;
|
this.sendRetryCount = 0;
|
||||||
|
|
||||||
//console.log('WebSocket连接已关闭');
|
//console.log('WebSocket连接已关闭');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -422,15 +422,15 @@ export default class SocketService {
|
|||||||
*/
|
*/
|
||||||
private buildWebSocketUrl(): string {
|
private buildWebSocketUrl(): string {
|
||||||
const { url } = this.config;
|
const { url } = this.config;
|
||||||
|
|
||||||
// 直接从JWT token中获取loginName作为name参数
|
// 直接从JWT token中获取loginName作为name参数
|
||||||
const loginName = jwtUtil.getLoginName();
|
const loginName = jwtUtil.getLoginName();
|
||||||
|
|
||||||
if (loginName) {
|
if (loginName) {
|
||||||
const separator = url.includes('?') ? '&' : '?';
|
const separator = url.includes('?') ? '&' : '?';
|
||||||
return `${url}${separator}name=${encodeURIComponent(loginName)}`;
|
return `${url}${separator}name=${encodeURIComponent(loginName)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果无法获取loginName,返回原始URL并输出警告
|
// 如果无法获取loginName,返回原始URL并输出警告
|
||||||
console.warn('无法从JWT token中获取loginName,WebSocket连接可能会失败');
|
console.warn('无法从JWT token中获取loginName,WebSocket连接可能会失败');
|
||||||
return url;
|
return url;
|
||||||
@@ -443,11 +443,11 @@ export default class SocketService {
|
|||||||
*/
|
*/
|
||||||
private setupEventHandlers(resolve: () => void, reject: (error: Error) => void): void {
|
private setupEventHandlers(resolve: () => void, reject: (error: Error) => void): void {
|
||||||
if (!this.ws) return;
|
if (!this.ws) return;
|
||||||
|
|
||||||
// 连接成功事件
|
// 连接成功事件
|
||||||
this.ws.onopen = () => {
|
this.ws.onopen = () => {
|
||||||
ElMessage.success("WebSocket连接服务端成功");
|
ElMessage.success("WebSocket连接服务端成功");
|
||||||
// console.log('WebSocket连接成功');
|
// console.log('WebSocket连接成功');
|
||||||
this.connectionStatus = ConnectionStatus.CONNECTED;
|
this.connectionStatus = ConnectionStatus.CONNECTED;
|
||||||
this.connectRetryCount = 0;
|
this.connectRetryCount = 0;
|
||||||
this.startHeartbeat();
|
this.startHeartbeat();
|
||||||
@@ -459,7 +459,7 @@ export default class SocketService {
|
|||||||
//console.log('WebSocket连接关闭', event.code, event.reason);
|
//console.log('WebSocket连接关闭', event.code, event.reason);
|
||||||
this.connectionStatus = ConnectionStatus.DISCONNECTED;
|
this.connectionStatus = ConnectionStatus.DISCONNECTED;
|
||||||
this.clearHeartbeat();
|
this.clearHeartbeat();
|
||||||
|
|
||||||
// 非正常关闭且未超过最大重连次数,尝试重连
|
// 非正常关闭且未超过最大重连次数,尝试重连
|
||||||
if (event.code !== 1000 && this.connectRetryCount < this.config.maxReconnectAttempts!) {
|
if (event.code !== 1000 && this.connectRetryCount < this.config.maxReconnectAttempts!) {
|
||||||
this.attemptReconnect();
|
this.attemptReconnect();
|
||||||
@@ -485,11 +485,11 @@ export default class SocketService {
|
|||||||
*/
|
*/
|
||||||
private setupEventHandlersLegacy(): void {
|
private setupEventHandlersLegacy(): void {
|
||||||
if (!this.ws) return;
|
if (!this.ws) return;
|
||||||
|
|
||||||
// 连接成功事件
|
// 连接成功事件
|
||||||
this.ws.onopen = () => {
|
this.ws.onopen = () => {
|
||||||
ElMessage.success("webSocket连接服务端成功了");
|
ElMessage.success("webSocket连接服务端成功了");
|
||||||
// console.log('连接服务端成功了');
|
// console.log('连接服务端成功了');
|
||||||
this.connectionStatus = ConnectionStatus.CONNECTED;
|
this.connectionStatus = ConnectionStatus.CONNECTED;
|
||||||
this.connectRetryCount = 0;
|
this.connectRetryCount = 0;
|
||||||
this.startHeartbeat();
|
this.startHeartbeat();
|
||||||
@@ -497,10 +497,10 @@ export default class SocketService {
|
|||||||
|
|
||||||
// 连接关闭事件
|
// 连接关闭事件
|
||||||
this.ws.onclose = (event: CloseEvent) => {
|
this.ws.onclose = (event: CloseEvent) => {
|
||||||
// console.log('连接webSocket服务端关闭');
|
// console.log('连接webSocket服务端关闭');
|
||||||
this.connectionStatus = ConnectionStatus.DISCONNECTED;
|
this.connectionStatus = ConnectionStatus.DISCONNECTED;
|
||||||
this.clearHeartbeat();
|
this.clearHeartbeat();
|
||||||
|
|
||||||
// 保持原有的重连逻辑(被注释掉的)
|
// 保持原有的重连逻辑(被注释掉的)
|
||||||
// this.connectRetryCount++;
|
// this.connectRetryCount++;
|
||||||
/* setTimeout(() => {
|
/* setTimeout(() => {
|
||||||
@@ -527,10 +527,10 @@ export default class SocketService {
|
|||||||
*/
|
*/
|
||||||
private handleMessage(event: MessageEvent): void {
|
private handleMessage(event: MessageEvent): void {
|
||||||
// console.log('Received message:', event.data);
|
// console.log('Received message:', event.data);
|
||||||
|
|
||||||
// 心跳响应处理
|
// 心跳响应处理
|
||||||
if (event.data === 'over') {
|
if (event.data === 'over') {
|
||||||
// console.log(`${new Date().toLocaleTimeString()} - 收到心跳响应`);
|
// console.log(`${new Date().toLocaleTimeString()} - 收到心跳响应`);
|
||||||
this.lastResponseHeartTime = Date.now();
|
this.lastResponseHeartTime = Date.now();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -553,16 +553,16 @@ export default class SocketService {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 非JSON格式的消息,作为普通文本处理
|
// 非JSON格式的消息,作为普通文本处理
|
||||||
// console.log('收到非JSON格式消息:', event.data);
|
// console.log('收到非JSON格式消息:', event.data);
|
||||||
// 可以添加文本消息的处理逻辑
|
// 可以添加文本消息的处理逻辑
|
||||||
if (this.callBackMapping['text']) {
|
if (this.callBackMapping['text']) {
|
||||||
this.callBackMapping['text']({
|
this.callBackMapping['text']({
|
||||||
type: 'text',
|
type: 'text',
|
||||||
data: event.data
|
data: event.data
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('消息解析失败:', event.data, error);
|
console.error('消息解析失败:', event.data, error);
|
||||||
console.error('消息类型:', typeof event.data);
|
console.error('消息类型:', typeof event.data);
|
||||||
@@ -584,11 +584,11 @@ export default class SocketService {
|
|||||||
|
|
||||||
this.connectionStatus = ConnectionStatus.RECONNECTING;
|
this.connectionStatus = ConnectionStatus.RECONNECTING;
|
||||||
this.connectRetryCount++;
|
this.connectRetryCount++;
|
||||||
|
|
||||||
const delay = this.config.reconnectDelay! * this.connectRetryCount;
|
const delay = this.config.reconnectDelay! * this.connectRetryCount;
|
||||||
|
|
||||||
// console.log(`尝试第${this.connectRetryCount}次重连,${delay}ms后开始...`);
|
// console.log(`尝试第${this.connectRetryCount}次重连,${delay}ms后开始...`);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
try {
|
try {
|
||||||
const result = this.connect();
|
const result = this.connect();
|
||||||
@@ -627,24 +627,24 @@ export default class SocketService {
|
|||||||
postMessage('heartbeat');
|
postMessage('heartbeat');
|
||||||
}, ${this.config.heartbeatInterval});
|
}, ${this.config.heartbeatInterval});
|
||||||
`;
|
`;
|
||||||
|
|
||||||
this.workerBlobUrl = window.URL.createObjectURL(
|
this.workerBlobUrl = window.URL.createObjectURL(
|
||||||
new Blob([workerScript], { type: 'application/javascript' })
|
new Blob([workerScript], { type: 'application/javascript' })
|
||||||
);
|
);
|
||||||
|
|
||||||
this.heartbeatWorker = new Worker(this.workerBlobUrl);
|
this.heartbeatWorker = new Worker(this.workerBlobUrl);
|
||||||
|
|
||||||
// 心跳Worker消息处理
|
// 心跳Worker消息处理
|
||||||
this.heartbeatWorker.onmessage = (event: MessageEvent) => {
|
this.heartbeatWorker.onmessage = (event: MessageEvent) => {
|
||||||
this.handleHeartbeatTick();
|
this.handleHeartbeatTick();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Worker错误处理
|
// Worker错误处理
|
||||||
this.heartbeatWorker.onerror = (error: ErrorEvent) => {
|
this.heartbeatWorker.onerror = (error: ErrorEvent) => {
|
||||||
console.error('心跳Worker错误:', error);
|
console.error('心跳Worker错误:', error);
|
||||||
this.clearHeartbeat();
|
this.clearHeartbeat();
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('创建心跳Worker失败:', error);
|
console.error('创建心跳Worker失败:', error);
|
||||||
}
|
}
|
||||||
@@ -657,7 +657,7 @@ export default class SocketService {
|
|||||||
private handleHeartbeatTick(): void {
|
private handleHeartbeatTick(): void {
|
||||||
// 检查是否超时(距离上次收到心跳响应的时间)
|
// 检查是否超时(距离上次收到心跳响应的时间)
|
||||||
const timeSinceLastResponse = Date.now() - this.lastResponseHeartTime;
|
const timeSinceLastResponse = Date.now() - this.lastResponseHeartTime;
|
||||||
|
|
||||||
if (timeSinceLastResponse > this.config.timeout!) {
|
if (timeSinceLastResponse > this.config.timeout!) {
|
||||||
console.error(`WebSocket心跳超时: ${timeSinceLastResponse}ms > ${this.config.timeout}ms`);
|
console.error(`WebSocket心跳超时: ${timeSinceLastResponse}ms > ${this.config.timeout}ms`);
|
||||||
ElMessage.error("WebSocket连接超时,请检查网络连接!");
|
ElMessage.error("WebSocket连接超时,请检查网络连接!");
|
||||||
@@ -665,7 +665,7 @@ export default class SocketService {
|
|||||||
this.closeWs();
|
this.closeWs();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sendHeartbeat();
|
this.sendHeartbeat();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -674,7 +674,7 @@ export default class SocketService {
|
|||||||
*/
|
*/
|
||||||
private sendHeartbeat(): void {
|
private sendHeartbeat(): void {
|
||||||
if (this.connected && this.ws) {
|
if (this.connected && this.ws) {
|
||||||
// console.log(`${new Date().toLocaleTimeString()} - 发送心跳消息`);
|
// console.log(`${new Date().toLocaleTimeString()} - 发送心跳消息`);
|
||||||
this.ws.send('alive');
|
this.ws.send('alive');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -688,7 +688,7 @@ export default class SocketService {
|
|||||||
this.heartbeatWorker.terminate();
|
this.heartbeatWorker.terminate();
|
||||||
this.heartbeatWorker = null;
|
this.heartbeatWorker = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.workerBlobUrl) {
|
if (this.workerBlobUrl) {
|
||||||
window.URL.revokeObjectURL(this.workerBlobUrl);
|
window.URL.revokeObjectURL(this.workerBlobUrl);
|
||||||
this.workerBlobUrl = null;
|
this.workerBlobUrl = null;
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import { jwtUtil } from '@/utils/jwtUtil'
|
|||||||
import { useCheckStore } from '@/stores/modules/check'
|
import { useCheckStore } from '@/stores/modules/check'
|
||||||
import { ipc } from '@/utils/ipcRenderer'
|
import { ipc } from '@/utils/ipcRenderer'
|
||||||
import { fa, tr } from 'element-plus/es/locale'
|
import { fa, tr } from 'element-plus/es/locale'
|
||||||
|
import { CheckData } from '@/api/check/interface'
|
||||||
const vueFlowElement = ref(442)
|
const vueFlowElement = ref(442)
|
||||||
const checkStore = useCheckStore()
|
const checkStore = useCheckStore()
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
@@ -427,7 +428,7 @@ const standardDevIds = ref<string[]>()
|
|||||||
const open = async () => {
|
const open = async () => {
|
||||||
edges.value = []
|
edges.value = []
|
||||||
|
|
||||||
devIds.value = prop.devIdList.map(d => d.id)
|
//devIds.value = prop.devIdList.map(d => d.id)
|
||||||
standardDevIds.value = prop.pqStandardDevList.map(d => d.id)
|
standardDevIds.value = prop.pqStandardDevList.map(d => d.id)
|
||||||
planId.value = prop.planIdKey
|
planId.value = prop.planIdKey
|
||||||
nodes.value = createNodes(prop.devIdList, prop.pqStandardDevList, prop.deviceMonitor)
|
nodes.value = createNodes(prop.devIdList, prop.pqStandardDevList, prop.deviceMonitor)
|
||||||
@@ -447,11 +448,33 @@ const handleNext = async () => {
|
|||||||
let chnNumList: string[] = []
|
let chnNumList: string[] = []
|
||||||
await edges.value.forEach(edge => {
|
await edges.value.forEach(edge => {
|
||||||
const match = edge.source.split('-')
|
const match = edge.source.split('-')
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
chnNumList.push(match[2])
|
chnNumList.push(match[1] + '-'+ match[2])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const connectedDeviceIds = [...new Set(chnNumList.map(item => item.split('-')[0]))]
|
||||||
|
devIds.value = connectedDeviceIds
|
||||||
|
//可能存在勾选的被检设备未连线的情况,需要过滤掉
|
||||||
|
let devices: CheckData.Device[] = prop.devIdList
|
||||||
|
.filter((item: any) => connectedDeviceIds.includes(item.id))
|
||||||
|
.map((item: any) => {
|
||||||
|
return {
|
||||||
|
deviceId: item.id,
|
||||||
|
deviceName: item.name,
|
||||||
|
chnNum: item.devChns,
|
||||||
|
planId: item.planId,
|
||||||
|
deviceType: item.devType,
|
||||||
|
devVolt: item.devVolt,
|
||||||
|
devCurr: item.devCurr,
|
||||||
|
factorFlag: item.factorFlag,
|
||||||
|
checkResult: item.checkResult
|
||||||
|
}
|
||||||
|
})
|
||||||
|
checkStore.clearDevices()
|
||||||
|
checkStore.addDevices(devices)
|
||||||
|
|
||||||
|
|
||||||
const connections = edges.value.reduce(
|
const connections = edges.value.reduce(
|
||||||
(map, edge) => {
|
(map, edge) => {
|
||||||
// 从source中提取设备ID和通道号: 被检通道-{deviceId}-{channelNum} => {deviceId}-{channelNum}
|
// 从source中提取设备ID和通道号: 被检通道-{deviceId}-{channelNum} => {deviceId}-{channelNum}
|
||||||
|
|||||||
430
frontend/src/views/home/components/compareDataCheckChart.vue
Normal file
@@ -0,0 +1,430 @@
|
|||||||
|
<template>
|
||||||
|
<!-- 历史趋势数据 -->
|
||||||
|
<div class="history_chart">
|
||||||
|
<MyEchart ref="historyChart" :options="echartsData"/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
|
||||||
|
|
||||||
|
import { nextTick, ref, watch } from 'vue'
|
||||||
|
import { yMethod } from '@/utils/echartMethod'
|
||||||
|
import MyEchart from '@/components/echarts/line/index.vue'
|
||||||
|
import { CheckData } from '@/api/check/interface'
|
||||||
|
|
||||||
|
const prop = defineProps({
|
||||||
|
tableData: {
|
||||||
|
type: Array as () => CheckData.TableRow[],
|
||||||
|
default: []
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const color = [
|
||||||
|
'var(--el-color-primary)',
|
||||||
|
'#07CCCA',
|
||||||
|
'#00BFF5',
|
||||||
|
'#FFBF00',
|
||||||
|
'#77DA63',
|
||||||
|
'#D5FF6B',
|
||||||
|
'#Ff6600',
|
||||||
|
'#FF9100',
|
||||||
|
'#5B6E96',
|
||||||
|
'#66FFCC',
|
||||||
|
'#B3B3B3'
|
||||||
|
]
|
||||||
|
|
||||||
|
const chartsList = ref<any>([])
|
||||||
|
|
||||||
|
const echartsData = ref<any>(null)
|
||||||
|
//初始化趋势图
|
||||||
|
const lineStyle = [{ type: 'solid' }, { type: 'dashed' }, { type: 'dotted' }]
|
||||||
|
|
||||||
|
const setEchart = () => {
|
||||||
|
echartsData.value = {}
|
||||||
|
// y轴单位数组
|
||||||
|
let unitList: any = []
|
||||||
|
|
||||||
|
let groupedData = chartsList.value.reduce((acc: any, item: any) => {
|
||||||
|
let key = ''
|
||||||
|
if (item.phase == null) {
|
||||||
|
key = item.unit
|
||||||
|
} else {
|
||||||
|
key = item.anotherName
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!acc[key]) {
|
||||||
|
acc[key] = []
|
||||||
|
}
|
||||||
|
acc[key].push(item)
|
||||||
|
return acc
|
||||||
|
}, {})
|
||||||
|
let result = Object.values(groupedData)
|
||||||
|
if (chartsList.value.length > 0) {
|
||||||
|
unitList = result.map((item: any) => {
|
||||||
|
return item[0].unit
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
echartsData.value = {
|
||||||
|
legend: {
|
||||||
|
itemWidth: 20,
|
||||||
|
itemHeight: 20,
|
||||||
|
itemStyle: { opacity: 0 }, //去圆点
|
||||||
|
type: 'scroll', // 开启滚动分页
|
||||||
|
// orient: 'vertical', // 垂直排列
|
||||||
|
top: 5,
|
||||||
|
right: 70
|
||||||
|
// width: 550,
|
||||||
|
// height: 50
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
top: '30px',
|
||||||
|
},
|
||||||
|
tooltip: {
|
||||||
|
axisPointer: {
|
||||||
|
type: 'cross',
|
||||||
|
label: {
|
||||||
|
color: '#fff',
|
||||||
|
fontSize: 16
|
||||||
|
}
|
||||||
|
},
|
||||||
|
textStyle: {
|
||||||
|
color: '#fff',
|
||||||
|
fontStyle: 'normal',
|
||||||
|
opacity: 0.35,
|
||||||
|
fontSize: 14
|
||||||
|
},
|
||||||
|
backgroundColor: 'rgba(0,0,0,0.55)',
|
||||||
|
borderWidth: 0,
|
||||||
|
formatter(params: any) {
|
||||||
|
const xname = params[0].value[0]
|
||||||
|
let str = `${xname}<br>`
|
||||||
|
params.forEach((el: any, index: any) => {
|
||||||
|
let marker = ''
|
||||||
|
|
||||||
|
if (el.value[3] == 'dashed') {
|
||||||
|
for (let i = 0; i < 3; i++) {
|
||||||
|
marker += `<span style="display:inline-block;border: 2px ${el.color} solid;margin-right:5px;width:10px;height:0px;background-color:#ffffff00;"></span>`
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
marker = `<span style="display:inline-block;border: 2px ${el.color} ${el.value[3]};margin-right:5px;width:40px;height:0px;background-color:#ffffff00;"></span>`
|
||||||
|
}
|
||||||
|
let unit = el.value[2] ? el.value[2] : ''
|
||||||
|
// 格式化数值显示为4位小数
|
||||||
|
const value = parseFloat(el.value[1]);
|
||||||
|
const formattedValue = value.toFixed(4);
|
||||||
|
|
||||||
|
str += `${marker}${el.seriesName.split('(')[0]}:${formattedValue}${unit}<br>`
|
||||||
|
})
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
},
|
||||||
|
color: ['#DAA520', '#2E8B57', '#A52a2a', ...color],
|
||||||
|
xAxis: {
|
||||||
|
type: 'time',
|
||||||
|
axisLabel: {
|
||||||
|
formatter: function(value) {
|
||||||
|
const date = new Date(value);
|
||||||
|
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 `${hours}:${minutes}:${seconds}`;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
splitNumber: 8
|
||||||
|
},
|
||||||
|
yAxis: [{}],
|
||||||
|
|
||||||
|
options: {
|
||||||
|
series: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (chartsList.value.length > 0) {
|
||||||
|
let yData: any = []
|
||||||
|
echartsData.value.yAxis = []
|
||||||
|
let setList = [...new Set(unitList)]
|
||||||
|
|
||||||
|
setList.forEach((item: any, index: any) => {
|
||||||
|
if (index > 2) {
|
||||||
|
echartsData.value.grid.right = (index - 1) * 80
|
||||||
|
}
|
||||||
|
yData.push([])
|
||||||
|
let right = {
|
||||||
|
position: 'right',
|
||||||
|
offset: (index - 1) * 80
|
||||||
|
}
|
||||||
|
echartsData.value.yAxis.push({
|
||||||
|
name: item,
|
||||||
|
yAxisIndex: index,
|
||||||
|
splitNumber: 5,
|
||||||
|
minInterval: 0,
|
||||||
|
splitLine: {
|
||||||
|
show: false
|
||||||
|
},
|
||||||
|
axisLabel: {
|
||||||
|
// 添加标签格式化,支持小数显示
|
||||||
|
formatter: function(value) {
|
||||||
|
return value.toFixed(5);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
...(index > 0 ? right : null)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
let ABCName = [
|
||||||
|
...new Set(
|
||||||
|
chartsList.value.map((item: any) => {
|
||||||
|
return item.anotherName == '电压负序分量'
|
||||||
|
? '电压不平衡'
|
||||||
|
: item.anotherName == '电压正序分量'
|
||||||
|
? '电压不平衡'
|
||||||
|
: item.anotherName == '电压零序分量'
|
||||||
|
? '电压不平衡'
|
||||||
|
: item.anotherName
|
||||||
|
})
|
||||||
|
)
|
||||||
|
]
|
||||||
|
result.forEach((item: any, index: any) => {
|
||||||
|
let yMethodList: any = []
|
||||||
|
|
||||||
|
let ABCList = Object.values(
|
||||||
|
item.reduce((acc, item) => {
|
||||||
|
let key = ''
|
||||||
|
if (item.phase == null) {
|
||||||
|
key = item.anotherName
|
||||||
|
} else {
|
||||||
|
key = item.phase
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!acc[key]) {
|
||||||
|
acc[key] = []
|
||||||
|
}
|
||||||
|
acc[key].push(item)
|
||||||
|
return acc
|
||||||
|
}, {})
|
||||||
|
)
|
||||||
|
|
||||||
|
ABCList.forEach((kk: any) => {
|
||||||
|
let colorName = kk[0].phase?.charAt(0).toUpperCase()
|
||||||
|
let lineS = ABCName.findIndex(
|
||||||
|
item =>
|
||||||
|
item ===
|
||||||
|
(kk[0].anotherName == '电压负序分量'
|
||||||
|
? '电压不平衡'
|
||||||
|
: kk[0].anotherName == '电压正序分量'
|
||||||
|
? '电压不平衡'
|
||||||
|
: kk[0].anotherName == '电压零序分量'
|
||||||
|
? '电压不平衡'
|
||||||
|
: kk[0].anotherName)
|
||||||
|
)
|
||||||
|
let seriesList: any = []
|
||||||
|
kk.forEach((cc: any) => {
|
||||||
|
if (cc.statisticalData !== null) {
|
||||||
|
yData[setList.indexOf(kk[0].unit)].push(cc.statisticalData?.toFixed(4))
|
||||||
|
}
|
||||||
|
|
||||||
|
seriesList.push([cc.time, cc.statisticalData, cc.unit, lineStyle[lineS].type])
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
echartsData.value.options.series.push({
|
||||||
|
name: kk[0].phase ? kk[0].phase + '相' + kk[0].anotherName : kk[0].anotherName,
|
||||||
|
type: 'line',
|
||||||
|
smooth: true,
|
||||||
|
color:
|
||||||
|
colorName == 'A' ? '#DAA520' : colorName == 'B' ? '#2E8B57' : colorName == 'C' ? '#A52a2a' : '',
|
||||||
|
symbol: 'none',
|
||||||
|
data: seriesList,
|
||||||
|
lineStyle: lineStyle[lineS],
|
||||||
|
yAxisIndex: setList.indexOf(kk[0].unit)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
// yData.forEach((item: any, index: any) => {
|
||||||
|
// let [min, max] = yMethod(item)
|
||||||
|
// echartsData.value.yAxis[index].min = min
|
||||||
|
// echartsData.value.yAxis[index].max = max
|
||||||
|
// })
|
||||||
|
let allValues: number[] = [];
|
||||||
|
yData.forEach(item => {
|
||||||
|
item.forEach((val: string) => {
|
||||||
|
allValues.push(val);
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 计算全局最大最小值
|
||||||
|
let globalMin = Math.min(...allValues) - 0.0001;
|
||||||
|
let globalMax = Math.max(...allValues) +0.0001
|
||||||
|
|
||||||
|
// 确保最小值不小于0
|
||||||
|
globalMin = Math.max(0, globalMin);
|
||||||
|
|
||||||
|
// 特殊情况:如果所有值都是0
|
||||||
|
if (globalMin === 0 && globalMax === 0) {
|
||||||
|
globalMax = 1;
|
||||||
|
}
|
||||||
|
// 为所有Y轴应用相同的范围
|
||||||
|
yData.forEach((item: any, index: any) => {
|
||||||
|
echartsData.value.yAxis[index].min = globalMin ;
|
||||||
|
echartsData.value.yAxis[index].max = globalMax;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监听 tableData 变化并触发 setEchart
|
||||||
|
watch(() => prop.tableData, (newTableData) => {
|
||||||
|
// 处理数据转换
|
||||||
|
const processedData: any[] = []
|
||||||
|
|
||||||
|
newTableData.forEach(item => {
|
||||||
|
// 处理标准设备数据
|
||||||
|
processDeviceData(item, '标准设备', item.uaStdDev, item.ubStdDev, item.ucStdDev, item.utStdDev, item.timeStdDev, item.unit)
|
||||||
|
.forEach(data => processedData.push(data));
|
||||||
|
// 处理被检设备数据
|
||||||
|
processDeviceData(item, '被检设备', item.uaDev, item.ubDev, item.ucDev, item.utDev, item.timeDev, item.unit)
|
||||||
|
.forEach(data => processedData.push(data));
|
||||||
|
});
|
||||||
|
// 更新 chartsList 数据
|
||||||
|
chartsList.value = processedData
|
||||||
|
// 延迟执行确保 DOM 已经渲染
|
||||||
|
nextTick(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
setEchart()
|
||||||
|
}, 100)
|
||||||
|
})
|
||||||
|
}, {
|
||||||
|
immediate: true, // 立即执行一次
|
||||||
|
deep: true // 深度监听
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// 处理单个设备的数据
|
||||||
|
function processDeviceData(
|
||||||
|
item: any,
|
||||||
|
deviceType: string,
|
||||||
|
aValue: number | null,
|
||||||
|
bValue: number | null,
|
||||||
|
cValue: number | null,
|
||||||
|
tValue: number | null,
|
||||||
|
time: string,
|
||||||
|
unit: string
|
||||||
|
): any[] {
|
||||||
|
const result: any[] = [];
|
||||||
|
|
||||||
|
// 判断各相是否存在有效数据
|
||||||
|
const hasA = aValue !== null;
|
||||||
|
const hasB = bValue !== null;
|
||||||
|
const hasC = cValue !== null;
|
||||||
|
const hasT = tValue !== null;
|
||||||
|
|
||||||
|
// 计算有多少相有数据
|
||||||
|
const phaseCount = (hasA ? 1 : 0) + (hasB ? 1 : 0) + (hasC ? 1 : 0);
|
||||||
|
// 时间四舍五入到秒
|
||||||
|
const roundedTime = roundTimeToSecond(time);
|
||||||
|
|
||||||
|
if (hasA) {
|
||||||
|
result.push({
|
||||||
|
anotherName: deviceType,
|
||||||
|
phase: phaseCount > 1 ? 'A' : null,
|
||||||
|
statisticalData: aValue,
|
||||||
|
time: roundedTime,
|
||||||
|
unit: unit,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasB) {
|
||||||
|
result.push({
|
||||||
|
anotherName: deviceType,
|
||||||
|
phase: phaseCount > 1 ? 'B' : null,
|
||||||
|
statisticalData: bValue,
|
||||||
|
time: roundedTime,
|
||||||
|
unit: unit,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasC) {
|
||||||
|
result.push({
|
||||||
|
anotherName: deviceType,
|
||||||
|
phase: phaseCount > 1 ? 'C' : null,
|
||||||
|
statisticalData: cValue,
|
||||||
|
time: roundedTime,
|
||||||
|
unit: unit,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasT) {
|
||||||
|
result.push({
|
||||||
|
anotherName: deviceType,
|
||||||
|
phase: null,
|
||||||
|
statisticalData: tValue,
|
||||||
|
time: roundedTime,
|
||||||
|
unit: unit,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 时间四舍五入到秒的辅助函数
|
||||||
|
function roundTimeToSecond(timeStr: string): string {
|
||||||
|
if (!timeStr) return timeStr;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 直接使用本地时间解析,避免时区转换问题
|
||||||
|
// 替换空格为 T 以符合 ISO 格式
|
||||||
|
const isoString = timeStr.replace(' ', 'T');
|
||||||
|
const date = new Date(isoString);
|
||||||
|
|
||||||
|
// 检查日期是否有效
|
||||||
|
if (isNaN(date.getTime())) {
|
||||||
|
return timeStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取毫秒部分
|
||||||
|
const milliseconds = date.getMilliseconds();
|
||||||
|
|
||||||
|
// 如果毫秒数大于等于500,则加一秒
|
||||||
|
if (milliseconds >= 500) {
|
||||||
|
date.setSeconds(date.getSeconds() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 清除毫秒部分
|
||||||
|
date.setMilliseconds(0);
|
||||||
|
|
||||||
|
// 手动格式化为 YYYY-MM-DD HH:mm:ss 格式(使用本地时间)
|
||||||
|
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');
|
||||||
|
|
||||||
|
const formattedTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
||||||
|
|
||||||
|
|
||||||
|
return formattedTime;
|
||||||
|
} catch (error) {
|
||||||
|
// 如果解析失败,返回原始时间字符串
|
||||||
|
console.error('时间解析错误:', error);
|
||||||
|
return timeStr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.history_chart {
|
||||||
|
width: 100%;
|
||||||
|
height: 360px; /* 明确指定高度 */
|
||||||
|
margin-top: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 或者设置最小高度 */
|
||||||
|
.history_chart {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 300px; /* 确保有最小高度 */
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -12,14 +12,14 @@
|
|||||||
<el-table-column type="index" label="序号" width="70" fixed="left"/>
|
<el-table-column type="index" label="序号" width="70" fixed="left"/>
|
||||||
|
|
||||||
|
|
||||||
<el-table-column prop="dataA" :label="'标准设备'">
|
<el-table-column :label="'标准设备'">
|
||||||
<el-table-column prop="timeStdDev" label="数据时间" width="200"/>
|
<el-table-column prop="timeStdDev" label="数据时间" width="200"/>
|
||||||
<el-table-column prop="uaStdDev" :label="'A相'+(outerUnit==''?'':'('+outerUnit+')')" v-if="prop.tableData.length==0||prop.tableData[0]?.uaStdDev != null"/>
|
<el-table-column prop="uaStdDev" :label="'A相'+(outerUnit==''?'':'('+outerUnit+')')" v-if="prop.tableData.length==0||prop.tableData[0]?.uaStdDev != null"/>
|
||||||
<el-table-column prop="ubStdDev" :label="setB+(outerUnit==''?'':'('+outerUnit+')')" v-if="prop.tableData.length==0||prop.tableData[0]?.ubStdDev != null"/>
|
<el-table-column prop="ubStdDev" :label="setB+(outerUnit==''?'':'('+outerUnit+')')" v-if="prop.tableData.length==0||prop.tableData[0]?.ubStdDev != null"/>
|
||||||
<el-table-column prop="ucStdDev" :label="'C相'+(outerUnit==''?'':'('+outerUnit+')')" v-if="prop.tableData.length==0||prop.tableData[0]?.ucStdDev != null"/>
|
<el-table-column prop="ucStdDev" :label="'C相'+(outerUnit==''?'':'('+outerUnit+')')" v-if="prop.tableData.length==0||prop.tableData[0]?.ucStdDev != null"/>
|
||||||
<el-table-column prop="utStdDev" :label="setT+(outerUnit==''?'':'('+outerUnit+')')" v-if="prop.tableData[0]?.utStdDev != null"/>
|
<el-table-column prop="utStdDev" :label="setT+(outerUnit==''?'':'('+outerUnit+')')" v-if="prop.tableData[0]?.utStdDev != null"/>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="dataA" :label="'被检设备'">
|
<el-table-column :label="'被检设备'">
|
||||||
<el-table-column prop="timeDev" label="数据时间" width="200"/>
|
<el-table-column prop="timeDev" label="数据时间" width="200"/>
|
||||||
<el-table-column prop="uaDev" :label="'A相'+(outerUnit==''?'':'('+outerUnit+')')" v-if="prop.tableData.length==0||prop.tableData[0]?.uaDev != null"/>
|
<el-table-column prop="uaDev" :label="'A相'+(outerUnit==''?'':'('+outerUnit+')')" v-if="prop.tableData.length==0||prop.tableData[0]?.uaDev != null"/>
|
||||||
<el-table-column prop="ubDev" :label="setB+(outerUnit==''?'':'('+outerUnit+')')" v-if="prop.tableData.length==0||prop.tableData[0]?.ubDev != null"/>
|
<el-table-column prop="ubDev" :label="setB+(outerUnit==''?'':'('+outerUnit+')')" v-if="prop.tableData.length==0||prop.tableData[0]?.ubDev != null"/>
|
||||||
|
|||||||
@@ -2,11 +2,13 @@
|
|||||||
<div class="table-main">
|
<div class="table-main">
|
||||||
<el-table
|
<el-table
|
||||||
:data="prop.tableData"
|
:data="prop.tableData"
|
||||||
height="368px"
|
stripe
|
||||||
|
border
|
||||||
:header-cell-style="{ textAlign: 'center' }"
|
:header-cell-style="{ textAlign: 'center' }"
|
||||||
:cell-style="{ textAlign: 'center' }"
|
:cell-style="{ textAlign: 'center' }"
|
||||||
|
height="368px"
|
||||||
|
style="width: 100%"
|
||||||
>
|
>
|
||||||
<!-- <el-table-column type="index" label="序号" width="70" fixed="left" />-->
|
|
||||||
<el-table-column label="A相" v-if="prop.tableData.length==0|| prop.tableData[0]?.dataA">
|
<el-table-column label="A相" v-if="prop.tableData.length==0|| prop.tableData[0]?.dataA">
|
||||||
|
|
||||||
<el-table-column prop="dataA" :label="'标准值'+(outerUnit==''?'':'('+outerUnit+')')">
|
<el-table-column prop="dataA" :label="'标准值'+(outerUnit==''?'':'('+outerUnit+')')">
|
||||||
@@ -21,7 +23,11 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="isDataA" label="检测结果">
|
<el-table-column prop="isDataA" label="检测结果">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-tooltip effect="dark" placement="bottom">
|
<template v-if="row.dataA.isData === 4 || row.dataA.isData === 5">
|
||||||
|
<el-tag type="warning" v-if="row.dataA.isData === 4">/</el-tag>
|
||||||
|
<el-tag type="info" v-if="row.dataA.isData === 5">-</el-tag>
|
||||||
|
</template>
|
||||||
|
<el-tooltip v-else effect="dark" placement="bottom">
|
||||||
<template #content>
|
<template #content>
|
||||||
误差范围:{{ addPercentSigns(row.dataA.radius, row.dataA.unit) }}
|
误差范围:{{ addPercentSigns(row.dataA.radius, row.dataA.unit) }}
|
||||||
<br/>
|
<br/>
|
||||||
@@ -29,8 +35,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<el-tag type="success" v-if="row.dataA.isData === 1">符合</el-tag>
|
<el-tag type="success" v-if="row.dataA.isData === 1">符合</el-tag>
|
||||||
<el-tag type="danger" v-if="row.dataA.isData === 2">不符合</el-tag>
|
<el-tag type="danger" v-if="row.dataA.isData === 2">不符合</el-tag>
|
||||||
<el-tag type="warning" v-if="row.dataA.isData === 4">/</el-tag>
|
|
||||||
<el-tag type="info" v-if="row.dataA.isData === 5">-</el-tag>
|
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -49,7 +54,11 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="isDataB" label="检测结果">
|
<el-table-column prop="isDataB" label="检测结果">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-tooltip effect="dark" placement="bottom">
|
<template v-if="row.dataB.isData === 4 || row.dataB.isData === 5">
|
||||||
|
<el-tag type="warning" v-if="row.dataB.isData === 4">/</el-tag>
|
||||||
|
<el-tag type="info" v-if="row.dataB.isData === 5">-</el-tag>
|
||||||
|
</template>
|
||||||
|
<el-tooltip v-else effect="dark" placement="bottom">
|
||||||
<template #content>
|
<template #content>
|
||||||
误差范围:{{ addPercentSigns(row.dataB.radius, row.dataB.unit) }}
|
误差范围:{{ addPercentSigns(row.dataB.radius, row.dataB.unit) }}
|
||||||
<br/>
|
<br/>
|
||||||
@@ -57,8 +66,6 @@
|
|||||||
</template>
|
</template>
|
||||||
<el-tag type="success" v-if="row.dataB.isData === 1">符合</el-tag>
|
<el-tag type="success" v-if="row.dataB.isData === 1">符合</el-tag>
|
||||||
<el-tag type="danger" v-if="row.dataB.isData === 2">不符合</el-tag>
|
<el-tag type="danger" v-if="row.dataB.isData === 2">不符合</el-tag>
|
||||||
<el-tag type="warning" v-if="row.dataB.isData === 4">/</el-tag>
|
|
||||||
<el-tag type="info" v-if="row.dataB.isData === 5">-</el-tag>
|
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -77,7 +84,11 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="isDataC" label="检测结果">
|
<el-table-column prop="isDataC" label="检测结果">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-tooltip effect="dark" placement="bottom">
|
<template v-if="row.dataC.isData === 4 || row.dataC.isData === 5">
|
||||||
|
<el-tag type="warning" v-if="row.dataC.isData === 4">/</el-tag>
|
||||||
|
<el-tag type="info" v-if="row.dataC.isData === 5">-</el-tag>
|
||||||
|
</template>
|
||||||
|
<el-tooltip v-else effect="dark" placement="bottom">
|
||||||
<template #content>
|
<template #content>
|
||||||
误差范围:{{ addPercentSigns(row.dataC.radius, row.dataC.unit) }}
|
误差范围:{{ addPercentSigns(row.dataC.radius, row.dataC.unit) }}
|
||||||
<br/>
|
<br/>
|
||||||
@@ -85,8 +96,6 @@
|
|||||||
</template>
|
</template>
|
||||||
<el-tag type="success" v-if="row.dataC.isData === 1">符合</el-tag>
|
<el-tag type="success" v-if="row.dataC.isData === 1">符合</el-tag>
|
||||||
<el-tag type="danger" v-if="row.dataC.isData === 2">不符合</el-tag>
|
<el-tag type="danger" v-if="row.dataC.isData === 2">不符合</el-tag>
|
||||||
<el-tag type="warning" v-if="row.dataC.isData === 4">/</el-tag>
|
|
||||||
<el-tag type="info" v-if="row.dataC.isData === 5">-</el-tag>
|
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -105,7 +114,11 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="isDataT" label="检测结果">
|
<el-table-column prop="isDataT" label="检测结果">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-tooltip effect="dark" placement="bottom">
|
<template v-if="row.dataT.isData === 4 || row.dataT.isData === 5">
|
||||||
|
<el-tag type="warning" v-if="row.dataT.isData === 4">/</el-tag>
|
||||||
|
<el-tag type="info" v-if="row.dataT.isData === 5">-</el-tag>
|
||||||
|
</template>
|
||||||
|
<el-tooltip v-else effect="dark" placement="bottom">
|
||||||
<template #content>
|
<template #content>
|
||||||
误差范围:{{ addPercentSigns(row.dataT.radius, row.dataT.unit) }}
|
误差范围:{{ addPercentSigns(row.dataT.radius, row.dataT.unit) }}
|
||||||
<br/>
|
<br/>
|
||||||
@@ -113,8 +126,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<el-tag type="success" v-if="row.dataT.isData === 1">符合</el-tag>
|
<el-tag type="success" v-if="row.dataT.isData === 1">符合</el-tag>
|
||||||
<el-tag type="danger" v-if="row.dataT.isData === 2">不符合</el-tag>
|
<el-tag type="danger" v-if="row.dataT.isData === 2">不符合</el-tag>
|
||||||
<el-tag type="warning" v-if="row.dataT.isData === 4">/</el-tag>
|
|
||||||
<el-tag type="info" v-if="row.dataT.isData === 5">-</el-tag>
|
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
v-model="formContent.errorSysId"
|
v-model="formContent.errorSysId"
|
||||||
placeholder="请选择误差体系"
|
placeholder="请选择误差体系"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
@change="handleErrorSysChange"
|
@change="handleErrorSysChange('切换误差体系成功')"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="option in pqErrorList"
|
v-for="option in pqErrorList"
|
||||||
@@ -29,7 +29,20 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="数据原则">
|
<el-form-item label="数据原则">
|
||||||
<el-input v-model="formContent.dataRule" :disabled="true" />
|
<!-- <el-input v-model="formContent.dataRule" :disabled="true" />-->
|
||||||
|
<el-select
|
||||||
|
:disabled="checkStore.showDetailType === 2 || checkStore.showDetailType === 0"
|
||||||
|
v-model="formContent.dataRule"
|
||||||
|
placeholder="请选择数据原则"
|
||||||
|
autocomplete="off"
|
||||||
|
@change="handleErrorSysChange('切换数据处理原则成功')">
|
||||||
|
<el-option
|
||||||
|
v-for="item in dictStore.getDictData('Data_Rule')"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.name"
|
||||||
|
:value="item.id"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="设备名称">
|
<el-form-item label="设备名称">
|
||||||
<el-input v-model="formContent.deviceName" :disabled="true" />
|
<el-input v-model="formContent.deviceName" :disabled="true" />
|
||||||
@@ -55,7 +68,7 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-if="checkStore.showDetailType === 1">
|
<el-form-item v-if="checkStore.showDetailType === 1">
|
||||||
<el-button type="primary" :icon="Postcard">报告生成</el-button>
|
<el-button type="primary" :icon="Postcard" @click="handleGenerateReport">报告生成</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-if="checkStore.showDetailType === 0">
|
<el-form-item v-if="checkStore.showDetailType === 0">
|
||||||
<el-button type="primary" :icon="Histogram" @click="handleReCalculate">重新计算</el-button>
|
<el-button type="primary" :icon="Histogram" @click="handleReCalculate">重新计算</el-button>
|
||||||
@@ -146,10 +159,10 @@
|
|||||||
<el-tabs type="border-card" v-model="activeTab">
|
<el-tabs type="border-card" v-model="activeTab">
|
||||||
<el-tab-pane label="检测结果" name="resultTab">
|
<el-tab-pane label="检测结果" name="resultTab">
|
||||||
<CompareDataCheckResultTable
|
<CompareDataCheckResultTable
|
||||||
|
v-if="activeTab === 'resultTab'"
|
||||||
:tableData="checkResultData.length == 0 ? [] : currentCheckResultData"
|
:tableData="checkResultData.length == 0 ? [] : currentCheckResultData"
|
||||||
:currentCheckItem="currentCheckItem"
|
:currentCheckItem="currentCheckItem"
|
||||||
:currentScriptTypeName="currentScriptTypeName"
|
:currentScriptTypeName="currentScriptTypeName"
|
||||||
v-if="activeTab === 'resultTab'"
|
|
||||||
/>
|
/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="原始数据" name="rawDataTab">
|
<el-tab-pane label="原始数据" name="rawDataTab">
|
||||||
@@ -160,6 +173,12 @@
|
|||||||
:currentScriptTypeName="currentScriptTypeName"
|
:currentScriptTypeName="currentScriptTypeName"
|
||||||
/>
|
/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
<el-tab-pane label="历史趋势" name="chartTab" v-if="!isWaveData">
|
||||||
|
<CompareDataCheckChart
|
||||||
|
v-if="activeTab === 'chartTab'"
|
||||||
|
:tableData="rawTableData.length == 0 ? [] : currentRawTableData"
|
||||||
|
/>
|
||||||
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -172,10 +191,11 @@ import { dialogBig } from '@/utils/elementBind'
|
|||||||
import { computed, reactive, ref } from 'vue'
|
import { computed, reactive, ref } from 'vue'
|
||||||
import CompareDataCheckResultTable from './compareDataCheckResultTable.vue'
|
import CompareDataCheckResultTable from './compareDataCheckResultTable.vue'
|
||||||
import CompareDataCheckRawDataTable from './compareDataCheckRawDataTable.vue'
|
import CompareDataCheckRawDataTable from './compareDataCheckRawDataTable.vue'
|
||||||
|
import CompareDataCheckChart from './compareDataCheckChart.vue'
|
||||||
import { CheckData } from '@/api/check/interface'
|
import { CheckData } from '@/api/check/interface'
|
||||||
import { useCheckStore } from '@/stores/modules/check'
|
import { useCheckStore } from '@/stores/modules/check'
|
||||||
import { Histogram, Postcard } from '@element-plus/icons-vue'
|
import { Histogram, Postcard } from '@element-plus/icons-vue'
|
||||||
import { getPqErrSysList } from '@/api/plan/plan'
|
import {generateDevReport, getPqErrSysList} from '@/api/plan/plan'
|
||||||
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
|
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
|
||||||
import { useDictStore } from '@/stores/modules/dict'
|
import { useDictStore } from '@/stores/modules/dict'
|
||||||
import {
|
import {
|
||||||
@@ -256,6 +276,7 @@ const currentRawTableData = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const open = async (row: any, chnNum: string, deviceId: string | null, source: number) => {
|
const open = async (row: any, chnNum: string, deviceId: string | null, source: number) => {
|
||||||
|
activeTab.value = 'resultTab'
|
||||||
isWaveData.value = false
|
isWaveData.value = false
|
||||||
pattern.value = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? '' //获取数据字典中对应的id
|
pattern.value = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? '' //获取数据字典中对应的id
|
||||||
rowList.value = {}
|
rowList.value = {}
|
||||||
@@ -507,6 +528,7 @@ const getResults = async (code: any) => {
|
|||||||
// 判断是否为录波数据请求
|
// 判断是否为录波数据请求
|
||||||
const isWaveDataRequest = code === 'wave_data' || isWaveData.value
|
const isWaveDataRequest = code === 'wave_data' || isWaveData.value
|
||||||
|
|
||||||
|
|
||||||
getContrastResult({
|
getContrastResult({
|
||||||
planId: checkStore.plan.id,
|
planId: checkStore.plan.id,
|
||||||
scriptType: rowList.value.scriptType,
|
scriptType: rowList.value.scriptType,
|
||||||
@@ -515,7 +537,8 @@ const getResults = async (code: any) => {
|
|||||||
num: formContent.num == '' ? null : formContent.num,
|
num: formContent.num == '' ? null : formContent.num,
|
||||||
waveNum: isWaveDataRequest ? waveNumber.value : null,
|
waveNum: isWaveDataRequest ? waveNumber.value : null,
|
||||||
isWave: isWaveDataRequest,
|
isWave: isWaveDataRequest,
|
||||||
patternId: pattern.value
|
patternId: pattern.value,
|
||||||
|
code: checkStore.plan.code + (formContent.errorSysId!=checkStore.plan.errorSysId || formContent.dataRule!=checkStore.plan.dataRule? '_temp':'')
|
||||||
}).then((res: any) => {
|
}).then((res: any) => {
|
||||||
let list: string[] = []
|
let list: string[] = []
|
||||||
for (let key in res.data.resultMap) {
|
for (let key in res.data.resultMap) {
|
||||||
@@ -556,17 +579,19 @@ const close = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleErrorSysChange = async () => {
|
const handleErrorSysChange = async (msg:string) => {
|
||||||
changeErrorSystem({
|
changeErrorSystem({
|
||||||
planId: checkStore.plan.id,
|
planId: checkStore.plan.id,
|
||||||
scriptId: '',
|
scriptId: '',
|
||||||
errorSysId: formContent.errorSysId,
|
errorSysId: formContent.errorSysId,
|
||||||
deviceId: formContent.deviceId,
|
deviceId: formContent.deviceId,
|
||||||
code: checkStore.plan.code + '',
|
code: checkStore.plan.code + '',
|
||||||
patternId: dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? ''
|
patternId: dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? '',
|
||||||
|
chnNum: formContent.chnNum,
|
||||||
|
dataRuleId: formContent.dataRule
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.code === ResultEnum.SUCCESS) {
|
if (res.code === ResultEnum.SUCCESS) {
|
||||||
ElMessage.success('切换误差体系成功')
|
ElMessage.success(msg)
|
||||||
handleChnNumChange(formContent.chnNum)
|
handleChnNumChange(formContent.chnNum)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -579,7 +604,9 @@ const handleReCalculate = async () => {
|
|||||||
errorSysId: formContent.errorSysId,
|
errorSysId: formContent.errorSysId,
|
||||||
deviceId: formContent.deviceId,
|
deviceId: formContent.deviceId,
|
||||||
code: checkStore.plan.code + '',
|
code: checkStore.plan.code + '',
|
||||||
patternId: dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? ''
|
patternId: dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? '',
|
||||||
|
chnNum: formContent.chnNum,
|
||||||
|
dataRuleId: formContent.dataRule,
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.code === ResultEnum.SUCCESS) {
|
if (res.code === ResultEnum.SUCCESS) {
|
||||||
ElMessage.success('重新计算成功!')
|
ElMessage.success('重新计算成功!')
|
||||||
@@ -588,6 +615,20 @@ const handleReCalculate = async () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleGenerateReport = async () => {
|
||||||
|
generateDevReport({
|
||||||
|
planId: checkStore.plan.id,
|
||||||
|
devIdList: [formContent.deviceId],
|
||||||
|
scriptId: checkStore.plan.scriptId,
|
||||||
|
planCode: checkStore.plan.code + (formContent.errorSysId!=checkStore.plan.errorSysId ? '_temp':'')
|
||||||
|
}).then(res => {
|
||||||
|
if (res.code === ResultEnum.SUCCESS) {
|
||||||
|
ElMessage.success({ message: `报告生成成功!` })
|
||||||
|
handleChnNumChange(formContent.chnNum)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
open
|
open
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<el-step :status="step1" title="设备通讯校验"/>
|
<el-step :status="step1" title="设备通讯校验"/>
|
||||||
<el-step :status="step2" title="模型一致性校验"/>
|
<el-step :status="step2" title="模型一致性校验"/>
|
||||||
<el-step :status="step3" title="数据对齐验证" v-if="!props.onlyWave"/>
|
<el-step :status="step3" title="数据对齐验证" v-if="!props.onlyWave"/>
|
||||||
<el-step :status="step4" title="相序校验"/>
|
<el-step :status="step4" title="相序校验" v-if="props.xiangXuIsShow"/>
|
||||||
<!-- <el-step :status="step6" title="遥控录波功能验证"/> -->
|
<!-- <el-step :status="step6" title="遥控录波功能验证"/> -->
|
||||||
<el-step :status="step5" :title="ts === 'error'? '检测失败':ts === 'process'? '检测中':ts === 'success'? '检测成功':'待检测'"/>
|
<el-step :status="step5" :title="ts === 'error'? '检测失败':ts === 'process'? '检测中':ts === 'success'? '检测成功':'待检测'"/>
|
||||||
</el-steps>
|
</el-steps>
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</el-collapse-item>
|
</el-collapse-item>
|
||||||
<el-collapse-item title="相序校验" name="4">
|
<el-collapse-item title="相序校验" name="4" v-if="props.xiangXuIsShow">
|
||||||
<div class="div-log">
|
<div class="div-log">
|
||||||
<p v-for="(item, index) in step4InitLog" :key="index"
|
<p v-for="(item, index) in step4InitLog" :key="index"
|
||||||
:style="{ color: item.type === 'error' ? '#F56C6C' : 'var(--el-text-color-regular)' }">
|
:style="{ color: item.type === 'error' ? '#F56C6C' : 'var(--el-text-color-regular)' }">
|
||||||
@@ -84,6 +84,28 @@
|
|||||||
import { ElMessage, ElMessageBox, StepProps } from 'element-plus'
|
import { ElMessage, ElMessageBox, StepProps } from 'element-plus'
|
||||||
import { computed, PropType, ref, toRef, watch } from 'vue'
|
import { computed, PropType, ref, toRef, watch } from 'vue'
|
||||||
import RealTimeData from './realTimeDataAlign.vue'
|
import RealTimeData from './realTimeDataAlign.vue'
|
||||||
|
const props = defineProps({
|
||||||
|
testStatus: {
|
||||||
|
type: String,
|
||||||
|
default: 'wait'
|
||||||
|
},
|
||||||
|
webMsgSend: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({})
|
||||||
|
},
|
||||||
|
mapping: {
|
||||||
|
type: Object as PropType<Record<string, Record<string, string>>>,
|
||||||
|
default: () => ({})
|
||||||
|
},
|
||||||
|
onlyWave: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
xiangXuIsShow:{
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const realTimeDataRef = ref()
|
const realTimeDataRef = ref()
|
||||||
|
|
||||||
@@ -122,10 +144,13 @@ const isShowDialog = ref(false)
|
|||||||
const collapseActiveName = ref('1')
|
const collapseActiveName = ref('1')
|
||||||
const activeIndex = ref(0)
|
const activeIndex = ref(0)
|
||||||
const activeTotalNum = computed(() => {
|
const activeTotalNum = computed(() => {
|
||||||
let count = 4; // 基础步骤数:设备通讯校验、模型一致性校验、相序校验、最终状态
|
let count = 3; // 基础步骤数:设备通讯校验、模型一致性校验、最终状态
|
||||||
if (props.onlyWave) {
|
if (!props.onlyWave) {
|
||||||
count++; // 添加数据对齐验证步骤
|
count++; // 添加数据对齐验证步骤
|
||||||
}
|
}
|
||||||
|
if(props.xiangXuIsShow){//添加相序校验
|
||||||
|
count++;
|
||||||
|
}
|
||||||
return count;
|
return count;
|
||||||
});
|
});
|
||||||
const step1 = ref<StepProps['status']>('wait')
|
const step1 = ref<StepProps['status']>('wait')
|
||||||
@@ -150,35 +175,18 @@ const detectionOptions = ref([
|
|||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
name: "数据对齐验证",
|
name: "数据对齐验证",
|
||||||
selected: true,
|
selected: !props.onlyWave,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
name: "相序校验",
|
name: "相序校验",
|
||||||
selected: true,
|
selected: props.xiangXuIsShow,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const currentStepStatus = ref<'error' | 'finish' | 'wait' | 'success' | 'process'>('finish');
|
const currentStepStatus = ref<'error' | 'finish' | 'wait' | 'success' | 'process'>('finish');
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
testStatus: {
|
|
||||||
type: String,
|
|
||||||
default: 'wait'
|
|
||||||
},
|
|
||||||
webMsgSend: {
|
|
||||||
type: Object,
|
|
||||||
default: () => ({})
|
|
||||||
},
|
|
||||||
mapping: {
|
|
||||||
type: Object as PropType<Record<string, Record<string, string>>>,
|
|
||||||
default: () => ({})
|
|
||||||
},
|
|
||||||
onlyWave: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
const testStatus = toRef(props, 'testStatus');
|
const testStatus = toRef(props, 'testStatus');
|
||||||
@@ -332,6 +340,11 @@ watch(webMsgSend, function (newValue, oldValue) {
|
|||||||
if (newValue.code == 25001) { //最终成功
|
if (newValue.code == 25001) { //最终成功
|
||||||
step2.value = 'success'
|
step2.value = 'success'
|
||||||
step3.value = 'process'
|
step3.value = 'process'
|
||||||
|
if(props.onlyWave === true && props.xiangXuIsShow === false )//只有录波,相序不选
|
||||||
|
{
|
||||||
|
step5.value = 'success'
|
||||||
|
ts.value = 'success'
|
||||||
|
}
|
||||||
activeIndex.value = 2
|
activeIndex.value = 2
|
||||||
}
|
}
|
||||||
if (newValue.code == 25003) { //最终失败
|
if (newValue.code == 25003) { //最终失败
|
||||||
@@ -374,6 +387,11 @@ watch(webMsgSend, function (newValue, oldValue) {
|
|||||||
isShowDialog.value = true
|
isShowDialog.value = true
|
||||||
step3.value = 'success'
|
step3.value = 'success'
|
||||||
step4.value = 'process'
|
step4.value = 'process'
|
||||||
|
if(props.onlyWave === false && props.xiangXuIsShow === false )//相序不选
|
||||||
|
{
|
||||||
|
step5.value = 'success'
|
||||||
|
ts.value = 'success'
|
||||||
|
}
|
||||||
activeIndex.value = 3
|
activeIndex.value = 3
|
||||||
testDataStructure.value = newValue.data
|
testDataStructure.value = newValue.data
|
||||||
}
|
}
|
||||||
@@ -514,18 +532,30 @@ watch(webMsgSend, function (newValue, oldValue) {
|
|||||||
// })
|
// })
|
||||||
|
|
||||||
watch(activeIndex, function (newValue, oldValue) {
|
watch(activeIndex, function (newValue, oldValue) {
|
||||||
if(props.onlyWave === true)
|
|
||||||
|
if(props.onlyWave === true && props.xiangXuIsShow === false )
|
||||||
{
|
{
|
||||||
if (Number(collapseActiveName.value) < activeTotalNum.value - 2) {
|
if (Number(collapseActiveName.value) < activeTotalNum.value) {
|
||||||
|
if(newValue == 2){
|
||||||
|
collapseActiveName.value = '2'
|
||||||
|
}else{
|
||||||
|
collapseActiveName.value = (newValue + 1).toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(props.onlyWave === true && props.xiangXuIsShow === true )
|
||||||
|
{
|
||||||
|
if (Number(collapseActiveName.value) < activeTotalNum.value) {
|
||||||
if(newValue == 2){
|
if(newValue == 2){
|
||||||
collapseActiveName.value = '4'
|
collapseActiveName.value = '4'
|
||||||
}else{
|
}else{
|
||||||
collapseActiveName.value = (newValue + 1).toString()
|
collapseActiveName.value = (newValue + 1).toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (Number(collapseActiveName.value) < activeTotalNum.value) {
|
if (Number(collapseActiveName.value) < activeTotalNum.value - 1) {
|
||||||
collapseActiveName.value = (newValue + 1).toString()
|
collapseActiveName.value = (newValue + 1).toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,9 +37,9 @@
|
|||||||
align="center"
|
align="center"
|
||||||
>
|
>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
v-for="(chnItem, index2) in checkStore.chnNumList"
|
v-for="(chnItem, index2) in checkStore.chnNumList.filter(c => c.startsWith(item.deviceId))"
|
||||||
:key="`${item.deviceId}${chnItem}`"
|
:key="`${item.deviceId}${chnItem}`"
|
||||||
:label="'通道' + chnItem"
|
:label="'通道' + chnItem.split('-')[1]"
|
||||||
align="center"
|
align="center"
|
||||||
>
|
>
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
"
|
"
|
||||||
:color="row.devices[index1].chnResult[index2].color"
|
:color="row.devices[index1].chnResult[index2].color"
|
||||||
size="small"
|
size="small"
|
||||||
@click="handleClick(row, chnItem, row.scriptType)"
|
@click="handleClick(row, chnItem.split('-')[1], row.scriptType)"
|
||||||
style="align-self: center"
|
style="align-self: center"
|
||||||
>
|
>
|
||||||
<el-icon
|
<el-icon
|
||||||
@@ -129,6 +129,7 @@ import {useCheckStore} from '@/stores/modules/check'
|
|||||||
import {ElMessage, ElMessageBox} from 'element-plus'
|
import {ElMessage, ElMessageBox} from 'element-plus'
|
||||||
import {getBigTestItem} from '@/api/check/test'
|
import {getBigTestItem} from '@/api/check/test'
|
||||||
import {getAutoGenerate} from '@/api/user/login'
|
import {getAutoGenerate} from '@/api/user/login'
|
||||||
|
import { generateDevReport } from '@/api/plan/plan'
|
||||||
import {useModeStore} from '@/stores/modules/mode' // 引入模式 store
|
import {useModeStore} from '@/stores/modules/mode' // 引入模式 store
|
||||||
import {useDictStore} from '@/stores/modules/dict'
|
import {useDictStore} from '@/stores/modules/dict'
|
||||||
const checkStore = useCheckStore()
|
const checkStore = useCheckStore()
|
||||||
@@ -668,19 +669,19 @@ const updatePercentage = async () => {
|
|||||||
percentage.value = 100
|
percentage.value = 100
|
||||||
emit('update:testStatus', 'success')
|
emit('update:testStatus', 'success')
|
||||||
|
|
||||||
let {data: autoGenerate} = await getAutoGenerate()
|
|
||||||
|
// 检查是否需要自动生成报告
|
||||||
|
let { data: autoGenerate } = await getAutoGenerate()
|
||||||
if (autoGenerate == 1) {
|
if (autoGenerate == 1) {
|
||||||
//调用自动生成报告接口
|
// 自动生成报告
|
||||||
let devIdList = checkStore.devices.map(item => {
|
let devIdList = checkStore.devices.map(item => {
|
||||||
return item.deviceId
|
return item.deviceId
|
||||||
})
|
})
|
||||||
|
await generateDevReport({
|
||||||
// await generateDevReport({
|
'planId': checkStore.plan.id,
|
||||||
// planId: checkStore.plan.id,
|
'devIdList': devIdList,
|
||||||
// devIdList: devIdList,
|
'planCode': checkStore.plan.code + ''
|
||||||
// scriptId: checkStore.plan.scriptId,
|
})
|
||||||
// planCode: checkStore.plan.code + ''
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
stopTimeCount(1)
|
stopTimeCount(1)
|
||||||
ElMessageBox.alert(
|
ElMessageBox.alert(
|
||||||
@@ -803,6 +804,7 @@ const initCheckResult = (defaultValue: CheckData.ChnCheckResultEnum) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Object.assign(checkResult, result)
|
Object.assign(checkResult, result)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const scrollToBottom = () => {
|
const scrollToBottom = () => {
|
||||||
|
|||||||
@@ -58,6 +58,7 @@
|
|||||||
:webMsgSend="webMsgSend"
|
:webMsgSend="webMsgSend"
|
||||||
:mapping="channelMapping"
|
:mapping="channelMapping"
|
||||||
:onlyWave="onlyWave"
|
:onlyWave="onlyWave"
|
||||||
|
:xiangXuIsShow="xiangXuIsShow"
|
||||||
/>
|
/>
|
||||||
</keep-alive>
|
</keep-alive>
|
||||||
<keep-alive>
|
<keep-alive>
|
||||||
@@ -170,6 +171,9 @@ const preTestRef = ref<InstanceType<typeof ComparePreTest> | null>(null)
|
|||||||
const testRef: any = ref(null)
|
const testRef: any = ref(null)
|
||||||
const windowWidth = ref(window.innerWidth)
|
const windowWidth = ref(window.innerWidth)
|
||||||
const computedDialogWidth = ref(0)
|
const computedDialogWidth = ref(0)
|
||||||
|
|
||||||
|
const xiangXuIsShow = ref(true)//预检测是否展示相序检测
|
||||||
|
|
||||||
// 监听窗口大小变化
|
// 监听窗口大小变化
|
||||||
const handleResize = () => {
|
const handleResize = () => {
|
||||||
windowWidth.value = window.innerWidth
|
windowWidth.value = window.innerWidth
|
||||||
@@ -278,7 +282,6 @@ const open = async (
|
|||||||
pairs.value = pair
|
pairs.value = pair
|
||||||
showSteps.value = true
|
showSteps.value = true
|
||||||
initOperate()
|
initOperate()
|
||||||
dialogTitle.value = title
|
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
|
|
||||||
// 等待组件渲染完成
|
// 等待组件渲染完成
|
||||||
@@ -343,7 +346,8 @@ const handleSubmitAgain = async () => {
|
|||||||
standardDevIds: standardDevIds.value,
|
standardDevIds: standardDevIds.value,
|
||||||
pairs: pairs.value,
|
pairs: pairs.value,
|
||||||
testItemList: [checkStore.selectTestItems.preTest, false, checkStore.selectTestItems.test],
|
testItemList: [checkStore.selectTestItems.preTest, false, checkStore.selectTestItems.test],
|
||||||
userId: userStore.userInfo.id
|
userId: userStore.userInfo.id,
|
||||||
|
phaseCheck: xiangXuIsShow.value ? 1 : 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
preTestStatus.value = 'start'
|
preTestStatus.value = 'start'
|
||||||
@@ -351,6 +355,26 @@ const handleSubmitAgain = async () => {
|
|||||||
|
|
||||||
//开始检测
|
//开始检测
|
||||||
const handleSubmitFast = async () => {
|
const handleSubmitFast = async () => {
|
||||||
|
|
||||||
|
try {
|
||||||
|
await ElMessageBox.confirm('是否需要进行相序检测?', '确认检测', {
|
||||||
|
confirmButtonText: '是',
|
||||||
|
cancelButtonText: '否',
|
||||||
|
distinguishCancelAndClose: true, // 区分取消和关闭操作
|
||||||
|
type: 'warning'
|
||||||
|
});
|
||||||
|
xiangXuIsShow.value = true;
|
||||||
|
} catch (action) {
|
||||||
|
// 区分用户点击关闭按钮和其他情况
|
||||||
|
if (action === 'cancel') {
|
||||||
|
// 用户点击了"否"按钮
|
||||||
|
xiangXuIsShow.value = false;
|
||||||
|
} else {
|
||||||
|
// 用户点击了关闭按钮或按了ESC键,中断流程
|
||||||
|
return; // 直接返回,不继续执行后续代码
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (channelPairingRef.value) {
|
if (channelPairingRef.value) {
|
||||||
const res = await channelPairingRef.value.handleNext()
|
const res = await channelPairingRef.value.handleNext()
|
||||||
|
|
||||||
@@ -391,7 +415,8 @@ const handleSubmitFast = async () => {
|
|||||||
pairs: pairs.value,
|
pairs: pairs.value,
|
||||||
testItemList: [checkStore.selectTestItems.preTest, false, checkStore.selectTestItems.test],
|
testItemList: [checkStore.selectTestItems.preTest, false, checkStore.selectTestItems.test],
|
||||||
|
|
||||||
userId: userStore.userInfo.id
|
userId: userStore.userInfo.id,
|
||||||
|
phaseCheck: xiangXuIsShow.value ? 1 : 0,
|
||||||
})
|
})
|
||||||
preTestStatus.value = 'start'
|
preTestStatus.value = 'start'
|
||||||
if (checkStore.selectTestItems.test) {
|
if (checkStore.selectTestItems.test) {
|
||||||
@@ -415,7 +440,8 @@ const handleSubmitFast = async () => {
|
|||||||
pairs: pairs.value,
|
pairs: pairs.value,
|
||||||
testItemList: [checkStore.selectTestItems.preTest, false, checkStore.selectTestItems.test],
|
testItemList: [checkStore.selectTestItems.preTest, false, checkStore.selectTestItems.test],
|
||||||
|
|
||||||
userId: userStore.userInfo.id
|
userId: userStore.userInfo.id,
|
||||||
|
phaseCheck: xiangXuIsShow.value ? 1 : 0,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
TestStatus.value = 'start'
|
TestStatus.value = 'start'
|
||||||
@@ -509,8 +535,6 @@ const sendPause = () => {
|
|||||||
pauseTest()
|
pauseTest()
|
||||||
}
|
}
|
||||||
const sendResume = () => {
|
const sendResume = () => {
|
||||||
|
|
||||||
|
|
||||||
resumeTest({
|
resumeTest({
|
||||||
userPageId: JwtUtil.getLoginName(),
|
userPageId: JwtUtil.getLoginName(),
|
||||||
devIds: checkStore.devices.map(item => item.deviceId),
|
devIds: checkStore.devices.map(item => item.deviceId),
|
||||||
|
|||||||
@@ -17,7 +17,11 @@
|
|||||||
<el-table-column prop="dataA" :label="'被检值' + (outerUnit == '' ? '' : '(' + outerUnit + ')')" />
|
<el-table-column prop="dataA" :label="'被检值' + (outerUnit == '' ? '' : '(' + outerUnit + ')')" />
|
||||||
<el-table-column prop="isDataA" label="检测结果">
|
<el-table-column prop="isDataA" label="检测结果">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-tooltip effect="dark" placement="bottom">
|
<template v-if="scope.row.isDataA === 4 || scope.row.isDataA === 5">
|
||||||
|
<el-tag type="warning" v-if="scope.row.isDataA === 4">/</el-tag>
|
||||||
|
<el-tag type="info" v-if="scope.row.isDataA === 5">-</el-tag>
|
||||||
|
</template>
|
||||||
|
<el-tooltip v-else effect="dark" placement="bottom">
|
||||||
<template #content>
|
<template #content>
|
||||||
误差范围:{{ scope.row.maxErrorA }}
|
误差范围:{{ scope.row.maxErrorA }}
|
||||||
<br />
|
<br />
|
||||||
@@ -25,8 +29,6 @@
|
|||||||
</template>
|
</template>
|
||||||
<el-tag type="success" v-if="scope.row.isDataA === 1">符合</el-tag>
|
<el-tag type="success" v-if="scope.row.isDataA === 1">符合</el-tag>
|
||||||
<el-tag type="danger" v-if="scope.row.isDataA === 2">不符合</el-tag>
|
<el-tag type="danger" v-if="scope.row.isDataA === 2">不符合</el-tag>
|
||||||
<el-tag type="warning" v-if="scope.row.isDataA === 4">/</el-tag>
|
|
||||||
<el-tag type="info" v-if="scope.row.isDataA === 5">-</el-tag>
|
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -36,7 +38,11 @@
|
|||||||
<el-table-column prop="dataB" :label="'被检值' + (outerUnit == '' ? '' : '(' + outerUnit + ')')" />
|
<el-table-column prop="dataB" :label="'被检值' + (outerUnit == '' ? '' : '(' + outerUnit + ')')" />
|
||||||
<el-table-column prop="isDataB" label="检测结果">
|
<el-table-column prop="isDataB" label="检测结果">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-tooltip effect="dark" placement="bottom">
|
<template v-if="scope.row.isDataB === 4 || scope.row.isDataB === 5">
|
||||||
|
<el-tag type="warning" v-if="scope.row.isDataB === 4">/</el-tag>
|
||||||
|
<el-tag type="info" v-if="scope.row.isDataA === 5">-</el-tag>
|
||||||
|
</template>
|
||||||
|
<el-tooltip v-else effect="dark" placement="bottom">
|
||||||
<template #content>
|
<template #content>
|
||||||
误差范围:{{ scope.row.maxErrorB }}
|
误差范围:{{ scope.row.maxErrorB }}
|
||||||
<br />
|
<br />
|
||||||
@@ -44,8 +50,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<el-tag type="success" v-if="scope.row.isDataB === 1">符合</el-tag>
|
<el-tag type="success" v-if="scope.row.isDataB === 1">符合</el-tag>
|
||||||
<el-tag type="danger" v-if="scope.row.isDataB === 2">不符合</el-tag>
|
<el-tag type="danger" v-if="scope.row.isDataB === 2">不符合</el-tag>
|
||||||
<el-tag type="warning" v-if="scope.row.isDataB === 4">/</el-tag>
|
|
||||||
<el-tag type="info" v-if="scope.row.isDataA === 5">-</el-tag>
|
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -55,7 +60,11 @@
|
|||||||
<el-table-column prop="dataC" :label="'被检值' + (outerUnit == '' ? '' : '(' + outerUnit + ')')" />
|
<el-table-column prop="dataC" :label="'被检值' + (outerUnit == '' ? '' : '(' + outerUnit + ')')" />
|
||||||
<el-table-column prop="isDataC" label="检测结果">
|
<el-table-column prop="isDataC" label="检测结果">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-tooltip effect="dark" placement="bottom">
|
<template v-if="scope.row.isDataC === 4 || scope.row.isDataC === 5">
|
||||||
|
<el-tag type="warning" v-if="scope.row.isDataC === 4">/</el-tag>
|
||||||
|
<el-tag type="info" v-if="scope.row.isDataA === 5">-</el-tag>
|
||||||
|
</template>
|
||||||
|
<el-tooltip v-else effect="dark" placement="bottom">
|
||||||
<template #content>
|
<template #content>
|
||||||
误差范围: {{ scope.row.maxErrorC }}
|
误差范围: {{ scope.row.maxErrorC }}
|
||||||
<br />
|
<br />
|
||||||
@@ -63,8 +72,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<el-tag type="success" v-if="scope.row.isDataC === 1">符合</el-tag>
|
<el-tag type="success" v-if="scope.row.isDataC === 1">符合</el-tag>
|
||||||
<el-tag type="danger" v-if="scope.row.isDataC === 2">不符合</el-tag>
|
<el-tag type="danger" v-if="scope.row.isDataC === 2">不符合</el-tag>
|
||||||
<el-tag type="warning" v-if="scope.row.isDataC === 4">/</el-tag>
|
|
||||||
<el-tag type="info" v-if="scope.row.isDataA === 5">-</el-tag>
|
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -75,7 +83,11 @@
|
|||||||
<el-table-column prop="dataT" :label="'被检值' + (outerUnit == '' ? '' : '(' + outerUnit + ')')" />
|
<el-table-column prop="dataT" :label="'被检值' + (outerUnit == '' ? '' : '(' + outerUnit + ')')" />
|
||||||
<el-table-column prop="isDataT" label="检测结果">
|
<el-table-column prop="isDataT" label="检测结果">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-tooltip effect="dark" placement="bottom">
|
<template v-if="scope.row.isDataT === 4 || scope.row.isDataT === 5">
|
||||||
|
<el-tag type="warning" v-if="scope.row.isDataT === 4">/</el-tag>
|
||||||
|
<el-tag type="info" v-if="scope.row.isDataA === 5">-</el-tag>
|
||||||
|
</template>
|
||||||
|
<el-tooltip v-else effect="dark" placement="bottom">
|
||||||
<template #content>
|
<template #content>
|
||||||
误差范围: {{ scope.row.maxErrorT }}
|
误差范围: {{ scope.row.maxErrorT }}
|
||||||
<br />
|
<br />
|
||||||
@@ -83,8 +95,6 @@
|
|||||||
</template>
|
</template>
|
||||||
<el-tag type="success" v-if="scope.row.isDataT === 1">符合</el-tag>
|
<el-tag type="success" v-if="scope.row.isDataT === 1">符合</el-tag>
|
||||||
<el-tag type="danger" v-if="scope.row.isDataT === 2">不符合</el-tag>
|
<el-tag type="danger" v-if="scope.row.isDataT === 2">不符合</el-tag>
|
||||||
<el-tag type="warning" v-if="scope.row.isDataT === 4">/</el-tag>
|
|
||||||
<el-tag type="info" v-if="scope.row.isDataA === 5">-</el-tag>
|
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
v-model="formContent.errorSysId"
|
v-model="formContent.errorSysId"
|
||||||
placeholder="请选择误差体系"
|
placeholder="请选择误差体系"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
@change="handleErrorSysChange"
|
@change="handleErrorSysChange('切换误差体系成功')"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="option in pqErrorList"
|
v-for="option in pqErrorList"
|
||||||
@@ -33,7 +33,20 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="数据原则">
|
<el-form-item label="数据原则">
|
||||||
<el-input v-model="formContent.dataRule" :disabled="true" />
|
<!-- <el-input v-model="formContent.dataRule" :disabled="true" />-->
|
||||||
|
<el-select
|
||||||
|
:disabled="checkStore.showDetailType === 2 || checkStore.showDetailType === 0"
|
||||||
|
v-model="formContent.dataRule"
|
||||||
|
placeholder="请选择数据原则"
|
||||||
|
autocomplete="off"
|
||||||
|
@change="handleErrorSysChange('切换数据处理原则成功')">
|
||||||
|
<el-option
|
||||||
|
v-for="item in dictStore.getDictData('Data_Rule')"
|
||||||
|
:key="item.id"
|
||||||
|
:label="item.name"
|
||||||
|
:value="item.id"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="设备名称">
|
<el-form-item label="设备名称">
|
||||||
<el-input v-model="formContent.deviceName" :disabled="true" />
|
<el-input v-model="formContent.deviceName" :disabled="true" />
|
||||||
@@ -203,7 +216,6 @@ const formContent = reactive<CheckData.DataCheck>({
|
|||||||
})
|
})
|
||||||
// 原始误差体系id
|
// 原始误差体系id
|
||||||
let originErrorSysId: string = ''
|
let originErrorSysId: string = ''
|
||||||
let planCode: string = ''
|
|
||||||
// 谐波次数列表
|
// 谐波次数列表
|
||||||
// const harmNumList = reactive<{ value: string, label: string }[]>([])
|
// const harmNumList = reactive<{ value: string, label: string }[]>([])
|
||||||
// 当前选中的检测项
|
// 当前选中的检测项
|
||||||
@@ -273,7 +285,7 @@ const handleNodeClick = async (data: any) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleErrorSysChange = async () => {
|
const handleErrorSysChange = async (msg:string) => {
|
||||||
|
|
||||||
changeErrorSystem({
|
changeErrorSystem({
|
||||||
planId: checkStore.plan.id,
|
planId: checkStore.plan.id,
|
||||||
@@ -281,15 +293,11 @@ const handleErrorSysChange = async () => {
|
|||||||
errorSysId: formContent.errorSysId,
|
errorSysId: formContent.errorSysId,
|
||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
code: checkStore.plan.code + '',
|
code: checkStore.plan.code + '',
|
||||||
patternId: dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? ''
|
patternId: dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? '',
|
||||||
|
dataRuleId: formContent.dataRule
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.code === ResultEnum.SUCCESS) {
|
if (res.code === ResultEnum.SUCCESS) {
|
||||||
ElMessage.success('切换误差体系成功')
|
ElMessage.success(msg)
|
||||||
if (originErrorSysId != formContent.errorSysId) {
|
|
||||||
planCode = checkStore.plan.code + '_temp'
|
|
||||||
} else {
|
|
||||||
planCode = checkStore.plan.code + ''
|
|
||||||
}
|
|
||||||
if (formContent.chnNum != chnList[0].value) {
|
if (formContent.chnNum != chnList[0].value) {
|
||||||
formContent.chnNum = chnList[0].value
|
formContent.chnNum = chnList[0].value
|
||||||
} else {
|
} else {
|
||||||
@@ -317,7 +325,7 @@ const handleChnNumChange = async () => {
|
|||||||
devId: deviceId,
|
devId: deviceId,
|
||||||
devNum: formContent.chnNum + '',
|
devNum: formContent.chnNum + '',
|
||||||
scriptType: originScriptType,
|
scriptType: originScriptType,
|
||||||
code: planCode
|
code: checkStore.plan.code + (formContent.errorSysId!=checkStore.plan.errorSysId || formContent.dataRule!=checkStore.plan.dataRule? '_temp':'')
|
||||||
})
|
})
|
||||||
updateTreeFly(resTreeDataTemp, 4)
|
updateTreeFly(resTreeDataTemp, 4)
|
||||||
updateTreeFly(resTreeDataTemp, 2)
|
updateTreeFly(resTreeDataTemp, 2)
|
||||||
@@ -379,7 +387,7 @@ const updateTableData = async () => {
|
|||||||
scriptId: checkStore.plan.scriptId,
|
scriptId: checkStore.plan.scriptId,
|
||||||
devId: deviceId,
|
devId: deviceId,
|
||||||
devNum: formContent.chnNum + '',
|
devNum: formContent.chnNum + '',
|
||||||
code: planCode,
|
code: checkStore.plan.code + (formContent.errorSysId!=checkStore.plan.errorSysId || formContent.dataRule!=checkStore.plan.dataRule? '_temp':''),
|
||||||
index: parseInt(checkIndex.value)
|
index: parseInt(checkIndex.value)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -473,7 +481,6 @@ const doCurrentCheckItemUpdate = (newVal: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const open = async (_deviceId: string, chnNum: string, _scriptType: string | null) => {
|
const open = async (_deviceId: string, chnNum: string, _scriptType: string | null) => {
|
||||||
planCode = checkStore.plan.code + ''
|
|
||||||
deviceId = _deviceId
|
deviceId = _deviceId
|
||||||
originScriptType = _scriptType
|
originScriptType = _scriptType
|
||||||
scriptType = _scriptType
|
scriptType = _scriptType
|
||||||
@@ -510,7 +517,7 @@ const handleGenerateReport = async () => {
|
|||||||
planId: checkStore.plan.id,
|
planId: checkStore.plan.id,
|
||||||
devIdList: [deviceId],
|
devIdList: [deviceId],
|
||||||
scriptId: checkStore.plan.scriptId,
|
scriptId: checkStore.plan.scriptId,
|
||||||
planCode: planCode
|
planCode: checkStore.plan.code + (formContent.errorSysId!=checkStore.plan.errorSysId || formContent.dataRule!=checkStore.plan.dataRule? '_temp':'')
|
||||||
})
|
})
|
||||||
ElMessage.success({ message: `报告生成成功!` })
|
ElMessage.success({ message: `报告生成成功!` })
|
||||||
}
|
}
|
||||||
@@ -522,14 +529,10 @@ const handleReCalculate = async () => {
|
|||||||
errorSysId: formContent.errorSysId,
|
errorSysId: formContent.errorSysId,
|
||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
code: checkStore.plan.code + '',
|
code: checkStore.plan.code + '',
|
||||||
patternId: dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? ''
|
patternId: dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? '',
|
||||||
|
dataRuleId: formContent.dataRule
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
ElMessage.success('重新计算成功!')
|
ElMessage.success('重新计算成功!')
|
||||||
// if (originErrorSysId != formContent.errorSysId) {
|
|
||||||
// planCode = checkStore.plan.code + "_temp"
|
|
||||||
// } else {
|
|
||||||
// planCode = checkStore.plan.code + ''
|
|
||||||
// }
|
|
||||||
if (formContent.chnNum != chnList[0].value) {
|
if (formContent.chnNum != chnList[0].value) {
|
||||||
formContent.chnNum = chnList[0].value
|
formContent.chnNum = chnList[0].value
|
||||||
} else {
|
} else {
|
||||||
@@ -560,7 +563,6 @@ const close = async () => {
|
|||||||
currentScriptTypeName.value = ''
|
currentScriptTypeName.value = ''
|
||||||
currentDesc.value = ''
|
currentDesc.value = ''
|
||||||
pqErrorList.length = 0
|
pqErrorList.length = 0
|
||||||
planCode = ''
|
|
||||||
|
|
||||||
visible.value = false
|
visible.value = false
|
||||||
|
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ const planIdKey = ref<string>('')
|
|||||||
const deviceMonitor = ref<Map<string, any[]>>();
|
const deviceMonitor = ref<Map<string, any[]>>();
|
||||||
const planIsOnlyWave = ref(false)
|
const planIsOnlyWave = ref(false)
|
||||||
const open = async (
|
const open = async (
|
||||||
|
title: string,
|
||||||
device: Device.ResPqDev[],
|
device: Device.ResPqDev[],
|
||||||
standardDev: StandardDevice.ResPqStandardDevice[],
|
standardDev: StandardDevice.ResPqStandardDevice[],
|
||||||
fatherPlanId: string,
|
fatherPlanId: string,
|
||||||
@@ -223,6 +223,7 @@ const open = async (
|
|||||||
checkType: string,
|
checkType: string,
|
||||||
isOnlyWave:boolean
|
isOnlyWave:boolean
|
||||||
) => {
|
) => {
|
||||||
|
dialogTitle.value = title
|
||||||
planIsOnlyWave.value = isOnlyWave
|
planIsOnlyWave.value = isOnlyWave
|
||||||
CompareTestVisible.value = false
|
CompareTestVisible.value = false
|
||||||
devIdList.value = device
|
devIdList.value = device
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ const open = async (mapping : Record<string, Record<string, string>>,data : any)
|
|||||||
|
|
||||||
// 导出数据
|
// 导出数据
|
||||||
const exportData =async () => {
|
const exportData =async () => {
|
||||||
useDownload(exportAlignData, '原始数据', null, false, '.xlsx')
|
useDownload(exportAlignData, '对齐数据', null, false, '.xlsx')
|
||||||
ElMessage.success('数据导出成功');
|
ElMessage.success('数据导出成功');
|
||||||
// 这里可以添加实际的数据导出逻辑
|
// 这里可以添加实际的数据导出逻辑
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -650,7 +650,7 @@ function tableHeaderInit(val: number) {
|
|||||||
break
|
break
|
||||||
case 3: // 报告生成模式
|
case 3: // 报告生成模式
|
||||||
if (modeStore.currentMode === '比对式') {
|
if (modeStore.currentMode === '比对式') {
|
||||||
checkStateTable.value = [1, 2, 3] // 显示检测中,检测完成和归档状态
|
checkStateTable.value = [2, 3] // 显示检测中,检测完成和归档状态
|
||||||
} else {
|
} else {
|
||||||
checkStateTable.value = [2, 3] // 显示检测完成和归档状态
|
checkStateTable.value = [2, 3] // 显示检测完成和归档状态
|
||||||
}
|
}
|
||||||
@@ -845,8 +845,9 @@ const handleTest2 = async (val: string) => {
|
|||||||
|
|
||||||
// 检查数组长度是否为1且唯一元素是'wave_data'
|
// 检查数组长度是否为1且唯一元素是'wave_data'
|
||||||
const isOnlyWave = targetPlan.datasourceIds.length === 1 && targetPlan.datasourceIds[0] === 'wave_data'
|
const isOnlyWave = targetPlan.datasourceIds.length === 1 && targetPlan.datasourceIds[0] === 'wave_data'
|
||||||
|
dialogTitle.value = val
|
||||||
deviceConnectionPopupRef.value?.open(
|
deviceConnectionPopupRef.value?.open(
|
||||||
|
dialogTitle.value,
|
||||||
filteredChannelsSelection,
|
filteredChannelsSelection,
|
||||||
pqStandardDevList.value,
|
pqStandardDevList.value,
|
||||||
props.id,
|
props.id,
|
||||||
@@ -1018,9 +1019,7 @@ const handleTest = async (val: string) => {
|
|||||||
planId: checkStore.plan.id,
|
planId: checkStore.plan.id,
|
||||||
devIdList: devIdList,
|
devIdList: devIdList,
|
||||||
scriptId: checkStore.plan.scriptId,
|
scriptId: checkStore.plan.scriptId,
|
||||||
planCode: checkStore.plan.code + '',
|
planCode: checkStore.plan.code + ''
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 999
|
|
||||||
})
|
})
|
||||||
emit('batchGenerateClicked') // 触发事件
|
emit('batchGenerateClicked') // 触发事件
|
||||||
ElMessage.success({ message: `报告生成成功!` })
|
ElMessage.success({ message: `报告生成成功!` })
|
||||||
@@ -1060,9 +1059,7 @@ const openDrawer = async (title: string, row: any) => {
|
|||||||
planId: checkStore.plan.id,
|
planId: checkStore.plan.id,
|
||||||
devIdList: [row.id],
|
devIdList: [row.id],
|
||||||
scriptId: checkStore.plan.scriptId,
|
scriptId: checkStore.plan.scriptId,
|
||||||
planCode: checkStore.plan.code + '',
|
planCode: checkStore.plan.code + ''
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 999
|
|
||||||
})
|
})
|
||||||
emit('batchGenerateClicked') // 触发事件
|
emit('batchGenerateClicked') // 触发事件
|
||||||
ElMessage.success({ message: `报告生成成功!` })
|
ElMessage.success({ message: `报告生成成功!` })
|
||||||
|
|||||||
@@ -706,9 +706,7 @@ const updatePercentage = async () => {
|
|||||||
'planId': checkStore.plan.id,
|
'planId': checkStore.plan.id,
|
||||||
'devIdList': devIdList,
|
'devIdList': devIdList,
|
||||||
'scriptId': checkStore.plan.scriptId,
|
'scriptId': checkStore.plan.scriptId,
|
||||||
'planCode': checkStore.plan.code + '',
|
'planCode': checkStore.plan.code + ''
|
||||||
'pageNum': 1,
|
|
||||||
'pageSize': 999,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 提示检测完成
|
// 提示检测完成
|
||||||
|
|||||||
@@ -18,13 +18,15 @@
|
|||||||
<img :src="item.img" />
|
<img :src="item.img" />
|
||||||
</div>
|
</div>
|
||||||
<div class="test_button">
|
<div class="test_button">
|
||||||
<el-button size="large" type="primary" @click="handelOpen(item)" :disabled="!item.activated">
|
<el-button size="large" type="primary" @click="handelOpen(item)">
|
||||||
进入检测
|
{{ item.activated ? '进入检测' : '待激活' }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-carousel-item>
|
</el-carousel-item>
|
||||||
</el-carousel>
|
</el-carousel>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- versionRegisterDialog -->
|
||||||
|
<VersionDialog ref="versionRegisterRef"></VersionDialog>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useAuthStore } from '@/stores/modules/auth'
|
import { useAuthStore } from '@/stores/modules/auth'
|
||||||
@@ -32,6 +34,8 @@ import { useAppSceneStore, useModeStore } from '@/stores/modules/mode' // 引入
|
|||||||
import { getCurrentScene } from '@/api/user/login'
|
import { getCurrentScene } from '@/api/user/login'
|
||||||
import { initDynamicRouter } from '@/routers/modules/dynamicRouter'
|
import { initDynamicRouter } from '@/routers/modules/dynamicRouter'
|
||||||
import { useTabsStore } from '@/stores/modules/tabs'
|
import { useTabsStore } from '@/stores/modules/tabs'
|
||||||
|
import VersionDialog from '@/views/system/versionRegister/index.vue'
|
||||||
|
import { ref, onMounted } from 'vue'
|
||||||
|
|
||||||
const authStore = useAuthStore()
|
const authStore = useAuthStore()
|
||||||
const modeStore = useModeStore() // 使用模式 store
|
const modeStore = useModeStore() // 使用模式 store
|
||||||
@@ -39,6 +43,7 @@ const AppSceneStore = useAppSceneStore()
|
|||||||
const activateInfo = authStore.activateInfo
|
const activateInfo = authStore.activateInfo
|
||||||
const isActivateOpen = import.meta.env.VITE_ACTIVATE_OPEN
|
const isActivateOpen = import.meta.env.VITE_ACTIVATE_OPEN
|
||||||
const tabsStore = useTabsStore()
|
const tabsStore = useTabsStore()
|
||||||
|
const versionRegisterRef = ref<InstanceType<typeof VersionDialog> | null>(null)
|
||||||
const modeList = [
|
const modeList = [
|
||||||
{
|
{
|
||||||
name: '模拟式模块',
|
name: '模拟式模块',
|
||||||
@@ -64,7 +69,8 @@ const modeList = [
|
|||||||
]
|
]
|
||||||
const handelOpen = async (item: any) => {
|
const handelOpen = async (item: any) => {
|
||||||
if (!item.activated) {
|
if (!item.activated) {
|
||||||
ElMessage.warning(`${item.name}未激活`)
|
// 打开版本激活弹窗
|
||||||
|
versionRegisterRef.value?.openDialog()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
modeStore.setCurrentMode(item.code) // 将模式code存入 store
|
modeStore.setCurrentMode(item.code) // 将模式code存入 store
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item prop="checked">
|
<el-form-item prop="checked" v-show="false">
|
||||||
<el-checkbox v-model="loginForm.checked">记住我</el-checkbox>
|
<el-checkbox v-model="loginForm.checked">记住我</el-checkbox>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
<el-input
|
<el-input
|
||||||
v-model="formContent.name"
|
v-model="formContent.name"
|
||||||
placeholder="请输入设备名称"
|
placeholder="请输入设备名称"
|
||||||
:disabled="scene === '1' || formContent.importFlag == 1"
|
:disabled="scene === '1'"
|
||||||
maxlength="32"
|
maxlength="32"
|
||||||
show-word-limit
|
show-word-limit
|
||||||
/>
|
/>
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
clearable
|
clearable
|
||||||
placeholder="请选择设备类型"
|
placeholder="请选择设备类型"
|
||||||
@change="handleDevTypeChange"
|
@change="handleDevTypeChange"
|
||||||
:disabled="formContent.importFlag == 1"
|
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in devTypeOptions"
|
v-for="item in devTypeOptions"
|
||||||
@@ -63,7 +63,7 @@
|
|||||||
v-model="formContent.manufacturer"
|
v-model="formContent.manufacturer"
|
||||||
clearable
|
clearable
|
||||||
placeholder="请选择设备厂家"
|
placeholder="请选择设备厂家"
|
||||||
:disabled="formContent.importFlag == 1"
|
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in dictStore.getDictData('Dev_Manufacturers')"
|
v-for="item in dictStore.getDictData('Dev_Manufacturers')"
|
||||||
@@ -78,7 +78,7 @@
|
|||||||
v-model="formContent.createDate"
|
v-model="formContent.createDate"
|
||||||
:placeholder="`请选择${createDateTitle}`"
|
:placeholder="`请选择${createDateTitle}`"
|
||||||
:disabled-date="disabledDate"
|
:disabled-date="disabledDate"
|
||||||
:disabled="formContent.importFlag == 1"
|
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="固件版本" prop="hardwareVersion" v-if="scene === '0'">
|
<el-form-item label="固件版本" prop="hardwareVersion" v-if="scene === '0'">
|
||||||
@@ -92,7 +92,7 @@
|
|||||||
v-model="formContent.inspectDate"
|
v-model="formContent.inspectDate"
|
||||||
placeholder="请选择定检日期"
|
placeholder="请选择定检日期"
|
||||||
:disabled-date="disabledDate"
|
:disabled-date="disabledDate"
|
||||||
:disabled="formContent.importFlag == 1"
|
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-divider>参数信息</el-divider>
|
<el-divider>参数信息</el-divider>
|
||||||
@@ -128,7 +128,7 @@
|
|||||||
v-model="formContent.protocol"
|
v-model="formContent.protocol"
|
||||||
clearable
|
clearable
|
||||||
placeholder="请选择通讯协议"
|
placeholder="请选择通讯协议"
|
||||||
:disabled="formContent.importFlag == 1"
|
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in dictStore.getDictData('Protocol')"
|
v-for="item in dictStore.getDictData('Protocol')"
|
||||||
@@ -139,17 +139,17 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="IP地址" prop="ip" placeholder="请输入IP地址">
|
<el-form-item label="IP地址" prop="ip" placeholder="请输入IP地址">
|
||||||
<el-input v-model="formContent.ip" :disabled="formContent.importFlag == 1" />
|
<el-input v-model="formContent.ip" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="端口号" prop="port" placeholder="请输入端口号">
|
<el-form-item label="端口号" prop="port" placeholder="请输入端口号">
|
||||||
<el-input v-model="formContent.port" :disabled="formContent.importFlag == 1" />
|
<el-input v-model="formContent.port" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="是否加密" prop="encryptionFlag">
|
<el-form-item label="是否加密" prop="encryptionFlag">
|
||||||
<el-select
|
<el-select
|
||||||
v-model="formContent.encryptionFlag"
|
v-model="formContent.encryptionFlag"
|
||||||
clearable
|
clearable
|
||||||
placeholder="请选择是否加密"
|
placeholder="请选择是否加密"
|
||||||
:disabled="formContent.importFlag == 1"
|
|
||||||
>
|
>
|
||||||
<el-option label="是" :value="1"></el-option>
|
<el-option label="是" :value="1"></el-option>
|
||||||
<el-option label="否" :value="0"></el-option>
|
<el-option label="否" :value="0"></el-option>
|
||||||
@@ -160,7 +160,7 @@
|
|||||||
v-model="formContent.series"
|
v-model="formContent.series"
|
||||||
placeholder="请输入识别码"
|
placeholder="请输入识别码"
|
||||||
show-password
|
show-password
|
||||||
:disabled="formContent.importFlag == 1"
|
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="密钥" prop="devKey" clearable v-if="formContent.encryptionFlag">
|
<el-form-item label="密钥" prop="devKey" clearable v-if="formContent.encryptionFlag">
|
||||||
@@ -168,7 +168,7 @@
|
|||||||
v-model="formContent.devKey"
|
v-model="formContent.devKey"
|
||||||
placeholder="请输入密钥"
|
placeholder="请输入密钥"
|
||||||
show-password
|
show-password
|
||||||
:disabled="formContent.importFlag == 1"
|
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="样品编号" prop="sampleId" clearable v-if="DevIsShow && scene === '0'">
|
<el-form-item label="样品编号" prop="sampleId" clearable v-if="DevIsShow && scene === '0'">
|
||||||
@@ -196,7 +196,7 @@
|
|||||||
v-model="formContent.cityName"
|
v-model="formContent.cityName"
|
||||||
clearable
|
clearable
|
||||||
placeholder="请输入所属地市"
|
placeholder="请输入所属地市"
|
||||||
:disabled="formContent.importFlag == 1"
|
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="所属供电公司" prop="gdName" v-if="MonIsShow">
|
<el-form-item label="所属供电公司" prop="gdName" v-if="MonIsShow">
|
||||||
@@ -204,7 +204,7 @@
|
|||||||
v-model="formContent.gdName"
|
v-model="formContent.gdName"
|
||||||
clearable
|
clearable
|
||||||
placeholder="请输入所属供电公司"
|
placeholder="请输入所属供电公司"
|
||||||
:disabled="formContent.importFlag == 1"
|
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="所属电站" prop="subName" v-if="MonIsShow">
|
<el-form-item label="所属电站" prop="subName" v-if="MonIsShow">
|
||||||
@@ -212,7 +212,7 @@
|
|||||||
v-model="formContent.subName"
|
v-model="formContent.subName"
|
||||||
clearable
|
clearable
|
||||||
placeholder="请输入所属电站"
|
placeholder="请输入所属电站"
|
||||||
:disabled="formContent.importFlag == 1"
|
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item
|
||||||
@@ -232,7 +232,7 @@
|
|||||||
prop="harmSysId"
|
prop="harmSysId"
|
||||||
placeholder="请输入谐波系统设备id"
|
placeholder="请输入谐波系统设备id"
|
||||||
>
|
>
|
||||||
<el-input v-model="formContent.harmSysId" :disabled="formContent.importFlag == 1" />
|
<el-input v-model="formContent.harmSysId" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -11,17 +11,17 @@
|
|||||||
<div>
|
<div>
|
||||||
<el-form :model="formContent" ref="dialogFormRef" :rules="rules" label-width="140" class="form-two">
|
<el-form :model="formContent" ref="dialogFormRef" :rules="rules" label-width="140" class="form-two">
|
||||||
<el-form-item label="名称" prop="name">
|
<el-form-item label="名称" prop="name">
|
||||||
<el-input clearable v-model="formContent.name" placeholder="请输入监测点名称" :disabled="props.DevFormContent.importFlag == 1 || formContent.resultType!=null"/>
|
<el-input clearable v-model="formContent.name" placeholder="请输入监测点名称" :disabled=" formContent.resultType!=null"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="线路号" prop="num">
|
<el-form-item label="线路号" prop="num">
|
||||||
<el-select v-model="formContent.num" placeholder="请选择线路号" @change="handleMonNumChange" :disabled="props.DevFormContent.importFlag == 1 || formContent.resultType!=null">
|
<el-select v-model="formContent.num" placeholder="请选择线路号" @change="handleMonNumChange" :disabled=" formContent.resultType!=null">
|
||||||
<el-option v-for="item in lineNum" :key="item.id" :label="item.name" :value="item.id" />
|
<el-option v-for="item in lineNum" :key="item.id" :label="item.name" :value="item.id" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="所属母线" prop="busbar">
|
<el-form-item label="母线名称" prop="busbar">
|
||||||
<el-input v-model="formContent.busbar" clearable placeholder="请输入所属母线" :disabled="props.DevFormContent.importFlag == 1 || formContent.resultType!=null"/>
|
<el-input v-model="formContent.busbar" clearable placeholder="请输入所属母线" :disabled=" formContent.resultType!=null"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<!-- <el-form-item label="所属母线" prop="busbar">
|
<!-- <el-form-item label="母线名称" prop="busbar">
|
||||||
<el-select
|
<el-select
|
||||||
v-model="formContent.busbar"
|
v-model="formContent.busbar"
|
||||||
clearable
|
clearable
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item> -->
|
</el-form-item> -->
|
||||||
<el-form-item label="接线方式" prop="connection">
|
<el-form-item label="接线方式" prop="connection">
|
||||||
<el-select v-model="formContent.connection" clearable placeholder="请选择接线方式" :disabled="props.DevFormContent.importFlag == 1 || formContent.resultType!=null">
|
<el-select v-model="formContent.connection" clearable placeholder="请选择接线方式" :disabled=" formContent.resultType!=null">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in dictStore.getDictData('Dev_Connect')"
|
v-for="item in dictStore.getDictData('Dev_Connect')"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
@@ -56,11 +56,11 @@
|
|||||||
</template>
|
</template>
|
||||||
<div class="ratio-input-group">
|
<div class="ratio-input-group">
|
||||||
<el-form-item prop="ptPrimary" class="ratio-form-item">
|
<el-form-item prop="ptPrimary" class="ratio-form-item">
|
||||||
<el-input v-model="ptPrimary" placeholder="一次侧" @input="handlePtInput" :disabled="props.DevFormContent.importFlag == 1 || formContent.resultType!=null"/>
|
<el-input v-model="ptPrimary" placeholder="一次侧" @input="handlePtInput" :disabled=" formContent.resultType!=null"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<div class="colon">:</div>
|
<div class="colon">:</div>
|
||||||
<el-form-item prop="ptSecondary" style="margin-left: 10px" class="ratio-form-item">
|
<el-form-item prop="ptSecondary" style="margin-left: 10px" class="ratio-form-item">
|
||||||
<el-input v-model="ptSecondary" placeholder="二次侧" @input="handlePtInput" :disabled="props.DevFormContent.importFlag == 1 || formContent.resultType!=null"/>
|
<el-input v-model="ptSecondary" placeholder="二次侧" @input="handlePtInput" :disabled=" formContent.resultType!=null"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -75,17 +75,17 @@
|
|||||||
</template>
|
</template>
|
||||||
<div class="ratio-input-group">
|
<div class="ratio-input-group">
|
||||||
<el-form-item prop="ctPrimary" class="ratio-form-item">
|
<el-form-item prop="ctPrimary" class="ratio-form-item">
|
||||||
<el-input v-model="ctPrimary" placeholder="一次侧" @input="handleCtInput" :disabled="props.DevFormContent.importFlag == 1 || formContent.resultType!=null"/>
|
<el-input v-model="ctPrimary" placeholder="一次侧" @input="handleCtInput" :disabled=" formContent.resultType!=null"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<div class="colon">:</div>
|
<div class="colon">:</div>
|
||||||
<el-form-item prop="ctSecondary" style="margin-left: 10px" class="ratio-form-item">
|
<el-form-item prop="ctSecondary" style="margin-left: 10px" class="ratio-form-item">
|
||||||
<el-input v-model="ctSecondary" placeholder="二次侧" @input="handleCtInput" :disabled="props.DevFormContent.importFlag == 1 || formContent.resultType!=null"/>
|
<el-input v-model="ctSecondary" placeholder="二次侧" @input="handleCtInput" :disabled=" formContent.resultType!=null"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="统计间隔" prop="statInterval">
|
<el-form-item label="统计间隔" prop="statInterval">
|
||||||
<el-select v-model="formContent.statInterval" clearable placeholder="请选择统计间隔" :disabled="props.DevFormContent.importFlag == 1 || formContent.resultType!=null">
|
<el-select v-model="formContent.statInterval" clearable placeholder="请选择统计间隔" :disabled=" formContent.resultType!=null">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in dictStore.getDictData('Dev_Chns')"
|
v-for="item in dictStore.getDictData('Dev_Chns')"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
@@ -95,7 +95,7 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="谐波系统检测点id" prop="harmSysId" placeholder="请输入谐波系统检测点id">
|
<el-form-item label="谐波系统检测点id" prop="harmSysId" placeholder="请输入谐波系统检测点id">
|
||||||
<el-input v-model="formContent.harmSysId" :disabled="props.DevFormContent.importFlag == 1 || formContent.resultType!=null"/>
|
<el-input v-model="formContent.harmSysId" :disabled=" formContent.resultType!=null"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="是否参与检测" prop="checkFlag" placeholder="请输入CT编号">
|
<el-form-item label="是否参与检测" prop="checkFlag" placeholder="请输入CT编号">
|
||||||
<el-select v-model="formContent.checkFlag" :disabled="formContent.resultType!=null">
|
<el-select v-model="formContent.checkFlag" :disabled="formContent.resultType!=null">
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ const columns = reactive<ColumnProps<Monitor.ResPqMon>[]>([
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'busbar',
|
prop: 'busbar',
|
||||||
label: '所属母线',
|
label: '母线名称',
|
||||||
width: 200
|
width: 200
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,6 +14,23 @@
|
|||||||
show-word-limit
|
show-word-limit
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="映射文件" prop="mappingFile">
|
||||||
|
<el-upload
|
||||||
|
action="#"
|
||||||
|
:limit="1"
|
||||||
|
:on-change='MappingHandleChange'
|
||||||
|
:auto-upload="false"
|
||||||
|
:file-list="mappingFileList"
|
||||||
|
:on-exceed="MappingHandleExceed"
|
||||||
|
:on-remove="MappingHandleRemove"
|
||||||
|
style="width: 100% !important;"
|
||||||
|
accept=".txt"
|
||||||
|
class="upload-container"
|
||||||
|
>
|
||||||
|
<el-button type="primary">选择文件</el-button>
|
||||||
|
</el-upload>
|
||||||
|
仅支持上传大小不超过1MB的.txt文件
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="是否支持电压相角、电流相角指标" prop="angle" label-width="auto">
|
<el-form-item label="是否支持电压相角、电流相角指标" prop="angle" label-width="auto">
|
||||||
<el-switch
|
<el-switch
|
||||||
v-model="formContent.angle"
|
v-model="formContent.angle"
|
||||||
@@ -46,7 +63,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ElMessage, type FormInstance, type FormItemRule } from 'element-plus'
|
import { ElMessage, UploadFile, type FormInstance, type FormItemRule } from 'element-plus'
|
||||||
import { computed, ref, Ref } from 'vue'
|
import { computed, ref, Ref } from 'vue'
|
||||||
import { type ICD } from '@/api/device/interface/icd'
|
import { type ICD } from '@/api/device/interface/icd'
|
||||||
import { dialogSmall } from '@/utils/elementBind'
|
import { dialogSmall } from '@/utils/elementBind'
|
||||||
@@ -56,6 +73,17 @@ import { addICD, updateICD } from '@/api/device/icd'
|
|||||||
const dictStore = useDictStore()
|
const dictStore = useDictStore()
|
||||||
// 定义弹出组件元信息
|
// 定义弹出组件元信息
|
||||||
const dialogFormRef = ref()
|
const dialogFormRef = ref()
|
||||||
|
const mappingFileName = ref('')
|
||||||
|
const mappingFileUrl = ref('')
|
||||||
|
let excelFormData = new FormData()
|
||||||
|
|
||||||
|
|
||||||
|
const mappingFileList = computed(() => {
|
||||||
|
if (mappingFileName.value && mappingFileUrl.value) {
|
||||||
|
return [{name: mappingFileName.value, url: mappingFileUrl.value}];
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
});
|
||||||
function useMetaInfo() {
|
function useMetaInfo() {
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
const titleType = ref('add')
|
const titleType = ref('add')
|
||||||
@@ -65,7 +93,8 @@ function useMetaInfo() {
|
|||||||
path: '',
|
path: '',
|
||||||
state: 1,
|
state: 1,
|
||||||
angle: 0,
|
angle: 0,
|
||||||
usePhaseIndex: 0
|
usePhaseIndex: 0,
|
||||||
|
mappingFile: ''
|
||||||
})
|
})
|
||||||
return { dialogVisible, titleType, formContent }
|
return { dialogVisible, titleType, formContent }
|
||||||
}
|
}
|
||||||
@@ -80,7 +109,8 @@ const resetFormContent = () => {
|
|||||||
path: '',
|
path: '',
|
||||||
state: 1,
|
state: 1,
|
||||||
angle: 0,
|
angle: 0,
|
||||||
usePhaseIndex: 0
|
usePhaseIndex: 0,
|
||||||
|
mappingFile: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,11 +123,13 @@ const formRuleRef = ref<FormInstance>()
|
|||||||
//定义校验规则
|
//定义校验规则
|
||||||
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
|
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
|
||||||
name: [{ required: true, message: 'icd名称必填!', trigger: 'blur' }],
|
name: [{ required: true, message: 'icd名称必填!', trigger: 'blur' }],
|
||||||
path: [{ required: true, message: 'icd存储地址必填!', trigger: 'blur' }]
|
path: [{ required: true, message: 'icd存储地址必填!', trigger: 'blur' }],
|
||||||
|
mappingFile: [{required: true, message: '请上传映射文件', trigger: 'change'}],
|
||||||
})
|
})
|
||||||
|
|
||||||
// 关闭弹窗
|
// 关闭弹窗
|
||||||
const close = () => {
|
const close = () => {
|
||||||
|
excelFormData = new FormData()
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
// 清空dialogForm中的值
|
// 清空dialogForm中的值
|
||||||
resetFormContent()
|
resetFormContent()
|
||||||
@@ -110,10 +142,27 @@ const save = () => {
|
|||||||
try {
|
try {
|
||||||
dialogFormRef.value?.validate(async (valid: boolean) => {
|
dialogFormRef.value?.validate(async (valid: boolean) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
// 清空 excelFormData
|
||||||
|
excelFormData.delete('name')
|
||||||
|
excelFormData.delete('path')
|
||||||
|
excelFormData.delete('angle')
|
||||||
|
excelFormData.delete('usePhaseIndex')
|
||||||
|
|
||||||
|
excelFormData.append('name', formContent.value.name)
|
||||||
|
excelFormData.append('path', formContent.value.path)
|
||||||
|
excelFormData.append('angle', formContent.value.angle)
|
||||||
|
excelFormData.append('usePhaseIndex', formContent.value.usePhaseIndex)
|
||||||
|
|
||||||
|
let baseFileFlag = handleFileLimit(excelFormData.get('mappingFile') as File)
|
||||||
|
if (!baseFileFlag) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (formContent.value.id) {
|
if (formContent.value.id) {
|
||||||
await updateICD(formContent.value)
|
excelFormData.append('id', formContent.value.id)
|
||||||
|
await updateICD(excelFormData)
|
||||||
} else {
|
} else {
|
||||||
await addICD(formContent.value)
|
await addICD(excelFormData)
|
||||||
}
|
}
|
||||||
ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
||||||
close()
|
close()
|
||||||
@@ -135,11 +184,66 @@ const open = async (sign: string, data: ICD.ResICD) => {
|
|||||||
|
|
||||||
if (data.id) {
|
if (data.id) {
|
||||||
formContent.value = { ...data }
|
formContent.value = { ...data }
|
||||||
|
formContent.value.id = data.id
|
||||||
|
// 文件信息回显
|
||||||
|
if (data.mappingFile) {
|
||||||
|
mappingFileName.value = data.mappingFile.name
|
||||||
|
mappingFileUrl.value = data.mappingFile.url
|
||||||
|
// 模拟文件列表显示
|
||||||
|
formContent.value.mappingFile = data.mappingFile.name
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
mappingFileName.value = ''
|
||||||
|
mappingFileUrl.value = ''
|
||||||
resetFormContent()
|
resetFormContent()
|
||||||
|
// 清空 excelFormData
|
||||||
|
excelFormData = new FormData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MappingHandleChange = async (param: UploadFile) => {
|
||||||
|
mappingFileName.value = param.name;
|
||||||
|
mappingFileUrl.value = URL.createObjectURL(param.raw as Blob);
|
||||||
|
excelFormData.append('mappingFile', param.raw as Blob, param.name);
|
||||||
|
|
||||||
|
formContent.value.mappingFile = param.name;
|
||||||
|
};
|
||||||
|
|
||||||
|
const MappingHandleRemove = () => {
|
||||||
|
excelFormData.delete('mappingFile');
|
||||||
|
formContent.value.mappingFile = ''
|
||||||
|
};
|
||||||
|
|
||||||
|
const MappingHandleExceed = (files: File[]) => {
|
||||||
|
// 移除旧文件
|
||||||
|
excelFormData.delete('mappingFile');
|
||||||
|
// 添加新文件
|
||||||
|
if (files.length > 0) {
|
||||||
|
const newFile = files[0] as unknown as UploadFile;
|
||||||
|
mappingFileName.value = newFile.name;
|
||||||
|
excelFormData.append('mappingFile', newFile as Blob, newFile.name);
|
||||||
|
|
||||||
|
formContent.value.mappingFile = newFile.name
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
const fileSizeLimit = 1 * 1024 * 1024; // 1MB
|
||||||
|
|
||||||
|
const handleFileLimit = (file: File) => {
|
||||||
|
if (file) {
|
||||||
|
if (file.size > fileSizeLimit) {
|
||||||
|
ElMessage.error({message: `文件大小不能超过${fileSizeLimit / 1024 / 1024}MB`});
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// 对外映射
|
// 对外映射
|
||||||
defineExpose({ open })
|
defineExpose({ open })
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
|
|||||||
@@ -69,6 +69,14 @@
|
|||||||
label: '存储地址',
|
label: '存储地址',
|
||||||
|
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
prop: 'mappingFile',
|
||||||
|
label: '映射文件路径',
|
||||||
|
minWidth: 150,
|
||||||
|
render: scope => {
|
||||||
|
return scope.row.mappingFile.url
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
prop: 'createTime',
|
prop: 'createTime',
|
||||||
label: '创建时间',
|
label: '创建时间',
|
||||||
|
|||||||
@@ -84,6 +84,13 @@
|
|||||||
clearable
|
clearable
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item v-if="appSceneStore.currentScene=='1'" label="福禄克专用" prop="fluke">
|
||||||
|
<el-switch
|
||||||
|
v-model="formContent.fluke"
|
||||||
|
active-color="#13ce66"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-card>
|
</el-card>
|
||||||
<el-card v-if="show">
|
<el-card v-if="show">
|
||||||
@@ -102,6 +109,7 @@ import type { CascaderOption } from 'element-plus'
|
|||||||
import { Select, Close, ArrowDownBold, ArrowUpBold } from '@element-plus/icons-vue'
|
import { Select, Close, ArrowDownBold, ArrowUpBold } from '@element-plus/icons-vue'
|
||||||
import { pqScriptAdd, pqScriptUpdate } from '@/api/device/testScript'
|
import { pqScriptAdd, pqScriptUpdate } from '@/api/device/testScript'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
import {useAppSceneStore} from "@/stores/modules/mode";
|
||||||
const modeId = ref()
|
const modeId = ref()
|
||||||
const show = ref(false)
|
const show = ref(false)
|
||||||
const height = ref('125px')
|
const height = ref('125px')
|
||||||
@@ -113,6 +121,8 @@ const secondLevelOptions: any[] = []
|
|||||||
// 定义弹出组件元信息
|
// 定义弹出组件元信息
|
||||||
const dialogFormRef = ref()
|
const dialogFormRef = ref()
|
||||||
const dictStore = useDictStore()
|
const dictStore = useDictStore()
|
||||||
|
const appSceneStore = useAppSceneStore()
|
||||||
|
|
||||||
function useMetaInfo() {
|
function useMetaInfo() {
|
||||||
const titleType = ref('add')
|
const titleType = ref('add')
|
||||||
const formContent = ref<TestScript.ResTestScript>({
|
const formContent = ref<TestScript.ResTestScript>({
|
||||||
@@ -124,7 +134,8 @@ function useMetaInfo() {
|
|||||||
standardTime: '',
|
standardTime: '',
|
||||||
state: 1,
|
state: 1,
|
||||||
ratedCurr: 0,
|
ratedCurr: 0,
|
||||||
ratedVolt: 0
|
ratedVolt: 0,
|
||||||
|
fluke: 0,
|
||||||
})
|
})
|
||||||
return { titleType, formContent }
|
return { titleType, formContent }
|
||||||
}
|
}
|
||||||
@@ -140,7 +151,8 @@ const rules = {
|
|||||||
type: [{ required: true, message: '请选择模版类型', trigger: 'change' }],
|
type: [{ required: true, message: '请选择模版类型', trigger: 'change' }],
|
||||||
valueType: [{ required: true, message: '请选择检测脚本值类型', trigger: 'change' }],
|
valueType: [{ required: true, message: '请选择检测脚本值类型', trigger: 'change' }],
|
||||||
ratedCurr: [{ required: true, message: '请填写额定电流', trigger: 'change' }],
|
ratedCurr: [{ required: true, message: '请填写额定电流', trigger: 'change' }],
|
||||||
ratedVolt: [{ required: true, message: '请填写额定电压', trigger: 'change' }]
|
ratedVolt: [{ required: true, message: '请填写额定电压', trigger: 'change' }],
|
||||||
|
fluke: [{ required: true }],
|
||||||
}
|
}
|
||||||
|
|
||||||
const { titleType, formContent } = useMetaInfo()
|
const { titleType, formContent } = useMetaInfo()
|
||||||
@@ -160,7 +172,8 @@ const resetFormContent = () => {
|
|||||||
standardTime: '',
|
standardTime: '',
|
||||||
state: 1,
|
state: 1,
|
||||||
ratedCurr: 0,
|
ratedCurr: 0,
|
||||||
ratedVolt: 0
|
ratedVolt: 0,
|
||||||
|
fluke: 0,
|
||||||
}
|
}
|
||||||
router.go(-1)
|
router.go(-1)
|
||||||
}
|
}
|
||||||
@@ -190,7 +203,9 @@ const save = () => {
|
|||||||
if (valid) {
|
if (valid) {
|
||||||
if (titleType.value == '新增检测脚本') {
|
if (titleType.value == '新增检测脚本') {
|
||||||
formContent.value.pattern = modeId.value
|
formContent.value.pattern = modeId.value
|
||||||
pqScriptAdd(formContent.value).then(res => {
|
let params = {...formContent.value}
|
||||||
|
params.fluke = params.fluke ? 1 : 0
|
||||||
|
pqScriptAdd(params).then(res => {
|
||||||
if (res.code === 'A0000') {
|
if (res.code === 'A0000') {
|
||||||
ElMessage.success({ message: res.message })
|
ElMessage.success({ message: res.message })
|
||||||
formContent.value.id = res.data
|
formContent.value.id = res.data
|
||||||
@@ -199,7 +214,9 @@ const save = () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
pqScriptUpdate(formContent.value).then(res => {
|
let params = {...formContent.value}
|
||||||
|
params.fluke = params.fluke ? 1 : 0
|
||||||
|
pqScriptUpdate(params).then(res => {
|
||||||
if (res.code === 'A0000') {
|
if (res.code === 'A0000') {
|
||||||
ElMessage.success({ message: res.message })
|
ElMessage.success({ message: res.message })
|
||||||
}
|
}
|
||||||
@@ -224,6 +241,7 @@ const open = async (title: string, row: any) => {
|
|||||||
} else {
|
} else {
|
||||||
let list = JSON.parse(row)
|
let list = JSON.parse(row)
|
||||||
formContent.value = list
|
formContent.value = list
|
||||||
|
formContent.value.fluke = formContent.value.fluke == 1? true : false
|
||||||
show.value = true
|
show.value = true
|
||||||
}
|
}
|
||||||
// 重置表单
|
// 重置表单
|
||||||
|
|||||||
@@ -235,7 +235,7 @@
|
|||||||
</el-icon>
|
</el-icon>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<el-button
|
<el-button
|
||||||
v-if="!data.disabled && !props.disabled"
|
v-if="modeStore.currentMode === '比对式' ? !data.disabled : (!data.disabled && !props.disabled)"
|
||||||
text
|
text
|
||||||
circle
|
circle
|
||||||
@click="removeNode(data)"
|
@click="removeNode(data)"
|
||||||
@@ -252,7 +252,7 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { nextTick, ref, watch } from 'vue'
|
import { computed, nextTick, onMounted, PropType, ref, useSlots, watch } from 'vue'
|
||||||
import type {
|
import type {
|
||||||
FilterNodeMethodFunction,
|
FilterNodeMethodFunction,
|
||||||
RenderContentContext,
|
RenderContentContext,
|
||||||
@@ -261,6 +261,7 @@ import type {
|
|||||||
TreeKey
|
TreeKey
|
||||||
} from 'element-plus'
|
} from 'element-plus'
|
||||||
import { Cpu, Lightning, Location, OfficeBuilding, Warning } from '@element-plus/icons-vue'
|
import { Cpu, Lightning, Location, OfficeBuilding, Warning } from '@element-plus/icons-vue'
|
||||||
|
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
|
||||||
|
|
||||||
interface Tree {
|
interface Tree {
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
@@ -274,6 +275,7 @@ interface Device {
|
|||||||
type Data = RenderContentContext['data']
|
type Data = RenderContentContext['data']
|
||||||
const modelValue = defineModel<string[]>({ default: [] })
|
const modelValue = defineModel<string[]>({ default: [] })
|
||||||
const slots = useSlots()
|
const slots = useSlots()
|
||||||
|
const modeStore = useModeStore()
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
data: {
|
data: {
|
||||||
type: Array as unknown as PropType<Device[]>,
|
type: Array as unknown as PropType<Device[]>,
|
||||||
@@ -298,7 +300,7 @@ const props = defineProps({
|
|||||||
expandAll: {
|
expandAll: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
const leftTreeRef = ref<TreeInstance>()
|
const leftTreeRef = ref<TreeInstance>()
|
||||||
const rightTreeRef = ref<TreeInstance>()
|
const rightTreeRef = ref<TreeInstance>()
|
||||||
@@ -353,6 +355,7 @@ watch(
|
|||||||
)
|
)
|
||||||
|
|
||||||
const initTree = (data: Device[]) => {
|
const initTree = (data: Device[]) => {
|
||||||
|
|
||||||
// 禁用Key数据
|
// 禁用Key数据
|
||||||
disabledKeys.value = data.filter(item => item.disabled).map(item => item.id)
|
disabledKeys.value = data.filter(item => item.disabled).map(item => item.id)
|
||||||
// 编辑逻辑
|
// 编辑逻辑
|
||||||
@@ -360,11 +363,14 @@ const initTree = (data: Device[]) => {
|
|||||||
modelValue.value = []
|
modelValue.value = []
|
||||||
}
|
}
|
||||||
// 左侧树数据
|
// 左侧树数据
|
||||||
leftTreeData.value = convertToTree(data, filter.value.groupBy)
|
leftTreeData.value = convertToTree(data, 0,filter.value.groupBy)
|
||||||
|
|
||||||
// 右侧树数据
|
// 右侧树数据
|
||||||
rightTreeData.value = convertToTree(
|
rightTreeData.value = convertToTree(
|
||||||
data.filter(item => item.checked),
|
data.filter(item => item.checked),
|
||||||
|
1,
|
||||||
filter.value.groupBy
|
filter.value.groupBy
|
||||||
|
|
||||||
)
|
)
|
||||||
defaultCheckedKeys.value = data.filter(item => item.checked).map(item => item.id)
|
defaultCheckedKeys.value = data.filter(item => item.checked).map(item => item.id)
|
||||||
modelValue.value = defaultCheckedKeys.value
|
modelValue.value = defaultCheckedKeys.value
|
||||||
@@ -393,7 +399,7 @@ const setCheckedStatus = (checked: boolean) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const convertToTree = (data: Device[], groupBy?: string | undefined) => {
|
const convertToTree = (data: Device[], type: number,groupBy?: string | undefined) => {
|
||||||
if (groupBy) {
|
if (groupBy) {
|
||||||
// 创建一个映射来存储每个分组
|
// 创建一个映射来存储每个分组
|
||||||
const groupMap = new Map()
|
const groupMap = new Map()
|
||||||
@@ -408,21 +414,57 @@ const convertToTree = (data: Device[], groupBy?: string | undefined) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// 将分组转换为树形结构
|
// 将分组转换为树形结构
|
||||||
const treeData: Tree[] = []
|
const treeData: Tree[] = []
|
||||||
groupMap.forEach((items, groupName) => {
|
|
||||||
const groupNode: Tree = {
|
if(modeStore.currentMode == '比对式'){
|
||||||
id: `${groupBy}_${groupName}`,
|
groupMap.forEach((items, groupName) => {
|
||||||
label: groupName,
|
let groupNode: Tree;
|
||||||
children: (items as any[]).map((item: any) => ({
|
if(type === 0){
|
||||||
...item,
|
// 只有当组内所有项目都禁用时,才将组节点设为禁用
|
||||||
label: item.name,
|
const allItemsDisabled = (items as any[]).every((item: any) => {
|
||||||
children: [],
|
return item.disabled === true ;
|
||||||
disabled: item.disabled ? item.disabled : props.disabled
|
});
|
||||||
})),
|
groupNode = {
|
||||||
disabled: props.disabled
|
id: `${groupBy}_${groupName}`,
|
||||||
}
|
label: groupName,
|
||||||
treeData.push(groupNode)
|
children: (items as any[]).map((item: any) => ({
|
||||||
})
|
...item,
|
||||||
|
label: item.name,
|
||||||
|
children: [],
|
||||||
|
// disabled: item.disabled ? item.disabled : props.disabled
|
||||||
|
})),
|
||||||
|
// disabled: props.disabled
|
||||||
|
disabled: allItemsDisabled
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
groupNode = {
|
||||||
|
id: `${groupBy}_${groupName}`,
|
||||||
|
label: groupName,
|
||||||
|
children: (items as any[]).map((item: any) => ({
|
||||||
|
...item,
|
||||||
|
label: item.name,
|
||||||
|
children: [],
|
||||||
|
})),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
treeData.push(groupNode)
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
groupMap.forEach((items, groupName) => {
|
||||||
|
const groupNode: Tree = {
|
||||||
|
id: `${groupBy}_${groupName}`,
|
||||||
|
label: groupName,
|
||||||
|
children: (items as any[]).map((item: any) => ({
|
||||||
|
...item,
|
||||||
|
label: item.name,
|
||||||
|
children: [],
|
||||||
|
disabled: item.disabled ? item.disabled : props.disabled
|
||||||
|
})),
|
||||||
|
disabled: props.disabled
|
||||||
|
}
|
||||||
|
treeData.push(groupNode)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return treeData
|
return treeData
|
||||||
} else {
|
} else {
|
||||||
@@ -445,14 +487,17 @@ const filterNode: FilterNodeMethodFunction = (value: string, data: Tree) => {
|
|||||||
}
|
}
|
||||||
return data.label.includes(value) || data.cityName.includes(value) || data.manufacturer.includes(value)
|
return data.label.includes(value) || data.cityName.includes(value) || data.manufacturer.includes(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleCommand = (command: string) => {
|
const handleCommand = (command: string) => {
|
||||||
filter.value.groupBy = command
|
filter.value.groupBy = command
|
||||||
const oldCheckedKeys = leftTreeRef.value?.getCheckedKeys() || []
|
const oldCheckedKeys = leftTreeRef.value?.getCheckedKeys() || []
|
||||||
leftTreeData.value = convertToTree(props.data, filter.value.groupBy)
|
leftTreeData.value = convertToTree(props.data,0, filter.value.groupBy)
|
||||||
leftTreeRef.value?.setCheckedKeys(oldCheckedKeys)
|
leftTreeRef.value?.setCheckedKeys(oldCheckedKeys)
|
||||||
rightTreeData.value = convertToTree(
|
rightTreeData.value = convertToTree(
|
||||||
props.data.filter(item => oldCheckedKeys.includes(item.id)),
|
props.data.filter(item => oldCheckedKeys.includes(item.id)),
|
||||||
|
1,
|
||||||
filter.value.groupBy
|
filter.value.groupBy
|
||||||
|
|
||||||
)
|
)
|
||||||
if (filter.value.checkAll) {
|
if (filter.value.checkAll) {
|
||||||
setCheckedStatus(true)
|
setCheckedStatus(true)
|
||||||
@@ -467,10 +512,14 @@ const handleCheckChange = () => {
|
|||||||
.map(key => key.toString())
|
.map(key => key.toString())
|
||||||
rightTreeData.value = convertToTree(
|
rightTreeData.value = convertToTree(
|
||||||
props.data.filter(item => checkedKeys.includes(item.id)),
|
props.data.filter(item => checkedKeys.includes(item.id)),
|
||||||
filter.value.groupBy
|
1,
|
||||||
|
filter.value.groupBy,
|
||||||
|
|
||||||
)
|
)
|
||||||
statistics.value.checked = checkedKeys.length || 0
|
statistics.value.checked = checkedKeys.length || 0
|
||||||
filter.value.checkAll = statistics.value.checked === statistics.value.total
|
filter.value.checkAll = statistics.value.checked === statistics.value.total
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
const clearAll = () => {
|
const clearAll = () => {
|
||||||
if (statistics.value.checked > 0) {
|
if (statistics.value.checked > 0) {
|
||||||
@@ -478,11 +527,44 @@ const clearAll = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const removeNode = (data: Data) => {
|
const removeNode = (data: Data) => {
|
||||||
|
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
leftTreeRef.value?.setChecked(data, false, true)
|
leftTreeRef.value?.setChecked(data, false, true)
|
||||||
rightTreeRef.value?.remove(data)
|
rightTreeRef.value?.remove(data)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取当前右侧树中的设备ID
|
||||||
|
const getSelectedDeviceIds = () => {
|
||||||
|
const extractDeviceIds = (treeData: Tree[]): string[] => {
|
||||||
|
const ids: string[] = [];
|
||||||
|
|
||||||
|
const traverse = (nodes: Tree[]) => {
|
||||||
|
if (!Array.isArray(nodes)) return;
|
||||||
|
|
||||||
|
nodes.forEach(node => {
|
||||||
|
// 如果节点有 children 且不为空,则递归遍历
|
||||||
|
if (node.children && Array.isArray(node.children) && node.children.length > 0) {
|
||||||
|
traverse(node.children);
|
||||||
|
} else {
|
||||||
|
// 只有叶子节点(设备节点)才添加到 ID 列表中
|
||||||
|
// 设备节点的 ID 不包含下划线
|
||||||
|
if (node.id && !node.id.toString().includes('_')) {
|
||||||
|
ids.push(node.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
traverse(treeData);
|
||||||
|
return ids;
|
||||||
|
};
|
||||||
|
|
||||||
|
return extractDeviceIds(rightTreeData.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
defineExpose({ getSelectedDeviceIds });
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.card-header {
|
.card-header {
|
||||||
|
|||||||
@@ -33,36 +33,23 @@
|
|||||||
multiple
|
multiple
|
||||||
placeholder="请选择标准设备"
|
placeholder="请选择标准设备"
|
||||||
>
|
>
|
||||||
<el-option
|
<!-- <el-option-->
|
||||||
v-for="option in pqStandardDevArray"
|
<!-- v-for="option in pqStandardDevArray"-->
|
||||||
:key="option.value"
|
<!-- :key="option.value"-->
|
||||||
:disabled="subPlanBindStandardDev.includes(option.label) || option.disabled"
|
<!-- :disabled="subPlanBindStandardDev.includes(option.label) || option.disabled"-->
|
||||||
:label="option.label"
|
<!-- :label="option.label"-->
|
||||||
:value="option.value"
|
<!-- :value="option.value"-->
|
||||||
/>
|
<!-- />-->
|
||||||
</el-select>
|
<el-option
|
||||||
</el-form-item>
|
v-for="option in pqStandardDevArray"
|
||||||
<el-form-item v-if="selectByMode" :label-width="110" label="检测项" prop="testItems">
|
:key="option.value"
|
||||||
<el-select
|
:disabled="subPlanBindStandardDev.includes(option.label) || option.disabled"
|
||||||
v-model="formContent.testItems"
|
:label="option.label"
|
||||||
:disabled="planType != 0 || allDisabled || !canEdited"
|
:value="option.value"
|
||||||
:max-collapse-tags="1"
|
/>
|
||||||
clearable
|
|
||||||
collapse-tags
|
|
||||||
collapse-tags-tooltip
|
|
||||||
filterable
|
|
||||||
multiple
|
|
||||||
placeholder="请选择检测项"
|
|
||||||
@blur="handleTestItemChange"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="(option, index) in secondLevelOptions"
|
|
||||||
:key="index"
|
|
||||||
:label="option.label"
|
|
||||||
:value="option.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item v-if="!selectByMode" :label-width="110" label="检测源" prop="sourceIds">
|
<el-form-item v-if="!selectByMode" :label-width="110" label="检测源" prop="sourceIds">
|
||||||
<el-select
|
<el-select
|
||||||
v-model="formContent.sourceIds"
|
v-model="formContent.sourceIds"
|
||||||
@@ -72,6 +59,7 @@
|
|||||||
collapse-tags
|
collapse-tags
|
||||||
filterable
|
filterable
|
||||||
placeholder="请选择检测源"
|
placeholder="请选择检测源"
|
||||||
|
@change="handleSourceChange"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="(option, index) in pqSourceArray"
|
v-for="(option, index) in pqSourceArray"
|
||||||
@@ -118,6 +106,7 @@
|
|||||||
:key="index"
|
:key="index"
|
||||||
:label="option.label"
|
:label="option.label"
|
||||||
:value="option.value"
|
:value="option.value"
|
||||||
|
:disabled="option.fluke!=1&&pqSourceArray?.find(item=>formContent.sourceIds==item.value)?.label.includes('FLUKE')"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -139,6 +128,28 @@
|
|||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item v-if="selectByMode" :label-width="110" label="检测项" prop="testItems">
|
||||||
|
<el-select
|
||||||
|
v-model="formContent.testItems"
|
||||||
|
:disabled="planType != 0 || allDisabled || !canEdited"
|
||||||
|
:max-collapse-tags="1"
|
||||||
|
clearable
|
||||||
|
collapse-tags
|
||||||
|
collapse-tags-tooltip
|
||||||
|
filterable
|
||||||
|
multiple
|
||||||
|
placeholder="请选择检测项"
|
||||||
|
@blur="handleTestItemChange"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="(option, index) in secondLevelOptions"
|
||||||
|
:disabled="shouldDisableTestItem(option)"
|
||||||
|
:key="index"
|
||||||
|
:label="option.label"
|
||||||
|
:value="option.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item :label-width="110" label="数据处理原则" prop="dataRule">
|
<el-form-item :label-width="110" label="数据处理原则" prop="dataRule">
|
||||||
<el-select
|
<el-select
|
||||||
v-model="formContent.dataRule"
|
v-model="formContent.dataRule"
|
||||||
@@ -232,6 +243,7 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="15">
|
<el-col :span="15">
|
||||||
<DevSelect
|
<DevSelect
|
||||||
|
ref="devSelectRef"
|
||||||
v-model="formContent.devIds"
|
v-model="formContent.devIds"
|
||||||
:titles="['被检设备列表', '已选被检设备列表']"
|
:titles="['被检设备列表', '已选被检设备列表']"
|
||||||
filter-placeholder="请输入内容搜索"
|
filter-placeholder="请输入内容搜索"
|
||||||
@@ -448,12 +460,14 @@ import { getTestConfig } from '@/api/system/base'
|
|||||||
import { getRegRes } from '@/api/system/versionRegister'
|
import { getRegRes } from '@/api/system/versionRegister'
|
||||||
import DevSelect from '@/views/plan/planList/components/devSelect.vue'
|
import DevSelect from '@/views/plan/planList/components/devSelect.vue'
|
||||||
import { WarningFilled } from '@element-plus/icons-vue'
|
import { WarningFilled } from '@element-plus/icons-vue'
|
||||||
|
import { el } from 'element-plus/es/locale'
|
||||||
|
|
||||||
const modeStore = useModeStore()
|
const modeStore = useModeStore()
|
||||||
const AppSceneStore = useAppSceneStore()
|
const AppSceneStore = useAppSceneStore()
|
||||||
const dictStore = useDictStore()
|
const dictStore = useDictStore()
|
||||||
// 定义弹出组件元信息
|
// 定义弹出组件元信息
|
||||||
const dialogFormRef = ref()
|
const dialogFormRef = ref()
|
||||||
|
const devSelectRef = ref()
|
||||||
const mode = ref()
|
const mode = ref()
|
||||||
const selectByMode = ref(true)
|
const selectByMode = ref(true)
|
||||||
const pqSourceList = ref<TestSource.ResTestSource[]>([]) //获取指定模式下所有检测源
|
const pqSourceList = ref<TestSource.ResTestSource[]>([]) //获取指定模式下所有检测源
|
||||||
@@ -465,7 +479,7 @@ const pqStandardDevList = ref<StandardDevice.ResPqStandardDevice[]>([]) //获取
|
|||||||
const pqReportName = ref<{ name: string }[]>([])
|
const pqReportName = ref<{ name: string }[]>([])
|
||||||
|
|
||||||
const pqSourceArray = ref<{ label: string; value: string }[]>()
|
const pqSourceArray = ref<{ label: string; value: string }[]>()
|
||||||
const pqScriptArray = ref<{ label: string; value: string }[]>()
|
const pqScriptArray = ref<{ label: string; value: string,fluke?:number|boolean}[]>()
|
||||||
const pqErrorArray = ref<{ label: string; value: string }[]>()
|
const pqErrorArray = ref<{ label: string; value: string }[]>()
|
||||||
const pqStandardDevArray = ref<{ label: string; value: string }[]>()
|
const pqStandardDevArray = ref<{ label: string; value: string }[]>()
|
||||||
const secondLevelOptions: any[] = []
|
const secondLevelOptions: any[] = []
|
||||||
@@ -485,6 +499,8 @@ const waveRecordSetting = ref(false)
|
|||||||
const realTimeSetting = ref(false)
|
const realTimeSetting = ref(false)
|
||||||
const statisticsSetting = ref(false)
|
const statisticsSetting = ref(false)
|
||||||
const flickerSetting = ref(false)
|
const flickerSetting = ref(false)
|
||||||
|
|
||||||
|
|
||||||
const generateData = () => {
|
const generateData = () => {
|
||||||
const manufacturerDict = dictStore.getDictData('Dev_Manufacturers')
|
const manufacturerDict = dictStore.getDictData('Dev_Manufacturers')
|
||||||
|
|
||||||
@@ -500,11 +516,20 @@ const generateData = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
i.checked = boundPqDevIds.length > 0 ? boundPqDevIds.includes(i.id) : false
|
i.checked = boundPqDevIds.length > 0 ? boundPqDevIds.includes(i.id) : false
|
||||||
if (i.checkState && i.checkState != 0) {
|
|
||||||
i.disabled = true
|
if (mode.value === '比对式') {
|
||||||
}
|
if (i.checkState && i.checkState != 0) {
|
||||||
if (allDisabled.value) {
|
i.disabled = true
|
||||||
i.disabled = true
|
}else {
|
||||||
|
i.disabled = false
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if (i.checkState && i.checkState != 0) {
|
||||||
|
i.disabled = true
|
||||||
|
}
|
||||||
|
if (allDisabled.value) {
|
||||||
|
i.disabled = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 排序逻辑
|
// 排序逻辑
|
||||||
@@ -520,8 +545,11 @@ const generateData = () => {
|
|||||||
// 最后按名称排序(升序)
|
// 最后按名称排序(升序)
|
||||||
return a.name.localeCompare(b.name)
|
return a.name.localeCompare(b.name)
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function useMetaInfo() {
|
function useMetaInfo() {
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
const titleType = ref('add')
|
const titleType = ref('add')
|
||||||
@@ -591,6 +619,18 @@ watch(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const handleSourceChange = () => {
|
||||||
|
let pqSource = pqSourceArray.value?.find(item => item.value === formContent.sourceIds)
|
||||||
|
|
||||||
|
if (pqSource?.label.includes('FLUKE')) {
|
||||||
|
|
||||||
|
let pqScript = pqScriptArray.value?.find(item => item.value === formContent.scriptId)
|
||||||
|
if (pqScript?.fluke!=1) {
|
||||||
|
formContent.scriptId = ''
|
||||||
|
ElMessage.warning('专用检测脚本只能使用福禄克检测源!')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// 清空formContent
|
// 清空formContent
|
||||||
const resetFormContent = () => {
|
const resetFormContent = () => {
|
||||||
Object.assign(formContent, {
|
Object.assign(formContent, {
|
||||||
@@ -729,6 +769,7 @@ const save = () => {
|
|||||||
emit('update:tab')
|
emit('update:tab')
|
||||||
} else {
|
} else {
|
||||||
formContent.sourceIds = null
|
formContent.sourceIds = null
|
||||||
|
formContent.devIds = devSelectRef.value?.getSelectedDeviceIds() || [];
|
||||||
await updatePlan(formContent)
|
await updatePlan(formContent)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -804,7 +845,7 @@ const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan:
|
|||||||
user_Result: any
|
user_Result: any
|
||||||
|
|
||||||
if (mode.value === '比对式') {
|
if (mode.value === '比对式') {
|
||||||
;[
|
[
|
||||||
PqErrSys_Result,
|
PqErrSys_Result,
|
||||||
pqDevList_Result,
|
pqDevList_Result,
|
||||||
pqReportName_Result,
|
pqReportName_Result,
|
||||||
@@ -849,7 +890,7 @@ const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan:
|
|||||||
const rule = dataRuleDict.find(item => item.code === 'Cp95_Value')
|
const rule = dataRuleDict.find(item => item.code === 'Cp95_Value')
|
||||||
formContent.dataRule = rule ? rule.id : ''
|
formContent.dataRule = rule ? rule.id : ''
|
||||||
} else {
|
} else {
|
||||||
;[pqSource_Result, PqScript_Result, PqErrSys_Result, pqDevList_Result, pqReportName_Result] =
|
[pqSource_Result, PqScript_Result, PqErrSys_Result, pqDevList_Result, pqReportName_Result] =
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
getTestSourceList(data),
|
getTestSourceList(data),
|
||||||
getPqScriptList(data),
|
getPqScriptList(data),
|
||||||
@@ -886,6 +927,7 @@ const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan:
|
|||||||
formContent.datasourceIds = datasourceDicts
|
formContent.datasourceIds = datasourceDicts
|
||||||
.filter(item => ['real', 'wave_data'].includes(item.code))
|
.filter(item => ['real', 'wave_data'].includes(item.code))
|
||||||
.map(item => item.code)
|
.map(item => item.code)
|
||||||
|
|
||||||
realTimeSetting.value = true
|
realTimeSetting.value = true
|
||||||
waveRecordSetting.value = true
|
waveRecordSetting.value = true
|
||||||
} else {
|
} else {
|
||||||
@@ -964,7 +1006,7 @@ const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
;[
|
[
|
||||||
pqSource_Result,
|
pqSource_Result,
|
||||||
PqScript_Result,
|
PqScript_Result,
|
||||||
PqErrSys_Result,
|
PqErrSys_Result,
|
||||||
@@ -1040,7 +1082,10 @@ const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan:
|
|||||||
formContent.devIds = boundData.map((i: any) => i.id) // 已绑定设备id集合
|
formContent.devIds = boundData.map((i: any) => i.id) // 已绑定设备id集合
|
||||||
}
|
}
|
||||||
handleDataSourceChange()
|
handleDataSourceChange()
|
||||||
handleTestItemChange(false)
|
if (mode.value === '比对式'){
|
||||||
|
handleTestItemChange(false)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pqToArray() //将对象转为数组
|
pqToArray() //将对象转为数组
|
||||||
@@ -1054,6 +1099,13 @@ const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan:
|
|||||||
formContent.testItems = data.testItems
|
formContent.testItems = data.testItems
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//数据源选中录波,检测项禁止频率和闪变
|
||||||
|
// if(formContent.datasourceIds.includes('wave_data')){
|
||||||
|
// const frequencyOption = secondLevelOptions.find(option => option.label.includes('频率'));
|
||||||
|
// if (frequencyOption && Array.isArray(formContent.testItems)) {
|
||||||
|
// formContent.testItems = formContent.testItems.filter(id => id !== frequencyOption.value);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode.value != '比对式') {
|
if (mode.value != '比对式') {
|
||||||
@@ -1079,7 +1131,7 @@ const open = async (sign: string, data: Plan.ReqPlan, currentMode: string, plan:
|
|||||||
formContent.name = ''
|
formContent.name = ''
|
||||||
// 新建子计划允许选择数据源
|
// 新建子计划允许选择数据源
|
||||||
const datasourceDicts = dictStore.getDictData('Datasource')
|
const datasourceDicts = dictStore.getDictData('Datasource')
|
||||||
formContent.datasourceIds = [datasourceDicts[0]?.code] ?? []
|
formContent.datasourceIds = datasourceDicts[0]?.code ? [datasourceDicts[0].code] : []
|
||||||
formContent.memberIds = []
|
formContent.memberIds = []
|
||||||
}
|
}
|
||||||
generateData()
|
generateData()
|
||||||
@@ -1189,7 +1241,8 @@ function pqToArray() {
|
|||||||
const sourceArray2 = Array.isArray(pqScriptList.value) ? pqScriptList.value : []
|
const sourceArray2 = Array.isArray(pqScriptList.value) ? pqScriptList.value : []
|
||||||
pqScriptArray.value = sourceArray2.map(item => ({
|
pqScriptArray.value = sourceArray2.map(item => ({
|
||||||
label: item.name || '',
|
label: item.name || '',
|
||||||
value: item.id || ''
|
value: item.id || '',
|
||||||
|
fluke:item.fluke
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const sourceArray3 = Array.isArray(pqErrSysList.value) ? pqErrSysList.value : []
|
const sourceArray3 = Array.isArray(pqErrSysList.value) ? pqErrSysList.value : []
|
||||||
@@ -1257,6 +1310,7 @@ const handleDataSourceChange = () => {
|
|||||||
const hasMinuteStats = selectedLabels.some(label => label.includes('分钟'))
|
const hasMinuteStats = selectedLabels.some(label => label.includes('分钟'))
|
||||||
const hasLuBo = selectedLabels.some(label => label.includes('录波'))
|
const hasLuBo = selectedLabels.some(label => label.includes('录波'))
|
||||||
|
|
||||||
|
|
||||||
if (hasThreeSeconds && hasMinuteStats) {
|
if (hasThreeSeconds && hasMinuteStats) {
|
||||||
ElMessage.warning('3s实时数据与分钟统计数据不能同时选择')
|
ElMessage.warning('3s实时数据与分钟统计数据不能同时选择')
|
||||||
formContent.datasourceIds = []
|
formContent.datasourceIds = []
|
||||||
@@ -1294,13 +1348,79 @@ const handleDataSourceChange = () => {
|
|||||||
} else {
|
} else {
|
||||||
statisticsSetting.value = false
|
statisticsSetting.value = false
|
||||||
}
|
}
|
||||||
if (hasLuBo) {
|
if (hasLuBo && selectedLabels.length === 1) {
|
||||||
waveRecordSetting.value = true
|
waveRecordSetting.value = true
|
||||||
} else {
|
|
||||||
|
//只勾选录波数据源时,从已选检测项中移除频率和闪变项
|
||||||
|
const frequencyOption = secondLevelOptions.find(option => option.label.includes('频率'));
|
||||||
|
const flickerOption = secondLevelOptions.find(option => option.label.includes('闪变'));
|
||||||
|
|
||||||
|
if (Array.isArray(formContent.testItems)) {
|
||||||
|
let filteredItems = [...formContent.testItems];
|
||||||
|
|
||||||
|
if (frequencyOption) {
|
||||||
|
filteredItems = filteredItems.filter(id => id !== frequencyOption.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flickerOption) {
|
||||||
|
filteredItems = filteredItems.filter(id => id !== flickerOption.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
formContent.testItems = filteredItems;
|
||||||
|
}
|
||||||
|
}else if (hasLuBo && selectedLabels.length > 1) {
|
||||||
|
waveRecordSetting.value = true
|
||||||
|
//数据源有多个且包含录波数据源时,从已选检测项中移除闪变项
|
||||||
|
const flickerOption = secondLevelOptions.find(option => option.label.includes('闪变'));
|
||||||
|
|
||||||
|
if (Array.isArray(formContent.testItems)) {
|
||||||
|
let filteredItems = [...formContent.testItems];
|
||||||
|
|
||||||
|
if (flickerOption) {
|
||||||
|
filteredItems = filteredItems.filter(id => id !== flickerOption.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
formContent.testItems = filteredItems;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
waveRecordSetting.value = false
|
waveRecordSetting.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 判断检测项是否应被禁用
|
||||||
|
const shouldDisableTestItem = computed(() => {
|
||||||
|
return (option: { label: string; value: string }) => {
|
||||||
|
// 获取当前选中的 datasourceIds,并确保为数组
|
||||||
|
const values = Array.isArray(formContent.datasourceIds)
|
||||||
|
? formContent.datasourceIds
|
||||||
|
: [formContent.datasourceIds].filter(Boolean) // 转为数组并过滤空值
|
||||||
|
|
||||||
|
const selectedLabels = values.map(value => {
|
||||||
|
const dictItem = dictStore.getDictData(dataSourceType.value).find(item => item.code === value);
|
||||||
|
return dictItem ? dictItem.name : '';
|
||||||
|
});
|
||||||
|
|
||||||
|
const hasLuBo = selectedLabels.some(label => label.includes('录波'));
|
||||||
|
|
||||||
|
// 当只勾选录波数据源时,禁用频率和闪变选项
|
||||||
|
if (hasLuBo && selectedLabels.length === 1) {
|
||||||
|
if (option.label.includes('频率') || option.label.includes('闪变')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 当数据源有多个且包含录波数据源时,只禁用闪变选项
|
||||||
|
else if (hasLuBo && selectedLabels.length > 1) {
|
||||||
|
if (option.label.includes('闪变')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//导入设备
|
//导入设备
|
||||||
const deviceImportExcel = ref<InstanceType<typeof ImportExcel> | null>(null)
|
const deviceImportExcel = ref<InstanceType<typeof ImportExcel> | null>(null)
|
||||||
|
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ const BaseHandleExceed = (files: File[]) => {
|
|||||||
baseFileName.value = newFile.name;
|
baseFileName.value = newFile.name;
|
||||||
excelFormData.append('baseFile', newFile as Blob, newFile.name);
|
excelFormData.append('baseFile', newFile as Blob, newFile.name);
|
||||||
|
|
||||||
formContent.value.detailFile = newFile.name
|
formContent.value.baseFile = newFile.name
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,11 +14,12 @@
|
|||||||
"encrypt": "ee-bin encrypt",
|
"encrypt": "ee-bin encrypt",
|
||||||
"icon": "ee-bin icon",
|
"icon": "ee-bin icon",
|
||||||
"re-sqlite": "electron-rebuild -f -w better-sqlite3",
|
"re-sqlite": "electron-rebuild -f -w better-sqlite3",
|
||||||
"build-w": "ee-bin build --cmds=win64",
|
"build-w": "ee-bin build --cmds=win64 && npm run rename-output",
|
||||||
"build-we": "ee-bin build --cmds=win_e",
|
"build-we": "ee-bin build --cmds=win_e",
|
||||||
"build-m": "ee-bin build --cmds=mac",
|
"build-m": "ee-bin build --cmds=mac",
|
||||||
"build-m-arm64": "ee-bin build --cmds=mac_arm64",
|
"build-m-arm64": "ee-bin build --cmds=mac_arm64",
|
||||||
"build-l": "ee-bin build --cmds=linux"
|
"build-l": "ee-bin build --cmds=linux",
|
||||||
|
"rename-output": "node -e \"const fs=require('fs'); const oldPath='out/win-unpacked'; const newPath='out/NPQS-9100'; if(fs.existsSync(oldPath)){if(fs.existsSync(newPath)) fs.rmSync(newPath,{recursive:true}); fs.renameSync(oldPath, newPath); console.log('Renamed to NPQS-9100');}\""
|
||||||
},
|
},
|
||||||
"repository": "https://github.com/dromara/electron-egg.git",
|
"repository": "https://github.com/dromara/electron-egg.git",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -34,7 +35,8 @@
|
|||||||
"debug": "^4.4.0",
|
"debug": "^4.4.0",
|
||||||
"ee-bin": "^4.1.4",
|
"ee-bin": "^4.1.4",
|
||||||
"electron": "^31.7.6",
|
"electron": "^31.7.6",
|
||||||
"electron-builder": "^25.1.8"
|
"electron-builder": "^25.1.8",
|
||||||
|
"icon-gen": "^5.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"autofit.js": "^3.2.8",
|
"autofit.js": "^3.2.8",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>NPQS9100 正在启动...</title>
|
<title>NPQS-9100自动检测平台 正在启动...</title>
|
||||||
<style>
|
<style>
|
||||||
* {
|
* {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -145,8 +145,8 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="loading-container">
|
<div class="loading-container">
|
||||||
<div class="logo">NPQS9100</div>
|
<div class="logo">NPQS-9100自动检测平台</div>
|
||||||
<div class="subtitle">南京灿能电气自动化 · 自动检测平台</div>
|
<div class="subtitle">南京灿能电力自动化股份有限公司</div>
|
||||||
|
|
||||||
<div class="status-text" id="statusText">正在初始化应用...</div>
|
<div class="status-text" id="statusText">正在初始化应用...</div>
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 739 KiB |
|
Before Width: | Height: | Size: 95 KiB |
|
Before Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 63 KiB |
|
Before Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 204 KiB |
|
Before Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 137 KiB |
|
Before Width: | Height: | Size: 61 KiB |